From 6741a4825b6c6ee725268f4878f7fb80b841cec5 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sun, 30 Aug 2015 20:14:19 +0200 Subject: [PATCH] Make sure all classes that control a cvar initialize cvarName to string_null in their configure method so they can be properly re-configured --- qcsrc/menu/xonotic/checkbox.qc | 7 ++----- qcsrc/menu/xonotic/checkbox_string.qc | 7 ++----- qcsrc/menu/xonotic/colorpicker_string.qc | 7 ++----- qcsrc/menu/xonotic/dialog_multiplayer_create.qc | 3 --- qcsrc/menu/xonotic/gametypebutton.qc | 7 ++----- qcsrc/menu/xonotic/inputbox.qc | 7 ++----- qcsrc/menu/xonotic/radiobutton.qc | 7 ++----- qcsrc/menu/xonotic/slider.qc | 6 ++---- qcsrc/menu/xonotic/textslider.qc | 7 ++----- 9 files changed, 16 insertions(+), 42 deletions(-) diff --git a/qcsrc/menu/xonotic/checkbox.qc b/qcsrc/menu/xonotic/checkbox.qc index 88fbfaa2a..bb63bffe4 100644 --- a/qcsrc/menu/xonotic/checkbox.qc +++ b/qcsrc/menu/xonotic/checkbox.qc @@ -76,11 +76,8 @@ void XonoticCheckBox_configureXonoticCheckBox(entity me, float theYesValue, floa me.yesValue = theYesValue; me.noValue = theNoValue; me.checked = 0; - if(theCvar) - { - me.cvarName = theCvar; - me.loadCvars(me); - } + me.cvarName = (theCvar) ? theCvar : string_null; + me.loadCvars(me); setZonedTooltip(me, theTooltip, theCvar); me.configureCheckBox(me, theText, me.fontSize, me.image); } diff --git a/qcsrc/menu/xonotic/checkbox_string.qc b/qcsrc/menu/xonotic/checkbox_string.qc index 15ee0921e..a93c9acf5 100644 --- a/qcsrc/menu/xonotic/checkbox_string.qc +++ b/qcsrc/menu/xonotic/checkbox_string.qc @@ -38,11 +38,8 @@ void XonoticCheckBoxString_configureXonoticCheckBoxString(entity me, string theY me.yesString = theYesValue; me.noString = theNoValue; me.checked = 0; - if(theCvar) - { - me.cvarName = theCvar; - me.loadCvars(me); - } + me.cvarName = (theCvar) ? theCvar : string_null; + me.loadCvars(me); me.configureCheckBox(me, theText, me.fontSize, me.image); } void XonoticCheckBoxString_setChecked(entity me, float foo) diff --git a/qcsrc/menu/xonotic/colorpicker_string.qc b/qcsrc/menu/xonotic/colorpicker_string.qc index fa830cd69..c8c26e4f3 100644 --- a/qcsrc/menu/xonotic/colorpicker_string.qc +++ b/qcsrc/menu/xonotic/colorpicker_string.qc @@ -33,11 +33,8 @@ entity makeXonoticColorpickerString(string theCvar, string theDefaultCvar) void XonoticColorpickerString_configureXonoticColorpickerString(entity me, string theCvar, string theDefaultCvar) { me.configureImage(me, me.image); - if(theCvar) - { - me.cvarName = theCvar; - me.loadCvars(me); - } + me.cvarName = (theCvar) ? theCvar : string_null; + me.loadCvars(me); } void XonoticColorpickerString_loadCvars(entity me) diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_create.qc b/qcsrc/menu/xonotic/dialog_multiplayer_create.qc index 619433068..0c27210aa 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_create.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_create.qc @@ -25,7 +25,6 @@ void GameType_ConfigureSliders(entity e, entity l, string pLabel, float pMin, fl { if(pCvar == "") { - e.cvarName = string_null; // FIXME XonoticTextSlider doesn't clear cvarName in configureXonoticTextSlider as it's not thought to re-configure itself e.configureXonoticTextSlider(e, string_null, string_null); l.setText(l, pLabel); e.disabled = l.disabled = true; @@ -246,8 +245,6 @@ void XonoticServerCreateTab_gameTypeChangeNotify(entity me) case MAPINFO_TYPE_KEYHUNT: x = "g_keyhunt_teams_override"; break; case MAPINFO_TYPE_TEAM_DEATHMATCH: x = "g_tdm_teams_override"; break; } - if(!x) - e.cvarName = string_null; // FIXME XonoticTextSlider doesn't clear cvarName in configureXonoticTextSlider as it's not thought to re-configure itself e.configureXonoticTextSlider(e, x, theTooltip); e.configureXonoticTextSliderValues(e); if(!x) diff --git a/qcsrc/menu/xonotic/gametypebutton.qc b/qcsrc/menu/xonotic/gametypebutton.qc index 161c62bfc..fb8086690 100644 --- a/qcsrc/menu/xonotic/gametypebutton.qc +++ b/qcsrc/menu/xonotic/gametypebutton.qc @@ -34,11 +34,8 @@ entity makeXonoticGametypeButton(float theGroup, string theCvar, string theText) } void XonoticGametypeButton_configureXonoticGametypeButton(entity me, float theGroup, string theCvar, string theText, string theTooltip) { - if(theCvar) - { - me.cvarName = theCvar; - me.loadCvars(me); - } + me.cvarName = (theCvar) ? theCvar : string_null; + me.loadCvars(me); setZonedTooltip(me, theTooltip, theCvar); me.configureRadioButton(me, theText, me.fontSize, me.image, theGroup, 0); me.align = 0.5; diff --git a/qcsrc/menu/xonotic/inputbox.qc b/qcsrc/menu/xonotic/inputbox.qc index c72339caf..6dc49c02e 100644 --- a/qcsrc/menu/xonotic/inputbox.qc +++ b/qcsrc/menu/xonotic/inputbox.qc @@ -53,11 +53,8 @@ void XonoticInputBox_configureXonoticInputBox(entity me, float doEditColorCodes, { me.configureInputBox(me, "", 0, me.fontSize, me.image); me.editColorCodes = doEditColorCodes; - if(theCvar) - { - me.cvarName = theCvar; - me.loadCvars(me); - } + me.cvarName = (theCvar) ? theCvar : string_null; + me.loadCvars(me); setZonedTooltip(me, theTooltip, theCvar); me.cursorPos = strlen(me.text); } diff --git a/qcsrc/menu/xonotic/radiobutton.qc b/qcsrc/menu/xonotic/radiobutton.qc index 7e9993924..272822077 100644 --- a/qcsrc/menu/xonotic/radiobutton.qc +++ b/qcsrc/menu/xonotic/radiobutton.qc @@ -40,11 +40,8 @@ entity makeXonoticRadioButton(float theGroup, string theCvar, string theValue, s } void XonoticRadioButton_configureXonoticRadioButton(entity me, float theGroup, string theCvar, string theValue, string theText, string theTooltip) { - if(theCvar) - { - me.cvarName = theCvar; - me.loadCvars(me); - } + me.cvarName = (theCvar) ? theCvar : string_null; + me.loadCvars(me); setZonedTooltip(me, theTooltip, theCvar); me.configureRadioButton(me, theText, me.fontSize, me.image, theGroup, 0); } diff --git a/qcsrc/menu/xonotic/slider.qc b/qcsrc/menu/xonotic/slider.qc index 1ffc7c987..ca65c6621 100644 --- a/qcsrc/menu/xonotic/slider.qc +++ b/qcsrc/menu/xonotic/slider.qc @@ -48,16 +48,14 @@ void XonoticSlider_configureXonoticSlider(entity me, float theValueMin, float th me.configureSliderVisuals(me, me.fontSize, me.align, me.valueSpace, me.image); + me.cvarName = (theCvar) ? theCvar : string_null; if(theCvar) - { // Prevent flickering of the slider button by initialising the // slider out of bounds to hide the button before loading the cvar me.configureSliderValues(me, theValueMin, theValueMin-theValueStep, theValueMax, theValueStep, theValueStep, vp); - me.cvarName = theCvar; - me.loadCvars(me); - } else me.configureSliderValues(me, theValueMin, theValueMin, theValueMax, theValueStep, theValueStep, vp); + me.loadCvars(me); setZonedTooltip(me, theTooltip, theCvar); } void XonoticSlider_setValue(entity me, float val) diff --git a/qcsrc/menu/xonotic/textslider.qc b/qcsrc/menu/xonotic/textslider.qc index d55dfc621..597772e34 100644 --- a/qcsrc/menu/xonotic/textslider.qc +++ b/qcsrc/menu/xonotic/textslider.qc @@ -43,11 +43,8 @@ entity makeXonoticTextSlider(string theCvar) void XonoticTextSlider_configureXonoticTextSlider(entity me, string theCvar, string theTooltip) { me.configureSliderVisuals(me, me.fontSize, me.align, me.valueSpace, me.image); - if(theCvar) - { - me.cvarName = theCvar; - // me.loadCvars(me); // don't load it yet - } + me.cvarName = (theCvar) ? theCvar : string_null; + // me.loadCvars(me); // don't load it yet setZonedTooltip(me, theTooltip, theCvar); } void XonoticTextSlider_setValue(entity me, float val) -- 2.39.2