}
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;
}
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)
{
me.nameInput.loadCvars(me.nameInput);
}
+ // color buttons
string color = cvar_string("_cl_color");
string inputColor = cvar_string("_menu_profile_color");
if (color != inputColor)
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);
}
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;
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
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();
#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;
}
#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);
}
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;
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)
#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));
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);