Xonotic
cvarlist.qc File Reference
#include "cvarlist.qh"
#include "inputbox.qh"
#include "../item/checkbox.qh"
#include "../item/container.qh"
+ Include dependency graph for cvarlist.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void CvarList_End_Editing (entity box, entity me)
 
void CvarList_Filter_Change (entity box, entity me)
 
void CvarList_Filter_ModifiedCvars (entity box, entity me)
 
void CvarList_Load (entity me, string filter)
 
void CvarList_Revert_Click (entity btn, entity me)
 
void CvarList_Value_Change (entity box, entity me)
 
entity makeXonoticCvarList ()
 
void XonoticCvarList_configureXonoticCvarList (entity me)
 
void XonoticCvarList_destroy (entity me)
 
void XonoticCvarList_drawListBoxItem (entity me, int i, vector absSize, bool isSelected, bool isFocused)
 
void XonoticCvarList_hideNotify (entity me)
 
float XonoticCvarList_keyDown (entity me, float scan, float ascii, float shift)
 
float XonoticCvarList_mouseRelease (entity me, vector pos)
 
void XonoticCvarList_resizeNotify (entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
 
void XonoticCvarList_setSelected (entity me, float i)
 
void XonoticCvarList_showNotify (entity me)
 
float XonoticCvarList_updateCvarType (entity me)
 

Variables

string autocvar_menu_forced_saved_cvars
 
string autocvar_menu_reverted_nonsaved_cvars
 

Function Documentation

◆ CvarList_End_Editing()

void CvarList_End_Editing ( entity  box,
entity  me 
)

Definition at line 251 of file cvarlist.qc.

252 {
253  box.parent.setFocus(box.parent, me);
254 }

◆ CvarList_Filter_Change()

void CvarList_Filter_Change ( entity  box,
entity  me 
)

Definition at line 126 of file cvarlist.qc.

References CvarList_Load().

127 {
128  CvarList_Load(me, box.text);
129  me.setSelected(me, 0);
130 }
void CvarList_Load(entity me, string filter)
Definition: cvarlist.qc:21
+ Here is the call graph for this function:

◆ CvarList_Filter_ModifiedCvars()

void CvarList_Filter_ModifiedCvars ( entity  box,
entity  me 
)

Definition at line 131 of file cvarlist.qc.

References autocvar_menu_cvarlist_onlymodified, cvar_set(), CvarList_Load(), and ftos().

132 {
133  cvar_set("menu_cvarlist_onlymodified", ftos(!autocvar_menu_cvarlist_onlymodified));
134  box.setChecked(box, autocvar_menu_cvarlist_onlymodified);
135  CvarList_Load(me, me.controlledTextbox.text);
136  me.setSelected(me, 0);
137 }
void CvarList_Load(entity me, string filter)
Definition: cvarlist.qc:21
float autocvar_menu_cvarlist_onlymodified
Definition: cvarlist.qh:47
+ Here is the call graph for this function:

◆ CvarList_Load()

void CvarList_Load ( entity  me,
string  filter 
)

Definition at line 21 of file cvarlist.qc.

References autocvar_menu_cvarlist_onlymodified, buf_create, cvar_defstring(), and cvar_string().

Referenced by CvarList_Filter_Change(), CvarList_Filter_ModifiedCvars(), and XonoticCvarList_showNotify().

22 {
23  if(me.handle < 0)
24  return;
25 
26  buf_cvarlist(me.handle, filter, "_"); // cvars starting with "_" are excluded
27  me.nItems = buf_getsize(me.handle);
29  {
30  float newbuf = buf_create();
31  for (int i = 0; i < me.nItems; ++i)
32  {
33  string k = bufstr_get(me.handle, i);
34  if(cvar_string(k) != cvar_defstring(k))
35  bufstr_add(newbuf, k, false);
36  }
37  buf_del(me.handle);
38  me.handle = newbuf;
39  me.nItems = buf_getsize(me.handle);
40  }
41 }
#define buf_create
Definition: dpextensions.qh:63
float autocvar_menu_cvarlist_onlymodified
Definition: cvarlist.qh:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CvarList_Revert_Click()

void CvarList_Revert_Click ( entity  btn,
entity  me 
)

Definition at line 236 of file cvarlist.qc.

References autocvar_menu_forced_saved_cvars, autocvar_menu_reverted_nonsaved_cvars, cvar_set(), strcat(), strhasword, strlen(), and substring().

Referenced by XonoticCvarList_keyDown().

237 {
238  me.cvarValueBox.setText(me.cvarValueBox, me.cvarDefault);
239  me.cvarValueBox.cursorPos = strlen(me.cvarDefault);
241  {
242  cvar_set("menu_forced_saved_cvars", substring(strreplace(strcat(" ", me.cvarName, " "), " ", strcat(" ", autocvar_menu_forced_saved_cvars, " ")), 1, -2));
244  cvar_set("menu_reverted_nonsaved_cvars", me.cvarName);
245  else
246  cvar_set("menu_reverted_nonsaved_cvars", strcat(autocvar_menu_reverted_nonsaved_cvars, " ", me.cvarName));
247  }
248  me.cvarNeedsForcing = me.updateCvarType(me);
249 }
string autocvar_menu_forced_saved_cvars
Definition: cvarlist.qc:63
#define strhasword(s, w)
Definition: string.qh:352
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"))
string autocvar_menu_reverted_nonsaved_cvars
Definition: cvarlist.qc:64
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CvarList_Value_Change()

void CvarList_Value_Change ( entity  box,
entity  me 
)

Definition at line 220 of file cvarlist.qc.

References autocvar_menu_forced_saved_cvars, autocvar_menu_reverted_nonsaved_cvars, cvar_set(), localcmd, strcat(), and substring().

221 {
222  cvar_set(me.cvarNameBox.text, box.text);
223  if(me.cvarNeedsForcing)
224  {
225  localcmd(sprintf("\nseta %1$s \"$%1$s\"\n", me.cvarName));
226  cvar_set("menu_reverted_nonsaved_cvars", substring(strreplace(strcat(" ", me.cvarName, " "), " ", strcat(" ", autocvar_menu_reverted_nonsaved_cvars, " ")), 1, -2));
228  cvar_set("menu_forced_saved_cvars", me.cvarName);
229  else
230  cvar_set("menu_forced_saved_cvars", strcat(autocvar_menu_forced_saved_cvars, " ", me.cvarName));
231  me.cvarNeedsForcing = 0;
232  me.updateCvarType(me);
233  }
234 }
string autocvar_menu_forced_saved_cvars
Definition: cvarlist.qc:63
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"))
string autocvar_menu_reverted_nonsaved_cvars
Definition: cvarlist.qc:64
+ Here is the call graph for this function:

◆ makeXonoticCvarList()

entity makeXonoticCvarList ( )

Definition at line 8 of file cvarlist.qc.

References entity(), and NEW.

Referenced by XonoticCvarsDialog_fill().

9 {
10  entity me;
11  me = NEW(XonoticCvarList);
12  me.configureXonoticCvarList(me);
13  return me;
14 }
#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:

◆ XonoticCvarList_configureXonoticCvarList()

void XonoticCvarList_configureXonoticCvarList ( entity  me)

Definition at line 15 of file cvarlist.qc.

References buf_create.

16 {
17  me.configureXonoticListBox(me);
18  me.handle = buf_create();
19  me.nItems = 0;
20 }
#define buf_create
Definition: dpextensions.qh:63

◆ XonoticCvarList_destroy()

void XonoticCvarList_destroy ( entity  me)

Definition at line 58 of file cvarlist.qc.

59 {
60  if(me.handle)
61  buf_del(me.handle);
62 }

◆ XonoticCvarList_drawListBoxItem()

void XonoticCvarList_drawListBoxItem ( entity  me,
int  i,
vector  absSize,
bool  isSelected,
bool  isFocused 
)

Definition at line 151 of file cvarlist.qc.

References autocvar_menu_forced_saved_cvars, autocvar_menu_reverted_nonsaved_cvars, cvar_defstring(), cvar_string(), CVAR_TYPEFLAG_SAVED, draw_Fill(), draw_Text(), draw_TextShortenToWidth(), eX, eY, getFadedAlpha(), strhasword, v, and vector().

152 {
153  string k, v, d;
154  float t;
155 
156  vector theColor;
157  float theAlpha;
158 
159  string s;
160 
161  if(isSelected)
162  draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
163  else if(isFocused)
164  {
165  me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
166  draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
167  }
168 
169  k = bufstr_get(me.handle, i);
170 
171  v = cvar_string(k);
172  d = cvar_defstring(k);
173  t = cvar_type(k);
175  theAlpha = SKINALPHA_CVARLIST_SAVED;
177  theAlpha = SKINALPHA_CVARLIST_TEMPORARY;
178  else if(t & CVAR_TYPEFLAG_SAVED)
179  theAlpha = SKINALPHA_CVARLIST_SAVED;
180  else
181  theAlpha = SKINALPHA_CVARLIST_TEMPORARY;
182  if(v == d)
183  theColor = SKINCOLOR_CVARLIST_UNCHANGED;
184  else
185  theColor = SKINCOLOR_CVARLIST_CHANGED;
186 
187  s = draw_TextShortenToWidth(k, me.columnNameSize, 0, me.realFontSize);
188  draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s, me.realFontSize, theColor, theAlpha, 0);
189  s = draw_TextShortenToWidth(v, me.columnValueSize, 0, me.realFontSize);
190  draw_Text(me.realUpperMargin * eY + me.columnValueOrigin * eX, s, me.realFontSize, theColor, theAlpha, 0);
191 }
const vector eY
Definition: vector.qh:45
string autocvar_menu_forced_saved_cvars
Definition: cvarlist.qc:63
#define strhasword(s, w)
Definition: string.qh:352
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector v
Definition: ent_cs.qc:116
const vector eX
Definition: vector.qh:44
string autocvar_menu_reverted_nonsaved_cvars
Definition: cvarlist.qc:64
float CVAR_TYPEFLAG_SAVED
+ Here is the call graph for this function:

◆ XonoticCvarList_hideNotify()

void XonoticCvarList_hideNotify ( entity  me)

Definition at line 51 of file cvarlist.qc.

References buf_create.

52 {
53  if(me.handle)
54  buf_del(me.handle);
55  me.handle = buf_create();
56  me.nItems = 0;
57 }
#define buf_create
Definition: dpextensions.qh:63

◆ XonoticCvarList_keyDown()

float XonoticCvarList_keyDown ( entity  me,
float  scan,
float  ascii,
float  shift 
)

Definition at line 193 of file cvarlist.qc.

References CvarList_Revert_Click(), K_ENTER, K_MOUSE3, K_SPACE, NULL, S_CTRL, and SUPER.

194 {
195  if (scan == K_MOUSE3 || ((shift & S_CTRL) && scan == K_SPACE))
196  {
198  return 1;
199  }
200  else if(scan == K_ENTER)
201  {
202  me.cvarValueBox.parent.setFocus(me.cvarValueBox.parent, me.cvarValueBox);
203  return 1;
204  }
205  else if(SUPER(XonoticCvarList).keyDown(me, scan, ascii, shift))
206  return 1;
207  else if(!me.controlledTextbox)
208  return 0;
209  else
210  return me.controlledTextbox.keyDown(me.controlledTextbox, scan, ascii, shift);
211 }
void CvarList_Revert_Click(entity btn, entity me)
Definition: cvarlist.qc:236
float K_MOUSE3
Definition: keycodes.qc:131
float K_SPACE
Definition: keycodes.qc:10
#define SUPER(cname)
Definition: oo.qh:219
#define NULL
Definition: post.qh:17
float K_ENTER
Definition: keycodes.qc:8
const int S_CTRL
Definition: hud.qh:128
+ Here is the call graph for this function:

◆ XonoticCvarList_mouseRelease()

float XonoticCvarList_mouseRelease ( entity  me,
vector  pos 
)

Definition at line 213 of file cvarlist.qc.

References SUPER.

214 {
215  if(me.pressed == 2)
216  me.cvarValueBox.parent.setFocus(me.cvarValueBox.parent, me.cvarValueBox);
217  return SUPER(XonoticCvarList).mouseRelease(me, pos);
218 }
#define SUPER(cname)
Definition: oo.qh:219

◆ XonoticCvarList_resizeNotify()

void XonoticCvarList_resizeNotify ( entity  me,
vector  relOrigin,
vector  relSize,
vector  absOrigin,
vector  absSize 
)

Definition at line 138 of file cvarlist.qc.

References SUPER.

139 {
140  SUPER(XonoticCvarList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
141 
142  me.realFontSize_y = me.fontSize / (absSize.y * me.itemHeight);
143  me.realFontSize_x = me.fontSize / (absSize.x * (1 - me.controlWidth));
144  me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
145 
146  me.columnNameOrigin = 0;
147  me.columnValueSize = me.realFontSize.x * 20;
148  me.columnNameSize = 1 - me.columnValueSize - me.realFontSize.x;
149  me.columnValueOrigin = me.columnNameOrigin + me.columnNameSize + me.realFontSize.x;
150 }
#define SUPER(cname)
Definition: oo.qh:219

◆ XonoticCvarList_setSelected()

void XonoticCvarList_setSelected ( entity  me,
float  i 
)

Definition at line 102 of file cvarlist.qc.

References cvar_defstring(), cvar_string(), strcpy, strfree, strlen(), and SUPER.

103 {
104  string s;
105 
106  SUPER(XonoticCvarList).setSelected(me, i);
107  if(me.nItems == 0)
108  return;
109 
110  strfree(me.cvarType);
111  strcpy(me.cvarName, bufstr_get(me.handle, me.selectedItem));
112  strcpy(me.cvarDescription, cvar_description(me.cvarName));
113  strcpy(me.cvarDefault, cvar_defstring(me.cvarName));
114  me.cvarNameBox.setText(me.cvarNameBox, me.cvarName);
115  me.cvarDescriptionBox.setText(me.cvarDescriptionBox, me.cvarDescription);
116  float needsForcing = me.updateCvarType(me);
117  me.cvarDefaultBox.setText(me.cvarDefaultBox, me.cvarDefault);
118 
119  // this one can handle tempstrings
120  s = cvar_string(me.cvarName);
121  me.cvarNeedsForcing = 0;
122  me.cvarValueBox.setText(me.cvarValueBox, s);
123  me.cvarNeedsForcing = needsForcing;
124  me.cvarValueBox.cursorPos = strlen(s);
125 }
#define strcpy(this, s)
Definition: string.qh:49
#define SUPER(cname)
Definition: oo.qh:219
#define strfree(this)
Definition: string.qh:56
+ Here is the call graph for this function:

◆ XonoticCvarList_showNotify()

void XonoticCvarList_showNotify ( entity  me)

Definition at line 42 of file cvarlist.qc.

References CvarList_Load().

43 {
44  bool force_initial_selection = false;
45  if(me.handle >= 0 && me.nItems <= 0) // me.handle not loaded yet?
46  force_initial_selection = true;
47  CvarList_Load(me, me.controlledTextbox.text);
48  if(force_initial_selection)
49  me.setSelected(me, 0);
50 }
void CvarList_Load(entity me, string filter)
Definition: cvarlist.qc:21
+ Here is the call graph for this function:

◆ XonoticCvarList_updateCvarType()

float XonoticCvarList_updateCvarType ( entity  me)

Definition at line 65 of file cvarlist.qc.

References autocvar_menu_forced_saved_cvars, strcat(), and strhasword.

66 {
67  float t;
68  t = cvar_type(me.cvarName);
69  me.cvarType = "";
70  float needsForcing;
72  {
73  me.cvarType = strcat(me.cvarType, ", ", _("forced to be saved to config.cfg"));
74  needsForcing = 0;
75  }
77  {
78  // Currently claims to be saved, but won't be on next startup.
79  me.cvarType = strcat(me.cvarType, ", ", _("will not be saved"));
80  needsForcing = 1;
81  }
82  else if(t & CVAR_TYPEFLAG_SAVED)
83  {
84  me.cvarType = strcat(me.cvarType, ", ", _("will be saved to config.cfg"));
85  needsForcing = 0;
86  }
87  else
88  {
89  me.cvarType = strcat(me.cvarType, ", ", _("will not be saved"));
90  needsForcing = 1;
91  }
92  if(t & CVAR_TYPEFLAG_PRIVATE)
93  me.cvarType = strcat(me.cvarType, ", ", _("private"));
94  if(t & CVAR_TYPEFLAG_ENGINE)
95  me.cvarType = strcat(me.cvarType, ", ", _("engine setting"));
97  me.cvarType = strcat(me.cvarType, ", ", _("read only"));
98  me.cvarType = strzone(substring(me.cvarType, 2, strlen(me.cvarType) - 2));
99  me.cvarTypeBox.setText(me.cvarTypeBox, me.cvarType);
100  return needsForcing;
101 }
string autocvar_menu_forced_saved_cvars
Definition: cvarlist.qc:63
#define strhasword(s, w)
Definition: string.qh:352
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"))
float CVAR_TYPEFLAG_READONLY
float CVAR_TYPEFLAG_PRIVATE
float CVAR_TYPEFLAG_ENGINE
string autocvar_menu_reverted_nonsaved_cvars
Definition: cvarlist.qc:64
float CVAR_TYPEFLAG_SAVED
+ Here is the call graph for this function:

Variable Documentation

◆ autocvar_menu_forced_saved_cvars

string autocvar_menu_forced_saved_cvars

◆ autocvar_menu_reverted_nonsaved_cvars

string autocvar_menu_reverted_nonsaved_cvars