]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/dialog_settings_game.qc
Merge branch 'terencehill/respawn_timer_fix' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / dialog_settings_game.qc
1 #include "dialog_settings_game.qh"
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 = Settings_from(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 = Settings_from(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 Settings_COUNT; }
20
21 string XonoticRegisteredSettingsList_cb_name;
22 string XonoticRegisteredSettingsList_cb_tooltip;
23 void XonoticRegisteredSettingsList_getNameIcon_cb(string _name, string _icon)
24 {
25     XonoticRegisteredSettingsList_cb_name = _name;
26 }
27 void XonoticRegisteredSettingsList_getTooltip_cb(string _tooltip)
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;
36     string name = XonoticRegisteredSettingsList_cb_name;
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 }
88 CONSTRUCTOR(XonoticRegisteredSettingsList, DataSource _source) {
89     CONSTRUCT(XonoticRegisteredSettingsList);
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 c = this.currentPanel;
98     entity removing = this.currentItem;
99     DataSource data = this.topicList.source;
100     entity adding = data.getEntry(data, this.topicList.selectedItem, func_null);
101     if (removing == adding) return;
102     if (removing) {
103         this.currentItem = NULL;
104         c.removeItem(c, removing);
105     }
106     if (adding) {
107         this.currentItem = adding;
108         adding.resizeNotify(adding, '0 0 0', c.size, '0 0 0', c.size);
109         c.addItem(c, adding, '0 0 0', '1 1 0', 1);
110     }
111 }
112 METHOD(XonoticGameSettingsTab, fill, void(entity this))
113 {
114     entity topics = this.topicList;
115         topics.onChange = this.topicChangeNotify;
116         topics.onChangeEntity = this;
117
118     int
119     col = 0, width = 1;
120     this.gotoRC(this, 0, col);
121         this.TD(this, this.rows, width, topics);
122
123     col += width, width = this.columns - col;
124     this.gotoRC(this, 0, col); this.setFirstColumn(this, this.currentColumn);
125         this.TD(this, this.rows, width, this.currentPanel);
126
127     this.topicChangeNotify(topics, this);
128 }