Changeset View
Changeset View
Standalone View
Standalone View
source/ps/scripting/JSInterface_Console.cpp
Show All 16 Lines | |||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "JSInterface_Console.h" | #include "JSInterface_Console.h" | ||||
#include "ps/CConsole.h" | #include "ps/CConsole.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
#include "scriptinterface/FunctionWrapper.h" | |||||
bool JSI_Console::CheckGlobalInitialized() | bool JSI_Console::CheckGlobalInitialized() | ||||
{ | { | ||||
if (!g_Console) | if (!g_Console) | ||||
{ | { | ||||
LOGERROR("Trying to access the console when it's not initialized!"); | LOGERROR("Trying to access the console when it's not initialized!"); | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool JSI_Console::GetVisibleEnabled(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) | bool JSI_Console::GetVisibleEnabled() | ||||
{ | { | ||||
if (!CheckGlobalInitialized()) | if (!CheckGlobalInitialized()) | ||||
return false; | return false; | ||||
return g_Console->IsActive(); | return g_Console->IsActive(); | ||||
} | } | ||||
void JSI_Console::SetVisibleEnabled(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), bool Enabled) | void JSI_Console::SetVisibleEnabled(bool Enabled) | ||||
{ | { | ||||
if (!CheckGlobalInitialized()) | if (!CheckGlobalInitialized()) | ||||
return; | return; | ||||
g_Console->SetVisible(Enabled); | g_Console->SetVisible(Enabled); | ||||
} | } | ||||
void JSI_Console::RegisterScriptFunctions(const ScriptInterface& scriptInterface) | void JSI_Console::RegisterScriptFunctions(const ScriptInterface& scriptInterface) | ||||
{ | { | ||||
scriptInterface.RegisterFunction<bool, &JSI_Console::GetVisibleEnabled>("Console_GetVisibleEnabled"); | ScriptWrapper::WrapAndRegister<decltype(&JSI_Console::GetVisibleEnabled), &JSI_Console::GetVisibleEnabled>(scriptInterface, "Console_GetVisibleEnabled"); | ||||
scriptInterface.RegisterFunction<void, bool, &JSI_Console::SetVisibleEnabled>("Console_SetVisibleEnabled"); | ScriptWrapper::WrapAndRegister<decltype(&JSI_Console::SetVisibleEnabled), &JSI_Console::SetVisibleEnabled>(scriptInterface, "Console_SetVisibleEnabled"); | ||||
} | } |
Wildfire Games · Phabricator