diff --git a/binaries/data/mods/public/gui/common/tooltips.js b/binaries/data/mods/public/gui/common/tooltips.js index 3477dae168..eb7a16a575 100644 --- a/binaries/data/mods/public/gui/common/tooltips.js +++ b/binaries/data/mods/public/gui/common/tooltips.js @@ -1219,16 +1219,28 @@ function getResourceDropsiteTooltip(template) }); } -function showTemplateViewerOnRightClickTooltip() +function getFocusOnLeftClickTooltip() { - // Translation: Appears in a tooltip to indicate that right-clicking the corresponding GUI element will open the Template Details GUI page. - return translate("Right-click to view more information."); + // Translation: Appears in a tooltip to indicate that left-clicking the corresponding GUI element will center the view on the selected entity. + return translate("Left-click to focus."); } -function showTemplateViewerOnClickTooltip() +function getFollowOnLeftClickTooltip() +{ + // Translation: Appears in a tooltip to indicate that left-clicking the corresponding GUI element will make the camera follow the selected unit. + return translate("Left-click to follow."); +} + +function getTemplateViewerOnRightClickTooltip() +{ + // Translation: Appears in a tooltip to indicate that right-clicking the corresponding GUI element will open the Template Details GUI page. + return translate("Right-click for more information."); +} + +function getTemplateViewerOnClickTooltip() { // Translation: Appears in a tooltip to indicate that clicking the corresponding GUI element will open the Template Details GUI page. - return translate("Click to view more information."); + return translate("Click for more information."); } /** diff --git a/binaries/data/mods/public/gui/reference/structree/Boxes/EntityBox.js b/binaries/data/mods/public/gui/reference/structree/Boxes/EntityBox.js index b15f4813e6..c63e2a9441 100644 --- a/binaries/data/mods/public/gui/reference/structree/Boxes/EntityBox.js +++ b/binaries/data/mods/public/gui/reference/structree/Boxes/EntityBox.js @@ -45,7 +45,7 @@ class EntityBox static compileTooltip(template) { - return ReferencePage.buildText(template, this.prototype.TooltipFunctions) + "\n" + showTemplateViewerOnClickTooltip(); + return ReferencePage.buildText(template, this.prototype.TooltipFunctions) + "\n" + getTemplateViewerOnClickTooltip(); } /** diff --git a/binaries/data/mods/public/gui/session/selection.js b/binaries/data/mods/public/gui/session/selection.js index ee4818bac5..2cfb283c73 100644 --- a/binaries/data/mods/public/gui/session/selection.js +++ b/binaries/data/mods/public/gui/session/selection.js @@ -479,8 +479,8 @@ EntitySelection.prototype.selectAndMoveTo = function(entityID) this.reset(); this.addList([entityID]); - Engine.CameraMoveTo(entState.position.x, entState.position.z); -} + setCameraFollow(entityID); +}; /** * Adds the formation members of a selected entities to the selection. diff --git a/binaries/data/mods/public/gui/session/selection_details.js b/binaries/data/mods/public/gui/session/selection_details.js index 4a429b07e3..0914f18b43 100644 --- a/binaries/data/mods/public/gui/session/selection_details.js +++ b/binaries/data/mods/public/gui/session/selection_details.js @@ -324,9 +324,19 @@ function displaySingle(entState) // 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 = () => { + { + const iconBorder = Engine.GetGUIObjectByName("iconBorder"); + + // Actions on left click + iconBorder.onPress = () => { + setCameraFollow(entState.id); + }; + + // Actions on right click + iconBorder.onPressRight = () => { showTemplateDetails(entState.template, playerState.civ); }; + } let detailedTooltip = [ getAttackTooltip, @@ -357,10 +367,12 @@ function displaySingle(entState) getVisibleEntityClassesFormatted, getAurasTooltip, getEntityTooltip, - getTreasureTooltip, - showTemplateViewerOnRightClickTooltip + getTreasureTooltip ].map(func => func(template))); + const leftClickTooltip = hasClass(entState, "Unit") ? getFollowOnLeftClickTooltip() : getFocusOnLeftClickTooltip(); + iconTooltips.push(leftClickTooltip + " " + getTemplateViewerOnRightClickTooltip()); + Engine.GetGUIObjectByName("iconBorder").tooltip = iconTooltips.filter(tip => tip).join("\n"); Engine.GetGUIObjectByName("detailsAreaSingle").hidden = false; diff --git a/binaries/data/mods/public/gui/session/selection_panels.js b/binaries/data/mods/public/gui/session/selection_panels.js index a0a063f5e6..287b141e87 100644 --- a/binaries/data/mods/public/gui/session/selection_panels.js +++ b/binaries/data/mods/public/gui/session/selection_panels.js @@ -207,7 +207,7 @@ g_SelectionPanels.Construction = { getGarrisonTooltip(template), getTurretsTooltip(template), getPopulationBonusTooltip(template), - showTemplateViewerOnRightClickTooltip(template) + getTemplateViewerOnRightClickTooltip(template) ); @@ -578,7 +578,7 @@ g_SelectionPanels.Queue = { "neededSlots": queuedItem.neededSlots })); } - tooltips.push(showTemplateViewerOnRightClickTooltip(template)); + tooltips.push(getTemplateViewerOnRightClickTooltip(template)); data.button.tooltip = tooltips.join("\n"); data.countDisplay.caption = queuedItem.count > 1 ? queuedItem.count : ""; @@ -763,7 +763,7 @@ g_SelectionPanels.Research = { getEntityNamesFormatted, getEntityTooltip, getEntityCostTooltip, - showTemplateViewerOnRightClickTooltip + getTemplateViewerOnRightClickTooltip ].map(func => func(template)); if (!requirementsPassed) @@ -1058,7 +1058,7 @@ g_SelectionPanels.Training = { getResourceDropsiteTooltip ].map(func => func(template))); - tooltips.push(showTemplateViewerOnRightClickTooltip()); + tooltips.push(getTemplateViewerOnRightClickTooltip()); tooltips.push( formatBatchTrainingString(buildingsCountToTrainFullBatch, fullBatchSize, remainderBatch), getRequirementsTooltip(requirementsMet, template.requirements, GetSimState().players[data.player].civ), @@ -1180,7 +1180,8 @@ g_SelectionPanels.Upgrade = { formatMatchLimitString(limits.matchLimit, limits.matchCount, limits.type), getRequirementsTooltip(requirementsMet, data.item.requirements, GetSimState().players[data.player].civ), getNeededResourcesTooltip(neededResources), - showTemplateViewerOnRightClickTooltip()); + getTemplateViewerOnRightClickTooltip() + ); tooltip = tooltips.filter(tip => tip).join("\n"); diff --git a/binaries/data/mods/public/gui/session/selection_panels_helpers.js b/binaries/data/mods/public/gui/session/selection_panels_helpers.js index e54757ef6e..5243346956 100644 --- a/binaries/data/mods/public/gui/session/selection_panels_helpers.js +++ b/binaries/data/mods/public/gui/session/selection_panels_helpers.js @@ -386,14 +386,16 @@ function cancelUpgradeEntity() } /** - * Set the camera to follow the given entity if it's a unit. - * Otherwise stop following. + * Focus the camera on the entity and follow if it's a unit. + * If that's not possible, stop any current follow. */ function setCameraFollow(entity) { - let entState = entity && GetEntityState(entity); + const entState = entity && GetEntityState(entity); if (entState && hasClass(entState, "Unit")) Engine.CameraFollow(entity); + else if (entState?.position) + Engine.CameraMoveTo(entState.position.x, entState.position.z); else Engine.CameraFollow(0); }