Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
colorbutton.qc
Go to the documentation of this file.
1#include "colorbutton.qh"
2
3entity makeXonoticColorButton(float theGroup, float theColor, float theValue)
4{
6 me.configureXonoticColorButton(me, theGroup, theColor, theValue);
7 return me;
8}
9void XonoticColorButton_configureXonoticColorButton(entity me, float theGroup, float theColor, float theValue)
10{
11 switch(theValue)
12 {
13 // rearrange 1..14 for rainbow order
14 case 1: theValue = 10; break;
15 case 2: theValue = 4; break;
16 case 3: theValue = 1; break;
17 case 4: theValue = 14; break;
18 case 5: theValue = 12; break;
19 case 6: theValue = 7; break;
20 case 7: theValue = 3; break;
21 case 8: theValue = 2; break;
22 case 9: theValue = 6; break;
23 case 10: theValue = 5; break;
24 case 11: theValue = 13; break;
25 case 12: theValue = 11; break;
26 case 13: theValue = 8; break;
27 case 14: theValue = 9; break;
28 default:
29 // no change
30 break;
31 }
32 me.controlledCvar = "_cl_color";
33 me.cvarValueFloat = theValue;
34 me.cvarPart = theColor;
35 me.loadCvars(me);
36 me.configureRadioButton(me, string_null, me.fontSize, me.image, theGroup, 0);
37}
39{
40 if(val != me.checked)
41 {
42 me.checked = val;
43 me.saveCvars(me);
44 }
45}
47{
48 if (!me.controlledCvar)
49 return;
50
51 if(cvar_string(me.controlledCvar) == cvar_defstring(me.controlledCvar))
52 cvar_set(me.controlledCvar, ftos(16 * floor(random() * 15) + floor(random() * 15)));
53
54 if(me.cvarPart == 1)
55 me.checked = (cvar(me.controlledCvar) & 240) == me.cvarValueFloat * 16;
56 else
57 me.checked = (cvar(me.controlledCvar) & 15) == me.cvarValueFloat;
58}
60{
61 if (!me.controlledCvar)
62 return;
63
64 if(me.checked)
65 {
66 if(me.cvarPart == 1)
67 cvar_set(me.controlledCvar, ftos((cvar(me.controlledCvar) & 15) + me.cvarValueFloat * 16));
68 else
69 cvar_set(me.controlledCvar, ftos((cvar(me.controlledCvar) & 240) + me.cvarValueFloat));
70 }
71}
73{
74 me.color = colormapPaletteColor(me.cvarValueFloat, me.cvarPart);
75 me.colorC = me.color;
76 me.colorF = me.color;
77 me.colorD = me.color;
78 SUPER(XonoticColorButton).draw(me);
79}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define colormapPaletteColor(c, isPants)
Definition color.qh:5
entity makeXonoticColorButton(float theGroup, float theColor, float theValue)
Definition colorbutton.qc:3
void XonoticColorButton_configureXonoticColorButton(entity me, float theGroup, float theColor, float theValue)
Definition colorbutton.qc:9
void XonoticColorButton_setChecked(entity me, bool val)
void XonoticColorButton_draw(entity me)
void XonoticColorButton_loadCvars(entity me)
void XonoticColorButton_saveCvars(entity me)
void cvar_set(string name, string value)
float cvar(string name)
float random(void)
const string cvar_string(string name)
string ftos(float f)
float floor(float f)
const string cvar_defstring(string name)
string string_null
Definition nil.qh:9
#define NEW(cname,...)
Definition oo.qh:117
#define SUPER(cname)
Definition oo.qh:231