From 3ef2806e71b7678f7a641a774588c07b6ae8b0eb Mon Sep 17 00:00:00 2001 From: terencehill Date: Thu, 12 Oct 2023 19:22:06 +0200 Subject: [PATCH] Update MENU_CVAR_NAME in XonoticProfileTab_draw only on menu init. No need to do it when _menu_profile_apply_button_command_executed is 1 since the apply button command has already updated it --- qcsrc/menu/menu.qc | 2 +- qcsrc/menu/xonotic/dialog_multiplayer_profile.qc | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/qcsrc/menu/menu.qc b/qcsrc/menu/menu.qc index 453737b02..a6a796428 100644 --- a/qcsrc/menu/menu.qc +++ b/qcsrc/menu/menu.qc @@ -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); diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc b/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc index a101ef76c..c0d72a61b 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc @@ -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"); -- 2.39.2