From: ColdSpirit Date: Tue, 21 Dec 2021 08:46:35 +0000 (+0400) Subject: Model update fix X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b1eee15bf53b7bf17c0cb0bff42d181204b63967;p=xonotic%2Fxonotic-data.pk3dir.git Model update fix --- diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc b/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc index d3b8a7025..b5c94c1ed 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc @@ -32,6 +32,12 @@ entity makeXonoticProfileTab() } registercvar("_menu_profile_color", color, 0); + string skin = cvar_string("_cl_playerskin"); + registercvar("_menu_profile_skin", skin, 0); + + string model = cvar_string("_cl_playermodel"); + registercvar("_menu_profile_model", model, 0); + return me; } @@ -44,9 +50,10 @@ void XonoticProfileTab_draw(entity me) else me.playerNameLabel.alpha = me.playerNameLabelAlpha; - // if values changed from console + // if values changed from console, update it in menu if (me.applyButton.disabled) { + // name field string inputName = cvar_string("_menu_profile_name"); if (name != inputName) { @@ -54,6 +61,7 @@ void XonoticProfileTab_draw(entity me) me.nameInput.loadCvars(me.nameInput); } + // color buttons string color = cvar_string("_cl_color"); string inputColor = cvar_string("_menu_profile_color"); if (color != inputColor) @@ -65,6 +73,19 @@ void XonoticProfileTab_draw(entity me) me.colorButtonGroup2[i].loadCvars(me.colorButtonGroup2[i]); } } + + // player model + string skin = cvar_string("_cl_playerskin"); + string skinInput = cvar_string("_menu_profile_skin"); + string model = cvar_string("_cl_playermodel"); + string modelInput = cvar_string("_menu_profile_model"); + if (skin != skinInput || model != modelInput) + { + cvar_set("_menu_profile_skin", skin); + cvar_set("_menu_profile_model", model); + me.playerModelSelector.loadCvars(me.playerModelSelector); + me.playerModelSelector.go(me.playerModelSelector, 0); + } } SUPER(XonoticProfileTab).draw(me); @@ -75,14 +96,14 @@ void language_selector_click(entity me, entity btn) } void XonoticProfileTab_fill(entity me) { - entity e, pms, label; + entity e, label; float i; me.applyButton = makeXonoticCommandButton(_("Apply immediately"), '0 0 0', "_cl_color \"$_menu_profile_color\"" "color -1 -1;" // apply colors contained in _cl_color "name \"$_menu_profile_name\";" - "playermodel $_cl_playermodel;" - "playerskin $_cl_playerskin;" + "playermodel $_menu_profile_model;" + "playerskin $_menu_profile_skin;" , COMMANDBUTTON_APPLY); me.applyButton.disableOnClick = true; @@ -124,15 +145,15 @@ void XonoticProfileTab_fill(entity me) me.TR(me); //me.TDempty(me, 0); // MODEL LEFT, COLOR RIGHT me.TDempty(me, 1); // MODEL RIGHT, COLOR LEFT - pms = makeXonoticPlayerModelSelector(); + me.playerModelSelector = makeXonoticPlayerModelSelector("_menu_profile_skin", "_menu_profile_model"); me.TD(me, 1, 0.3, e = makeXonoticButton("<<", '0 0 0')); e.onClick = PlayerModelSelector_Prev_Click; - e.onClickEntity = pms; + e.onClickEntity = me.playerModelSelector; e.applyButton = me.applyButton; - me.TD(me, 11.5, 1.4, pms); + me.TD(me, 11.5, 1.4, me.playerModelSelector); me.TD(me, 1, 0.3, e = makeXonoticButton(">>", '0 0 0')); e.onClick = PlayerModelSelector_Next_Click; - e.onClickEntity = pms; + e.onClickEntity = me.playerModelSelector; e.applyButton = me.applyButton; //me.setFirstColumn(me, me.currentColumn + 2); // MODEL LEFT, COLOR RIGHT diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_profile.qh b/qcsrc/menu/xonotic/dialog_multiplayer_profile.qh index 7e1379269..ccf772518 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_profile.qh +++ b/qcsrc/menu/xonotic/dialog_multiplayer_profile.qh @@ -14,5 +14,6 @@ CLASS(XonoticProfileTab, XonoticTab) ATTRIB(XonoticProfileTab, nameInput, entity); ATTRIB(XonoticProfileTab, colorButtonGroup1[COLOR_BUTTONS_COUNT], entity); ATTRIB(XonoticProfileTab, colorButtonGroup2[COLOR_BUTTONS_COUNT], entity); + ATTRIB(XonoticProfileTab, playerModelSelector, entity); ENDCLASS(XonoticProfileTab) entity makeXonoticProfileTab(); diff --git a/qcsrc/menu/xonotic/playermodel.qc b/qcsrc/menu/xonotic/playermodel.qc index 08518d131..a40e2aa9d 100644 --- a/qcsrc/menu/xonotic/playermodel.qc +++ b/qcsrc/menu/xonotic/playermodel.qc @@ -1,10 +1,10 @@ #include "playermodel.qh" -entity makeXonoticPlayerModelSelector() +entity makeXonoticPlayerModelSelector(string theSkinCvar, string theModelCvar) { entity me; me = NEW(XonoticPlayerModelSelector); - me.configureXonoticPlayerModelSelector(me); + me.configureXonoticPlayerModelSelector(me, theSkinCvar, theModelCvar); return me; } @@ -17,8 +17,10 @@ const float BUFMODELS_COUNT = 5; #define XONVOTE186 1 // (nyov) removal of model text description -void XonoticPlayerModelSelector_configureXonoticPlayerModelSelector(entity me) +void XonoticPlayerModelSelector_configureXonoticPlayerModelSelector(entity me, string theSkinCvar, string theModelCvar) { + me.skinCvar = theSkinCvar; + me.modelCvar = theModelCvar; me.configureXonoticImage(me, string_null, -1); } @@ -95,14 +97,14 @@ void XonoticPlayerModelSelector_loadCvars(entity me) string skin, modelname; float i; - skin = cvar_string("_cl_playerskin"); - modelname = cvar_string("_cl_playermodel"); + skin = cvar_string(me.skinCvar); + modelname = cvar_string(me.modelCvar); for(i = 0; i < me.numModels; ++i) { if(bufstr_get(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_MODEL) == modelname) - if(bufstr_get(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_SKIN) == skin) - break; + if(bufstr_get(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_SKIN) == skin) + break; } if(i >= me.numModels) // fail i = 0; @@ -147,8 +149,8 @@ void PlayerModelSelector_Prev_Click(entity btn, entity me) void XonoticPlayerModelSelector_saveCvars(entity me) { // we can't immediately apply here because of flood control - cvar_set("_cl_playermodel", me.currentModel); - cvar_set("_cl_playerskin", ftos(me.currentSkin)); + cvar_set(me.modelCvar, me.currentModel); + cvar_set(me.skinCvar, ftos(me.currentSkin)); } void XonoticPlayerModelSelector_draw(entity me) diff --git a/qcsrc/menu/xonotic/playermodel.qh b/qcsrc/menu/xonotic/playermodel.qh index 4635c6ccd..41607f8fc 100644 --- a/qcsrc/menu/xonotic/playermodel.qh +++ b/qcsrc/menu/xonotic/playermodel.qh @@ -2,7 +2,7 @@ #include "image.qh" CLASS(XonoticPlayerModelSelector, XonoticImage) - METHOD(XonoticPlayerModelSelector, configureXonoticPlayerModelSelector, void(entity)); + METHOD(XonoticPlayerModelSelector, configureXonoticPlayerModelSelector, void(entity, string, string)); METHOD(XonoticPlayerModelSelector, loadModels, void(entity)); METHOD(XonoticPlayerModelSelector, loadCvars, void(entity)); METHOD(XonoticPlayerModelSelector, saveCvars, void(entity)); @@ -24,7 +24,9 @@ CLASS(XonoticPlayerModelSelector, XonoticImage) ATTRIB(XonoticPlayerModelSelector, bufModels, float, -1); ATTRIB(XonoticPlayerModelSelector, numModels, float, -1); ATTRIB(XonoticPlayerModelSelector, idxModels, float, -1); + ATTRIB(XonoticPlayerModelSelector, skinCvar, string); + ATTRIB(XonoticPlayerModelSelector, modelCvar, string); ENDCLASS(XonoticPlayerModelSelector) -entity makeXonoticPlayerModelSelector(); +entity makeXonoticPlayerModelSelector(string theSkinCvar, string theModelCvar); void PlayerModelSelector_Next_Click(entity btn, entity me); void PlayerModelSelector_Prev_Click(entity btn, entity me);