Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
dialog_settings_game.qc
Go to the documentation of this file.
2
3#include "../gamesettings.qh"
4
5METHOD(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}
12METHOD(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}
19METHOD(SettingSource, reload, int(entity this, string filter)) { return REGISTRY_COUNT(Settings); }
20
31
32METHOD(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
48{
49 if (this.focusedItem < 0 || !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 }
60 if(theTooltip != "")
61 setZonedTooltip(this, theTooltip, string_null);
62 else
63 clearTooltip(this);
64}
65
67{
68 if (!this.source) {
69 this.nItems = 0;
70 return;
71 }
72 this.nItems = this.source.reload(this.source, this.stringFilter);
73}
74METHOD(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}
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
97{
98 entity me;
100 me.configureDialog(me);
101 return me;
102}
104{
105 entity s = NULL;
106 entity c = me.currentPanel;
107 if (c.classname == "XonoticScrollPanel")
108 {
109 s = me.currentPanel;
110 s.viewportHeight = 15.5;
111 c = s.currentPanel;
112 }
113
114 entity removing = me.currentItem;
115 DataSource data = me.topicList.source;
116 entity adding = data.getEntry(data, me.topicList.selectedItem, func_null);
117 if (removing == adding) return;
118 if (removing) {
119 me.currentItem = NULL;
120 c.removeItem(c, removing);
121 }
122 if (adding) {
123 me.currentItem = adding;
124 adding.resizeNotify(adding, '0 0 0', c.size, '0 0 0', c.size);
125 c.addItem(c, adding, '0 0 0', '1 1 0', 1);
126 if (s)
127 s.resizeNotify(s, '0 0 0', s.size, '0 0 0', s.size);
128 }
129}
131{
132 entity topics = me.topicList;
133 topics.onChange = me.topicChangeNotify;
134 topics.onChangeEntity = me;
135
136 int
137 col = 0, width = 1;
138 me.gotoRC(me, 0, col);
139 me.TD(me, me.rows, width, topics);
140
141 col += width, width = me.columns - col;
142 me.gotoRC(me, 0, col); me.setFirstColumn(me, me.currentColumn);
143 me.TD(me, me.rows, width, me.currentPanel);
144
145 me.topicChangeNotify(topics, me);
146}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
virtual void getEntry()
get entry i passing name and icon through returns if it is not null returns DataSource_false if out o...
Definition datasource.qh:11
Definition lazy.qh:5
float controlWidth
Definition listbox.qh:35
float itemHeight
Definition listbox.qh:47
float focusedItemAlpha
Definition listbox.qh:16
int focusedItem
Definition listbox.qh:15
int nItems
Definition listbox.qh:46
virtual void getEntryTooltip()
virtual void reload()
reload all entries matching filter returning how many matches were found
virtual void getEntry()
get entry i passing name and icon through returns if it is not null returns DataSource_false if out o...
virtual void configureXonoticListBox()
float fontSize
Definition listbox.qh:6
XonoticRegisteredSettingsList(DataSource _source)
entity() spawn
entity makeXonoticGameSettingsTab()
void XonoticRegisteredSettingsList_getNameIcon_cb(string _name, string _icon)
void XonoticRegisteredSettingsList_getTooltip_cb(string _tooltip)
string XonoticRegisteredSettingsList_cb_tooltip
string XonoticRegisteredSettingsList_cb_name
void XonoticGameSettingsTab_fill(entity me)
string draw_TextShortenToWidth(string theText, float maxWidth, float ICanHasKallerz, vector SizeThxBye)
Definition draw.qc:377
void draw_Text(vector theOrigin, string theText, vector theSize, vector theColor, float theAlpha, float ICanHasKallerz)
Definition draw.qc:282
void draw_Fill(vector theOrigin, vector theSize, vector theColor, float theAlpha)
Definition draw.qc:97
float getFadedAlpha(float currentAlpha, float startAlpha, float targetAlpha)
Definition util.qc:816
void clearTooltip(entity e)
Definition util.qc:277
void setZonedTooltip(entity e, string theTooltip, string theCvar)
Definition util.qc:257
string name
Definition menu.qh:30
var void func_null()
string string_null
Definition nil.qh:9
#define NEW(cname,...)
Definition oo.qh:117
#define SUPER(cname)
Definition oo.qh:231
#define METHOD(cname, name, prototype)
Definition oo.qh:269
#define CONSTRUCTOR(cname,...)
Definition oo.qh:213
#define CONSTRUCT(cname,...)
Definition oo.qh:123
#define NULL
Definition post.qh:14
#define REGISTRY_COUNT(id)
Definition registry.qh:18
#define REGISTRY_GET(id, i)
Definition registry.qh:43
vector
Definition self.qh:92
const vector eY
Definition vector.qh:45
const vector eX
Definition vector.qh:44