Pyrogenesis  trunk
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
CGUIManager Class Reference

External interface to the GUI system. More...

#include <GUIManager.h>

Collaboration diagram for CGUIManager:
Collaboration graph
[legend]

Classes

struct  SGUIPage
 

Public Member Functions

 CGUIManager ()
 
 ~CGUIManager ()
 
std::shared_ptr< ScriptInterfaceGetScriptInterface ()
 
std::shared_ptr< 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...
 
void PushPage (const CStrW &pageName, Script::StructuredClone initData, JS::HandleValue callbackFunc)
 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 Types

using PageStackType = std::deque< SGUIPage >
 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...
 

Private Member Functions

 NONCOPYABLE (CGUIManager)
 
std::shared_ptr< CGUItop () const
 

Private Attributes

std::shared_ptr< ScriptContextm_ScriptContext
 
std::shared_ptr< 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.

Member Typedef Documentation

◆ PageStackType

using CGUIManager::PageStackType = std::deque<SGUIPage>
private

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).

Therefore use std::deque over std::vector.

Constructor & Destructor Documentation

◆ CGUIManager()

CGUIManager::CGUIManager ( )

◆ ~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()

std::shared_ptr<ScriptContext> CGUIManager::GetContext ( )
inline

◆ GetPageCount()

size_t CGUIManager::GetPageCount ( ) const

Returns the number of currently open GUI pages.

◆ GetScriptInterface()

std::shared_ptr<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()

void CGUIManager::PushPage ( const CStrW &  pageName,
Script::StructuredClone  initData,
JS::HandleValue  callbackFunc 
)

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. If given, the callbackHandler function will be executed once this 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

std::shared_ptr<ScriptContext> CGUIManager::m_ScriptContext
private

◆ m_ScriptInterface

std::shared_ptr<ScriptInterface> CGUIManager::m_ScriptInterface
private

◆ m_TemplateLoader

CTemplateLoader CGUIManager::m_TemplateLoader
private

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