Xonotic
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, float val)
 

Function Documentation

◆ makeXonoticColorButton()

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

Definition at line 3 of file colorbutton.qc.

References entity(), and NEW.

4 {
5  entity me;
7  me.configureXonoticColorButton(me, theGroup, theColor, theValue);
8  return me;
9 }
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
+ Here is the call graph for this function:

◆ XonoticColorButton_configureXonoticColorButton()

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

Definition at line 10 of file colorbutton.qc.

References string_null.

11 {
12  switch(theValue)
13  {
14  // rearrange 1..14 for rainbow order
15  case 1: theValue = 10; break;
16  case 2: theValue = 4; break;
17  case 3: theValue = 1; break;
18  case 4: theValue = 14; break;
19  case 5: theValue = 12; break;
20  case 6: theValue = 7; break;
21  case 7: theValue = 3; break;
22  case 8: theValue = 2; break;
23  case 9: theValue = 6; break;
24  case 10: theValue = 5; break;
25  case 11: theValue = 13; break;
26  case 12: theValue = 11; break;
27  case 13: theValue = 8; break;
28  case 14: theValue = 9; break;
29  default:
30  // no change
31  break;
32  }
33  me.controlledCvar = "_cl_color";
34  me.cvarValueFloat = theValue;
35  me.cvarPart = theColor;
36  me.loadCvars(me);
37  me.configureRadioButton(me, string_null, me.fontSize, me.image, theGroup, 0);
38 }
string string_null
Definition: nil.qh:9

◆ XonoticColorButton_draw()

void XonoticColorButton_draw ( entity  me)

Definition at line 73 of file colorbutton.qc.

References colormapPaletteColor, and SUPER.

74 {
75  me.color = colormapPaletteColor(me.cvarValueFloat, me.cvarPart);
76  me.colorC = me.color;
77  me.colorF = me.color;
78  me.colorD = me.color;
79  SUPER(XonoticColorButton).draw(me);
80 }
#define SUPER(cname)
Definition: oo.qh:219
#define colormapPaletteColor(c, isPants)
Definition: color.qh:5

◆ XonoticColorButton_loadCvars()

void XonoticColorButton_loadCvars ( entity  me)

Definition at line 47 of file colorbutton.qc.

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

48 {
49  if (!me.controlledCvar)
50  return;
51 
52  if(cvar_string(me.controlledCvar) == cvar_defstring(me.controlledCvar))
53  cvar_set(me.controlledCvar, ftos(16 * floor(random() * 15) + floor(random() * 15)));
54 
55  if(me.cvarPart == 1)
56  me.checked = (cvar(me.controlledCvar) & 240) == me.cvarValueFloat * 16;
57  else
58  me.checked = (cvar(me.controlledCvar) & 15) == me.cvarValueFloat;
59 }
+ Here is the call graph for this function:

◆ XonoticColorButton_saveCvars()

void XonoticColorButton_saveCvars ( entity  me)

Definition at line 60 of file colorbutton.qc.

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

61 {
62  if (!me.controlledCvar)
63  return;
64 
65  if(me.checked)
66  {
67  if(me.cvarPart == 1)
68  cvar_set(me.controlledCvar, ftos((cvar(me.controlledCvar) & 15) + me.cvarValueFloat * 16));
69  else
70  cvar_set(me.controlledCvar, ftos((cvar(me.controlledCvar) & 240) + me.cvarValueFloat));
71  }
72 }
+ Here is the call graph for this function:

◆ XonoticColorButton_setChecked()

void XonoticColorButton_setChecked ( entity  me,
float  val 
)

Definition at line 39 of file colorbutton.qc.

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