]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/textslider.c
fix the team number slider, hopefully
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / textslider.c
index 0c0da18aa3f4bc30a05ad5e7bceba9788cfa21e6..415e152748b27e3fe5c8962c72bbf9184c6fbbe9 100644 (file)
@@ -32,7 +32,7 @@ entity makeXonoticTextSlider(string theCvar)
        me.configureXonoticTextSlider(me, theCvar);
        return me;
 }
-void configureXonoticTextSliderXonoticTextSlider(entity me, string theCvar)
+void XonoticTextSlider_configureXonoticTextSlider(entity me, string theCvar)
 {
        me.configureSliderVisuals(me, me.fontSize, me.align, me.valueSpace, me.image);
        if(theCvar)
@@ -42,7 +42,7 @@ void configureXonoticTextSliderXonoticTextSlider(entity me, string theCvar)
                // don't load it yet
        }
 }
-void setValueXonoticTextSlider(entity me, float val)
+void XonoticTextSlider_setValue(entity me, float val)
 {
        if(val != me.value)
        {
@@ -50,7 +50,7 @@ void setValueXonoticTextSlider(entity me, float val)
                me.saveCvars(me);
        }
 }
-void loadCvarsXonoticTextSlider(entity me)
+void XonoticTextSlider_loadCvars(entity me)
 {
        if not(me.cvarName)
                return;
@@ -61,8 +61,18 @@ void loadCvarsXonoticTextSlider(entity me)
        for(i = 1; i < n; ++i)
                s = strcat(s, " ", cvar_string(argv(i)));
        me.setValueFromIdentifier(me, s);
+       if(me.value < 0 && n > 1)
+       {
+               // if it failed: check if all cvars have the same value
+               // if yes, try its value as 1-word identifier
+               for(i = 1; i < n; ++i)
+                       if(cvar_string(argv(i)) != cvar_string(argv(i-1)))
+                               break;
+               if(i >= n)
+                       me.setValueFromIdentifier(me, cvar_string(argv(0)));
+       }
 }
-void saveCvarsXonoticTextSlider(entity me)
+void XonoticTextSlider_saveCvars(entity me)
 {
        if not(me.cvarName)
                return;
@@ -94,7 +104,7 @@ void saveCvarsXonoticTextSlider(entity me)
                }
        }
 }
-void configureXonoticTextSliderValuesXonoticTextSlider(entity me)
+void XonoticTextSlider_configureXonoticTextSliderValues(entity me)
 {
        me.configureTextSliderValues(me, string_null);
        me.loadCvars(me);