ATTRIB(Button, allowFocusSound, float, 1)
ATTRIB(Button, pressed, float, 0)
ATTRIB(Button, clickTime, float, 0)
+ ATTRIB(Button, applyButton, entity, NULL)
+ ATTRIB(Button, disableOnClick, bool, false)
ATTRIB(Button, disabled, float, 0)
ATTRIB(Button, disabledAlpha, float, 0.3)
ATTRIB(Button, forcePressed, float, 0)
if (me.srcMulti) me.keepspaceLeft = 0;
else me.keepspaceLeft = min(0.8, absSize.x == 0 ? 0 : (absSize.y / absSize.x));
SUPER(Button).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
+
+ if(me.disableOnClick)
+ me.disabled = true; // initially disabled
}
void Button_configureButton(entity me, string txt, float sz, string gfx)
{
if (!me.disabled)
{
me.playClickSound(me);
- if (me.onClick) me.onClick(me, me.onClickEntity);
+ if (me.onClick)
+ {
+ if(me.applyButton)
+ me.applyButton.disabled = false;
+ me.onClick(me, me.onClickEntity);
+ if(me.disableOnClick)
+ me.disabled = true;
+ }
}
me.pressed = 0;
}
ATTRIB(InputBox, color, vector, '1 1 1')
ATTRIB(InputBox, colorF, vector, '1 1 1')
ATTRIB(InputBox, maxLength, float, 255) // if negative, it counts bytes, not chars
+ ATTRIB(InputBox, applyButton, entity, NULL)
ATTRIB(InputBox, enableClearButton, float, 1)
ATTRIB(InputBox, clearButton, entity, NULL)
{
m_play_click_sound(MENU_SOUND_CLEAR);
me.setText(me, "");
+ if(me.applyButton)
+ me.applyButton.disabled = false;
me.cb_pressed = 0;
return 1;
}
if (ascii >= 32 && ascii != 127)
{
me.enterText(me, chr(ascii));
+ if(me.applyButton)
+ me.applyButton.disabled = false;
return 1;
}
switch (key)
{
me.cursorPos -= 1;
me.setText(me, strcat(substring(me.text, 0, me.cursorPos), substring(me.text, me.cursorPos + 1, strlen(me.text) - me.cursorPos - 1)));
+ if(me.applyButton)
+ me.applyButton.disabled = false;
}
return 1;
case K_KP_DEL:
me.setText(me, "");
}
else
- {
me.setText(me, strcat(substring(me.text, 0, me.cursorPos), substring(me.text, me.cursorPos + 1, strlen(me.text) - me.cursorPos - 1)));
- }
+ if(me.applyButton)
+ me.applyButton.disabled = false;
return 1;
}
return 0;
{
if (inRange) me.setValue(me, median(me.valueMin, me.value - me.valueKeyStep, me.valueMax));
else me.setValue(me, me.valueMax);
+ if(me.applyButton)
+ me.applyButton.disabled = false;
return 1;
}
if (key == K_RIGHTARROW || key == K_KP_RIGHTARROW || key == K_MWHEELUP)
{
if (inRange) me.setValue(me, median(me.valueMin, me.value + me.valueKeyStep, me.valueMax));
else me.setValue(me, me.valueMin);
+ if(me.applyButton)
+ me.applyButton.disabled = false;
return 1;
}
if (key == K_PGDN || key == K_KP_PGDN)
{
if (inRange) me.setValue(me, median(me.valueMin, me.value - me.valuePageStep, me.valueMax));
else me.setValue(me, me.valueMax);
+ if(me.applyButton)
+ me.applyButton.disabled = false;
return 1;
}
if (key == K_PGUP || key == K_KP_PGUP)
{
if (inRange) me.setValue(me, median(me.valueMin, me.value + me.valuePageStep, me.valueMax));
else me.setValue(me, me.valueMin);
+ if(me.applyButton)
+ me.applyButton.disabled = false;
return 1;
}
if (key == K_HOME || key == K_KP_HOME)
{
me.setValue(me, me.valueMin);
+ if(me.applyButton)
+ me.applyButton.disabled = false;
return 1;
}
if (key == K_END || key == K_KP_END)
{
me.setValue(me, me.valueMax);
+ if(me.applyButton)
+ me.applyButton.disabled = false;
return 1;
}
// TODO more keys (NOTE also add them to Slider_keyUp)
pageValue = max(pageValue, clickValue);
if (inRange) me.setValue(me, median(me.valueMin, pageValue, me.valueMax));
else me.setValue(me, me.valueMax);
+ if(me.applyButton)
+ me.applyButton.disabled = false;
}
else
{
pageValue = min(pageValue, clickValue);
if (inRange) me.setValue(me, median(me.valueMin, pageValue, me.valueMax));
else me.setValue(me, me.valueMax);
+ if(me.applyButton)
+ me.applyButton.disabled = false;
}
if (pageValue == clickValue)
{
{
entity e, pms, label, box;
float i;
+ entity profileApplyButton = makeXonoticCommandButton(_("Apply immediately"), '0 0 0',
+ "color -1 -1;"
+ "name \"$_cl_name\";"
+ "playermodel $_cl_playermodel;"
+ "playerskin $_cl_playerskin;"
+ "sendcvar cl_allow_uidtracking;"
+ "sendcvar cl_allow_uid2name;"
+ , COMMANDBUTTON_APPLY);
+ profileApplyButton.disableOnClick = true;
// ==============
// NAME SECTION
me.TD(me, 1, 0.3, e = makeXonoticButton("<<", '0 0 0'));
e.onClick = PlayerModelSelector_Prev_Click;
e.onClickEntity = pms;
+ e.applyButton = profileApplyButton;
me.TD(me, 11.5, 1.4, pms);
me.TD(me, 1, 0.3, e = makeXonoticButton(">>", '0 0 0'));
e.onClick = PlayerModelSelector_Next_Click;
e.onClickEntity = pms;
+ e.applyButton = profileApplyButton;
//me.setFirstColumn(me, me.currentColumn + 2); // MODEL LEFT, COLOR RIGHT
me.gotoRC(me, me.currentRow, 0); me.setFirstColumn(me, me.currentColumn); // MODEL RIGHT, COLOR LEFT
if(mod(i, 5) == 0)
me.TR(me);
me.TDNoMargin(me, 1, 0.2, e = makeXonoticColorButton(1, 0, i), '0 1 0');
+ e.applyButton = profileApplyButton;
}
me.TR(me);
me.TR(me);
if(mod(i, 5) == 0)
me.TR(me);
me.TDNoMargin(me, 1, 0.2, e = makeXonoticColorButton(2, 1, i), '0 1 0');
+ e.applyButton = profileApplyButton;
}
// ====================
me.TR(me);
me.TDempty(me, 0.25);
me.TD(me, 1, 2.5, e = makeXonoticCheckBox(0, "cl_allow_uidtracking", _("Allow player statistics to track your client")));
+ e.applyButton = profileApplyButton;
me.TR(me);
me.TDempty(me, 0.25);
me.TD(me, 1, 2.5, e = makeXonoticCheckBox(0, "cl_allow_uid2name", _("Allow player statistics to use your nickname")));
- setDependent(e, "cl_allow_uidtracking", 1, 1);
+ e.applyButton = profileApplyButton;
+ setDependent(e, "cl_allow_uidtracking", 1, 1);
me.gotoRC(me, 4, 3.1); // TOP RIGHT
//me.gotoRC(me, 12.5, 3.1); // BOTTOM RIGHT
//me.gotoRC(me, 12.5, 0); // BOTTOM LEFT
#endif
me.gotoRC(me, me.rows - 1, 0);
- me.TD(me, 1, me.columns, makeXonoticCommandButton(_("Apply immediately"), '0 0 0', "color -1 -1;name \"$_cl_name\";playermodel $_cl_playermodel;playerskin $_cl_playerskin; sendcvar cl_allow_uidtracking; sendcvar cl_allow_uid2name;", COMMANDBUTTON_APPLY));
+ me.TD(me, 1, me.columns, profileApplyButton);
}
#endif
void XonoticAudioSettingsTab_fill(entity me)
{
entity e, s;
+ entity audioApplyButton = makeXonoticCommandButton(_("Apply immediately"), '0 0 0',
+ "snd_restart;"
+ "snd_attenuation_method_${menu_snd_attenuation_method};"
+ , COMMANDBUTTON_APPLY);
+ audioApplyButton.disableOnClick = true;
me.TR(me);
s = makeXonoticDecibelsSlider_T(-40, 0, 0.4, "mastervolume", "-");
me.TR(me);
me.TR(me);
me.TD(me, 1, 3, makeXonoticCheckBox(0, "menu_snd_attenuation_method", _("New style sound attenuation")));
+ e.applyButton = audioApplyButton;
me.TR(me);
me.TD(me, 1, 3, makeXonoticCheckBox(0, "snd_mutewhenidle", _("Mute sounds when not active")));
e.addValue(e, _("44.1 kHz"), "44100");
e.addValue(e, _("48 kHz"), "48000");
e.configureXonoticTextSliderValues(e);
+ e.applyButton = audioApplyButton;
me.TR(me);
me.TD(me, 1, 1, makeXonoticTextLabel(0, _("Channels:")));
me.TD(me, 1, 2, e = makeXonoticTextSlider_T("snd_channels",
e.addValue(e, _("6.1"), "7");
e.addValue(e, _("7.1"), "8");
e.configureXonoticTextSliderValues(e);
+ e.applyButton = audioApplyButton;
me.TR(me);
me.TR(me);
me.TD(me, 1, 3, e = makeXonoticCheckBox_T(0, "snd_swapstereo", _("Swap stereo output channels"),
me.TD(me, 1, 3, makeXonoticCheckBox(0, "showsound", _("Debug info about sounds")));
me.gotoRC(me, me.rows - 1, 0);
- me.TD(me, 1, me.columns, makeXonoticCommandButton(_("Apply immediately"), '0 0 0', "snd_restart; snd_attenuation_method_${menu_snd_attenuation_method}", COMMANDBUTTON_APPLY));
+ me.TD(me, 1, me.columns, audioApplyButton);
}
#endif
void XonoticEffectsSettingsTab_fill(entity me)
{
entity e, s;
+ entity effectsApplyButton = makeXonoticCommandButton(_("Apply immediately"), '0 0 0', "vid_restart", COMMANDBUTTON_APPLY);
+ effectsApplyButton.disableOnClick = true;
float n;
me.TR(me);
me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Quality preset:")));
n = 5 + 2 * boolean(cvar("developer"));
if(cvar("developer"))
+ {
me.TD(me, 1, 5 / n, e = makeXonoticCommandButton(ZCTX(_("PRE^OMG!")), '1 0 1', "exec effects-omg.cfg", 0));
+ e.applyButton = effectsApplyButton;
+ }
me.TD(me, 1, 5 / n, e = makeXonoticCommandButton(ZCTX(_("PRE^Low")), '0 0 0', "exec effects-low.cfg", 0));
+ e.applyButton = effectsApplyButton;
me.TD(me, 1, 5 / n, e = makeXonoticCommandButton(ZCTX(_("PRE^Medium")), '0 0 0', "exec effects-med.cfg", 0));
+ e.applyButton = effectsApplyButton;
me.TD(me, 1, 5 / n, e = makeXonoticCommandButton(ZCTX(_("PRE^Normal")), '0 0 0', "exec effects-normal.cfg", 0));
+ e.applyButton = effectsApplyButton;
me.TD(me, 1, 5 / n, e = makeXonoticCommandButton(ZCTX(_("PRE^High")), '0 0 0', "exec effects-high.cfg", 0));
+ e.applyButton = effectsApplyButton;
me.TD(me, 1, 5 / n, e = makeXonoticCommandButton(ZCTX(_("PRE^Ultra")), '0 0 0', "exec effects-ultra.cfg", 0));
+ e.applyButton = effectsApplyButton;
if(cvar("developer"))
+ {
me.TD(me, 1, 5 / n, e = makeXonoticCommandButton(ZCTX(_("PRE^Ultimate")), '0.5 0 0', "exec effects-ultimate.cfg", 0));
+ e.applyButton = effectsApplyButton;
+ }
me.gotoRC(me, 1.25, 0);
me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Geometry detail:")));
e.addValue(e, ZCTX(_("DET^Best")), "2");
e.addValue(e, ZCTX(_("DET^Insane")), "1");
e.configureXonoticTextSliderValues(e);
+ e.applyButton = effectsApplyButton;
me.TR(me);
me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Player detail:")));
me.TD(me, 1, 2, e = makeXonoticTextSlider("cl_playerdetailreduction"));
e.addValue(e, ZCTX(_("PDET^Good")), "1");
e.addValue(e, ZCTX(_("PDET^Best")), "0");
e.configureXonoticTextSliderValues(e);
+ e.applyButton = effectsApplyButton;
me.TR(me);
me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Texture resolution:")));
setDependent(e, "r_showsurfaces", 0, 0);
e.addValue(e, ZCTX(_("RES^Best")), "-2");
e.configureXonoticTextSliderValues(e);
setDependent(e, "r_showsurfaces", 0, 0);
+ e.applyButton = effectsApplyButton;
me.TR(me);
me.TDempty(me, 0.2);
{
case 0:
me.TD(me, 1, 2.8, e = makeXonoticCheckBox(1, "r_texture_dds_load", _("Avoid lossy texture compression")));
e.disabled = 1; // just show the checkbox anyway, but with no ability to control it
+ e.applyButton = effectsApplyButton;
break;
case 1:
me.TD(me, 1, 2.8, e = makeXonoticCheckBox(1, "r_texture_dds_load", _("Avoid lossy texture compression")));
setDependent(e, "r_showsurfaces", 0, 0);
+ e.applyButton = effectsApplyButton;
break;
case 2:
me.TD(me, 1, 2.8, e = makeXonoticCheckBox(1, "r_texture_dds_load", _("Avoid lossy texture compression")));
setDependent(e, "r_showsurfaces", 0, 0);
makeMulti(e, "gl_texturecompression");
+ e.applyButton = effectsApplyButton;
break;
}
}
setDependent(e, "cl_particles", 1, 1);
me.gotoRC(me, me.rows - 1, 0);
- me.TD(me, 1, me.columns, makeXonoticCommandButton(_("Apply immediately"), '0 0 0', "vid_restart", COMMANDBUTTON_APPLY));
+ me.TD(me, 1, me.columns, effectsApplyButton);
}
#endif
void XonoticGameWeaponsSettingsTab_fill(entity me)
{
entity e;
+ entity weaponsApplyButton = makeXonoticCommandButton(_("Apply immediately"), '0 0 0',
+ "sendcvar cl_autoswitch;"
+ "sendcvar cl_weaponpriority;"
+ "sendcvar cl_weaponimpulsemode;"
+ , COMMANDBUTTON_APPLY);
+ weaponsApplyButton.disableOnClick = true;
me.TR(me);
me.TDempty(me, 0.25);
me.TR(me);
me.TDempty(me, 0.25);
me.TD(me, 9, 2.5, e = me.weaponsList = makeXonoticWeaponsList());
+ e.applyButton = weaponsApplyButton;
me.gotoRC(me, 10, 0.25);
me.TD(me, 1, 1.25, e = makeXonoticButton(_("Up"), '0 0 0'));
e.onClick = WeaponsList_MoveUp_Click;
e.onClickEntity = me.weaponsList;
+ e.applyButton = weaponsApplyButton;
me.TD(me, 1, 1.25, e = makeXonoticButton(_("Down"), '0 0 0'));
e.onClick = WeaponsList_MoveDown_Click;
e.onClickEntity = me.weaponsList;
+ e.applyButton = weaponsApplyButton;
me.gotoRC(me, 0, 3); me.setFirstColumn(me, me.currentColumn);
me.TD(me, 1, 3, e = makeXonoticCheckBox_T(0, "cl_weaponpriority_useforcycling", _("Use priority list for weapon cycling"),
_("Make use of the list above when cycling through weapons with the mouse wheel")));
me.TR(me);
me.TD(me, 1, 3, e = makeXonoticCheckBox(1, "cl_weaponimpulsemode", _("Cycle through only usable weapon selections")));
+ e.applyButton = weaponsApplyButton;
me.TR(me);
me.TR(me);
me.TD(me, 1, 3, e = makeXonoticCheckBox_T(0, "cl_autoswitch", _("Auto switch weapons on pickup"),
_("Automatically switch to newly picked up weapons if they are better than what you are carrying")));
+ e.applyButton = weaponsApplyButton;
me.TR(me);
me.TD(me, 1, 3, e = makeXonoticCheckBox(0, "cl_unpress_attack_on_weapon_switch", _("Release attack buttons when you switch weapons")));
me.TR(me);
me.TD(me, 1, 2.8, e = makeXonoticCheckBox(0, "cl_bobmodel", _("Gun model bobbing")));
setDependent(e, "r_drawviewmodel", 1, 1);
me.gotoRC(me, me.rows - 1, 0); me.setFirstColumn(me, me.currentColumn);
- me.TD(me, 1, me.columns, makeXonoticCommandButton(_("Apply immediately"), '0 0 0',
- "sendcvar cl_autoswitch; sendcvar cl_weaponpriority; sendcvar cl_weaponimpulsemode", COMMANDBUTTON_APPLY));
+ me.TD(me, 1, me.columns, weaponsApplyButton);
}
#endif
void XonoticUserSettingsTab_fill(entity me)
{
- entity e;
- entity sk;
+ entity e, sk;
+ entity userApplyButton = makeXonoticCommandButton(_("Apply immediately"), '0 0 0', "sendcvar cl_gentle;", COMMANDBUTTON_APPLY);
+ userApplyButton.disableOnClick = true;
me.TR(me);
me.TDempty(me, 0.25);
me.gotoRC(me, 11.5, 3.25); me.setFirstColumn(me, me.currentColumn);
me.TD(me, 1, 2.5, e = makeXonoticCheckBox_T(0, "cl_gentle", _("Disable gore effects and harsh language"),
_("Replace blood and gibs with content that does not have any gore effects (default: disabled)")));
+ e.applyButton = userApplyButton;
me.gotoRC(me, me.rows - 1, 0);
- me.TD(me, 1, 6, makeXonoticCommandButton(_("Apply immediately"), '0 0 0', "sendcvar cl_gentle;", COMMANDBUTTON_APPLY));
+ me.TD(me, 1, 6, userApplyButton);
}
#endif
void XonoticVideoSettingsTab_fill(entity me)
{
entity e;
+ entity videoApplyButton = makeXonoticCommandButton(_("Apply immediately"), '0 0 0',
+ "vid_width $_menu_vid_width;"
+ "vid_height $_menu_vid_height;"
+ "vid_pixelheight $_menu_vid_pixelheight;"
+ "vid_desktopfullscreen $_menu_vid_desktopfullscreen;"
+ "menu_cmd update_conwidths_before_vid_restart;"
+ "vid_restart;"
+ "menu_cmd sync;"
+ , COMMANDBUTTON_APPLY);
+ videoApplyButton.disableOnClick = true;
me.TR(me);
me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Resolution:")));
me.TD(me, 1, 2, e = makeXonoticResolutionSlider());
+ e.applyButton = videoApplyButton;
me.TR(me);
me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Font/UI size:")));
me.TD(me, 1, 2, e = makeXonoticTextSlider("menu_vid_scale"));
e.addValue(e, _("16bit"), "16");
e.addValue(e, _("32bit"), "32");
e.configureXonoticTextSliderValues(e);
+ e.applyButton = videoApplyButton;
me.TR(me);
me.TD(me, 1, 1, e = makeXonoticCheckBox(0, "vid_fullscreen", _("Full screen")));
+ e.applyButton = videoApplyButton;
me.TD(me, 1, 2, e = makeXonoticCheckBox_T(0, "vid_vsync", _("Vertical Synchronization"),
_("Enable vertical synchronization to prevent tearing, will cap your fps to the screen refresh rate (default: disabled)")));
}
me.gotoRC(me, me.rows - 1, 0);
- me.TD(me, 1, me.columns, makeXonoticCommandButton(_("Apply immediately"), '0 0 0', "vid_width $_menu_vid_width; vid_height $_menu_vid_height; vid_pixelheight $_menu_vid_pixelheight; vid_desktopfullscreen $_menu_vid_desktopfullscreen; menu_cmd update_conwidths_before_vid_restart; vid_restart; menu_cmd sync", COMMANDBUTTON_APPLY));
+ me.TD(me, 1, me.columns, videoApplyButton);
}
#endif
ATTRIB(XonoticWeaponsList, realFontSize, vector, '0 0 0')
ATTRIB(XonoticWeaponsList, realUpperMargin, float, 0)
METHOD(XonoticWeaponsList, mouseDrag, float(entity, vector));
+
+ ATTRIB(XonoticWeaponsList, applyButton, entity, NULL)
ENDCLASS(XonoticWeaponsList)
entity makeXonoticWeaponsList();
void WeaponsList_MoveUp_Click(entity btn, entity me);
if(me.pressed != 1) // don't change priority if the person is just scrolling
{
if(me.selectedItem != i)
+ {
+ if(me.applyButton)
+ me.applyButton.disabled = false;
cvar_set("cl_weaponpriority", swapInPriorityList(cvar_string("cl_weaponpriority"), me.selectedItem, i));
+ }
}
return f;