1
0
forked from 0ad/0ad

# Extensions and cleanups to session GUI files.

Add various GUI pieces (exit button, resource counts, unit details).
Clean up implementation of button panels.
Split some content out of 'common' and into page-specific files.
Delete some obsolete content.

This was SVN commit r7337.
This commit is contained in:
Ykkrosh 2010-02-28 21:45:09 +00:00
parent 633705c832
commit c8c10a4871
19 changed files with 2640 additions and 3148 deletions

File diff suppressed because it is too large Load Diff

View File

@ -209,22 +209,6 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
sprite_button_bottom_pressed="sprite2_pressed"
sprite_button_top_pressed="sprite2_pressed"
/>
<scrollbar name="atlas_scrollbar"
width="12"
minimum_bar_size="4"
alwaysshown="true"
sprite_button_top="atlas_global_button_up"
sprite_button_top_over="atlas_global_button_up_lit"
sprite_button_top_pressed="atlas_global_button_up_lit"
sprite_button_bottom="atlas_global_button_dn"
sprite_button_bottom_over="atlas_global_button_dn_lit"
sprite_button_bottom_pressed="atlas_global_button_dn_lit"
sprite_back_vertical="atlas_button"
sprite_bar_vertical="atlas_button"
sprite_bar_vertical_over="atlas_button_lit"
sprite_bar_vertical_pressed="atlas_button_lit"
/>

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,4 @@
<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>
<!DOCTYPE styles SYSTEM "..\gui.dtd">
<?xml version="1.0" encoding="utf-8"?>
<styles>
<!--
@ -427,404 +425,4 @@
tooltip="(TBA)"
/>
<!--
==========================================
- STYLE - UNIQUE
==========================================
-->
<!--
==========================================
- STYLE - UNIQUE - PREGAME
==========================================
-->
<style name="pgButton"
tooltip_style="pgToolTip"
tooltip=""
/>
<!--
==========================================
- STYLE - UNIQUE - SESSION
==========================================
-->
<style name="snObject"
tooltip_style="snToolTip"
tooltip=""
/>
<style name="snAction"
sprite="snIconCommand"
sprite_over="snIconCommandOver"
sprite_disabled="snIconCommandDisabled"
text_align="right"
textcolor="255 255 255"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<style name="snPortrait"
sprite="snIconPortrait"
sprite_over="snIconPortraitOver"
sprite_disabled="snIconPortraitDisabled"
text_align="right"
textcolor="255 255 255"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<style name="snPortraitProgress"
sprite_background=""
sprite_bar="bkTranslucent"
text_align="center"
text_valign="center"
textcolor="255 255 255"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<style name="snIcon"
ghost="true"
/>
<style name="snResourceIcon"
ghost="true"
sprite="snIconSheetResource"
z="100"
/>
<style name="snStat"
text_align="left"
text_valign="center"
font="tahoma14"
textcolor="white"
tooltip_style="snToolTip"
ghost="true"
/>
<style name="snCounter"
sprite="snCounter"
text_align="right"
text_valign="center"
font="tahoma14"
textcolor="white"
tooltip_style="snToolTip"
ghost="false"
/>
<style name="snStatusPane"
sprite="snStatusPane"
buffer_zone="10"
text_align="left"
text_valign="top"
/>
<style name="snMiniMapBorder"
sprite="snMiniMapBorder"
buffer_zone="10"
ghost="true"
text_align="left"
text_valign="top"
/>
<style name="snMiniMapArcLeft"
sprite="snIconArcLeft"
sprite_over="snIconArcLeftOver"
sprite_disabled="snIconArcLeftDisabled"
tooltip_style="snToolTip"
ghost="false"
enabled="false"
/>
<style name="snMiniMapArcUp"
sprite="snIconArcUp"
sprite_over="snIconArcUpOver"
sprite_disabled="snIconArcUpDisabled"
tooltip_style="snToolTip"
ghost="false"
enabled="false"
/>
<style name="snMiniMapButton"
text_align="left"
text_valign="center"
font="tahoma14"
textcolor="white"
tooltip_style="snToolTip"
sprite="snIconSheetMiniMapButton"
sprite_over="snIconSheetMiniMapButtonOver"
sprite_disabled="snIconSheetMiniMapButtonDisabled"
ghost="false"
enabled="false"
/>
<style name="snGreenBar"
sprite_background=""
sprite_bar="bkGreenBar"
ghost="true"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<style name="snBlueBar"
sprite_background=""
sprite_bar="bkBlueBar"
ghost="true"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<!--
NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED
NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED
-->
<!--
==========================================
- STYLE - UNIQUE - SESSION
==========================================
-->
<style name="control_group"
size="0 0 100% 100%"
/>
<style name="session_object"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<style name="session_button_object"
text_align="center"
text_valign="center"
sprite="wheatButton"
sprite_over="wheatButtonOver"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<style name="session_ghost_object"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
<style name="session_ghost_miniheading_object"
font="verdana8"
textcolor="200 200 200"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
<style name="session_ghost_subheading_object"
font="verdana10"
textcolor="200 200 200"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
<style name="session_ghost_subheading_center_object"
font="verdana10"
textcolor="200 200 200"
text_align="center"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
<style name="session_ghost_subheading_left_object"
font="verdana10"
textcolor="200 200 200"
text_align="left"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
<style name="session_ghost_midheading_object"
font="verdana11"
textcolor="255 255 255"
text_align="center"
text_valign="bottom"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
<style name="session_ghost_midheading_center_bottom_object"
font="verdana11"
textcolor="255 255 255"
text_align="center"
text_valign="bottom"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
<style name="session_ghost_heading_object"
font="verdana12"
textcolor="200 200 200"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
<style name="session_ghost_heading_left_object"
font="verdana12"
textcolor="200 200 200"
text_align="left"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
<style name="session_ghost_text_object"
font="verdana10"
textcolor="255 255 255"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
<style name="session_ghost_text_left_object"
font="verdana10"
textcolor="255 255 255"
text_align="left"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
<style name="session_ghost_text_left_centre_object"
font="verdana10"
textcolor="255 255 255"
text_align="left"
text_valign="center"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
<style name="portrait_progress"
sprite_background=""
sprite_bar="translucent_background"
text_align="center"
text_valign="center"
textcolor="255 255 255"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<style name="action"
sprite="ui_portrait_default_circle"
sprite_over="ui_portrait_default_circle_lit"
sprite_disabled="ui_portrait_default_circle_grey"
text_align="right"
textcolor="255 255 255"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<style name="action_left"
sprite="ui_portrait_default_circle"
sprite_over="ui_portrait_default_circle_lit"
sprite_disabled="ui_portrait_default_circle_grey"
text_align="left"
textcolor="255 255 255"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<!-- Entity progress bar. -->
<style name="group_portrait_bar"
sprite_background=""
sprite_bar="green_bar"
ghost="true"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<style name="up_bar"
sprite_background=""
sprite_bar="yellow_bar"
ghost="true"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<style name="blue_bar"
sprite_background=""
sprite_bar="blue_bar"
ghost="true"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<style name="blue_bar_outlined"
sprite_background="bkBorderBlack"
sprite_bar="blue_bar_outlined"
ghost="true"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<style name="globalMessageStyle"
hidden="true"
text_align="left"
text_valign="top"
textcolor="255 255 255"
ghost="true"
font="trebuchet14b"
size="6 150 100% 30%"
/>
<!-- This is for creating a small 1px. shadow so the text is visible on the bright maps. -->
<style name="globalMessageStyleUnder"
hidden="true"
text_align="left"
text_valign="top"
textcolor="50 50 50"
ghost="true"
font="trebuchet14b"
size="5 150 100% 30%"
/>
<style name="PlayersListStyle"
hidden="true"
text_align="right"
text_valign="bottom"
textcolor="white"
ghost="true"
font="trebuchet14b"
size="100%-500 100%-320 100% 100%-180"
/>
<style name="PlayersListStyleShadow"
hidden="true"
text_align="right"
text_valign="bottom"
textcolor="50 50 50"
ghost="true"
font="trebuchet14b"
size="100%-500 100%-320 100% 100%-180"
/>
<style name="PlayerStyle"
ghost="true"
textcolor="white"
text_align="right"
font="trebuchet14b"
/>
<style name="PlayerStyleShadow"
ghost="true"
textcolor="50 50 50"
text_align="right"
font="trebuchet14b"
/>
</styles>

View File

@ -4,6 +4,8 @@
<include>common/styles.xml</include>
<include>common/sprite1.xml</include>
<include>common/init.xml</include>
<include>pregame/sprites.xml</include>
<include>pregame/styles.xml</include>
<include>pregame/mainmenu.xml</include>
<include>common/global.xml</include>
</page>

View File

@ -4,6 +4,9 @@
<include>common/styles.xml</include>
<include>common/sprite1.xml</include>
<include>common/init.xml</include>
<include>common/icon_sprites.xml</include>
<include>session/sprites.xml</include>
<include>session/styles.xml</include>
<include>session/session.xml</include>
<include>session/manual.xml</include>
<include>common/global.xml</include>

View File

@ -4,6 +4,7 @@
<include>common/styles.xml</include>
<include>common/sprite1.xml</include>
<include>common/init.xml</include>
<include>common/icon_sprites.xml</include>
<include>session_new/sprites.xml</include>
<include>session_new/styles.xml</include>
<include>session_new/session.xml</include>

View File

@ -0,0 +1,177 @@
<?xml version="1.0" encoding="utf-8"?>
<sprites>
<!--
==========================================
PREGAME GUI - TEXTURE SPRITES - BACKDROPS
==========================================
-->
<sprite name="pgBackground">
<image texture="pregame/shell/parchment/background.dds"
real_texture_placement="0 0 1024 768"
size="0 0 100% 100%"
/>
</sprite>
<!--
==========================================
PREGAME GUI - TEXTURE SPRITES - LOGOS
==========================================
-->
<sprite name="pgProductLogo">
<image texture="pregame/shell/logo/product.dds"
real_texture_placement="0 0 480 218"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="pgCompanyLogo">
<image texture="pregame/shell/logo/company.dds"
real_texture_placement="0 0 256 64"
size="0 0 100% 100%"
/>
</sprite>
<!--
==========================================
PREGAME GUI - TEXTURE SPRITES - BUTTONS
==========================================
-->
<sprite name="pgSinglePlayerOver">
<image texture="pregame/shell/parchment/singleplayer_over.dds"
real_texture_placement="0 0 256 256"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="pgMultiPlayerOver">
<image texture="pregame/shell/parchment/multiplayer_over.dds"
real_texture_placement="0 0 256 256"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="pgEditorOver">
<image texture="pregame/shell/parchment/scenarioeditor_over.dds"
real_texture_placement="0 0 256 256"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="pgCampaignsOver">
<image texture="pregame/shell/parchment/campaigns_over.dds"
real_texture_placement="0 0 256 256"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="pgOptionsOver">
<image texture="pregame/shell/parchment/options_over.dds"
real_texture_placement="0 0 256 256"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="pgHistoryOver">
<image texture="pregame/shell/parchment/history_over.dds"
real_texture_placement="0 0 256 256"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="pgSinglePlayerDisabled">
<effect grayscale="" />
<image texture="pregame/shell/parchment/singleplayer_over.dds"
real_texture_placement="0 0 256 256"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="pgMultiPlayerDisabled">
<effect grayscale="" />
<image texture="pregame/shell/parchment/multiplayer_over.dds"
real_texture_placement="0 0 256 256"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="pgEditorDisabled">
<effect grayscale="" />
<image texture="pregame/shell/parchment/scenarioeditor_over.dds"
real_texture_placement="0 0 256 256"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="pgCampaignsDisabled">
<effect grayscale="" />
<image texture="pregame/shell/parchment/campaigns_over.dds"
real_texture_placement="0 0 256 256"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="pgOptionsDisabled">
<effect grayscale="" />
<image texture="pregame/shell/parchment/options_over.dds"
real_texture_placement="0 0 256 256"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="pgHistoryDisabled">
<effect grayscale="" />
<image texture="pregame/shell/parchment/history_over.dds"
real_texture_placement="0 0 256 256"
size="0 0 100% 100%"
/>
</sprite>
<!--
==========================================
CIV EMBLEMS
==========================================
-->
<sprite name="snEmblemCelt">
<image texture="session/portraits/emblems/celt.dds"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="snEmblemHele">
<image texture="session/portraits/emblems/hele.dds"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="snEmblemIber">
<image texture="session/portraits/emblems/iber.dds"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="snEmblemKart">
<image texture="session/portraits/emblems/kart.dds"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="snEmblemPers">
<image texture="session/portraits/emblems/pers.dds"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="snEmblemRome">
<image texture="session/portraits/emblems/rome.dds"
size="0 0 100% 100%"
/>
</sprite>
</sprites>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<styles>
<style name="pgButton"
tooltip_style="pgToolTip"
tooltip=""
/>
</styles>

View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<sprites>
<!--
==========================================
RESOURCE COUNTER
==========================================
-->
<sprite name="snCounter">
<image texture="session/counter_tile.dds"
real_texture_placement="0 0 32 32"
size="0%+32 0% 100%-32 0%+32"
/>
<image texture="session/counter_edge.dds"
real_texture_placement="0 0 32 32"
size="100%-32 0% 100% 0%+32"
/>
<image texture="session/counter_icon.dds"
real_texture_placement="0 0 32 32"
size="0% 0% 0%+32 0%+32"
/>
</sprite>
<!--
==========================================
STATUS PANE
==========================================
-->
<sprite name="snStatusPane">
<image texture="session/status_pane.dds"
size="0 0 100% 100%"
/>
</sprite>
<!--
==========================================
STATUS PANE CIVILISATION OVERLAYS
==========================================
-->
<sprite name="snStatusPaneEmblemCart">
<image texture="session/status_pane_cart.dds"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="snStatusPaneEmblemCelt">
<image texture="session/status_pane_celt.dds"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="snStatusPaneEmblemHele">
<image texture="session/status_pane_hele.dds"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="snStatusPaneEmblemIber">
<image texture="session/status_pane_iber.dds"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="snStatusPaneEmblemPers">
<image texture="session/status_pane_pers.dds"
size="0 0 100% 100%"
/>
</sprite>
<sprite name="snStatusPaneEmblemRome">
<image texture="session/status_pane_rome.dds"
size="0 0 100% 100%"
/>
</sprite>
<!--
==========================================
MINIMAP
==========================================
-->
<sprite name="snMiniMapBorder">
<image texture="session/minimap_pane.dds"
real_texture_placement="0 0 174 172"
size="0 0 100% 100%"
/>
</sprite>
</sprites>

View File

@ -0,0 +1,186 @@
<?xml version="1.0" encoding="utf-8"?>
<styles>
<style name="snObject"
tooltip_style="snToolTip"
tooltip=""
/>
<style name="snAction"
sprite="snIconCommand"
sprite_over="snIconCommandOver"
sprite_disabled="snIconCommandDisabled"
text_align="right"
textcolor="255 255 255"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<style name="snPortrait"
sprite="snIconPortrait"
sprite_over="snIconPortraitOver"
sprite_disabled="snIconPortraitDisabled"
text_align="right"
textcolor="255 255 255"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<style name="snPortraitProgress"
sprite_background=""
sprite_bar="bkTranslucent"
text_align="center"
text_valign="center"
textcolor="255 255 255"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<style name="snIcon"
ghost="true"
/>
<style name="snResourceIcon"
ghost="true"
sprite="snIconSheetResource"
z="100"
/>
<style name="snStat"
text_align="left"
text_valign="center"
font="tahoma14"
textcolor="white"
tooltip_style="snToolTip"
ghost="true"
/>
<style name="snCounter"
sprite="snCounter"
text_align="right"
text_valign="center"
font="tahoma14"
textcolor="white"
tooltip_style="snToolTip"
ghost="false"
/>
<style name="snStatusPane"
sprite="snStatusPane"
buffer_zone="10"
text_align="left"
text_valign="top"
/>
<style name="snMiniMapBorder"
sprite="snMiniMapBorder"
buffer_zone="10"
ghost="true"
text_align="left"
text_valign="top"
/>
<style name="snMiniMapArcLeft"
sprite="snIconArcLeft"
sprite_over="snIconArcLeftOver"
sprite_disabled="snIconArcLeftDisabled"
tooltip_style="snToolTip"
ghost="false"
enabled="false"
/>
<style name="snMiniMapArcUp"
sprite="snIconArcUp"
sprite_over="snIconArcUpOver"
sprite_disabled="snIconArcUpDisabled"
tooltip_style="snToolTip"
ghost="false"
enabled="false"
/>
<style name="snMiniMapButton"
text_align="left"
text_valign="center"
font="tahoma14"
textcolor="white"
tooltip_style="snToolTip"
sprite="snIconSheetMiniMapButton"
sprite_over="snIconSheetMiniMapButtonOver"
sprite_disabled="snIconSheetMiniMapButtonDisabled"
ghost="false"
enabled="false"
/>
<style name="snGreenBar"
sprite_background=""
sprite_bar="bkGreenBar"
ghost="true"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<style name="snBlueBar"
sprite_background=""
sprite_bar="bkBlueBar"
ghost="true"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<style name="globalMessageStyle"
hidden="true"
text_align="left"
text_valign="top"
textcolor="255 255 255"
ghost="true"
font="trebuchet14b"
size="6 150 100% 30%"
/>
<!-- This is for creating a small 1px. shadow so the text is visible on the bright maps. -->
<style name="globalMessageStyleUnder"
hidden="true"
text_align="left"
text_valign="top"
textcolor="50 50 50"
ghost="true"
font="trebuchet14b"
size="5 150 100% 30%"
/>
<style name="PlayersListStyle"
hidden="true"
text_align="right"
text_valign="bottom"
textcolor="white"
ghost="true"
font="trebuchet14b"
size="100%-500 100%-320 100% 100%-180"
/>
<style name="PlayersListStyleShadow"
hidden="true"
text_align="right"
text_valign="bottom"
textcolor="50 50 50"
ghost="true"
font="trebuchet14b"
size="100%-500 100%-320 100% 100%-180"
/>
<style name="PlayerStyle"
ghost="true"
textcolor="white"
text_align="right"
font="trebuchet14b"
/>
<style name="PlayerStyleShadow"
ghost="true"
textcolor="50 50 50"
text_align="right"
font="trebuchet14b"
/>
</styles>

View File

@ -1,6 +1,17 @@
function init()
function init(initData, hotloadData)
{
updateDebug();
if (hotloadData)
{
g_Selection = hotloadData.selection;
}
onSimulationUpdate();
}
// Return some data that we'll use when hotloading this file after changes
function getHotloadData()
{
return { selection: g_Selection };
}
function onTick()
@ -10,22 +21,63 @@ function onTick()
function onSimulationUpdate()
{
updateDebug();
var simState = Engine.GuiInterfaceCall("GetSimulationState");
// If we're called during init when the game is first loading, there will be
// no simulation yet, so do nothing
if (!simState)
return;
// updateDebug(simState);
updatePlayerDisplay(simState);
updateUnitDisplay();
}
function updateDebug()
function updateDebug(simState)
{
var debug = getGUIObjectByName("debug");
var simState = Engine.GuiInterfaceCall("GetSimulationState");
var text = uneval(simState);
var selection = getEntitySelection();
if (selection.length)
{
var entState = Engine.GuiInterfaceCall("GetEntityState", selection[0]);
var template = Engine.GuiInterfaceCall("GetTemplateData", entState.template);
text += "\n\n" + uneval(entState) + "\n\n" + uneval(template);
}
debug.caption = text;
}
function updatePlayerDisplay(simState)
{
var playerState = simState.players[Engine.GetPlayerID()];
getGUIObjectByName("resourceFood").caption = playerState.resourceCounts.food;
getGUIObjectByName("resourceWood").caption = playerState.resourceCounts.wood;
getGUIObjectByName("resourceStone").caption = playerState.resourceCounts.stone;
getGUIObjectByName("resourceMetal").caption = playerState.resourceCounts.metal;
getGUIObjectByName("resourcePop").caption = playerState.popCount + "/" + playerState.popLimit;
}
function damageTypesToText(dmg)
{
if (!dmg)
return "(None)";
return dmg.hack + " Hack\n" + dmg.pierce + " Pierce\n" + dmg.crush + " Crush";
}
var g_unitConstructionButtons = 0; // the number currently visible
// The unitSomethingPanel objects, which are displayed in a stack at the bottom of the screen,
// ordered with *lowest* first
var g_unitPanels = ["Stance", "Formation", "Construction", "Research", "Training", "Queue"];
function updateUnitDisplay()
{
var detailsPanel = getGUIObjectByName("unitDetails");
var detailsPanel = getGUIObjectByName("selectionDetails");
var commandsPanel = getGUIObjectByName("unitCommands");
var selection = getEntitySelection();
@ -40,33 +92,107 @@ function updateUnitDisplay()
var template = Engine.GuiInterfaceCall("GetTemplateData", entState.template);
detailsPanel.hidden = false;
detailsPanel.caption = uneval(entState)+"\n\n"+uneval(template);
commandsPanel.hidden = false;
var i = 0;
for each (var build in entState.buildEntities)
getGUIObjectByName("selectionDetailsIcon").sprite = "snPortraitSheetHele";
getGUIObjectByName("selectionDetailsIcon").cell_id = template.icon_cell;
var healthSize = getGUIObjectByName("selectionDetailsHealthBar").size;
healthSize.rright = 100*Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints));
getGUIObjectByName("selectionDetailsHealthBar").size = healthSize;
getGUIObjectByName("selectionDetailsHealth").tooltip = "Hitpoints " + entState.hitpoints + " / " + entState.maxHitpoints;
getGUIObjectByName("selectionDetailsSpecific").caption = template.name.specific;
if (template.name.generic == template.name.specific)
{
var button = getGUIObjectByName("cButton"+i);
var icon = getGUIObjectByName("cIcon"+i);
var template = Engine.GuiInterfaceCall("GetTemplateData", build);
var name;
if (template.name.specific && template.name.generic)
name = template.name.specific + " (" + template.name.generic + ")";
else
name = template.name.specific || template.name.generic || "???";
button.hidden = false;
button.tooltip = "Construct " + name;
button.onpress = (function(b) { return function() { testBuild(b) } })(build);
// (need nested functions to get the closure right)
icon.sprite = "snPortraitSheetHele";
icon.cell_id = template.name.icon_cell;
++i;
getGUIObjectByName("selectionDetailsGeneric").hidden = true;
}
else
{
getGUIObjectByName("selectionDetailsGeneric").hidden = false;
getGUIObjectByName("selectionDetailsGeneric").caption = template.name.generic;
}
getGUIObjectByName("selectionDetailsAttack").caption = damageTypesToText(entState.attack);
getGUIObjectByName("selectionDetailsArmour").caption = damageTypesToText(entState.armour);
var usedPanels = {};
if (entState.attack) // TODO - this should be based on some AI properties
{
usedPanels["Stance"] = 1;
usedPanels["Formation"] = 1;
}
else // TODO - this should be based on various other things
{
usedPanels["Queue"] = 1;
usedPanels["Training"] = 1;
usedPanels["Research"] = 1;
}
// Set up the unit construction buttons
// (TODO: abstract this to apply to the other button panels)
if (entState.buildEntities && entState.buildEntities.length)
{
usedPanels["Construction"] = 1;
var i = 0;
for each (var build in entState.buildEntities)
{
var button = getGUIObjectByName("unitConstructionButton["+i+"]");
var icon = getGUIObjectByName("unitConstructionIcon["+i+"]");
var template = Engine.GuiInterfaceCall("GetTemplateData", build);
var name;
if (template.name.specific && template.name.generic)
name = template.name.specific + " (" + template.name.generic + ")";
else
name = template.name.specific || template.name.generic || "???";
button.hidden = false;
button.tooltip = "Construct " + name;
button.onpress = (function(b) { return function() { testBuild(b) } })(build);
// (need nested functions to get the closure right)
icon.sprite = "snPortraitSheetHele";
icon.cell_id = template.icon_cell;
++i;
}
var numButtons = i;
// Position the visible buttons
// (TODO: if there's lots, maybe they should be squeezed together to fit)
for (i = 0; i < numButtons; ++i)
{
var button = getGUIObjectByName("unitConstructionButton["+i+"]");
var size = button.size;
size.left = 40*i;
size.right = 40*i + size.bottom;
button.size = size;
}
// Hide any buttons we're no longer using
for (i = numButtons; i < g_unitConstructionButtons; ++i)
getGUIObjectByName("unitConstructionButton["+i+"]").hidden = true;
g_unitConstructionButtons = numButtons;
}
var offset = 0;
for each (var panelName in g_unitPanels)
{
var panel = getGUIObjectByName("unit"+panelName+"Panel");
if (usedPanels[panelName])
{
var size = panel.size;
var h = size.bottom - size.top;
size.bottom = offset;
size.top = offset - h;
panel.size = size;
panel.hidden = false;
offset -= (h + 12);
}
else
{
panel.hidden = true;
}
}
for (; i < 8; ++i)
getGUIObjectByName("cButton"+i).hidden = true;
}

View File

@ -2,27 +2,7 @@
<objects>
<!--
<script file="gui/common/functions_utility.js" />
<script file="gui/common/functions_utility_list.js" />
<script file="gui/common/functions_utility_object.js" />
<script file="gui/common/functions_utility_coord.js" />
<script file="gui/common/functions_utility_music.js" />
<script file="gui/common/functions_utility_animation.js" />
-->
<script file="gui/common/functions_global_object.js" />
<!--
<script file="gui/common/functions_page_pregame.js" />
<script file="gui/common/functions_page_pregame_multiplayer.js" />
<script file="gui/common/functions_page_pregame_setup.js" />
<script file="gui/common/functions_page_pregame_load.js" />
<script file="gui/common/functions_page_session.js"/>
<script file="gui/common/functions_page_session_status_pane.js" />
<script file="gui/common/functions_page_session_status_commands.js" />
<script file="gui/common/functions_page_session_manual.js" />
<script file="gui/common/functions_sim_player.js"/>
<script file="gui/common/functions_sim_entity.js"/>
-->
<script file="gui/session_new/session.js"/>
<script file="gui/session_new/selection.js"/>
<script file="gui/session_new/input.js"/>
@ -44,8 +24,13 @@
this.hidden = !this.hidden;
</action>
<!-- Exit hotkey -->
<object name="leave" hotkey="leave">
<!-- Exit button -->
<object type="button" style="wheatExit"
size="100%-16 0 100% 16"
tooltip_style="snToolTip"
tooltip="Exit game"
hotkey="leave"
>
<action on="Press"><![CDATA[
messageBox(400, 200, "Do you really want to quit?", "Confirmation", 0,
["Yes", "No!"], [confirmLeave, null]);
@ -55,84 +40,172 @@
<!-- Debug text -->
<object name="debug"
type="text"
size="0 0 50% 100%"
size="0 50 50% 100%"
ghost="true"
textcolor="yellow"
font="console"
/>
<!-- Player resource bar -->
<object
size="50%-200 0 50%+200 30"
type="image"
style="goldPanelFrilly"
>
[default debug text]
<!-- Food -->
<object size="0 0 18% 100%" type="image" style="resourceCounter" tooltip="Food">
<object size="0 0 28 28" type="image" style="resourceIcon" cell_id="0"/>
<object size="24 4 100% 32" type="text" style="resourceText" name="resourceFood"/>
</object>
<!-- Wood -->
<object size="18% 0 36% 100%" type="image" style="resourceCounter" tooltip="Wood">
<object size="0 0 28 28" type="image" style="resourceIcon" cell_id="1"/>
<object size="24 4 100% 32" type="text" style="resourceText" name="resourceWood"/>
</object>
<!-- Stone -->
<object size="36% 0 54% 100%" type="image" style="resourceCounter" tooltip="Stone">
<object size="0 0 28 28" type="image" style="resourceIcon" cell_id="2"/>
<object size="24 4 100% 32" type="text" style="resourceText" name="resourceStone"/>
</object>
<!-- Metal -->
<object size="54% 0 72% 100%" type="image" style="resourceCounter" tooltip="Metal">
<object size="0 0 28 28" type="image" style="resourceIcon" cell_id="3"/>
<object size="24 4 100% 32" type="text" style="resourceText" name="resourceMetal"/>
</object>
<!-- Population -->
<object size="72% 0 100% 100%" type="image" style="resourceCounter" tooltip="Population (current / maximum)">
<object size="0 0 28 28" type="image" style="resourceIcon" cell_id="4"/>
<object size="24 4 100% 32" type="text" style="resourceText" name="resourcePop"/>
</object>
</object>
<!-- Bottom-left selected-unit details panel -->
<object name="unitDetails"
<object name="selectionDetails"
type="image"
style="goldPanel"
size="0 100%-250 300 100%"
type="text"
hidden="true"
>
[unit details]
<!-- Big unit icon -->
<object size="8 8 136 136">
<object type="image" style="selectionDetailsIconOutline"/>
<object type="image" name="selectionDetailsIcon" ghost="true"/>
</object>
<!-- Health bar -->
<object size="8 138 136 144" 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>
<!-- Stamina bar -->
<object size="8 146 136 152" 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>
<!-- Details text -->
<object size="136 6 100% 100%">
<object size="0 0 100% 20" name="selectionDetailsSpecific" type="text" font="prospero18b"/>
<object size="0 20 100% 40" name="selectionDetailsGeneric" type="text" font="prospero16"/>
<object size="0 40 100% 60" name="selectionDetailsPlayer" type="text" font="prospero16" textcolor="blue">Wijitmaker</object>
</object>
<!-- Attack stats -->
<object size="146 72 100% 130" type="image" tooltip="Attack strengths" tooltip_style="snToolTip">
<object size="-4 -8 48 48" type="image" ghost="true" sprite="snIconSheetStance" cell_id="1"/>
<object size="40 0 100% 100%" type="text" ghost="true" name="selectionDetailsAttack" font="tahoma12"/>
</object>
<!-- Armour stats -->
<object size="146 130 100% 188" type="image" tooltip="Armour strengths" tooltip_style="snToolTip">
<object size="-4 -4 48 48" type="image" ghost="true" sprite="snIconSheetStance" cell_id="3"/>
<object size="40 0 100% 100%" type="text" ghost="true" name="selectionDetailsArmour" font="tahoma12"/>
</object>
</object>
<!-- Bottom-middle selected-unit commands panel -->
<object name="unitCommands"
size="350 100%-204 100%-300 100%"
size="350 0 100%-300 100%-8"
>
<object name="unitConstructionPanel"
style="goldPanelFrilly"
size="0 0 100% 56"
size="0 100%-56 100% 100%"
type="image"
>
<object size="50%-159 10 50%+159 47">
<object size="-5 -2 59 62" type="image" sprite="snIconSheetTab" tooltip_style="snToolTip"
cell_id="0" tooltip="Construction"/>
<!-- TODO: need a better way to do this. Perhaps something like
<object name="buttons" type="repeater" count="8" sizedelta="40 0 0 0">
<object type="button" .../>
<object size="59 10 100% 47">
<repeat count="16">
<object name="unitConstructionButton[n]" hidden="true" style="iconButton" type="button" size="0 0 37 37">
<object name="unitConstructionIcon[n]" type="image" ghost="true" size="3 3 35 35"/>
</object>
</repeat>
</object>
where a script can change the count dynamically?
-->
<object name="cButton0" style="iconButton" type="button" size="0 0 37 37">
<object name="cIcon0" type="image" ghost="true" size="3 3 35 35"/>
</object>
<object name="cButton1" style="iconButton" type="button" size="40 0 77 37">
<object name="cIcon1" type="image" ghost="true" size="3 3 35 35"/>
</object>
<object name="cButton2" style="iconButton" type="button" size="80 0 117 37">
<object name="cIcon2" type="image" ghost="true" size="3 3 35 35"/>
</object>
<object name="cButton3" style="iconButton" type="button" size="120 0 157 37">
<object name="cIcon3" type="image" ghost="true" size="3 3 35 35"/>
</object>
<object name="cButton4" style="iconButton" type="button" size="160 0 197 37">
<object name="cIcon4" type="image" ghost="true" size="3 3 35 35"/>
</object>
<object name="cButton5" style="iconButton" type="button" size="200 0 237 37">
<object name="cIcon5" type="image" ghost="true" size="3 3 35 35"/>
</object>
<object name="cButton6" style="iconButton" type="button" size="240 0 277 37">
<object name="cIcon6" type="image" ghost="true" size="3 3 35 35"/>
</object>
<object name="cButton7" style="iconButton" type="button" size="280 0 317 37">
<object name="cIcon7" type="image" ghost="true" size="3 3 35 35"/>
</object>
</object>
</object>
<object name="unitFormationPanel"
style="goldPanelFrilly"
size="0 72 100% 128"
type="text"
>
[formation commands]
</object>
<object name="unitStancePanel"
style="goldPanelFrilly"
size="0 144 100% 200"
size="0 100%-56 100% 100%"
type="text"
>
[stance commands]
<object size="-5 -2 59 62" type="image" sprite="snIconSheetTab" tooltip_style="snToolTip"
cell_id="4" tooltip="Stances"/>
[stance commands]
</object>
<object name="unitFormationPanel"
style="goldPanelFrilly"
size="0 100%-56 100% 100%"
type="text"
>
<object size="-5 -2 59 62" type="image" sprite="snIconSheetTab" tooltip_style="snToolTip"
cell_id="5" tooltip="Formations"/>
[formation commands]
</object>
<object name="unitResearchPanel"
style="goldPanelFrilly"
size="0 100%-56 100% 100%"
type="text"
>
<object size="-5 -2 59 62" type="image" sprite="snIconSheetTab" tooltip_style="snToolTip"
cell_id="1" tooltip="Research"/>
[research commands]
</object>
<object name="unitTrainingPanel"
style="goldPanelFrilly"
size="0 100%-56 100% 100%"
type="text"
>
<object size="-5 -2 59 62" type="image" sprite="snIconSheetTab" tooltip_style="snToolTip"
cell_id="2" tooltip="Training"/>
[training commands]
</object>
<object name="unitQueuePanel"
style="goldPanelFrilly"
size="0 100%-56 100% 100%"
type="text"
>
<object size="-5 -2 59 62" type="image" sprite="snIconSheetTab" tooltip_style="snToolTip"
cell_id="3" tooltip="Production queue"/>
[training/research queue]
</object>
</object>
@ -144,7 +217,6 @@
type="image"
/>
<object name="minimapDisplay"
style="snObject"
type="minimap"
size="100%-206 100%-206 100%-6 100%-6"
/>
@ -153,7 +225,3 @@
</object>
</objects>

View File

@ -67,5 +67,25 @@
/>
</sprite>
<sprite name="selectionDetailsIconOutline">
<image backcolor="blue"/>
</sprite>
<sprite name="selectionDetailsHealthBackground">
<image backcolor="red"/>
</sprite>
<sprite name="selectionDetailsHealthForeground">
<image backcolor="green"/>
</sprite>
<sprite name="selectionDetailsStaminaBackground">
<image backcolor="black"/>
</sprite>
<sprite name="selectionDetailsStaminaForeground">
<image backcolor="blue"/>
</sprite>
</sprites>

View File

@ -1,21 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<styles>
<style name="goldPanel"
<style name="goldPanel"
sprite="goldPanel"
buffer_zone="4"
text_align="left"
text_valign="top"
/>
<style name="goldPanelFrilly"
<style name="goldPanelFrilly"
sprite="goldPanelFrilly"
buffer_zone="4"
text_align="center"
text_valign="center"
/>
<style name="iconButton"
<style name="resourceIcon"
sprite="snIconSheetResource"
ghost="true"
/>
<style name="resourceText"
textcolor="black"
font="tahoma14"
ghost="true"
/>
<style name="resourceCounter"
tooltip_style="snToolTip"
/>
<style name="selectionDetailsIconOutline"
sprite="selectionDetailsIconOutline"
/>
<style name="iconButton"
sprite="snIconPortrait"
sprite_over="snIconPortraitOver"
sprite_disabled="snIconPortraitDisabled"

View File

@ -20,4 +20,14 @@ Armour.prototype.TakeDamage = function(hack, pierce, crush)
cmpHealth.Reduce(total);
};
Armour.prototype.GetArmourStrengths = function()
{
// Convert attack values to numbers, default 0 if unspecified
return {
hack: +(this.template.Hack || 0),
pierce: +(this.template.Pierce || 0),
crush: +(this.template.Crush || 0)
};
};
Engine.RegisterComponentType(IID_DamageReceiver, "Armour", Armour);

View File

@ -43,6 +43,7 @@ GuiInterface.prototype.GetEntityState = function(player, ent)
if (cmpHealth)
{
ret.hitpoints = cmpHealth.GetHitpoints();
ret.maxHitpoints = cmpHealth.GetMaxHitpoints();
}
var cmpAttack = Engine.QueryInterface(ent, IID_Attack);
@ -51,6 +52,12 @@ GuiInterface.prototype.GetEntityState = function(player, ent)
ret.attack = cmpAttack.GetAttackStrengths();
}
var cmpArmour = Engine.QueryInterface(ent, IID_DamageReceiver);
if (cmpArmour)
{
ret.armour = cmpArmour.GetArmourStrengths();
}
var cmpBuilder = Engine.QueryInterface(ent, IID_Builder);
if (cmpBuilder)
{
@ -92,10 +99,10 @@ GuiInterface.prototype.GetTemplateData = function(player, name)
if (template.Identity)
{
ret.name = {
"specific": template.Identity.SpecificName,
"generic": template.Identity.GenericName,
"icon_cell": template.Identity.IconCell
"specific": (template.Identity.SpecificName || template.Identity.GenericName),
"generic": template.Identity.GenericName
};
ret.icon_cell = template.Identity.IconCell;
}
return ret;
@ -109,12 +116,16 @@ GuiInterface.prototype.SetSelectionHighlight = function(player, cmd)
GuiInterface.prototype.SetBuildingPlacementPreview = function(player, cmd)
{
// See if we're changing template
if (!this.placementEntity || this.placementEntity[0] != cmd.template)
{
// Destroy the old preview if there was one
if (this.placementEntity)
Engine.DestroyEntity(this.placementEntity[1]);
// Load the new template
if (cmd.template == "")
{
if (this.placementEntity)
Engine.DestroyEntity(this.placementEntity[1]);
this.placementEntity = undefined;
}
else
@ -123,6 +134,7 @@ GuiInterface.prototype.SetBuildingPlacementPreview = function(player, cmd)
}
}
// Move the preview into the right location
if (this.placementEntity)
{
var pos = Engine.QueryInterface(this.placementEntity[1], IID_Position);

View File

@ -2,7 +2,7 @@ function Health() {}
Health.prototype.Init = function()
{
this.hitpoints = +this.template.Max;
this.hitpoints = this.GetMaxHitpoints();
};
Health.prototype.GetHitpoints = function()
@ -10,6 +10,11 @@ Health.prototype.GetHitpoints = function()
return this.hitpoints;
};
Health.prototype.GetMaxHitpoints = function()
{
return +this.template.Max;
};
Health.prototype.Reduce = function(amount)
{
if (amount >= this.hitpoints)

View File

@ -1,5 +1,6 @@
Engine.LoadComponentScript("interfaces/Attack.js");
Engine.LoadComponentScript("interfaces/Builder.js");
Engine.LoadComponentScript("interfaces/DamageReceiver.js");
Engine.LoadComponentScript("interfaces/Health.js");
Engine.LoadComponentScript("interfaces/ResourceGatherer.js");
Engine.LoadComponentScript("interfaces/ResourceSupply.js");
@ -42,9 +43,8 @@ AddMock(10, IID_Position, {
});
AddMock(10, IID_Health, {
GetHitpoints: function() {
return 50;
}
GetHitpoints: function() { return 50; },
GetMaxHitpoints: function() { return 60; },
});
AddMock(10, IID_Builder, {
@ -58,5 +58,6 @@ TS_ASSERT_UNEVAL_EQUALS(state, {
template: "example",
position: {x:1, y:2, z:3},
hitpoints: 50,
maxHitpoints: 60,
buildEntities: ["test1", "test2"]
});