]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Relocate methods to .qc files from .qh
authorotta8634 <k9wolf@pm.me>
Mon, 16 Dec 2024 10:53:31 +0000 (18:53 +0800)
committerotta8634 <k9wolf@pm.me>
Mon, 16 Dec 2024 11:08:37 +0000 (19:08 +0800)
Also replaced cvar("developer").

qcsrc/menu/xonotic/dialog_multiplayer_media_guide.qc
qcsrc/menu/xonotic/guide/description.qc
qcsrc/menu/xonotic/guide/description.qh
qcsrc/menu/xonotic/guide/entries.qc
qcsrc/menu/xonotic/guide/guide.qc
qcsrc/menu/xonotic/guide/guide.qh
qcsrc/menu/xonotic/guide/pages.qc
qcsrc/menu/xonotic/guide/pages.qh
qcsrc/menu/xonotic/guide/topics.qc

index c65e5682298aab64e6a60b938846268cc4e5e0ab..5faa81d5b2cef14721d7765b3447c564d550e870 100644 (file)
@@ -73,7 +73,7 @@ void XonoticGuideTab_entryChangeNotify(entity, entity this)
        entity entries = this.entryList;
        entity e = entries.source.getEntry(entries.source, entries.selectedItem, func_null);
        string s = e.describe(e);
-       if (cvar("developer"))
+       if (gamestatus & GAME_DEVELOPER)
                s = sprintf("entity %i\n%s", e, s);
        desc.setDescription(desc, s);
 }
index 35068c1e5bbeebf4242b412bb6822fe3b006c38f..ae81664e2c9eb001d03321518683de40152f9cd9 100644 (file)
@@ -1 +1,43 @@
 #include "description.qh"
+
+void XonoticGuideDescription_drawListBoxItem(entity this, int i, vector absSize, bool isSelected, bool isFocused)
+{
+       tokenizebyseparator(this.descriptionWrapped, "\n");
+       draw_Text(this.realUpperMargin * eY, argv(i), this.realFontSize, '1 1 1', 1, 0);
+}
+
+void XonoticGuideDescription_setDescription(entity this, string desc)
+{
+       string current = this.description;
+       if (current && current != desc)
+               strunzone(current);
+       this.description = strzone(desc);
+
+       string currentWrapped = this.descriptionWrapped;
+       if (currentWrapped)
+               strunzone(currentWrapped);
+       string wrapped = "";
+       for (int i = 0, n = tokenizebyseparator(desc, "\n"); i < n; ++i)
+       {
+               string line = "";
+               for (getWrappedLine_remaining = argv(i); getWrappedLine_remaining; )
+               {
+                       string s = getWrappedLine(1, this.realFontSize, draw_TextWidth_WithColors);
+                       line = strcat(line, "\n", s);
+               }
+               wrapped = strcat(wrapped, line);
+       }
+       this.descriptionWrapped = strzone(wrapped);
+
+       this.nItems = tokenizebyseparator(wrapped, "\n");
+}
+
+void XonoticGuideDescription_resizeNotify(entity this, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
+{
+       SUPER(XonoticGuideDescription).resizeNotify(this, relOrigin, relSize, absOrigin, absSize);
+
+       this.realFontSize_y = this.fontSize / (absSize.y * this.itemHeight);
+       this.realFontSize_x = this.fontSize / (absSize.x * (1 - this.controlWidth));
+       this.realUpperMargin = 0.5 * (1 - this.realFontSize.y);
+       this.setDescription(this, this.description);
+}
index a7f1501090a3aadb2d6df615abf707955c109c70..81e9644d0863d4b3b9eeb1c3648760e1c53982ae 100644 (file)
@@ -6,52 +6,14 @@ CLASS(XonoticGuideDescription, XonoticListBox)
        ATTRIB(XonoticGuideDescription, realUpperMargin, float, 0);
        ATTRIB(XonoticGuideDescription, rowsPerItem, float, 1);
        ATTRIB(XonoticGuideDescription, selectionDoesntMatter, bool, true);
-
-       METHOD(XonoticGuideDescription, setDescription, void(entity, string));
        ATTRIB(XonoticGuideDescription, description, string, string_null);
+       ATTRIB(XonoticGuideDescription, descriptionWrapped, string, string_null);
 
-       METHOD(XonoticGuideDescription, resizeNotify, void(entity this, vector relOrigin, vector relSize, vector absOrigin, vector absSize)) {
-               SUPER(XonoticGuideDescription).resizeNotify(this, relOrigin, relSize, absOrigin, absSize);
-
-               this.realFontSize_y = this.fontSize / (absSize.y * this.itemHeight);
-               this.realFontSize_x = this.fontSize / (absSize.x * (1 - this.controlWidth));
-               this.realUpperMargin = 0.5 * (1 - this.realFontSize.y);
-               this.setDescription(this, this.description);
-       }
+       METHOD(XonoticGuideDescription, drawListBoxItem, void(entity, int, vector, bool, bool));
+       METHOD(XonoticGuideDescription, setDescription, void(entity, string));
+       METHOD(XonoticGuideDescription, resizeNotify, void(entity, vector, vector, vector, vector));
 
        INIT(XonoticGuideDescription) {
                this.configureXonoticListBox(this);
        }
-
-       ATTRIB(XonoticGuideDescription, descriptionWrapped, string, string_null);
-       void XonoticGuideDescription_setDescription(entity this, string desc)
-       {
-               string current = this.description;
-               if (current && current != desc)
-                       strunzone(current);
-               this.description = strzone(desc);
-
-               string currentWrapped = this.descriptionWrapped;
-               if (currentWrapped)
-                       strunzone(currentWrapped);
-               string wrapped = "";
-               for (int i = 0, n = tokenizebyseparator(desc, "\n"); i < n; ++i)
-               {
-                       string line = "";
-                       for (getWrappedLine_remaining = argv(i); getWrappedLine_remaining; )
-                       {
-                               string s = getWrappedLine(1, this.realFontSize, draw_TextWidth_WithColors);
-                               line = strcat(line, "\n", s);
-                       }
-                       wrapped = strcat(wrapped, line);
-               }
-               this.descriptionWrapped = strzone(wrapped);
-
-               this.nItems = tokenizebyseparator(wrapped, "\n");
-       }
-
-       METHOD(XonoticGuideDescription, drawListBoxItem, void(entity this, int i, vector absSize, bool isSelected, bool isFocused)) {
-               tokenizebyseparator(this.descriptionWrapped, "\n");
-               draw_Text(this.realUpperMargin * eY, argv(i), this.realFontSize, '1 1 1', 1, 0);
-       }
 ENDCLASS(XonoticGuideDescription)
index f09210db876fa0e46ecaf14018915e9613ed9ce1..5d7fe8e96ba44f461ad6c73fa4ebdc7b91d0c201 100644 (file)
@@ -5,7 +5,8 @@
 #include <menu/xonotic/mainwindow.qh>
 
 string XonoticEntryList_cb_name, XonoticEntryList_cb_icon;
-void XonoticEntryList_cb(string _name, string _icon) {
+void XonoticEntryList_cb(string _name, string _icon)
+{
        XonoticEntryList_cb_name = _name;
        XonoticEntryList_cb_icon = _icon;
 }
index ca61a60117b7ea6f69bad00789a69577202d1b0f..5723211f8a612f8735e0e6785f901dd54118c576 100644 (file)
@@ -1 +1,100 @@
 #include "guide.qh"
+
+METHOD(TopicSource, getEntry, entity(TopicSource this, int i, void(string, string) returns))
+{
+       int idx = 0;
+       #define TOPIC(src, name, icon) \
+               if (idx++ == i) \
+               { \
+                       if (returns) \
+                               returns(name, icon); \
+                       return DataSource_true; \
+               }
+       TOPICS(TOPIC);
+       #undef TOPIC
+       if (returns)
+               returns("undefined", "undefined");
+       return DataSource_false;
+}
+METHOD(TopicSource, reload, int(TopicSource this, string filter))
+{
+       int n = 0;
+       #define TOPIC(src, name, icon) n++;
+       TOPICS(TOPIC);
+       #undef TOPIC
+       return n;
+}
+
+entity DebugSource_find_debug()
+{
+       entity head = NULL, tail = NULL;
+       for (entity it = NULL; (it = nextent(it)); ) {
+               if (!it.instanceOfObject) continue;
+               if (it.instanceOfGameItem) continue;
+               if (it.instanceOfAnimHost) continue;
+               if (it.instanceOfDataSource) continue;
+               if (it.classname == "Object") continue;
+               if (it.classname == "vtbl") continue;
+               if (!tail)
+                       tail = head = it;
+               else
+               {
+                       tail.nextdebug = it;
+                       tail = it;
+               }
+       }
+       return head;
+}
+METHOD(DebugSource, getEntry, entity(DebugSource this, int i, void(string, string) returns))
+{
+       int idx = 0;
+       entity e;
+       for (e = DebugSource_find_debug(); e; e = e.nextdebug)
+       {
+               if (strstrofs(sprintf("entity %i", e), DebugSource_activeFilter, 0) < 0) continue;
+               if (idx++ == i) break;
+       }
+       if (returns)
+               e.display(e, returns);
+       return e;
+}
+METHOD(DebugSource, reload, int(DebugSource this, string filter))
+{
+       DebugSource_activeFilter = filter;
+       int idx = 0;
+       entity e;
+       for (e = DebugSource_find_debug(); e; e = e.nextdebug)
+       {
+               if (strstrofs(sprintf("entity %i", e), DebugSource_activeFilter, 0) < 0) continue;
+               idx++;
+       }
+       return idx;
+}
+
+METHOD(MapSource, getEntry, entity(MapSource this, int i, void(string, string) returns))
+{
+       if (!MapInfo_Get_ByID(i))
+               return DataSource_false;
+       string path = strcat("/maps/", MapInfo_Map_bspname);
+       string img = draw_PictureSize(path) ? path : "nopreview_map";
+       if (returns)
+               returns(MapInfo_Map_titlestring, img);
+       MapInfo_ClearTemps();
+       return DataSource_true;
+}
+METHOD(MapSource, indexOf, int(MapSource this, string s))
+{
+       MapInfo_FindName(s);
+       return MapInfo_FindName_firstResult;
+}
+METHOD(MapSource, reload, int(MapSource this, string s))
+{
+       _MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 0);
+       if (s)
+               MapInfo_FilterString(s);
+       return MapInfo_count;
+}
+METHOD(MapSource, destroy, void(MapSource this))
+{
+       MapInfo_Shutdown();
+}
index 2bf2aa55618afd634faaf4f5e976d750e865ffe0..b1f36ec58c7373f65c139fd9f09257ca4e935c9e 100644 (file)
        X(NEW(TurretSource),    _("Turrets"),   "gametype_as") \
        X(NEW(MutatorSource),   _("Mutators"),  "gametype_nb") \
        X(NEW(MapSource),       _("Maps"),      "gametype_ctf") \
-       if (cvar("developer")) X(NEW(DebugSource), _("Debug"), "gametype_ons") \
+       if (gamestatus & GAME_DEVELOPER) X(NEW(DebugSource), _("Debug"), "gametype_ons") \
        /**/
 CLASS(TopicSource, DataSource)
-       METHOD(TopicSource, getEntry, entity(TopicSource this, int i, void(string, string) returns)) {
-               int idx = 0;
-               #define TOPIC(src, name, icon) \
-                       if (idx++ == i) \
-                       { \
-                               if (returns) \
-                                       returns(name, icon); \
-                               return DataSource_true; \
-                       }
-               TOPICS(TOPIC);
-               #undef TOPIC
-               if (returns)
-                       returns("undefined", "undefined");
-               return DataSource_false;
-       }
-       METHOD(TopicSource, reload, int(TopicSource this, string filter)) {
-               int n = 0;
-               #define TOPIC(src, name, icon) n++;
-               TOPICS(TOPIC);
-               #undef TOPIC
-               return n;
-       }
+       METHOD(TopicSource, getEntry, entity(TopicSource this, int i, void(string, string) returns));
+       METHOD(TopicSource, reload, int(TopicSource this, string filter));
 ENDCLASS(TopicSource)
 
 CLASS(DebugSource, DataSource)
        .entity nextdebug;
-       entity find_debug() {
-               entity head = NULL, tail = NULL;
-               for (entity it = NULL; (it = nextent(it)); ) {
-                       if (!it.instanceOfObject) continue;
-                       if (it.instanceOfGameItem) continue;
-                       if (it.instanceOfAnimHost) continue;
-                       if (it.instanceOfDataSource) continue;
-                       if (it.classname == "Object") continue;
-                       if (it.classname == "vtbl") continue;
-                       if (!tail)
-                               tail = head = it;
-                       else
-                       {
-                               tail.nextdebug = it;
-                               tail = it;
-                       }
-               }
-               return head;
-       }
        string DebugSource_activeFilter = "";
-       METHOD(DebugSource, getEntry, entity(DebugSource this, int i, void(string, string) returns)) {
-               int idx = 0;
-               entity e;
-               for (e = find_debug(); e; e = e.nextdebug)
-               {
-                       if (strstrofs(sprintf("entity %i", e), DebugSource_activeFilter, 0) < 0) continue;
-                       if (idx++ == i) break;
-               }
-               if (returns)
-                       e.display(e, returns);
-               return e;
-       }
-       METHOD(DebugSource, reload, int(DebugSource this, string filter)) {
-               DebugSource_activeFilter = filter;
-               int idx = 0;
-               entity e;
-               for (e = find_debug(); e; e = e.nextdebug)
-               {
-                       if (strstrofs(sprintf("entity %i", e), DebugSource_activeFilter, 0) < 0) continue;
-                       idx++;
-               }
-               return idx;
-       }
+       METHOD(DebugSource, getEntry, entity(DebugSource this, int i, void(string, string) returns));
+       METHOD(DebugSource, reload, int(DebugSource this, string filter));
 ENDCLASS(DebugSource)
 
 .bool m_hidden;
@@ -144,25 +84,8 @@ REGISTRY_SOURCE(TurretSource, Turrets)
 REGISTRY_SOURCE(MutatorSource, Mutators)
 
 CLASS(MapSource, DataSource)
-       METHOD(MapSource, getEntry, entity(MapSource this, int i, void(string, string) returns)) {
-               if (!MapInfo_Get_ByID(i))
-                       return DataSource_false;
-               string path = strcat("/maps/", MapInfo_Map_bspname);
-               string img = draw_PictureSize(path) ? path : "nopreview_map";
-               if (returns)
-                       returns(MapInfo_Map_titlestring, img);
-               MapInfo_ClearTemps();
-               return DataSource_true;
-       }
-       METHOD(MapSource, indexOf, int(MapSource this, string s)) {
-               MapInfo_FindName(s);
-               return MapInfo_FindName_firstResult;
-       }
-       METHOD(MapSource, reload, int(MapSource this, string s)) {
-               _MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 0);
-               if (s)
-                       MapInfo_FilterString(s);
-               return MapInfo_count;
-       }
-       METHOD(MapSource, destroy, void(MapSource this)) { MapInfo_Shutdown(); }
+       METHOD(MapSource, getEntry, entity(MapSource this, int i, void(string, string) returns));
+       METHOD(MapSource, indexOf, int(MapSource this, string s));
+       METHOD(MapSource, reload, int(MapSource this, string s));
+       METHOD(MapSource, destroy, void(MapSource));
 ENDCLASS(MapSource)
index e79aed7efdf9862828d1b92fd85c642cdf661afd..1b15398b5907058d970f7c5a5168f696b7fe1de1 100644 (file)
@@ -1 +1,10 @@
 #include "pages.qh"
+
+METHOD(GuidePage, describe, string(GuidePage this))
+{
+       return this.m_description;
+}
+METHOD(GuidePage, display, void(GuidePage this, void(string name, string icon) returns))
+{
+       returns(this.m_title, "nopreview_map");
+}
index 78030ea40baac7724449bc4878ed8b8b4edef72f..b11cb9fb8ea152e82176d57b8cb5708b7c6d9cf5 100644 (file)
@@ -4,16 +4,15 @@ CLASS(GuidePage, Object);
        ATTRIB(GuidePage, m_id, int, 0);
        ATTRIB(GuidePage, m_title, string, "");
        ATTRIB(GuidePage, m_description, string, "");
-       METHOD(GuidePage, describe, string(GuidePage this)) {
-               return this.m_description;
-       }
-       METHOD(GuidePage, display, void(GuidePage this, void(string name, string icon) returns)) {
-               returns(this.m_title, "nopreview_map");
-       }
+
+       METHOD(GuidePage, describe, string(GuidePage));
+       METHOD(GuidePage, display, void(GuidePage this, void(string name, string icon) returns));
+
        CONSTRUCTOR(GuidePage, string _title) {
                CONSTRUCT(GuidePage);
                this.m_title = _title;
        }
+
 ENDCLASS(GuidePage)
 
 REGISTRY(GuidePages, 16)
index 0e693dc948c916b11d318e20446c7dc67c30a8f6..369509f9f9cd638497d107ede7713f962991f5a5 100644 (file)
@@ -8,7 +8,8 @@ void XonoticTopicList_clickListBoxItem(entity this, float i, vector where)
 }
 
 string XonoticTopicList_cb_name, XonoticTopicList_cb_icon;
-void XonoticTopicList_cb(string _name, string _icon) {
+void XonoticTopicList_cb(string _name, string _icon)
+{
        XonoticTopicList_cb_name = _name;
        XonoticTopicList_cb_icon = _icon;
 }