]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/datasource.qh
1808b765515d0d81f60e9a3c517ef1ecdbe423be
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / datasource.qh
1 #pragma once
2
3 CLASS(DataSource, Object)
4     entity DataSource_true;
5     entity DataSource_false;
6     INIT_STATIC(DataSource) {
7         DataSource_true = NEW(Object);
8         DataSource_false = NULL;
9     }
10     /**
11      * get entry `i` passing `name` and `icon` through `returns` if it is not null
12      * returns `DataSource_false` if out of bounds
13      * otherwise returns an entity or `DataSource_true`
14      */
15     METHOD(DataSource, getEntry, entity(entity this, int i, void(string name, string icon) returns)) { return DataSource_false; }
16     /** return the index of the first match for `find`. optional */
17     METHOD(DataSource, indexOf, int(entity this, string find)) { return -1; }
18     /** reload all entries matching `filter` returning how many matches were found */
19     METHOD(DataSource, reload, int(entity this, string filter)) { return 0; }
20     /** cleanup on shutdown. optional */
21     METHOD(DataSource, destroy, void(entity this)) { }
22 ENDCLASS(DataSource)
23
24
25 CLASS(StringSource, DataSource)
26     ATTRIB(StringSource, StringSource_str, string, string_null)
27     ATTRIB(StringSource, StringSource_sep, string, string_null)
28     CONSTRUCTOR(StringSource, string str, string sep);
29     METHOD(StringSource, getEntry, entity(entity this, int i, void(string name, string icon) returns));
30     METHOD(StringSource, reload, int(entity this, string filter));
31 ENDCLASS(StringSource)
32
33 CLASS(CvarStringSource, StringSource)
34     ATTRIB(CvarStringSource, CvarStringSource_cvar, string, string_null)
35     CONSTRUCTOR(CvarStringSource, string cv, string sep);
36     METHOD(CvarStringSource, getEntry, entity(entity this, int i, void(string name, string icon) returns));
37     METHOD(CvarStringSource, reload, int(entity this, string filter));
38 ENDCLASS(CvarStringSource)