#include "xonotic/crosshairpicker.qc"
#include "xonotic/crosshairpreview.qc"
#include "xonotic/cvarlist.qc"
+#include "xonotic/datasource.qc"
#include "xonotic/demolist.qc"
#include "xonotic/dialog.qc"
#include "xonotic/dialog_credits.qc"
--- /dev/null
+#ifndef DATASOURCE_H
+#define DATASOURCE_H
+.string stringfield_null;
+CLASS(DataSource, Object)
+ ATTRIB(DataSource, entryIcon, .string, stringfield_null)
+ ATTRIB(DataSource, entryName, .string, stringfield_null)
+ METHOD(DataSource, getEntry, entity(int))
+ METHOD(DataSource, indexOf, int(string))
+ METHOD(DataSource, reload, int(string))
+ METHOD(DataSource, destroy, void(entity))
+ENDCLASS(DataSource)
+#endif
#ifndef DIALOG_MEDIA_GUIDE_H
#define DIALOG_MEDIA_GUIDE_H
+#include "datasource.qc"
+CLASS(TopicSource, DataSource)
+ .string mdl, message;
+ ATTRIB(TopicSource, entryIcon, .string, mdl)
+ ATTRIB(TopicSource, entryName, .string, message)
+ METHOD(TopicSource, getEntry, entity(int))
+ METHOD(TopicSource, reload, int(string))
+ METHOD(TopicSource, destroy, void(entity))
+ENDCLASS(TopicSource)
+
+CLASS(MapSource, DataSource)
+ .string icon, name;
+ ATTRIB(MapSource, entryIcon, .string, icon)
+ ATTRIB(MapSource, entryName, .string, name)
+ METHOD(MapSource, getEntry, entity(int))
+ METHOD(MapSource, indexOf, int(string))
+ METHOD(MapSource, reload, int(string))
+ENDCLASS(MapSource)
+
#include "dialog_media_guide_topics.qc"
#include "dialog_media_guide_entries.qc"
#include "tab.qc"
METHOD(XonoticGuideTab, topicChangeNotify, void(entity))
METHOD(XonoticGuideTab, topicSelectNotify, void(entity))
- entity Topics_get(int i);
- int Topics_reload(string filter);
- .string mdl, message;
- ATTRIB(XonoticGuideTab, topicList, entity, NEW(XonoticTopicList, Topics_get, func_null, Topics_reload, mdl, message, func_null, this))
+ ATTRIB(XonoticGuideTab, topicSource, entity, NEW(TopicSource))
+ ATTRIB(XonoticGuideTab, mapSource, entity, NEW(MapSource))
- entity XonoticGuideTab_maps_get(int i);
- int XonoticGuideTab_maps_indexOf(string s);
- int XonoticGuideTab_maps_reload(string s);
- void XonoticGuideTab_maps_destroy(entity this);
- .string icon, name;
- ATTRIB(XonoticGuideTab, entryList, entity, NEW(XonoticEntryList, XonoticGuideTab_maps_get, XonoticGuideTab_maps_indexOf, XonoticGuideTab_maps_reload, icon, name, XonoticGuideTab_maps_destroy))
+ ATTRIB(XonoticGuideTab, topicList, entity, NEW(XonoticTopicList, this.topicSource, "gametype_", this))
+ ATTRIB(XonoticGuideTab, entryList, entity, NEW(XonoticEntryList, this.mapSource))
INIT(XonoticGuideTab) {
- this.topicList.entryIconPrefix = "gametype_";
this.configureDialog(this);
}
ENDCLASS(XonoticGuideTab)
void XonoticGuideTab_topicSelectNotify(entity this) { this.setFocus(this, this.entryList); }
-entity Topics_get(int i) { return MAPINFO_TYPES[i]; }
+entity TopicSource_getEntry(int i) { return MAPINFO_TYPES[i]; }
-int Topics_reload(string filter) { return MAPINFO_TYPE_COUNT; }
+int TopicSource_reload(string filter) { return MAPINFO_TYPE_COUNT; }
-entity XonoticGuideTab_maps_get(int i)
+entity MapSource_getEntry(int i)
{
if (!MapInfo_Get_ByID(i)) return NULL;
static entity e;
return e;
}
-int XonoticGuideTab_maps_indexOf(string s)
+int MapSource_indexOf(string s)
{
MapInfo_FindName(s);
return MapInfo_FindName_firstResult;
}
-int XonoticGuideTab_maps_reload(string s)
+int MapSource_reload(string s)
{
MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 0);
if (s) MapInfo_FilterString(s);
return MapInfo_count;
}
-void XonoticGuideTab_maps_destroy(entity this) { MapInfo_Shutdown(); }
+void MapSource_destroy(entity this) { MapInfo_Shutdown(); }
#endif
#ifndef DIALOG_MEDIA_GUIDE_ENTRIES_H
#define DIALOG_MEDIA_GUIDE_ENTRIES_H
+#include "datasource.qc"
#include "listbox.qc"
CLASS(XonoticEntryList, XonoticListBox)
ATTRIB(XonoticEntryList, alphaBG, float, 0)
METHOD(XonoticEntryList, refilter, void(entity))
METHOD(XonoticEntryList, resizeNotify, void(entity, vector, vector, vector, vector))
- INIT(XonoticEntryList) {
- this.configureXonoticListBox(this);
- }
+ ATTRIB(XonoticEntryList, source, DataSource, NULL)
- .string stringfield_null;
- ATTRIB(XonoticEntryList, destroy, void(entity), func_null)
- ATTRIB(XonoticEntryList, entries, void(int), func_null)
- ATTRIB(XonoticEntryList, entryIcon, .string, stringfield_null)
- ATTRIB(XonoticEntryList, entryName, .string, stringfield_null)
- ATTRIB(XonoticEntryList, indexOf, int(string), func_null)
- ATTRIB(XonoticEntryList, reload, int(string), func_null)
-
- CONSTRUCTOR(XonoticEntryList, entity _entries(int), int _indexOf(string), int _reload(string), .string _entryIcon, .string _entryName, void _destroy(entity)) {
+ CONSTRUCTOR(XonoticEntryList, DataSource _source) {
CONSTRUCT(XonoticEntryList);
- this.entries = _entries;
- this.indexOf = _indexOf;
- this.reload = _reload;
- this.entryIcon = _entryIcon;
- this.entryName = _entryName;
- this.destroy = _destroy;
+ this.source = _source;
+ this.configureXonoticListBox(this);
this.refilter(this);
}
void XonoticEntryList_drawListBoxItem(entity this, int i, vector absSize, bool isSelected, bool isFocused)
{
- entity e = this.entries(i);
+ entity e = this.source.getEntry(i);
if (!e) return;
if (isSelected) {
this.focusedItemAlpha = getFadedAlpha(this.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, this.focusedItemAlpha);
}
- string s = draw_TextShortenToWidth(strdecolorize(e.(this.entryName)), this.columnNameSize, 0, this.realFontSize);
- draw_Picture(this.columnPreviewOrigin * eX, e.(this.entryIcon), this.columnPreviewSize * eX + eY, '1 1 1', SKINALPHA_LISTBOX_SELECTED);
+ string s = draw_TextShortenToWidth(strdecolorize(e.(this.source.entryName)), this.columnNameSize, 0, this.realFontSize);
+ draw_Picture(this.columnPreviewOrigin * eX, e.(this.source.entryIcon), this.columnPreviewSize * eX + eY, '1 1 1', SKINALPHA_LISTBOX_SELECTED);
draw_Text(this.realUpperMargin1 * eY + (this.columnNameOrigin + 0.00 * (this.columnNameSize - draw_TextWidth(s, 0, this.realFontSize))) * eX, s, this.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
}
this.typeToSearchString = strzone(save);
this.typeToSearchTime = time + 0.5;
if (strlen(this.typeToSearchString)) {
- int idx = this.indexOf(this.typeToSearchString);
+ int idx = this.source.indexOf(this.typeToSearchString);
if (idx >= 0) this.setSelected(this, idx);
}
}
if (this.typeToSearchString) strunzone(this.typeToSearchString);
this.typeToSearchString = strzone(save);
this.typeToSearchTime = time + 0.5;
- int idx = this.indexOf(this.typeToSearchString);
+ int idx = this.source.indexOf(this.typeToSearchString);
if (idx >= 0) this.setSelected(this, idx);
} else if (shift & S_CTRL && scan == 'f') {
this.parent.setFocus(this.parent, this.stringFilterBox);
void XonoticEntryList_refilter(entity this)
{
- this.nItems = this.reload(this.stringFilter);
+ this.nItems = this.source.reload(this.stringFilter);
for (int i = 0, n = this.nItems; i < n; ++i) {
- draw_PreloadPicture(this.entries(i).(this.entryIcon));
+ draw_PreloadPicture(this.source.getEntry(i).(this.source.entryIcon));
}
}
#ifndef DIALOG_MEDIA_GUIDE_TOPICS_H
#define DIALOG_MEDIA_GUIDE_TOPICS_H
+#include "datasource.qc"
#include "listbox.qc"
CLASS(XonoticTopicList, XonoticListBox)
ATTRIB(XonoticTopicList, columnIconOrigin, float, 0)
METHOD(XonoticTopicList, resizeNotify, void(entity, vector, vector, vector, vector))
METHOD(XonoticTopicList, setSelected, void(entity, int))
- INIT(XonoticTopicList) {
- this.configureXonoticListBox(this);
- }
-
- .string stringfield_null;
- ATTRIB(XonoticTopicList, entries, entity(int), func_null)
+ ATTRIB(XonoticTopicList, source, DataSource, NULL)
ATTRIB(XonoticTopicList, entryIconPrefix, string, "")
- ATTRIB(XonoticTopicList, entryIcon, .string, stringfield_null)
- ATTRIB(XonoticTopicList, entryName, .string, stringfield_null)
ATTRIB(XonoticTopicList, listener, entity, NULL)
- CONSTRUCTOR(XonoticTopicList, entity(int) _entries, int _indexOf(string), int _reload(string), .string _entryIcon, .string _entryName, void _destroy(entity), entity _listener) {
+ CONSTRUCTOR(XonoticTopicList, DataSource _source, string _entryIconPrefix, entity _listener) {
CONSTRUCT(XonoticTopicList);
- this.entries = _entries;
- this.nItems = _reload("");
- this.entryIcon = _entryIcon;
- this.entryName = _entryName;
+ this.source = _source;
+ this.entryIconPrefix = _entryIconPrefix;
this.listener = _listener;
+ this.nItems = _source.reload("");
+ this.configureXonoticListBox(this);
}
ENDCLASS(XonoticTopicList)
#endif
this.focusedItemAlpha = getFadedAlpha(this.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, this.focusedItemAlpha);
}
- entity entry = this.entries(i);
- string icon = strcat(this.entryIconPrefix, entry.(this.entryIcon));
- string name = entry.(this.entryName);
+ entity entry = this.source.getEntry(i);
+ string icon = strcat(this.entryIconPrefix, entry.(this.source.entryIcon));
+ string name = entry.(this.source.entryName);
draw_Picture(this.columnIconOrigin * eX, icon, this.columnIconSize * eX + eY, '1 1 1', SKINALPHA_LISTBOX_SELECTED);
vector save_fontscale = draw_fontscale;
float f = draw_CondensedFontFactor(name, false, this.realFontSize, 1);