From 63288d9d2991dcb4845f78f4a0f4d0c833365fb8 Mon Sep 17 00:00:00 2001 From: terencehill Date: Tue, 28 Dec 2021 18:24:36 +0100 Subject: [PATCH] Menu Profile: make work the Apply button on name change in DP master --- .../menu/xonotic/dialog_multiplayer_profile.qc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc b/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc index e885ee0b0..402a2c88b 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_profile.qc @@ -48,11 +48,24 @@ void XonoticProfileTab_draw(entity me) { // name field string inputName = cvar_string(MENU_CVAR_NAME); + // WORKAROUND + // in DP master when the Apply button is pressed cmd("_cl_name $_menu_cl_name") takes 2 frames + // to update _cl_name, so in the following code we have to delay the update of _menu_cl_name + // by one frame to avoid setting _menu_cl_name to the old _cl_name value + static bool name_changed; if (name != inputName) { - cvar_set(MENU_CVAR_NAME, name); - me.nameInput.loadCvars(me.nameInput); + if (name_changed == false) + name_changed = true; // don't update _menu_cl_name this frame + else + { + cvar_set(MENU_CVAR_NAME, name); + me.nameInput.loadCvars(me.nameInput); + name_changed = false; + } } + else + name_changed = false; // color buttons string color = cvar_string("_cl_color"); -- 2.39.2