Changeset View
Changeset View
Standalone View
Standalone View
source/gui/Scripting/JSInterface_GUIManager.cpp
/* Copyright (C) 2020 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 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | bool TemplateExists(const std::string& templateName) | ||||
return g_GUI->TemplateExists(templateName); | return g_GUI->TemplateExists(templateName); | ||||
} | } | ||||
CParamNode GetTemplate(const std::string& templateName) | CParamNode GetTemplate(const std::string& templateName) | ||||
{ | { | ||||
return g_GUI->GetTemplate(templateName); | return g_GUI->GetTemplate(templateName); | ||||
} | } | ||||
CParamNode GetParamNodeAt(const std::wstring& path) | |||||
{ | |||||
CParamNode node; | |||||
CParamNode::LoadXML(node, VfsPath(path), ""); | |||||
return node; | |||||
} | |||||
CParamNode CreateParamNode(const ScriptInterface& itf, JS::HandleValue val) | |||||
{ | |||||
CParamNode node; | |||||
CParamNode::LoadJS(node, itf, val); | |||||
return node; | |||||
} | |||||
wraitii: These are 'debug' functions, though this also makes it possible for JS to read XML files, in… | |||||
Done Inline ActionsNot sure how well that will work with packaged versions of the game... It might introduce some confusion too ? Stan: Not sure how well that will work with packaged versions of the game... It might introduce some… | |||||
Done Inline ActionsMakes no difference. Not sure what you mean about confusion. wraitii: Makes no difference. Not sure what you mean about confusion. | |||||
void RegisterScriptFunctions(const ScriptRequest& rq) | void RegisterScriptFunctions(const ScriptRequest& rq) | ||||
{ | { | ||||
ScriptFunction::Register<&PushGuiPage>(rq, "PushGuiPage"); | ScriptFunction::Register<&PushGuiPage>(rq, "PushGuiPage"); | ||||
ScriptFunction::Register<&SwitchGuiPage>(rq, "SwitchGuiPage"); | ScriptFunction::Register<&SwitchGuiPage>(rq, "SwitchGuiPage"); | ||||
ScriptFunction::Register<&PopGuiPage>(rq, "PopGuiPage"); | ScriptFunction::Register<&PopGuiPage>(rq, "PopGuiPage"); | ||||
ScriptFunction::Register<&SetCursor>(rq, "SetCursor"); | ScriptFunction::Register<&SetCursor>(rq, "SetCursor"); | ||||
ScriptFunction::Register<&ResetCursor>(rq, "ResetCursor"); | ScriptFunction::Register<&ResetCursor>(rq, "ResetCursor"); | ||||
ScriptFunction::Register<&TemplateExists>(rq, "TemplateExists"); | ScriptFunction::Register<&TemplateExists>(rq, "TemplateExists"); | ||||
ScriptFunction::Register<&GetTemplate>(rq, "GetTemplate"); | ScriptFunction::Register<&GetTemplate>(rq, "GetTemplate"); | ||||
ScriptFunction::Register<&GetParamNodeAt>(rq, "GetParamNodeAt"); | |||||
ScriptFunction::Register<&CreateParamNode>(rq, "CreateParamNode"); | |||||
ScriptFunction::Register<&CGUI::FindObjectByName, &ScriptFunction::ObjectFromCBData<CGUI>>(rq, "GetGUIObjectByName"); | ScriptFunction::Register<&CGUI::FindObjectByName, &ScriptFunction::ObjectFromCBData<CGUI>>(rq, "GetGUIObjectByName"); | ||||
ScriptFunction::Register<&CGUI::SetGlobalHotkey, &ScriptFunction::ObjectFromCBData<CGUI>>(rq, "SetGlobalHotkey"); | ScriptFunction::Register<&CGUI::SetGlobalHotkey, &ScriptFunction::ObjectFromCBData<CGUI>>(rq, "SetGlobalHotkey"); | ||||
ScriptFunction::Register<&CGUI::UnsetGlobalHotkey, &ScriptFunction::ObjectFromCBData<CGUI>>(rq, "UnsetGlobalHotkey"); | ScriptFunction::Register<&CGUI::UnsetGlobalHotkey, &ScriptFunction::ObjectFromCBData<CGUI>>(rq, "UnsetGlobalHotkey"); | ||||
} | } | ||||
} | } |
Wildfire Games · Phabricator
These are 'debug' functions, though this also makes it possible for JS to read XML files, in effect, & I might add those next to related JSON functions.
(this opens up the door for an actor/template editor in-game)