Index: binaries/data/mods/mod/gui/common/modern/sprites.xml =================================================================== --- binaries/data/mods/mod/gui/common/modern/sprites.xml +++ binaries/data/mods/mod/gui/common/modern/sprites.xml @@ -142,6 +142,60 @@ size = "50%+102 0%-18 50%+134 15" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Close + closePage(); + + + + Index: binaries/data/mods/public/gui/session/selection_details.js =================================================================== --- binaries/data/mods/public/gui/session/selection_details.js +++ binaries/data/mods/public/gui/session/selection_details.js @@ -305,6 +305,10 @@ // TODO: we should require all entities to have icons Engine.GetGUIObjectByName("icon").sprite = template.icon ? ("stretched:session/portraits/" + template.icon) : "BackgroundBlack"; + if (template.icon) + Engine.GetGUIObjectByName("iconBorder").onPressRight = () => { + showTemplateDetails(entState.template, playerState.civ); + }; Engine.GetGUIObjectByName("attackAndArmorStats").tooltip = [ getAttackTooltip, @@ -329,7 +333,8 @@ iconTooltips = iconTooltips.concat([ getVisibleEntityClassesFormatted, getAurasTooltip, - getEntityTooltip + getEntityTooltip, + getRightClickMessage ].map(func => func(template))); Engine.GetGUIObjectByName("iconBorder").tooltip = iconTooltips.filter(tip => tip).join("\n"); Index: binaries/data/mods/public/gui/session/selection_panels.js =================================================================== --- binaries/data/mods/public/gui/session/selection_panels.js +++ binaries/data/mods/public/gui/session/selection_panels.js @@ -259,6 +259,7 @@ }); data.button.onPress = function () { startBuildingPlacement(data.item, data.playerState); }; + data.button.onPressRight = function () { showTemplateDetails(data.item, data.playerState.civ); }; let tooltips = [ getEntityNamesFormatted, @@ -267,7 +268,8 @@ getEntityTooltip, getEntityCostTooltip, getGarrisonTooltip, - getPopulationBonusTooltip + getPopulationBonusTooltip, + getRightClickMessage ].map(func => func(template)); let limits = getEntityLimitAndCount(data.playerState, data.item); @@ -763,7 +765,8 @@ let tooltips = [ getEntityNamesFormatted, getEntityTooltip, - getEntityCostTooltip + getEntityCostTooltip, + getRightClickMessage ].map(func => func(template)); if (!requirementsPassed) @@ -814,6 +817,15 @@ addResearchToQueue(data.item.researchFacilityId, tech); }; + button.onPressRight = function () { + let researcherTemplate; + for (let selectedEntity of data.unitEntStates) + if (selectedEntity.id == data.item.researchFacilityId) + researcherTemplate = selectedEntity.template; + + showTemplateDetails("tech/"+data.item.tech, data.playerState.civ, researcherTemplate); + }; + if (data.item.tech.pair) { // On mouse enter, show a cross over the other icon @@ -1001,6 +1013,9 @@ data.button.onPress = function() { addTrainingToQueue(data.unitEntStates.map(state => state.id), data.item, data.playerState); }; + data.button.onPressRight = function() { + showTemplateDetails(data.item, data.playerState.civ); + }; data.countDisplay.caption = trainNum > 1 ? trainNum : ""; @@ -1026,7 +1041,8 @@ getArmorTooltip, getGarrisonTooltip, getProjectilesTooltip, - getSpeedTooltip + getSpeedTooltip, + getRightClickMessage ].map(func => func(template))); tooltips.push( @@ -1116,7 +1132,8 @@ getEntityCostComponentsTooltipString(data.item, undefined, data.unitEntStates.length), formatLimitString(limits.entLimit, limits.entCount, limits.entLimitChangers), getRequiredTechnologyTooltip(technologyEnabled, data.item.requiredTechnology, GetSimState().players[data.player].civ), - getNeededResourcesTooltip(neededResources)); + getNeededResourcesTooltip(neededResources), + getRightClickMessage()); tooltip = tooltips.filter(tip => tip).join("\n"); @@ -1135,6 +1152,10 @@ data.button.enabled = controlsPlayer(data.player); data.button.tooltip = tooltip; + data.button.onPressRight = function() { + showTemplateDetails(data.item.entity, data.playerState.civ); + }; + let modifier = ""; if (!isUpgrading) { @@ -1171,6 +1192,32 @@ } }; +/** + * Pauses game and opens the template details viewer for a selected entity or technology. + * + * Arguably, we shouldn't have to pass a civcode, as that should be derivable from the + * template page. However, the palisade walls and trainable animals have a set civ of + * gaia, so we pass the civcode of the currently owning civ. + * + * And technologies don't have a set civ, so we pass along the name of the template of + * the entity that's researching it so as to derive the civcode from that, if we can. + * + * @param {string} templateName + * @param {string} civ - Civ code of the current owner of the entity selected. + * @param {string} [researcherName] - The template name of the entity that researches a selected technology. + */ +function showTemplateDetails(templateName, civ, researcherName) +{ + pauseGame(); + + Engine.PushGuiPage("page_viewer.xml", { + "templateName": templateName, + "callback": "resumeGame", + "civ": civ, + "researcherName": researcherName + }); +} + /** * If two panels need the same space, so they collide, * the one appearing first in the order is rendered. Index: binaries/data/mods/public/gui/session/selection_panels_helpers.js =================================================================== --- binaries/data/mods/public/gui/session/selection_panels_helpers.js +++ binaries/data/mods/public/gui/session/selection_panels_helpers.js @@ -84,6 +84,11 @@ } } +function getRightClickMessage() +{ + return translate("Right-click for more information."); +} + /** * Format entity count/limit message for the tooltip */ Index: binaries/data/mods/public/gui/session/selection_panels_middle/single_details_area.xml =================================================================== --- binaries/data/mods/public/gui/session/selection_panels_middle/single_details_area.xml +++ binaries/data/mods/public/gui/session/selection_panels_middle/single_details_area.xml @@ -67,7 +67,7 @@ - + Index: binaries/data/mods/public/l10n/messages.json =================================================================== --- binaries/data/mods/public/l10n/messages.json +++ binaries/data/mods/public/l10n/messages.json @@ -243,6 +243,7 @@ "gui/pregame/**.js", "gui/reference/common/**.js", "gui/reference/structree/**.js", + "gui/reference/viewer/**.js", "gui/replaymenu/**.js", "gui/savedgames/**.js", "gui/splashscreen/**.js", @@ -277,6 +278,7 @@ "gui/options/**.xml", "gui/pregame/**.xml", "gui/reference/structree/**.xml", + "gui/reference/viewer/**.xml", "gui/replaymenu/**.xml", "gui/savedgames/**.xml", "gui/splashscreen/**.xml", @@ -386,6 +388,7 @@ "keywords": { "GenericName": {}, "SpecificName": {}, + "History": {}, "VisibleClasses": { "splitOnWhitespace": true }, @@ -417,6 +420,7 @@ "keywords": { "GenericName": {}, "SpecificName": {}, + "History": {}, "VisibleClasses": { "splitOnWhitespace": true }, @@ -455,6 +459,7 @@ "keywords": { "GenericName": {}, "SpecificName": {}, + "History": {}, "VisibleClasses": { "splitOnWhitespace": true },