18#ifndef INCLUDED_GUIMANAGER
19#define INCLUDED_GUIMANAGER
32#include <js/TypeDecls.h>
36#include <unordered_set>
42namespace Script {
class Context; }
43namespace JS {
class HandleValueArray; }
44namespace JS {
class Value; }
107 std::optional<JS::HandleValueArray> paramData = std::nullopt)
const;
180 std::optional<CloseResult>
MaybeClose(
const bool isRootPage);
192 std::shared_ptr<CGUI>
gui;
207 std::shared_ptr<CGUI>
top()
const;
228 while (!std::deque<SGUIPage>::empty())
229 std::deque<SGUIPage>::pop_back();
CGUIManager * g_GUI
Definition: GUIManager.cpp:73
Definition: Canvas2D.h:36
The page stack must not move pointers on push/pop, or pushing a page in a page's init method may cras...
Definition: GUIManager.h:219
void clear()
Definition: GUIManager.h:226
~PageStackType()
Definition: GUIManager.h:221
External interface to the GUI system.
Definition: GUIManager.h:57
Status ReloadAllPages()
Called when we should reload all pages (e.g.
Definition: GUIManager.cpp:362
PageStackType m_PageStack
Definition: GUIManager.h:232
CGUIManager(Script::Context &scriptContext, Script::Interface &scriptInterface)
Definition: GUIManager.cpp:93
Script::Interface & m_ScriptInterface
Definition: GUIManager.h:210
void DisplayLoadProgress(int percent, const wchar_t *pending_task)
Display progress / description in loading screen.
Definition: GUIManager.cpp:506
std::optional< bool > TickObjects()
See CGUI::TickObjects; applies to all loaded pages.
Definition: GUIManager.cpp:428
std::shared_ptr< CGUI > top() const
Definition: GUIManager.cpp:525
Script::Interface & GetScriptInterface()
Definition: GUIManager.h:63
bool TemplateExists(const std::string &templateName) const
Check if a template with this name exists.
Definition: GUIManager.cpp:492
Script::Context & GetContext()
Definition: GUIManager.h:67
void SwitchPage(const CStrW &name, const Script::Interface *srcScriptInterface, JS::HandleValue initData)
Load a new GUI page and make it active.
Definition: GUIManager.cpp:119
Script::Context & m_ScriptContext
Definition: GUIManager.h:209
void Draw(CCanvas2D &canvas) const
See CGUI::Draw; applies to all loaded pages.
Definition: GUIManager.cpp:473
std::shared_ptr< CGUI > GetActiveGUI()
Definition: GUIManager.h:68
void SendEventToAll(const CStr &eventName, std::optional< JS::HandleValueArray > paramData=std::nullopt) const
See CGUI::SendEventToAll; applies to the currently active page.
Definition: GUIManager.cpp:414
Status ReloadChangedFile(const VfsPath &path)
Called when a file has been modified, to hotload changes.
Definition: GUIManager.cpp:348
Input::Reaction HandleEvent(const SDL_Event &ev)
Pass input events to the currently active GUI page.
Definition: GUIManager.cpp:371
void UpdateResolution()
See CGUI::UpdateResolution; applies to all loaded pages.
Definition: GUIManager.cpp:481
PS::StaticVector< SGUIPage, 16 > GetCopyOfFrozenStack() const
Returns an immutable copy so iterators aren't invalidated by handlers.
Definition: GUIManager.cpp:531
JS::Value OpenChildPage(const CStrW &pageName, Script::StructuredClone initData)
Load a new GUI page and make it active.
Definition: GUIManager.cpp:141
const CParamNode & GetTemplate(const std::string &templateName)
Retrieve the requested template, used for displaying faction specificities.
Definition: GUIManager.cpp:497
size_t GetPageCount() const
Returns the number of currently open GUI pages.
Definition: GUIManager.cpp:114
Input::Handler< InputHandler > m_InputHandler
Definition: GUIManager.h:246
~CGUIManager()
Definition: GUIManager.cpp:109
CTemplateLoader m_TemplateLoader
Definition: GUIManager.h:239
The main object that represents a whole GUI page.
Definition: CGUI.h:80
An entity initialisation parameter node.
Definition: ParamNode.h:153
Template loader: Handles the loading of entity template files for:
Definition: TemplateLoader.h:50
A conntainer close to std::vector but the elements are stored in place: There is a fixed capacity and...
Definition: StaticVector.h:89
Definition: Interface.h:93
Definition: GUIManager.h:45
Abstraction around a SpiderMonkey JSContext.
Definition: DapInterface.h:32
std::shared_ptr< JSStructuredCloneData > StructuredClone
Structured clones are a way to serialize 'simple' JS::Values into a buffer that can safely be passed ...
Definition: StructuredClone.h:39
std::int64_t Status
Error handling system.
Definition: status.h:174
Definition: GUIManager.h:163
bool rejected
Definition: GUIManager.h:165
Script::StructuredClone arg
Definition: GUIManager.h:164
Definition: GUIManager.h:169
Script::StructuredClone arg
Definition: GUIManager.h:171
std::wstring path
Definition: GUIManager.h:170
Definition: GUIManager.h:143
std::shared_ptr< JS::PersistentRootedObject > sendingPromise
When this promise is settled this page wants to be closed.
Definition: GUIManager.h:198
std::unordered_set< VfsPath > inputs
Definition: GUIManager.h:190
SGUIPage(const CStrW &pageName, const Script::StructuredClone initData)
Initializes the data that will be used to create the CGUI page one or multiple times (hotloading).
Definition: GUIManager.cpp:163
void LoadPage(Script::Context &context)
Create the CGUI with it's own Script::Interface.
Definition: GUIManager.cpp:168
std::shared_ptr< CGUI > gui
Definition: GUIManager.h:192
std::wstring m_Name
Definition: GUIManager.h:189
std::optional< CloseResult > MaybeClose(const bool isRootPage)
If the page should be closed this function closes the page and returns the result of the init functio...
Definition: GUIManager.cpp:281
std::variant< Close, OpenRequest > CloseResult
Definition: GUIManager.h:174
void Refocus(const Close &result)
This function should be called when a child page got closed.
Definition: GUIManager.cpp:327
std::shared_ptr< JS::PersistentRootedObject > receivingPromise
The parent page waits on this promise.
Definition: GUIManager.h:204
JS::Value GetPromise()
A reference to the promise is returned.
Definition: GUIManager.cpp:269
Script::StructuredClone initData
Definition: GUIManager.h:191