forked from mirrors/0ad
Rename PushGuiPage to OpenChildPage
There is no `PopGuiPage` anymore. For symmetry there should also be no `PushGuiPage`.
This commit is contained in:
@@ -113,10 +113,10 @@ void CGUIManager::SwitchPage(const CStrW& pageName, const ScriptInterface* srcSc
|
||||
m_PageStack.clear();
|
||||
}
|
||||
|
||||
PushPage(pageName, initDataClone);
|
||||
OpenChildPage(pageName, initDataClone);
|
||||
}
|
||||
|
||||
JS::Value CGUIManager::PushPage(const CStrW& pageName, Script::StructuredClone initData)
|
||||
JS::Value CGUIManager::OpenChildPage(const CStrW& pageName, Script::StructuredClone initData)
|
||||
{
|
||||
// Store the callback handler in the current GUI page before opening the new one
|
||||
JS::RootedValue promise{m_ScriptInterface.GetGeneralJSContext(), [&]
|
||||
@@ -130,8 +130,8 @@ JS::Value CGUIManager::PushPage(const CStrW& pageName, Script::StructuredClone i
|
||||
return m_PageStack.back().ReplacePromise(*currentPage.GetScriptInterface());
|
||||
}()};
|
||||
|
||||
// Push the page prior to loading its contents, because that may push
|
||||
// another GUI page on init which should be pushed on top of this new page.
|
||||
// Emplace the page prior to loading its contents, because that may open
|
||||
// another GUI page on init which should be emplaced on top of this new page.
|
||||
m_PageStack.emplace_back(pageName, initData);
|
||||
m_PageStack.back().LoadPage(m_ScriptContext);
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
* user inputs.
|
||||
* The returned promise will be fulfilled once the pushed page is closed.
|
||||
*/
|
||||
JS::Value PushPage(const CStrW& pageName, Script::StructuredClone initData);
|
||||
JS::Value OpenChildPage(const CStrW& pageName, Script::StructuredClone initData);
|
||||
|
||||
/**
|
||||
* Called when a file has been modified, to hotload changes.
|
||||
|
||||
@@ -33,9 +33,9 @@ namespace JSI_GUIManager
|
||||
// Note that the initData argument may only contain clonable data.
|
||||
// Functions aren't supported for example!
|
||||
// It returns a promise.
|
||||
JS::Value PushGuiPage(const ScriptRequest& rq, const std::wstring& name, JS::HandleValue initData)
|
||||
JS::Value OpenChildPage(const ScriptRequest& rq, const std::wstring& name, JS::HandleValue initData)
|
||||
{
|
||||
return g_GUI->PushPage(name, Script::WriteStructuredClone(rq, initData));
|
||||
return g_GUI->OpenChildPage(name, Script::WriteStructuredClone(rq, initData));
|
||||
}
|
||||
|
||||
void SwitchGuiPage(const ScriptInterface& scriptInterface, const std::wstring& name, JS::HandleValue initData)
|
||||
@@ -66,7 +66,7 @@ CParamNode GetTemplate(const std::string& templateName)
|
||||
|
||||
void RegisterScriptFunctions(const ScriptRequest& rq)
|
||||
{
|
||||
ScriptFunction::Register<&PushGuiPage>(rq, "PushGuiPage");
|
||||
ScriptFunction::Register<&OpenChildPage>(rq, "OpenChildPage");
|
||||
ScriptFunction::Register<&SwitchGuiPage>(rq, "SwitchGuiPage");
|
||||
ScriptFunction::Register<&SetCursor>(rq, "SetCursor");
|
||||
ScriptFunction::Register<&ResetCursor>(rq, "ResetCursor");
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
Script::CreateObject(rq, &val);
|
||||
|
||||
Script::StructuredClone data = Script::WriteStructuredClone(rq, JS::NullHandleValue);
|
||||
g_GUI->PushPage(L"event/page_event.xml", data);
|
||||
g_GUI->OpenChildPage(L"event/page_event.xml", data);
|
||||
|
||||
const ScriptInterface& pageScriptInterface = *(g_GUI->GetActiveGUI()->GetScriptInterface());
|
||||
ScriptRequest prq(pageScriptInterface);
|
||||
@@ -146,7 +146,7 @@ public:
|
||||
Script::CreateObject(rq, &val);
|
||||
|
||||
Script::StructuredClone data = Script::WriteStructuredClone(rq, JS::NullHandleValue);
|
||||
g_GUI->PushPage(L"hotkey/page_hotkey.xml", data);
|
||||
g_GUI->OpenChildPage(L"hotkey/page_hotkey.xml", data);
|
||||
|
||||
// Press 'a'.
|
||||
SDL_Event_ hotkeyNotification;
|
||||
@@ -228,11 +228,11 @@ public:
|
||||
Script::WriteStructuredClone(rq, JS::UndefinedHandleValue)};
|
||||
|
||||
TS_ASSERT_EQUALS(g_GUI->GetPageCount(), 0);
|
||||
g_GUI->PushPage(L"regainFocus/page_emptyPage.xml", undefined);
|
||||
g_GUI->OpenChildPage(L"regainFocus/page_emptyPage.xml", undefined);
|
||||
TS_ASSERT_EQUALS(g_GUI->GetPageCount(), 1);
|
||||
|
||||
// This page instantly pushes an empty page with a callback that pops another page again.
|
||||
g_GUI->PushPage(L"regainFocus/page_pushWithPopOnInit.xml", undefined);
|
||||
g_GUI->OpenChildPage(L"regainFocus/page_pushWithPopOnInit.xml", undefined);
|
||||
TS_ASSERT_EQUALS(g_GUI->GetPageCount(), 3);
|
||||
|
||||
// Pop the empty page and execute the continuation.
|
||||
@@ -254,7 +254,7 @@ public:
|
||||
|
||||
const Script::StructuredClone undefined{
|
||||
Script::WriteStructuredClone(rq, JS::UndefinedHandleValue)};
|
||||
g_GUI->PushPage(L"regainFocus/page_emptyPage.xml", undefined);
|
||||
g_GUI->OpenChildPage(L"regainFocus/page_emptyPage.xml", undefined);
|
||||
|
||||
|
||||
for (const auto& [reject, result] : testSteps)
|
||||
@@ -263,7 +263,7 @@ public:
|
||||
const Script::StructuredClone clonedValue{Script::WriteStructuredClone(rq, value)};
|
||||
|
||||
const JS::RootedValue promise{rq.cx,
|
||||
g_GUI->PushPage(L"resolveReject/page_resolveReject.xml", clonedValue)};
|
||||
g_GUI->OpenChildPage(L"resolveReject/page_resolveReject.xml", clonedValue)};
|
||||
|
||||
// Check whether promises are settled in the page stack and flush the stack.
|
||||
g_GUI->TickObjects();
|
||||
@@ -277,7 +277,7 @@ public:
|
||||
const ScriptRequest rq{g_GUI->GetScriptInterface()};
|
||||
const Script::StructuredClone undefined{
|
||||
Script::WriteStructuredClone(rq, JS::UndefinedHandleValue)};
|
||||
g_GUI->PushPage(L"sequential/page_sequential.xml", undefined);
|
||||
g_GUI->OpenChildPage(L"sequential/page_sequential.xml", undefined);
|
||||
TS_ASSERT_EQUALS(g_GUI->GetPageCount(), 2);
|
||||
CloseTopmostPage();
|
||||
TS_ASSERT_EQUALS(g_GUI->GetPageCount(), 2);
|
||||
|
||||
Reference in New Issue
Block a user