Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/GUIManager.h
Show All 16 Lines | |||||
#ifndef INCLUDED_GUIMANAGER | #ifndef INCLUDED_GUIMANAGER | ||||
#define INCLUDED_GUIMANAGER | #define INCLUDED_GUIMANAGER | ||||
#include "lib/file/vfs/vfs_path.h" | #include "lib/file/vfs/vfs_path.h" | ||||
#include "lib/input.h" | #include "lib/input.h" | ||||
#include "ps/CStr.h" | #include "ps/CStr.h" | ||||
#include "ps/TemplateLoader.h" | #include "ps/TemplateLoader.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/StructuredClone.h" | ||||
#include <string> | #include <string> | ||||
#include <unordered_set> | #include <unordered_set> | ||||
class CGUI; | class CGUI; | ||||
/** | /** | ||||
* External interface to the GUI system. | * External interface to the GUI system. | ||||
Show All 29 Lines | public: | ||||
void SwitchPage(const CStrW& name, ScriptInterface* srcScriptInterface, JS::HandleValue initData); | void SwitchPage(const CStrW& name, ScriptInterface* srcScriptInterface, JS::HandleValue initData); | ||||
/** | /** | ||||
* Load a new GUI page and make it active. All current pages will be retained, | * Load a new GUI page and make it active. All current pages will be retained, | ||||
* and will still be drawn and receive tick events, but will not receive | * and will still be drawn and receive tick events, but will not receive | ||||
* user inputs. | * user inputs. | ||||
* If given, the callbackHandler function will be executed once this page is closed. | * If given, the callbackHandler function will be executed once this page is closed. | ||||
*/ | */ | ||||
void PushPage(const CStrW& pageName, ScriptInterface::StructuredClone initData, JS::HandleValue callbackFunc); | void PushPage(const CStrW& pageName, Script::StructuredClone initData, JS::HandleValue callbackFunc); | ||||
/** | /** | ||||
* Unload the currently active GUI page, and make the previous page active. | * Unload the currently active GUI page, and make the previous page active. | ||||
* (There must be at least two pages when you call this.) | * (There must be at least two pages when you call this.) | ||||
*/ | */ | ||||
void PopPage(ScriptInterface::StructuredClone args); | void PopPage(Script::StructuredClone args); | ||||
/** | /** | ||||
* Called when a file has been modified, to hotload changes. | * Called when a file has been modified, to hotload changes. | ||||
*/ | */ | ||||
Status ReloadChangedFile(const VfsPath& path); | Status ReloadChangedFile(const VfsPath& path); | ||||
/** | /** | ||||
* Called when we should reload all pages (e.g. translation hotloading update). | * Called when we should reload all pages (e.g. translation hotloading update). | ||||
Show All 40 Lines | private: | ||||
struct SGUIPage | struct SGUIPage | ||||
{ | { | ||||
// COPYABLE, because event handlers may invalidate page stack iterators by open or close pages, | // COPYABLE, because event handlers may invalidate page stack iterators by open or close pages, | ||||
// and event handlers need to be called for the entire stack. | // and event handlers need to be called for the entire stack. | ||||
/** | /** | ||||
* Initializes the data that will be used to create the CGUI page one or multiple times (hotloading). | * Initializes the data that will be used to create the CGUI page one or multiple times (hotloading). | ||||
*/ | */ | ||||
SGUIPage(const CStrW& pageName, const ScriptInterface::StructuredClone initData); | SGUIPage(const CStrW& pageName, const Script::StructuredClone initData); | ||||
/** | /** | ||||
* Create the CGUI with it's own ScriptInterface. Deletes the previous CGUI if it existed. | * Create the CGUI with it's own ScriptInterface. Deletes the previous CGUI if it existed. | ||||
*/ | */ | ||||
void LoadPage(shared_ptr<ScriptContext> scriptContext); | void LoadPage(shared_ptr<ScriptContext> scriptContext); | ||||
/** | /** | ||||
* Sets the callback handler when a new page is opened that will be performed when the page is closed. | * Sets the callback handler when a new page is opened that will be performed when the page is closed. | ||||
*/ | */ | ||||
void SetCallbackFunction(ScriptInterface& scriptInterface, JS::HandleValue callbackFunc); | void SetCallbackFunction(ScriptInterface& scriptInterface, JS::HandleValue callbackFunc); | ||||
/** | /** | ||||
* Execute the stored callback function with the given arguments. | * Execute the stored callback function with the given arguments. | ||||
*/ | */ | ||||
void PerformCallbackFunction(ScriptInterface::StructuredClone args); | void PerformCallbackFunction(Script::StructuredClone args); | ||||
CStrW m_Name; | CStrW m_Name; | ||||
std::unordered_set<VfsPath> inputs; // for hotloading | std::unordered_set<VfsPath> inputs; // for hotloading | ||||
ScriptInterface::StructuredClone initData; // data to be passed to the init() function | Script::StructuredClone initData; // data to be passed to the init() function | ||||
shared_ptr<CGUI> gui; // the actual GUI page | shared_ptr<CGUI> gui; // the actual GUI page | ||||
/** | /** | ||||
* Function executed by this parent GUI page when the child GUI page it pushed is popped. | * Function executed by this parent GUI page when the child GUI page it pushed is popped. | ||||
* Notice that storing it in the SGUIPage instead of CGUI means that it will survive the hotloading CGUI reset. | * Notice that storing it in the SGUIPage instead of CGUI means that it will survive the hotloading CGUI reset. | ||||
*/ | */ | ||||
shared_ptr<JS::PersistentRootedValue> callbackFunction; | shared_ptr<JS::PersistentRootedValue> callbackFunction; | ||||
}; | }; | ||||
Show All 19 Lines |
Wildfire Games · Phabricator