Index: binaries/data/mods/public/gui/page_structree.xml
===================================================================
--- binaries/data/mods/public/gui/page_structree.xml
+++ binaries/data/mods/public/gui/page_structree.xml
@@ -4,6 +4,7 @@
common/modern/styles.xml
common/modern/sprites.xml
+ common/setup.xml
common/setup_resources.xml
common/sprites.xml
common/styles.xml
Index: binaries/data/mods/public/gui/pregame/mainmenu.xml
===================================================================
--- binaries/data/mods/public/gui/pregame/mainmenu.xml
+++ binaries/data/mods/public/gui/pregame/mainmenu.xml
@@ -167,7 +167,7 @@
size="0 64 100% 92"
tooltip_style="pgToolTip"
>
- Structure Tree
+ Civilizations
View the structure tree of civilizations featured in 0 A.D.
closeMenu();
@@ -176,24 +176,6 @@
]]>
-
-
-
-
@@ -457,7 +439,7 @@
Learn how to play, start the tutorial, discover the technology trees, and the history behind the civilizations
closeMenu();
- openMenu("submenuLearn", (this.parent.size.top+this.size.top), (this.size.bottom-this.size.top), 4);
+ openMenu("submenuLearn", (this.parent.size.top+this.size.top), (this.size.bottom-this.size.top), 3);
Index: binaries/data/mods/public/gui/reference/common/setup.xml
===================================================================
--- binaries/data/mods/public/gui/reference/common/setup.xml
+++ binaries/data/mods/public/gui/reference/common/setup.xml
@@ -10,4 +10,14 @@
sprite="bkTooltip"
textcolor="white"
/>
+
Index: binaries/data/mods/public/gui/reference/common/sprites.xml
===================================================================
--- binaries/data/mods/public/gui/reference/common/sprites.xml
+++ binaries/data/mods/public/gui/reference/common/sprites.xml
@@ -15,4 +15,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
Index: binaries/data/mods/public/gui/reference/structree/structree.js
===================================================================
--- binaries/data/mods/public/gui/reference/structree/structree.js
+++ binaries/data/mods/public/gui/reference/structree/structree.js
@@ -40,12 +40,32 @@
civSelection.list = civList.map(c => c.name);
civSelection.list_data = civList.map(c => c.code);
civSelection.selected = data.civ ? civSelection.list_data.indexOf(data.civ) : 0;
+
+ let pageSelection = Engine.GetGUIObjectByName("pageSelection");
+ pageSelection.list = ["Structure Tree", "History"];
+ pageSelection.selected = 0;
+}
+
+function pageSelection(i)
+{
+ Engine.GetGUIObjectByName("structTreePage").hidden = i == 1;
+ Engine.GetGUIObjectByName("civHistoryPage").hidden = i == 0 ;
+ selectCiv();
+}
+
+function selectCiv()
+{
+ let civCode = Engine.GetGUIObjectByName("civSelection").list_data[Engine.GetGUIObjectByName("civSelection").selected]
+ if (!Engine.GetGUIObjectByName("structTreePage").hidden)
+ selectStructTreeCiv(civCode);
+ else
+ selectCivHistory(civCode);
}
/**
* @param {string} civCode
*/
-function selectCiv(civCode)
+function selectStructTreeCiv(civCode)
{
if (civCode === g_SelectedCiv || !g_CivData[civCode])
return;
@@ -182,3 +202,115 @@
draw();
drawPhaseIcons();
}
+
+/**
+ * Give the first character a larger font.
+ */
+function bigFirstLetter(str, size)
+{
+ return '[font="sans-bold-'+(size+6)+'"]' + str[0] + '[/font]' + '[font="sans-bold-'+size+'"]' + str.substring(1) + '[/font]';
+}
+
+/**
+ * Set heading font - bold and mixed caps
+ *
+ * @param string {string}
+ * @param size {number} - Font size
+ * @returns {string}
+ */
+function heading(string, size)
+{
+ var textArray = string.split(" ");
+
+ for (let i in textArray)
+ {
+ var word = textArray[i];
+ var wordCaps = word.toUpperCase();
+
+ // Check if word is capitalized, if so assume it needs a big first letter
+ // Check if toLowerCase changes the character to avoid false positives from special signs
+ if (word.length && word[0].toLowerCase() != word[0])
+ textArray[i] = bigFirstLetter(wordCaps, size);
+ else
+ textArray[i] = '[font="sans-bold-'+size+'"]' + wordCaps + '[/font]'; // TODO: Would not be necessary if we could do nested tags
+ }
+
+ return textArray.join(" ");
+}
+
+/**
+ * Prepends a backslash to all quotation marks.
+ * @param str {string}
+ * @returns {string}
+ */
+function escapeQuotation(str)
+{
+ return str.replace(/"/g, "\\\"");
+}
+
+/**
+ * Returns a styled concatenation of Name, History and Description of the given object.
+ *
+ * @param obj {Object}
+ * @returns {string}
+ */
+function subHeading(obj)
+{
+ if (!obj.Name)
+ return "";
+ let string = '[color="white"][font="sans-bold-14"]' + obj.Name + '[/font] ';
+ if (obj.History)
+ string += '[icon="iconInfo" tooltip="' + escapeQuotation(obj.History) + '" tooltip_style="civInfoTooltip"]';
+ if (obj.Description)
+ string += '\n ' + obj.Description;
+ string += '\n[/color]';
+ return string;
+}
+
+/**
+ * Updates the GUI after the user selected a civ from dropdown.
+ *
+ * @param code {string}
+ */
+function selectCivHistory(code)
+{
+ var civInfo = g_CivData[code];
+
+ if(!civInfo)
+ error(sprintf("Error loading civ data for \"%(code)s\"", { "code": code }));
+
+ // Bonuses
+ var bonusCaption = heading(translatePlural("Civilization Bonus", "Civilization Bonuses", civInfo.CivBonuses.length), 12) + '\n';
+ for (let bonus of civInfo.CivBonuses)
+ bonusCaption += subHeading(bonus);
+
+ // Team Bonuses
+ bonusCaption += heading(translatePlural("Team Bonus", "Team Bonuses", civInfo.TeamBonuses.length), 12) + '\n';
+ for (let bonus of civInfo.TeamBonuses)
+ bonusCaption += subHeading(bonus);
+
+ Engine.GetGUIObjectByName("civBonuses").caption = bonusCaption;
+
+ // Special techs
+ var techCaption = heading(translate("Special Technologies"), 12) + '\n';
+ for (let faction of civInfo.Factions)
+ for (let technology of faction.Technologies)
+ techCaption += subHeading(technology);
+
+ // Special buildings
+ techCaption += heading(translatePlural("Special Building", "Special Buildings", civInfo.Structures.length), 12) + '\n';
+ for (let structure of civInfo.Structures)
+ techCaption += subHeading(structure);
+
+ Engine.GetGUIObjectByName("civTechs").caption = techCaption;
+
+ // Heroes
+ var heroCaption = heading(translate("Heroes"), 12) + '\n';
+ for (let faction of civInfo.Factions)
+ {
+ for (let hero of faction.Heroes)
+ heroCaption += subHeading(hero);
+ heroCaption += '\n';
+ }
+ Engine.GetGUIObjectByName("civHeroes").caption = heroCaption;
+}
Index: binaries/data/mods/public/gui/reference/structree/structree.xml
===================================================================
--- binaries/data/mods/public/gui/reference/structree/structree.xml
+++ binaries/data/mods/public/gui/reference/structree/structree.xml
@@ -13,7 +13,7 @@
+
+
+
+
+ pageSelection(this.selected);
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+ Trainer Units
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
- Trainer Units
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+