]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Update MENU_CVAR_NAME in XonoticProfileTab_draw only on menu init. No need to do...
authorterencehill <piuntn@gmail.com>
Thu, 12 Oct 2023 17:22:06 +0000 (19:22 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 12 Oct 2023 17:22:06 +0000 (19:22 +0200)
qcsrc/menu/menu.qc
qcsrc/menu/xonotic/dialog_multiplayer_profile.qc

index 453737b02d2aadef95a90b1d979a63bc4eb13cb2..a6a79642897850c23882962b743fe24155f1f2e8 100644 (file)
@@ -67,7 +67,7 @@ void m_init()
        }
        prvm_language = strzone(prvm_language);
        cvar_set("_menu_prvm_language", prvm_language);
-       cvar_set("_menu_profile_apply_button_command_executed", "1");
+       cvar_set("_menu_profile_apply_button_command_executed", "-1");
 
 #ifdef WATERMARK
                LOG_TRACEF("^4MQC Build information: ^1%s", WATERMARK);
index a101ef76cbaa6d1f1449fd4d35b1099ad29ac613..c0d72a61b099d7e1164cabd91a751fa77f456f16 100644 (file)
@@ -44,18 +44,22 @@ void XonoticProfileTab_draw(entity me)
        else
                me.playerNameLabel.alpha = me.playerNameLabelAlpha;
 
-       // if this cvar is set then we are sure the apply button command has really taken effect
+       // when this cvar is set to 1 we are sure the apply button command has really taken effect
        // we can't assume that it gets executed in one frame due to how cmd works
-       if (autocvar__menu_profile_apply_button_command_executed)
+       if (autocvar__menu_profile_apply_button_command_executed == -1) // set to -1 on menu init
        {
                cvar_set("_menu_profile_apply_button_command_executed", "0");
-               // name field
+               // initialize the input name box text
                string inputName  = cvar_string(MENU_CVAR_NAME);
                if (name != inputName)
                {
                        cvar_set(MENU_CVAR_NAME, name);
                        me.nameInput.loadCvars(me.nameInput);
                }
+       }
+       else if (autocvar__menu_profile_apply_button_command_executed == 1) // set to 1 by the apply button command
+       {
+               cvar_set("_menu_profile_apply_button_command_executed", "0");
 
                // color buttons
                string color = cvar_string("_cl_color");