Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CGUIManager Class Reference

External interface to the GUI system. More...

#include <GUIManager.h>

Collaboration diagram for CGUIManager:

Classes

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 (ScriptContext &scriptContext, ScriptInterface &scriptInterface)
 
 ~CGUIManager ()
 
ScriptInterfaceGetScriptInterface ()
 
ScriptContextGetContext ()
 
std::shared_ptr< CGUIGetActiveGUI ()
 
size_t GetPageCount () const
 Returns the number of currently open GUI pages. More...
 
void SwitchPage (const CStrW &name, const ScriptInterface *srcScriptInterface, JS::HandleValue initData)
 Load a new GUI page and make it active. More...
 
JS::Value PushPage (const CStrW &pageName, Script::StructuredClone initData)
 Load a new GUI page and make it active. More...
 
void PopPage (Script::StructuredClone args)
 Unload the currently active GUI page, and make the previous page 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...
 
InReaction HandleEvent (const SDL_Event_ *ev)
 Pass input events to the currently active GUI page. More...
 
void SendEventToAll (const CStr &eventName) const
 See CGUI::SendEventToAll; applies to the currently active page. More...
 
void SendEventToAll (const CStr &eventName, JS::HandleValueArray paramData) const
 
void 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 CParamNodeGetTemplate (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< CGUItop () const
 

Private Attributes

ScriptContextm_ScriptContext
 
ScriptInterfacem_ScriptInterface
 
PageStackType m_PageStack
 
CTemplateLoader m_TemplateLoader
 

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 ( ScriptContext scriptContext,
ScriptInterface 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()

ScriptContext & CGUIManager::GetContext ( )
inline

◆ GetPageCount()

size_t CGUIManager::GetPageCount ( ) const

Returns the number of currently open GUI pages.

◆ GetScriptInterface()

ScriptInterface & CGUIManager::GetScriptInterface ( )
inline

◆ GetTemplate()

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

Retrieve the requested template, used for displaying faction specificities.

◆ HandleEvent()

InReaction CGUIManager::HandleEvent ( const SDL_Event_ ev)

Pass input events to the currently active GUI page.

◆ NONCOPYABLE()

CGUIManager::NONCOPYABLE ( CGUIManager  )
private

◆ PopPage()

void CGUIManager::PopPage ( Script::StructuredClone  args)

Unload the currently active GUI page, and make the previous page active.

(There must be at least two pages when you call this.)

◆ PushPage()

JS::Value CGUIManager::PushPage ( 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() [1/2]

void CGUIManager::SendEventToAll ( const CStr &  eventName) const

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

◆ SendEventToAll() [2/2]

void CGUIManager::SendEventToAll ( const CStr &  eventName,
JS::HandleValueArray  paramData 
) const

◆ SwitchPage()

void CGUIManager::SwitchPage ( const CStrW &  name,
const ScriptInterface 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()

void CGUIManager::TickObjects ( )

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

◆ 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_PageStack

PageStackType CGUIManager::m_PageStack
private

◆ m_ScriptContext

ScriptContext& CGUIManager::m_ScriptContext
private

◆ m_ScriptInterface

ScriptInterface& CGUIManager::m_ScriptInterface
private

◆ m_TemplateLoader

CTemplateLoader CGUIManager::m_TemplateLoader
private

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