Index: binaries/data/config/default.cfg
===================================================================
--- binaries/data/config/default.cfg
+++ binaries/data/config/default.cfg
@@ -154,6 +154,8 @@
; > DIALOG HOTKEYS
summary = "Ctrl+Tab" ; Toggle in-game summary
lobby = "Alt+L" ; Show the multiplayer lobby in a dialog window.
+structree = "Alt+Shift+S" ; Show structure tree
+civinfo = "Alt+Shift+H" ; Show civilization info
; > CLIPBOARD CONTROLS
copy = "Ctrl+C" ; Copy to clipboard
Index: binaries/data/mods/public/gui/civinfo/civinfo.js
===================================================================
--- binaries/data/mods/public/gui/civinfo/civinfo.js
+++ binaries/data/mods/public/gui/civinfo/civinfo.js
@@ -3,17 +3,25 @@
*/
const g_CivData = loadCivData(true, false);
+/*
+ * Callback function on closing gui via Engine.PopGuiPage().
+ */
+var g_Callback = "";
+
/**
* Initialize the dropdown containing all the available civs.
*/
-function init(settings)
+function init(data = {})
{
+ if (data.callback)
+ g_Callback = data.callback;
+
var civList = Object.keys(g_CivData).map(civ => ({ "name": g_CivData[civ].Name, "code": civ })).sort(sortNameIgnoreCase);
var civSelection = Engine.GetGUIObjectByName("civSelection");
civSelection.list = civList.map(civ => civ.name);
civSelection.list_data = civList.map(civ => civ.code);
- civSelection.selected = 0;
+ civSelection.selected = data.civ ? civSelection.list_data.indexOf(data.civ) : 0;
}
/**
@@ -79,6 +87,20 @@
return coloredText(string + "\n", "white");
}
+function switchToStrucTreePage()
+{
+ Engine.PopGuiPage();
+ Engine.PushGuiPage("page_structree.xml", { "civ": g_SelectedCiv, "callback": g_Callback });
+}
+
+function close()
+{
+ if (g_Callback)
+ Engine.PopGuiPageCB({ "civ": g_SelectedCiv, "page": "page_civinfo.xml" });
+ else
+ Engine.PopGuiPage();
+}
+
/**
* Updates the GUI after the user selected a civ from dropdown.
*
@@ -88,7 +110,9 @@
{
var civInfo = g_CivData[code];
- if(!civInfo)
+ g_SelectedCiv = code;
+
+ if (!civInfo)
error(sprintf("Error loading civ data for \"%(code)s\"", { "code": code }));
// Update civ gameplay display
Index: binaries/data/mods/public/gui/civinfo/civinfo.xml
===================================================================
--- binaries/data/mods/public/gui/civinfo/civinfo.xml
+++ binaries/data/mods/public/gui/civinfo/civinfo.xml
@@ -5,6 +5,18 @@
+
+
+
+
@@ -116,12 +128,19 @@
>
Close
-
+ close();
+
+
Index: binaries/data/mods/public/gui/gamesetup/gamesetup.js
===================================================================
--- binaries/data/mods/public/gui/gamesetup/gamesetup.js
+++ binaries/data/mods/public/gui/gamesetup/gamesetup.js
@@ -18,6 +18,15 @@
const g_CivData = loadCivData(false, false);
/**
+ * Store civilization code and page (structree or history) opened in civilization info.
+ * So the same civ and page is opened again, when clicking on the button again.
+ */
+var g_CivInfo = {
+ "code": "",
+ "page": "page_civinfo.xml"
+};
+
+/**
* Highlight the "random" dropdownlist item.
*/
var g_ColorRandom = "orange";
@@ -2680,3 +2689,9 @@
g_Autocomplete = Object.keys(autocomplete).sort().reverse().reduce((all, priority) => all.concat(autocomplete[priority]), []);
}
+
+function storeCivInfoPage(data)
+{
+ g_CivInfo.code = data.civ;
+ g_CivInfo.page = data.page;
+}
Index: binaries/data/mods/public/gui/gamesetup/gamesetup.xml
===================================================================
--- binaries/data/mods/public/gui/gamesetup/gamesetup.xml
+++ binaries/data/mods/public/gui/gamesetup/gamesetup.xml
@@ -5,6 +5,18 @@
+
+
+
+
-
+
Close
- closePage();
+
+ close();
+
+
+
+
+
+ History
+ switchToCivInfoPage();
Index: binaries/data/mods/public/gui/session/hotkeys/misc.xml
===================================================================
--- binaries/data/mods/public/gui/session/hotkeys/misc.xml
+++ binaries/data/mods/public/gui/session/hotkeys/misc.xml
@@ -36,6 +36,18 @@
openGameSummary();
+
+
+ Engine.PushGuiPage("page_civinfo.xml", { "civ": g_CivInfo.code, "callback": "storeCivInfoPage" });
+
+
+
+
+
+ Engine.PushGuiPage("page_structree.xml", { "civ": g_CivInfo.code, "callback": "storeCivInfoPage" });
+
+
+
toggleConfigBool("silhouettes");
Index: binaries/data/mods/public/gui/session/menu.js
===================================================================
--- binaries/data/mods/public/gui/session/menu.js
+++ binaries/data/mods/public/gui/session/menu.js
@@ -26,6 +26,14 @@
var g_IdleTraderTextColor = "orange";
/**
+ * Store civilization code and page (structree or history) opened in civilization info.
+ */
+var g_CivInfo = {
+ "code": "",
+ "page": "page_structree.xml"
+};
+
+/**
* The barter constants should match with the simulation
* Quantity of goods to sell per click.
*/
@@ -1111,12 +1119,20 @@
pauseGame();
// TODO add info about researched techs and unlocked entities
- Engine.PushGuiPage("page_structree.xml", {
- "civ": g_Players[g_ViewedPlayer].civ,
- "callback": "resumeGame",
+
+ Engine.PushGuiPage(g_CivInfo.page, {
+ "civ": g_CivInfo.code || g_Players[g_ViewedPlayer].civ,
+ "callback": "storeCivInfoPage"
});
}
+function storeCivInfoPage(data)
+{
+ g_CivInfo.code = data.civ;
+ g_CivInfo.page = data.page;
+ resumeGame();
+}
+
/**
* Pause or resume the game.
*
Index: binaries/data/mods/public/gui/session/session.js
===================================================================
--- binaries/data/mods/public/gui/session/session.js
+++ binaries/data/mods/public/gui/session/session.js
@@ -571,7 +571,7 @@
if (isPlayer)
{
civIcon.sprite = "stretched:" + g_CivData[g_Players[g_ViewedPlayer].civ].Emblem;
- Engine.GetGUIObjectByName("civIconOverlay").tooltip = sprintf(translate("%(civ)s - Structure Tree"), {
+ Engine.GetGUIObjectByName("civIconOverlay").tooltip = sprintf(translate("%(civ)s - Structure Tree / Civilization Info"), {
"civ": g_CivData[g_Players[g_ViewedPlayer].civ].Name
});
}