1
0
forked from 0ad/0ad

Reimplemented session GUI refresh loop, with unit portrait as test subject. Fixed some broken things.

This was SVN commit r2666.
This commit is contained in:
Acumen 2005-09-05 03:21:20 +00:00
parent 7b144a11ca
commit 84a980a344
11 changed files with 287 additions and 98 deletions

View File

@ -167,8 +167,8 @@ hotkey.dudemachine.random = "Ctrl+ForwardSlash" ; Create random Dude.
; > OVERLAY KEYS
hotkey.fps.toggle = "Shift+F" ; Toggle frame counter.
hotkey.statusorb.toggle = "Shift+S" ; Toggle Status Orb.
hotkey.maporb.toggle = "Shift+M" ; Toggle Map Orb.
hotkey.session.statuspane.toggle = "Shift+S" ; Toggle Status Orb.
hotkey.session.minimap.toggle = "Shift+M" ; Toggle Map Orb.
hotkey.resourcepool.toggle = "Shift+R" ; Toggle Resource Pool.
hotkey.grouppane.toggle = "Shift+G" ; Toggle Group Pane.
hotkey.teamtray.toggle = "Shift+T" ; Toggle Team Tray.

View File

@ -46,6 +46,8 @@
<script file="gui/test/functions_page_session.js"/>
<script file="gui/test/functions_page_session_status_pane.js" />
<!--
==========================================
- INCLUDE SCRIPT - SIMULATION FUNCTIONS

View File

@ -95,10 +95,7 @@
sprite_over="pgCampaignsOver"
sprite_disabled="pgCampaignsDisabled"
tooltip="Want to play a campaign? Tough luck, buddy! That's right, go cry on your mamma's shoulder."
font="verdana12"
textcolor="white"
>Iš Kidón RakhúvÀÁÂÃÄÅÈÉÊËÒÓÔÕÖàáâãäåèéêëìíî
>
<action on="Press"><![CDATA[
openMainMenuSubWindow ("pgCampaigns");
]]></action>

View File

@ -18,6 +18,7 @@
guiToggle (this.name);
]]></action>
<!-- EMPTY OBJECT USED TO FLIP THE GUI TO VARIOUS ORIENTATIONS. -->
<object name="snFlip"
hotkey="session.gui.flip"
>
@ -26,9 +27,11 @@
]]></action>
</object>
<!-- GROUP: MINIMAP -->
<object name="snMiniMap"
style="session_minimap"
type="minimap"
hotkey="session.minimap.toggle"
>
<action on="Load"><![CDATA[
addCrd (this.name, rb, 100, 100, 0, 0, 180, 180);
@ -36,6 +39,43 @@
addCrd (this.name, lt, 0, 0);
addCrd (this.name, rt, 100, 0);
]]></action>
<action on="Press"><![CDATA[
guiToggle (this.name);
]]></action>
</object>
<!-- GROUP: STATUS PANE -->
<object name="snStatusPane"
style="skin*Hele*Window"
type="image"
hotkey="session.statuspane.toggle"
>
<action on="Load"><![CDATA[
addCrd (this.name, rb, 0, 100, 0, 0, 200, 120);
addCrd (this.name, lb, 100, 100);
addCrd (this.name, lt, 100, 0);
addCrd (this.name, rt, 0, 0);
]]></action>
<action on="Press"><![CDATA[
guiToggle (this.name);
]]></action>
<object name="snStatusPanePortrait"
style="portrait"
type="button"
hotkey="selection.snap"
>
<action on="Load"><![CDATA[
addCrd (this.name, rb, 0, 0, 5, 5, 64, 64);
]]></action>
<action on="Press"><![CDATA[
// Focus the camera on the unit when his portrait is clicked.
if (selection[0].position)
setCameraTarget(selection[0].position);
]]></action>
</object>
</object>
</object>

View File

@ -137,7 +137,7 @@ function setupSession ()
// will be replaced soon by native version that doesn't block.
// Start refreshing the session controls.
// setInterval( getObjectInfo, 1, 100 );
setInterval( snRefresh, 1, 100 );
}
// ====================================================================
@ -160,6 +160,9 @@ function endSession (closeType)
// janwas: greatly accelerate this timesink;
// will be replaced soon by native version that doesn't block.
// Stop refreshing the session controls.
cancelInterval();
// Swap GUIs to display main menu.
guiSwitch ("sn", "pg");
break;

View File

@ -124,65 +124,6 @@ function setPortrait(objectName, portraitString, portraitSuffix, portraitCell)
// ====================================================================
function getObjectInfo()
{
// Updated each tick to extract entity information from selected unit(s).
// Don't process GUI when we're full-screen.
if (GUIType != "none")
{
if (!selection.length) // If no entity selected,
{
// Hide Status Orb
getGUIObjectByName("session_status_orb").hidden = true;
// Hide Group Pane.
getGUIObjectByName("session_group_pane").hidden = true;
getGlobal().MultipleEntitiesSelected = 0;
}
else // If at least one entity selected,
{
// Store globals for entity information.
// strString = "" + selection[0].position;
// EntityPos = strString.substring(20,strString.length-3);
UpdateStatusOrb(); // (later, we need to base this on the selected unit's stats changing)
// Check if a group of entities selected
if (selection.length > 1)
{
// If a group pane isn't already open, and we don't have the same set as last time,
// NOTE: This "if" is an optimisation because the game crawls if this set of processing occurs every frame.
// It's quite possible for the player to select another group of the same size and for it to not be recognised.
// Best solution would be to base this off a "new entities selected" instead of an on-tick.
if (
// getGUIObjectByName("session_group_pane").hidden == true ||
selection.length != getGlobal().MultipleEntitiesSelected)
{
UpdateGroupPane(); // (later, we need to base this on the selection changing)
getGlobal().MultipleEntitiesSelected = selection.length;
}
}
else
{
getGlobal().MultipleEntitiesSelected = 0;
// Hide Group Pane.
getGUIObjectByName("session_group_pane").hidden = true;
}
}
// Modify any resources given/taken (later, we need to base this on a resource-changing event).
UpdateResourcePool();
// Update Team Tray (later, we need to base this on the player creating a group).
UpdateTeamTray();
}
}
// ====================================================================
function flipGUI (NewGUIType)
{
// Changes GUI to a different layout.
@ -222,3 +163,169 @@ function flipGUI (NewGUIType)
// ====================================================================
// Update-on-alteration trickery...
// We don't really want to update every single time we get a
// selection-changed or property-changed event; that could happen
// a lot. Instead, use this bunch of globals to cache any changes
// that happened between GUI updates.
// This boolean determines whether the selection has been changed.
var selectionChanged = false;
// This boolean determines what the template of the selected object
// was when last we looked
var selectionTemplate = null;
// This array holds the name of all properties that need to be updated
var selectionPropertiesChanged = new Array();
// This array holds a list of all the objects we hold property-change
// watches on
var propertyWatches = new Array();
// ====================================================================
// This function resets all the update variables, above
function resetUpdateVars()
{
if( selectionChanged )
{
for( watchedObject in propertyWatches )
propertyWatches[watchedObject].unwatchAll( selectionWatchHandler ); // Remove the handler
propertyWatches = new Array();
if( selection[0] )
{
// Watch the object itself
selection[0].watchAll( selectionWatchHandler );
propertyWatches.push( selection[0] );
// And every parent back up the tree (changes there will affect
// displayed properties via inheritance)
var parent = selection[0].template
while( parent )
{
parent.watchAll( selectionWatchHandler );
propertyWatches.push( selection[0] );
parent = parent.parent;
}
}
}
selectionChanged = false;
if( selection[0] )
{
selectionTemplate = selection[0].template;
}
else
selectionTemplate = null;
selectionPropertiesChanged = new Array();
}
// ====================================================================
// This function returns whether we should update a particular statistic
// in the GUI (e.g. "actions.attack") - this should happen if: the selection
// changed, the selection had its template altered (changing lots of stuff)
// or an assignment has been made to that stat or any property within that
// stat.
function shouldUpdateStat( statname )
{
if( selectionChanged || ( selectionTemplate != selection[0].template ) )
return( true );
for( var property in selectionPropertiesChanged )
{
// If property starts with statname
if( selectionPropertiesChanged[property].substring( 0, statname.length ) == statname )
return( true );
}
return( false );
}
// ====================================================================
// This function is a handler for the 'selectionChanged' event,
// it updates the selectionChanged flag
function selectionChangedHandler()
{
selectionChanged = true;
}
// ====================================================================
// Register it.
addGlobalHandler( "selectionChanged", selectionChangedHandler );
// ====================================================================
// This function is a handler for a watch event; it updates the
// selectionPropertiesChanged array.
function selectionWatchHandler( propname, oldvalue, newvalue )
{
selectionPropertiesChanged.push( propname );
// This bit's important (watches allow the handler to change the value
// before it gets written; we don't want to affect things, so make sure
// the value we send back is the one that was going to be written)
return( newvalue );
}
// ====================================================================
function snRefresh()
{
// Updated each tick to refresh session controls if necessary.
// Don't process GUI when we're full-screen.
if (getGUIObjectByName ("sn").hidden == false)
{
if (!selection.length) // If no entity selected,
{
// Hide Status Orb
guiHide ("snStatusPane");
// Hide Group Pane.
// guiHide ("snGroupPane");
getGlobal().MultipleEntitiesSelected = 0;
}
else // If at least one entity selected,
{
// Reveal Status Orb
guiUnHide ("snStatusPane");
// (later, we need to base this on the selected unit's stats changing)
refreshStatusPane();
// Check if a group of entities selected
if (selection.length > 1)
{
// If a group pane isn't already open, and we don't have the same set as last time,
if (selection.length != getGlobal().MultipleEntitiesSelected)
{
// (later, we need to base this on the selection changing)
// refreshGroupPane();
getGlobal().MultipleEntitiesSelected = selection.length;
}
}
else
{
getGlobal().MultipleEntitiesSelected = 0;
// Hide Group Pane.
// guiHide ("snGroupPane");
}
}
// Modify any resources given/taken
// (later, we need to base this on a resource-changing event).
// refreshResourcePool();
// Update Team Tray
// (later, we need to base this on the player creating a group).
// refreshTeamTray();
}
}

View File

@ -0,0 +1,19 @@
/*
DESCRIPTION : Functions for the "Status Pane" section of the session GUI.
NOTES :
*/
// ====================================================================
function refreshStatusPane()
{
if ( shouldUpdateStat ( "traits.id.icon" ) )
{
// Update portrait
if (selection[0].traits.id.icon)
setPortrait ("snStatusPanePortrait", selection[0].traits.id.icon,
selection[0].traits.id.civ_code, selection[0].traits.id.icon_cell);
}
}
// ====================================================================

View File

@ -25,7 +25,7 @@ function initCoord()
function addCrd (name, group, rx, ry, x, y, width, height)
{
// Create new coordinate if necessary (it doesn't exist, or we have a new name).
if (!Crd[Crd.last])
if (group == rb || !Crd[Crd.last])
{
Crd.last++;
Crd[Crd.last] = new Object();

View File

@ -262,11 +262,6 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
hide_object="true"
/>
<!--
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
-->
<tooltip name="snToolTip"
anchor="top"
buffer_zone="4"
@ -278,6 +273,11 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
textcolor="0 0 0"
/>
<!--
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
-->
<!--
==========================================
- SETUP - COLORS

View File

@ -99,6 +99,14 @@
/>
</sprite>
<sprite name="bkGraniteBorderBlack">
<image texture="global/tile/granite.png"
size="0 0 100% 100%"
border="true"
bordercolor="black"
/>
</sprite>
<sprite name="textureSand">
<image texture="global/tile/sandstone.png"
size="0 0 100% 100%"

View File

@ -25,7 +25,7 @@
<!--
==========================================
- STYLE - GLOBAL - WHEAT SKIN - PANES
- STYLE - GLOBAL - PANES - WHEAT SKIN
==========================================
-->
@ -51,6 +51,19 @@
text_valign="center"
/>
<!--
==========================================
- STYLE - GLOBAL - PANES - HELLENIC SKIN
==========================================
-->
<style name="skin*Hele*Window"
sprite="bkGraniteBorderBlack"
buffer_zone="10"
text_align="left"
text_valign="top"
/>
<!--
==========================================
- STYLE - GLOBAL - WHEAT SKIN - CONTROLS
@ -393,7 +406,7 @@
sprite_background="bkBorderBlack"
sprite_bar="bkBlueBorderBlack"
ghost="true"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
@ -430,7 +443,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
text_align="right"
font="prospero16"
textcolor="white"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
ghost="false"
/>
@ -439,7 +452,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
/>
<style name="session_object"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
@ -448,12 +461,12 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
text_valign="center"
sprite="wheatButton"
sprite_over="wheatButtonOver"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
<style name="session_ghost_object"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
@ -461,7 +474,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
<style name="session_ghost_miniheading_object"
font="verdana8"
textcolor="200 200 200"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
@ -469,7 +482,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
<style name="session_ghost_subheading_object"
font="verdana10"
textcolor="200 200 200"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
@ -478,7 +491,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
font="verdana10"
textcolor="200 200 200"
text_align="center"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
@ -487,7 +500,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
font="verdana10"
textcolor="200 200 200"
text_align="left"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
@ -497,7 +510,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
textcolor="255 255 255"
text_align="center"
text_valign="bottom"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
@ -507,7 +520,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
textcolor="255 255 255"
text_align="center"
text_valign="bottom"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
@ -515,7 +528,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
<style name="session_ghost_heading_object"
font="verdana12"
textcolor="200 200 200"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
@ -524,7 +537,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
font="verdana12"
textcolor="200 200 200"
text_align="left"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
@ -532,7 +545,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
<style name="session_ghost_text_object"
font="verdana10"
textcolor="255 255 255"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
@ -541,7 +554,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
font="verdana10"
textcolor="255 255 255"
text_align="left"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
@ -551,13 +564,13 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
textcolor="255 255 255"
text_align="left"
text_valign="center"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
ghost="true"
/>
<style name="session_minimap"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip=""
/>
@ -568,7 +581,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
sprite_disabled="ui_portrait_default_square_grey"
text_align="right"
textcolor="255 255 255"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
@ -578,7 +591,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
text_align="center"
text_valign="center"
textcolor="255 255 255"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
@ -588,7 +601,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
sprite_disabled="ui_portrait_default_circle_grey"
text_align="right"
textcolor="255 255 255"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
@ -598,7 +611,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
sprite_disabled="ui_portrait_default_circle_grey"
text_align="left"
textcolor="255 255 255"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
@ -607,7 +620,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
sprite_background=""
sprite_bar="green_bar"
ghost="true"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
@ -615,7 +628,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
sprite_background=""
sprite_bar="yellow_bar"
ghost="true"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
@ -623,7 +636,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
sprite_background=""
sprite_bar="blue_bar"
ghost="true"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>
@ -631,7 +644,7 @@ NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET CONVERTED NOT YET
sprite_background="bkBorderBlack"
sprite_bar="blue_bar_outlined"
ghost="true"
tooltip_style="session_tooltip"
tooltip_style="snToolTip"
tooltip="(TBA)"
/>