From a1a4c6754f9a8c8374d76ae368e8c8e2294876d5 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sun, 16 Aug 2015 20:29:17 +1000 Subject: [PATCH] Add a debug menu --- qcsrc/menu/xonotic/dialog_media_guide.qc | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/qcsrc/menu/xonotic/dialog_media_guide.qc b/qcsrc/menu/xonotic/dialog_media_guide.qc index 929cc20151..8ea4214fbf 100644 --- a/qcsrc/menu/xonotic/dialog_media_guide.qc +++ b/qcsrc/menu/xonotic/dialog_media_guide.qc @@ -5,6 +5,7 @@ #define TOPICS(X) \ X(NEW(GametypeSource), _("Gametypes"), "gametype_dm") \ X(NEW(MapSource), _("Maps"), "gametype_ctf") \ + if (cvar("developer")) X(NEW(DebugSource), _("Debug"), "gametype_ons") \ /**/ CLASS(TopicSource, DataSource) .string icon, name; @@ -32,6 +33,39 @@ CLASS(TopicSource, DataSource) } ENDCLASS(TopicSource) +CLASS(DebugSource, DataSource) + .string name, icon; + ATTRIB(DebugSource, entryName, .string, name) + ATTRIB(DebugSource, entryIcon, .string, icon) + .entity chain; + METHOD(DebugSource, getEntry, entity(int)) + entity DebugSource_getEntry(int i) { + int idx = 0; + entity e; + for (e = findchainfloat(instanceOfObject, true); e; e = e.chain) { + if (e.classname == "vtbl") continue; + if (e.instanceOfItem) continue; + if (idx++ == i) break; + } + static entity entry; + if (!entry) entry = new(entry); + entry.name = sprintf("entity %i", e); + entry.icon = ""; + return entry; + } + METHOD(DebugSource, reload, int(string)) + int DebugSource_reload(string filter) { + int idx = 0; + entity e; + for (e = findchainfloat(instanceOfObject, true); e; e = e.chain) { + if (e.classname == "vtbl") continue; + if (e.instanceOfItem) continue; + idx++; + } + return idx; + } +ENDCLASS(DebugSource) + #include "../../common/mapinfo.qh" CLASS(GametypeSource, DataSource) .string mdl, message; -- 2.39.2