Changeset View
Changeset View
Standalone View
Standalone View
source/gui/GUIManager.cpp
Show All 28 Lines | |||||
#include "scriptinterface/FunctionWrapper.h" | #include "scriptinterface/FunctionWrapper.h" | ||||
#include "scriptinterface/ScriptContext.h" | #include "scriptinterface/ScriptContext.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
#include "scriptinterface/StructuredClone.h" | #include "scriptinterface/StructuredClone.h" | ||||
CGUIManager* g_GUI = nullptr; | CGUIManager* g_GUI = nullptr; | ||||
const CStr CGUIManager::EventNameWindowResized = "WindowResized"; | const CStr CGUIManager::EventNameWindowResized = "WindowResized"; | ||||
const CStr CGUIManager::EventNamePageRegainedFocus = "PageRegainedFocus"; | |||||
// General TODOs: | // General TODOs: | ||||
// | // | ||||
// A lot of the CGUI data could (and should) be shared between | // A lot of the CGUI data could (and should) be shared between | ||||
// multiple pages, instead of treating them as completely independent, to save | // multiple pages, instead of treating them as completely independent, to save | ||||
// memory and loading time. | // memory and loading time. | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
if (m_PageStack.size() < 2) | if (m_PageStack.size() < 2) | ||||
{ | { | ||||
debug_warn(L"Tried to pop GUI page when there's < 2 in the stack"); | debug_warn(L"Tried to pop GUI page when there's < 2 in the stack"); | ||||
return; | return; | ||||
} | } | ||||
m_PageStack.pop_back(); | m_PageStack.pop_back(); | ||||
// Save an immutable copy so page isn't invalidated by anything that happens in the callback function. | |||||
SGUIPage page = m_PageStack.back(); | |||||
m_PageStack.back().PerformCallbackFunction(args); | m_PageStack.back().PerformCallbackFunction(args); | ||||
// Only send the regained focus event if the page is still on the top. | |||||
// We can assume that pages are identifiable by their gui pointer. | |||||
wraitii: This sounds too unconfident -> they are, because the guy pointer is literally the GUI page | |||||
if (page.gui == m_PageStack.back().gui) | |||||
m_PageStack.back().gui->SendEventToAll(EventNamePageRegainedFocus); | |||||
} | } | ||||
CGUIManager::SGUIPage::SGUIPage(const CStrW& pageName, const Script::StructuredClone initData) | CGUIManager::SGUIPage::SGUIPage(const CStrW& pageName, const Script::StructuredClone initData) | ||||
: m_Name(pageName), initData(initData), inputs(), gui(), callbackFunction() | : m_Name(pageName), initData(initData), inputs(), gui(), callbackFunction() | ||||
{ | { | ||||
} | } | ||||
void CGUIManager::SGUIPage::LoadPage(std::shared_ptr<ScriptContext> scriptContext) | void CGUIManager::SGUIPage::LoadPage(std::shared_ptr<ScriptContext> scriptContext) | ||||
▲ Show 20 Lines • Show All 276 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
This sounds too unconfident -> they are, because the guy pointer is literally the GUI page