]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Keep Apply buttons disabled, enable them as soon as user changes some setting that...
authorterencehill <piuntn@gmail.com>
Thu, 10 Dec 2015 13:47:01 +0000 (14:47 +0100)
committerGitLab <gitlab@gitlab.com>
Thu, 28 Jan 2016 20:16:18 +0000 (20:16 +0000)
qcsrc/menu/item/button.qc
qcsrc/menu/item/inputbox.qc
qcsrc/menu/item/slider.qc
qcsrc/menu/xonotic/dialog_multiplayer_profile.qc
qcsrc/menu/xonotic/dialog_settings_audio.qc
qcsrc/menu/xonotic/dialog_settings_effects.qc
qcsrc/menu/xonotic/dialog_settings_game_weapons.qc
qcsrc/menu/xonotic/dialog_settings_user.qc
qcsrc/menu/xonotic/dialog_settings_video.qc
qcsrc/menu/xonotic/weaponslist.qc

index a8c19483b469f3270ff546f02627cc455b79a278..a81a0a22f78a3cb5d57479eae08f23cd4a565258 100644 (file)
@@ -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)
        {
                        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;
                }
index 89adfaae934425dcc46ca6b024a79fac384dc24e..522801f818d92a37747560dc1da201fdc79b2574 100644 (file)
@@ -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)
                        {
                                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;
index e3220f57d9d49c392d8f6a8fa036bb1fb24091c0..073d2eb79a0653ced1f87e2be8d50dd9b7b5e9c5 100644 (file)
                {
                        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)
                        {
index 12adbfc2aaa6c2e70c2fa150a445bdf85e433c5b..6c753a98c669e3beb29c53425b9658fa4193a30c 100644 (file)
@@ -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
index be2778117047a1f7d5e67e0710e1210cf744cc6e..d44008a5da7e0d291e3befae1e3e991963101287 100644 (file)
@@ -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
index 2fa622e041a1ee3069878f19efd3ce09b9b1b19a..ed03e2f6e867b5f965fd6d01fd242536509ffa2d 100644 (file)
@@ -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
index 5b20e384219e5d6095933e2b225be6f48df71073..86b160331d3be5d512ff0a0f1d8893ec394948ce 100644 (file)
@@ -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
index 93002ba02c5f4cf9b52576eee3f521486f01129f..07ab1bd0d1d845a5fec09ecab657d4b328dc4cbd 100644 (file)
@@ -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
index fec137b72e060b96e9dca18498b083271ed34f19..d8e55cb9da27829f2143cde516c7288627d8ee3c 100644 (file)
@@ -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
index 8a3fbd670e669d42640e1864a917f481f4f5ac7f..94347b3255b1fcfc587e5334d5e3992d896a3a3a 100644 (file)
@@ -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;