Changeset View
Changeset View
Standalone View
Standalone View
source/gui/Scripting/JSInterface_GUIManager.cpp
Show All 28 Lines | |||||
// Functions aren't supported for example! | // Functions aren't supported for example! | ||||
void JSI_GUIManager::PushGuiPage(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& name, JS::HandleValue initData, JS::HandleValue callbackFunction) | void JSI_GUIManager::PushGuiPage(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& name, JS::HandleValue initData, JS::HandleValue callbackFunction) | ||||
{ | { | ||||
g_GUI->PushPage(name, pCxPrivate->pScriptInterface->WriteStructuredClone(initData), callbackFunction); | g_GUI->PushPage(name, 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); | ||||
Stan: Debug leftover. | |||||
} | } | ||||
void JSI_GUIManager::PopGuiPage(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue args) | void JSI_GUIManager::PopGuiPage(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue args) | ||||
{ | { | ||||
if (g_GUI->GetPageCount() < 2) | if (g_GUI->GetPageCount() < 2) | ||||
{ | { | ||||
JSContext* cx = pCxPrivate->pScriptInterface->GetContext(); | JSContext* cx = pCxPrivate->pScriptInterface->GetContext(); | ||||
JSAutoRequest rq(cx); | JSAutoRequest rq(cx); | ||||
Show All 22 Lines | |||||
} | } | ||||
void JSI_GUIManager::UnsetGlobalHotkey(ScriptInterface::CxPrivate* pCxPrivate, const std::string& hotkeyTag, const std::string& eventName) | void JSI_GUIManager::UnsetGlobalHotkey(ScriptInterface::CxPrivate* pCxPrivate, const std::string& hotkeyTag, const std::string& eventName) | ||||
{ | { | ||||
CGUI* guiPage = static_cast<CGUI*>(pCxPrivate->pCBData); | CGUI* guiPage = static_cast<CGUI*>(pCxPrivate->pCBData); | ||||
guiPage->UnsetGlobalHotkey(hotkeyTag, eventName); | guiPage->UnsetGlobalHotkey(hotkeyTag, eventName); | ||||
} | } | ||||
std::wstring JSI_GUIManager::SetCursor(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& name) | std::wstring JSI_GUIManager::SetCursor(const std::wstring& name) | ||||
{ | { | ||||
std::wstring old = g_CursorName; | std::wstring old = g_CursorName; | ||||
g_CursorName = name; | g_CursorName = name; | ||||
return old; | return old; | ||||
} | } | ||||
void JSI_GUIManager::ResetCursor(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) | void JSI_GUIManager::ResetCursor() | ||||
{ | { | ||||
g_CursorName = g_DefaultCursor; | g_CursorName = g_DefaultCursor; | ||||
} | } | ||||
bool JSI_GUIManager::TemplateExists(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& templateName) | bool JSI_GUIManager::TemplateExists(const std::string& templateName) | ||||
{ | { | ||||
return g_GUI->TemplateExists(templateName); | return g_GUI->TemplateExists(templateName); | ||||
} | } | ||||
CParamNode JSI_GUIManager::GetTemplate(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& templateName) | CParamNode JSI_GUIManager::GetTemplate(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, JS::HandleValue, &PushGuiPage>("PushGuiPage"); | #define Register(name) scriptInterface.RegisterGlobalFunction<decltype(&name), &name>(#name); | ||||
scriptInterface.RegisterFunction<void, std::wstring, JS::HandleValue, &SwitchGuiPage>("SwitchGuiPage"); | Register(PushGuiPage); | ||||
scriptInterface.RegisterFunction<void, std::string, std::string, JS::HandleValue, &SetGlobalHotkey>("SetGlobalHotkey"); | Register(SwitchGuiPage); | ||||
scriptInterface.RegisterFunction<void, std::string, std::string, &UnsetGlobalHotkey>("UnsetGlobalHotkey"); | Register(SetGlobalHotkey); | ||||
scriptInterface.RegisterFunction<void, JS::HandleValue, &PopGuiPage>("PopGuiPage"); | Register(UnsetGlobalHotkey); | ||||
scriptInterface.RegisterFunction<JS::Value, std::string, &GetGUIObjectByName>("GetGUIObjectByName"); | Register(PopGuiPage); | ||||
scriptInterface.RegisterFunction<std::wstring, std::wstring, &SetCursor>("SetCursor"); | Register(GetGUIObjectByName); | ||||
scriptInterface.RegisterFunction<void, &ResetCursor>("ResetCursor"); | Register(SetCursor); | ||||
scriptInterface.RegisterFunction<bool, std::string, &TemplateExists>("TemplateExists"); | Register(ResetCursor); | ||||
scriptInterface.RegisterFunction<CParamNode, std::string, &GetTemplate>("GetTemplate"); | Register(TemplateExists); | ||||
Register(GetTemplate); | |||||
#undef Register | |||||
Not Done Inline ActionsRegisterFunction, I'm not sure what the gain is here though? Stan: RegisterFunction, I'm not sure what the gain is here though? | |||||
} | } |
Wildfire Games · Phabricator
Debug leftover.