]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/datasource.qc
Merge branch 'martin-t/shield' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / datasource.qc
index 57ce0c80c312e73c7826110a6075dc8a6e9b4284..d51a1f74893682130152f79b07a742747165fcc2 100644 (file)
@@ -1,30 +1,5 @@
-#ifndef DATASOURCE_H
-#define DATASOURCE_H
-CLASS(DataSource, Object)
-    entity DataSource_true;
-    entity DataSource_false;
-    INIT_STATIC(DataSource) {
-        DataSource_true = NEW(Object);
-        DataSource_false = NULL;
-    }
-    /**
-     * 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(entity this, int i, void(string name, string icon) returns)) { return DataSource_false; }
-    /** return the index of the first match for `find`. optional */
-    METHOD(DataSource, indexOf, int(entity this, string find)) { return -1; }
-    /** reload all entries matching `filter` returning how many matches were found */
-    METHOD(DataSource, reload, int(entity this, string filter)) { return 0; }
-    /** cleanup on shutdown. optional */
-    METHOD(DataSource, destroy, void(entity this)) { }
-ENDCLASS(DataSource)
-
+#include "datasource.qh"
 
-CLASS(StringSource, DataSource)
-    ATTRIB(StringSource, StringSource_str, string, string_null)
-    ATTRIB(StringSource, StringSource_sep, string, string_null)
     CONSTRUCTOR(StringSource, string str, string sep)
     {
         CONSTRUCT(StringSource);
@@ -43,10 +18,7 @@ CLASS(StringSource, DataSource)
     {
         return tokenizebyseparator(this.StringSource_str, this.StringSource_sep);
     }
-ENDCLASS(StringSource)
 
-CLASS(CvarStringSource, StringSource)
-    ATTRIB(CvarStringSource, CvarStringSource_cvar, string, string_null)
     CONSTRUCTOR(CvarStringSource, string cv, string sep)
     {
         CONSTRUCT(CvarStringSource);
@@ -57,13 +29,11 @@ CLASS(CvarStringSource, StringSource)
     {
         string s = this.CvarStringSource_cvar;
         this.StringSource_str = s ? cvar_string(s) : string_null;
-        return super.getEntry(this, i, returns);
+        return SUPER(CvarStringSource).getEntry(this, i, returns);
     }
     METHOD(CvarStringSource, reload, int(entity this, string filter))
     {
         string s = this.CvarStringSource_cvar;
         this.StringSource_str = s ? cvar_string(s) : string_null;
-        return super.reload(this, filter);
+        return SUPER(CvarStringSource).reload(this, filter);
     }
-ENDCLASS(CvarStringSource)
-#endif