]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/colorbutton.c
Merge remote-tracking branch 'origin/terencehill/cmd_fixes'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / colorbutton.c
index 2ca8c86c4078d056c86ba0d8512709b7d45b5df8..e0f4c5b2e4c616e02ea7eca35595969d5953618a 100644 (file)
@@ -28,6 +28,27 @@ entity makeXonoticColorButton(float theGroup, float theColor, float theValue)
 }
 void XonoticColorButton_configureXonoticColorButton(entity me, float theGroup, float theColor, float theValue)
 {
+       switch(theValue)
+       {
+               // rearrange 1..14 for rainbow order
+               case  1: theValue = 10; break;
+               case  2: theValue =  4; break;
+               case  3: theValue =  1; break;
+               case  4: theValue = 14; break;
+               case  5: theValue = 12; break;
+               case  6: theValue =  7; break;
+               case  7: theValue =  3; break;
+               case  8: theValue =  2; break;
+               case  9: theValue =  6; break;
+               case 10: theValue =  5; break;
+               case 11: theValue = 13; break;
+               case 12: theValue = 11; break;
+               case 13: theValue =  8; break;
+               case 14: theValue =  9; break;
+               default:
+                       // no change
+                       break;
+       }
        me.cvarName = "_cl_color";
        me.cvarValueFloat = theValue;
        me.cvarPart = theColor;
@@ -49,6 +70,9 @@ void XonoticColorButton_loadCvars(entity me)
        if not(me.cvarName)
                return;
 
+       if(cvar_string(me.cvarName) == cvar_defstring(me.cvarName))
+               cvar_set(me.cvarName, ftos(16 * floor(random() * 15) + floor(random() * 15)));
+
        if(me.cvarPart == 1)
                me.checked = (cvar(me.cvarName) & 240) == me.cvarValueFloat * 16;
        else