Left-click the portrait to follow the entity
- Left-clicking the portrait of a unit will make the camera follow that unit (before: no action). A tooltip informs the player of this possibility. - Left-clicking the portrait of a structure will make the camera focus on that structure (before: no action). A tooltip informs the player of this possibility. - Double-clicking a hero/treasure icon will make the camera follow that hero/treasure (before: just focus on that hero/treasure). - Some minor related changes. Fixes #6879
This commit is contained in:
parent
e56ebb3f46
commit
663e46920c
@ -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.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user