X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fmenu%2Fxonotic%2Fdatasource.qh;h=1ca3d5811fd316192c7ca4b86bbf5b10ada6ca5c;hb=77d6a05629e33da863fccb3cdd03b3c63af890dd;hp=6f70f09beec2219624baeca92e2cd7deaa104fb4;hpb=826222f84e886d85179a032b07edc71d99982040;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/menu/xonotic/datasource.qh b/qcsrc/menu/xonotic/datasource.qh index 6f70f09be..1ca3d5811 100644 --- a/qcsrc/menu/xonotic/datasource.qh +++ b/qcsrc/menu/xonotic/datasource.qh @@ -1 +1,34 @@ #pragma once + +CLASS(DataSource, Object) + STATIC_ATTRIB(DataSource, true, entity, NEW(Object)); + STATIC_ATTRIB(DataSource, false, entity, 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) + + +CLASS(StringSource, DataSource) + ATTRIB(StringSource, StringSource_str, string, string_null) + ATTRIB(StringSource, StringSource_sep, string, string_null) + CONSTRUCTOR(StringSource, string str, string sep); + METHOD(StringSource, getEntry, entity(entity this, int i, void(string name, string icon) returns)); + METHOD(StringSource, reload, int(entity this, string filter)); +ENDCLASS(StringSource) + +CLASS(CvarStringSource, StringSource) + ATTRIB(CvarStringSource, CvarStringSource_cvar, string, string_null) + CONSTRUCTOR(CvarStringSource, string cv, string sep); + METHOD(CvarStringSource, getEntry, entity(entity this, int i, void(string name, string icon) returns)); + METHOD(CvarStringSource, reload, int(entity this, string filter)); +ENDCLASS(CvarStringSource)