Index: ps/trunk/binaries/data/mods/public/gui/civinfo/civinfo.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/civinfo/civinfo.js (revision 23670)
+++ ps/trunk/binaries/data/mods/public/gui/civinfo/civinfo.js (revision 23671)
@@ -1,153 +1,153 @@
/**
* Display selectable civs only.
*/
const g_CivData = loadCivData(true, false);
var g_SelectedCiv = "";
/**
* Initialize the dropdown containing all the available civs.
*/
function init(data = {})
{
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 = 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");
+ Engine.GetGUIObjectByName("close").tooltip = colorizeHotkey(translate("%(hotkey)s: Close Civilization Overview."), "cancel");
}
/**
* 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 = '[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;
// Translation: insert an itemization symbol for each entry.
return sprintf(translate("• %(string)s"), { "string": string }) + "\n";
}
function switchToStrucTreePage()
{
Engine.PopGuiPage({ "civ": g_SelectedCiv, "nextPage": "page_structree.xml" });
}
function closePage()
{
Engine.PopGuiPage({ "civ": g_SelectedCiv, "page": "page_civinfo.xml" });
}
/**
* Updates the GUI after the user selected a civ from dropdown.
*
* @param code {string}
*/
function selectCiv(code)
{
var civInfo = g_CivData[code];
g_SelectedCiv = code;
if(!civInfo)
error(sprintf("Error loading civ data for \"%(code)s\"", { "code": code }));
// Update civ gameplay display
Engine.GetGUIObjectByName("civGameplayHeading").caption = heading(sprintf(translate("%(civilization)s Gameplay"), { "civilization": civInfo.Name }), 16);
// 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 technologies
var techCaption = heading(translate("Special Technologies"), 12) + '\n';
for (let faction of civInfo.Factions)
for (let technology of faction.Technologies)
techCaption += subHeading(technology);
// Special structures
techCaption += heading(translatePlural("Special Structure", "Special Structures", 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;
// Update civ history display
Engine.GetGUIObjectByName("civHistoryHeading").caption = heading(sprintf(translate("History of the %(civilization)s"), { "civilization": civInfo.Name }), 16);
Engine.GetGUIObjectByName("civHistoryText").caption = civInfo.History;
}
Index: ps/trunk/binaries/data/mods/public/gui/civinfo/civinfo.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/civinfo/civinfo.xml (revision 23670)
+++ ps/trunk/binaries/data/mods/public/gui/civinfo/civinfo.xml (revision 23671)
@@ -1,141 +1,141 @@
Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/CivInfoButton.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/CivInfoButton.js (revision 23670)
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/CivInfoButton.js (revision 23671)
@@ -1,48 +1,48 @@
class CivInfoButton
{
constructor()
{
this.civInfo = {
"civ": "",
"page": "page_civinfo.xml"
};
let civInfoButton = Engine.GetGUIObjectByName("civInfoButton");
civInfoButton.onPress = this.onPress.bind(this);
civInfoButton.tooltip =
sprintf(translate(this.Tooltip), {
"hotkey_civinfo": colorizeHotkey("%(hotkey)s", "civinfo"),
"hotkey_structree": colorizeHotkey("%(hotkey)s", "structree")
});
Engine.SetGlobalHotkey("structree", this.openPage.bind(this, "page_structree.xml"));
Engine.SetGlobalHotkey("civinfo", this.openPage.bind(this, "page_civinfo.xml"));
}
onPress()
{
this.openPage(this.civInfo.page);
}
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;
}
}
CivInfoButton.prototype.Tooltip =
- translate("%(hotkey_civinfo)s / %(hotkey_structree)s: View History / Structure Tree\nLast opened will be reopened on click.");
+ translate("%(hotkey_civinfo)s / %(hotkey_structree)s: View Civilization Overview / Structure Tree\nLast opened will be reopened on click.");
Index: ps/trunk/binaries/data/mods/public/gui/pregame/MainMenuItems.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/pregame/MainMenuItems.js (revision 23670)
+++ ps/trunk/binaries/data/mods/public/gui/pregame/MainMenuItems.js (revision 23671)
@@ -1,211 +1,211 @@
var g_MainMenuItems = [
{
"caption": translate("Learn To Play"),
"tooltip": translate("Learn how to play, start the tutorial, discover the technology trees, and the history behind the civilizations."),
"submenu": [
{
"caption": translate("Manual"),
"tooltip": translate("Open the 0 A.D. Game Manual."),
"onPress": () => {
Engine.PushGuiPage("page_manual.xml");
}
},
{
"caption": translate("Tutorial"),
"tooltip": translate("Start the economic tutorial."),
"onPress": () => {
Engine.SwitchGuiPage("page_gamesetup.xml", {
"mapType": "scenario",
"map": "maps/tutorials/starting_economy_walkthrough"
});
}
},
{
"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);
},
},
{
- "caption": translate("History"),
+ "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);
}
}
]
},
{
"caption": translate("Single-player"),
"tooltip": translate("Start, load, or replay a single-player game."),
"submenu": [
{
"caption": translate("Matches"),
"tooltip": translate("Start a new single-player game."),
"onPress": () => {
Engine.SwitchGuiPage("page_gamesetup.xml");
}
},
{
"caption": translate("Campaigns"),
"tooltip": translate("Relive history through historical military campaigns. \\[NOT YET IMPLEMENTED]"),
"enabled": false
},
{
"caption": translate("Load Game"),
"tooltip": translate("Load a saved game."),
"onPress": () => {
Engine.PushGuiPage("page_loadgame.xml");
}
},
{
"caption": translate("Replays"),
"tooltip": translate("Playback previous games."),
"onPress": () => {
Engine.SwitchGuiPage("page_replaymenu.xml", {
"replaySelectionData": {
"filters": {
"singleplayer": "Single-player"
}
}
});
}
}
]
},
{
"caption": translate("Multiplayer"),
"tooltip": translate("Fight against one or more human players in a multiplayer game."),
"submenu": [
{
// Translation: Join a game by specifying the host's IP address.
"caption": translate("Join Game"),
"tooltip": translate("Joining an existing multiplayer game."),
"onPress": () => {
Engine.PushGuiPage("page_gamesetup_mp.xml", {
"multiplayerGameType": "join"
});
}
},
{
"caption": translate("Host Game"),
"tooltip": translate("Host a multiplayer game."),
"onPress": () => {
Engine.PushGuiPage("page_gamesetup_mp.xml", {
"multiplayerGameType": "host"
});
}
},
{
"caption": translate("Game Lobby"),
"tooltip":
colorizeHotkey(translate("%(hotkey)s: Launch the multiplayer lobby to join and host publicly visible games and chat with other players."), "lobby") +
(Engine.StartXmppClient ? "" : translate("Launch the multiplayer lobby. \\[DISABLED BY BUILD]")),
"enabled": !!Engine.StartXmppClient,
"hotkey": "lobby",
"onPress": () => {
if (Engine.StartXmppClient)
Engine.PushGuiPage("page_prelobby_entrance.xml");
}
},
{
"caption": translate("Replays"),
"tooltip": translate("Playback previous games."),
"onPress": () => {
Engine.SwitchGuiPage("page_replaymenu.xml", {
"replaySelectionData": {
"filters": {
"singleplayer": "Multiplayer"
}
}
});
}
}
]
},
{
"caption": translate("Settings"),
"tooltip": translate("Change game options."),
"submenu": [
{
"caption": translate("Options"),
"tooltip": translate("Adjust game settings."),
"onPress": () => {
Engine.PushGuiPage(
"page_options.xml",
{},
fireConfigChangeHandlers);
}
},
{
"caption": translate("Language"),
"tooltip": translate("Choose the language of the game."),
"onPress": () => {
Engine.PushGuiPage("page_locale.xml");
}
},
{
"caption": translate("Mod Selection"),
"tooltip": translate("Select and download mods for the game."),
"onPress": () => {
Engine.SwitchGuiPage("page_modmod.xml");
}
},
{
"caption": translate("Welcome Screen"),
"tooltip": translate("Show the Welcome Screen again. Useful if you hid it by mistake."),
"onPress": () => {
Engine.PushGuiPage("page_splashscreen.xml");
}
}
]
},
{
"caption": translate("Scenario Editor"),
"tooltip": translate('Open the Atlas Scenario Editor in a new window. You can run this more reliably by starting the game with the command-line argument "-editor".'),
"onPress": () => {
if (Engine.AtlasIsAvailable())
messageBox(
400, 200,
translate("Are you sure you want to quit 0 A.D. and open the Scenario Editor?"),
translate("Confirmation"),
[translate("No"), translate("Yes")],
[null, Engine.RestartInAtlas]);
else
messageBox(
400, 200,
translate("The scenario editor is not available or failed to load. See the game logs for additional information."),
translate("Error"));
}
},
{
"caption": translate("Credits"),
"tooltip": translate("Show the 0 A.D. credits."),
"onPress": () => {
Engine.PushGuiPage("page_credits.xml");
}
},
{
"caption": translate("Exit"),
"tooltip": translate("Exit the game."),
"onPress": () => {
messageBox(
400, 200,
translate("Are you sure you want to quit 0 A.D.?"),
translate("Confirmation"),
[translate("No"), translate("Yes")],
[null, Engine.Exit]);
}
}
];
Index: ps/trunk/binaries/data/mods/public/gui/reference/structree/structree.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/reference/structree/structree.js (revision 23670)
+++ ps/trunk/binaries/data/mods/public/gui/reference/structree/structree.js (revision 23671)
@@ -1,194 +1,194 @@
/**
* Array of structure template names when given a civ and a phase name.
*/
var g_BuildList = {};
/**
* Array of template names that can be trained from a unit, given a civ and unit template name.
*/
var g_TrainList = {};
/**
* Initialize the page
*
* @param {object} data - Parameters passed from the code that calls this page into existence.
*/
function init(data = {})
{
let civList = Object.keys(g_CivData).map(civ => ({
"name": g_CivData[civ].Name,
"code": civ,
})).sort(sortNameIgnoreCase);
if (!civList.length)
{
closePage();
return;
}
g_ParsedData = {
"units": {},
"structures": {},
"techs": {},
"phases": {}
};
let civSelection = Engine.GetGUIObjectByName("civSelection");
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;
- Engine.GetGUIObjectByName("civinfo").tooltip = colorizeHotkey(translate("%(hotkey)s: Switch to History."), "civinfo");
+ Engine.GetGUIObjectByName("civinfo").tooltip = colorizeHotkey(translate("%(hotkey)s: Switch to Civilization Overview."), "civinfo");
Engine.GetGUIObjectByName("close").tooltip = colorizeHotkey(translate("%(hotkey)s: Close Structure Tree."), "cancel");
}
function switchToCivInfoPage()
{
Engine.PopGuiPage({ "civ": g_SelectedCiv, "nextPage": "page_civinfo.xml" });
}
function closePage()
{
Engine.PopGuiPage({ "civ": g_SelectedCiv, "page": "page_structree.xml" });
}
/**
* @param {string} civCode
*/
function selectCiv(civCode)
{
if (civCode === g_SelectedCiv || !g_CivData[civCode])
return;
g_SelectedCiv = civCode;
g_CurrentModifiers = deriveModifications(g_AutoResearchTechList);
// If a buildList already exists, then this civ has already been parsed
if (g_BuildList[g_SelectedCiv])
{
draw();
drawPhaseIcons();
return;
}
let templateLists = compileTemplateLists(civCode);
for (let u of templateLists.units.keys())
if (!g_ParsedData.units[u])
g_ParsedData.units[u] = loadEntityTemplate(u);
for (let s of templateLists.structures.keys())
if (!g_ParsedData.structures[s])
g_ParsedData.structures[s] = loadEntityTemplate(s);
// Load technologies
g_ParsedData.techs[civCode] = {};
for (let techcode of templateLists.techs.keys())
if (basename(techcode).startsWith("phase"))
g_ParsedData.phases[techcode] = loadPhase(techcode);
else
g_ParsedData.techs[civCode][techcode] = loadTechnology(techcode);
// Establish phase order
g_ParsedData.phaseList = UnravelPhases(g_ParsedData.phases);
// Load any required generic phases that aren't already loaded
for (let phasecode of g_ParsedData.phaseList)
if (!g_ParsedData.phases[phasecode])
g_ParsedData.phases[phasecode] = loadPhase(phasecode);
// Group production and upgrade lists of structures by phase
for (let structCode of templateLists.structures.keys())
{
let structInfo = g_ParsedData.structures[structCode];
structInfo.phase = getPhaseOfTemplate(structInfo);
let structPhaseIdx = g_ParsedData.phaseList.indexOf(structInfo.phase);
// If this structure is shared with another civ,
// it may have already gone through the grouping process already.
if (!Array.isArray(structInfo.production.techs))
continue;
// Sort techs by phase
let newProdTech = {};
for (let prod of structInfo.production.techs)
{
let phase = getPhaseOfTechnology(prod);
if (phase === false)
continue;
if (g_ParsedData.phaseList.indexOf(phase) < structPhaseIdx)
phase = structInfo.phase;
if (!(phase in newProdTech))
newProdTech[phase] = [];
newProdTech[phase].push(prod);
}
// Sort units by phase
let newProdUnits = {};
for (let prod of structInfo.production.units)
{
let phase = getPhaseOfTemplate(g_ParsedData.units[prod]);
if (phase === false)
continue;
if (g_ParsedData.phaseList.indexOf(phase) < structPhaseIdx)
phase = structInfo.phase;
if (!(phase in newProdUnits))
newProdUnits[phase] = [];
newProdUnits[phase].push(prod);
}
g_ParsedData.structures[structCode].production = {
"techs": newProdTech,
"units": newProdUnits
};
// Sort upgrades by phase
let newUpgrades = {};
if (structInfo.upgrades)
for (let upgrade of structInfo.upgrades)
{
let phase = getPhaseOfTemplate(upgrade);
if (g_ParsedData.phaseList.indexOf(phase) < structPhaseIdx)
phase = structInfo.phase;
if (!newUpgrades[phase])
newUpgrades[phase] = [];
newUpgrades[phase].push(upgrade);
}
g_ParsedData.structures[structCode].upgrades = newUpgrades;
}
// Determine the buildList for the civ (grouped by phase)
let buildList = {};
let trainerList = [];
for (let pha of g_ParsedData.phaseList)
buildList[pha] = [];
for (let structCode of templateLists.structures.keys())
{
let phase = g_ParsedData.structures[structCode].phase;
buildList[phase].push(structCode);
}
for (let unitCode of templateLists.units.keys())
{
let unitTemplate = g_ParsedData.units[unitCode];
if (!unitTemplate.production.units.length && !unitTemplate.production.techs.length && !unitTemplate.upgrades)
continue;
trainerList.push(unitCode);
}
g_BuildList[g_SelectedCiv] = buildList;
g_TrainList[g_SelectedCiv] = trainerList;
draw();
drawPhaseIcons();
}
Index: ps/trunk/binaries/data/mods/public/gui/reference/structree/structree.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/reference/structree/structree.xml (revision 23670)
+++ ps/trunk/binaries/data/mods/public/gui/reference/structree/structree.xml (revision 23671)
@@ -1,141 +1,141 @@
closePage();
Structure Tree
Civilization:
selectCiv(this.list_data[this.selected]);
Trainer Units
-
+
- History
+ Civilization Overview
switchToCivInfoPage();
Close
closePage();
Index: ps/trunk/binaries/data/mods/public/gui/session/top_panel/CivIcon.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/session/top_panel/CivIcon.js (revision 23670)
+++ ps/trunk/binaries/data/mods/public/gui/session/top_panel/CivIcon.js (revision 23671)
@@ -1,79 +1,79 @@
/**
- * This displas the emblem of the civilization of the currently viewed player in the top panel.
- * If clicked, it opens the structure tree or history dialog for the last viewed civilization.
+ * This displays the emblem of the civilization of the currently viewed player in the top panel.
+ * If clicked, it opens the Structure Tree or Civilization Overview dialog, for the last viewed civilization.
*/
class CivIcon
{
constructor(playerViewControl)
{
this.dialogSelection = {
"civ": "",
"page": "page_structree.xml"
};
this.civIcon = Engine.GetGUIObjectByName("civIcon");
this.civIconOverlay = Engine.GetGUIObjectByName("civIconOverlay");
this.civIconOverlay.onPress = this.onPress.bind(this);
playerViewControl.registerViewedPlayerChangeHandler(this.rebuild.bind(this));
registerHotkeyChangeHandler(this.rebuild.bind(this));
Engine.SetGlobalHotkey("civinfo", () => this.openPage("page_civinfo.xml"));
Engine.SetGlobalHotkey("structree", () => this.openPage("page_structree.xml"));
}
onPress()
{
this.openPage(this.dialogSelection.page);
}
openPage(page)
{
closeOpenDialogs();
g_PauseControl.implicitPause();
Engine.PushGuiPage(
page,
{
"civ": this.dialogSelection.civ || g_Players[g_ViewedPlayer].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();
}
}
rebuild()
{
let hidden = g_ViewedPlayer <= 0;
this.civIcon.hidden = hidden;
if (hidden)
return;
let civData = g_CivData[g_Players[g_ViewedPlayer].civ];
this.civIcon.sprite = "stretched:" + civData.Emblem;
this.civIconOverlay.tooltip = sprintf(translate(this.Tooltip), {
"civ": setStringTags(civData.Name, this.CivTags),
"hotkey_civinfo": colorizeHotkey("%(hotkey)s", "civinfo"),
"hotkey_structree": colorizeHotkey("%(hotkey)s", "structree")
});
}
}
CivIcon.prototype.Tooltip =
- markForTranslation("%(civ)s\n%(hotkey_civinfo)s / %(hotkey_structree)s: View History / Structure Tree\nLast opened will be reopened on click.");
+ markForTranslation("%(civ)s\n%(hotkey_civinfo)s / %(hotkey_structree)s: View Civilization Overview / Structure Tree\nLast opened will be reopened on click.");
CivIcon.prototype.CivTags = { "font": "sans-bold-stroke-14" };