Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CGUIManager Class Reference

External interface to the GUI system. More...

#include <GUIManager.h>

Collaboration diagram for CGUIManager:

Classes

struct  InputHandler
 
class  PageStackType
 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). More...
 
struct  SGUIPage
 

Public Member Functions

 CGUIManager (Script::Context &scriptContext, Script::Interface &scriptInterface)
 
 ~CGUIManager ()
 
Script::Interface & GetScriptInterface ()
 
Script::Context & GetContext ()
 
std::shared_ptr< CGUI > GetActiveGUI ()
 
size_t GetPageCount () const
 Returns the number of currently open GUI pages. More...
 
void SwitchPage (const CStrW &name, const Script::Interface *srcScriptInterface, JS::HandleValue initData)
 Load a new GUI page and make it active. More...
 
JS::Value OpenChildPage (const CStrW &pageName, Script::StructuredClone initData)
 Load a new GUI page and make it active. More...
 
Status ReloadChangedFile (const VfsPath &path)
 Called when a file has been modified, to hotload changes. More...
 
Status ReloadAllPages ()
 Called when we should reload all pages (e.g. More...
 
Input::Reaction HandleEvent (const SDL_Event &ev)
 Pass input events to the currently active GUI page. More...
 
void SendEventToAll (const CStr &eventName, std::optional< JS::HandleValueArray > paramData=std::nullopt) const
 See CGUI::SendEventToAll; applies to the currently active page. More...
 
std::optional< bool > TickObjects ()
 See CGUI::TickObjects; applies to all loaded pages. More...
 
void Draw (CCanvas2D &canvas) const
 See CGUI::Draw; applies to all loaded pages. More...
 
void UpdateResolution ()
 See CGUI::UpdateResolution; applies to all loaded pages. More...
 
bool TemplateExists (const std::string &templateName) const
 Check if a template with this name exists. More...
 
const CParamNode & GetTemplate (const std::string &templateName)
 Retrieve the requested template, used for displaying faction specificities. More...
 
void DisplayLoadProgress (int percent, const wchar_t *pending_task)
 Display progress / description in loading screen. More...
 

Private Member Functions

 NONCOPYABLE (CGUIManager)
 
std::shared_ptr< CGUI > top () const
 
PS::StaticVector< SGUIPage, 16 > GetCopyOfFrozenStack () const
 Returns an immutable copy so iterators aren't invalidated by handlers. More...
 

Private Attributes

Script::Context & m_ScriptContext
 
Script::Interface & m_ScriptInterface
 
PageStackType m_PageStack
 
CTemplateLoader m_TemplateLoader
 
Input::Handler< InputHandler > m_InputHandler
 

Detailed Description

External interface to the GUI system.

The GUI consists of a set of pages. Each page is constructed from a series of XML files, and is independent from any other page. Only one page is active at a time. All events and render requests etc will go to the active page. This lets the GUI switch between pre-game menu and in-game UI.

Constructor & Destructor Documentation

◆ CGUIManager()

CGUIManager::CGUIManager ( Script::Context &  scriptContext,
Script::Interface &  scriptInterface 
)

◆ ~CGUIManager()

CGUIManager::~CGUIManager ( )

Member Function Documentation

◆ DisplayLoadProgress()

void CGUIManager::DisplayLoadProgress ( int  percent,
const wchar_t *  pending_task 
)

Display progress / description in loading screen.

◆ Draw()

void CGUIManager::Draw ( CCanvas2D &  canvas) const

See CGUI::Draw; applies to all loaded pages.

◆ GetActiveGUI()

std::shared_ptr< CGUI > CGUIManager::GetActiveGUI ( )
inline

◆ GetContext()

Script::Context & CGUIManager::GetContext ( )
inline

◆ GetCopyOfFrozenStack()

PS::StaticVector< CGUIManager::SGUIPage, 16 > CGUIManager::GetCopyOfFrozenStack ( ) const
private

Returns an immutable copy so iterators aren't invalidated by handlers.

◆ GetPageCount()

size_t CGUIManager::GetPageCount ( ) const

Returns the number of currently open GUI pages.

◆ GetScriptInterface()

Script::Interface & CGUIManager::GetScriptInterface ( )
inline

◆ GetTemplate()

const CParamNode & CGUIManager::GetTemplate ( const std::string &  templateName)

Retrieve the requested template, used for displaying faction specificities.

◆ HandleEvent()

Input::Reaction CGUIManager::HandleEvent ( const SDL_Event &  ev)

Pass input events to the currently active GUI page.

◆ NONCOPYABLE()

CGUIManager::NONCOPYABLE ( CGUIManager  )
private

◆ OpenChildPage()

JS::Value CGUIManager::OpenChildPage ( const CStrW &  pageName,
Script::StructuredClone  initData 
)

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 user inputs. The returned promise will be fulfilled once the pushed page is closed.

◆ ReloadAllPages()

Status CGUIManager::ReloadAllPages ( )

Called when we should reload all pages (e.g.

translation hotloading update).

◆ ReloadChangedFile()

Status CGUIManager::ReloadChangedFile ( const VfsPath &  path)

Called when a file has been modified, to hotload changes.

◆ SendEventToAll()

void CGUIManager::SendEventToAll ( const CStr &  eventName,
std::optional< JS::HandleValueArray >  paramData = std::nullopt 
) const

See CGUI::SendEventToAll; applies to the currently active page.

◆ SwitchPage()

void CGUIManager::SwitchPage ( const CStrW &  name,
const Script::Interface *  srcScriptInterface,
JS::HandleValue  initData 
)

Load a new GUI page and make it active.

All current pages will be destroyed.

◆ TemplateExists()

bool CGUIManager::TemplateExists ( const std::string &  templateName) const

Check if a template with this name exists.

◆ TickObjects()

std::optional< bool > CGUIManager::TickObjects ( )

See CGUI::TickObjects; applies to all loaded pages.

When the root page is closed it's returned wheter Atlas should be started.

◆ top()

std::shared_ptr< CGUI > CGUIManager::top ( ) const
private

◆ UpdateResolution()

void CGUIManager::UpdateResolution ( )

See CGUI::UpdateResolution; applies to all loaded pages.

Member Data Documentation

◆ m_InputHandler

Input::Handler<InputHandler> CGUIManager::m_InputHandler
private

◆ m_PageStack

PageStackType CGUIManager::m_PageStack
private

◆ m_ScriptContext

Script::Context& CGUIManager::m_ScriptContext
private

◆ m_ScriptInterface

Script::Interface& CGUIManager::m_ScriptInterface
private

◆ m_TemplateLoader

CTemplateLoader CGUIManager::m_TemplateLoader
private

The documentation for this class was generated from the following files: