3 #include <common/items/item.qh>
4 #include <menu/anim/animhost.qh>
5 #include <menu/xonotic/datasource.qh>
8 X(NEW(FreetextSource), _("Guide"), "gametype_tdm") \
9 X(NEW(GametypeSource), _("Gametypes"), "gametype_dm") \
10 X(NEW(WeaponSource), _("Weapons"), "gametype_ka") \
11 X(NEW(ItemSource), _("Items"), "gametype_kh") \
12 X(NEW(BuffSource), _("Buffs"), "gametype_dom") \
13 X(NEW(NadeSource), _("Nades"), "gametype_ft") \
14 X(NEW(MonsterSource), _("Monsters"), "gametype_lms") \
15 X(NEW(VehicleSource), _("Vehicles"), "gametype_rc") \
16 X(NEW(TurretSource), _("Turrets"), "gametype_as") \
17 X(NEW(MutatorSource), _("Mutators"), "gametype_nb") \
18 X(NEW(MapSource), _("Maps"), "gametype_ctf") \
19 if (cvar("developer")) X(NEW(DebugSource), _("Debug"), "gametype_ons") \
21 CLASS(TopicSource, DataSource)
22 METHOD(TopicSource, getEntry, entity(TopicSource this, int i, void(string, string) returns)) {
24 #define TOPIC(src, name, icon) if (idx++ == i) { if (returns) returns(name, icon); return DataSource_true; }
27 if (returns) returns("undefined", "undefined");
28 return DataSource_false;
30 METHOD(TopicSource, reload, int(TopicSource this, string filter)) {
32 #define TOPIC(src, name, icon) n++;
39 CLASS(DebugSource, DataSource)
42 entity head = NULL, tail = NULL;
43 for (entity it = NULL; (it = nextent(it)); ) {
44 if (!it.instanceOfObject) continue;
45 if (it.instanceOfGameItem) continue;
46 if (it.instanceOfAnimHost) continue;
47 if (it.instanceOfDataSource) continue;
48 if (it.classname == "Object") continue;
49 if (it.classname == "vtbl") continue;
59 string DebugSource_activeFilter = "";
60 METHOD(DebugSource, getEntry, entity(DebugSource this, int i, void(string, string) returns)) {
63 for (e = find_debug(); e; e = e.nextdebug) {
64 if (strstrofs(sprintf("entity %i", e), DebugSource_activeFilter, 0) < 0) continue;
65 if (idx++ == i) break;
67 if (returns) e.display(e, returns);
70 METHOD(DebugSource, reload, int(DebugSource this, string filter)) {
71 DebugSource_activeFilter = filter;
74 for (e = find_debug(); e; e = e.nextdebug) {
75 if (strstrofs(sprintf("entity %i", e), DebugSource_activeFilter, 0) < 0) continue;
82 #define REGISTRY_SOURCE(id, arr) \
83 CLASS(id, DataSource) \
84 METHOD(id, getEntry, entity(id this, int i, void(string, string) returns)) { \
85 entity e = _R_GET(_##arr, i); \
86 if (returns) e.display(e, returns); \
89 METHOD(id, reload, int(id this, string filter)) { return arr##_COUNT; } \
93 REGISTRY_SOURCE(FreetextSource, GuidePages)
95 #include <common/mapinfo.qh>
96 REGISTRY_SOURCE(GametypeSource, Gametypes)
98 #include <common/items/all.qh>
99 REGISTRY_SOURCE(ItemSource, Items)
101 #include <common/mutators/mutator/buffs/buffs.qh>
102 REGISTRY_SOURCE(BuffSource, StatusEffect)
104 #include <common/mutators/mutator/nades/nades.qh>
105 REGISTRY_SOURCE(NadeSource, Nades)
107 #include <common/weapons/all.qh>
108 REGISTRY_SOURCE(WeaponSource, Weapons)
110 #include <common/monsters/all.qh>
111 REGISTRY_SOURCE(MonsterSource, Monsters)
113 #include <common/vehicles/all.qh>
114 REGISTRY_SOURCE(VehicleSource, Vehicles)
116 #include <common/turrets/all.qh>
117 REGISTRY_SOURCE(TurretSource, Turrets)
119 #include <common/mutators/base.qh>
120 REGISTRY_SOURCE(MutatorSource, Mutators)
122 CLASS(MapSource, DataSource)
123 METHOD(MapSource, getEntry, entity(MapSource this, int i, void(string, string) returns)) {
124 if (!MapInfo_Get_ByID(i)) return DataSource_false;
125 string path = strcat("/maps/", MapInfo_Map_bspname);
126 string img = draw_PictureSize(path) ? path : "nopreview_map";
127 if (returns) returns(MapInfo_Map_titlestring, img);
128 MapInfo_ClearTemps();
129 return DataSource_true;
131 METHOD(MapSource, indexOf, int(MapSource this, string s)) {
133 return MapInfo_FindName_firstResult;
135 METHOD(MapSource, reload, int(MapSource this, string s)) {
136 _MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 0);
137 if (s) MapInfo_FilterString(s);
138 return MapInfo_count;
140 METHOD(MapSource, destroy, void(MapSource this)) { MapInfo_Shutdown(); }
144 #include "entries.qh"
145 #include "description.qh"
146 #include <menu/xonotic/tab.qh>
147 CLASS(XonoticGuideTab, XonoticTab)
148 ATTRIB(XonoticGuideTab, rows, float, 21);
149 ATTRIB(XonoticGuideTab, columns, float, 6);
150 ATTRIB(XonoticGuideTab, intendedWidth, float, 1);
151 METHOD(XonoticGuideTab, fill, void(entity));
152 METHOD(XonoticGuideTab, topicChangeNotify, void(entity, entity));
153 METHOD(XonoticGuideTab, entryChangeNotify, void(entity, entity));
155 ATTRIB(XonoticGuideTab, controlledTextbox, entity);
156 ATTRIB(XonoticGuideTab, topicList, entity, NEW(XonoticTopicList, NEW(TopicSource)));
157 ATTRIB(XonoticGuideTab, entryList, entity, NEW(XonoticEntryList, NULL));
158 ATTRIB(XonoticGuideTab, descriptionPane, entity, NEW(XonoticGuideDescription));
160 INIT(XonoticGuideTab) {
161 this.configureDialog(this);
163 ENDCLASS(XonoticGuideTab)