From 2efbf10d546c98e94d42c6757f6384912fb64c09 Mon Sep 17 00:00:00 2001 From: TimePath Date: Tue, 25 Aug 2015 11:00:57 +1000 Subject: [PATCH] Backport DataSource --- qcsrc/menu/classes.inc | 1 + qcsrc/menu/xonotic/datasource.qc | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 qcsrc/menu/xonotic/datasource.qc diff --git a/qcsrc/menu/classes.inc b/qcsrc/menu/classes.inc index 01a7c8a04..aee7166e1 100644 --- a/qcsrc/menu/classes.inc +++ b/qcsrc/menu/classes.inc @@ -37,6 +37,7 @@ #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" diff --git a/qcsrc/menu/xonotic/datasource.qc b/qcsrc/menu/xonotic/datasource.qc new file mode 100644 index 000000000..db3b77a01 --- /dev/null +++ b/qcsrc/menu/xonotic/datasource.qc @@ -0,0 +1,23 @@ +#ifndef DATASOURCE_H +#define DATASOURCE_H +CLASS(DataSource, Object) + /** + * get entry `i` passing `name` and `icon` through `returns` if it is not null + * returns `DataSource_false` if out of bounds + * otherwise returns an entity or `DataSource_true` + */ + METHOD(DataSource, getEntry, entity(int i, void(string name, string icon) returns)); + /** return the index of the first match for `find`. optional */ + METHOD(DataSource, indexOf, int(string find)); + /** reload all entries matching `filter` returning how many matches were found */ + METHOD(DataSource, reload, int(string filter)); + /** cleanup on shutdown. optional */ + METHOD(DataSource, destroy, void(entity)); + entity DataSource_true; + entity DataSource_false; + INIT_STATIC(DataSource) { + DataSource_true = NEW(Object); + DataSource_false = NULL; + } +ENDCLASS(DataSource) +#endif -- 2.39.2