]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Backport DataSource
authorTimePath <andrew.hardaker1995@gmail.com>
Tue, 25 Aug 2015 01:00:57 +0000 (11:00 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Tue, 25 Aug 2015 01:02:53 +0000 (11:02 +1000)
qcsrc/menu/classes.inc
qcsrc/menu/xonotic/datasource.qc [new file with mode: 0644]

index 01a7c8a040f47526e09ee027a125068acacb78ef..aee7166e1b3676a0a5052c454b664466836d5c81 100644 (file)
@@ -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 (file)
index 0000000..db3b77a
--- /dev/null
@@ -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