1
0
forked from 0ad/0ad

Added tooltip to rank icon

Some code cleanup / rework
Minor fixes

This was SVN commit r7696.
This commit is contained in:
WhiteTreePaladin 2010-07-05 16:50:06 +00:00
parent 98a2a887c8
commit 5d224bbeb6
8 changed files with 132 additions and 95 deletions

View File

@ -251,9 +251,6 @@ function handleInputBeforeGui(ev)
// Create the selection groups
g_Selection.createSelectionGroups(ents);
// turn on unit highlight for first unit in selection
getGUIObjectByName("unitSelectionHighlight[0]").hidden = false;
inputState = INPUT_NORMAL;
return true;

View File

@ -101,6 +101,8 @@ EntitySelection.prototype.createSelectionGroups = function(ents)
this.groups.typeCount[template] += 1;
}
}
getGUIObjectByName("unitSelectionHighlight[0]").hidden = false;
};
// Update the selection to take care of changes (like units that have been killed)
@ -126,7 +128,6 @@ EntitySelection.prototype.updateSelection = function()
{
this.dirty = true;
this.createSelectionGroups(g_Selection.toList());
getGUIObjectByName("unitSelectionHighlight[0]").hidden = false;
}
};

View File

@ -3,40 +3,49 @@ const resourceIconCellIds = {food : 0, wood : 1, stone : 2, metal : 3};
// Multiple Selection Layout
function selectionLayoutMultiple()
{
getGUIObjectByName("selectionDetailsMainText").size = "80 100%-70 100%-14 100%-10";
getGUIObjectByName("selectionDetailsSpecific").size = "0 6 100% 30";
getGUIObjectByName("selectionDetailsPlayer").size = "0 34 100% 100%-8";
getGUIObjectByName("selectionDetailsIcon").size = "10 100%-74 66 100%-18";
getGUIObjectByName("selectionDetailsHealth").size = "10 100%-16 66 100%-12";
getGUIObjectByName("selectionDetailsStamina").size = "10 100%-10 66 100%-6";
/*
getGUIObjectByName("sdMainText").size = "80 100%-70 100%-14 100%-32";
getGUIObjectByName("sdRankIcon").size = "0 -14 32 18";
getGUIObjectByName("sdSpecific").size = "0 -14 100% 16";
getGUIObjectByName("sdPlayer").size = "0 16 100% 100%";
*/
getGUIObjectByName("selectionDetailsAttack").hidden = true;
getGUIObjectByName("selectionDetailsArmour").hidden = true;
getGUIObjectByName("sdMainText").size = "80 100%-70 100%-14 100%-10";
getGUIObjectByName("sdSpecific").size = "0 6 100% 30";
getGUIObjectByName("sdPlayer").size = "0 34 100% 100%-8";
getGUIObjectByName("sdIcon").size = "10 100%-74 66 100%-18";
getGUIObjectByName("sdHealth").size = "10 100%-16 66 100%-12";
getGUIObjectByName("sdStamina").size = "10 100%-10 66 100%-6";
getGUIObjectByName("selectionDetailsMainText").sprite = "goldPanel";
getGUIObjectByName("selectionDetailsSpecific").sprite = "";
getGUIObjectByName("sdAttack").hidden = true;
getGUIObjectByName("sdArmour").hidden = true;
getGUIObjectByName("sdMainText").sprite = "goldPanel";
getGUIObjectByName("sdSpecific").sprite = "";
}
// Single Selection Layout
function selectionLayoutSingle()
{
getGUIObjectByName("selectionDetailsMainText").size = "6 0 100%-6 50";
getGUIObjectByName("selectionDetailsSpecific").size = "0 0 100% 30";
getGUIObjectByName("selectionDetailsPlayer").size = "0 30 100% 50";
getGUIObjectByName("sdMainText").size = "6 0 100%-6 50";
getGUIObjectByName("sdRankIcon").size = "0 0 32 32";
getGUIObjectByName("sdSpecific").size = "0 0 100% 30";
getGUIObjectByName("sdPlayer").size = "0 30 100% 50";
getGUIObjectByName("selectionDetailsIcon").size = "10 100%-104 90 100%-22";
getGUIObjectByName("selectionDetailsHealth").size = "10 100%-20 90 100%-14";
getGUIObjectByName("selectionDetailsStamina").size = "10 100%-12 90 100%-6";
getGUIObjectByName("sdIcon").size = "10 100%-102 90 100%-22";
getGUIObjectByName("sdHealth").size = "10 100%-20 90 100%-14";
getGUIObjectByName("sdStamina").size = "10 100%-12 90 100%-6";
getGUIObjectByName("selectionDetailsAttack").size = "104 64 100% 100%-30";
getGUIObjectByName("selectionDetailsArmour").size = "204 64 100% 100%-30";
getGUIObjectByName("sdAttack").size = "104 64 100% 100%-30";
getGUIObjectByName("sdArmour").size = "204 64 100% 100%-30";
getGUIObjectByName("selectionDetailsAttack").hidden = false;
getGUIObjectByName("selectionDetailsArmour").hidden = false;
getGUIObjectByName("sdAttack").hidden = false;
getGUIObjectByName("sdArmour").hidden = false;
getGUIObjectByName("selectionDetailsMainText").sprite = "";
getGUIObjectByName("selectionDetailsSpecific").sprite = "";
getGUIObjectByName("sdMainText").sprite = "";
getGUIObjectByName("sdSpecific").sprite = "";
}
// Fills out information that most entities have
@ -51,50 +60,51 @@ function displayGeneralInfo(playerState, entState, template)
// var eliteStatus = isUnitElite(entState.template);
// Rank Icon
getGUIObjectByName("rankIconImage").sprite = "snIconSheetRank";
getGUIObjectByName("rankIconImage").cell_id = getRankCellId(entState.template);
var rankId = getRankCellId(entState.template);
getGUIObjectByName("sdRankIcon").cell_id = rankId;
getGUIObjectByName("sdRankIcon").tooltip = getRankTitle(rankId);
// Specific Name
var name = template.name.specific; // (eliteStatus? "Elite " + template.name.specific : template.name.specific);
getGUIObjectByName("selectionDetailsSpecific").caption = name;
getGUIObjectByName("sdSpecific").caption = name;
iconTooltip += "[font=\"serif-bold-16\"]" + name + "[/font]";
// Generic Name
if (template.name.generic != template.name.specific)
getGUIObjectByName("selectionDetailsSpecific").tooltip = template.name.generic;
getGUIObjectByName("sdSpecific").tooltip = template.name.generic;
else
getGUIObjectByName("selectionDetailsSpecific").tooltip = "";
getGUIObjectByName("sdSpecific").tooltip = "";
// Player Name
getGUIObjectByName("selectionDetailsPlayer").caption = playerState.name;
getGUIObjectByName("selectionDetailsPlayer").tooltip = getFormalCivName(civName);
getGUIObjectByName("selectionDetailsPlayer").textcolor = playerColor;
getGUIObjectByName("sdPlayer").caption = playerState.name;
getGUIObjectByName("sdPlayer").tooltip = getFormalCivName(civName);
getGUIObjectByName("sdPlayer").textcolor = playerColor;
// Hitpoints
if (entState.hitpoints != undefined)
{
var healthSize = getGUIObjectByName("selectionDetailsHealthBar").size;
var healthSize = getGUIObjectByName("sdHealthBar").size;
healthSize.rright = 100*Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints));
getGUIObjectByName("selectionDetailsHealthBar").size = healthSize;
getGUIObjectByName("sdHealthBar").size = healthSize;
var tooltipHitPoints = "[font=\"serif-bold-13\"]Hitpoints [/font]" + entState.hitpoints + "/" + entState.maxHitpoints;
getGUIObjectByName("selectionDetailsHealth").tooltip = tooltipHitPoints;
getGUIObjectByName("selectionDetailsHealth").hidden = false;
getGUIObjectByName("sdHealth").tooltip = tooltipHitPoints;
getGUIObjectByName("sdHealth").hidden = false;
iconTooltip += "\n" + tooltipHitPoints;
}
else
{
getGUIObjectByName("selectionDetailsHealth").hidden = true;
getGUIObjectByName("selectionDetailsHealth").tooltip = "";
getGUIObjectByName("sdHealth").hidden = true;
getGUIObjectByName("sdHealth").tooltip = "";
}
// Attack stats
getGUIObjectByName("selectionDetailsAttackStats").caption = damageTypesToTextStacked(entState.attack);
getGUIObjectByName("sdAttackStats").caption = damageTypesToTextStacked(entState.attack);
if (entState.attack)
iconTooltip += "\n" + "[font=\"serif-bold-13\"]Attack: [/font]" + damageTypesToText(entState.attack);
// Armour stats
getGUIObjectByName("selectionDetailsArmourStats").caption = damageTypesToTextStacked(entState.armour);
getGUIObjectByName("sdArmourStats").caption = damageTypesToTextStacked(entState.armour);
if (entState.armour)
iconTooltip += "\n" + "[font=\"serif-bold-13\"]Armour: [/font]" + damageTypesToText(entState.armour);
@ -104,30 +114,30 @@ function displayGeneralInfo(playerState, entState, template)
var resources = entState.resourceSupply.amount + "/" + entState.resourceSupply.max + " ";
var resourceType = entState.resourceSupply.type["generic"];
getGUIObjectByName("selectionDetailsResourceStats").caption = resources;
getGUIObjectByName("selectionDetailsResourceIcon").cell_id = resourceIconCellIds[resourceType];
getGUIObjectByName("selectionDetailsResources").hidden = false;
getGUIObjectByName("sdResourceStats").caption = resources;
getGUIObjectByName("sdResourceIcon").cell_id = resourceIconCellIds[resourceType];
getGUIObjectByName("sdResources").hidden = false;
iconTooltip += "\n[font=\"serif-bold-13\"]Resources: [/font]" + resources + "[font=\"serif-12\"]" + resourceType + "[/font]";
// Don't show attack and armour stats on unit with resources - not enough space
getGUIObjectByName("selectionDetailsAttack").hidden = true;
getGUIObjectByName("selectionDetailsArmour").hidden = true;
getGUIObjectByName("sdAttack").hidden = true;
getGUIObjectByName("sdArmour").hidden = true;
}
else
{
getGUIObjectByName("selectionDetailsResources").hidden = true;
getGUIObjectByName("sdResources").hidden = true;
}
// Icon
getGUIObjectByName("selectionDetailsIconImage").sprite = getPortraitSheetName(playerState, entState);
getGUIObjectByName("selectionDetailsIconImage").cell_id = template.icon_cell;
getGUIObjectByName("selectionDetailsIconImage").tooltip = iconTooltip;
//getGUIObjectByName("selectionDetailsIconOutline"); // Need to change color of icon outline with the playerColor
getGUIObjectByName("sdIconImage").sprite = getPortraitSheetName(playerState, entState);
getGUIObjectByName("sdIconImage").cell_id = template.icon_cell;
getGUIObjectByName("sdIconImage").tooltip = iconTooltip;
//getGUIObjectByName("sdIconOutline"); // Need to change color of icon outline with the playerColor
// Is this a Gaia unit?
if (civName == GAIA)
getGUIObjectByName("selectionDetailsPlayer").tooltip = ""; // Don't need civ tooltip for Gaia Player - redundant
getGUIObjectByName("sdPlayer").tooltip = ""; // Don't need civ tooltip for Gaia Player - redundant
}
// Updates middle entity Selection Details Panel
@ -136,7 +146,9 @@ function updateSelectionDetails(simState)
var detailsPanel = getGUIObjectByName("selectionDetails");
var commandsPanel = getGUIObjectByName("unitCommands");
g_Selection.updateSelection();
var selection = g_Selection.toList();
if (selection.length == 0)
{
detailsPanel.hidden = true;

View File

@ -111,7 +111,6 @@ function onSimulationUpdate()
updateDebug(simState);
updatePlayerDisplay(simState);
updateSelection();
updateSelectionDetails(simState);
}
@ -159,11 +158,6 @@ function updatePlayerDisplay(simState)
getGUIObjectByName("resourcePop").caption = playerState.popCount + "/" + playerState.popLimit;
}
function updateSelection()
{
g_Selection.updateSelection();
}
//-------------------------------- -------------------------------- --------------------------------
// Utility functions
//-------------------------------- -------------------------------- --------------------------------
@ -254,6 +248,16 @@ function getRankCellId(templateName)
return -1;
}
function getRankTitle(cellId)
{
if (cellId == 0)
return "Elite";
else if (cellId == 1)
return "Advanced";
return "";
}
function isUnitElite(templateName)
{
var eliteStatus = false;

View File

@ -271,7 +271,7 @@
</object>
<!-- ================================ ================================ -->
<!-- Bottom-middle selected-units and unit details panel -->
<!-- Bottom-middle selected-units and unit details panel ("Selection Details" is Abbreviated as "sd") -->
<!-- ================================ ================================ -->
<object name="selectionDetails"
type="image"
@ -296,48 +296,57 @@
</object>
<!-- Big unit icon -->
<object size="16 100%-94 88 100%-22" name="selectionDetailsIcon" >
<object type="image" name="selectionDetailsIconOutline" style="selectionDetailsIconOutline"/>
<object type="image" name="selectionDetailsIconImage" tooltip_style="snToolTip"/>
<object size="16 100%-94 88 100%-22" name="sdIcon" >
<object type="image" name="sdIconOutline" style="sdIconOutline"/>
<object type="image" name="sdIconImage" tooltip_style="snToolTip"/>
</object>
<!-- Health bar -->
<object size="16 100%-20 88 100%-14" type="image" name="selectionDetailsHealth" tooltip="Hitpoints" tooltip_style="snToolTip">
<object type="image" sprite="selectionDetailsHealthBackground" ghost="true"/>
<object type="image" sprite="selectionDetailsHealthForeground" ghost="true" name="selectionDetailsHealthBar"/>
<object size="16 100%-20 88 100%-14" type="image" name="sdHealth" tooltip="Hitpoints" tooltip_style="snToolTip">
<object type="image" sprite="sdHealthBackground" ghost="true"/>
<object type="image" sprite="sdHealthForeground" ghost="true" name="sdHealthBar"/>
</object>
<!-- Stamina bar -->
<object size="16 100%-12 88 100%-6" type="image" name="selectionDetailsStamina" tooltip="Stamina" tooltip_style="snToolTip">
<object type="image" sprite="selectionDetailsStaminaBackground" ghost="true"/>
<object type="image" sprite="selectionDetailsStaminaForeground" ghost="true" name="selectionDetailsStaminaBar"/>
<object size="16 100%-12 88 100%-6" type="image" name="sdStamina" tooltip="Stamina" tooltip_style="snToolTip">
<object type="image" sprite="sdStaminaBackground" ghost="true"/>
<object type="image" sprite="sdStaminaForeground" ghost="true" name="sdStaminaBar"/>
</object>
<!-- Details text -->
<object size="10 0 100%-10 56" name="selectionDetailsMainText" type="image" sprite="wheatWindowTitle">
<object size="0 0 32 32" name="rankIconImage" type="image" cell_id="0" tooltip_style="snToolTip"/>
<object size="0 5 100% 30" name="selectionDetailsSpecific" type="text" style="largeBoldCenteredText" tooltip_style="snToolTip"/>
<object hidden="true" size="0 20 100% 40" name="selectionDetailsGeneric" type="text" font="serif-14"/>
<object size="0 30 100% 50" name="selectionDetailsPlayer" type="text" style="centeredText" font="serif-bold-14" tooltip_style="snToolTip"/>
<object size="10 0 100%-10 56" name="sdMainText" type="image" sprite="wheatWindowTitle">
<object size="0 5 100% 30" name="sdSpecific" type="text" style="largeBoldCenteredText" tooltip_style="snToolTip"/>
<object hidden="true" size="0 20 100% 40" name="sdGeneric" type="text" font="serif-14"/>
<object size="0 30 100% 50" name="sdPlayer" type="text" style="centeredText" font="serif-bold-14" tooltip_style="snToolTip"/>
<object size="0 0 32 32" name="sdRankIcon" type="image" cell_id="0" sprite="snIconSheetRank" tooltip_style="snToolTip"/>
</object>
<!-- Attack stats -->
<object hidden="true" size="116 72 100% 100%" type="image" name="selectionDetailsAttack" tooltip="Attack strengths" tooltip_style="snToolTip">
<object size="-4 -8 36 36" type="image" name="selectionDetailsAttackImage" ghost="true" sprite="snIconSheetStance" cell_id="1"/>
<object size="30 0 100% 100%" type="text" name="selectionDetailsAttackStats" ghost="true" font="serif-bold-12"/>
<object hidden="true" size="116 72 100% 100%" type="image" name="sdAttack" tooltip="Attack strengths" tooltip_style="snToolTip">
<object size="-4 -8 36 36" type="image" name="sdAttackImage" ghost="true" sprite="snIconSheetStance" cell_id="1"/>
<object size="30 0 100% 100%" type="text" name="sdAttackStats" ghost="true" font="serif-bold-12"/>
</object>
<!-- Armour stats -->
<object hidden="true" size="216 72 100% 100%" type="image" name="selectionDetailsArmour" tooltip="Armour strengths" tooltip_style="snToolTip">
<object size="-4 -4 36 36" type="image" name="selectionDetailsArmourImage" ghost="true" sprite="snIconSheetStance" cell_id="3"/>
<object size="30 0 100% 100%" type="text" name="selectionDetailsArmourStats" ghost="true" font="serif-bold-12"/>
<object hidden="true" size="216 72 100% 100%" type="image" name="sdArmour" tooltip="Armour strengths" tooltip_style="snToolTip">
<object size="-4 -4 36 36" type="image" name="sdArmourImage" ghost="true" sprite="snIconSheetStance" cell_id="3"/>
<object size="30 0 100% 100%" type="text" name="sdArmourStats" ghost="true" font="serif-bold-12"/>
</object>
<!-- Resource Quantity -->
<object hidden="true" size="152 80 100% 100" type="image" name="selectionDetailsResources" tooltip="Resources" tooltip_style="snToolTip">
<object size="0 0 28 24" name="selectionDetailsResourceIcon" type="image" style="resourceIcon" cell_id="0"/>
<object size="28 0 100% 100%" name="selectionDetailsResourceStats" ghost="true" type="text" font="serif-bold-14"/>
<object hidden="true" size="152 80 100% 100" type="image" name="sdResources" tooltip="Resources" tooltip_style="snToolTip">
<object size="0 0 28 24" name="sdResourceIcon" type="image" style="resourceIcon" cell_id="0"/>
<object size="28 0 100% 100%" name="sdResourceStats" ghost="true" type="text" font="serif-bold-14"/>
</object>
<!-- Commands
<object size="90 100%-30 100% 100%-10" type="image" name="sdCommands" tooltip="Commands" tooltip_style="snToolTip">
<object name="commandsDeleteButton" style="iconButton" type="button" size="100%-48 0 100%-24 24">
<object size="0 0 24 24" name="sdCommandsDelete" type="image" style="commandsIcon" cell_id="4"/>
<action on="Press">deleteUnit()</action>
</object>
</object>
-->
</object>
<!-- ================================ ================================ -->

View File

@ -90,23 +90,23 @@
/>
</sprite>
<sprite name="selectionDetailsIconOutline">
<sprite name="sdIconOutline">
<image backcolor="blue"/>
</sprite>
<sprite name="selectionDetailsHealthBackground">
<sprite name="sdHealthBackground">
<image backcolor="red"/>
</sprite>
<sprite name="selectionDetailsHealthForeground">
<sprite name="sdHealthForeground">
<image backcolor="green"/>
</sprite>
<sprite name="selectionDetailsStaminaBackground">
<sprite name="sdStaminaBackground">
<image backcolor="black"/>
</sprite>
<sprite name="selectionDetailsStaminaForeground">
<sprite name="sdStaminaForeground">
<image backcolor="blue"/>
</sprite>

View File

@ -23,7 +23,7 @@
/>
<style name="resourceIcon"
sprite="snIconSheetResource"
sprite="snIconSheetResource"
ghost="true"
/>
@ -37,8 +37,13 @@
tooltip_style="snToolTip"
/>
<style name="selectionDetailsIconOutline"
sprite="selectionDetailsIconOutline"
<style name="commandsIcon"
sprite="snIconSheetCommand"
ghost="true"
/>
<style name="sdIconOutline"
sprite="sdIconOutline"
/>
<style name="iconButton"

View File

@ -115,18 +115,27 @@ function setupUnitPanel(guiName, usedPanels, playerState, unitEntState, items, c
var buttonSideLength = getGUIObjectByName("unit"+guiName+"Button[0]").size.bottom;
var numButtons = i;
var buttonSpacer = ((guiName == "Selection")? 37 : 45);
if (numButtons < 9) // Row 0
{
if ((guiName == "Queue")) // or garrison
getGUIObjectByName("unit"+guiName+"Panel").size = "0 -60 100% 100%-166";
layoutButtonRow(0, guiName, buttonSideLength, buttonSpacer, 0, numButtons);
}
else if (numButtons < 17) // Row 1
{
if (guiName == "Queue") // or garrison
getGUIObjectByName("unit"+guiName+"Panel").size = "0 -105 100% 100%-166";
layoutButtonRow(0, guiName, buttonSideLength, buttonSpacer, 0, 8);
layoutButtonRow(1, guiName, buttonSideLength, buttonSpacer, 8, numButtons);
}
else // Row 2
{
if (guiName == "Queue") // or garrison
getGUIObjectByName("unit"+guiName+"Panel").size = "0 -150 100% 100%-166";
layoutButtonRow(0, guiName, buttonSideLength, buttonSpacer, 0, 8);
layoutButtonRow(1, guiName, buttonSideLength, buttonSpacer, 8, 16);
if (guiName != "Selection")
@ -178,15 +187,15 @@ function updateUnitCommands(playerState, entState, commandsPanel, selection)
// Stamina
if (entState.stamina != undefined)
getGUIObjectByName("selectionDetailsStamina").hidden = false;
getGUIObjectByName("sdStamina").hidden = false;
else
getGUIObjectByName("selectionDetailsStamina").hidden = true;
getGUIObjectByName("sdStamina").hidden = true;
commandsPanel.hidden = false;
}
else
{
getGUIObjectByName("selectionDetailsStamina").hidden = true;
getGUIObjectByName("sdStamina").hidden = true;
commandsPanel.hidden = true;
}