Xonotic
dialog_settings_game.qc
Go to the documentation of this file.
2 
3 #include "../gamesettings.qh"
4 
5 METHOD(SettingSource, getEntry, entity(entity this, int i, void(string name, string icon) returns))
6 {
7  Lazy l = REGISTRY_GET(Settings, i);
8  entity it = l.m_get();
9  if (returns) returns(it.title, string_null);
10  return it;
11 }
12 METHOD(SettingSource, getEntryTooltip, entity(entity this, int i, void(string theTooltip) returns))
13 {
14  Lazy l = REGISTRY_GET(Settings, i);
15  entity it = l.m_get();
16  if (returns) returns(it.titleTooltip);
17  return it;
18 }
19 METHOD(SettingSource, reload, int(entity this, string filter)) { return REGISTRY_COUNT(Settings); }
20 
23 void XonoticRegisteredSettingsList_getNameIcon_cb(string _name, string _icon)
24 {
25  XonoticRegisteredSettingsList_cb_name = _name;
26 }
28 {
29  XonoticRegisteredSettingsList_cb_tooltip = _tooltip;
30 }
31 
32 METHOD(XonoticRegisteredSettingsList, drawListBoxItem, void(entity this, int i, vector absSize, bool isSelected, bool isFocused))
33 {
34  if (!this.source) return;
35  if (!this.source.getEntry(this.source, i, XonoticRegisteredSettingsList_getNameIcon_cb)) return;
37  if (isSelected) {
38  draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
39  } else if (isFocused) {
40  this.focusedItemAlpha = getFadedAlpha(this.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
41  draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, this.focusedItemAlpha);
42  }
43  string s = draw_TextShortenToWidth(strdecolorize(name), 1, 0, this.realFontSize);
44  draw_Text(this.realUpperMargin * eY + (0.5 * this.realFontSize.x) * eX, s, this.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
45 }
46 
47 METHOD(XonoticRegisteredSettingsList, focusedItemChangeNotify, void(entity this))
48 {
49  if (this.focusedItem == -1 || !this.source)
50  {
51  clearTooltip(this);
52  return;
53  }
54  if (!this.source.getEntryTooltip(this, this.focusedItem, XonoticRegisteredSettingsList_getTooltip_cb))
55  {
56  clearTooltip(this);
57  return;
58  }
59  string theTooltip = XonoticRegisteredSettingsList_cb_tooltip;
60  if(theTooltip != "")
61  setZonedTooltip(this, theTooltip, string_null);
62  else
63  clearTooltip(this);
64 }
65 
66 METHOD(XonoticRegisteredSettingsList, refilter, void(entity this))
67 {
68  if (!this.source) {
69  this.nItems = 0;
70  return;
71  }
72  this.nItems = this.source.reload(this.source, this.stringFilter);
73 }
74 METHOD(XonoticRegisteredSettingsList, resizeNotify, void(entity this, vector relOrigin, vector relSize, vector absOrigin, vector absSize))
75 {
76  SUPER(XonoticRegisteredSettingsList).resizeNotify(this, relOrigin, relSize, absOrigin, absSize);
77 
78  this.itemAbsSize = '0 0 0';
79  this.realFontSize_y = this.fontSize / (this.itemAbsSize_y = (absSize.y * this.itemHeight));
80  this.realFontSize_x = this.fontSize / (this.itemAbsSize_x = (absSize.x * (1 - this.controlWidth)));
81  this.realUpperMargin = 0.5 * (1 - this.realFontSize.y);
82 }
83 METHOD(XonoticRegisteredSettingsList, setSelected, void(entity this, int i))
84 {
85  SUPER(XonoticRegisteredSettingsList).setSelected(this, i);
86  this.onChange(this, this.onChangeEntity);
87 }
90  this.source = _source;
91  this.configureXonoticListBox(this);
92  this.refilter(this);
93 }
94 
95 METHOD(XonoticGameSettingsTab, topicChangeNotify, void(entity, entity this))
96 {
97  entity s = NULL;
98  entity c = this.currentPanel;
99  if (c.classname == "XonoticScrollPanel")
100  {
101  s = this.currentPanel;
102  s.viewportHeight = 15.5;
103  c = s.currentPanel;
104  }
105 
106  entity removing = this.currentItem;
107  DataSource data = this.topicList.source;
108  entity adding = data.getEntry(data, this.topicList.selectedItem, func_null);
109  if (removing == adding) return;
110  if (removing) {
111  this.currentItem = NULL;
112  c.removeItem(c, removing);
113  }
114  if (adding) {
115  this.currentItem = adding;
116  adding.resizeNotify(adding, '0 0 0', c.size, '0 0 0', c.size);
117  c.addItem(c, adding, '0 0 0', '1 1 0', 1);
118  if (s)
119  s.resizeNotify(s, '0 0 0', s.size, '0 0 0', s.size);
120  }
121 }
122 METHOD(XonoticGameSettingsTab, fill, void(entity this))
123 {
124  entity topics = this.topicList;
125  topics.onChange = this.topicChangeNotify;
126  topics.onChangeEntity = this;
127 
128  int
129  col = 0, width = 1;
130  this.gotoRC(this, 0, col);
131  this.TD(this, this.rows, width, topics);
132 
133  col += width, width = this.columns - col;
134  this.gotoRC(this, 0, col); this.setFirstColumn(this, this.currentColumn);
135  this.TD(this, this.rows, width, this.currentPanel);
136 
137  this.topicChangeNotify(topics, this);
138 }
string string_null
Definition: nil.qh:9
const vector eY
Definition: vector.qh:45
entity() spawn
#define REGISTRY_GET(id, i)
Definition: registry.qh:43
void XonoticRegisteredSettingsList_getTooltip_cb(string _tooltip)
#define METHOD(cname, name, prototype)
Definition: oo.qh:257
#define CONSTRUCT(cname,...)
Definition: oo.qh:111
string XonoticRegisteredSettingsList_cb_tooltip
#define SUPER(cname)
Definition: oo.qh:219
#define REGISTRY_COUNT(id)
Definition: registry.qh:18
string XonoticRegisteredSettingsList_cb_name
#define NULL
Definition: post.qh:17
Definition: lazy.qh:5
vector(float skel, float bonenum) _skel_get_boneabs_hidden
void XonoticRegisteredSettingsList_getNameIcon_cb(string _name, string _icon)
const vector eX
Definition: vector.qh:44
#define CONSTRUCTOR(cname,...)
Definition: oo.qh:201
var void func_null()