28#include <angelscript.h>
30using namespace AngelScript;
36 std::string log_msg =
"modcache.query(): ";
37 std::string search_expr;
42 int64_t i64_filter_category_id;
49 if (search_expr.find(
":") == std::string::npos)
56 Ogre::StringVector v = Ogre::StringUtil::split(search_expr,
":");
62 else if (v[0] ==
"guid")
67 else if (v[0] ==
"author")
72 else if (v[0] ==
"wheels")
77 else if (v[0] ==
"file")
90 size_t results_count = self->
Query(query);
95 CScriptArray* results_entries = CScriptArray::Create(typeinfo_array_entries);
96 CScriptArray* results_scores = CScriptArray::Create(typeinfo_array_scores);
99 CacheEntry* entry_ptr = result.cqr_entry.GetRef();
100 results_entries->InsertLast(&entry_ptr);
101 results_scores->InsertLast(&result.cqr_score);
104 CScriptDictionary* results_dict = CScriptDictionary::Create(
App::GetScriptEngine()->getEngine());
105 results_dict->Set(
"count", (asINT64)results_count);
106 results_dict->Set(
"entries", results_entries, typeinfo_array_entries->GetTypeId());
107 results_dict->Set(
"scores", results_scores, typeinfo_array_scores->GetTypeId());
114 CacheEntry::RegisterRefCountingObject(engine,
"CacheEntryClass");
120 result = engine->RegisterEnum(
"LoaderType");
ROR_ASSERT(result >= 0);
121 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_NONE",
LT_None);
ROR_ASSERT(result >= 0);
122 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_TERRAIN",
LT_Terrain);
ROR_ASSERT(result >= 0);
123 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_VEHICLE",
LT_Vehicle);
ROR_ASSERT(result >= 0);
124 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_TRUCK",
LT_Truck);
ROR_ASSERT(result >= 0);
125 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_CAR",
LT_Car);
ROR_ASSERT(result >= 0);
126 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_BOAT",
LT_Boat);
ROR_ASSERT(result >= 0);
127 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_AIRPLANE",
LT_Airplane);
ROR_ASSERT(result >= 0);
128 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_TRAILER",
LT_Trailer);
ROR_ASSERT(result >= 0);
129 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_TRAIN",
LT_Train);
ROR_ASSERT(result >= 0);
130 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_LOAD",
LT_Load);
ROR_ASSERT(result >= 0);
131 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_EXTENSION",
LT_Extension);
ROR_ASSERT(result >= 0);
132 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_SKIN",
LT_Skin);
ROR_ASSERT(result >= 0);
133 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_ALLBEAM",
LT_AllBeam);
ROR_ASSERT(result >= 0);
134 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_ADDONPART",
LT_AddonPart);
ROR_ASSERT(result >= 0);
135 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_TUNEUP",
LT_Tuneup);
ROR_ASSERT(result >= 0);
136 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_ASSETPACK",
LT_AssetPack);
ROR_ASSERT(result >= 0);
137 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_DASHBOARD",
LT_DashBoard);
ROR_ASSERT(result >= 0);
138 result = engine->RegisterEnumValue(
"LoaderType",
"LOADER_TYPE_GADGET",
LT_Gadget);
ROR_ASSERT(result >= 0);
143 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"const string& get_fpath() const property", asFUNCTIONPR([](
CacheEntry* self) ->
const std::string& {
return self->
fpath;}, (
CacheEntry*),
const std::string&), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
144 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"const string& get_fname() const property", asFUNCTIONPR([](
CacheEntry* self) ->
const std::string& {
return self->
fname;}, (
CacheEntry*),
const std::string&), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
145 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"const string& get_fext() const property", asFUNCTIONPR([](
CacheEntry* self) ->
const std::string& {
return self->
fext;}, (
CacheEntry*),
const std::string&), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
146 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"const string& get_dname() const property", asFUNCTIONPR([](
CacheEntry* self) ->
const std::string& {
return self->
dname;}, (
CacheEntry*),
const std::string&), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
147 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"int get_categoryid() const property", asFUNCTIONPR([](
CacheEntry* self) ->
int {
return self->
categoryid;}, (
CacheEntry*),
int), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
148 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"const string& get_categoryname() const property", asFUNCTIONPR([](
CacheEntry* self) ->
const std::string& {
return self->
categoryname;}, (
CacheEntry*),
const std::string&), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
149 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"const string& get_resource_bundle_type() const property", asFUNCTIONPR([](
CacheEntry* self) ->
const std::string& {
return self->
resource_bundle_type;}, (
CacheEntry*),
const std::string&), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
150 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"const string& get_resource_bundle_path() const property", asFUNCTIONPR([](
CacheEntry* self) ->
const std::string& {
return self->
resource_bundle_path;}, (
CacheEntry*),
const std::string&), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
151 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"int get_number() const property", asFUNCTIONPR([](
CacheEntry* self) ->
int {
return self->
number;}, (
CacheEntry*),
int), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
152 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"bool get_deleted() const property", asFUNCTIONPR([](
CacheEntry* self) ->
bool {
return self->
deleted;}, (
CacheEntry*),
bool), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
153 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"const string& get_filecachename() const property", asFUNCTIONPR([](
CacheEntry* self) ->
const std::string& {
return self->
filecachename;}, (
CacheEntry*),
const std::string&), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
154 result = engine->RegisterObjectMethod(
"CacheEntryClass",
"const string& get_resource_group() const property", asFUNCTIONPR([](
CacheEntry* self) ->
const std::string& {
return self->
resource_group;}, (
CacheEntry*),
const std::string&), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
157 result = engine->RegisterObjectType(
"CacheSystemClass",
sizeof(
CacheSystem), asOBJ_REF | asOBJ_NOCOUNT);
ROR_ASSERT(result>=0);
158 result = engine->RegisterObjectMethod(
"CacheSystemClass",
"CacheEntryClassPtr @findEntryByFilename(LoaderType, bool, const string &in)", asMETHOD(
CacheSystem,FindEntryByFilename), asCALL_THISCALL);
ROR_ASSERT(result>=0);
159 result = engine->RegisterObjectMethod(
"CacheSystemClass",
"CacheEntryClassPtr @getEntryByNumber(int)", asMETHOD(
CacheSystem,GetEntryByNumber), asCALL_THISCALL);
ROR_ASSERT(result>=0);
160 result = engine->RegisterObjectMethod(
"CacheSystemClass",
"dictionary@ query(dictionary@)", asFUNCTION(
CacheSystemQueryWrapper), asCALL_CDECL_OBJFIRST);
ROR_ASSERT(result>=0);
#define ROR_ASSERT(_EXPR)
A database of user-installed content alias 'mods' (vehicles, terrains...)
CScriptDictionary * CacheSystemQueryWrapper(CacheSystem *self, CScriptDictionary *dict)
static void RegisterRefCountingObjectPtr(AS_NAMESPACE_QUALIFIER asIScriptEngine *engine, const char *handle_name, const char *obj_name)
CacheEntryID_t number
Sequential number, assigned internally, used by Selector-GUI.
Ogre::String fname
filename
Ogre::String fext
file's extension
Ogre::String fpath
filepath relative to the .zip file
int categoryid
category id
Ogre::String dname
name parsed from the file
Ogre::String resource_group
Resource group of the loaded bundle. Empty if not loaded yet.
std::string resource_bundle_type
Archive type recognized by OGRE resource system: 'FileSystem' or 'Zip'.
std::string resource_bundle_path
Path of ZIP or directory which contains the media. Shared between CacheEntries, loaded only once.
bool deleted
is this mod deleted?
Ogre::String categoryname
category name
Ogre::String filecachename
preview image filename
A content database MOTIVATION: RoR users usually have A LOT of content installed.
size_t Query(CacheQuery &query)
AngelScript::asIScriptEngine * getEngine()
void RegisterCacheSystem(AngelScript::asIScriptEngine *engine)
defined in CacheSystemAngelscript.cpp
bool GetValueFromScriptDict(const std::string &log_msg, AngelScript::CScriptDictionary *dict, bool required, std::string const &key, const char *decl, T &out_value)
ScriptEngine * GetScriptEngine()
int cqy_filter_category_id
std::string cqy_filter_guid
Exact match (case-insensitive); leave empty to disable.
std::string cqy_search_string
CacheSearchMethod cqy_search_method
std::vector< CacheQueryResult > cqy_results
RoR::LoaderType cqy_filter_type