From: otta8634 Date: Fri, 10 Jan 2025 15:14:43 +0000 (+0800) Subject: Cleanup guide freetext section code X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a70d3e27ec7864acb769bd5e0cd05a962c9bedbf;p=xonotic%2Fxonotic-data.pk3dir.git Cleanup guide freetext section code Relocated describe and display method code to pages.qc. Made the constructor take an icon string, and renamed m_title to m_name. --- diff --git a/qcsrc/menu/xonotic/guide/pages.qc b/qcsrc/menu/xonotic/guide/pages.qc index aa8c70d6ff..e79aed7efd 100644 --- a/qcsrc/menu/xonotic/guide/pages.qc +++ b/qcsrc/menu/xonotic/guide/pages.qc @@ -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); -} diff --git a/qcsrc/menu/xonotic/guide/pages.qh b/qcsrc/menu/xonotic/guide/pages.qh index 5f29b530bd..3eae3a7152 100644 --- a/qcsrc/menu/xonotic/guide/pages.qh +++ b/qcsrc/menu/xonotic/guide/pages.qh @@ -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 }