Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
colorbutton.qc File Reference
#include "colorbutton.qh"
Include dependency graph for colorbutton.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

entity makeXonoticColorButton (float theGroup, float theColor, float theValue)
void XonoticColorButton_configureXonoticColorButton (entity me, float theGroup, float theColor, float theValue)
void XonoticColorButton_draw (entity me)
void XonoticColorButton_loadCvars (entity me)
void XonoticColorButton_saveCvars (entity me)
void XonoticColorButton_setChecked (entity me, bool val)

Function Documentation

◆ makeXonoticColorButton()

entity makeXonoticColorButton ( float theGroup,
float theColor,
float theValue )

Definition at line 3 of file colorbutton.qc.

4{
6 me.configureXonoticColorButton(me, theGroup, theColor, theValue);
7 return me;
8}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define NEW(cname,...)
Definition oo.qh:117

References entity(), and NEW.

Referenced by XonoticColorButton::saveCvars(), and XonoticProfileTab_fill().

◆ XonoticColorButton_configureXonoticColorButton()

void XonoticColorButton_configureXonoticColorButton ( entity me,
float theGroup,
float theColor,
float theValue )

Definition at line 9 of file colorbutton.qc.

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}
string string_null
Definition nil.qh:9

References entity(), and string_null.

◆ XonoticColorButton_draw()

void XonoticColorButton_draw ( entity me)

Definition at line 72 of file colorbutton.qc.

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}
#define colormapPaletteColor(c, isPants)
Definition color.qh:5
#define SUPER(cname)
Definition oo.qh:231

References colormapPaletteColor, entity(), and SUPER.

◆ XonoticColorButton_loadCvars()

void XonoticColorButton_loadCvars ( entity me)

Definition at line 46 of file colorbutton.qc.

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}
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)

References cvar(), cvar_defstring(), cvar_set(), cvar_string(), entity(), floor(), ftos(), and random().

◆ XonoticColorButton_saveCvars()

void XonoticColorButton_saveCvars ( entity me)

Definition at line 59 of file colorbutton.qc.

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}

References cvar(), cvar_set(), entity(), and ftos().

◆ XonoticColorButton_setChecked()

void XonoticColorButton_setChecked ( entity me,
bool val )

Definition at line 38 of file colorbutton.qc.

39{
40 if(val != me.checked)
41 {
42 me.checked = val;
43 me.saveCvars(me);
44 }
45}

References entity().