From: terencehill Date: Thu, 10 Dec 2015 13:47:01 +0000 (+0100) Subject: Keep Apply buttons disabled, enable them as soon as user changes some setting that... X-Git-Tag: xonotic-v0.8.2~1213^2~6 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6fdf9ec10563a47738d4e207aa7246d16017de08;p=xonotic%2Fxonotic-data.pk3dir.git Keep Apply buttons disabled, enable them as soon as user changes some setting that needs to be applied. This code change is also useful to prevent coders from moving menu items from a window to another one without moving the relative command of the Apply button --- diff --git a/qcsrc/menu/item/button.qc b/qcsrc/menu/item/button.qc index a8c19483b..a81a0a22f 100644 --- a/qcsrc/menu/item/button.qc +++ b/qcsrc/menu/item/button.qc @@ -23,6 +23,8 @@ 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) @@ -44,6 +46,9 @@ 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) { @@ -85,7 +90,14 @@ 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; } diff --git a/qcsrc/menu/item/inputbox.qc b/qcsrc/menu/item/inputbox.qc index 89adfaae9..522801f81 100644 --- a/qcsrc/menu/item/inputbox.qc +++ b/qcsrc/menu/item/inputbox.qc @@ -31,6 +31,7 @@ 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) @@ -132,6 +133,8 @@ { m_play_click_sound(MENU_SOUND_CLEAR); me.setText(me, ""); + if(me.applyButton) + me.applyButton.disabled = false; me.cb_pressed = 0; return 1; } @@ -167,6 +170,8 @@ if (ascii >= 32 && ascii != 127) { me.enterText(me, chr(ascii)); + if(me.applyButton) + me.applyButton.disabled = false; return 1; } switch (key) @@ -192,6 +197,8 @@ { 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: @@ -202,9 +209,9 @@ 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; diff --git a/qcsrc/menu/item/slider.qc b/qcsrc/menu/item/slider.qc index e3220f57d..073d2eb79 100644 --- a/qcsrc/menu/item/slider.qc +++ b/qcsrc/menu/item/slider.qc @@ -124,34 +124,46 @@ { 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) @@ -236,6 +248,8 @@ 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 { @@ -244,6 +258,8 @@ 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) { diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc b/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc index 12adbfc2a..6c753a98c 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc @@ -33,6 +33,15 @@ void XonoticProfileTab_fill(entity me) { 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 @@ -75,10 +84,12 @@ void XonoticProfileTab_fill(entity me) 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 @@ -89,6 +100,7 @@ void XonoticProfileTab_fill(entity me) 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); @@ -98,6 +110,7 @@ void XonoticProfileTab_fill(entity 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; } // ==================== @@ -111,10 +124,12 @@ void XonoticProfileTab_fill(entity me) 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 @@ -161,6 +176,6 @@ void XonoticProfileTab_fill(entity me) #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 diff --git a/qcsrc/menu/xonotic/dialog_settings_audio.qc b/qcsrc/menu/xonotic/dialog_settings_audio.qc index be2778117..d44008a5d 100644 --- a/qcsrc/menu/xonotic/dialog_settings_audio.qc +++ b/qcsrc/menu/xonotic/dialog_settings_audio.qc @@ -23,6 +23,11 @@ entity makeXonoticAudioSettingsTab() 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", "-"); @@ -97,6 +102,7 @@ void XonoticAudioSettingsTab_fill(entity me) 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"))); @@ -113,6 +119,7 @@ void XonoticAudioSettingsTab_fill(entity me) 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", @@ -126,6 +133,7 @@ void XonoticAudioSettingsTab_fill(entity me) 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"), @@ -175,6 +183,6 @@ void XonoticAudioSettingsTab_fill(entity me) 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 diff --git a/qcsrc/menu/xonotic/dialog_settings_effects.qc b/qcsrc/menu/xonotic/dialog_settings_effects.qc index 2fa622e04..ed03e2f6e 100644 --- a/qcsrc/menu/xonotic/dialog_settings_effects.qc +++ b/qcsrc/menu/xonotic/dialog_settings_effects.qc @@ -33,19 +33,32 @@ float someShadowCvarIsEnabled(entity box) 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:"))); @@ -58,6 +71,7 @@ void XonoticEffectsSettingsTab_fill(entity me) 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")); @@ -67,6 +81,7 @@ void XonoticEffectsSettingsTab_fill(entity me) 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); @@ -81,6 +96,7 @@ void XonoticEffectsSettingsTab_fill(entity me) 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); { @@ -92,15 +108,18 @@ void XonoticEffectsSettingsTab_fill(entity me) 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; } } @@ -235,6 +254,6 @@ void XonoticEffectsSettingsTab_fill(entity me) 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 diff --git a/qcsrc/menu/xonotic/dialog_settings_game_weapons.qc b/qcsrc/menu/xonotic/dialog_settings_game_weapons.qc index 5b20e3842..86b160331 100644 --- a/qcsrc/menu/xonotic/dialog_settings_game_weapons.qc +++ b/qcsrc/menu/xonotic/dialog_settings_game_weapons.qc @@ -31,6 +31,12 @@ entity makeXonoticGameWeaponsSettingsTab() 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); @@ -38,23 +44,28 @@ void XonoticGameWeaponsSettingsTab_fill(entity me) 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); @@ -83,7 +94,6 @@ void XonoticGameWeaponsSettingsTab_fill(entity 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 diff --git a/qcsrc/menu/xonotic/dialog_settings_user.qc b/qcsrc/menu/xonotic/dialog_settings_user.qc index 93002ba02..07ab1bd0d 100644 --- a/qcsrc/menu/xonotic/dialog_settings_user.qc +++ b/qcsrc/menu/xonotic/dialog_settings_user.qc @@ -21,8 +21,9 @@ entity makeXonoticUserSettingsTab() 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); @@ -77,9 +78,10 @@ void XonoticUserSettingsTab_fill(entity me) 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 diff --git a/qcsrc/menu/xonotic/dialog_settings_video.qc b/qcsrc/menu/xonotic/dialog_settings_video.qc index fec137b72..d8e55cb9d 100644 --- a/qcsrc/menu/xonotic/dialog_settings_video.qc +++ b/qcsrc/menu/xonotic/dialog_settings_video.qc @@ -22,10 +22,21 @@ entity makeXonoticVideoSettingsTab() 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")); @@ -46,8 +57,10 @@ void XonoticVideoSettingsTab_fill(entity me) 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)"))); @@ -161,6 +174,6 @@ void XonoticVideoSettingsTab_fill(entity me) } 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 diff --git a/qcsrc/menu/xonotic/weaponslist.qc b/qcsrc/menu/xonotic/weaponslist.qc index 8a3fbd670..94347b325 100644 --- a/qcsrc/menu/xonotic/weaponslist.qc +++ b/qcsrc/menu/xonotic/weaponslist.qc @@ -12,6 +12,8 @@ CLASS(XonoticWeaponsList, XonoticListBox) 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); @@ -73,7 +75,11 @@ float XonoticWeaponsList_mouseDrag(entity me, vector pos) 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;