1
0
forked from 0ad/0ad

Fixed HP display issues in GUI

This was SVN commit r7864.
This commit is contained in:
WhiteTreePaladin 2010-08-07 00:21:17 +00:00
parent 91cd032827
commit d2e6233c44
4 changed files with 21 additions and 18 deletions

View File

@ -204,28 +204,23 @@ function getPreferredEntities(ents)
var entStateList = [];
var preferredEnts = [];
// Get list of ent states
for (var i = 0; i < ents.length; i++)
// Check if there are units in the selection and get a list of entity states
for each (var ent in ents)
{
var entState = Engine.GuiInterfaceCall("GetEntityState", ents[i]);
var entState = Engine.GuiInterfaceCall("GetEntityState", ent);
if (!entState)
continue;
if (isUnit(entState))
preferredEnts.push(ent);
entStateList.push(entState);
}
// Check if there are units in the selection
for (var i = 0; i < ents.length; i++)
if (isUnit(entStateList[i]))
preferredEnts.push(ents[i]);
// If there are no units, check if there are defensive entities in the selection
if (!preferredEnts.length)
{
// Check if there are defensive entities in the selection
for (var i = 0; i < ents.length; i++)
if (isDefensive(entStateList[i]))
preferredEnts.push(ents[i]);
}
return preferredEnts;
}

View File

@ -21,10 +21,10 @@ function layoutSelectionSingle(entState)
var player = Engine.GetPlayerID();
if (entState.player == player || g_DevSettings.controlAll)
{
// if (entState.stamina != undefined)
if (entState.stamina != undefined)
getGUIObjectByName("sdStamina").hidden = false;
// else
// getGUIObjectByName("sdStamina").hidden = true;
else
getGUIObjectByName("sdStamina").hidden = true;
}
}
@ -61,7 +61,7 @@ function displayGeneralInfo(playerState, entState, template)
getGUIObjectByName("sdPlayer").textcolor = playerColor;
// Hitpoints
if (entState.maxHitpoints != undefined)
if (entState.hitpoints != undefined)
{
var unitHealthBar = getGUIObjectByName("sdHealthBar");
var healthSize = unitHealthBar.size;

View File

@ -308,8 +308,10 @@
<repeat count="32">
<object name="unitSelectionButton[n]" hidden="true" style="iconButton" type="button" size="0 0 36 36">
<object name="unitSelectionIcon[n]" type="image" ghost="true" size="3 3 34 34"/>
<object size="0 100%-3 100% 100%" name="unitSelectionHealthBackground[n]" type="image" sprite="sdHealthBackground" ghost="true"/>
<object size="0 100%-3 100% 100%" name="unitSelectionHealthForeground[n]" type="image" sprite="sdHealthForeground" ghost="true"/>
<object size="0 100%-3 100% 100%" name="unitSelectionHealth[n]" ghost="true">
<object size="0 0 100% 100%" name="unitSelectionHealthBackground[n]" type="image" sprite="sdHealthBackground" ghost="true"/>
<object size="0 0 100% 100%" name="unitSelectionHealthForeground[n]" type="image" sprite="sdHealthForeground" ghost="true"/>
</object>
</object>
</repeat>
</object>

View File

@ -69,13 +69,19 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback)
tooltip += "[font=\"serif-bold-16\"]" + getRankTitle(getRankCellId(entState)) + "[/font]";
// Hitpoints
if (entState.maxHitpoints != undefined)
var unitHealth = getGUIObjectByName("unitSelectionHealth["+i+"]");
if (entState.hitpoints != undefined)
{
var unitHealthBar = getGUIObjectByName("unitSelectionHealthForeground["+i+"]");
var healthSize = unitHealthBar.size;
healthSize.rright = 100*Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints));
unitHealthBar.size = healthSize;
tooltip += " [font=\"serif-9\"](" + entState.hitpoints + "/" + entState.maxHitpoints + ")[/font]";
unitHealth.hidden = false;
}
else
{
unitHealth.hidden = true;
}
break;