Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/Scripting/JSInterface_GUIManager.cpp
Show All 23 Lines | |||||
#include "gui/ObjectBases/IGUIObject.h" | #include "gui/ObjectBases/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. | // Note that the initData argument may only contain clonable data. | ||||
// Functions aren't supported for example! | // Functions aren't supported for example! | ||||
void JSI_GUIManager::PushGuiPage(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& name, JS::HandleValue initData, JS::HandleValue callbackFunction) | void JSI_GUIManager::PushGuiPage(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& name, JS::HandleValue initData, JS::HandleValue callbackFunction) | ||||
{ | { | ||||
g_GUI->PushPage(name, pCmptPrivate->pScriptInterface->WriteStructuredClone(initData), callbackFunction); | g_GUI->PushPage(name, pCmptPrivate->pScriptInterface->WriteStructuredClone(initData, true), callbackFunction); | ||||
} | } | ||||
void JSI_GUIManager::SwitchGuiPage(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& name, JS::HandleValue initData) | void JSI_GUIManager::SwitchGuiPage(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& name, JS::HandleValue initData) | ||||
{ | { | ||||
g_GUI->SwitchPage(name, pCmptPrivate->pScriptInterface, initData); | g_GUI->SwitchPage(name, pCmptPrivate->pScriptInterface, initData); | ||||
} | } | ||||
void JSI_GUIManager::PopGuiPage(ScriptInterface::CmptPrivate* pCmptPrivate, JS::HandleValue args) | void JSI_GUIManager::PopGuiPage(ScriptInterface::CmptPrivate* pCmptPrivate, JS::HandleValue args) | ||||
{ | { | ||||
if (g_GUI->GetPageCount() < 2) | if (g_GUI->GetPageCount() < 2) | ||||
{ | { | ||||
ScriptRequest rq(pCmptPrivate->pScriptInterface); | ScriptRequest rq(pCmptPrivate->pScriptInterface); | ||||
ScriptException::Raise(rq, "Can't pop GUI pages when less than two pages are opened!"); | ScriptException::Raise(rq, "Can't pop GUI pages when less than two pages are opened!"); | ||||
return; | return; | ||||
} | } | ||||
g_GUI->PopPage(pCmptPrivate->pScriptInterface->WriteStructuredClone(args)); | g_GUI->PopPage(pCmptPrivate->pScriptInterface->WriteStructuredClone(args, true)); | ||||
} | } | ||||
JS::Value JSI_GUIManager::GetGUIObjectByName(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& name) | JS::Value JSI_GUIManager::GetGUIObjectByName(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& name) | ||||
{ | { | ||||
CGUI* guiPage = static_cast<CGUI*>(pCmptPrivate->pCBData); | CGUI* guiPage = static_cast<CGUI*>(pCmptPrivate->pCBData); | ||||
IGUIObject* guiObj = guiPage->FindObjectByName(name); | IGUIObject* guiObj = guiPage->FindObjectByName(name); | ||||
if (!guiObj) | if (!guiObj) | ||||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator