Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/GUIManager.h
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | public: | ||||
* Load a new GUI page and make it active. All current pages will be destroyed. | * Load a new GUI page and make it active. All current pages will be destroyed. | ||||
*/ | */ | ||||
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. | |||||
*/ | */ | ||||
void PushPage(const CStrW& pageName, shared_ptr<ScriptInterface::StructuredClone> initData); | void PushPage(const CStrW& pageName, shared_ptr<ScriptInterface::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(); | void PopPage(shared_ptr<ScriptInterface::StructuredClone> args); | ||||
void PopPageCB(shared_ptr<ScriptInterface::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); | ||||
/** | /** | ||||
* Sets the default mouse pointer. | * Sets the default mouse pointer. | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | public: | ||||
*/ | */ | ||||
const CParamNode& GetTemplate(const std::string& templateName); | const CParamNode& GetTemplate(const std::string& templateName); | ||||
private: | 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). | |||||
*/ | |||||
SGUIPage(const CStrW& pageName, const shared_ptr<ScriptInterface::StructuredClone> initData); | SGUIPage(const CStrW& pageName, const shared_ptr<ScriptInterface::StructuredClone> initData); | ||||
/** | |||||
* Create the CGUI with it's own ScriptInterface. Deletes the previous CGUI if it existed. | |||||
*/ | |||||
void LoadPage(shared_ptr<ScriptRuntime> scriptRuntime); | void LoadPage(shared_ptr<ScriptRuntime> scriptRuntime); | ||||
/** | |||||
* 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); | |||||
/** | |||||
* Execute the stored callback function with the given arguments. | |||||
*/ | |||||
void PerformCallbackFunction(shared_ptr<ScriptInterface::StructuredClone> args); | |||||
CStrW name; | CStrW name; | ||||
boost::unordered_set<VfsPath> inputs; // for hotloading | boost::unordered_set<VfsPath> inputs; // for hotloading | ||||
shared_ptr<ScriptInterface::StructuredClone> initData; // data to be passed to the init() function | shared_ptr<ScriptInterface::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. | |||||
* 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<CGUI> top() const; | shared_ptr<CGUI> top() const; | ||||
shared_ptr<ScriptRuntime> m_ScriptRuntime; | shared_ptr<ScriptRuntime> m_ScriptRuntime; | ||||
shared_ptr<ScriptInterface> m_ScriptInterface; | shared_ptr<ScriptInterface> m_ScriptInterface; | ||||
typedef std::vector<SGUIPage> PageStackType; | typedef std::vector<SGUIPage> PageStackType; | ||||
Show All 10 Lines |
Wildfire Games · Phabricator