18 #include "precompiled.h"
52 m_ScriptInterface(scriptInterface)
87 debug_warn(L
"Tried to pop GUI page when there's < 2 in the stack");
118 page.
gui->Initialize();
135 LOGERROR(L
"GUI page '%ls' must have root element <page>", page.
name.c_str());
141 if (node.GetNodeName() != elmt_include)
143 LOGERROR(L
"GUI page '%ls' must only have <include> elements inside <page>", page.
name.c_str());
147 CStrW name (node.GetText().FromUTF8());
154 page.
gui->LoadXmlFile(path, page.
inputs);
161 page.
gui->SendEventToAll(
"load");
166 LOGERROR(L
"GUI page '%ls': Failed to call init() function", page.
name.c_str());
176 if (it->inputs.count(path))
178 LOGMESSAGE(L
"GUI file '%ls' changed - reloading page '%ls'", path.
string().c_str(), it->name.c_str());
191 LOGERROR(L
"Failed to call getSavedGameData() on the current GUI page");
207 PROFILE(
"handleInputBeforeGui");
214 PROFILE(
"handle event in native GUI");
221 PROFILE(
"handleInputAfterGui");
233 return top()->GetPreDefinedColor(name, output);
238 return top()->IconExists(str);
243 return top()->GetIcon(str);
253 return top()->FindObjectByName(name);
258 top()->SendEventToAll(eventName);
268 for (PageStackType::iterator it = pageStack.begin(); it != pageStack.end(); ++it)
271 it->gui->TickObjects();
287 it->gui->UpdateResolution();
292 return top()->GetScriptObject();
void LoadPage(SGUIPage &page)
InReaction gui_handler(const SDL_Event_ *ev)
void PopPage()
Unload the currently active GUI page, and make the previous page active.
Path VfsPath
VFS path of the form "(dir/)*file?".
PageStackType m_PageStack
PSRETURN Load(const PIVFS &vfs, const VfsPath &filename)
Load from an XML file (with invisible XMB caching).
void SetCallbackData(void *cbdata)
const PSRETURN PSRETURN_OK
int GetElementID(const char *Name) const
CGUIManager(ScriptInterface &scriptInterface)
bool CallFunctionVoid(jsval val, const char *name)
Call the named property on the given object, with void return type and 0 arguments.
void PushPage(const CStrW &name, CScriptVal initData)
Load a new GUI page and make it active.
#define XERO_ITER_EL(parent_element, child_element)
A trivial wrapper around a jsval.
bool GetPreDefinedColor(const CStr &name, CColor &output)
See CGUI::GetPreDefinedColor; applies to the currently active page.
Base settings, all objects possess these settings in their m_BaseSettings Instructions can be found i...
bool LoadGlobalScripts()
Load global scripts that most script contexts need, located in the /globalscripts directory...
CScriptValRooted initData
boost::unordered_set< VfsPath > inputs
void UpdateResolution()
See CGUI::UpdateResolution; applies to all loaded pages.
std::vector< SGUIPage > PageStackType
The main object that represents a whole GUI page.
CScriptVal GetSavedGameData()
Calls the current page's script function getSavedGameData() and returns the result.
bool IconExists(const CStr &str) const
See CGUI::IconExists; applies to the currently active page.
SGUIIcon GetIcon(const CStr &str) const
See CGUI::GetIcon; applies to the currently active page.
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
#define PROFILE2(region)
Starts timing from now until the end of the current scope.
static void * GetCallbackData(JSContext *cx)
const String & string() const
IGUIObject * FindObjectByName(const CStr &name) const
See CGUI::FindObjectByName; applies to the currently active page.
JSObject * GetScriptObject()
See CGUI::GetScriptObject; applies to the currently active page.
bool Eval(const char *code)
void TickObjects()
See CGUI::TickObjects; applies to all loaded pages.
i64 Status
Error handling system.
void DisplayMessageBox(int width, int height, const CStrW &title, const CStrW &message)
Display a modal message box with an "OK" button.
#define TIMER(description)
Measures the time taken to execute code up until end of the current scope; displays it via debug_prin...
bool CallFunction(jsval val, const char *name, R &ret)
Call the named property on the given object, with return type R and 0 arguments.
#define PROFILE2_ATTR
Associates a string (with printf-style formatting) with the current region or event.
void SwitchPage(const CStrW &name, CScriptVal initData)
Load a new GUI page and make it active.
XMBElement GetRoot() const
jsval get() const
Returns the current value (or JSVAL_VOID if uninitialised).
Abstraction around a SpiderMonkey JSContext.
ScriptInterface & m_ScriptInterface
#define PROFILE3_GPU(name)
#define debug_warn(expr)
display the error dialog with the given text.
void Draw()
See CGUI::Draw; applies to all loaded pages.
shared_ptr< CGUI > top() const
External interface to the GUI system.
shared_ptr< CGUI > m_CurrentGUI
bool SetProperty(jsval obj, const char *name, const T &value, bool constant=false, bool enumerate=true)
Set the named property on the given object.
bool HasPages()
Returns whether there are any current pages.
JSContext * GetContext() const
InReaction HandleEvent(const SDL_Event_ *ev)
Pass input events to the currently active GUI page.
void SendEventToAll(const CStr &eventName)
See CGUI::SendEventToAll; applies to the currently active page.
Status ReloadChangedFiles(const VfsPath &path)
Call when a file has bee modified, to hotload pages if their .xml files changed.