Changeset View
Changeset View
Standalone View
Standalone View
source/ps/scripting/JSInterface_Mod.cpp
Show All 21 Lines | |||||
#include "ps/Mod.h" | #include "ps/Mod.h" | ||||
#include "scriptinterface/FunctionWrapper.h" | #include "scriptinterface/FunctionWrapper.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
extern void RestartEngine(); | extern void RestartEngine(); | ||||
namespace | namespace | ||||
{ | { | ||||
JS::Value GetEngineInfo(ScriptInterface::CmptPrivate* pCmptPrivate) | bool SetModsAndRestartEngine(ScriptInterface::CmptPrivate* pCmptPrivate, const std::vector<CStr>& mods) | ||||
{ | { | ||||
return Mod::GetEngineInfo(*(pCmptPrivate->pScriptInterface)); | Mod::ClearIncompatibleMods(); | ||||
} | if (!Mod::CheckAndEnableMods(*(pCmptPrivate->pScriptInterface), mods)) | ||||
return false; | |||||
/** | RestartEngine(); | ||||
* Returns a JS object containing a listing of available mods that | return true; | ||||
* have a modname.json file in their modname folder. The returned | } | ||||
* object looks like { modname1: json1, modname2: json2, ... } where | |||||
* jsonN is the content of the modnameN/modnameN.json file as a JS | |||||
* object. | |||||
* | |||||
* @return JS object with available mods as the keys of the modname.json | |||||
* properties. | |||||
*/ | |||||
JS::Value GetAvailableMods(ScriptInterface::CmptPrivate* pCmptPrivate) | |||||
{ | |||||
return Mod::GetAvailableMods(*(pCmptPrivate->pScriptInterface)); | |||||
} | } | ||||
void SetMods(const std::vector<CStr>& mods) | bool HasFailedMods(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate)) | ||||
{ | { | ||||
g_modsLoaded = mods; | return Mod::GetFailedMods().size() > 0; | ||||
vladislavbelov: Just `RestartEngine`, without `::`. | |||||
} | |||||
} | } | ||||
void JSI_Mod::RegisterScriptFunctions(const ScriptRequest& rq) | void JSI_Mod::RegisterScriptFunctions(const ScriptRequest& rq) | ||||
{ | { | ||||
Not Done Inline ActionsIt should be possible to just call Mod::GetEnabledMods directly. You might run into ambiguity as you have overloads - can be solved with static_cast (see JSI_l10n), renaming one of the two functions. In any case, you can now update this file to take const ScriptInterface& as first parameter, I've added that. wraitii: It should be possible to just call Mod::GetEnabledMods directly. You might run into ambiguity… | |||||
ScriptFunction::Register<&GetEngineInfo>(rq, "GetEngineInfo"); | ScriptFunction::Register<&Mod::GetEngineInfo>(rq, "GetEngineInfo"); | ||||
ScriptFunction::Register<&GetAvailableMods>(rq, "GetAvailableMods"); | ScriptFunction::Register<&Mod::GetAvailableMods>(rq, "GetAvailableMods"); | ||||
ScriptFunction::Register<&RestartEngine>(rq, "RestartEngine"); | ScriptFunction::Register<&Mod::GetEnabledMods>(rq, "GetEnabledMods"); | ||||
ScriptFunction::Register<&SetMods>(rq, "SetMods"); | ScriptFunction::Register<HasFailedMods> (rq, "HasFailedMods"); | ||||
ScriptFunction::Register<&Mod::GetFailedMods>(rq, "GetFailedMods"); | |||||
ScriptFunction::Register<&SetModsAndRestartEngine>(rq, "SetModsAndRestartEngine"); | |||||
} | } |
Wildfire Games · Phabricator
Just RestartEngine, without ::.