1
0
forked from 0ad/0ad

Made ESC close out open dialogs rather than offer to close the game

Fixed the multiple unit health bar failing to work correctly
Changed multiple selection area to fit layout better.
Organized code

This was SVN commit r8256.
This commit is contained in:
WhiteTreePaladin 2010-10-03 22:42:15 +00:00
parent 2cc6280d70
commit eff766d6b9
6 changed files with 380 additions and 434 deletions

View File

@ -53,3 +53,13 @@ function togglePause()
pauseOverlay.hidden = !pauseOverlay.hidden;
menu.hidden = true;
}
function escapeKeyAction() // runs multiple times, so always closes all for now...
{
if (!menu.hidden)
menu.hidden = true;
else if (!chatWindow.hidden)
chatWindow.hidden = true;
else if (!settingsWindow.hidden)
settingsWindow.hidden = true;
}

View File

@ -1,29 +1,32 @@
const RESOURCE_ICON_CELL_IDS = {food : 0, wood : 1, stone : 2, metal : 3};
function layoutSelectionMultiple()
{
getGUIObjectByName("specific").hidden = true;
getGUIObjectByName("iconBorder").hidden = true;
getGUIObjectByName("attackIcon").size = "-4 10 32 46";
getGUIObjectByName("armourIcon").size = "-4 46 32 82";
getGUIObjectByName("barsArea").size = "50%+60 40 100% 136"
}
function layoutSelectionSingle()
{
getGUIObjectByName("specific").hidden = false;
getGUIObjectByName("iconBorder").hidden = false;
getGUIObjectByName("detailsAreaSingle").hidden = false;
getGUIObjectByName("detailsAreaMultiple").hidden = true;
getGUIObjectByName("attackIcon").size = "0 0 48 48";
getGUIObjectByName("armourIcon").size = "0 48 48 96";
getGUIObjectByName("barsArea").size = "50%+48 40 100% 136"
// getGUIObjectByName("specific").hidden = false;
// getGUIObjectByName("iconBorder").hidden = false;
//getGUIObjectByName("attackIcon").size = "0 0 48 48";
//getGUIObjectByName("armourIcon").size = "0 48 48 96";
//getGUIObjectByName("barsArea").size = "50%+48 40 100% 136"
}
function layoutSelectionMultiple()
{
// getGUIObjectByName("specific").hidden = true;
// getGUIObjectByName("iconBorder").hidden = true;
//getGUIObjectByName("attackIcon").size = "-4 10 32 46";
//getGUIObjectByName("armourIcon").size = "-4 46 32 82";
//getGUIObjectByName("barsArea").size = "50%+60 40 100% 136"
getGUIObjectByName("detailsAreaMultiple").hidden = false;
getGUIObjectByName("detailsAreaSingle").hidden = true;
}
// Fills out information that most entities have
function displayGeneralInfo(entState, template)
function displaySingle(entState, template)
{
// Get general unit and player data
var specificName = template.name.specific;
@ -111,7 +114,6 @@ function displayGeneralInfo(entState, template)
getGUIObjectByName("attackIcon").tooltip = damageTypesToText(entState.attack);
getGUIObjectByName("armourIcon").tooltip = damageTypesToText(entState.armour);
// Icon Tooltip
var iconTooltip = "";
@ -122,6 +124,46 @@ function displayGeneralInfo(entState, template)
iconTooltip += "\n[font=\"serif-13\"]" + template.tooltip + "[/font]";
getGUIObjectByName("iconBorder").tooltip = iconTooltip;
// Unhide Details Area
getGUIObjectByName("detailsAreaSingle").hidden = false;
getGUIObjectByName("detailsAreaMultiple").hidden = true;
}
// Fills out information for multiple entities
function displayMultiple(selection, template)
{
var averageHealth = 0;
var maxHealth = 0;
for (var i = 0; i < selection.length; i++)
{
var entState = GetEntityState(selection[i])
if (entState)
{
if (entState.hitpoints)
{
averageHealth += entState.hitpoints;
maxHealth += entState.maxHitpoints;
}
}
if (i == selection.length-1)
{
var unitHealthBar = getGUIObjectByName("healthBarMultiple");
var healthSize = unitHealthBar.size;
healthSize.rright = 100*Math.max(0, Math.min(1, averageHealth / maxHealth));
unitHealthBar.size = healthSize;
var hitpoints = "[font=\"serif-bold-13\"]Hitpoints [/font]" + averageHealth + "/" + maxHealth;
getGUIObjectByName("healthMultiple").tooltip = hitpoints;
}
}
// Unhide Details Area
getGUIObjectByName("detailsAreaMultiple").hidden = false;
getGUIObjectByName("detailsAreaSingle").hidden = true;
}
// Updates middle entity Selection Details Panel
@ -150,27 +192,13 @@ function updateSelectionDetails()
if (!entState)
return;
// Choose the highest ranked version of the primary selection
// Different selection details are shown based on whether multiple units or a single unit is selected
/*
if (selection.length > 1)
layoutSelectionMultiple();
else
layoutSelectionSingle(entState);
*/
var template = GetTemplateData(entState.template);
// Fill out general info and display it
if (selection.length == 1)
{
layoutSelectionSingle();
}
displaySingle(entState, template);
else
{
layoutSelectionMultiple();
}
displayMultiple(selection, template);
var player = Engine.GetPlayerID();
if (entState.player == player || g_DevSettings.controlAll)
@ -181,8 +209,6 @@ function updateSelectionDetails()
// getGUIObjectByName("stamina").hidden = true;
}
displayGeneralInfo(entState, template); // must come after layout functions
// Show Panels
detailsPanel.hidden = false;

View File

@ -46,11 +46,15 @@
<!-- ================================ ================================ -->
<!-- Exit button Hotkey -->
<!--
<action on="Press"><![CDATA[
messageBox(400, 200, "Do you really want to quit?", "Confirmation", 0,
["Yes", "No!"], [leaveGame, null]);
]]></action>
-->
<object hotkey="leave">
<action on="Press"><![CDATA[
messageBox(400, 200, "Do you really want to quit?", "Confirmation", 0,
["Yes", "No!"], [leaveGame, null]);
]]></action>
<action on="Press">escapeKeyAction();</action>
</object>
<!-- Chat: Depending on the current state, it either opens message window or closes message window / posts message -->
@ -156,8 +160,7 @@
<object name="notificationPanel" type="image" size="50%-300 30 50%+300 90" ghost="true">
<object name="notificationText" size="0 0 100% 100%" type="text" style="notificationPanel" ghost="true"/>
</object>
<!-- ================================ ================================ -->
<!-- Chat -->
<!-- ================================ ================================ -->
@ -451,23 +454,22 @@
size="50%-114 100%-205 50%+114 100%"
hidden="true"
>
<object name="unitSelectionPanel"
size="40 36 100%-20 100%"
>
<object size="0 0 100% 100%">
<repeat count="12">
<object name="unitSelectionButton[n]" hidden="true" style="iconButton" type="button" size="0 0 36 36" z="100">
<object name="unitSelectionIcon[n]" type="image" ghost="true" size="1 1 35 35"/>
<object name="unitSelectionCount[n]" ghost="true" style="groupIconsText" type="text" size="0 0 100% 100%"/>
<object size="0 100%-3 100% 100%" name="unitSelectionHealth[n]" ghost="true">
</object>
</object>
</repeat>
</object>
</object>
<!-- Specific unit details -->
<object size="50%-112 0 50%+112 100%" name="detailsArea">
<!-- Unit details for Single Unit -->
<object size="50%-112 0 50%+112 100%" name="detailsAreaSingle">
<!-- Player Name -->
<object size="0 10 100% 30" name="player" type="text" style="largeCenteredOutlinedText" tooltip_style="snToolTip"/>
@ -489,7 +491,7 @@
</object>
<!-- Stats Bars -->
<object size= "50%+48 36 100% 140" type="image" name="barsArea" tooltip_style="snToolTip">
<object size= "50%+48 36 100% 140" type="image" tooltip_style="snToolTip">
<!-- Health bar -->
<object size="18 0 30 100%" type="image" name="health" tooltip="Hitpoints" tooltip_style="snToolTip">
<object type="image" sprite="healthBackground" ghost="true"/>
@ -516,6 +518,52 @@
<object size="0 142 100% 162" name="specific" type="text" style="largeCenteredOutlinedText" tooltip_style="snToolTip"/>
</object>
<!-- Unit details for Multiplle Units -->
<object size="50%-112 0 50%+112 100%" name="detailsAreaMultiple">
<object name="unitSelectionPanel"
size="20 16 100%-20 100%"
>
<object size="0 0 100% 100%">
<repeat count="15">
<object name="unitSelectionButton[n]" hidden="true" style="iconButton" type="button" size="0 0 36 36" z="100">
<object name="unitSelectionIcon[n]" type="image" ghost="true" size="1 1 35 35"/>
<object name="unitSelectionCount[n]" ghost="true" style="groupIconsText" type="text" size="0 0 100% 100%"/>
<object size="0 100%-3 100% 100%" name="unitSelectionHealth[n]" ghost="true">
</object>
</object>
</repeat>
</object>
</object>
<!-- Stats Bars -->
<object size= "40 100%-65 100%-40 100%-35" type="image" tooltip_style="snToolTip">
<!-- Health bar -->
<object size="0 0 100% 12" type="image" name="healthMultiple" tooltip="Hitpoints" tooltip_style="snToolTip">
<object type="image" sprite="healthBackground" ghost="true"/>
<object type="image" sprite="healthForeground" ghost="true" name="healthBarMultiple"/>
<object type="image" sprite="statsBarShader" ghost="true"/>
</object>
<!-- Stamina bar -->
<object size="0 14 100% 26" type="image" name="staminaMultiple" tooltip="Stamina" tooltip_style="snToolTip">
<object type="image" sprite="staminaBackground" ghost="true"/>
<object type="image" sprite="staminaForeground" ghost="true" name="staminaBarMultiple"/>
<object type="image" sprite="statsBarShader" ghost="true"/>
</object>
</object>
</object>
<!-- Unit Commands -->
<object name="unitCommandPanel"
size="0 100%-35 100% 100%"

View File

@ -2,6 +2,9 @@
<sprites>
<!-- ================================ ================================ -->
<!-- Civ Icons -->
<!-- ================================ ================================ -->
<sprite name="heleIcon">
<image
texture="session/portraits/emblems/emblem_hellenes.png"
@ -16,7 +19,9 @@
/>
</sprite>
<!-- ICONS NEED BETTER PLACE -->
<!-- ================================ ================================ -->
<!-- Unit Command Icons -->
<!-- ================================ ================================ -->
<sprite name="formation">
<image
texture="session/icons/sheets/formation_select.png"
@ -40,62 +45,22 @@
size="0 0 100% 100%"
/>
</sprite>
<!-- ================================ ================================ -->
<!-- Menu -->
<!-- ================================ ================================ -->
<sprite name="menuButton">
<image
texture="session/icons/single/menu.png"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="glassSquareMap">
<image backcolor="255 255 255 56" size="0 0 100% 1"/>
<image backcolor="255 255 255 56" size="100%-1 1 100% 100%"/>
<image backcolor="255 255 255 56" size="0 100%-1 100% 100%"/>
<image backcolor="255 255 255 56" size="0 1 1 100%-1"/>
<image backcolor="255 255 255 44" size="1 1 100%-1 2"/>
<image backcolor="255 255 255 44" size="100%-2 2 100%-1 100%-1"/>
<image backcolor="255 255 255 44" size="1 100%-2 100%-1 100%-1"/>
<image backcolor="255 255 255 44" size="1 2 2 100%-2"/>
<image backcolor="255 255 255 32" size="2 2 100%-2 3"/>
<image backcolor="255 255 255 32" size="100%-3 3 100%-2 100%-2"/>
<image backcolor="255 255 255 32" size="2 100%-3 100%-2 100%-2"/>
<image backcolor="255 255 255 32" size="2 3 3 100%-3"/>
</sprite>
<sprite name="glassSquareIcon">
<image backcolor="255 255 255 128" size="0 0 100% 1"/>
<image backcolor="255 255 255 44" size="100%-1 1 100% 100%"/>
<image backcolor="255 255 255 44" size="0 100%-1 100% 100%"/>
<image backcolor="255 255 255 128" size="0 1 1 100%-1"/>
<image backcolor="255 255 255 96" size="1 1 100%-1 2"/>
<image backcolor="255 255 255 32" size="100%-2 2 100%-1 100%-1"/>
<image backcolor="255 255 255 32" size="1 100%-2 100%-1 100%-1"/>
<image backcolor="255 255 255 96" size="1 2 2 100%-2"/>
<image backcolor="255 255 255 64" size="2 2 100%-2 3"/>
<image backcolor="255 255 255 16" size="100%-3 3 100%-2 100%-2"/>
<image backcolor="255 255 255 16" size="2 100%-3 100%-2 100%-2"/>
<image backcolor="255 255 255 64" size="2 3 3 100%-3"/>
</sprite>
<!-- PANELS -->
<!-- generic -->
<!-- ================================ ================================ -->
<!-- Panel Backgrounds -->
<!-- ================================ ================================ -->
<!-- Generic Panel -->
<sprite name="genericPanel">
<image
texture="global/tile/tile_dark.png"
@ -103,7 +68,7 @@
size="0 0 100% 100%"
/>
<!-- Sides -->
<!-- sides -->
<image
texture="global/border/line_horiz.png"
texture_size="0 0 64 4"
@ -125,7 +90,7 @@
size="0 4 4 100%-4"
/>
<!-- Corners -->
<!-- corners -->
<image
texture="global/border/line_corner_top_right.png"
texture_size="0 0 4 4"
@ -148,14 +113,14 @@
/>
</sprite>
<!-- top -->
<!-- Top Panel -->
<sprite name="topPanel">
<image
texture="session/ribbon_bg.png"
real_texture_placement="0 0 2048 32"
size="0 0 100% 100%"
/>
<!-- Sides -->
<!-- sides -->
<image
texture="global/border/line_horiz.png"
texture_size="0 0 64 4"
@ -168,14 +133,14 @@
/>
</sprite>
<!-- Map -->
<!-- Map Panel -->
<sprite name="mapPanel">
<image
texture="session/map_bg.png"
texture_size="0 0 100% 100%"
size="0 0 100% 100%"
/>
<!-- Sides -->
<!-- sides -->
<image
texture="global/border/line_horiz.png"
texture_size="0 0 64 4"
@ -197,7 +162,7 @@
size="0 4 4 100%-4"
/>
<!-- Corners -->
<!-- corners -->
<image
texture="global/border/line_corner_top_right.png"
texture_size="0 0 4 4"
@ -220,7 +185,7 @@
/>
</sprite>
<!-- bottomLeft -->
<!-- Bottom Left Panel -->
<sprite name="bottomLeft">
<image
texture="session/panel_left.png"
@ -229,7 +194,7 @@
size="0 0 100% 100%"
/>
<!-- Sides -->
<!-- sides -->
<image
texture="global/border/line_horiz.png"
texture_size="0 0 64 4"
@ -251,7 +216,7 @@
size="0 4 4 100%-4"
/>
<!-- Corners -->
<!-- corners -->
<image
texture="global/border/line_corner_middle_left.png"
texture_size="0 0 4 4"
@ -274,7 +239,7 @@
/>
</sprite>
<!-- bottomMiddle-->
<!-- Bottom Middle Panel -->
<sprite name="bottomMiddle">
<image
texture="session/panel_middle.png"
@ -283,7 +248,7 @@
size="0 0 100% 100%"
/>
<!-- Sides -->
<!-- sides -->
<image
texture="global/border/line_horiz.png"
texture_size="0 0 64 4"
@ -305,7 +270,7 @@
size="0 4 4 100%-4"
/>
<!-- Corners -->
<!-- corners -->
<image
texture="global/border/line_corner_top_right.png"
texture_size="0 0 4 4"
@ -328,7 +293,7 @@
/>
</sprite>
<!-- bottomRight -->
<!-- Bottom Right Panel -->
<sprite name="bottomRight">
<image
texture="session/panel_right.png"
@ -337,7 +302,7 @@
size="0 0 100% 100%"
/>
<!-- Sides -->
<!-- sides -->
<image
texture="global/border/line_horiz.png"
texture_size="0 0 64 4"
@ -359,7 +324,7 @@
size="0 4 4 100%-4"
/>
<!-- Corners -->
<!-- corners -->
<image
texture="global/border/line_corner_top_right.png"
texture_size="0 0 4 4"
@ -381,89 +346,8 @@
size="0 0 4 4"
/>
</sprite>
<sprite name="lightPanel">
<!-- (currently this is all a hack - need proper textures) -->
<image
texture="global/tile/tile_light.png"
texture_size="0 0 256 256"
/>
<image
texture="global/titlebar/middle_gold_fern.dds"
real_texture_placement="0 4 64 6"
texture_size="0 0 64 32"
size="0 0 100% 3"
/>
<image
texture="global/titlebar/middle_gold_fern.dds"
real_texture_placement="0 4 64 6"
texture_size="0 0 64 32"
size="0 100%-3 100% 100%"
/>
<image
texture="global/border/corner_bronze.dds"
real_texture_placement="1 1 15 15"
texture_size="0 0 16 100%"
size="0 0 3 100%"
/>
<image
texture="global/border/corner_bronze.dds"
real_texture_placement="1 1 15 15"
texture_size="0 0 16 100%"
size="100%-3 0 100% 100%"
/>
</sprite>
<sprite name="darkPanel">
<!-- (currently this is all a hack - need proper textures) -->
<image
texture="global/tile/tile_dark.png"
texture_size="0 0 256 256"
/>
<image
texture="global/titlebar/middle_gold_fern.dds"
real_texture_placement="0 4 64 6"
texture_size="0 0 64 32"
size="0 0 100% 3"
/>
<image
texture="global/titlebar/middle_gold_fern.dds"
real_texture_placement="0 4 64 6"
texture_size="0 0 64 32"
size="0 100%-3 100% 100%"
/>
<image
texture="global/border/corner_bronze.dds"
real_texture_placement="1 1 15 15"
texture_size="0 0 16 100%"
size="0 0 3 100%"
/>
<image
texture="global/border/corner_bronze.dds"
real_texture_placement="1 1 15 15"
texture_size="0 0 16 100%"
size="100%-3 0 100% 100%"
/>
</sprite>
<!-- Older Panel Sprites -->
<sprite name="goldPanel">
<!-- (currently this is all a hack - need proper textures) -->
<image
@ -491,7 +375,7 @@
texture_size="0 0 128 128"
/>
</sprite>
<sprite name="goldPanelFrilly">
<!-- (currently this is all a hack - need proper textures) -->
<image
@ -660,7 +544,44 @@
size="100%-64 0% 100%+0 0%+30"
/>
</sprite>
<!-- ================================ ================================ -->
<!-- Shading -->
<!-- ================================ ================================ -->
<sprite name="glassSquareMap">
<image backcolor="255 255 255 56" size="0 0 100% 1"/>
<image backcolor="255 255 255 56" size="100%-1 1 100% 100%"/>
<image backcolor="255 255 255 56" size="0 100%-1 100% 100%"/>
<image backcolor="255 255 255 56" size="0 1 1 100%-1"/>
<image backcolor="255 255 255 44" size="1 1 100%-1 2"/>
<image backcolor="255 255 255 44" size="100%-2 2 100%-1 100%-1"/>
<image backcolor="255 255 255 44" size="1 100%-2 100%-1 100%-1"/>
<image backcolor="255 255 255 44" size="1 2 2 100%-2"/>
<image backcolor="255 255 255 32" size="2 2 100%-2 3"/>
<image backcolor="255 255 255 32" size="100%-3 3 100%-2 100%-2"/>
<image backcolor="255 255 255 32" size="2 100%-3 100%-2 100%-2"/>
<image backcolor="255 255 255 32" size="2 3 3 100%-3"/>
</sprite>
<sprite name="glassSquareIcon">
<image backcolor="255 255 255 128" size="0 0 100% 1"/>
<image backcolor="255 255 255 44" size="100%-1 1 100% 100%"/>
<image backcolor="255 255 255 44" size="0 100%-1 100% 100%"/>
<image backcolor="255 255 255 128" size="0 1 1 100%-1"/>
<image backcolor="255 255 255 96" size="1 1 100%-1 2"/>
<image backcolor="255 255 255 32" size="100%-2 2 100%-1 100%-1"/>
<image backcolor="255 255 255 32" size="1 100%-2 100%-1 100%-1"/>
<image backcolor="255 255 255 96" size="1 2 2 100%-2"/>
<image backcolor="255 255 255 64" size="2 2 100%-2 3"/>
<image backcolor="255 255 255 16" size="100%-3 3 100%-2 100%-2"/>
<image backcolor="255 255 255 16" size="2 100%-3 100%-2 100%-2"/>
<image backcolor="255 255 255 64" size="2 3 3 100%-3"/>
</sprite>
<sprite name="statsBarShader">
<image backcolor="0 0 0 192" size="0 0 100% 1"/>
<image backcolor="0 0 0 192" size="100%-1 1 100% 100%-1"/>
@ -678,21 +599,9 @@
<image backcolor="0 0 0 64" size="2 3 3 100%-3"/>
</sprite>
<sprite name="resourceBox">
<!--<image backcolor="0 0 0 128" size="0 0 100% 100%"/>-->
<image backcolor="0 0 0 192" size="2 0 100%-2 100%-2"/>
<image backcolor="255 255 255 64" size="100%-2 1 100%-1 100%-2"/>
<image backcolor="255 255 255 96" size="100%-1 0 100% 100%-1"/>
<image backcolor="255 255 255 64" size="1 100%-2 100%-1 100%-1"/>
<image backcolor="255 255 255 96" size="0 100%-1 100% 100%"/>
<image backcolor="255 255 255 64" size="1 1 2 100%-2"/>
<image backcolor="255 255 255 96" size="0 0 1 100%-1"/>
</sprite>
<!-- ================================ ================================ -->
<!-- Colored Bars -->
<!-- ================================ ================================ -->
<sprite name="queueProgressSlider">
<image backcolor="0 255 0 128"/>
</sprite>
@ -721,17 +630,9 @@
<image backcolor="blue"/>
</sprite>
<sprite name="bandbox">
<image backcolor="black" size="0 0 100% 1"/>
<image backcolor="black" size="100%-1 0 100% 100%"/>
<image backcolor="black" size="0 100%-1 100% 100%"/>
<image backcolor="black" size="0 0 1 100%"/>
<image backcolor="white" size="1 1 100%-1 2"/>
<image backcolor="white" size="100%-2 1 100%-1 100%-1"/>
<image backcolor="white" size="1 100%-2 100%-1 100%-1"/>
<image backcolor="white" size="1 1 2 100%-1"/>
</sprite>
<!-- ================================ ================================ -->
<!-- Chat -->
<!-- ================================ ================================ -->
<sprite name="chatInput">
<image backcolor="255 255 255 192" size="0 0 100% 1"/>
<image backcolor="255 255 255 192" size="100%-1 1 100% 100%-1"/>
@ -754,6 +655,20 @@
<sprite name="chatInputHighlight">
<image backcolor="255 165 0 192" size="-2 1 100% 100%+1"/>
</sprite>
<!-- ================================ ================================ -->
<!-- Misc -->
<!-- ================================ ================================ -->
<sprite name="bandbox">
<image backcolor="black" size="0 0 100% 1"/>
<image backcolor="black" size="100%-1 0 100% 100%"/>
<image backcolor="black" size="0 100%-1 100% 100%"/>
<image backcolor="black" size="0 0 1 100%"/>
<image backcolor="white" size="1 1 100%-1 2"/>
<image backcolor="white" size="100%-2 1 100%-1 100%-1"/>
<image backcolor="white" size="1 100%-2 100%-1 100%-1"/>
<image backcolor="white" size="1 1 2 100%-1"/>
</sprite>
<sprite name="devCommandsBackground">
<image backcolor="0 0 0 85"/>

View File

@ -1,148 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<styles>
<style name="goldPanel"
sprite="goldPanel"
buffer_zone="4"
text_align="left"
text_valign="top"
/>
<style name="goldPanelFrilly"
sprite="goldPanelFrilly"
buffer_zone="4"
text_align="center"
text_valign="center"
/>
<style name="frilly"
sprite="frilly"
buffer_zone="4"
text_align="center"
text_valign="center"
/>
<style name="sessionPanelLight"
sprite="lightPanel"
buffer_zone="2"
text_align="left"
text_valign="top"
/>
<style name="sessionPanelLight"
sprite="lightPanel"
buffer_zone="2"
text_align="left"
text_valign="top"
/>
<style name="sessionPanelDark"
sprite="darkPanel"
buffer_zone="2"
text_align="left"
text_valign="top"
/>
<style name="insetWheatWindow"
sprite="insetWheatWindow"
/>
<style name="resourcePanel"
size="50%-150 0 50%+150 32"
font="serif-bold-18"
sprite="titleBar"
text_align="center"
text_valign="center"
/>
<style name="statsText"
font="serif-bold-16"
text_valign="center"
ghost="true"
/>
<style name="resourceIcon"
sprite="snIconSheetResource"
ghost="true"
/>
<!--font="serif-bold-14"-->
<style name="resourceText"
textcolor="white"
font="serif-bold-stroke-14"
ghost="true"
text_align="left"
text_valign="center"
/>
<style name="resourceCounter"
tooltip_style="snToolTip"
/>
<style name="resourceCounter"
tooltip_style="snToolTip"
/>
<style name="formationIcon"
sprite="formation"
sprite_disabled="formation_disabled"
ghost="true"
/>
<style name="commandIcon"
sprite="commands"
ghost="true"
/>
<style name="iconButton"
sprite="snIconPortrait"
sprite_over="snIconPortraitOver"
sprite_disabled="snIconPortraitDisabled"
tooltip_style="snToolTipBottom"
/>
<style name="iconButtonCount"
textcolor="255 255 255"
font="serif-9"
text_align="right"
text_valign="top"
buffer_zone="4"
/>
<style name="iconButtonProgress"
textcolor="255 255 255"
font="serif-stroke-14"
text_align="center"
text_valign="center"
/>
<style name="groupIconsText"
font="serif-bold-stroke-14"
textcolor="white"
text_align="center"
text_valign="center"
/>
<style name="groupIconsCenteredText"
font="mono-stroke-10"
textcolor="255 255 255"
text_align="center"
text_valign="center"
/>
<style name="devCommandsText"
font="sans-10"
textcolor="255 255 255"
text_align="right"
/>
<style name="settingsText"
font="serif-16"
textcolor="white"
text_align="right"
text_valign="center"
/>
<!-- ================================ ================================ -->
<!-- Text Styles -->
<!-- ================================ ================================ -->
<style name="leftAlignedText"
textcolor="white"
text_align="left"
@ -175,14 +37,102 @@
text_valign="center"
/>
<style name="netStatus"
font="serif-bold-18"
<style name="iconButtonCount"
textcolor="255 255 255"
font="serif-9"
text_align="right"
text_valign="top"
buffer_zone="4"
/>
<style name="iconButtonProgress"
textcolor="255 255 255"
font="serif-stroke-14"
text_align="center"
text_valign="center"
/>
<style name="groupIconsText"
font="serif-bold-stroke-14"
textcolor="white"
text_align="center"
text_valign="center"
/>
<style name="groupIconsCenteredText"
font="mono-stroke-10"
textcolor="255 255 255"
text_align="center"
text_valign="center"
sprite="netStatusBackground"
/>
<style name="devCommandsText"
font="sans-10"
textcolor="255 255 255"
text_align="right"
/>
<style name="resourceText"
textcolor="white"
font="serif-bold-stroke-14"
ghost="true"
text_align="left"
text_valign="center"
/><!--font="serif-bold-14"-->
<style name="statsText"
font="serif-bold-16"
text_valign="center"
ghost="true"
/>
<style name="settingsText"
font="serif-16"
textcolor="white"
text_align="right"
text_valign="center"
/>
<!-- ================================ ================================ -->
<!-- Icon Styles -->
<!-- ================================ ================================ -->
<style name="resourceIcon"
sprite="snIconSheetResource"
ghost="true"
/>
<style name="formationIcon"
sprite="formation"
sprite_disabled="formation_disabled"
ghost="true"
/>
<style name="commandIcon"
sprite="commands"
ghost="true"
/>
<style name="iconButton"
sprite="snIconPortrait"
sprite_over="snIconPortraitOver"
sprite_disabled="snIconPortraitDisabled"
tooltip_style="snToolTipBottom"
/>
<!-- ================================ ================================ -->
<!-- Tooltip Styles -->
<!-- ================================ ================================ -->
<style name="resourceCounter"
tooltip_style="snToolTip"
/>
<style name="resourceCounter"
tooltip_style="snToolTip"
/>
<!-- ================================ ================================ -->
<!-- Misc Styles -->
<!-- ================================ ================================ -->
<style name="chatPanel"
buffer_zone="5"
font="serif-bold-stroke-14"
@ -207,4 +157,36 @@
text_valign="top"
/>
<style name="netStatus"
font="serif-bold-18"
textcolor="255 255 255"
text_align="center"
text_valign="center"
sprite="netStatusBackground"
/>
<!-- ================================ ================================ -->
<!-- Old Panel Styles -->
<!-- ================================ ================================ -->
<style name="goldPanel"
sprite="goldPanel"
buffer_zone="4"
text_align="left"
text_valign="top"
/>
<style name="goldPanelFrilly"
sprite="goldPanelFrilly"
buffer_zone="4"
text_align="center"
text_valign="center"
/>
<style name="frilly"
sprite="frilly"
buffer_zone="4"
text_align="center"
text_valign="center"
/>
</styles>

View File

@ -7,9 +7,10 @@ const TRAINING = "Training";
const CONSTRUCTION = "Construction";
const COMMAND = "Command";
// Constants used by the Queue or Garrison panel
const UNIT_PANEL_BASE = -52; // The offset above the main panel (will often be negative)
const UNIT_PANEL_HEIGHT = 44; // The height needed for a row of buttons
// Constants
const COMMANDS_PANEL_WIDTH = 228;
const UNIT_PANEL_BASE = -52; // QUEUE: The offset above the main panel (will often be negative)
const UNIT_PANEL_HEIGHT = 44; // QUEUE: The height needed for a row of buttons
// The number of currently visible buttons (used to optimise showing/hiding)
var g_unitPanelButtons = {"Selection": 0, "Queue": 0, "Formation": 0, "Garrison": 0, "Training": 0, "Construction": 0, "Command": 0};
@ -112,15 +113,12 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback)
{
usedPanels[guiName] = 1;
var numberOfItems = items.length;
var selection = g_Selection.toList();
var averageHealth = 0;
var maxHealth = 0;
if (guiName == "Selection")
{
if (numberOfItems > 12)
numberOfItems = 12;
if (numberOfItems > 15)
numberOfItems = 15;
}
if (guiName == "Formation" || guiName == "Garrison")
{
@ -161,29 +159,6 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback)
var tooltip = getEntityName(template);
var count = g_Selection.groups.getCount(item);
getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = (count > 1 ? count : "");
var entState = GetEntityState(selection[i])
if (entState)
{
if (entState.hitpoints)
{
averageHealth += entState.hitpoints*count;
maxHealth += entState.maxHitpoints*count;
}
}
if (i == numberOfItems-1)
{
var unitHealthBar = getGUIObjectByName("healthBar");
var healthSize = unitHealthBar.size;
healthSize.rtop = 100-100*Math.max(0, Math.min(1, averageHealth / maxHealth));
unitHealthBar.size = healthSize;
var hitpoints = "[font=\"serif-bold-13\"]Hitpoints [/font]" + averageHealth + "/" + maxHealth;
getGUIObjectByName("health").tooltip = hitpoints;
}
break;
case QUEUE:
@ -270,29 +245,30 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback)
}
}
// Position the visible buttons (TODO: if there's lots, maybe they should be squeezed together to fit)
var numButtons = i;
var rowLength = 8;
if (guiName == "Selection" || guiName == "Formation" || guiName == "Garrison")
rowLength = 4;
else if (guiName == "Command")
if (guiName == "Selection")
rowLength = 5;
else if (guiName == "Formation" || guiName == "Garrison" || guiName == "Command")
rowLength = 4;
var numRows = Math.ceil(numButtons / rowLength);
var buttonSideLength = getGUIObjectByName("unit"+guiName+"Button[0]").size.bottom;
var buttonSpacer = buttonSideLength+1;
// Layout buttons
if (guiName == "Command")
{
layoutButtonRowCentered(0, guiName, 0, numButtons, COMMANDS_PANEL_WIDTH);
}
else
{
for (var i = 0; i < numRows; i++)
layoutButtonRow(i, guiName, buttonSideLength, buttonSpacer, rowLength*i, rowLength*(i+1) );
}
// Resize Queue panel if needed
if (guiName == "Queue") // or garrison
{
@ -302,17 +278,6 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback)
panel.size = size;
}
// Layout buttons
if (guiName == "Command")
{
layoutButtonRowCentered(0, guiName, 0, numButtons, 228);
}
else
{
for (var i = 0; i < numRows; i++)
layoutButtonRow(i, guiName, buttonSideLength, buttonSpacer, rowLength*i, rowLength*(i+1) );
}
// Hide any buttons we're no longer using
for (i = numButtons; i < g_unitPanelButtons[guiName]; ++i)
getGUIObjectByName("unit"+guiName+"Button["+i+"]").hidden = true;