3 #include <menu/xonotic/datasource.qh>
6 X(NEW(FreetextSource), _("Guide"), "gametype_tdm") \
7 X(NEW(GametypeSource), _("Gametypes"), "gametype_dm") \
8 X(NEW(WeaponSource), _("Weapons"), "gametype_ka") \
9 X(NEW(ItemSource), _("Items"), "gametype_kh") \
10 X(NEW(BuffSource), _("Buffs"), "gametype_dom") \
11 X(NEW(NadeSource), _("Nades"), "gametype_ft") \
12 X(NEW(MonsterSource), _("Monsters"), "gametype_lms") \
13 X(NEW(VehicleSource), _("Vehicles"), "gametype_rc") \
14 X(NEW(TurretSource), _("Turrets"), "gametype_as") \
15 X(NEW(MutatorSource), _("Mutators"), "gametype_nb") \
16 X(NEW(MapSource), _("Maps"), "gametype_ctf") \
17 if (cvar("developer")) X(NEW(DebugSource), _("Debug"), "gametype_ons") \
19 CLASS(TopicSource, DataSource)
20 METHOD(TopicSource, getEntry, entity(TopicSource this, int i, void(string, string) returns)) {
22 #define TOPIC(src, name, icon) if (idx++ == i) { if (returns) returns(name, icon); return DataSource_true; }
25 if (returns) returns("undefined", "undefined");
26 return DataSource_false;
28 METHOD(TopicSource, reload, int(TopicSource this, string filter)) {
30 #define TOPIC(src, name, icon) n++;
37 CLASS(DebugSource, DataSource)
40 entity head = NULL, tail = NULL;
41 for (entity it = NULL; (it = nextent(it)); ) {
42 if (!it.instanceOfObject) continue;
43 if (it.instanceOfGameItem) continue;
44 if (it.instanceOfAnimHost) continue;
45 if (it.instanceOfDataSource) continue;
46 if (it.classname == "Object") continue;
47 if (it.classname == "vtbl") continue;
57 string DebugSource_activeFilter = "";
58 METHOD(DebugSource, getEntry, entity(DebugSource this, int i, void(string, string) returns)) {
61 for (e = find_debug(); e; e = e.nextdebug) {
62 if (strstrofs(sprintf("entity %i", e), DebugSource_activeFilter, 0) < 0) continue;
63 if (idx++ == i) break;
65 if (returns) e.display(e, returns);
68 METHOD(DebugSource, reload, int(DebugSource this, string filter)) {
69 DebugSource_activeFilter = filter;
72 for (e = find_debug(); e; e = e.nextdebug) {
73 if (strstrofs(sprintf("entity %i", e), DebugSource_activeFilter, 0) < 0) continue;
80 #define REGISTRY_SOURCE(id, arr) \
81 CLASS(id, DataSource) \
82 METHOD(id, getEntry, entity(id this, int i, void(string, string) returns)) { \
83 entity e = _R_GET(_##arr, i); \
84 if (returns) e.display(e, returns); \
87 METHOD(id, reload, int(id this, string filter)) { return arr##_COUNT; } \
91 REGISTRY_SOURCE(FreetextSource, GuidePages)
93 #include <common/mapinfo.qh>
94 REGISTRY_SOURCE(GametypeSource, Gametypes)
96 #include <common/items/all.qh>
97 REGISTRY_SOURCE(ItemSource, Items)
99 #include <common/mutators/mutator/buffs/buffs.qh>
100 REGISTRY_SOURCE(BuffSource, Buffs)
102 #include <common/mutators/mutator/nades/nades.qh>
103 REGISTRY_SOURCE(NadeSource, Nades)
105 #include <common/weapons/all.qh>
106 REGISTRY_SOURCE(WeaponSource, Weapons)
108 #include <common/monsters/all.qh>
109 REGISTRY_SOURCE(MonsterSource, Monsters)
111 #include <common/vehicles/all.qh>
112 REGISTRY_SOURCE(VehicleSource, Vehicles)
114 #include <common/turrets/all.qh>
115 REGISTRY_SOURCE(TurretSource, Turrets)
117 #include <common/mutators/base.qh>
118 REGISTRY_SOURCE(MutatorSource, Mutators)
120 CLASS(MapSource, DataSource)
121 METHOD(MapSource, getEntry, entity(MapSource this, int i, void(string, string) returns)) {
122 if (!MapInfo_Get_ByID(i)) return DataSource_false;
123 string path = strcat("/maps/", MapInfo_Map_bspname);
124 string img = draw_PictureSize(path) ? path : "nopreview_map";
125 if (returns) returns(MapInfo_Map_titlestring, img);
126 MapInfo_ClearTemps();
127 return DataSource_true;
129 METHOD(MapSource, indexOf, int(MapSource this, string s)) {
131 return MapInfo_FindName_firstResult;
133 METHOD(MapSource, reload, int(MapSource this, string s)) {
134 _MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 0);
135 if (s) MapInfo_FilterString(s);
136 return MapInfo_count;
138 METHOD(MapSource, destroy, void(MapSource this)) { MapInfo_Shutdown(); }
142 #include "entries.qh"
143 #include "description.qh"
144 #include <menu/xonotic/tab.qh>
145 CLASS(XonoticGuideTab, XonoticTab)
146 ATTRIB(XonoticGuideTab, rows, float, 21);
147 ATTRIB(XonoticGuideTab, columns, float, 6);
148 ATTRIB(XonoticGuideTab, intendedWidth, float, 1);
149 METHOD(XonoticGuideTab, fill, void(entity));
150 METHOD(XonoticGuideTab, topicChangeNotify, void(entity, entity));
151 METHOD(XonoticGuideTab, entryChangeNotify, void(entity, entity));
153 ATTRIB(XonoticGuideTab, topicList, entity, NEW(XonoticTopicList, NEW(TopicSource)));
154 ATTRIB(XonoticGuideTab, entryList, entity, NEW(XonoticEntryList, NULL));
155 ATTRIB(XonoticGuideTab, descriptionPane, entity, NEW(XonoticGuideDescription));
157 INIT(XonoticGuideTab) {
158 this.configureDialog(this);
160 ENDCLASS(XonoticGuideTab)