Xonotic
colorpicker_string.qc File Reference
+ Include dependency graph for colorpicker_string.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

entity makeXonoticColorpickerString (string theCvar, string theDefaultCvar)
 
void XonoticColorpickerString_configureXonoticColorpickerString (entity me, string theCvar, string theDefaultCvar)
 
void XonoticColorpickerString_draw (entity me)
 
void XonoticColorpickerString_loadCvars (entity me)
 
float XonoticColorpickerString_mouseDrag (entity me, vector coords)
 
float XonoticColorpickerString_mouseRelease (entity me, vector coords)
 
void XonoticColorpickerString_saveCvars (entity me)
 

Variables

bool disabled
 

Function Documentation

◆ makeXonoticColorpickerString()

entity makeXonoticColorpickerString ( string  theCvar,
string  theDefaultCvar 
)

Definition at line 5 of file colorpicker_string.qc.

References entity(), and NEW.

Referenced by GameType_GetIcon().

6 {
7  entity me;
9  me.configureXonoticColorpickerString(me, theCvar, theDefaultCvar);
10  return me;
11 }
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ XonoticColorpickerString_configureXonoticColorpickerString()

void XonoticColorpickerString_configureXonoticColorpickerString ( entity  me,
string  theCvar,
string  theDefaultCvar 
)

Definition at line 13 of file colorpicker_string.qc.

References string_null.

14 {
15  me.configureImage(me, me.image);
16  me.controlledCvar = (theCvar) ? theCvar : string_null;
17  me.loadCvars(me);
18 }
string string_null
Definition: nil.qh:9

◆ XonoticColorpickerString_draw()

void XonoticColorpickerString_draw ( entity  me)

Definition at line 84 of file colorpicker_string.qc.

References draw_alpha, draw_Picture(), draw_PictureSize(), draw_scale, globalToBoxSize(), strcat(), SUPER, and vector().

85 {
86  float save;
87  save = draw_alpha;
88  if(me.disabled)
89  draw_alpha *= me.disabledAlpha;
90 
92 
93  vector sz;
94  sz = draw_PictureSize(strcat(me.src, "_selected"));
95  sz = globalToBoxSize(sz, draw_scale);
96 
97  if(!me.disabled)
98  draw_Picture(me.imgOrigin + me.prevcoords - 0.5 * sz, strcat(me.src, "_selected"), sz, '1 1 1', 1);
99 
100  draw_alpha = save;
101 }
#define SUPER(cname)
Definition: oo.qh:219
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
vector(float skel, float bonenum) _skel_get_boneabs_hidden
+ Here is the call graph for this function:

◆ XonoticColorpickerString_loadCvars()

void XonoticColorpickerString_loadCvars ( entity  me)

Definition at line 20 of file colorpicker_string.qc.

References color_hslimage(), cvar(), cvar_string(), eX, eY, eZ, stov(), strcat(), and substring().

21 {
22  if (!me.controlledCvar)
23  return;
24 
25  if(substring(me.controlledCvar, -1, 1) == "_")
26  {
27  me.prevcoords = color_hslimage(
28  eX * cvar(strcat(me.controlledCvar, "red")) +
29  eY * cvar(strcat(me.controlledCvar, "green")) +
30  eZ * cvar(strcat(me.controlledCvar, "blue")),
31  me.imagemargin);
32  }
33  else
34  me.prevcoords = color_hslimage(stov(cvar_string(me.controlledCvar)), me.imagemargin);
35 }
const vector eY
Definition: vector.qh:45
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
const vector eX
Definition: vector.qh:44
const vector eZ
Definition: vector.qh:46
vector color_hslimage(vector v, vector margin)
Definition: colorpicker.qc:40
+ Here is the call graph for this function:

◆ XonoticColorpickerString_mouseDrag()

float XonoticColorpickerString_mouseDrag ( entity  me,
vector  coords 
)

Definition at line 59 of file colorpicker_string.qc.

References vector().

60 {
61  if(me.disabled)
62  return 0;
63  vector margin;
64  margin = me.imagemargin;
65  if(coords.x >= margin.x)
66  if(coords.y >= margin.y)
67  if(coords.x <= 1 - margin.x)
68  if(coords.y <= 1 - margin.y)
69  {
70  me.prevcoords = coords;
71  me.saveCvars(me);
72  }
73 
74  return 1;
75 }
vector(float skel, float bonenum) _skel_get_boneabs_hidden
+ Here is the call graph for this function:

◆ XonoticColorpickerString_mouseRelease()

float XonoticColorpickerString_mouseRelease ( entity  me,
vector  coords 
)

Definition at line 77 of file colorpicker_string.qc.

References m_play_click_sound(), and MENU_SOUND_SLIDE.

78 {
80  me.mouseDrag(me, coords);
81  return 1;
82 }
+ Here is the call graph for this function:

◆ XonoticColorpickerString_saveCvars()

void XonoticColorpickerString_saveCvars ( entity  me)

Definition at line 37 of file colorpicker_string.qc.

References cvar_set(), ftos(), hslimage_color(), METHOD, strcat(), substring(), v, and vector().

38 {
39  if (!me.controlledCvar)
40  return;
41 
42  if(substring(me.controlledCvar, -1, 1) == "_")
43  {
44  vector v = hslimage_color(me.prevcoords, me.imagemargin);
45  cvar_set(strcat(me.controlledCvar, "red"), ftos(v.x));
46  cvar_set(strcat(me.controlledCvar, "green"), ftos(v.y));
47  cvar_set(strcat(me.controlledCvar, "blue"), ftos(v.z));
48  }
49  else
50  cvar_set(me.controlledCvar, sprintf("%v", hslimage_color(me.prevcoords, me.imagemargin)));
51 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
vector hslimage_color(vector v, vector margin)
Definition: colorpicker.qc:26
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector v
Definition: ent_cs.qc:116
+ Here is the call graph for this function:

Variable Documentation

◆ disabled

bool disabled

Definition at line 3 of file colorpicker_string.qc.

Referenced by Slider_mouseDrag().