2010-07-01 22:31:47 +02:00
|
|
|
const resourceIconCellIds = {food : 0, wood : 1, stone : 2, metal : 3};
|
|
|
|
|
|
|
|
// Multiple Selection Layout
|
|
|
|
function selectionLayoutMultiple()
|
|
|
|
{
|
|
|
|
|
2010-07-05 18:50:06 +02:00
|
|
|
/*
|
|
|
|
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%";
|
|
|
|
*/
|
2010-07-01 22:31:47 +02:00
|
|
|
|
2010-07-05 18:50:06 +02:00
|
|
|
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("sdAttack").hidden = true;
|
|
|
|
getGUIObjectByName("sdArmour").hidden = true;
|
2010-07-01 22:31:47 +02:00
|
|
|
|
2010-07-05 18:50:06 +02:00
|
|
|
getGUIObjectByName("sdMainText").sprite = "goldPanel";
|
|
|
|
getGUIObjectByName("sdSpecific").sprite = "";
|
2010-07-01 22:31:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Single Selection Layout
|
|
|
|
function selectionLayoutSingle()
|
|
|
|
{
|
2010-07-05 18:50:06 +02:00
|
|
|
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";
|
2010-07-01 22:31:47 +02:00
|
|
|
|
2010-07-05 18:50:06 +02:00
|
|
|
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";
|
2010-07-01 22:31:47 +02:00
|
|
|
|
2010-07-05 18:50:06 +02:00
|
|
|
getGUIObjectByName("sdAttack").size = "104 64 100% 100%-30";
|
|
|
|
getGUIObjectByName("sdArmour").size = "204 64 100% 100%-30";
|
2010-07-01 22:31:47 +02:00
|
|
|
|
2010-07-05 18:50:06 +02:00
|
|
|
getGUIObjectByName("sdAttack").hidden = false;
|
|
|
|
getGUIObjectByName("sdArmour").hidden = false;
|
2010-07-01 22:31:47 +02:00
|
|
|
|
2010-07-05 18:50:06 +02:00
|
|
|
getGUIObjectByName("sdMainText").sprite = "";
|
|
|
|
getGUIObjectByName("sdSpecific").sprite = "";
|
2010-07-01 22:31:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Fills out information that most entities have
|
2010-07-02 04:50:45 +02:00
|
|
|
function displayGeneralInfo(playerState, entState, template)
|
2010-07-01 22:31:47 +02:00
|
|
|
{
|
2010-07-02 04:50:45 +02:00
|
|
|
var civName = toTitleCase(playerState.civ);
|
2010-07-02 23:42:17 +02:00
|
|
|
var color = playerState.color;
|
|
|
|
var playerColor = color["r"]*255 + " " + color["g"]*255 + " " + color["b"]*255 + " " + color["a"]*255;
|
2010-07-01 22:31:47 +02:00
|
|
|
var iconTooltip = "";
|
2010-07-02 04:50:45 +02:00
|
|
|
|
2010-07-01 22:31:47 +02:00
|
|
|
// Is unit Elite?
|
2010-07-03 17:06:31 +02:00
|
|
|
// var eliteStatus = isUnitElite(entState.template);
|
|
|
|
|
|
|
|
// Rank Icon
|
2010-07-05 18:50:06 +02:00
|
|
|
var rankId = getRankCellId(entState.template);
|
|
|
|
getGUIObjectByName("sdRankIcon").cell_id = rankId;
|
|
|
|
getGUIObjectByName("sdRankIcon").tooltip = getRankTitle(rankId);
|
2010-07-01 22:31:47 +02:00
|
|
|
|
|
|
|
// Specific Name
|
2010-07-03 17:06:31 +02:00
|
|
|
var name = template.name.specific; // (eliteStatus? "Elite " + template.name.specific : template.name.specific);
|
2010-07-05 18:50:06 +02:00
|
|
|
getGUIObjectByName("sdSpecific").caption = name;
|
2010-07-01 22:31:47 +02:00
|
|
|
iconTooltip += "[font=\"serif-bold-16\"]" + name + "[/font]";
|
|
|
|
|
|
|
|
// Generic Name
|
|
|
|
if (template.name.generic != template.name.specific)
|
2010-07-05 18:50:06 +02:00
|
|
|
getGUIObjectByName("sdSpecific").tooltip = template.name.generic;
|
2010-07-01 22:31:47 +02:00
|
|
|
else
|
2010-07-05 18:50:06 +02:00
|
|
|
getGUIObjectByName("sdSpecific").tooltip = "";
|
2010-07-01 22:31:47 +02:00
|
|
|
|
|
|
|
// Player Name
|
2010-07-05 18:50:06 +02:00
|
|
|
getGUIObjectByName("sdPlayer").caption = playerState.name;
|
|
|
|
getGUIObjectByName("sdPlayer").tooltip = getFormalCivName(civName);
|
|
|
|
getGUIObjectByName("sdPlayer").textcolor = playerColor;
|
2010-07-01 22:31:47 +02:00
|
|
|
|
|
|
|
// Hitpoints
|
|
|
|
if (entState.hitpoints != undefined)
|
|
|
|
{
|
2010-07-05 18:50:06 +02:00
|
|
|
var healthSize = getGUIObjectByName("sdHealthBar").size;
|
2010-07-01 22:31:47 +02:00
|
|
|
healthSize.rright = 100*Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints));
|
2010-07-05 18:50:06 +02:00
|
|
|
getGUIObjectByName("sdHealthBar").size = healthSize;
|
2010-07-01 22:31:47 +02:00
|
|
|
|
|
|
|
var tooltipHitPoints = "[font=\"serif-bold-13\"]Hitpoints [/font]" + entState.hitpoints + "/" + entState.maxHitpoints;
|
2010-07-05 18:50:06 +02:00
|
|
|
getGUIObjectByName("sdHealth").tooltip = tooltipHitPoints;
|
|
|
|
getGUIObjectByName("sdHealth").hidden = false;
|
2010-07-01 22:31:47 +02:00
|
|
|
iconTooltip += "\n" + tooltipHitPoints;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-05 18:50:06 +02:00
|
|
|
getGUIObjectByName("sdHealth").hidden = true;
|
|
|
|
getGUIObjectByName("sdHealth").tooltip = "";
|
2010-07-01 22:31:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Attack stats
|
2010-07-05 18:50:06 +02:00
|
|
|
getGUIObjectByName("sdAttackStats").caption = damageTypesToTextStacked(entState.attack);
|
2010-07-01 22:31:47 +02:00
|
|
|
if (entState.attack)
|
|
|
|
iconTooltip += "\n" + "[font=\"serif-bold-13\"]Attack: [/font]" + damageTypesToText(entState.attack);
|
|
|
|
|
|
|
|
// Armour stats
|
2010-07-05 18:50:06 +02:00
|
|
|
getGUIObjectByName("sdArmourStats").caption = damageTypesToTextStacked(entState.armour);
|
2010-07-01 22:31:47 +02:00
|
|
|
if (entState.armour)
|
|
|
|
iconTooltip += "\n" + "[font=\"serif-bold-13\"]Armour: [/font]" + damageTypesToText(entState.armour);
|
|
|
|
|
2010-07-04 05:49:58 +02:00
|
|
|
// Resource stats
|
|
|
|
if (entState.resourceSupply)
|
2010-07-01 22:31:47 +02:00
|
|
|
{
|
2010-07-04 05:49:58 +02:00
|
|
|
var resources = entState.resourceSupply.amount + "/" + entState.resourceSupply.max + " ";
|
|
|
|
var resourceType = entState.resourceSupply.type["generic"];
|
2010-07-01 22:31:47 +02:00
|
|
|
|
2010-07-05 18:50:06 +02:00
|
|
|
getGUIObjectByName("sdResourceStats").caption = resources;
|
|
|
|
getGUIObjectByName("sdResourceIcon").cell_id = resourceIconCellIds[resourceType];
|
|
|
|
getGUIObjectByName("sdResources").hidden = false;
|
2010-07-02 23:42:17 +02:00
|
|
|
|
2010-07-04 05:49:58 +02:00
|
|
|
iconTooltip += "\n[font=\"serif-bold-13\"]Resources: [/font]" + resources + "[font=\"serif-12\"]" + resourceType + "[/font]";
|
2010-07-02 23:42:17 +02:00
|
|
|
|
2010-07-04 05:49:58 +02:00
|
|
|
// Don't show attack and armour stats on unit with resources - not enough space
|
2010-07-05 18:50:06 +02:00
|
|
|
getGUIObjectByName("sdAttack").hidden = true;
|
|
|
|
getGUIObjectByName("sdArmour").hidden = true;
|
2010-07-04 05:49:58 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-05 18:50:06 +02:00
|
|
|
getGUIObjectByName("sdResources").hidden = true;
|
2010-07-01 22:31:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Icon
|
2010-07-05 18:50:06 +02:00
|
|
|
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
|
2010-07-04 05:49:58 +02:00
|
|
|
|
|
|
|
// Is this a Gaia unit?
|
|
|
|
if (civName == GAIA)
|
2010-07-05 18:50:06 +02:00
|
|
|
getGUIObjectByName("sdPlayer").tooltip = ""; // Don't need civ tooltip for Gaia Player - redundant
|
2010-07-01 22:31:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Updates middle entity Selection Details Panel
|
2010-07-02 04:50:45 +02:00
|
|
|
function updateSelectionDetails(simState)
|
2010-07-01 22:31:47 +02:00
|
|
|
{
|
|
|
|
var detailsPanel = getGUIObjectByName("selectionDetails");
|
|
|
|
var commandsPanel = getGUIObjectByName("unitCommands");
|
|
|
|
|
2010-07-05 18:50:06 +02:00
|
|
|
g_Selection.updateSelection();
|
2010-07-01 22:31:47 +02:00
|
|
|
var selection = g_Selection.toList();
|
2010-07-05 18:50:06 +02:00
|
|
|
|
2010-07-01 22:31:47 +02:00
|
|
|
if (selection.length == 0)
|
|
|
|
{
|
|
|
|
detailsPanel.hidden = true;
|
|
|
|
commandsPanel.hidden = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the unit has no data (e.g. it was killed), don't try displaying any
|
|
|
|
data for it. (TODO: it should probably be removed from the selection too;
|
|
|
|
also need to handle multi-unit selections) */
|
|
|
|
var entState = Engine.GuiInterfaceCall("GetEntityState", selection[g_Selection.getPrimary()]);
|
|
|
|
if (!entState)
|
|
|
|
return;
|
|
|
|
|
2010-07-02 04:50:45 +02:00
|
|
|
var playerState = simState.players[entState.player];
|
|
|
|
if (!playerState)
|
|
|
|
return;
|
|
|
|
|
2010-07-01 22:31:47 +02:00
|
|
|
var template = Engine.GuiInterfaceCall("GetTemplateData", entState.template);
|
2010-07-02 23:42:17 +02:00
|
|
|
|
2010-07-01 22:31:47 +02:00
|
|
|
// Different selection details are shown based on whether multiple units or a single unit is selected
|
|
|
|
if (selection.length > 1)
|
|
|
|
selectionLayoutMultiple();
|
|
|
|
else
|
|
|
|
selectionLayoutSingle();
|
|
|
|
|
|
|
|
// Fill out general info and display it
|
2010-07-02 04:50:45 +02:00
|
|
|
displayGeneralInfo(playerState, entState, template); // must come after layout functions
|
2010-07-01 22:31:47 +02:00
|
|
|
|
|
|
|
// Show Panels
|
|
|
|
detailsPanel.hidden = false;
|
|
|
|
|
|
|
|
// Fill out commands panel for specific unit selected (or first unit of primary group)
|
2010-07-02 04:50:45 +02:00
|
|
|
updateUnitCommands(playerState, entState, commandsPanel, selection);
|
2010-07-01 22:31:47 +02:00
|
|
|
}
|