Also replaced cvar("developer").
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);
}
#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);
+}
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)
#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;
}
#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();
+}
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;
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)
#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");
+}
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)
}
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;
}