Page Menu
Home
Wildfire Games
Search
Configure Global Search
Log In
Files
F5232373
D5261.id22936.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
7 KB
Referenced Files
None
Subscribers
None
D5261.id22936.diff
View Options
Index: binaries/data/mods/public/gui/common/functions_utility.js
===================================================================
--- binaries/data/mods/public/gui/common/functions_utility.js
+++ binaries/data/mods/public/gui/common/functions_utility.js
@@ -282,3 +282,25 @@
"revision": Engine.GetBuildRevision()
});
}
+
+/**
+ * Opens a page. If that page completes with an object with a @a nextPage
+ * property that page is opened with the @a args property of that object.
+ * That continues untill there is no @a nextPage property in the completion
+ * value. If there is no @a nextPage in the completion value the
+ * @a continuation is called with the completion value.
+ * @param {String} page - The page first opened.
+ * @param args - passed to the first page opened.
+ * @param continuation {function | undefined} - Completion callback, called when
+ * there is no @a nextPage property in the completion value.
+ */
+function pageLoop(page, args, continuation)
+{
+ (function recursiveFunction(completionValue)
+ {
+ if (completionValue?.nextPage != null)
+ Engine.PushGuiPage(completionValue.nextPage, completionValue.args, recursiveFunction);
+ else
+ continuation?.(completionValue);
+ })({ "nextPage": page, "args": args });
+}
Index: binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/CivInfoButton.js
===================================================================
--- binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/CivInfoButton.js
+++ binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/CivInfoButton.js
@@ -3,7 +3,6 @@
constructor()
{
this.civInfo = {
- "civ": "",
"page": "page_civinfo.xml"
};
@@ -26,21 +25,7 @@
openPage(page)
{
- Engine.PushGuiPage(
- page,
- { "civ": this.civInfo.civ },
- this.storeCivInfoPage.bind(this));
- }
-
- storeCivInfoPage(data)
- {
- if (data.nextPage)
- Engine.PushGuiPage(
- data.nextPage,
- { "civ": data.civ },
- this.storeCivInfoPage.bind(this));
- else
- this.civInfo = data;
+ pageLoop(page, this.civInfo.args, data => this.civInfo = data);
}
}
Index: binaries/data/mods/public/gui/pregame/MainMenuItems.js
===================================================================
--- binaries/data/mods/public/gui/pregame/MainMenuItems.js
+++ binaries/data/mods/public/gui/pregame/MainMenuItems.js
@@ -36,25 +36,13 @@
"caption": translate("Structure Tree"),
"tooltip": colorizeHotkey(translate("%(hotkey)s: View the structure tree of civilizations featured in 0 A.D."), "structree"),
"hotkey": "structree",
- "onPress": () => {
- let callback = data => {
- if (data.nextPage)
- Engine.PushGuiPage(data.nextPage, { "civ": data.civ }, callback);
- };
- Engine.PushGuiPage("page_structree.xml", {}, callback);
- },
+ "onPress": pageLoop.bind(null, "page_structree.xml")
},
{
"caption": translate("Civilization Overview"),
"tooltip": colorizeHotkey(translate("%(hotkey)s: Learn about the civilizations featured in 0 A.D."), "civinfo"),
"hotkey": "civinfo",
- "onPress": () => {
- let callback = data => {
- if (data.nextPage)
- Engine.PushGuiPage(data.nextPage, { "civ": data.civ }, callback);
- };
- Engine.PushGuiPage("page_civinfo.xml", {}, callback);
- }
+ "onPress": pageLoop.bind(null, "page_civinfo.xml")
},
{
"caption": translate("Catafalque Overview"),
Index: binaries/data/mods/public/gui/reference/civinfo/CivInfoPage.js
===================================================================
--- binaries/data/mods/public/gui/reference/civinfo/CivInfoPage.js
+++ binaries/data/mods/public/gui/reference/civinfo/CivInfoPage.js
@@ -17,12 +17,22 @@
switchToStructreePage()
{
- Engine.PopGuiPage({ "civ": this.activeCiv, "nextPage": "page_structree.xml" });
+ Engine.PopGuiPage({
+ "nextPage": "page_structree.xml",
+ "args": {
+ "civ": this.activeCiv
+ }
+ });
}
closePage()
{
- Engine.PopGuiPage({ "civ": this.activeCiv, "page": "page_civinfo.xml" });
+ Engine.PopGuiPage({
+ "page": "page_civinfo.xml",
+ "args": {
+ "civ": this.activeCiv
+ }
+ });
}
/**
Index: binaries/data/mods/public/gui/reference/common/Buttons/CivInfoButton.js
===================================================================
--- binaries/data/mods/public/gui/reference/common/Buttons/CivInfoButton.js
+++ binaries/data/mods/public/gui/reference/common/Buttons/CivInfoButton.js
@@ -12,7 +12,12 @@
onPress()
{
- Engine.PopGuiPage({ "civ": this.parentPage.activeCiv, "nextPage": "page_civinfo.xml" });
+ Engine.PopGuiPage({
+ "nextPage": "page_civinfo.xml",
+ "args": {
+ "civ": this.parentPage.activeCiv
+ }
+ });
}
}
Index: binaries/data/mods/public/gui/reference/common/Buttons/StructreeButton.js
===================================================================
--- binaries/data/mods/public/gui/reference/common/Buttons/StructreeButton.js
+++ binaries/data/mods/public/gui/reference/common/Buttons/StructreeButton.js
@@ -12,7 +12,12 @@
onPress()
{
- Engine.PopGuiPage({ "civ": this.parentPage.activeCiv, "nextPage": "page_structree.xml" });
+ Engine.PopGuiPage({
+ "nextPage": "page_structree.xml",
+ "args": {
+ "civ": this.parentPage.activeCiv
+ }
+ });
}
}
Index: binaries/data/mods/public/gui/reference/structree/StructreePage.js
===================================================================
--- binaries/data/mods/public/gui/reference/structree/StructreePage.js
+++ binaries/data/mods/public/gui/reference/structree/StructreePage.js
@@ -39,7 +39,12 @@
closePage()
{
- Engine.PopGuiPage({ "civ": this.activeCiv, "page": "page_structree.xml" });
+ Engine.PopGuiPage({
+ "page": "page_structree.xml",
+ "args": {
+ "civ": this.activeCiv
+ }
+ });
}
selectCiv(civCode)
Index: binaries/data/mods/public/gui/session/top_panel/CivIcon.js
===================================================================
--- binaries/data/mods/public/gui/session/top_panel/CivIcon.js
+++ binaries/data/mods/public/gui/session/top_panel/CivIcon.js
@@ -7,8 +7,10 @@
constructor(playerViewControl)
{
this.dialogSelection = {
- "civ": "",
- "page": "page_structree.xml"
+ "page": "page_structree.xml",
+ "args": {
+ "civ": undefined
+ }
};
this.civIcon = Engine.GetGUIObjectByName("civIcon");
@@ -32,30 +34,20 @@
closeOpenDialogs();
g_PauseControl.implicitPause();
- Engine.PushGuiPage(
+ pageLoop(
page,
{
// If an Observer triggers `openPage()` via hotkey, g_ViewedPlayer could be -1 or 0
// (depending on whether they're "viewing" no-one or gaia respectively)
- "civ": this.dialogSelection.civ || g_Players[Math.max(g_ViewedPlayer, 1)].civ,
+ "civ": this.dialogSelection.args.civ ?? g_Players[Math.max(g_ViewedPlayer, 1)].civ
// TODO add info about researched techs and unlocked entities
},
- this.storePageSelection.bind(this));
- }
-
- storePageSelection(data)
- {
- if (data.nextPage)
- Engine.PushGuiPage(
- data.nextPage,
- { "civ": data.civ },
- this.storePageSelection.bind(this));
- else
- {
- this.dialogSelection = data;
- resumeGame();
- }
+ data =>
+ {
+ this.dialogSelection = data;
+ resumeGame();
+ });
}
rebuild()
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Sep 28, 1:38 PM (21 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3385305
Default Alt Text
D5261.id22936.diff (7 KB)
Attached To
Mode
D5261: Use pageLoop for structree and civinfo
Attached
Detach File
Event Timeline
Log In to Comment