]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Cleanup guide freetext section code
authorotta8634 <k9wolf@pm.me>
Fri, 10 Jan 2025 15:14:43 +0000 (23:14 +0800)
committerotta8634 <k9wolf@pm.me>
Fri, 10 Jan 2025 15:51:25 +0000 (23:51 +0800)
Relocated describe and display method code to pages.qc.
Made the constructor take an icon string, and renamed m_title to m_name.

qcsrc/menu/xonotic/guide/pages.qc
qcsrc/menu/xonotic/guide/pages.qh

index aa8c70d6ff16600b37218bdfbb7ec244ff74e8b3..e79aed7efdf9862828d1b92fd85c642cdf661afd 100644 (file)
@@ -1,19 +1 @@
 #include "pages.qh"
-
-METHOD(GuidePage, describe, string(GuidePage this))
-{
-       TC(GuidePage, this);
-       return this.m_description;
-}
-METHOD(GuidePage, display, void(GuidePage this, void(string name, string icon) returns))
-{
-       TC(GuidePage, this);
-       string icon_str;
-       if (this.m_title == _("Introduction"))
-               icon_str = "gametype_dm";
-       else if (this.m_title == _("Movement"))
-               icon_str = "gametype_inv";
-       else
-               icon_str = string_null;
-       returns(this.m_title, icon_str);
-}
index 5f29b530bd079b2b11739167e17153addc217a12..3eae3a715269ca18aec08c37a637e6160d854d3f 100644 (file)
@@ -2,27 +2,40 @@
 
 CLASS(GuidePage, Object);
        ATTRIB(GuidePage, m_id, int, 0);
-       ATTRIB(GuidePage, m_title, string, "");
+       ATTRIB(GuidePage, m_name, string, "");
+       ATTRIB(GuidePage, m_icon, string);
        ATTRIB(GuidePage, m_description, string, "");
 
-       METHOD(GuidePage, describe, string(GuidePage));
-       METHOD(GuidePage, display, void(GuidePage this, void(string name, string icon) returns));
+       METHOD(GuidePage, describe, string(GuidePage this))
+       {
+               TC(GuidePage, this);
+               return this.m_description;
+       }
+       METHOD(GuidePage, display, void(GuidePage this, void(string name, string icon) returns))
+       {
+               TC(GuidePage, this);
+               returns(this.m_name, this.m_icon ? this.m_icon : string_null);
+       }
 
-       CONSTRUCTOR(GuidePage, string _title) {
+       CONSTRUCTOR(GuidePage, string _name, string _icon) {
                CONSTRUCT(GuidePage);
-               this.m_title = _title;
+               this.m_name = _name;
+               this.m_icon = _icon;
        }
 ENDCLASS(GuidePage)
 
 REGISTRY(GuidePages, 16)
-#define REGISTER_GUIDE_PAGE(id, title) \
-       REGISTER(GuidePages, GUIDE_PAGE, id, m_id, NEW(GuidePage, title))
+#define REGISTER_GUIDE_PAGE(id, name, icon) \
+       REGISTER(GuidePages, GUIDE_PAGE, id, m_id, NEW(GuidePage, name, icon))
 REGISTER_REGISTRY(GuidePages)
 
-REGISTER_GUIDE_PAGE(0, _("Introduction")) {
+REGISTER_GUIDE_PAGE(0, _("Introduction"), "gametype_dm")
+{
        this.m_description = _("Welcome to Xonotic, the free and fast arena shooter!\n\n"
                "Keep in mind all values and descriptions in this guide are based on the default game settings, so it may differ from the experience when playing on some modified servers");
 }
-REGISTER_GUIDE_PAGE(1, _("Movement")) {
+
+REGISTER_GUIDE_PAGE(1, _("Movement"), "gametype_inv")
+{
        this.m_description = _("In Xonotic to move quickly you will have to airstrafe and bunnyhop"); // TODO
 }