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 @@ -122,6 +122,22 @@ return bodyFont(template.tooltip); } +function getDescriptionTooltip(template) +{ + if (!template.description) + return ""; + + return bodyFont(template.description); +} + +function getHistoryTooltip(template) +{ + if (!template.history) + return ""; + + return bodyFont(template.history); +} + function getHealthTooltip(template) { if (!template.health) @@ -573,6 +589,26 @@ } /** + * 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: Number.isFinite(+supply.amount) ? supply.amount : translate("∞") + }); + + 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/page_viewer.xml =================================================================== --- /dev/null +++ binaries/data/mods/public/gui/page_viewer.xml @@ -0,0 +1,19 @@ + + + common/modern/setup.xml + common/modern/styles.xml + common/modern/sprites.xml + + common/setup_resources.xml + common/sprites.xml + common/styles.xml + + reference/common/sprites.xml + reference/common/styles.xml + + reference/viewer/styles.xml + reference/viewer/sprites.xml + reference/viewer/viewer.xml + + reference/common/setup.xml + Index: binaries/data/mods/public/gui/reference/common/core.js =================================================================== --- binaries/data/mods/public/gui/reference/common/core.js +++ binaries/data/mods/public/gui/reference/common/core.js @@ -1,4 +1,4 @@ -var g_SelectedCiv = ""; +var g_SelectedCiv = "gaia"; var g_CallbackSet = false; /** @@ -183,3 +183,19 @@ return templateLists; } + +function setViewerOnPress(guiObject, templateName) +{ + if (typeof guiObject === "string") + guiObject = Engine.GetGUIObjectByName(guiObject); + + guiObject.onPressRight = function () { Engine.PushGuiPage("page_viewer.xml", { + "templateName": templateName, + "civ": g_SelectedCiv, + }); }; +} + +function unsetViewerOnPress(guiObject) +{ + guiObject.onPressRight = function () {}; +} Index: binaries/data/mods/public/gui/reference/common/draw.js =================================================================== --- binaries/data/mods/public/gui/reference/common/draw.js +++ binaries/data/mods/public/gui/reference/common/draw.js @@ -6,11 +6,7 @@ /** * These functions are defined in gui/common/tooltips.js */ -var g_TooltipFunctions = [ - getEntityNamesFormatted, - getEntityCostTooltip, - getEntityTooltip, - getAurasTooltip, +var g_EntityStatFunctions = [ getHealthTooltip, getHealerTooltip, getAttackTooltip, @@ -20,10 +16,17 @@ getProjectilesTooltip, getSpeedTooltip, getGatherTooltip, + getResourceSupplyTooltip, getPopulationBonusTooltip, getResourceTrickleTooltip, getLootTooltip ]; +var g_TooltipFunctions = [ + getEntityNamesFormatted, + getEntityCostTooltip, + getEntityTooltip, + getAurasTooltip +].concat(g_EntityStatFunctions); /** * Concatanates the return values of the array of passed functions. Index: binaries/data/mods/public/gui/reference/common/helper.js =================================================================== --- binaries/data/mods/public/gui/reference/common/helper.js +++ binaries/data/mods/public/gui/reference/common/helper.js @@ -24,6 +24,7 @@ upgrade.entity = upgrade.entity.replace("{civ}", g_SelectedCiv); let data = GetTemplateDataHelper(loadTemplate(upgrade.entity), null, g_AuraData, g_ResourceData); + data.name.internal = upgrade.entity; data.cost = upgrade.cost; data.icon = upgrade.icon || data.icon; data.tooltip = upgrade.tooltip || data.tooltip; Index: binaries/data/mods/public/gui/reference/common/load.js =================================================================== --- binaries/data/mods/public/gui/reference/common/load.js +++ binaries/data/mods/public/gui/reference/common/load.js @@ -35,7 +35,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+/)) @@ -60,7 +60,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; } @@ -102,6 +102,9 @@ let template = loadTemplate(templateName); let unit = GetTemplateDataHelper(template, null, g_AuraData, g_ResourceData, g_CurrentModifiers); + unit.name.internal = templateName; + + unit.history = template.Identity.History; if (template.ProductionQueue) { @@ -128,6 +131,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 = []; @@ -142,6 +151,12 @@ if (unit.upgrades) unit.upgrades = getActualUpgradeData(unit.upgrades); + if (template.ResourceSupply) + unit.supply = { + "type": template.ResourceSupply.Type.split("."), + "amount": template.ResourceSupply.Amount, + }; + return unit; } @@ -158,6 +173,9 @@ let template = loadTemplate(templateName); let structure = GetTemplateDataHelper(template, null, g_AuraData, g_ResourceData, g_CurrentModifiers); + structure.name.internal = templateName; + + structure.history = template.Identity.History; structure.production = { "technology": [], @@ -236,9 +254,31 @@ }); } + if (template.ResourceSupply) + structure.supply = { + "type": template.ResourceSupply.Type.split("."), + "amount": template.ResourceSupply.Amount, + }; + return structure; } +function loadResource(templateName) +{ + let template = loadTemplate(templateName); + let resource = GetTemplateDataHelper(template); + resource.name.internal = templateName; + + 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. * @@ -249,6 +289,7 @@ { let template = loadTechData(techName); let tech = GetTechnologyDataHelper(template, g_SelectedCiv, g_ResourceData); + tech.name.internal = "tech/" + techName; if (template.pair !== undefined) { Index: binaries/data/mods/public/gui/reference/structree/draw.js =================================================================== --- binaries/data/mods/public/gui/reference/structree/draw.js +++ binaries/data/mods/public/gui/reference/structree/draw.js @@ -49,6 +49,7 @@ Engine.GetGUIObjectByName("phase["+i+"]_struct["+s+"]_name").caption = translate(stru.name.specific); + setViewerOnPress("phase["+i+"]_struct["+s+"]_icon", stru.name.internal); thisEle.hidden = false; for (let r in g_DrawLimits[pha].prodQuant) @@ -156,6 +157,7 @@ Engine.GetGUIObjectByName("trainer["+t+"]_icon").sprite = "stretched:session/portraits/"+trainer.icon; Engine.GetGUIObjectByName("trainer["+t+"]_icon").tooltip = buildText(trainer, g_TooltipFunctions); Engine.GetGUIObjectByName("trainer["+t+"]_name").caption = translate(trainer.name.specific); + setViewerOnPress("trainer["+t+"]_icon", trainer.name.internal); thisEle.hidden = false; let p = 0; @@ -244,6 +246,7 @@ prodEle.sprite = "stretched:session/portraits/"+template.icon; prodEle.tooltip = buildText(template, g_TooltipFunctions); prodEle.hidden = false; + setViewerOnPress(prodEle, template.name.internal); return true; } Index: binaries/data/mods/public/gui/reference/structree/rows.xml =================================================================== --- binaries/data/mods/public/gui/reference/structree/rows.xml +++ binaries/data/mods/public/gui/reference/structree/rows.xml @@ -6,14 +6,14 @@ - - + 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 @@ -99,12 +99,12 @@ - - + Index: binaries/data/mods/public/gui/reference/viewer/sprites.xml =================================================================== --- /dev/null +++ binaries/data/mods/public/gui/reference/viewer/sprites.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: binaries/data/mods/public/gui/reference/viewer/styles.xml =================================================================== --- /dev/null +++ binaries/data/mods/public/gui/reference/viewer/styles.xml @@ -0,0 +1,29 @@ + + + +