Focus on the building a hero is garrisoned in when the hero button is double-clicked. Patch by mimo. Fixes #2131

This was SVN commit r13978.
This commit is contained in:
alpha123 2013-10-10 21:23:19 +00:00
parent c7e3c1499f
commit f6c9db33d6
2 changed files with 19 additions and 6 deletions

View file

@ -462,13 +462,13 @@ function updateHero()
heroImage.sprite = "stretched:session/portraits/" + template.icon;
var hero = playerState.heroes[0];
heroButton.onpress = function()
{
heroButton.onpress = function()
{
if (!Engine.HotkeyIsPressed("selection.add"))
g_Selection.reset();
g_Selection.addList([hero]);
g_Selection.reset();
g_Selection.addList([hero]);
};
heroButton.ondoublepress = function() { selectAndMoveTo(hero) };
heroButton.ondoublepress = function() { selectAndMoveTo(getEntityOrHolder(hero)); };
heroButton.hidden = false;
// Setup tooltip

View file

@ -518,7 +518,7 @@ function getEntityNamesFormatted(template)
if (specific)
{
// drop caps for specific name
names += '[font="serif-bold-16"]' + specific[0] + '[/font]' +
names += '[font="serif-bold-16"]' + specific[0] + '[/font]' +
'[font="serif-bold-12"]' + specific.slice(1).toUpperCase() + '[/font]';
if (generic)
@ -573,3 +573,16 @@ function getTradingTooltip(gain)
return tooltip;
}
/**
* Returns the entity itself except when garrisoned where it returns its garrisonHolder
*/
function getEntityOrHolder(ent)
{
var entState = GetEntityState(ent);
if (entState && !entState.position && entState.unitAI && entState.unitAI.orders.length > 0 &&
entState.unitAI.orders[0].type == "Garrison")
return entState.unitAI.orders[0].data.target;
return ent;
}