1 #include "dialog_settings_game.qh"
3 #include "../gamesettings.qh"
5 METHOD(SettingSource, getEntry, entity(entity this, int i, void(string name, string icon) returns))
7 Lazy l = Settings_from(i);
9 if (returns) returns(it.title, string_null);
12 METHOD(SettingSource, getEntryTooltip, entity(entity this, int i, void(string theTooltip) returns))
14 Lazy l = Settings_from(i);
15 entity it = l.m_get();
16 if (returns) returns(it.titleTooltip);
19 METHOD(SettingSource, reload, int(entity this, string filter)) { return Settings_COUNT; }
21 string XonoticRegisteredSettingsList_cb_name;
22 string XonoticRegisteredSettingsList_cb_tooltip;
23 void XonoticRegisteredSettingsList_getNameIcon_cb(string _name, string _icon)
25 XonoticRegisteredSettingsList_cb_name = _name;
27 void XonoticRegisteredSettingsList_getTooltip_cb(string _tooltip)
29 XonoticRegisteredSettingsList_cb_tooltip = _tooltip;
32 METHOD(XonoticRegisteredSettingsList, drawListBoxItem, void(entity this, int i, vector absSize, bool isSelected, bool isFocused))
34 if (!this.source) return;
35 if (!this.source.getEntry(this.source, i, XonoticRegisteredSettingsList_getNameIcon_cb)) return;
36 string name = XonoticRegisteredSettingsList_cb_name;
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);
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);
47 METHOD(XonoticRegisteredSettingsList, focusedItemChangeNotify, void(entity this))
49 if (this.focusedItem == -1 || !this.source)
54 if (!this.source.getEntryTooltip(this, this.focusedItem, XonoticRegisteredSettingsList_getTooltip_cb))
59 string theTooltip = XonoticRegisteredSettingsList_cb_tooltip;
61 setZonedTooltip(this, theTooltip, string_null);
66 METHOD(XonoticRegisteredSettingsList, refilter, void(entity this))
72 this.nItems = this.source.reload(this.source, this.stringFilter);
74 METHOD(XonoticRegisteredSettingsList, resizeNotify, void(entity this, vector relOrigin, vector relSize, vector absOrigin, vector absSize))
76 SUPER(XonoticRegisteredSettingsList).resizeNotify(this, relOrigin, relSize, absOrigin, absSize);
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);
83 METHOD(XonoticRegisteredSettingsList, setSelected, void(entity this, int i))
85 SUPER(XonoticRegisteredSettingsList).setSelected(this, i);
86 this.onChange(this, this.onChangeEntity);
88 CONSTRUCTOR(XonoticRegisteredSettingsList, DataSource _source) {
89 CONSTRUCT(XonoticRegisteredSettingsList);
90 this.source = _source;
91 this.configureXonoticListBox(this);
95 METHOD(XonoticGameSettingsTab, topicChangeNotify, void(entity, entity this))
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;
103 this.currentItem = NULL;
104 c.removeItem(c, removing);
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);
112 METHOD(XonoticGameSettingsTab, fill, void(entity this))
114 entity topics = this.topicList;
115 topics.onChange = this.topicChangeNotify;
116 topics.onChangeEntity = this;
120 this.gotoRC(this, 0, col);
121 this.TD(this, this.rows, width, topics);
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);
127 this.topicChangeNotify(topics, this);