Index: binaries/data/mods/public/gui/common/tooltips.js =================================================================== --- binaries/data/mods/public/gui/common/tooltips.js +++ binaries/data/mods/public/gui/common/tooltips.js @@ -488,6 +488,23 @@ } /** + * Returns the resources this entity supplies in the specified entity's tooltip + */ +function getResourceSupplyTooltip(template) +{ + if (!template.supply) + return ""; + + let supply = template.supply; + let type = (supply.type[0] === "treasure") ? supply.type[1] : supply.type[0]; + + let txt = g_TooltipTextFormats.header[0] + translate("Resource Supply:") + g_TooltipTextFormats.header[1] + " "; + txt += sprintf(translate("%(component)s %(amount)s"), { component: resourceIcon(type), amount: supply.amount }); + + return txt; +} + +/** * Returns the population bonus information to display in the specified entity's construction button tooltip. */ function getPopulationBonusTooltip(template) Index: binaries/data/mods/public/gui/encyclopedia/common/core.js =================================================================== --- binaries/data/mods/public/gui/encyclopedia/common/core.js +++ binaries/data/mods/public/gui/encyclopedia/common/core.js @@ -2,6 +2,21 @@ var g_SelectedCiv = ""; var g_CallbackSet = false; +var g_EntityStatFunctions = [ + getHealthTooltip, + getHealerTooltip, + getAttackTooltip, + getSplashDamageTooltip, + getArmorTooltip, + getGarrisonTooltip, + getProjectilesTooltip, + getSpeedTooltip, + getGatherTooltip, + getResourceSupplyTooltip, + getPopulationBonusTooltip, + getLootTooltip +]; + function init_civs () { g_CivData = loadCivData(true); @@ -175,3 +190,18 @@ return entityLists; } +function setViewerOnPress(ele, entity) +{ + if (typeof ele === "string") + ele = Engine.GetGUIObjectByName(ele); + + ele.onpressright = function () { Engine.PushGuiPage("page_viewer.xml", { + "entity": entity, + "civ": g_SelectedCiv, + }); }; +} + +function unsetViewerOnPress(ele) +{ + ele.onPressRight = function () {}; +} Index: binaries/data/mods/public/gui/encyclopedia/common/draw.js =================================================================== --- binaries/data/mods/public/gui/encyclopedia/common/draw.js +++ binaries/data/mods/public/gui/encyclopedia/common/draw.js @@ -5,19 +5,8 @@ getEntityNamesFormatted, getEntityCostTooltip, getEntityTooltip, - getAurasTooltip, - getHealthTooltip, - getHealerTooltip, - getAttackTooltip, - getSplashDamageTooltip, - getArmorTooltip, - getGarrisonTooltip, - getProjectilesTooltip, - getSpeedTooltip, - getGatherTooltip, - getPopulationBonusTooltip, - getLootTooltip -]; + getAurasTooltip +].concat(g_EntityStatFunctions); /** * Assemble a tooltip text Index: binaries/data/mods/public/gui/encyclopedia/common/load.js =================================================================== --- binaries/data/mods/public/gui/encyclopedia/common/load.js +++ binaries/data/mods/public/gui/encyclopedia/common/load.js @@ -29,7 +29,7 @@ { // We need to clone the template because we want to perform some translations. let data = clone(Engine.GetTemplate(templateName)); - translateObjectKeys(data, ["GenericName", "SpecificName", "Tooltip"]); + translateObjectKeys(data, ["GenericName", "SpecificName", "Tooltip", "History"]); if (data.Auras) for (let auraID of data.Auras._string.split(/\s+/)) @@ -54,7 +54,7 @@ if (!(templateName in g_TechnologyData)) { let data = Engine.ReadJSONFile(g_TechnologyPath + templateName + ".json"); - translateObjectKeys(data, ["genericName", "tooltip"]); + translateObjectKeys(data, ["genericName", "tooltip", "description"]); g_TechnologyData[templateName] = data; } @@ -97,6 +97,8 @@ let template = loadTemplate(templateName); let unit = GetTemplateDataHelper(template, null, g_AuraData, g_ResourceData); + unit.history = template.Identity.History; + if (template.ProductionQueue) { unit.production = {}; @@ -114,6 +116,12 @@ } } + if (template.Identity.Rank) + unit.promotion = { + "current_rank": template.Identity.Rank, + "entity": (template.Promotion) ? template.Promotion.Entity : null + }; + if (template.Builder && template.Builder.Entities._string) { unit.builder = []; @@ -139,6 +147,8 @@ let template = loadTemplate(templateName); let structure = GetTemplateDataHelper(template, null, g_AuraData, g_ResourceData); + structure.history = template.Identity.History; + structure.production = { "technology": [], "units": [] @@ -202,6 +212,21 @@ return structure; } +function loadResource(templateName) +{ + let template = loadTemplate(templateName); + let resource = GetTemplateDataHelper(template); + + resource.history = template.Identity.History; + + resource.supply = { + "type": template.ResourceSupply.Type.split("."), + "amount": template.ResourceSupply.Amount, + }; + + return resource; +} + /** * Load and parse technology from json template. * Index: binaries/data/mods/public/gui/encyclopedia/structree/draw.js =================================================================== --- binaries/data/mods/public/gui/encyclopedia/structree/draw.js +++ binaries/data/mods/public/gui/encyclopedia/structree/draw.js @@ -50,6 +50,7 @@ Engine.GetGUIObjectByName("phase["+i+"]_struct["+s+"]_name").caption = translate(stru.name.specific); + setViewerOnPress("phase["+i+"]_struct["+s+"]_icon", stru); thisEle.hidden = false; for (let r in g_DrawLimits[pha].prodQuant) @@ -150,6 +151,7 @@ trainer = g_ParsedData.units[trainer]; Engine.GetGUIObjectByName("trainer["+t+"]_icon").sprite = "stretched:session/portraits/"+trainer.icon; Engine.GetGUIObjectByName("trainer["+t+"]_icon").tooltip = assembleTooltip(trainer); + setViewerOnPress("trainer["+t+"]_icon", trainer); Engine.GetGUIObjectByName("trainer["+t+"]_name").caption = translate(trainer.name.specific); thisEle.hidden = false; @@ -217,6 +219,7 @@ prodEle.sprite = "stretched:session/portraits/"+prod.icon; prodEle.tooltip = assembleTooltip(prod); prodEle.hidden = false; + setViewerOnPress(prodEle, prod); return true; } Index: binaries/data/mods/public/gui/encyclopedia/viewer/setup.xml =================================================================== --- /dev/null +++ binaries/data/mods/public/gui/encyclopedia/viewer/setup.xml @@ -0,0 +1,5 @@ + + + + + Index: binaries/data/mods/public/gui/encyclopedia/viewer/sprites.xml =================================================================== --- /dev/null +++ binaries/data/mods/public/gui/encyclopedia/viewer/sprites.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: binaries/data/mods/public/gui/encyclopedia/viewer/styles.xml =================================================================== --- /dev/null +++ binaries/data/mods/public/gui/encyclopedia/viewer/styles.xml @@ -0,0 +1,29 @@ + + + +