Changeset View
Changeset View
Standalone View
Standalone View
source/gui/GUIManager.h
Show All 19 Lines | |||||
#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/StructuredClone.h" | #include "scriptinterface/StructuredClone.h" | ||||
#include <deque> | #include <deque> | ||||
#include <optional> | |||||
#include <string> | #include <string> | ||||
#include <unordered_set> | #include <unordered_set> | ||||
class CCanvas2D; | class CCanvas2D; | ||||
class CGUI; | class CGUI; | ||||
/** | /** | ||||
* External interface to the GUI system. | * External interface to the GUI system. | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | public: | ||||
/** | /** | ||||
* Pass input events to the currently active GUI page. | * Pass input events to the currently active GUI page. | ||||
*/ | */ | ||||
InReaction HandleEvent(const SDL_Event_* ev); | InReaction HandleEvent(const SDL_Event_* ev); | ||||
/** | /** | ||||
* See CGUI::SendEventToAll; applies to the currently active page. | * See CGUI::SendEventToAll; applies to the currently active page. | ||||
*/ | */ | ||||
void SendEventToAll(const CStr& eventName) const; | void SendEventToAll(const CStr& eventName); | ||||
void SendEventToAll(const CStr& eventName, JS::HandleValueArray paramData) const; | void SendEventToAll(const CStr& eventName, JS::HandleValueArray paramData); | ||||
/** | /** | ||||
* See CGUI::TickObjects; applies to @em all loaded pages. | * See CGUI::TickObjects; applies to @em all loaded pages. | ||||
*/ | */ | ||||
void TickObjects(); | void TickObjects(); | ||||
/** | /** | ||||
* See CGUI::Draw; applies to @em all loaded pages. | * See CGUI::Draw; applies to @em all loaded pages. | ||||
Show All 16 Lines | public: | ||||
const CParamNode& GetTemplate(const std::string& templateName); | const CParamNode& GetTemplate(const std::string& templateName); | ||||
/** | /** | ||||
* Display progress / description in loading screen. | * Display progress / description in loading screen. | ||||
*/ | */ | ||||
void DisplayLoadProgress(int percent, const wchar_t* pending_task); | void DisplayLoadProgress(int percent, const wchar_t* pending_task); | ||||
private: | private: | ||||
/** | |||||
* Copy the m_CurrentPages to m_NextPages if it needs to. Has to be called before the page stack is | |||||
* edited while iterating. | |||||
*/ | |||||
void MakeNextPages(); | |||||
phosit: Does somebody have a bether name for this function? | |||||
Not Done Inline ActionsUpdatePagesIfNeeded ? Stan: UpdatePagesIfNeeded ? | |||||
Not Done Inline ActionsBoth functions could be named that I tend to: PrepareToEdit and PrepareToIterate phosit: Both functions could be named that
I tend to: PrepareToEdit and PrepareToIterate | |||||
/** | |||||
* Copy m_NextPages back to m_CurrentPages if it needs to. Has to be called after JS-code might have | |||||
* edited the stack and we finished iterating. | |||||
phositAuthorUnsubmitted Not Done Inline ActionsThis comment is wrong now. phosit: This comment is wrong now. | |||||
*/ | |||||
void UpdatePages(); | |||||
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). | ||||
*/ | */ | ||||
Show All 32 Lines | private: | ||||
std::shared_ptr<ScriptInterface> m_ScriptInterface; | std::shared_ptr<ScriptInterface> m_ScriptInterface; | ||||
/** | /** | ||||
* The page stack must not move pointers on push/pop, or pushing a page in a page's init method | * The page stack must not move pointers on push/pop, or pushing a page in a page's init method | ||||
* may crash (as the pusher page will suddenly have moved, and the stack will be confused). | * may crash (as the pusher page will suddenly have moved, and the stack will be confused). | ||||
* Therefore use std::deque over std::vector. | * Therefore use std::deque over std::vector. | ||||
*/ | */ | ||||
using PageStackType = std::deque<SGUIPage>; | using PageStackType = std::deque<SGUIPage>; | ||||
PageStackType m_PageStack; | PageStackType m_CurrentPages; | ||||
std::optional<PageStackType> m_NextPages; | |||||
CTemplateLoader m_TemplateLoader; | CTemplateLoader m_TemplateLoader; | ||||
}; | }; | ||||
extern CGUIManager* g_GUI; | extern CGUIManager* g_GUI; | ||||
extern InReaction gui_handler(const SDL_Event_* ev); | extern InReaction gui_handler(const SDL_Event_* ev); | ||||
#endif // INCLUDED_GUIMANAGER | #endif // INCLUDED_GUIMANAGER |
Wildfire Games · Phabricator
Does somebody have a bether name for this function?