More miscellaneous and largely unnoticeable GUI stuff.
This was SVN commit r2566.
This commit is contained in:
parent
a04abf2967
commit
e63d314f74
@ -42,6 +42,16 @@
|
||||
|
||||
<script file="gui/test/functions_page_session.js"/>
|
||||
|
||||
<!--
|
||||
==========================================
|
||||
- INCLUDE SCRIPT - SIMULATION FUNCTIONS
|
||||
==========================================
|
||||
-->
|
||||
|
||||
<script file="gui/test/functions_sim_player.js"/>
|
||||
|
||||
<script file="gui/test/functions_sim_entity.js"/>
|
||||
|
||||
<!--
|
||||
==========================================
|
||||
- INCLUDE SCRIPT - INITIALISATION FUNCTIONS
|
||||
|
@ -134,8 +134,16 @@
|
||||
<object name="pgProductLogo"
|
||||
style="pgButton"
|
||||
type="button"
|
||||
ghost="true"
|
||||
size="21.1914062% 3.125% 68.0664062% 31.5104166%"
|
||||
sprite="pgProductLogo"
|
||||
>
|
||||
</object>
|
||||
|
||||
<object name="pgProductClick"
|
||||
style="pgButton"
|
||||
type="button"
|
||||
size="21.1914062% 3.125% 48.0664062% 31.5104166%"
|
||||
tooltip="Click this logo to roll credits."
|
||||
>
|
||||
<action on="Press"><![CDATA[
|
||||
@ -167,6 +175,7 @@
|
||||
<object name="pgVersionNumber"
|
||||
style="fancyTextHeadGold"
|
||||
type="text"
|
||||
ghost="true"
|
||||
size="43% 24% 43%+282 24%+25"
|
||||
>
|
||||
<action on="Load"><![CDATA[
|
||||
|
@ -21,9 +21,14 @@
|
||||
<object name="snMiniMap"
|
||||
style="session_minimap"
|
||||
type="minimap"
|
||||
size="100%-180 100%-180 100% 100%"
|
||||
/>
|
||||
|
||||
>
|
||||
<action on="Load"><![CDATA[
|
||||
addCrd (this.name, rb, 100, 100, 0, 0, 180, 180);
|
||||
addCrd (this.name, lb, 0, 100);
|
||||
addCrd (this.name, lt, 0, 0);
|
||||
addCrd (this.name, rt, 100, 0);
|
||||
]]></action>
|
||||
</object>
|
||||
</object>
|
||||
|
||||
</objects>
|
||||
|
@ -9,7 +9,6 @@ function init ()
|
||||
{
|
||||
// Root point for anything that needs to be globally initialised at startup.
|
||||
|
||||
// (Both of these need to be rewritten, so might be removed.)
|
||||
initCoord();
|
||||
initSession();
|
||||
}
|
||||
|
@ -132,6 +132,7 @@ function setupSession (GameMode)
|
||||
}
|
||||
|
||||
// Set starting UI layout.
|
||||
GUIType=rb;
|
||||
flipGUI (GUIType);
|
||||
|
||||
// Select session peace track.
|
||||
|
@ -9,8 +9,6 @@ function initSession()
|
||||
{
|
||||
// ============================================= CONSTANTS =================================================
|
||||
|
||||
GUIType="bottom";
|
||||
|
||||
// Standard portrait widths.
|
||||
crd_portrait_lrg_width = 64;
|
||||
crd_portrait_lrg_height = crd_portrait_lrg_width;
|
||||
@ -21,19 +19,10 @@ function initSession()
|
||||
crd_mini_icon_width = 20;
|
||||
crd_mini_icon_height = crd_mini_icon_width;
|
||||
|
||||
// Define cell reference constants for icon sheets.
|
||||
initCellReference();
|
||||
|
||||
// ============================================= GLOBALS =================================================
|
||||
|
||||
// initGroupPane();
|
||||
// initResourcePool();
|
||||
// initStatusOrb();
|
||||
// initMapOrb();
|
||||
// initTeamTray();
|
||||
// initSubWindows();
|
||||
// initManual();
|
||||
// initJukebox();
|
||||
// Define cell reference constants for icon sheets.
|
||||
initCellReference();
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
@ -194,308 +183,42 @@ function getObjectInfo()
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function MakeUnit(x, y, z, MakeUnitName)
|
||||
{
|
||||
// Spawn an entity at the given coordinates.
|
||||
|
||||
DudeSpawnPoint = new Vector3D(x, y, z);
|
||||
new Entity(getEntityTemplate(MakeUnitName), DudeSpawnPoint, 1.0);
|
||||
// writeConsole(MakeUnitName + " created at " + DudeSpawnPoint);
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function selected()
|
||||
{
|
||||
// Returns how many units selected.
|
||||
|
||||
if( selection.length > 0 )
|
||||
return( selection[0] );
|
||||
return( null );
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function flipGUI (NewGUIType)
|
||||
{
|
||||
// Sets the GUI coordinates and graphics so that the panel is either at the top or bottom of the screen.
|
||||
// Changes GUI to a different layout.
|
||||
|
||||
switch (NewGUIType)
|
||||
{
|
||||
// Set which GUI to use.
|
||||
case "top":
|
||||
case "bottom":
|
||||
case "none":
|
||||
GUIType=NewGUIType;
|
||||
case rb:
|
||||
case lb:
|
||||
case lt:
|
||||
case rt:
|
||||
GUIType = NewGUIType;
|
||||
break;
|
||||
default:
|
||||
// If no type specified, toggle.
|
||||
if (GUIType == "top")
|
||||
GUIType = "bottom";
|
||||
if (GUIType == rb)
|
||||
GUIType = lb;
|
||||
else
|
||||
if (GUIType == "bottom")
|
||||
GUIType = "none";
|
||||
if (GUIType == lb)
|
||||
GUIType = lt;
|
||||
else
|
||||
GUIType = "top";
|
||||
if (GUIType == lt)
|
||||
GUIType = rt;
|
||||
else
|
||||
GUIType = rb;
|
||||
break;
|
||||
}
|
||||
|
||||
if (GUIType != "none")
|
||||
// Seek through all sizes created.
|
||||
for (i = 0; i <= Crd.last; i++)
|
||||
{
|
||||
guiUnHide("sn");
|
||||
|
||||
// Seek through all sizes created.
|
||||
for (FlipGUILoop = 0; FlipGUILoop <= SizeCoord.last-1; FlipGUILoop++)
|
||||
{
|
||||
// Set each object to the other size.
|
||||
switch (GUIType)
|
||||
{
|
||||
case "bottom":
|
||||
setSize(SizeCoord[FlipGUILoop].name, SizeCoord[FlipGUILoop].size1);
|
||||
switch (SizeCoord[FlipGUILoop].name){
|
||||
case "SN_MAP_ORB_SEGBOTTOM1":
|
||||
getGUIObjectByName(SizeCoord[FlipGUILoop].name).sprite = "session_panel_minimap_segtop1";
|
||||
getGUIObjectByName(SizeCoord[FlipGUILoop].name).sprite_over = "session_panel_minimap_segtop1" + "_lit";
|
||||
break;
|
||||
case "SN_MAP_ORB_SEGBOTTOM2":
|
||||
getGUIObjectByName(SizeCoord[FlipGUILoop].name).sprite = "session_panel_minimap_segtop2";
|
||||
getGUIObjectByName(SizeCoord[FlipGUILoop].name).sprite_over = "session_panel_minimap_segtop2" + "_lit";
|
||||
break;
|
||||
case "SN_MAP_ORB_SEGBOTTOM3":
|
||||
getGUIObjectByName(SizeCoord[FlipGUILoop].name).sprite = "session_panel_minimap_segtop3";
|
||||
getGUIObjectByName(SizeCoord[FlipGUILoop].name).sprite_over = "session_panel_minimap_segtop3" + "_lit";
|
||||
break;
|
||||
case "SN_MAP_ORB_SEGBOTTOM4":
|
||||
getGUIObjectByName(SizeCoord[FlipGUILoop].name).sprite = "session_panel_minimap_segtop4";
|
||||
getGUIObjectByName(SizeCoord[FlipGUILoop].name).sprite_over = "session_panel_minimap_segtop4" + "_lit";
|
||||
break;
|
||||
case "SN_STATUS_PANE_BG":
|
||||
getGUIObjectByName(SizeCoord[FlipGUILoop].name).sprite = "session_panel_status_bg_top";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "top":
|
||||
setSize(SizeCoord[FlipGUILoop].name, SizeCoord[FlipGUILoop].size2);
|
||||
switch (SizeCoord[FlipGUILoop].name){
|
||||
case "SN_MAP_ORB_SEGBOTTOM1":
|
||||
getGUIObjectByName(SizeCoord[FlipGUILoop].name).sprite = "session_panel_minimap_segbottom1";
|
||||
getGUIObjectByName(SizeCoord[FlipGUILoop].name).sprite_over = "session_panel_minimap_segbottom1_lit";
|
||||
break;
|
||||
case "SN_MAP_ORB_SEGBOTTOM2":
|
||||
getGUIObjectByName(SizeCoord[FlipGUILoop].name).sprite = "session_panel_minimap_segbottom2";
|
||||
getGUIObjectByName(SizeCoord[FlipGUILoop].name).sprite_over = "session_panel_minimap_segbottom2_lit";
|
||||
break;
|
||||
case "SN_MAP_ORB_SEGBOTTOM3":
|
||||
getGUIObjectByName(SizeCoord[FlipGUILoop].name).sprite = "session_panel_minimap_segbottom3";
|
||||
getGUIObjectByName(SizeCoord[FlipGUILoop].name).sprite_over = "session_panel_minimap_segbottom3_lit";
|
||||
break;
|
||||
case "SN_MAP_ORB_SEGBOTTOM4":
|
||||
getGUIObjectByName(SizeCoord[FlipGUILoop].name).sprite = "session_panel_minimap_segbottom4";
|
||||
getGUIObjectByName(SizeCoord[FlipGUILoop].name).sprite_over = "session_panel_minimap_segbottom4_lit";
|
||||
break;
|
||||
case "SN_STATUS_PANE_BG":
|
||||
getGUIObjectByName(SizeCoord[FlipGUILoop].name).sprite = "session_panel_status_bg_bottom";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateGroupPane();
|
||||
}
|
||||
else
|
||||
{
|
||||
guiHide("sn");
|
||||
// Set their sizes to the stored value.
|
||||
getGUIObjectByName (Crd[i].name).size = Crd[i].size[GUIType];
|
||||
}
|
||||
|
||||
writeConsole("GUI flipped to " + GUIType + ".");
|
||||
|
||||
writeConsole("GUI flipped to size " + GUIType + ".");
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function selectEntity(handler)
|
||||
{
|
||||
endSelection();
|
||||
startSelection(function (event) {
|
||||
// Selection is performed when single-clicking the right mouse
|
||||
// button.
|
||||
if (event.button == SDL_BUTTON_RIGHT && event.clicks == 1)
|
||||
{
|
||||
handler(event.entity);
|
||||
}
|
||||
// End selection on first mouse-click
|
||||
endSelection();
|
||||
});
|
||||
}
|
||||
|
||||
function selectLocation(handler)
|
||||
{
|
||||
endSelection();
|
||||
startSelection(function (event) {
|
||||
// Selection is performed when single-clicking the right mouse
|
||||
// button.
|
||||
if (event.button == SDL_BUTTON_RIGHT && event.clicks == 1)
|
||||
{
|
||||
handler(event.x, event.y);
|
||||
}
|
||||
// End selection on first mouse-click
|
||||
endSelection();
|
||||
});
|
||||
}
|
||||
|
||||
function startSelection(handler)
|
||||
{
|
||||
gameView.startCustomSelection();
|
||||
getGlobal().selectionWorldClickHandler=handler;
|
||||
console.write("isSelecting(): "+isSelecting());
|
||||
}
|
||||
|
||||
function endSelection()
|
||||
{
|
||||
if (!isSelecting())
|
||||
return;
|
||||
|
||||
gameView.endCustomSelection();
|
||||
getGlobal().selectionWorldClickHandler = null;
|
||||
}
|
||||
|
||||
function isSelecting()
|
||||
{
|
||||
return getGlobal().selectionWorldClickHandler != null;
|
||||
}
|
||||
|
||||
// The world-click handler - called whenever the user clicks the terrain
|
||||
function worldClickHandler(event)
|
||||
{
|
||||
args=new Array(null, null);
|
||||
|
||||
console.write("worldClickHandler: button "+event.button+", clicks "+event.clicks);
|
||||
|
||||
if (isSelecting())
|
||||
{
|
||||
getGlobal().selectionWorldClickHandler(event);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Right button single- or double-clicks
|
||||
if (event.button == SDL_BUTTON_RIGHT && event.clicks <= 2)
|
||||
{
|
||||
if (event.clicks == 1)
|
||||
cmd = event.command;
|
||||
else if (event.clicks == 2)
|
||||
{
|
||||
console.write("Issuing secondary command");
|
||||
cmd = event.secondaryCommand;
|
||||
}
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
// location target commands
|
||||
case NMT_Goto:
|
||||
case NMT_Patrol:
|
||||
if (event.queued)
|
||||
{
|
||||
cmd = NMT_AddWaypoint;
|
||||
}
|
||||
case NMT_AddWaypoint:
|
||||
args[0]=event.x;
|
||||
args[1]=event.y;
|
||||
break;
|
||||
// entity target commands
|
||||
case NMT_AttackMelee:
|
||||
case NMT_Gather:
|
||||
args[0]=event.entity;
|
||||
args[1]=null;
|
||||
break;
|
||||
default:
|
||||
console.write("worldClickHandler: Unknown command: "+cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
issueCommand(selection, cmd, args[0], args[1]);
|
||||
}
|
||||
|
||||
addGlobalHandler("worldClick", worldClickHandler);
|
||||
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function createResources()
|
||||
{
|
||||
// Defines all resource types for future use.
|
||||
|
||||
addResource ("Food", 0);
|
||||
addResource ("Wood", 0);
|
||||
addResource ("Stone", 0);
|
||||
addResource ("Ore", 0);
|
||||
addResource ("Population", 0);
|
||||
addResource ("Housing", 0);
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function addResource (resourceName, resourceQty)
|
||||
{
|
||||
// Creates a resource type.
|
||||
|
||||
// MT: Rewritten to use JavaScript's nice associative-array-alikes. Requires the valueOf() hack - I'm looking into this.
|
||||
|
||||
if (!localPlayer.resource)
|
||||
{
|
||||
// Define the base resource group if it does not exist.
|
||||
localPlayer.resource = new Array();
|
||||
}
|
||||
|
||||
// Set resource name to upper-case to ensure it matches resource control name.
|
||||
resourceName = resourceName.toUpperCase();
|
||||
|
||||
// Store resource's name and starting value.
|
||||
localPlayer.resource.valueOf()[resourceName] = resourceQty;
|
||||
|
||||
console.write("Added " + resourceName );
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function giveResources (resourceName, resourceQty)
|
||||
{
|
||||
// Generic function to add resources to the player's Pool.
|
||||
|
||||
if ( localPlayer.resource.valueOf()[resourceName] )
|
||||
{
|
||||
localPlayer.resource.valueOf()[resourceName] += resourceQty;
|
||||
console.write ("Earned " + resourceQty + " resources.");
|
||||
return ( true );
|
||||
}
|
||||
|
||||
// If the resource wasn't in the list, report an error.
|
||||
return false;
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function deductResources (resourceName, resourceQty)
|
||||
{
|
||||
// Generic function to remove resources from the player's Pool.
|
||||
|
||||
if( localPlayer.resource.valueOf()[resourceName] )
|
||||
{
|
||||
localPlayer.resource.valueOf()[resourceName] -= resourceQty;
|
||||
console.write("Deducted " + resourceQty + " resources.");
|
||||
return( true );
|
||||
}
|
||||
|
||||
// If the resource wasn't in the list, report an error.
|
||||
return false;
|
||||
}
|
||||
|
||||
// ====================================================================
|
156
binaries/data/mods/official/gui/test/functions_sim_entity.js
Normal file
156
binaries/data/mods/official/gui/test/functions_sim_entity.js
Normal file
@ -0,0 +1,156 @@
|
||||
/*
|
||||
DESCRIPTION : Functions for the world click handler and manipulating entities.
|
||||
NOTES :
|
||||
*/
|
||||
|
||||
// ====================================================================
|
||||
|
||||
addGlobalHandler ("worldClick", worldClickHandler);
|
||||
|
||||
// ====================================================================
|
||||
|
||||
// The world-click handler - called whenever the user clicks the terrain
|
||||
function worldClickHandler(event)
|
||||
{
|
||||
args=new Array(null, null);
|
||||
|
||||
console.write("worldClickHandler: button "+event.button+", clicks "+event.clicks);
|
||||
|
||||
if (isSelecting())
|
||||
{
|
||||
getGlobal().selectionWorldClickHandler(event);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Right button single- or double-clicks
|
||||
if (event.button == SDL_BUTTON_RIGHT && event.clicks <= 2)
|
||||
{
|
||||
if (event.clicks == 1)
|
||||
cmd = event.command;
|
||||
else if (event.clicks == 2)
|
||||
{
|
||||
console.write("Issuing secondary command");
|
||||
cmd = event.secondaryCommand;
|
||||
}
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
// location target commands
|
||||
case NMT_Goto:
|
||||
case NMT_Patrol:
|
||||
if (event.queued)
|
||||
{
|
||||
cmd = NMT_AddWaypoint;
|
||||
}
|
||||
break;
|
||||
case NMT_AddWaypoint:
|
||||
args[0]=event.x;
|
||||
args[1]=event.y;
|
||||
break;
|
||||
// entity target commands
|
||||
case NMT_AttackMelee:
|
||||
case NMT_Gather:
|
||||
args[0]=event.entity;
|
||||
args[1]=null;
|
||||
break;
|
||||
default:
|
||||
console.write("worldClickHandler: Unknown command: "+cmd);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
issueCommand (selection, cmd, args[0], args[1]);
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function selectEntity(handler)
|
||||
{
|
||||
endSelection();
|
||||
startSelection(function (event) {
|
||||
// Selection is performed when single-clicking the right mouse
|
||||
// button.
|
||||
if (event.button == SDL_BUTTON_RIGHT && event.clicks == 1)
|
||||
{
|
||||
handler(event.entity);
|
||||
}
|
||||
// End selection on first mouse-click
|
||||
endSelection();
|
||||
});
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function selectLocation(handler)
|
||||
{
|
||||
endSelection();
|
||||
startSelection(function (event) {
|
||||
// Selection is performed when single-clicking the right mouse
|
||||
// button.
|
||||
if (event.button == SDL_BUTTON_RIGHT && event.clicks == 1)
|
||||
{
|
||||
handler(event.x, event.y);
|
||||
}
|
||||
// End selection on first mouse-click
|
||||
endSelection();
|
||||
});
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function startSelection(handler)
|
||||
{
|
||||
gameView.startCustomSelection();
|
||||
getGlobal().selectionWorldClickHandler=handler;
|
||||
console.write("isSelecting(): "+isSelecting());
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function endSelection()
|
||||
{
|
||||
if (!isSelecting())
|
||||
return;
|
||||
|
||||
gameView.endCustomSelection();
|
||||
getGlobal().selectionWorldClickHandler = null;
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function isSelecting()
|
||||
{
|
||||
return getGlobal().selectionWorldClickHandler != null;
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function makeUnit (x, y, z, MakeUnitName)
|
||||
{
|
||||
// Spawn an entity at the given coordinates.
|
||||
|
||||
DudeSpawnPoint = new Vector3D(x, y, z);
|
||||
new Entity(getEntityTemplate(MakeUnitName), DudeSpawnPoint, 1.0);
|
||||
// writeConsole(MakeUnitName + " created at " + DudeSpawnPoint);
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function selected()
|
||||
{
|
||||
// Returns how many units selected.
|
||||
|
||||
if( selection.length > 0 )
|
||||
return( selection[0] );
|
||||
return( null );
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
|
||||
|
||||
|
77
binaries/data/mods/official/gui/test/functions_sim_player.js
Normal file
77
binaries/data/mods/official/gui/test/functions_sim_player.js
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
DESCRIPTION : Functions for manipulating players and their properties (eg resources).
|
||||
NOTES :
|
||||
*/
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function createResources()
|
||||
{
|
||||
// Defines all resource types for future use.
|
||||
|
||||
addResource ("Food", 0);
|
||||
addResource ("Wood", 0);
|
||||
addResource ("Stone", 0);
|
||||
addResource ("Ore", 0);
|
||||
addResource ("Population", 0);
|
||||
addResource ("Housing", 0);
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function addResource (resourceName, resourceQty)
|
||||
{
|
||||
// Creates a resource type.
|
||||
|
||||
// MT: Rewritten to use JavaScript's nice associative-array-alikes. Requires the valueOf() hack - I'm looking into this.
|
||||
|
||||
if (!localPlayer.resource)
|
||||
{
|
||||
// Define the base resource group if it does not exist.
|
||||
localPlayer.resource = new Array();
|
||||
}
|
||||
|
||||
// Set resource name to upper-case to ensure it matches resource control name.
|
||||
resourceName = resourceName.toUpperCase();
|
||||
|
||||
// Store resource's name and starting value.
|
||||
localPlayer.resource.valueOf()[resourceName] = resourceQty;
|
||||
|
||||
console.write("Added " + resourceName );
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function giveResources (resourceName, resourceQty)
|
||||
{
|
||||
// Generic function to add resources to the player's Pool.
|
||||
|
||||
if ( localPlayer.resource.valueOf()[resourceName] )
|
||||
{
|
||||
localPlayer.resource.valueOf()[resourceName] += resourceQty;
|
||||
console.write ("Earned " + resourceQty + " resources.");
|
||||
return ( true );
|
||||
}
|
||||
|
||||
// If the resource wasn't in the list, report an error.
|
||||
return false;
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function deductResources (resourceName, resourceQty)
|
||||
{
|
||||
// Generic function to remove resources from the player's Pool.
|
||||
|
||||
if( localPlayer.resource.valueOf()[resourceName] )
|
||||
{
|
||||
localPlayer.resource.valueOf()[resourceName] -= resourceQty;
|
||||
console.write("Deducted " + resourceQty + " resources.");
|
||||
return( true );
|
||||
}
|
||||
|
||||
// If the resource wasn't in the list, report an error.
|
||||
return false;
|
||||
}
|
||||
|
||||
// ====================================================================
|
@ -4,192 +4,114 @@
|
||||
NOTES :
|
||||
*/
|
||||
|
||||
//// THIS WILL BE REWRITTEN SHORTLY - AGAIN! ////
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function initCoord()
|
||||
{
|
||||
// Initialise coordinate set for this page.
|
||||
Crd = new Array();
|
||||
Crd.last = 0;
|
||||
Crd.last = new Object(-1);
|
||||
|
||||
// Screen percentages.
|
||||
top_screen = 0;
|
||||
left_screen = 0;
|
||||
mid_screen = 50;
|
||||
bottom_screen = 100;
|
||||
right_screen = 100;
|
||||
|
||||
// Coord-style size table.
|
||||
SizeCoord = new Array();
|
||||
SizeCoord.last = 0;
|
||||
// Set corner constants.
|
||||
rb = 0;
|
||||
lb = 1;
|
||||
lt = 2;
|
||||
rt = 3;
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function AddSizeCoord(objectName, left1, top1, right1, bottom1, rleft1, rtop1, rright1, rbottom1, left2, top2, right2, bottom2, rleft2, rtop2, rright2, rbottom2)
|
||||
// Add a new size coordinate to the array.
|
||||
function addCrd (name, group, rx, ry, x, y, width, height)
|
||||
{
|
||||
// Used to store the two GUI style sizes for an object on creation (specified as coordinates).
|
||||
// Used later by FlipGUI() to switch the objects to a new set of positions.
|
||||
|
||||
SizeCoord[SizeCoord.last] = new Object();
|
||||
SizeCoord[SizeCoord.last].name = objectName;
|
||||
SizeCoord[SizeCoord.last].size1 = new GUISize(left1, top1, right1, bottom1, rleft1, rtop1, rright1, rbottom1);
|
||||
SizeCoord[SizeCoord.last].size2 = new GUISize(left2, top2, right2, bottom2, rleft2, rtop2, rright2, rbottom2);
|
||||
|
||||
SizeCoord.last++; // Increment counter for next entry.
|
||||
// Create new coordinate if necessary (it doesn't exist, or we have a new name).
|
||||
if (!Crd[Crd.last])
|
||||
{
|
||||
Crd.last++;
|
||||
Crd[Crd.last] = new Object();
|
||||
Crd[Crd.last].name = new Object(name);
|
||||
Crd[Crd.last].size = new Object();
|
||||
// console.write ("Created " + Crd.last + Crd[Crd.last].name);
|
||||
}
|
||||
|
||||
// Create new size.
|
||||
Crd[Crd.last].size[group] = new Array();
|
||||
/*
|
||||
// Get coordinates from first element if not defined.
|
||||
if (!x) x = Crd[Crd.last].size[rb].size.x1;
|
||||
if (!y) y = Crd[Crd.last].size[rb].size.y1;
|
||||
if (!width) width = Crd[Crd.last].size[rb].size.x2-Crd[Crd.last].size[rb].size.x1;
|
||||
if (!height) height = Crd[Crd.last].size[rb].size.y2-Crd[Crd.last].size[rb].size.y1;
|
||||
*/
|
||||
Crd[Crd.last].size[group] = calcCrdArray (rx, ry, x, y, width, height);
|
||||
// console.write (Crd[Crd.last].size[group]);
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function AddSizeString(objectName, size1, size2)
|
||||
// Calculates and returns "size" string from a given x/y/width/height and relative x and y.
|
||||
function calcCrdArray (rx, ry, x, y, width, height)
|
||||
{
|
||||
// Used to store the two GUI style sizes for an object on creation (specified as strings).
|
||||
// Used later by FlipGUI() to switch the objects to a new set of positions.
|
||||
|
||||
SizeCoord[SizeCoord.last] = new Object();
|
||||
SizeCoord[SizeCoord.last].name = objectName;
|
||||
SizeCoord[SizeCoord.last].size1 = size1;
|
||||
SizeCoord[SizeCoord.last].size2 = size2;
|
||||
|
||||
SizeCoord.last++; // Increment counter for next entry.
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function setSize(objectName, sizeString)
|
||||
{
|
||||
// Use this function as a shortcut to change the size of a GUI control, specifying a size string.
|
||||
|
||||
getGUIObjectByName(objectName).size = sizeString;
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function setSizeCoord(objectName, left, top, right, bottom, rleft, rtop, rright, rbottom)
|
||||
{
|
||||
// Use this function as a shortcut to change the size of a GUI control, specifying individual coordinates.
|
||||
|
||||
getGUIObjectByName(objectName).size = new GUISize(left, top, right, bottom, rleft, rtop, rright, rbottom);
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function addSizeArray(objectArray, objectElement, objectX, objectY, objectWidth, objectHeight)
|
||||
{
|
||||
// Adds a x/y/width/height element to a given coordinate array.
|
||||
|
||||
objectArray[objectElement] = new Object();
|
||||
objectArray[objectElement].width = objectWidth;
|
||||
objectArray[objectElement].height = objectHeight;
|
||||
objectArray[objectElement].x = objectX;
|
||||
objectArray[objectElement].y = objectY;
|
||||
|
||||
return objectElement;
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function addSizeArrayWH(objectArray, objectElement, objectWidth, objectHeight)
|
||||
{
|
||||
// Creates and adds a width/height element to a given coordinate array.
|
||||
|
||||
objectArray[objectElement] = new Object();
|
||||
objectArray[objectElement].width = objectWidth;
|
||||
objectArray[objectElement].height = objectHeight;
|
||||
|
||||
return objectElement;
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function addSizeArrayXY(objectArray, objectElement, objectX, objectY)
|
||||
{
|
||||
// Adds a x/y element to a given coordinate array and increments.
|
||||
|
||||
objectArray[objectElement].x = objectX;
|
||||
objectArray[objectElement].y = objectY;
|
||||
|
||||
objectElement++;
|
||||
return objectElement;
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function calcSizeArray(objectName, objectArrayElement, rleft, rtop, rright, rbottom)
|
||||
{
|
||||
// Use this function as a shortcut to change the size of a GUI control, via an array containing x, y, width, height and 4 relative sizes.
|
||||
// Alternatively, specify 4 relative sizes to override and use these ones instead.
|
||||
|
||||
setSizeContainer = new Object();
|
||||
|
||||
// Override with relative parameter if given.
|
||||
if (rleft && rtop && rright && rbottom)
|
||||
{
|
||||
objectArrayElement.rleft = rleft;
|
||||
objectArrayElement.rtop = rtop;
|
||||
objectArrayElement.rright = rright;
|
||||
objectArrayElement.rbottom = rbottom;
|
||||
}
|
||||
|
||||
setSizeContainer.rleft = objectArrayElement.rleft;
|
||||
setSizeContainer.rtop = objectArrayElement.rtop;
|
||||
setSizeContainer.rright = objectArrayElement.rright;
|
||||
setSizeContainer.rbottom = objectArrayElement.rbottom;
|
||||
// Set relatives.
|
||||
setSizeContainer.rleft = rx;
|
||||
setSizeContainer.rtop = ry;
|
||||
setSizeContainer.rright = rx;
|
||||
setSizeContainer.rbottom = ry;
|
||||
|
||||
// Define size dimensions.
|
||||
switch (setSizeContainer.rleft)
|
||||
{
|
||||
case left_screen:
|
||||
setSizeContainer.x1 = objectArrayElement.x;
|
||||
case 0:
|
||||
setSizeContainer.x1 = x;
|
||||
break;
|
||||
case right_screen:
|
||||
setSizeContainer.x1 = -objectArrayElement.x-objectArrayElement.width;
|
||||
case 100:
|
||||
setSizeContainer.x1 = -x-width;
|
||||
break;
|
||||
case mid_screen:
|
||||
setSizeContainer.x1 = objectArrayElement.x;
|
||||
case 50:
|
||||
setSizeContainer.x1 = x;
|
||||
break;
|
||||
}
|
||||
switch (setSizeContainer.rtop)
|
||||
{
|
||||
case top_screen:
|
||||
setSizeContainer.y1 = objectArrayElement.y;
|
||||
case 0:
|
||||
setSizeContainer.y1 = y;
|
||||
break;
|
||||
case bottom_screen:
|
||||
setSizeContainer.y1 = -objectArrayElement.y-objectArrayElement.height;
|
||||
case 100:
|
||||
setSizeContainer.y1 = -y-height;
|
||||
break;
|
||||
case mid_screen:
|
||||
setSizeContainer.y1 = objectArrayElement.y;
|
||||
case 50:
|
||||
setSizeContainer.y1 = y;
|
||||
break;
|
||||
}
|
||||
switch (setSizeContainer.rright)
|
||||
{
|
||||
case left_screen:
|
||||
setSizeContainer.x2 = objectArrayElement.x+objectArrayElement.width;
|
||||
case 0:
|
||||
setSizeContainer.x2 = x+width;
|
||||
break;
|
||||
case right_screen:
|
||||
if (setSizeContainer.rleft == right_screen)
|
||||
setSizeContainer.x2 = -objectArrayElement.x;
|
||||
case 100:
|
||||
if (setSizeContainer.rleft == 100)
|
||||
setSizeContainer.x2 = -x;
|
||||
else
|
||||
setSizeContainer.x2 = -objectArrayElement.width;
|
||||
setSizeContainer.x2 = -width;
|
||||
break;
|
||||
case mid_screen:
|
||||
setSizeContainer.x2 = objectArrayElement.x+objectArrayElement.width;
|
||||
case 50:
|
||||
setSizeContainer.x2 = x+width;
|
||||
break;
|
||||
}
|
||||
switch (setSizeContainer.rbottom)
|
||||
{
|
||||
case top_screen:
|
||||
setSizeContainer.y2 = objectArrayElement.y+objectArrayElement.height;
|
||||
case 0:
|
||||
setSizeContainer.y2 = y+height;
|
||||
break;
|
||||
case bottom_screen:
|
||||
if (setSizeContainer.rtop == bottom_screen)
|
||||
setSizeContainer.y2 = -objectArrayElement.y;
|
||||
case 100:
|
||||
if (setSizeContainer.rtop == 100)
|
||||
setSizeContainer.y2 = -y;
|
||||
else
|
||||
setSizeContainer.y2 = -objectArrayElement.height;
|
||||
setSizeContainer.y2 = -height;
|
||||
break;
|
||||
case mid_screen:
|
||||
case 50:
|
||||
setSizeContainer.y2 = objectArrayElement.y+objectArrayElement.height;
|
||||
break;
|
||||
}
|
||||
@ -198,94 +120,3 @@ function calcSizeArray(objectName, objectArrayElement, rleft, rtop, rright, rbot
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function setSizeArray(objectName, objectArrayElement, rleft, rtop, rright, rbottom)
|
||||
{
|
||||
// Set appropriate size for dimensions.
|
||||
getGUIObjectByName(objectName).size = calcSizeArray(objectName, objectArrayElement, rleft, rtop, rright, rbottom);
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function addSizeCoordArray(objectName, objectArrayElement, objectArrayElement_Flp)
|
||||
{
|
||||
// Used to store the two GUI style sizes for an object on creation (specified as coordinates).
|
||||
// Used later by FlipGUI() to switch the objects to a new set of positions.
|
||||
// This uses the revised coordinate system, so it handles the flipping internally.
|
||||
// If an optional secondary coordinate object is specified by parameter, it will
|
||||
// use the values in this object for the flipped version, rather than automatically
|
||||
// generating a top-down flip.
|
||||
|
||||
SizeCoord[SizeCoord.last] = new Object();
|
||||
SizeCoord[SizeCoord.last].name = objectName;
|
||||
|
||||
// Determine relatives for the second size.
|
||||
addSizeContainer = new Object();
|
||||
if (objectArrayElement_Flp) // Specify new flipped coordinates from object.
|
||||
{
|
||||
addSizeContainer.rleft = objectArrayElement_Flp.rleft;
|
||||
addSizeContainer.rtop = objectArrayElement_Flp.rtop;
|
||||
addSizeContainer.rright = objectArrayElement_Flp.rright;
|
||||
addSizeContainer.rbottom = objectArrayElement_Flp.rbottom;
|
||||
addSizeContainer.width = objectArrayElement_Flp.width;
|
||||
addSizeContainer.height = objectArrayElement_Flp.height;
|
||||
addSizeContainer.x = objectArrayElement_Flp.x;
|
||||
addSizeContainer.y = objectArrayElement_Flp.y;
|
||||
}
|
||||
else // Generate flipped version automatically.
|
||||
{
|
||||
addSizeContainer.rleft = objectArrayElement.rleft;
|
||||
addSizeContainer.rtop = 100-objectArrayElement.rtop;
|
||||
addSizeContainer.rright = objectArrayElement.rright;
|
||||
addSizeContainer.rbottom = 100-objectArrayElement.rbottom;
|
||||
|
||||
if (addSizeContainer.rtop <= 0) addSizeContainer.rtop = 0;
|
||||
if (addSizeContainer.rbottom <= 0) addSizeContainer.rbottom = 0;
|
||||
if (addSizeContainer.rtop >= 100) addSizeContainer.rtop = 100;
|
||||
if (addSizeContainer.rbottom >= 100) addSizeContainer.rbottom = 100;
|
||||
|
||||
addSizeContainer.x = objectArrayElement.x;
|
||||
addSizeContainer.y = objectArrayElement.y;
|
||||
addSizeContainer.width = objectArrayElement.width;
|
||||
addSizeContainer.height = objectArrayElement.height;
|
||||
|
||||
if (addSizeContainer.rtop == 100 && objectArrayElement.y < 0) addSizeContainer.y = objectArrayElement.y*-1;
|
||||
if (addSizeContainer.rbottom == 100 && objectArrayElement.y < 0) addSizeContainer.y = objectArrayElement.y*-1;
|
||||
}
|
||||
|
||||
// Assign the two sizes to array for retrieval when needed.
|
||||
SizeCoord[SizeCoord.last].size1 = calcSizeArray(objectName, objectArrayElement);
|
||||
SizeCoord[SizeCoord.last].size2 = calcSizeArray(objectName, addSizeContainer);
|
||||
|
||||
SizeCoord.last++; // Increment counter for next entry.
|
||||
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function setCoordInputUpDown(setCoordObjectUp, setCoordObjectDn, parentInput, rleft, rtop, rright, rbottom)
|
||||
{
|
||||
// Set the coordinates for the up/down button for an input box.
|
||||
|
||||
setCoordObjectUp.rleft = rleft;
|
||||
setCoordObjectUp.rtop = rtop;
|
||||
setCoordObjectUp.rright = rright;
|
||||
setCoordObjectUp.rbottom = rbottom;
|
||||
|
||||
setCoordObjectDn.rleft = rleft;
|
||||
setCoordObjectDn.rtop = rtop;
|
||||
setCoordObjectDn.rright = rright;
|
||||
setCoordObjectDn.rbottom = rbottom;
|
||||
|
||||
setCoordObjectUp.width = (Crd[parentInput].width/5)+3;
|
||||
setCoordObjectUp.height = (Crd[parentInput].height/2)+3;
|
||||
setCoordObjectUp.x = Crd[parentInput].x+Crd[parentInput].width-setCoordObjectUp.width;
|
||||
setCoordObjectUp.y = Crd[parentInput].y;
|
||||
|
||||
setCoordObjectDn.width = setCoordObjectUp.width;
|
||||
setCoordObjectDn.height = setCoordObjectUp.height;
|
||||
setCoordObjectDn.x = setCoordObjectUp.x;
|
||||
setCoordObjectDn.y = Crd[parentInput].y+Crd[parentInput].height-setCoordObjectDn.height+2;
|
||||
}
|
||||
|
||||
// ====================================================================
|
Loading…
Reference in New Issue
Block a user