]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/datasource.qc
Merge branch 'master' into terencehill/translated_keys
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / datasource.qc
1 #include "datasource.qh"
2
3     CONSTRUCTOR(StringSource, string str, string sep)
4     {
5         CONSTRUCT(StringSource);
6         this.StringSource_str = str;
7         this.StringSource_sep = sep;
8     }
9     METHOD(StringSource, getEntry, entity(entity this, int i, void(string name, string icon) returns))
10     {
11         int n = tokenizebyseparator(this.StringSource_str, this.StringSource_sep);
12         if (i < 0 || i >= n) return DataSource_false;
13         string s = argv(i);
14         if (returns) returns(s, string_null);
15         return DataSource_true;
16     }
17     METHOD(StringSource, reload, int(entity this, string filter))
18     {
19         return tokenizebyseparator(this.StringSource_str, this.StringSource_sep);
20     }
21
22     CONSTRUCTOR(CvarStringSource, string cv, string sep)
23     {
24         CONSTRUCT(CvarStringSource);
25         this.CvarStringSource_cvar = cv;
26         this.StringSource_sep = sep;
27     }
28     METHOD(CvarStringSource, getEntry, entity(entity this, int i, void(string name, string icon) returns))
29     {
30         string s = this.CvarStringSource_cvar;
31         this.StringSource_str = s ? cvar_string(s) : string_null;
32         return SUPER(CvarStringSource).getEntry(this, i, returns);
33     }
34     METHOD(CvarStringSource, reload, int(entity this, string filter))
35     {
36         string s = this.CvarStringSource_cvar;
37         this.StringSource_str = s ? cvar_string(s) : string_null;
38         return SUPER(CvarStringSource).reload(this, filter);
39     }