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