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
@@ -4,16 +4,29 @@
const g_CivData = loadCivData(true, false);
/**
+ * Callback function name on closing gui via Engine.PopGuiPage().
+ */
+var g_Callback = "";
+
+var g_SelectedCiv = "";
+
+/**
* 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;
+
+ Engine.GetGUIObjectByName("structreeButton").tooltip = colorizeHotkey(translate("%(hotkey)s: Switch to Structure Tree."), "structree");
+ Engine.GetGUIObjectByName("close").tooltip = colorizeHotkey(translate("%(hotkey)s: Close History."), "cancel");
}
/**
@@ -79,6 +92,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,6 +115,8 @@
{
var civInfo = g_CivData[code];
+ g_SelectedCiv = code;
+
if(!civInfo)
error(sprintf("Error loading civ data for \"%(code)s\"", { "code": code }));
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,12 @@
+
+
@@ -108,17 +114,29 @@
+
+
+
+
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,14 @@
const g_CivData = loadCivData(false, false);
/**
+ * Store civilization code and page (structree or history) opened in civilization info.
+ */
+var g_CivInfo = {
+ "code": "",
+ "page": "page_civinfo.xml"
+};
+
+/**
* Highlight the "random" dropdownlist item.
*/
var g_ColorRandom = "orange";
@@ -1103,6 +1111,12 @@
supplementDefaults();
setTimeout(displayGamestateNotifications, 1000);
+
+ Engine.GetGUIObjectByName("civInfoButton").tooltip = sprintf(
+ translate("%(hotkey_civinfo)s / %(hotkey_structree)s: View History / Structure Tree\nLast opened will be reopened on click."), {
+ "hotkey_civinfo": colorizeHotkey("%(hotkey)s", "civinfo"),
+ "hotkey_structree": colorizeHotkey("%(hotkey)s", "structree")
+ });
}
function initDefaults()
@@ -2670,3 +2684,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 @@
+
+
+
+
+
+
+ History
+ switchToCivInfoPage();
+
Close
- closePage();
+
+ close();
+
-
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.
*/
@@ -1108,12 +1116,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
@@ -644,9 +644,13 @@
if (isPlayer)
{
civIcon.sprite = "stretched:" + g_CivData[g_Players[g_ViewedPlayer].civ].Emblem;
- Engine.GetGUIObjectByName("civIconOverlay").tooltip = sprintf(translate("%(civ)s - Structure Tree"), {
- "civ": g_CivData[g_Players[g_ViewedPlayer].civ].Name
- });
+ Engine.GetGUIObjectByName("civIconOverlay").tooltip =
+ sprintf(
+ translate("%(civ)s\n%(hotkey_civinfo)s / %(hotkey_structree)s: View History / Structure Tree\nLast opened will be reopened on click."), {
+ "civ": setStringTags(g_CivData[g_Players[g_ViewedPlayer].civ].Name, { "font": "sans-bold-stroke-14"}),
+ "hotkey_civinfo": colorizeHotkey("%(hotkey)s", "civinfo"),
+ "hotkey_structree": colorizeHotkey("%(hotkey)s", "structree")
+ });
}
Engine.GetGUIObjectByName("optionFollowPlayer").hidden = !g_IsObserver || !isPlayer;