From: TimePath Date: Tue, 25 Aug 2015 01:00:57 +0000 (+1000) Subject: Backport DataSource X-Git-Tag: xonotic-v0.8.2~2036 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2efbf10d546c98e94d42c6757f6384912fb64c09;p=xonotic%2Fxonotic-data.pk3dir.git Backport DataSource --- 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