Index: ps/trunk/binaries/data/mods/public/gui/reference/civinfo/CivInfoPage.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/reference/civinfo/CivInfoPage.js (revision 27426) +++ ps/trunk/binaries/data/mods/public/gui/reference/civinfo/CivInfoPage.js (revision 27427) @@ -1,116 +1,113 @@ class CivInfoPage extends ReferencePage { constructor(data) { super(); this.civSelection = new CivSelectDropdown(this.civData); this.civSelection.registerHandler(this.selectCiv.bind(this)); this.gameplaySection = new GameplaySection(this); this.historySection = new HistorySection(this); let structreeButton = new StructreeButton(this); let closeButton = new CloseButton(this); Engine.SetGlobalHotkey("civinfo", "Press", this.closePage.bind(this)); } switchToStructreePage() { Engine.PopGuiPage({ "civ": this.activeCiv, "nextPage": "page_structree.xml" }); } closePage() { Engine.PopGuiPage({ "civ": this.activeCiv, "page": "page_civinfo.xml" }); } /** * Updates the GUI after the user selected a civ from dropdown. * * @param code {string} */ selectCiv(civCode) { this.setActiveCiv(civCode); let civInfo = this.civData[civCode]; if(!civInfo) error(sprintf("Error loading civ data for \"%(code)s\"", { "code": civCode })); - // Update civ gameplay display this.gameplaySection.update(this.activeCiv, civInfo); - - // Update civ history display this.historySection.update(civInfo); } /** * Give the first character a larger font. */ bigFirstLetter(text, size) { return setStringTags(text[0], { "font": "sans-bold-" + (size + 6) }) + text.substring(1); } /** * Set heading font - bold and mixed caps * * @param text {string} * @param size {number} - Font size * @returns {string} */ formatHeading(text, size) { let textArray = []; for (let word of text.split(" ")) { let wordCaps = word.toUpperCase(); // Usually we wish a big first letter, however this isn't always desirable. Check if // `.toLowerCase()` changes the character to avoid false positives from special characters. if (word.length && word[0].toLowerCase() != word[0]) word = this.bigFirstLetter(wordCaps, size); textArray.push(setStringTags(word, { "font": "sans-bold-" + size })); } return textArray.join(" "); } /** * @returns {string} */ formatEntry(name, tooltip, description) { let tooltip_icon = ""; if (tooltip) tooltip_icon = '[icon="iconInfo" tooltip="' + escapeQuotation(tooltip) + '" tooltip_style="civInfoTooltip"]'; let description_text = ""; if (description) // Translation: Description of an item in the CivInfo page, on a new line and indented. description_text = sprintf(translate('\n %(description)s'), { "description": description, }); return sprintf( // Translation: An entry in the CivInfo Page. The newline and indentation of the description is handled elsewhere. // Example: // > • Name of a Special Something (i) // > A brief description of the aforementioned something. translate("• %(name)s %(info_icon)s%(description)s"), { "name": setStringTags(name, { "font": "sans-bold-14" }), "info_icon": tooltip_icon, "description": description_text, } ); } } CivInfoPage.prototype.CloseButtonTooltip = translate("%(hotkey)s: Close Civilization Overview."); CivInfoPage.prototype.SectionHeaderSize = 16; CivInfoPage.prototype.SubsectionHeaderSize = 12; Index: ps/trunk/binaries/data/mods/public/gui/reference/civinfo/Sections/HistorySection.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/reference/civinfo/Sections/HistorySection.js (revision 27426) +++ ps/trunk/binaries/data/mods/public/gui/reference/civinfo/Sections/HistorySection.js (revision 27427) @@ -1,23 +1,30 @@ class HistorySection { constructor(page) { this.page = page; this.CivHistoryHeading = Engine.GetGUIObjectByName('civHistoryHeading'); this.CivHistoryText = Engine.GetGUIObjectByName('civHistoryText'); } update(civInfo) { + if (!civInfo.History) + { + this.CivHistoryHeading.caption = ""; + this.CivHistoryText.caption = ""; + return; + } + this.CivHistoryHeading.caption = this.page.formatHeading( sprintf(this.headingCaption, { "civilization": civInfo.Name }), this.page.SectionHeaderSize ); this.CivHistoryText.caption = civInfo.History; } } HistorySection.prototype.headingCaption = translate("History of the %(civilization)s"); Index: ps/trunk/binaries/data/mods/public/gui/reference/structree/StructreePage.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/reference/structree/StructreePage.js (revision 27426) +++ ps/trunk/binaries/data/mods/public/gui/reference/structree/StructreePage.js (revision 27427) @@ -1,92 +1,92 @@ /** * This class represents the Structure Tree GUI page. * * Further methods are described within draw.js */ class StructreePage extends ReferencePage { constructor(data) { super(); this.structureBoxes = []; this.trainerBoxes = []; this.StructreePage = Engine.GetGUIObjectByName("structreePage"); this.Background = Engine.GetGUIObjectByName("background"); this.CivEmblem = Engine.GetGUIObjectByName("civEmblem"); this.CivName = Engine.GetGUIObjectByName("civName"); this.CivHistory = Engine.GetGUIObjectByName("civHistory"); this.TrainerSection = new TrainerSection(this); this.TreeSection = new TreeSection(this); this.civSelection = new CivSelectDropdown(this.civData); if (!this.civSelection.hasCivs()) { this.closePage(); return; } this.civSelection.registerHandler(this.selectCiv.bind(this)); let civInfoButton = new CivInfoButton(this); let closeButton = new CloseButton(this); Engine.SetGlobalHotkey("structree", "Press", this.closePage.bind(this)); this.StructreePage.onWindowResized = this.updatePageWidth.bind(this); this.width = 0; } closePage() { Engine.PopGuiPage({ "civ": this.activeCiv, "page": "page_structree.xml" }); } selectCiv(civCode) { this.setActiveCiv(civCode); this.CivEmblem.sprite = "stretched:" + this.civData[this.activeCiv].Emblem; this.CivName.caption = this.civData[this.activeCiv].Name; - this.CivHistory.caption = this.civData[this.activeCiv].History; + this.CivHistory.caption = this.civData[this.activeCiv].History || ""; let templateLists = this.TemplateLister.getTemplateLists(this.activeCiv); this.TreeSection.draw(templateLists.structures, this.activeCiv); this.TrainerSection.draw(templateLists.units, this.activeCiv); this.width = this.TreeSection.width + -this.TreeSection.rightMargin; if (this.TrainerSection.isVisible()) this.width += this.TrainerSection.width + this.SectionGap; this.updatePageWidth(); this.updatePageHeight(); } updatePageHeight() { let y = (this.TreeSection.height + this.TreeSection.vMargin) / 2; let pageSize = this.StructreePage.size; pageSize.top = -y; pageSize.bottom = y; this.StructreePage.size = pageSize; } updatePageWidth() { let screenSize = this.Background.getComputedSize(); let pageSize = this.StructreePage.size; let x = Math.min(this.width, screenSize.right - this.BorderMargin * 2) / 2; pageSize.left = -x; pageSize.right = x; this.StructreePage.size = pageSize; } } StructreePage.prototype.CloseButtonTooltip = translate("%(hotkey)s: Close Structure Tree."); // Gap between the `TreeSection` and `TrainerSection` gui objects (when the latter is visible) StructreePage.prototype.SectionGap = 12; // Margin around the edge of the structree on lower resolutions, // preventing the UI from being clipped by the edges of the screen. StructreePage.prototype.BorderMargin = 16;