From 5d0b4d4921a83bf7de39371ad04b5a3909dac5fa Mon Sep 17 00:00:00 2001 From: ColdSpirit Date: Sat, 25 Dec 2021 19:45:33 +0400 Subject: [PATCH] Change menu cvar names, move it to define strings --- .../xonotic/dialog_multiplayer_profile.qc | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc b/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc index 330514f82..8f30c8937 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc @@ -12,6 +12,11 @@ #include "checkbox.qh" #include "radiobutton.qh" +#define MENU_CVAR_NAME "_menu_cl_name" +#define MENU_CVAR_COLOR "_menu_cl_color" +#define MENU_CVAR_SKIN "_menu_cl_playerskin" +#define MENU_CVAR_MODEL "_menu_cl_playermodel" + entity makeXonoticProfileTab() { entity me; @@ -20,7 +25,7 @@ entity makeXonoticProfileTab() // profile menu specific cvars string name = cvar_string("_cl_name"); - registercvar("_menu_profile_name", name, 0); + registercvar(MENU_CVAR_NAME, name, 0); string color = cvar_string("_cl_color"); // if color unset, set random color @@ -30,13 +35,13 @@ entity makeXonoticProfileTab() float randomColor = 16 * floor(random() * COLOR_BUTTONS_COUNT) + floor(random() * COLOR_BUTTONS_COUNT); cvar_set("_cl_color", ftos(randomColor)); } - registercvar("_menu_profile_color", color, 0); + registercvar(MENU_CVAR_COLOR, color, 0); string skin = cvar_string("_cl_playerskin"); - registercvar("_menu_profile_skin", skin, 0); + registercvar(MENU_CVAR_SKIN, skin, 0); string model = cvar_string("_cl_playermodel"); - registercvar("_menu_profile_model", model, 0); + registercvar(MENU_CVAR_MODEL, model, 0); return me; } @@ -54,19 +59,19 @@ void XonoticProfileTab_draw(entity me) if (me.applyButton.disabled) { // name field - string inputName = cvar_string("_menu_profile_name"); + string inputName = cvar_string(MENU_CVAR_NAME); if (name != inputName) { - cvar_set("_menu_profile_name", name); + cvar_set(MENU_CVAR_NAME, name); me.nameInput.loadCvars(me.nameInput); } // color buttons string color = cvar_string("_cl_color"); - string inputColor = cvar_string("_menu_profile_color"); + string inputColor = cvar_string(MENU_CVAR_COLOR); if (color != inputColor) { - cvar_set("_menu_profile_color", color); + cvar_set(MENU_CVAR_COLOR, color); for (int i = 0; i < COLOR_BUTTONS_COUNT; i++) { me.colorButtonGroup1[i].loadCvars(me.colorButtonGroup1[i]); @@ -76,13 +81,13 @@ void XonoticProfileTab_draw(entity me) // player model string skin = cvar_string("_cl_playerskin"); - string skinInput = cvar_string("_menu_profile_skin"); + string skinInput = cvar_string(MENU_CVAR_SKIN); string model = cvar_string("_cl_playermodel"); - string modelInput = cvar_string("_menu_profile_model"); + string modelInput = cvar_string(MENU_CVAR_MODEL); if (skin != skinInput || model != modelInput) { - cvar_set("_menu_profile_skin", skin); - cvar_set("_menu_profile_model", model); + cvar_set(MENU_CVAR_SKIN, skin); + cvar_set(MENU_CVAR_MODEL, model); me.playerModelSelector.loadCvars(me.playerModelSelector); me.playerModelSelector.go(me.playerModelSelector, 0); } @@ -99,11 +104,11 @@ void XonoticProfileTab_fill(entity me) entity e, label; float i; me.applyButton = makeXonoticCommandButton(_("Apply immediately"), '0 0 0', - "_cl_color \"$_menu_profile_color\"" + "_cl_color \"$"MENU_CVAR_COLOR"\"" "color -1 -1;" // apply colors contained in _cl_color - "name \"$_menu_profile_name\";" - "playermodel $_menu_profile_model;" - "playerskin $_menu_profile_skin;" + "name \"$"MENU_CVAR_NAME"\";" + "playermodel $"MENU_CVAR_MODEL";" + "playerskin $"MENU_CVAR_SKIN";" , COMMANDBUTTON_APPLY); me.applyButton.disableOnClick = true; @@ -122,7 +127,7 @@ void XonoticProfileTab_fill(entity me) label.fontSize = SKINFONTSIZE_TITLE; me.gotoRC(me, 2.5, 0); - me.TD(me, 1, 3.0, me.nameInput = makeXonoticInputBox_T(1, "_menu_profile_name", + me.TD(me, 1, 3.0, me.nameInput = makeXonoticInputBox_T(1, MENU_CVAR_NAME, _("Name under which you will appear in the game"))); me.nameInput.forbiddenCharacters = "\r\n\\\"$"; // don't care, isn't getting saved me.nameInput.maxLength = -127; // negative means encoded length in bytes @@ -145,7 +150,7 @@ void XonoticProfileTab_fill(entity me) me.TR(me); //me.TDempty(me, 0); // MODEL LEFT, COLOR RIGHT me.TDempty(me, 1); // MODEL RIGHT, COLOR LEFT - me.playerModelSelector = makeXonoticPlayerModelSelector("_menu_profile_skin", "_menu_profile_model"); + me.playerModelSelector = makeXonoticPlayerModelSelector(MENU_CVAR_SKIN, MENU_CVAR_MODEL); me.TD(me, 1, 0.3, e = makeXonoticButton("<<", '0 0 0')); e.onClick = PlayerModelSelector_Prev_Click; e.onClickEntity = me.playerModelSelector; @@ -164,7 +169,7 @@ void XonoticProfileTab_fill(entity me) { if(mod(i, 5) == 0) me.TR(me); - me.TDNoMargin(me, 1, 0.2, me.colorButtonGroup1[i] = makeXonoticColorButton("_menu_profile_color", 1, 0, i), '0 1 0'); + me.TDNoMargin(me, 1, 0.2, me.colorButtonGroup1[i] = makeXonoticColorButton(MENU_CVAR_COLOR, 1, 0, i), '0 1 0'); me.colorButtonGroup1[i].applyButton = me.applyButton; } me.TR(me); @@ -174,7 +179,7 @@ void XonoticProfileTab_fill(entity me) { if(mod(i, 5) == 0) me.TR(me); - me.TDNoMargin(me, 1, 0.2, me.colorButtonGroup2[i] = makeXonoticColorButton("_menu_profile_color", 2, 1, i), '0 1 0'); + me.TDNoMargin(me, 1, 0.2, me.colorButtonGroup2[i] = makeXonoticColorButton(MENU_CVAR_COLOR, 2, 1, i), '0 1 0'); me.colorButtonGroup2[i].applyButton = me.applyButton; } -- 2.39.2