Changeset View
Changeset View
Standalone View
Standalone View
source/ps/scripting/JSInterface_Mod.cpp
/* Copyright (C) 2018 Wildfire Games. | /* Copyright (C) 2021 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
Show All 31 Lines | |||||
*/ | */ | ||||
JS::Value JSI_Mod::GetAvailableMods(ScriptInterface::CmptPrivate* pCmptPrivate) | JS::Value JSI_Mod::GetAvailableMods(ScriptInterface::CmptPrivate* pCmptPrivate) | ||||
{ | { | ||||
return Mod::GetAvailableMods(*(pCmptPrivate->pScriptInterface)); | return Mod::GetAvailableMods(*(pCmptPrivate->pScriptInterface)); | ||||
} | } | ||||
void JSI_Mod::RestartEngine(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate)) | void JSI_Mod::RestartEngine(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate)) | ||||
{ | { | ||||
::RestartEngine(); | ::RestartEngine(); | ||||
vladislavbelov: Just `RestartEngine`, without `::`. | |||||
} | } | ||||
void JSI_Mod::SetMods(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::vector<CStr>& mods) | void JSI_Mod::SetModsAndRestartEngine(ScriptInterface::CmptPrivate* pCmptPrivate, const std::vector<CStr>& mods) | ||||
{ | { | ||||
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… | |||||
g_modsLoaded = mods; | if (Mod::CheckAndEnableMods(*(pCmptPrivate->pScriptInterface), mods)) | ||||
::RestartEngine(); | |||||
} | } | ||||
void JSI_Mod::RegisterScriptFunctions(const ScriptInterface& scriptInterface) | void JSI_Mod::RegisterScriptFunctions(const ScriptInterface& scriptInterface) | ||||
{ | { | ||||
scriptInterface.RegisterFunction<JS::Value, &GetEngineInfo>("GetEngineInfo"); | scriptInterface.RegisterFunction<JS::Value, &GetEngineInfo>("GetEngineInfo"); | ||||
scriptInterface.RegisterFunction<JS::Value, &JSI_Mod::GetAvailableMods>("GetAvailableMods"); | scriptInterface.RegisterFunction<JS::Value, &JSI_Mod::GetAvailableMods>("GetAvailableMods"); | ||||
scriptInterface.RegisterFunction<void, &JSI_Mod::RestartEngine>("RestartEngine"); | scriptInterface.RegisterFunction<void, &JSI_Mod::RestartEngine>("RestartEngine"); | ||||
scriptInterface.RegisterFunction<void, std::vector<CStr>, &JSI_Mod::SetMods>("SetMods"); | scriptInterface.RegisterFunction<void, std::vector<CStr>, &JSI_Mod::SetModsAndRestartEngine>("SetModsAndRestartEngine"); | ||||
} | } |
Wildfire Games · Phabricator
Just RestartEngine, without ::.