]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/guide/tab.qc
8b14a82fa6506b298d67f8eaffd4ad22268fba23
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / guide / tab.qc
1 #include "tab.qh"
2
3 void XonoticGuideTab_fill(entity this)
4 {
5     entity topics = this.topicList;
6         topics.onChange = XonoticGuideTab_topicChangeNotify;
7         topics.onChangeEntity = this;
8     entity entries = this.entryList;
9         entries.onChange = XonoticGuideTab_entryChangeNotify;
10         entries.onChangeEntity = this;
11     entity filter = entries.stringFilterBox = makeXonoticInputBox(false, string_null);
12         filter.keyDown = MapList_StringFilterBox_keyDown;
13         filter.onChange = MapList_StringFilterBox_Change;
14         filter.onChangeEntity = entries;
15     entries.controlledTextbox = filter;
16     entity description = this.descriptionPane;
17
18     int
19     col = 0, width = 1.5;
20     this.gotoRC(this, 0, col);
21         this.TD(this, 1, width, makeXonoticHeaderLabel(_("Topic")));
22     this.TR(this);
23         this.TD(this, this.rows - 1, width, topics);
24
25     col += width, width = 2;
26     this.gotoRC(this, 0, col); this.setFirstColumn(this, this.currentColumn);
27         this.TD(this, 1, width, makeXonoticHeaderLabel(_("Entry")));
28     this.TR(this);
29         this.TD(this, this.rows - 1 - 1, width, entries);
30     this.gotoRC(this, this.rows - 1, col);
31         this.TD(this, 1, 0.3, makeXonoticTextLabel(0, _("Filter:")));
32         this.TD(this, 1, width - 0.3, filter);
33
34     col += width, width = 2.5;
35     this.gotoRC(this, 0, col); this.setFirstColumn(this, this.currentColumn);
36         this.TD(this, 1, width, makeXonoticHeaderLabel(_("Description")));
37     this.TR(this);
38         this.TD(this, this.rows - 1, width, description);
39
40     this.topicChangeNotify(topics, this);
41 }
42
43 void XonoticGuideTab_topicChangeNotify(entity, entity this)
44 {
45     entity topics = this.topicList;
46     entity entries = this.entryList;
47     int i = topics.selectedItem;
48     int idx = 0;
49     entity found = NULL;
50     #define TOPIC(src, name, icon) if (idx++ == i) { static entity e; if (!e) e = src; found = e; break; }
51     do { TOPICS(TOPIC); } while (0);
52     #undef TOPIC
53     entries.source = found;
54     entries.refilter(entries);
55     entries.setSelected(entries, 0);
56 }
57
58 void XonoticGuideTab_entryChangeNotify(entity, entity this)
59 {
60     entity desc = this.descriptionPane;
61     entity entries = this.entryList;
62     entity e = entries.source.getEntry(entries.source, entries.selectedItem, func_null);
63     string s = e.describe(e);
64     if (cvar("developer")) { s = sprintf("entity %i\n%s", e, s); }
65     desc.setDescription(desc, s);
66 }