Changeset View
Changeset View
Standalone View
Standalone View
source/gui/GUIManager.cpp
/* Copyright (C) 2017 Wildfire Games. | /* Copyright (C) 2018 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void CGUIManager::PushPage(const CStrW& pageName, shared_ptr<ScriptInterface::StructuredClone> initData) | void CGUIManager::PushPage(const CStrW& pageName, shared_ptr<ScriptInterface::StructuredClone> initData) | ||||
{ | { | ||||
m_PageStack.push_back(SGUIPage()); | m_PageStack.push_back(SGUIPage()); | ||||
m_PageStack.back().name = pageName; | m_PageStack.back().name = pageName; | ||||
m_PageStack.back().initData = initData; | m_PageStack.back().initData = initData; | ||||
LoadPage(m_PageStack.back()); | LoadPage(m_PageStack.back()); | ||||
ActivateTopPage();; | |||||
elexis: ;; | |||||
ResetCursor(); | ResetCursor(); | ||||
} | } | ||||
void CGUIManager::PopPage() | void CGUIManager::PopPage() | ||||
{ | { | ||||
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(); | ||||
ActivateTopPage(); | |||||
} | } | ||||
void CGUIManager::PopPageCB(shared_ptr<ScriptInterface::StructuredClone> args) | void CGUIManager::PopPageCB(shared_ptr<ScriptInterface::StructuredClone> args) | ||||
{ | { | ||||
shared_ptr<ScriptInterface::StructuredClone> initDataClone = m_PageStack.back().initData; | shared_ptr<ScriptInterface::StructuredClone> initDataClone = m_PageStack.back().initData; | ||||
PopPage(); | PopPage(); | ||||
shared_ptr<ScriptInterface> scriptInterface = m_PageStack.back().gui->GetScriptInterface(); | shared_ptr<ScriptInterface> scriptInterface = m_PageStack.back().gui->GetScriptInterface(); | ||||
▲ Show 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
// TODO: this can crash if LoadPage runs an init script which modifies the page stack and breaks our iterators | // TODO: this can crash if LoadPage runs an init script which modifies the page stack and breaks our iterators | ||||
for (SGUIPage& p : m_PageStack) | for (SGUIPage& p : m_PageStack) | ||||
LoadPage(p); | LoadPage(p); | ||||
return INFO::OK; | return INFO::OK; | ||||
} | } | ||||
void CGUIManager::ActivateTopPage() | |||||
{ | |||||
top()->ActivatePage(); | |||||
} | |||||
elexisUnsubmitted Not Done Inline ActionsRemoving this proxy sounds safer, requiring the caller to actively figure out which GUI page it wants to operate on. elexis: Removing this proxy sounds safer, requiring the caller to actively figure out which GUI page it… | |||||
void CGUIManager::ResetCursor() | void CGUIManager::ResetCursor() | ||||
{ | { | ||||
g_CursorName = g_DefaultCursor; | g_CursorName = g_DefaultCursor; | ||||
} | } | ||||
std::string CGUIManager::GetSavedGameData() | std::string CGUIManager::GetSavedGameData() | ||||
{ | { | ||||
shared_ptr<ScriptInterface> scriptInterface = top()->GetScriptInterface(); | shared_ptr<ScriptInterface> scriptInterface = top()->GetScriptInterface(); | ||||
▲ Show 20 Lines • Show All 148 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
;;