Changeset View
Changeset View
Standalone View
Standalone View
source/gui/scripting/JSInterface_GUIManager.cpp
Show All 19 Lines | |||||
#include "JSInterface_GUIManager.h" | #include "JSInterface_GUIManager.h" | ||||
#include "gui/CGUI.h" | #include "gui/CGUI.h" | ||||
#include "gui/GUIManager.h" | #include "gui/GUIManager.h" | ||||
#include "gui/IGUIObject.h" | #include "gui/IGUIObject.h" | ||||
#include "ps/GameSetup/Config.h" | #include "ps/GameSetup/Config.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
// Note that the initData argument may only contain clonable data. | void JSI_GUIManager::PushGuiPage(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& name, JS::HandleValue initData, JS::HandleValue callbackFunction) | ||||
// Functions aren't supported for example! | |||||
void JSI_GUIManager::PushGuiPage(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& name, JS::HandleValue initData) | |||||
{ | { | ||||
g_GUI->PushPage(name, pCxPrivate->pScriptInterface->WriteStructuredClone(initData)); | g_GUI->PushPage(name, pCxPrivate->pScriptInterface, pCxPrivate->pScriptInterface->WriteStructuredClone(initData), callbackFunction); | ||||
} | } | ||||
void JSI_GUIManager::SwitchGuiPage(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& name, JS::HandleValue initData) | void JSI_GUIManager::SwitchGuiPage(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& name, JS::HandleValue initData) | ||||
{ | { | ||||
g_GUI->SwitchPage(name, pCxPrivate->pScriptInterface, initData); | g_GUI->SwitchPage(name, pCxPrivate->pScriptInterface, initData); | ||||
} | } | ||||
void JSI_GUIManager::PopGuiPage(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) | void JSI_GUIManager::PopGuiPage(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue args) | ||||
{ | { | ||||
g_GUI->PopPage(); | g_GUI->PopPage(pCxPrivate->pScriptInterface->WriteStructuredClone(args)); | ||||
} | |||||
void JSI_GUIManager::PopGuiPageCB(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue args) | |||||
{ | |||||
g_GUI->PopPageCB(pCxPrivate->pScriptInterface->WriteStructuredClone(args)); | |||||
} | } | ||||
JS::Value JSI_GUIManager::GetGUIObjectByName(ScriptInterface::CxPrivate* pCxPrivate, const std::string& name) | JS::Value JSI_GUIManager::GetGUIObjectByName(ScriptInterface::CxPrivate* pCxPrivate, const std::string& name) | ||||
{ | { | ||||
CGUI* guiPage = static_cast<CGUI*>(pCxPrivate->pCBData); | CGUI* guiPage = static_cast<CGUI*>(pCxPrivate->pCBData); | ||||
IGUIObject* guiObj = guiPage->FindObjectByName(name); | IGUIObject* guiObj = guiPage->FindObjectByName(name); | ||||
if (!guiObj) | if (!guiObj) | ||||
Show All 21 Lines | |||||
CParamNode JSI_GUIManager::GetTemplate(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& templateName) | CParamNode JSI_GUIManager::GetTemplate(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& templateName) | ||||
{ | { | ||||
return g_GUI->GetTemplate(templateName); | return g_GUI->GetTemplate(templateName); | ||||
} | } | ||||
void JSI_GUIManager::RegisterScriptFunctions(const ScriptInterface& scriptInterface) | void JSI_GUIManager::RegisterScriptFunctions(const ScriptInterface& scriptInterface) | ||||
{ | { | ||||
scriptInterface.RegisterFunction<void, std::wstring, JS::HandleValue, &PushGuiPage>("PushGuiPage"); | scriptInterface.RegisterFunction<void, std::wstring, JS::HandleValue, JS::HandleValue, &PushGuiPage>("PushGuiPage"); | ||||
scriptInterface.RegisterFunction<void, std::wstring, JS::HandleValue, &SwitchGuiPage>("SwitchGuiPage"); | scriptInterface.RegisterFunction<void, std::wstring, JS::HandleValue, &SwitchGuiPage>("SwitchGuiPage"); | ||||
scriptInterface.RegisterFunction<void, &PopGuiPage>("PopGuiPage"); | scriptInterface.RegisterFunction<void, JS::HandleValue, &PopGuiPage>("PopGuiPage"); | ||||
scriptInterface.RegisterFunction<void, JS::HandleValue, &PopGuiPageCB>("PopGuiPageCB"); | |||||
scriptInterface.RegisterFunction<JS::Value, std::string, &GetGUIObjectByName>("GetGUIObjectByName"); | scriptInterface.RegisterFunction<JS::Value, std::string, &GetGUIObjectByName>("GetGUIObjectByName"); | ||||
scriptInterface.RegisterFunction<std::wstring, std::wstring, &SetCursor>("SetCursor"); | scriptInterface.RegisterFunction<std::wstring, std::wstring, &SetCursor>("SetCursor"); | ||||
scriptInterface.RegisterFunction<void, &ResetCursor>("ResetCursor"); | scriptInterface.RegisterFunction<void, &ResetCursor>("ResetCursor"); | ||||
scriptInterface.RegisterFunction<bool, std::string, &TemplateExists>("TemplateExists"); | scriptInterface.RegisterFunction<bool, std::string, &TemplateExists>("TemplateExists"); | ||||
scriptInterface.RegisterFunction<CParamNode, std::string, &GetTemplate>("GetTemplate"); | scriptInterface.RegisterFunction<CParamNode, std::string, &GetTemplate>("GetTemplate"); | ||||
} | } |
Wildfire Games · Phabricator