Convert some line endings to native

This was SVN commit r6994.
This commit is contained in:
Ykkrosh
2009-07-16 10:20:51 +00:00
parent 0b17c32492
commit 4c4bc53a91
32 changed files with 11229 additions and 11229 deletions
+75 -75
View File
@@ -1,75 +1,75 @@
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE objects SYSTEM "../gui.dtd">
<objects>
<!--
==========================================
- INCLUDE SCRIPT - UTILITY FUNCTIONS
==========================================
-->
<script file="gui/test/functions_utility.js" />
<script file="gui/test/functions_utility_list.js" />
<script file="gui/test/functions_utility_object.js" />
<script file="gui/test/functions_utility_coord.js" />
<script file="gui/test/functions_utility_music.js" />
<script file="gui/test/functions_utility_animation.js" />
<!--
==========================================
- INCLUDE SCRIPT - GLOBAL OBJECT FUNCTIONS
==========================================
-->
<script file="gui/test/functions_global_object.js" />
<!--
==========================================
- INCLUDE SCRIPT - GUI PAGE FUNCTIONS
==========================================
-->
<script file="gui/test/functions_page_pregame.js" />
<script file="gui/test/functions_page_pregame_multiplayer.js" />
<script file="gui/test/functions_page_pregame_setup.js" />
<script file="gui/test/functions_page_pregame_load.js" />
<script file="gui/test/functions_page_session.js"/>
<script file="gui/test/functions_page_session_status_pane.js" />
<script file="gui/test/functions_page_session_status_commands.js" />
<script file="gui/test/functions_page_session_manual.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
==========================================
-->
<script file="gui/test/functions_global_init.js"><![CDATA[
init();
]]></script>
</objects>
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE objects SYSTEM "../gui.dtd">
<objects>
<!--
==========================================
- INCLUDE SCRIPT - UTILITY FUNCTIONS
==========================================
-->
<script file="gui/test/functions_utility.js" />
<script file="gui/test/functions_utility_list.js" />
<script file="gui/test/functions_utility_object.js" />
<script file="gui/test/functions_utility_coord.js" />
<script file="gui/test/functions_utility_music.js" />
<script file="gui/test/functions_utility_animation.js" />
<!--
==========================================
- INCLUDE SCRIPT - GLOBAL OBJECT FUNCTIONS
==========================================
-->
<script file="gui/test/functions_global_object.js" />
<!--
==========================================
- INCLUDE SCRIPT - GUI PAGE FUNCTIONS
==========================================
-->
<script file="gui/test/functions_page_pregame.js" />
<script file="gui/test/functions_page_pregame_multiplayer.js" />
<script file="gui/test/functions_page_pregame_setup.js" />
<script file="gui/test/functions_page_pregame_load.js" />
<script file="gui/test/functions_page_session.js"/>
<script file="gui/test/functions_page_session_status_pane.js" />
<script file="gui/test/functions_page_session_status_commands.js" />
<script file="gui/test/functions_page_session_manual.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
==========================================
-->
<script file="gui/test/functions_global_init.js"><![CDATA[
init();
]]></script>
</objects>
File diff suppressed because it is too large Load Diff
+104 -104
View File
@@ -1,104 +1,104 @@
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE objects SYSTEM "../gui.dtd">
<!--
==========================================
- LOADING SCREEN -
==========================================
-->
<objects>
<object name="ld"
type="image"
hidden="true"
sprite="bkFillBlack"
>
<!--
==========================================
- LOADING SCREEN - WINDOW
==========================================
-->
<object name="ldWindow"
style="wheatWindowGranite"
type="image"
size="25 35 100%-25 100%-25"
>
<object name="ldTitleBar"
style="wheatWindowTitleBar"
type="button"
/>
<!--
==========================================
- LOADING SCREEN - TEXT
==========================================
-->
<object name="ldText"
type="text"
size="23.571428% 20 100%-25 100%-100"
font="prospero18"
/>
<!--
==========================================
- LOADING SCREEN - CONCEPT ART
==========================================
-->
<object name="ldConcept"
type="image"
size="30 20 33.3008%+30 88.9323%+20"
sprite="black_bkg"
/>
<!--
==========================================
- LOADING SCREEN - PROGRESSBAR
==========================================
-->
<object name="ldProgressBarText"
type="text"
size="25 100%-190 100%-25 100%-175"
font="tahoma14"
textcolor="0 0 0"
text_align="center"
text_valign="center"
>
<action on="Progress"><![CDATA[
this.caption = g_LoadDescription;
]]></action>
</object>
<object name="ldProgressBar"
style="wheatProgressBarBlue"
type="progressbar"
size="25 100%-160 100%-25 100%-145"
>
<action on="Progress"><![CDATA[
this.caption = g_Progress;
]]></action>
</object>
<!--
==========================================
- LOADING SCREEN - TIP
==========================================
-->
<object name="ldTip"
type="text"
size="25 100%-135 100%-25 100%-25"
textcolor="0 0 0"
font="trebuchet16"
text_align="left"
text_valign="center"
sprite="wheatIndentBorder"
/>
</object>
</object>
</objects>
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE objects SYSTEM "../gui.dtd">
<!--
==========================================
- LOADING SCREEN -
==========================================
-->
<objects>
<object name="ld"
type="image"
hidden="true"
sprite="bkFillBlack"
>
<!--
==========================================
- LOADING SCREEN - WINDOW
==========================================
-->
<object name="ldWindow"
style="wheatWindowGranite"
type="image"
size="25 35 100%-25 100%-25"
>
<object name="ldTitleBar"
style="wheatWindowTitleBar"
type="button"
/>
<!--
==========================================
- LOADING SCREEN - TEXT
==========================================
-->
<object name="ldText"
type="text"
size="23.571428% 20 100%-25 100%-100"
font="prospero18"
/>
<!--
==========================================
- LOADING SCREEN - CONCEPT ART
==========================================
-->
<object name="ldConcept"
type="image"
size="30 20 33.3008%+30 88.9323%+20"
sprite="black_bkg"
/>
<!--
==========================================
- LOADING SCREEN - PROGRESSBAR
==========================================
-->
<object name="ldProgressBarText"
type="text"
size="25 100%-190 100%-25 100%-175"
font="tahoma14"
textcolor="0 0 0"
text_align="center"
text_valign="center"
>
<action on="Progress"><![CDATA[
this.caption = g_LoadDescription;
]]></action>
</object>
<object name="ldProgressBar"
style="wheatProgressBarBlue"
type="progressbar"
size="25 100%-160 100%-25 100%-145"
>
<action on="Progress"><![CDATA[
this.caption = g_Progress;
]]></action>
</object>
<!--
==========================================
- LOADING SCREEN - TIP
==========================================
-->
<object name="ldTip"
type="text"
size="25 100%-135 100%-25 100%-25"
textcolor="0 0 0"
font="trebuchet16"
text_align="left"
text_valign="center"
sprite="wheatIndentBorder"
/>
</object>
</object>
</objects>
File diff suppressed because it is too large Load Diff
+158 -158
View File
@@ -1,158 +1,158 @@
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE objects SYSTEM "../gui.dtd">
<!--
==========================================
- ONLINE MANUAL DEFINITION -
==========================================
-->
<objects>
<object name="mn"
hidden="true"
hotkey="onlinehelp"
>
<action on="Press"><![CDATA[
// Toggle manual if something selected.
if (selection.length > 0)
{
// Ensure manual is refreshed.
refreshManual();
// Open/Close the manual.
guiToggle ("mn");
guiToggle ("sn");
}
]]></action>
<object name="mnBkg"
type="text"
style="wheatWindow"
tooltip_style="snToolTip"
>
<action on="Load"><![CDATA[
// Note: This is an example of addCrd() using the traditional "GUISize" size structure.
// * rleft
// * rtop
// * x1
// * y1
// * x2
// * y2
// * rtop
// * rbottom
// While an unusual syntax, it means you can reference other stored coordinates with getCrd(),
// and combine them with mathematical operations to create dynamic coordinates.
addCrd (this.name, rb,
10,
10,
0,
0,
0,
0,
90,
90);
]]></action>
<object name="mnPortrait"
style="snPortrait"
type="button"
>
<action on="Load"><![CDATA[
// Note: This is an example of addCrd() using a custom structure that saves a lot of extra
// effort when you want to only reference one set of relative coordinates, and know the width
// and height of your control. The function internally takes care of converting this to a
// a "GUISize".
// * rleft
// * rtop
// * x
// * y
// * width
// * height
// While an unusual syntax, it means you can also reference other stored coordinates with
// getCrd(), and combine them with mathematical operations and variables to create dynamic
// coordinates.
addCrd (this.name, rb, 0, 0,
10,
10,
snConst.Portrait.Lrg.Width,
snConst.Portrait.Lrg.Height);
]]></action>
</object>
<!-- Gee needs to implement text clipping, so long text doesn't get clipped to these scroll windows yet. Scroll bars also don't block world input yet. -->
<object name="mnRollover"
type="text"
style="wheatBorderBlack"
font="trebuchet12"
scrollbar="true"
>
<action on="Load"><![CDATA[
addCrd (this.name, rb,
0,
0,
getCrd ("mnPortrait").coord[rb].x+getCrd ("mnPortrait").coord[rb].width+10,
getCrd ("mnPortrait").coord[rb].y,
(getCrd ("mnPortrait").coord[rb].x * -1),
getCrd ("mnPortrait").coord[rb].y+getCrd ("mnPortrait").coord[rb].height,
100,
0);
]]></action>
</object>
<!-- Gee needs to implement text clipping, so long text doesn't get clipped to these scroll windows yet. Scroll bars also don't block world input yet. -->
<object name="mnHistory"
style="wheatBorderBlack"
type="text"
font="trebuchet12"
scrollbar="true"
>
<action on="Load"><![CDATA[
addCrd (this.name, rb,
0,
100,
getCrd ("mnPortrait").coord[rb].x,
(getCrd ("mnRollover").coord[rb].height * -2),
(getCrd ("mnPortrait").coord[rb].x * -1),
(getCrd ("mnPortrait").coord[rb].y * -1),
100,
100);
]]></action>
</object>
<object name="mnText"
style="wheatBorderBlack"
type="text"
scrollbar="true"
>
<action on="Load"><![CDATA[
addCrd (this.name, rb,
0,
0,
getCrd ("mnHistory").coord[rb].x,
getCrd ("mnRollover").coord[rb].y+getCrd ("mnRollover").coord[rb].height+5,
getCrd ("mnHistory").coord[rb].width,
getCrd ("mnHistory").coord[rb].y+getCrd ("mnHistory").coord[rb].height-5,
100,
100);
]]></action>
</object>
<object name="mnExitButton"
style="wheatExit"
type="button"
tooltip="Click this button or hit the hotkey again to close this manual."
>
<action on="Press"><![CDATA[
// Close manual.
guiHide("mn");
guiUnHide("sn");
]]></action>
</object>
</object>
</object>
</objects>
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE objects SYSTEM "../gui.dtd">
<!--
==========================================
- ONLINE MANUAL DEFINITION -
==========================================
-->
<objects>
<object name="mn"
hidden="true"
hotkey="onlinehelp"
>
<action on="Press"><![CDATA[
// Toggle manual if something selected.
if (selection.length > 0)
{
// Ensure manual is refreshed.
refreshManual();
// Open/Close the manual.
guiToggle ("mn");
guiToggle ("sn");
}
]]></action>
<object name="mnBkg"
type="text"
style="wheatWindow"
tooltip_style="snToolTip"
>
<action on="Load"><![CDATA[
// Note: This is an example of addCrd() using the traditional "GUISize" size structure.
// * rleft
// * rtop
// * x1
// * y1
// * x2
// * y2
// * rtop
// * rbottom
// While an unusual syntax, it means you can reference other stored coordinates with getCrd(),
// and combine them with mathematical operations to create dynamic coordinates.
addCrd (this.name, rb,
10,
10,
0,
0,
0,
0,
90,
90);
]]></action>
<object name="mnPortrait"
style="snPortrait"
type="button"
>
<action on="Load"><![CDATA[
// Note: This is an example of addCrd() using a custom structure that saves a lot of extra
// effort when you want to only reference one set of relative coordinates, and know the width
// and height of your control. The function internally takes care of converting this to a
// a "GUISize".
// * rleft
// * rtop
// * x
// * y
// * width
// * height
// While an unusual syntax, it means you can also reference other stored coordinates with
// getCrd(), and combine them with mathematical operations and variables to create dynamic
// coordinates.
addCrd (this.name, rb, 0, 0,
10,
10,
snConst.Portrait.Lrg.Width,
snConst.Portrait.Lrg.Height);
]]></action>
</object>
<!-- Gee needs to implement text clipping, so long text doesn't get clipped to these scroll windows yet. Scroll bars also don't block world input yet. -->
<object name="mnRollover"
type="text"
style="wheatBorderBlack"
font="trebuchet12"
scrollbar="true"
>
<action on="Load"><![CDATA[
addCrd (this.name, rb,
0,
0,
getCrd ("mnPortrait").coord[rb].x+getCrd ("mnPortrait").coord[rb].width+10,
getCrd ("mnPortrait").coord[rb].y,
(getCrd ("mnPortrait").coord[rb].x * -1),
getCrd ("mnPortrait").coord[rb].y+getCrd ("mnPortrait").coord[rb].height,
100,
0);
]]></action>
</object>
<!-- Gee needs to implement text clipping, so long text doesn't get clipped to these scroll windows yet. Scroll bars also don't block world input yet. -->
<object name="mnHistory"
style="wheatBorderBlack"
type="text"
font="trebuchet12"
scrollbar="true"
>
<action on="Load"><![CDATA[
addCrd (this.name, rb,
0,
100,
getCrd ("mnPortrait").coord[rb].x,
(getCrd ("mnRollover").coord[rb].height * -2),
(getCrd ("mnPortrait").coord[rb].x * -1),
(getCrd ("mnPortrait").coord[rb].y * -1),
100,
100);
]]></action>
</object>
<object name="mnText"
style="wheatBorderBlack"
type="text"
scrollbar="true"
>
<action on="Load"><![CDATA[
addCrd (this.name, rb,
0,
0,
getCrd ("mnHistory").coord[rb].x,
getCrd ("mnRollover").coord[rb].y+getCrd ("mnRollover").coord[rb].height+5,
getCrd ("mnHistory").coord[rb].width,
getCrd ("mnHistory").coord[rb].y+getCrd ("mnHistory").coord[rb].height-5,
100,
100);
]]></action>
</object>
<object name="mnExitButton"
style="wheatExit"
type="button"
tooltip="Click this button or hit the hotkey again to close this manual."
>
<action on="Press"><![CDATA[
// Close manual.
guiHide("mn");
guiUnHide("sn");
]]></action>
</object>
</object>
</object>
</objects>
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE objects SYSTEM "../gui.dtd">
<!--
==========================================
- JUKEBOX DEFINITION -
==========================================
-->
<objects>
<object name="jb" >
</object>
</objects>
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE objects SYSTEM "../gui.dtd">
<!--
==========================================
- JUKEBOX DEFINITION -
==========================================
-->
<objects>
<object name="jb" >
</object>
</objects>
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE objects SYSTEM "../gui.dtd">
<!--
==========================================
- SESSION GUI SUB-WINDOW DEFINITIONS -
==========================================
-->
<objects>
</objects>
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE objects SYSTEM "../gui.dtd">
<!--
==========================================
- SESSION GUI SUB-WINDOW DEFINITIONS -
==========================================
-->
<objects>
</objects>
+13 -13
View File
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE objects SYSTEM "../gui.dtd">
<!--
==========================================
- ATLAS SCENARIO EDITOR DEFINITION -
==========================================
-->
<objects>
</objects>
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE objects SYSTEM "../gui.dtd">
<!--
==========================================
- ATLAS SCENARIO EDITOR DEFINITION -
==========================================
-->
<objects>
</objects>
+134 -134
View File
@@ -1,134 +1,134 @@
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE objects SYSTEM "../gui.dtd">
<objects>
<!--
==========================================
- GLOBAL OBJECTS -
==========================================
-->
<object>
<!--
==========================================
- MESSAGE BOX -
==========================================
-->
<object name="mbMain"
style="wheatWindow"
type="image"
hidden="true"
size="50%-400 50%-200 50%+400 50%+200"
z="198"
>
<!-- control for blocking access to other controls in background -->
<object name="mbBlocker"
type="image"
hidden="false"
/>
<object name="mbTitleBar"
style="wheatWindowTitleBar"
type="button"
>mbTitle
</object>
<!-- text -->
<object name="mbText"
style="fancyTextTitleBlack"
type="text"
size="30 30 100%-30 100%-100"
>mbMessage
</object>
<!-- buttons -->
<object name="mbButton1"
style="wheatButtonFancy"
type="button"
size="40 100%-50 33%-30 100%-20"
>mbButton1Caption
<action on="Press"><![CDATA[
eval (getGUIGlobal().mbButton1Code);
guiHide ("mbMain");
]]></action>
</object>
<object name="mbButton2"
style="wheatButtonFancy"
type="button"
size="33%+30 100%-50 66%-40 100%-20"
>mbButton2Caption
<action on="Press"><![CDATA[
eval (getGUIGlobal().mbButton2Code);
guiHide ("mbMain");
]]></action>
</object>
<object name="mbButton3"
style="wheatButtonFancy"
type="button"
size="66%+30 100%-50 100%-40 100%-20"
>mbButton3Caption
<action on="Press"><![CDATA[
eval (getGUIGlobal().mbButton2Code);
guiHide ("mbMain");
]]></action>
</object>
</object>
<!--
==========================================
- FPS COUNTER
==========================================
-->
<object name="fpsCounter"
type="text"
ghost="true"
hidden="true"
hotkey="fps.toggle"
font="verdana16"
textcolor="100 100 0"
size="18 18 200 35"
z="199"
>
<action on="Load"><![CDATA[
setInterval (updateFPS, 1, 200);
]]></action>
<action on="Press"><![CDATA[
guiToggle (this.name);
]]></action>
</object>
<!--
==========================================
- WATERMARK - USED WHEN TAKING OFFICIAL SCREENSHOTS
==========================================
-->
<object name="glbWaterMark"
hidden="true"
hotkey="screenshot.watermark"
z="200"
>
<action on="Press"><![CDATA[
guiToggle ("glbWaterMark");
]]></action>
<object name="glbWaterMarkProductLogo"
type="image"
size="0 100%-88 190 100%"
sprite="watermarkProduct"
/>
<object name="glbWaterMarkCompanyLogo"
type="image"
size="100%-207 100%-28 100% 100%"
sprite="watermarkCompany"
/>
</object>
</object>
</objects>
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE objects SYSTEM "../gui.dtd">
<objects>
<!--
==========================================
- GLOBAL OBJECTS -
==========================================
-->
<object>
<!--
==========================================
- MESSAGE BOX -
==========================================
-->
<object name="mbMain"
style="wheatWindow"
type="image"
hidden="true"
size="50%-400 50%-200 50%+400 50%+200"
z="198"
>
<!-- control for blocking access to other controls in background -->
<object name="mbBlocker"
type="image"
hidden="false"
/>
<object name="mbTitleBar"
style="wheatWindowTitleBar"
type="button"
>mbTitle
</object>
<!-- text -->
<object name="mbText"
style="fancyTextTitleBlack"
type="text"
size="30 30 100%-30 100%-100"
>mbMessage
</object>
<!-- buttons -->
<object name="mbButton1"
style="wheatButtonFancy"
type="button"
size="40 100%-50 33%-30 100%-20"
>mbButton1Caption
<action on="Press"><![CDATA[
eval (getGUIGlobal().mbButton1Code);
guiHide ("mbMain");
]]></action>
</object>
<object name="mbButton2"
style="wheatButtonFancy"
type="button"
size="33%+30 100%-50 66%-40 100%-20"
>mbButton2Caption
<action on="Press"><![CDATA[
eval (getGUIGlobal().mbButton2Code);
guiHide ("mbMain");
]]></action>
</object>
<object name="mbButton3"
style="wheatButtonFancy"
type="button"
size="66%+30 100%-50 100%-40 100%-20"
>mbButton3Caption
<action on="Press"><![CDATA[
eval (getGUIGlobal().mbButton2Code);
guiHide ("mbMain");
]]></action>
</object>
</object>
<!--
==========================================
- FPS COUNTER
==========================================
-->
<object name="fpsCounter"
type="text"
ghost="true"
hidden="true"
hotkey="fps.toggle"
font="verdana16"
textcolor="100 100 0"
size="18 18 200 35"
z="199"
>
<action on="Load"><![CDATA[
setInterval (updateFPS, 1, 200);
]]></action>
<action on="Press"><![CDATA[
guiToggle (this.name);
]]></action>
</object>
<!--
==========================================
- WATERMARK - USED WHEN TAKING OFFICIAL SCREENSHOTS
==========================================
-->
<object name="glbWaterMark"
hidden="true"
hotkey="screenshot.watermark"
z="200"
>
<action on="Press"><![CDATA[
guiToggle ("glbWaterMark");
]]></action>
<object name="glbWaterMarkProductLogo"
type="image"
size="0 100%-88 190 100%"
sprite="watermarkProduct"
/>
<object name="glbWaterMarkCompanyLogo"
type="image"
size="100%-207 100%-28 100% 100%"
sprite="watermarkCompany"
/>
</object>
</object>
</objects>
@@ -1,16 +1,16 @@
/*
DESCRIPTION : Global initialisation functions, called when scripts first included at startup.
NOTES : Use for any initialisation that cannot be mapped to an object.
*/
// ====================================================================
function init ()
{
// Root point for anything that needs to be globally initialised at startup.
initCoord();
initSession();
}
/*
DESCRIPTION : Global initialisation functions, called when scripts first included at startup.
NOTES : Use for any initialisation that cannot be mapped to an object.
*/
// ====================================================================
function init ()
{
// Root point for anything that needs to be globally initialised at startup.
initCoord();
initSession();
}
// ====================================================================
@@ -1,132 +1,132 @@
/*
DESCRIPTION : Contains global GUI functions, which will later be accessible from every GUI script/file.
NOTES : So far, only the message box-related functions are implemented.
*/
/*
***************************************
File version: 0.1
Edited by: Malte, Nov 14 2004
***************************************
Further comments:
Changelog:
v0.1: - first version.
***************************************
*/
// *******************************************
// messageBox
// *******************************************
// @params: int mbWidth, int mbHeight, string mbMessage, string mbTitle, int mbMode, arr mbButtonCaptions
// @return: void
// @desc: Displays a new message box. So far, we can only display one message box at
// a time, since the message box is based on one base-object which is modified
// according to the parameters. Later, we should probably be able to create GUI
// Objects (like the message box) at runtime.
// *******************************************
/*
TODO: Make button code work for any number of buttons without extending the code each time! ((arrays | nested variables) & calculating sizes)
*/
// ====================================================================
function messageBox (mbWidth, mbHeight, mbMessage, mbTitle, mbMode, mbButtonCaptions, mbButtonsCode)
{
mbMainObj = getGUIObjectByName ("mbMain");
mbTitleObj = getGUIObjectByName ("mbTitleBar");
mbTextObj = getGUIObjectByName ("mbText");
mbButton1Obj = getGUIObjectByName ("mbButton1");
mbButton2Obj = getGUIObjectByName ("mbButton2");
mbButton3Obj = getGUIObjectByName ("mbButton3");
// Calculate size
mbLRDiff = mbWidth / 2; // Message box left/right difference from 50% of screen
mbUDDiff = mbHeight / 2; // Message box up/down difference from 50% of screen
mbSizeString = "50%-" + mbLRDiff + " 50%-" + mbUDDiff + " 50%+" + mbLRDiff + " 50%+" + mbUDDiff;
mbMainObj.size = mbSizeString;
// Texts
mbTitleObj.caption = mbTitle;
mbTextObj.caption = mbMessage;
// Message box modes
// There is a number of standard modes, and if none of these is used (mbMode == 0), the button captions will be
// taken from the array mbButtonCaptions; there currently is a maximum of three buttons.
switch (mbMode)
{
case 1:
// Simple Yes/No question box
mbButtonCaptions = new Array("Yes", "No");
break;
case 2:
// Okay-only box
mbButtonCaptions = new Array("OK");
break;
case 3:
// Retry/Abort/Ignore box (will we ever need this?!)
mbButtonCaptions = new Array("Retry", "Ignore", "Abort");
default:
break;
}
// Buttons
switch (mbButtonCaptions.length)
{
case 1:
// One Button only
mbButton1Obj.caption = mbButtonCaptions[0];
mbButton1Obj.size = "30% 100%-80 70% 100%-50";
mbButton1Obj.hidden = false;
mbButton2Obj.hidden = true;
mbButton3Obj.hidden = true;
break;
case 2:
// Two Buttons
mbButton1Obj.caption = mbButtonCaptions[0];
mbButton2Obj.caption = mbButtonCaptions[1];
mbButton1Obj.size = "10% 100%-80 45% 100%-50";
mbButton2Obj.size = "55% 100%-80 90% 100%-50";
mbButton1Obj.hidden = false;
mbButton2Obj.hidden = false;
mbButton3Obj.hidden = true;
break;
case 3:
// Three Buttons
mbButton1Obj.caption = mbButtonCaptions[0];
mbButton2Obj.caption = mbButtonCaptions[1];
mbButton3Obj.caption = mbButtonCaptions[2];
mbButton1Obj.size = "10% 100%-80 30% 100%-50";
mbButton2Obj.size = "40% 100%-80 60% 100%-50";
mbButton3Obj.size = "70% 100%-80 90% 100%-50";
mbButton1Obj.hidden = false;
mbButton2Obj.hidden = false;
mbButton3Obj.hidden = false;
break;
}
// Show the message box
guiUnHide (mbMainObj.name);
// Testing
getGUIGlobal().mbButton1Code = mbButtonsCode[0];
getGUIGlobal().mbButton2Code = mbButtonsCode[1];
getGUIGlobal().mbButton3Code = mbButtonsCode[2];
}
// ====================================================================
function updateFPS()
{
getGUIObjectByName("fpsCounter").caption = "FPS: " + getFPS();
}
/*
DESCRIPTION : Contains global GUI functions, which will later be accessible from every GUI script/file.
NOTES : So far, only the message box-related functions are implemented.
*/
/*
***************************************
File version: 0.1
Edited by: Malte, Nov 14 2004
***************************************
Further comments:
Changelog:
v0.1: - first version.
***************************************
*/
// *******************************************
// messageBox
// *******************************************
// @params: int mbWidth, int mbHeight, string mbMessage, string mbTitle, int mbMode, arr mbButtonCaptions
// @return: void
// @desc: Displays a new message box. So far, we can only display one message box at
// a time, since the message box is based on one base-object which is modified
// according to the parameters. Later, we should probably be able to create GUI
// Objects (like the message box) at runtime.
// *******************************************
/*
TODO: Make button code work for any number of buttons without extending the code each time! ((arrays | nested variables) & calculating sizes)
*/
// ====================================================================
function messageBox (mbWidth, mbHeight, mbMessage, mbTitle, mbMode, mbButtonCaptions, mbButtonsCode)
{
mbMainObj = getGUIObjectByName ("mbMain");
mbTitleObj = getGUIObjectByName ("mbTitleBar");
mbTextObj = getGUIObjectByName ("mbText");
mbButton1Obj = getGUIObjectByName ("mbButton1");
mbButton2Obj = getGUIObjectByName ("mbButton2");
mbButton3Obj = getGUIObjectByName ("mbButton3");
// Calculate size
mbLRDiff = mbWidth / 2; // Message box left/right difference from 50% of screen
mbUDDiff = mbHeight / 2; // Message box up/down difference from 50% of screen
mbSizeString = "50%-" + mbLRDiff + " 50%-" + mbUDDiff + " 50%+" + mbLRDiff + " 50%+" + mbUDDiff;
mbMainObj.size = mbSizeString;
// Texts
mbTitleObj.caption = mbTitle;
mbTextObj.caption = mbMessage;
// Message box modes
// There is a number of standard modes, and if none of these is used (mbMode == 0), the button captions will be
// taken from the array mbButtonCaptions; there currently is a maximum of three buttons.
switch (mbMode)
{
case 1:
// Simple Yes/No question box
mbButtonCaptions = new Array("Yes", "No");
break;
case 2:
// Okay-only box
mbButtonCaptions = new Array("OK");
break;
case 3:
// Retry/Abort/Ignore box (will we ever need this?!)
mbButtonCaptions = new Array("Retry", "Ignore", "Abort");
default:
break;
}
// Buttons
switch (mbButtonCaptions.length)
{
case 1:
// One Button only
mbButton1Obj.caption = mbButtonCaptions[0];
mbButton1Obj.size = "30% 100%-80 70% 100%-50";
mbButton1Obj.hidden = false;
mbButton2Obj.hidden = true;
mbButton3Obj.hidden = true;
break;
case 2:
// Two Buttons
mbButton1Obj.caption = mbButtonCaptions[0];
mbButton2Obj.caption = mbButtonCaptions[1];
mbButton1Obj.size = "10% 100%-80 45% 100%-50";
mbButton2Obj.size = "55% 100%-80 90% 100%-50";
mbButton1Obj.hidden = false;
mbButton2Obj.hidden = false;
mbButton3Obj.hidden = true;
break;
case 3:
// Three Buttons
mbButton1Obj.caption = mbButtonCaptions[0];
mbButton2Obj.caption = mbButtonCaptions[1];
mbButton3Obj.caption = mbButtonCaptions[2];
mbButton1Obj.size = "10% 100%-80 30% 100%-50";
mbButton2Obj.size = "40% 100%-80 60% 100%-50";
mbButton3Obj.size = "70% 100%-80 90% 100%-50";
mbButton1Obj.hidden = false;
mbButton2Obj.hidden = false;
mbButton3Obj.hidden = false;
break;
}
// Show the message box
guiUnHide (mbMainObj.name);
// Testing
getGUIGlobal().mbButton1Code = mbButtonsCode[0];
getGUIGlobal().mbButton2Code = mbButtonsCode[1];
getGUIGlobal().mbButton3Code = mbButtonsCode[2];
}
// ====================================================================
function updateFPS()
{
getGUIObjectByName("fpsCounter").caption = "FPS: " + getFPS();
}
// ====================================================================
@@ -1,99 +1,99 @@
/*
DESCRIPTION : Main Pregame JS Script file.
NOTES : Contains functions and code for Main Menu.
*/
// ====================================================================
// Switch from the archive builder to the main menu.
function startMainMenu()
{
// Reveal the main menu now that the archive has been loaded.
guiHide ("ab");
guiUnHide ("pg");
// Play main 0 A.D. theme when the main menu starts.
curr_music = newRandomSound("music", "menu");
curr_music.loop();
// Set starting volume (I'm using a value of zero here for no sound; feel free to comment out these two lines to use defaults).
// curr_music.setGain (0.0);
// g_ConfigDB.system["sound.mastergain"] = 0.0;
}
// ====================================================================
// Helper function that enables the dark background mask, then reveals a given subwindow object.
function openMainMenuSubWindow (windowName)
{
guiUnHide ("pgSubWindow");
guiUnHide (windowName);
}
// ====================================================================
// Helper function that disables the dark background mask, then hides a given subwindow object.
function closeMainMenuSubWindow (windowName)
{
guiHide ("pgSubWindow");
guiHide (windowName);
}
// ====================================================================
// Switch to a given options tab window.
function openOptionsTab(tabName)
{
// Hide the other tabs.
for (i = 1; i <= 3; i++)
{
switch (i)
{
case 1:
var tmpName = "pgOptionsAudio";
break;
case 2:
var tmpName = "pgOptionsVideo";
break;
case 3:
var tmpName = "pgOptionsGame";
break;
default:
break;
}
if (tmpName != tabName)
{
getGUIObjectByName (tmpName + "Window").hidden = true;
getGUIObjectByName (tmpName + "Button").enabled = true;
}
}
// Make given tab visible.
getGUIObjectByName (tabName + "Window").hidden = false;
getGUIObjectByName (tabName + "Button").enabled = false;
}
// ====================================================================
// Move the credits up the screen.
function updateCredits()
{
// If there are still credit lines to remove, remove them.
if (getNumItems("pgCredits") > 0)
removeItem ("pgCredits", 0);
else
{
// When we've run out of credit,
// Stop the increment timer if it's still active.
cancelInterval();
// Close the credits screen and return.
closeMainMenuSubWindow ("pgCredits");
guiUnHide ("pg");
}
}
// ====================================================================
/*
DESCRIPTION : Main Pregame JS Script file.
NOTES : Contains functions and code for Main Menu.
*/
// ====================================================================
// Switch from the archive builder to the main menu.
function startMainMenu()
{
// Reveal the main menu now that the archive has been loaded.
guiHide ("ab");
guiUnHide ("pg");
// Play main 0 A.D. theme when the main menu starts.
curr_music = newRandomSound("music", "menu");
curr_music.loop();
// Set starting volume (I'm using a value of zero here for no sound; feel free to comment out these two lines to use defaults).
// curr_music.setGain (0.0);
// g_ConfigDB.system["sound.mastergain"] = 0.0;
}
// ====================================================================
// Helper function that enables the dark background mask, then reveals a given subwindow object.
function openMainMenuSubWindow (windowName)
{
guiUnHide ("pgSubWindow");
guiUnHide (windowName);
}
// ====================================================================
// Helper function that disables the dark background mask, then hides a given subwindow object.
function closeMainMenuSubWindow (windowName)
{
guiHide ("pgSubWindow");
guiHide (windowName);
}
// ====================================================================
// Switch to a given options tab window.
function openOptionsTab(tabName)
{
// Hide the other tabs.
for (i = 1; i <= 3; i++)
{
switch (i)
{
case 1:
var tmpName = "pgOptionsAudio";
break;
case 2:
var tmpName = "pgOptionsVideo";
break;
case 3:
var tmpName = "pgOptionsGame";
break;
default:
break;
}
if (tmpName != tabName)
{
getGUIObjectByName (tmpName + "Window").hidden = true;
getGUIObjectByName (tmpName + "Button").enabled = true;
}
}
// Make given tab visible.
getGUIObjectByName (tabName + "Window").hidden = false;
getGUIObjectByName (tabName + "Button").enabled = false;
}
// ====================================================================
// Move the credits up the screen.
function updateCredits()
{
// If there are still credit lines to remove, remove them.
if (getNumItems("pgCredits") > 0)
removeItem ("pgCredits", 0);
else
{
// When we've run out of credit,
// Stop the increment timer if it's still active.
cancelInterval();
// Close the credits screen and return.
closeMainMenuSubWindow ("pgCredits");
guiUnHide ("pg");
}
}
// ====================================================================
@@ -1,190 +1,190 @@
/*
DESCRIPTION : Functions used load/end the game session and manipulate the loading screen.
NOTES :
*/
// ====================================================================
function launchGame ()
{
// Starts the map, closing the session setup window.
var mapName = getCurrItemValue("pgSessionSetupMapName");
var gameMode = getCurrItemValue("pgSessionSetupGameMode");
var screenshotMode = getGUIObjectByName("pgSessionSetupScreenshotMode").checked;
var losSetting = getGUIObjectByName("pgSessionSetupLosSetting").selected;
var fogOfWar = getGUIObjectByName("pgSessionSetupFoW").checked;
if(screenshotMode)
{
losSetting = 2;
fogOfWar = false;
}
// Check whether we have a correct file extension, to avoid crashes
var extension = mapName.substring (mapName.length, mapName.length-4);
if (extension != ".pmp")
{
// Add .pmp to the file name.
var mapName = mapName + ".pmp";
}
// Set up game
g_GameAttributes.mapFile = mapName;
g_GameAttributes.losSetting = losSetting;
g_GameAttributes.fogOfWar = fogOfWar;
g_GameAttributes.gameMode = gameMode
g_GameAttributes.screenshotMode = screenshotMode;
// Close setup window
closeMainMenuSubWindow ("pgSessionSetup");
// Display loading screen.
startLoadingScreen();
console.write( "running startGame()" );
// Begin game session.
if (! startGame())
{
// Failed to start the game; go back to the main menu.
guiSwitch ("ld", "pg");
// Restore default cursor.
setCursor ("arrow-default");
// Show an error message
btCaptions = new Array("OK");
btCode = new Array("");
messageBox(400, 200, "The game could not be started with the given parameters. You probably have entered an invalid map name.", "Error", 0, btCaptions, btCode);
}
console.write( "done running startGame()" );
// Set starting UI layout.
GUIType=rb;
// Set session UI sprites to match the skin for the player's civilisation.
// (We don't have skins for all civs yet, so we're using the standard menu skin. But it should be settable from here later.)
setSkin ("wheat");
// Set GUI coordinates to starting orientation.
flipGUI (GUIType);
}
// ====================================================================
function startLoadingScreen()
{
// Switch screens from main menu to loading screen.
guiSwitch ("pg", "ld");
// Set to "hourglass" cursor.
setCursor("cursor-wait");
console.write ("Loading " + g_GameAttributes.mapFile + " (" + g_GameAttributes.numPlayers + " players) ...");
// Choose random concept art for loading screen background (should depend on the selected civ later when this is specified).
var sprite = "";
var loadingBkgArray = buildDirEntList("art/textures/ui/loading/", "*.dds", false);
if (loadingBkgArray.length == 0)
console.write ("ERROR: Failed to find any matching textures for the loading screen background.");
else
{
// Get a random index from the list of loading screen backgrounds.
sprite = "stretched:" + loadingBkgArray[getRandom (0, loadingBkgArray.length-1)];
sprite = sprite.replace ("art/textures/ui/", "");
}
getGUIObjectByName ("ldConcept").sprite = sprite;
// janwas: main loop now sets progress / description, but that won't
// happen until the first timeslice completes, so set initial values.
getGUIObjectByName ("ldTitleBar").caption = "Loading Scenario ...";
getGUIObjectByName ("ldProgressBarText").caption = "";
getGUIObjectByName ("ldProgressBar").caption = 0;
getGUIObjectByName ("ldText").caption = "LOADING " + g_GameAttributes.mapFile + " ...\nPlease wait ...";
// Pick a random tip of the day (each line is a separate tip).
var tipArray = readFileLines("gui/text/tips.txt");
// Set tip string.
getGUIObjectByName ("ldTip").caption = tipArray[getRandom(0, tipArray.length-1)];
}
// ====================================================================
function reallyStartGame()
{
// This is a reserved function name that is executed by the engine when it is ready
// to start the game (ie loading progress has reached 100%).
// Create resource pools for each player, etc.
setupSession();
// Switch GUI from loading screen to game session.
guiSwitch ("ld", "sn");
// Restore default cursor.
setCursor ("arrow-default");
}
// ====================================================================
function setupSession ()
{
// Do essentials that can only be done when the session has been loaded ...
// For example, create the resource types, scores, etc, for each player.
/*
if (sessionType == "Skirmish")
{
// Set up a bunch of players so we can see them pretty colours. :P
console.write ("Setting Up Temporary Single Players");
// The first player is by default allocated to the local player in SP, so
// adding 7 players means that we'll have 8 players in total
for (var i=0; i<7; i++)
{
g_GameAttributes.slots[i+1].assignLocal();
console.write ("Slot "+(i+1)+" is assigned: " + g_GameAttributes.slots[i+1].assignment);
}
}
*/
// Select session peace track.
curr_session_playlist_1 = newRandomSound("music", "peace");
// Fade out main theme and fade in session theme.
crossFade(curr_music, curr_session_playlist_1, 1)
// Create the resouce counters
createResourceCounters();
// Start refreshing the session controls.
setInterval( snRefresh, 1, 100 );
}
// ====================================================================
function endSession (closeType)
{
// Occurs when the player chooses to close the current game.
switch (closeType)
{
case ("return"):
// If the player has chosen to quit game and return to main menu,
// End the session.
endGame();
// Fade out current music and return to playing menu theme.
//curr_music = newRandomSound("music", "menu");
//crossFade(curr_session_playlist_1, curr_music, 1);
// Stop refreshing the session controls.
cancelInterval();
// Swap GUIs to display main menu.
guiSwitch ("sn", "pg");
break;
case ("exit"):
// If the player has chosen to shutdown and immediately return to operating system,
exit();
break;
}
}
// ====================================================================
/*
DESCRIPTION : Functions used load/end the game session and manipulate the loading screen.
NOTES :
*/
// ====================================================================
function launchGame ()
{
// Starts the map, closing the session setup window.
var mapName = getCurrItemValue("pgSessionSetupMapName");
var gameMode = getCurrItemValue("pgSessionSetupGameMode");
var screenshotMode = getGUIObjectByName("pgSessionSetupScreenshotMode").checked;
var losSetting = getGUIObjectByName("pgSessionSetupLosSetting").selected;
var fogOfWar = getGUIObjectByName("pgSessionSetupFoW").checked;
if(screenshotMode)
{
losSetting = 2;
fogOfWar = false;
}
// Check whether we have a correct file extension, to avoid crashes
var extension = mapName.substring (mapName.length, mapName.length-4);
if (extension != ".pmp")
{
// Add .pmp to the file name.
var mapName = mapName + ".pmp";
}
// Set up game
g_GameAttributes.mapFile = mapName;
g_GameAttributes.losSetting = losSetting;
g_GameAttributes.fogOfWar = fogOfWar;
g_GameAttributes.gameMode = gameMode
g_GameAttributes.screenshotMode = screenshotMode;
// Close setup window
closeMainMenuSubWindow ("pgSessionSetup");
// Display loading screen.
startLoadingScreen();
console.write( "running startGame()" );
// Begin game session.
if (! startGame())
{
// Failed to start the game; go back to the main menu.
guiSwitch ("ld", "pg");
// Restore default cursor.
setCursor ("arrow-default");
// Show an error message
btCaptions = new Array("OK");
btCode = new Array("");
messageBox(400, 200, "The game could not be started with the given parameters. You probably have entered an invalid map name.", "Error", 0, btCaptions, btCode);
}
console.write( "done running startGame()" );
// Set starting UI layout.
GUIType=rb;
// Set session UI sprites to match the skin for the player's civilisation.
// (We don't have skins for all civs yet, so we're using the standard menu skin. But it should be settable from here later.)
setSkin ("wheat");
// Set GUI coordinates to starting orientation.
flipGUI (GUIType);
}
// ====================================================================
function startLoadingScreen()
{
// Switch screens from main menu to loading screen.
guiSwitch ("pg", "ld");
// Set to "hourglass" cursor.
setCursor("cursor-wait");
console.write ("Loading " + g_GameAttributes.mapFile + " (" + g_GameAttributes.numPlayers + " players) ...");
// Choose random concept art for loading screen background (should depend on the selected civ later when this is specified).
var sprite = "";
var loadingBkgArray = buildDirEntList("art/textures/ui/loading/", "*.dds", false);
if (loadingBkgArray.length == 0)
console.write ("ERROR: Failed to find any matching textures for the loading screen background.");
else
{
// Get a random index from the list of loading screen backgrounds.
sprite = "stretched:" + loadingBkgArray[getRandom (0, loadingBkgArray.length-1)];
sprite = sprite.replace ("art/textures/ui/", "");
}
getGUIObjectByName ("ldConcept").sprite = sprite;
// janwas: main loop now sets progress / description, but that won't
// happen until the first timeslice completes, so set initial values.
getGUIObjectByName ("ldTitleBar").caption = "Loading Scenario ...";
getGUIObjectByName ("ldProgressBarText").caption = "";
getGUIObjectByName ("ldProgressBar").caption = 0;
getGUIObjectByName ("ldText").caption = "LOADING " + g_GameAttributes.mapFile + " ...\nPlease wait ...";
// Pick a random tip of the day (each line is a separate tip).
var tipArray = readFileLines("gui/text/tips.txt");
// Set tip string.
getGUIObjectByName ("ldTip").caption = tipArray[getRandom(0, tipArray.length-1)];
}
// ====================================================================
function reallyStartGame()
{
// This is a reserved function name that is executed by the engine when it is ready
// to start the game (ie loading progress has reached 100%).
// Create resource pools for each player, etc.
setupSession();
// Switch GUI from loading screen to game session.
guiSwitch ("ld", "sn");
// Restore default cursor.
setCursor ("arrow-default");
}
// ====================================================================
function setupSession ()
{
// Do essentials that can only be done when the session has been loaded ...
// For example, create the resource types, scores, etc, for each player.
/*
if (sessionType == "Skirmish")
{
// Set up a bunch of players so we can see them pretty colours. :P
console.write ("Setting Up Temporary Single Players");
// The first player is by default allocated to the local player in SP, so
// adding 7 players means that we'll have 8 players in total
for (var i=0; i<7; i++)
{
g_GameAttributes.slots[i+1].assignLocal();
console.write ("Slot "+(i+1)+" is assigned: " + g_GameAttributes.slots[i+1].assignment);
}
}
*/
// Select session peace track.
curr_session_playlist_1 = newRandomSound("music", "peace");
// Fade out main theme and fade in session theme.
crossFade(curr_music, curr_session_playlist_1, 1)
// Create the resouce counters
createResourceCounters();
// Start refreshing the session controls.
setInterval( snRefresh, 1, 100 );
}
// ====================================================================
function endSession (closeType)
{
// Occurs when the player chooses to close the current game.
switch (closeType)
{
case ("return"):
// If the player has chosen to quit game and return to main menu,
// End the session.
endGame();
// Fade out current music and return to playing menu theme.
//curr_music = newRandomSound("music", "menu");
//crossFade(curr_session_playlist_1, curr_music, 1);
// Stop refreshing the session controls.
cancelInterval();
// Swap GUIs to display main menu.
guiSwitch ("sn", "pg");
break;
case ("exit"):
// If the player has chosen to shutdown and immediately return to operating system,
exit();
break;
}
}
// ====================================================================
@@ -1,147 +1,147 @@
/*
DESCRIPTION : Functions for the hosting and joining multiplayer games.
NOTES :
*/
// ====================================================================
function initMPHost (parentWindow, gameName, welcomeMessage, profileName)
{
// Set up the server
var server = createServer();
// Welcome message
server.welcomeMessage = welcomeMessage;
// Server Name
server.serverName = gameName;
// Host Name
server.serverPlayerName = profileName;
// start listening
var success = server.open();
if (!success)
{
messageBox(400, 200, "Failed to start server. Please review the logfile for more information on the problem.", "Problem", 2, new Array(), new Array());
return 1;
}
else
{
console.write ("Host has started listening for client connections.");
// Switch to Session Setup screen.
sessionType = "Host";
openSessionSetup (parentWindow);
}
// -------------------------
// INCOMING CONNECTIONS
// -------------------------
server.onClientConnect = function (event)
{
console.write ("Client connected.");
console.write("A new client has successfully connected! ID: " + event.id + ", Name: " + event.name + ", Session: " + event.session);
// Assign newly connected client to next available slot.
var playerSlot = g_GameAttributes.getOpenSlot();
playerSlot.assignToSession (event.session);
// Set player slot to new player's name
var slotID = g_GameAttributes.getUsedSlotsAmount;
pushItem ("pgSessionSetupP" + slotID, g_GameAttributes.slots[slotID-1].player.name);
}
server.onClientDisconnect = function (event)
{
// Client has disconnected; free their slot.
var slotID = g_GameAttributes.getUsedSlotsAmount-1;
g_GameAttributes.slots[slotID].assignOpen();
var result = setCurrItemValue ("pgSessionSetupP" + slotID, "Open");
messageBox(400, 200, "Client " + event.name + "(" + event.id + ") disconnected from " + event.session + ".", "Client Disconnected", 2, new Array(), new Array());
}
server.onChat = function (event)
{
messageBox(400, 200, "(" + event.sender + ")" + event.message, "Host Chat Message", 2, new Array(), new Array());
}
// Need "waiting for more players to join and start game" code here
}
// ====================================================================
function initMPClient (mpParentWindow, ipAddress, profileName)
{
// Create the client instance
var client = createClient();
// Player Name
client.playerName = profileName;
client.onClientConnect = function (event)
{
// Set player slot to new player's name.
console.write("onClientConnect: name is " + event.name + ", event id is " + event.id);
var slotID = g_GameAttributes.getUsedSlotsAmount;
console.write("slotID="+slotID);
pushItem ("pgSessionSetupP" + eval(slotID+1), g_GameAttributes.slots[slotID].player.name);
}
client.onConnectComplete = function (event)
{
console.write("onConnectComplete: " + event.message);
if (event.success)
{
// Switch to Session Setup screen.
sessionType = "Client";
openSessionSetup ("pgMPJoin");
messageBox (400, 200, "Client connected " + event.message + ".",
"Connect Complete", 2, new Array(), new Array());
}
else
{
messageBox (400, 200, "Client failed to complete connection: " + event.message + ".",
"Connect Failure", 2, new Array(), new Array());
}
}
client.onChat = function (event)
{
messageBox (400, 200, "(" + event.sender + ")" + event.message,
"Client Chat Message", 2, new Array(), new Array());
}
client.onDisconnect = function (event)
{
console.write("onDisconnect: " + event.message);
messageBox (400, 200, event.message,
"Host Disconnected", 2, new Array(), new Array());
}
client.onClientDisconnect = function (event)
{
console.write("onClientDisconnect: " + event.message);
messageBox (400, 200, event.session,
"Client " + event.name + "(" + event.id + ") Disconnected", 2, new Array(), new Array());
}
client.onStartGame = function (event)
{
// The server has called Start Game!, so we better switch to the session GUI and stuff like that.
launchGame();
}
var success = client.beginConnect (ipAddress);
if (!success)
{
messageBox(400, 200, "Failed to connect to server. Please check the network connection.",
"Client Failure", 2, new Array(), new Array());
return 1;
}
else
{
console.write ("Client successfully started to connect to " + ipAddress + ".");
}
}
// ====================================================================
/*
DESCRIPTION : Functions for the hosting and joining multiplayer games.
NOTES :
*/
// ====================================================================
function initMPHost (parentWindow, gameName, welcomeMessage, profileName)
{
// Set up the server
var server = createServer();
// Welcome message
server.welcomeMessage = welcomeMessage;
// Server Name
server.serverName = gameName;
// Host Name
server.serverPlayerName = profileName;
// start listening
var success = server.open();
if (!success)
{
messageBox(400, 200, "Failed to start server. Please review the logfile for more information on the problem.", "Problem", 2, new Array(), new Array());
return 1;
}
else
{
console.write ("Host has started listening for client connections.");
// Switch to Session Setup screen.
sessionType = "Host";
openSessionSetup (parentWindow);
}
// -------------------------
// INCOMING CONNECTIONS
// -------------------------
server.onClientConnect = function (event)
{
console.write ("Client connected.");
console.write("A new client has successfully connected! ID: " + event.id + ", Name: " + event.name + ", Session: " + event.session);
// Assign newly connected client to next available slot.
var playerSlot = g_GameAttributes.getOpenSlot();
playerSlot.assignToSession (event.session);
// Set player slot to new player's name
var slotID = g_GameAttributes.getUsedSlotsAmount;
pushItem ("pgSessionSetupP" + slotID, g_GameAttributes.slots[slotID-1].player.name);
}
server.onClientDisconnect = function (event)
{
// Client has disconnected; free their slot.
var slotID = g_GameAttributes.getUsedSlotsAmount-1;
g_GameAttributes.slots[slotID].assignOpen();
var result = setCurrItemValue ("pgSessionSetupP" + slotID, "Open");
messageBox(400, 200, "Client " + event.name + "(" + event.id + ") disconnected from " + event.session + ".", "Client Disconnected", 2, new Array(), new Array());
}
server.onChat = function (event)
{
messageBox(400, 200, "(" + event.sender + ")" + event.message, "Host Chat Message", 2, new Array(), new Array());
}
// Need "waiting for more players to join and start game" code here
}
// ====================================================================
function initMPClient (mpParentWindow, ipAddress, profileName)
{
// Create the client instance
var client = createClient();
// Player Name
client.playerName = profileName;
client.onClientConnect = function (event)
{
// Set player slot to new player's name.
console.write("onClientConnect: name is " + event.name + ", event id is " + event.id);
var slotID = g_GameAttributes.getUsedSlotsAmount;
console.write("slotID="+slotID);
pushItem ("pgSessionSetupP" + eval(slotID+1), g_GameAttributes.slots[slotID].player.name);
}
client.onConnectComplete = function (event)
{
console.write("onConnectComplete: " + event.message);
if (event.success)
{
// Switch to Session Setup screen.
sessionType = "Client";
openSessionSetup ("pgMPJoin");
messageBox (400, 200, "Client connected " + event.message + ".",
"Connect Complete", 2, new Array(), new Array());
}
else
{
messageBox (400, 200, "Client failed to complete connection: " + event.message + ".",
"Connect Failure", 2, new Array(), new Array());
}
}
client.onChat = function (event)
{
messageBox (400, 200, "(" + event.sender + ")" + event.message,
"Client Chat Message", 2, new Array(), new Array());
}
client.onDisconnect = function (event)
{
console.write("onDisconnect: " + event.message);
messageBox (400, 200, event.message,
"Host Disconnected", 2, new Array(), new Array());
}
client.onClientDisconnect = function (event)
{
console.write("onClientDisconnect: " + event.message);
messageBox (400, 200, event.session,
"Client " + event.name + "(" + event.id + ") Disconnected", 2, new Array(), new Array());
}
client.onStartGame = function (event)
{
// The server has called Start Game!, so we better switch to the session GUI and stuff like that.
launchGame();
}
var success = client.beginConnect (ipAddress);
if (!success)
{
messageBox(400, 200, "Failed to connect to server. Please check the network connection.",
"Client Failure", 2, new Array(), new Array());
return 1;
}
else
{
console.write ("Client successfully started to connect to " + ipAddress + ".");
}
}
// ====================================================================
@@ -1,152 +1,152 @@
/*
DESCRIPTION : Functions for configuring a game prior to the loading screen (hosting, joining, or skirmish).
NOTES :
*/
// ====================================================================
// Open the Session Setup screen.
function openSessionSetup (sessionReturnWindow)
{
var profileName = getCurrItemValue ("pgProfileName");
var titleBar = getGUIObjectByName ("pgSessionSetupTitleBar");
// Setup remaining slots.
for (var i = 1; i <= g_GameAttributes.numSlots; i++)
{
if (i == 1)
{
// Set the host player's name on the setup screen.
getGUIObjectByName ("pgSessionSetupP" + i).caption = "(Host)";
}
else
/*
DESCRIPTION : Functions for configuring a game prior to the loading screen (hosting, joining, or skirmish).
NOTES :
*/
// ====================================================================
// Open the Session Setup screen.
function openSessionSetup (sessionReturnWindow)
{
var profileName = getCurrItemValue ("pgProfileName");
var titleBar = getGUIObjectByName ("pgSessionSetupTitleBar");
// Setup remaining slots.
for (var i = 1; i <= g_GameAttributes.numSlots; i++)
{
if (i == 1)
{
// Set the host player's name on the setup screen.
getGUIObjectByName ("pgSessionSetupP" + i).caption = "(Host)";
}
else
{
if (getNumItems("pgSessionSetupP" + i) == 0)
{
//pushItem ("pgSessionSetupP" + i, "session");
pushItem ("pgSessionSetupP" + i, "Open");
pushItem ("pgSessionSetupP" + i, "Closed");
//pushItem ("pgSessionSetupP" + i, "local");
//pushItem ("pgSessionSetupP" + i, "AI");
// Set other slots to Open.
var result = setCurrItemValue ("pgSessionSetupP" + i, "Open");
// Setup onchange event (closing and opening affects host slots).
getGUIObjectByName ("pgSessionSetupP" + i).onSelectionChange = function (event)
{
var slotNumber = this.name.substring (this.name.length-1, this.name.length);
switch (getCurrItemValue (this.name))
{
case "Open":
// If "Open" selected,
// Open the slot.
g_GameAttributes.slots[slotNumber-1].assignOpen();
//console.write ("Opened slot " + this.name);
break;
case "Closed":
// If "Closed" selected,
// And slot is occupied,
if (g_GameAttributes.slots[slotNumber-1].assignment == "session")
{
// Remove player name from slot list.
removeItem (this.name, g_GameAttributes.slots[slotNumber-1].player);
// Prompt that player was kicked.
// (Change this to a chat message when functionality available.)
console.write (g_GameAttributes.slots[slotNumber-1].player + " was kicked by the host.");
}
// Close the slot.
g_GameAttributes.slots[slotNumber-1].assignClosed();
//console.write ("Closed slot " + this.name);
break;
default:
break;
}
}
}
}
// Make objects non-interactive to client.
if (sessionType == "Client") guiDisable ("pgSessionSetupP" + i);
}
// Set the title for the setup screen
switch (sessionType)
{
case "Host":
titleBar.caption = "Hosting: " + g_NetServer.serverName;
// Reveal type-specific Session Setup objects.
guiUnHide ("pgSessionSetupMP");
guiUnHide ("pgSessionSetupMPHost");
guiUnHide ("pgSessionSetupMaster");
break;
case "Client":
titleBar.caption = "Joining: " // g_NetServer.serverName;
// Reveal type-specific Session Setup objects.
guiUnHide ("pgSessionSetupMP");
guiUnHide ("pgSessionSetupMPClient");
// Disable objects that clients shouldn't be able to modify.
guiDisable ("pgSessionSetupMapName");
guiDisable ("pgSessionSetupStartButton");
break;
case "Skirmish":
titleBar.caption = "Skirmish";
// Reveal type-specific Session Setup objects.
guiUnHide ("pgSessionSetupSkirmish");
guiUnHide ("pgSessionSetupMaster");
break;
default:
break;
}
// Reveal GUI.
guiHide ("pgVersionNumber");
if (sessionReturnWindow != "")
guiSwitch (sessionReturnWindow, "pgSessionSetup");
else
openMainMenuSubWindow ("pgSessionSetup");
}
// ====================================================================
// Close/cancel the Session Setup screen.
function closeSessionSetup ()
{
// Hide type-specific objects.
guiHide ("pgSessionSetupMP");
guiHide ("pgSessionSetupMPHost");
guiHide ("pgSessionSetupMPClient");
guiHide ("pgSessionSetupSkirmish");
guiHide ("pgSessionSetupMaster");
// Return to previous screen.
switch (sessionType)
{
case "Host":
case "Client":
// terminate the multiplayer server session
endGame();
// Go back to multiplayer mode selection screen.
guiSwitch ("pgSessionSetup", "pgMPModeSel");
break;
case "Skirmish":
// Go back to main menu.
closeMainMenuSubWindow ("pgSessionSetup");
break;
default:
break;
}
guiUnHide ("pgVersionNumber");
}
// ====================================================================
{
//pushItem ("pgSessionSetupP" + i, "session");
pushItem ("pgSessionSetupP" + i, "Open");
pushItem ("pgSessionSetupP" + i, "Closed");
//pushItem ("pgSessionSetupP" + i, "local");
//pushItem ("pgSessionSetupP" + i, "AI");
// Set other slots to Open.
var result = setCurrItemValue ("pgSessionSetupP" + i, "Open");
// Setup onchange event (closing and opening affects host slots).
getGUIObjectByName ("pgSessionSetupP" + i).onSelectionChange = function (event)
{
var slotNumber = this.name.substring (this.name.length-1, this.name.length);
switch (getCurrItemValue (this.name))
{
case "Open":
// If "Open" selected,
// Open the slot.
g_GameAttributes.slots[slotNumber-1].assignOpen();
//console.write ("Opened slot " + this.name);
break;
case "Closed":
// If "Closed" selected,
// And slot is occupied,
if (g_GameAttributes.slots[slotNumber-1].assignment == "session")
{
// Remove player name from slot list.
removeItem (this.name, g_GameAttributes.slots[slotNumber-1].player);
// Prompt that player was kicked.
// (Change this to a chat message when functionality available.)
console.write (g_GameAttributes.slots[slotNumber-1].player + " was kicked by the host.");
}
// Close the slot.
g_GameAttributes.slots[slotNumber-1].assignClosed();
//console.write ("Closed slot " + this.name);
break;
default:
break;
}
}
}
}
// Make objects non-interactive to client.
if (sessionType == "Client") guiDisable ("pgSessionSetupP" + i);
}
// Set the title for the setup screen
switch (sessionType)
{
case "Host":
titleBar.caption = "Hosting: " + g_NetServer.serverName;
// Reveal type-specific Session Setup objects.
guiUnHide ("pgSessionSetupMP");
guiUnHide ("pgSessionSetupMPHost");
guiUnHide ("pgSessionSetupMaster");
break;
case "Client":
titleBar.caption = "Joining: " // g_NetServer.serverName;
// Reveal type-specific Session Setup objects.
guiUnHide ("pgSessionSetupMP");
guiUnHide ("pgSessionSetupMPClient");
// Disable objects that clients shouldn't be able to modify.
guiDisable ("pgSessionSetupMapName");
guiDisable ("pgSessionSetupStartButton");
break;
case "Skirmish":
titleBar.caption = "Skirmish";
// Reveal type-specific Session Setup objects.
guiUnHide ("pgSessionSetupSkirmish");
guiUnHide ("pgSessionSetupMaster");
break;
default:
break;
}
// Reveal GUI.
guiHide ("pgVersionNumber");
if (sessionReturnWindow != "")
guiSwitch (sessionReturnWindow, "pgSessionSetup");
else
openMainMenuSubWindow ("pgSessionSetup");
}
// ====================================================================
// Close/cancel the Session Setup screen.
function closeSessionSetup ()
{
// Hide type-specific objects.
guiHide ("pgSessionSetupMP");
guiHide ("pgSessionSetupMPHost");
guiHide ("pgSessionSetupMPClient");
guiHide ("pgSessionSetupSkirmish");
guiHide ("pgSessionSetupMaster");
// Return to previous screen.
switch (sessionType)
{
case "Host":
case "Client":
// terminate the multiplayer server session
endGame();
// Go back to multiplayer mode selection screen.
guiSwitch ("pgSessionSetup", "pgMPModeSel");
break;
case "Skirmish":
// Go back to main menu.
closeMainMenuSubWindow ("pgSessionSetup");
break;
default:
break;
}
guiUnHide ("pgVersionNumber");
}
// ====================================================================
@@ -1,418 +1,418 @@
/*
DESCRIPTION : Functions for "main game" session GUI.
NOTES :
*/
// ====================================================================
function initSession()
{
// ============================================= CONSTANTS =================================================
snConst = new Object();
// Portraits (large and small).
snConst.Portrait = new Object();
snConst.Portrait.Sml = new Object();
snConst.Portrait.Sml.Width = 45;
snConst.Portrait.Sml.Height = snConst.Portrait.Sml.Width;
snConst.Portrait.Lrg = new Object();
snConst.Portrait.Lrg.Width = 64;
snConst.Portrait.Lrg.Height = snConst.Portrait.Lrg.Width;
// Small icons (eg Movement Rate, Food).
snConst.MiniIcon = new Object();
snConst.MiniIcon.Width = 30;
snConst.MiniIcon.Height = snConst.MiniIcon.Width;
// ============================================= GLOBALS =================================================
// Define cell reference constants for icon sheets.
initCellReference();
}
// ====================================================================
function initCellReference()
{
cellGroup = new Array();
// Define categories of cell groups by checking their reference files in the same locations as the icon sheets.
addCellGroupCategory ("art/textures/ui/session/icons/sheets/");
// (Note that we don't use this and we probably shouldn't, since the entities state which icon cell they should use; it makes it easier to remember which icon is used
// for which unit if we have this reference sheet, though.)
addCellGroupCategory ("art/textures/ui/session/portraits/sheets/");
}
// ====================================================================
function addCellGroupCategory(iconSheetPath)
{
// Get array list of all icon sheet reference files.
var iconSheets = buildDirEntList (iconSheetPath, "*.txt", true);
// Alphabetically sort the array.
iconSheets.sort();
// Seek through all icon sheets.
for (var sheet = 0; sheet < iconSheets.length; sheet++)
{
// Get the current icon sheet name.
var groupName = iconSheets[sheet];
// Remove path and extension information so we just have the group name.
groupName = groupName.replace (iconSheetPath, "");
groupName = groupName.replace (".txt", "");
groupName = toTitleCase(groupName);
// Get the elements from the current icon sheet.
var iconArray = readFileLines (iconSheets[sheet]);
// For each row in the icon sheet file,
for (var row = 0; row < iconArray.length; row++)
{
// Get the individual fields in the array as another array.
var iconElements = iconArray[row].split (",");
// Add this cell to the current group.
addCell (groupName, iconElements[0], iconElements[1]);
}
}
}
// ====================================================================
function addCell (group, cellID, cellName)
{
// Add a cell ID to a cell container group.
// If this array does not exist,
if (!cellGroup[group])
{
// Create the container.
cellGroup[group] = new Array();
cellGroup[group].length = new Object(0);
}
cellGroup[group][cellID] = new Array();
cellGroup[group][cellID].id = new Object (cellGroup[group].length);
cellGroup[group][cellID].name = new Object (cellName);
cellGroup[group].length++;
}
// ====================================================================
function setPortrait(objectName, portraitString, portraitSuffix, portraitCell)
{
// Use this function as a shortcut to change a portrait object to a different portrait image.
// Accepts an object and specifies its default, rollover (lit) and disabled (gray) sprites.
// Sprite Format: "sn""portraitString""portraitSuffix"
// Sprite Format: "sn""portraitString""portraitSuffix""Over"
// Sprite Format: "sn""portraitString""portraitSuffix""Disabled"
// Note: Make sure the file follows this naming convention or bad things could happen.
// Get GUI object
setPortraitGUIObject = getGUIObjectByName(objectName);
// Report error if object not found.
if (!setPortraitGUIObject)
{
console.write ("setPortrait(): Failed to find object " + objectName + ".");
return 1;
}
// Set the three portraits.
if (portraitSuffix && portraitSuffix != "")
setPortraitGUIObject.sprite = "sn" + portraitString + portraitSuffix;
else
setPortraitGUIObject.sprite = "sn" + portraitString;
setPortraitGUIObject.sprite_over = setPortraitGUIObject.sprite + "Over";
setPortraitGUIObject.sprite_disabled = setPortraitGUIObject.sprite + "Disabled";
// If the source texture is a multi-frame image (icon sheet), specify correct cell.
if (portraitCell && portraitCell != "")
setPortraitGUIObject.cell_id = portraitCell;
else
setPortraitGUIObject.cell_id = "";
return 0;
}
// ====================================================================
function flipGUI (NewGUIType)
{
// Changes GUI to a different layout.
switch (NewGUIType)
{
// Set which GUI to use.
case rb:
case lb:
case lt:
case rt:
GUIType = NewGUIType;
break;
default:
// If no type specified, toggle.
if (GUIType == rb)
GUIType = lb;
else
if (GUIType == lb)
GUIType = lt;
else
if (GUIType == lt)
GUIType = rt;
else
GUIType = rb;
break;
}
// Seek through all sizes created.
for (var i = 0; i <= Crd.last; i++)
{
// Set their sizes to the stored value.
getGUIObjectByName (Crd[i].name).size = Crd[i].size[GUIType];
}
writeConsole("GUI flipped to size " + GUIType + ".");
}
// ====================================================================
// 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.length > 0 && 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.length > 0 && 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();
// Refresh handler that monitors whether property/selection has been updated.
resetUpdateVars();
// Refresh resources
refreshResources();
}
if ( selectionChanged && getGUIObjectByName( "mn" ).hidden == false)
{
// Update manual if it's open.
refreshManual();
}
}
// ====================================================================
function confirmLeave()
{
if (isGameRunning())
{
endSession("return");
}
else
{
exit();
}
}
// ====================================================================
playersList_init = false;
function togglePlayersList()
{
//Initialization of names and colors.
if (!playersList_init)
{
playersList_init = true;
var trueLength = 0;
for (var i=1; i<=players.length-1; i++)
{
if (players[i].active)
trueLength++;
}
for (var i=1; i<=trueLength; i++)
{
if (players[i].active)
{
getGUIObjectByName("Player_" + (i+8-trueLength)).caption = players[i].name;
getGUIObjectByName("PlayerShadow_" + (i+8-trueLength)).caption = players[i].name;
var col_r = parseInt(players[i].getColour().r * 255);
var col_g = parseInt(players[i].getColour().g * 255);
var col_b = parseInt(players[i].getColour().b * 255);
getGUIObjectByName("Player_" + (i+8-trueLength)).textcolor = col_r + " " + col_g + " " + col_b;
}
}
}
var pl = getGUIObjectByName("PlayersList");
pl.hidden = ! pl.hidden;
var pls = getGUIObjectByName("PlayersListShadow");
pls.hidden = ! pls.hidden;
/*
DESCRIPTION : Functions for "main game" session GUI.
NOTES :
*/
// ====================================================================
function initSession()
{
// ============================================= CONSTANTS =================================================
snConst = new Object();
// Portraits (large and small).
snConst.Portrait = new Object();
snConst.Portrait.Sml = new Object();
snConst.Portrait.Sml.Width = 45;
snConst.Portrait.Sml.Height = snConst.Portrait.Sml.Width;
snConst.Portrait.Lrg = new Object();
snConst.Portrait.Lrg.Width = 64;
snConst.Portrait.Lrg.Height = snConst.Portrait.Lrg.Width;
// Small icons (eg Movement Rate, Food).
snConst.MiniIcon = new Object();
snConst.MiniIcon.Width = 30;
snConst.MiniIcon.Height = snConst.MiniIcon.Width;
// ============================================= GLOBALS =================================================
// Define cell reference constants for icon sheets.
initCellReference();
}
// ====================================================================
function initCellReference()
{
cellGroup = new Array();
// Define categories of cell groups by checking their reference files in the same locations as the icon sheets.
addCellGroupCategory ("art/textures/ui/session/icons/sheets/");
// (Note that we don't use this and we probably shouldn't, since the entities state which icon cell they should use; it makes it easier to remember which icon is used
// for which unit if we have this reference sheet, though.)
addCellGroupCategory ("art/textures/ui/session/portraits/sheets/");
}
// ====================================================================
function addCellGroupCategory(iconSheetPath)
{
// Get array list of all icon sheet reference files.
var iconSheets = buildDirEntList (iconSheetPath, "*.txt", true);
// Alphabetically sort the array.
iconSheets.sort();
// Seek through all icon sheets.
for (var sheet = 0; sheet < iconSheets.length; sheet++)
{
// Get the current icon sheet name.
var groupName = iconSheets[sheet];
// Remove path and extension information so we just have the group name.
groupName = groupName.replace (iconSheetPath, "");
groupName = groupName.replace (".txt", "");
groupName = toTitleCase(groupName);
// Get the elements from the current icon sheet.
var iconArray = readFileLines (iconSheets[sheet]);
// For each row in the icon sheet file,
for (var row = 0; row < iconArray.length; row++)
{
// Get the individual fields in the array as another array.
var iconElements = iconArray[row].split (",");
// Add this cell to the current group.
addCell (groupName, iconElements[0], iconElements[1]);
}
}
}
// ====================================================================
function addCell (group, cellID, cellName)
{
// Add a cell ID to a cell container group.
// If this array does not exist,
if (!cellGroup[group])
{
// Create the container.
cellGroup[group] = new Array();
cellGroup[group].length = new Object(0);
}
cellGroup[group][cellID] = new Array();
cellGroup[group][cellID].id = new Object (cellGroup[group].length);
cellGroup[group][cellID].name = new Object (cellName);
cellGroup[group].length++;
}
// ====================================================================
function setPortrait(objectName, portraitString, portraitSuffix, portraitCell)
{
// Use this function as a shortcut to change a portrait object to a different portrait image.
// Accepts an object and specifies its default, rollover (lit) and disabled (gray) sprites.
// Sprite Format: "sn""portraitString""portraitSuffix"
// Sprite Format: "sn""portraitString""portraitSuffix""Over"
// Sprite Format: "sn""portraitString""portraitSuffix""Disabled"
// Note: Make sure the file follows this naming convention or bad things could happen.
// Get GUI object
setPortraitGUIObject = getGUIObjectByName(objectName);
// Report error if object not found.
if (!setPortraitGUIObject)
{
console.write ("setPortrait(): Failed to find object " + objectName + ".");
return 1;
}
// Set the three portraits.
if (portraitSuffix && portraitSuffix != "")
setPortraitGUIObject.sprite = "sn" + portraitString + portraitSuffix;
else
setPortraitGUIObject.sprite = "sn" + portraitString;
setPortraitGUIObject.sprite_over = setPortraitGUIObject.sprite + "Over";
setPortraitGUIObject.sprite_disabled = setPortraitGUIObject.sprite + "Disabled";
// If the source texture is a multi-frame image (icon sheet), specify correct cell.
if (portraitCell && portraitCell != "")
setPortraitGUIObject.cell_id = portraitCell;
else
setPortraitGUIObject.cell_id = "";
return 0;
}
// ====================================================================
function flipGUI (NewGUIType)
{
// Changes GUI to a different layout.
switch (NewGUIType)
{
// Set which GUI to use.
case rb:
case lb:
case lt:
case rt:
GUIType = NewGUIType;
break;
default:
// If no type specified, toggle.
if (GUIType == rb)
GUIType = lb;
else
if (GUIType == lb)
GUIType = lt;
else
if (GUIType == lt)
GUIType = rt;
else
GUIType = rb;
break;
}
// Seek through all sizes created.
for (var i = 0; i <= Crd.last; i++)
{
// Set their sizes to the stored value.
getGUIObjectByName (Crd[i].name).size = Crd[i].size[GUIType];
}
writeConsole("GUI flipped to size " + GUIType + ".");
}
// ====================================================================
// 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.length > 0 && 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.length > 0 && 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();
// Refresh handler that monitors whether property/selection has been updated.
resetUpdateVars();
// Refresh resources
refreshResources();
}
if ( selectionChanged && getGUIObjectByName( "mn" ).hidden == false)
{
// Update manual if it's open.
refreshManual();
}
}
// ====================================================================
function confirmLeave()
{
if (isGameRunning())
{
endSession("return");
}
else
{
exit();
}
}
// ====================================================================
playersList_init = false;
function togglePlayersList()
{
//Initialization of names and colors.
if (!playersList_init)
{
playersList_init = true;
var trueLength = 0;
for (var i=1; i<=players.length-1; i++)
{
if (players[i].active)
trueLength++;
}
for (var i=1; i<=trueLength; i++)
{
if (players[i].active)
{
getGUIObjectByName("Player_" + (i+8-trueLength)).caption = players[i].name;
getGUIObjectByName("PlayerShadow_" + (i+8-trueLength)).caption = players[i].name;
var col_r = parseInt(players[i].getColour().r * 255);
var col_g = parseInt(players[i].getColour().g * 255);
var col_b = parseInt(players[i].getColour().b * 255);
getGUIObjectByName("Player_" + (i+8-trueLength)).textcolor = col_r + " " + col_g + " " + col_b;
}
}
}
var pl = getGUIObjectByName("PlayersList");
pl.hidden = ! pl.hidden;
var pls = getGUIObjectByName("PlayersListShadow");
pls.hidden = ! pls.hidden;
}
@@ -1,88 +1,88 @@
/*
DESCRIPTION : Functions for the "online manual" part of the Session GUI.
NOTES :
*/
// ====================================================================
function addItemsRecursively (container, indent, fontName)
{
// List the tree of items in a container and store it in the string *recursiveString* by recursively calling the function. (Thanks, Philip.)
// Reset recursive string if this is the first call.
if (indent == "")
recursiveString = "";
for (var item in container)
{
// Skip null strings and function references.
if (item != null && container[item] != null
&& container[item].toString().substring (0, 1) != "\n" && item != "template")
{
// Root-level items are in bold.
recursiveString += "[font=" + fontName;
if (indent == "")
recursiveString += "b]";
else
recursiveString += "]";
// Display the property name, and the value, if any.
if (container[item] == true && container[item].toString() != true)
recursiveString += indent + " " + item + "\n";
else
recursiveString += indent + " " + item + ": " + container[item] + "\n";
// Retrieve sub-items.
if (typeof container[item] == 'object')
addItemsRecursively (container[item], indent + "--", fontName);
}
}
}
// ====================================================================
function refreshManual()
{
if (selection.length != 0)
{
// Display portrait.
if (selection[0].traits.id.icon)
{
setPortrait ("mnPortrait", selection[0].traits.id.icon,
"Button" + toTitleCase(selection[0].traits.id.civ_code), selection[0].traits.id.icon_cell);
}
// Display rollover text.
if (selection[0].traits.id.rollover)
{
var manualRollover = getGUIObjectByName("mnRollover");
manualRollover.caption = selection[0].traits.id.rollover;
}
// Display history text.
if (selection[0].traits.id.rollover)
{
var manualHistory = getGUIObjectByName("mnHistory");
manualHistory.caption = selection[0].traits.id.history;
}
// Build manual text.
var manualText = "";
addItemsRecursively ( selection[0], "", "trebuchet14" );
manualText += recursiveString;
// Close the manual string.
manualText += "[/font]";
// Assign manual text to control.
getGUIObjectByName("mnText").caption = manualText;
}
else
{
// If the player has removed the selection while the manual is open, close the manual.
guiHide("mn");
guiUnHide("sn");
}
}
/*
DESCRIPTION : Functions for the "online manual" part of the Session GUI.
NOTES :
*/
// ====================================================================
function addItemsRecursively (container, indent, fontName)
{
// List the tree of items in a container and store it in the string *recursiveString* by recursively calling the function. (Thanks, Philip.)
// Reset recursive string if this is the first call.
if (indent == "")
recursiveString = "";
for (var item in container)
{
// Skip null strings and function references.
if (item != null && container[item] != null
&& container[item].toString().substring (0, 1) != "\n" && item != "template")
{
// Root-level items are in bold.
recursiveString += "[font=" + fontName;
if (indent == "")
recursiveString += "b]";
else
recursiveString += "]";
// Display the property name, and the value, if any.
if (container[item] == true && container[item].toString() != true)
recursiveString += indent + " " + item + "\n";
else
recursiveString += indent + " " + item + ": " + container[item] + "\n";
// Retrieve sub-items.
if (typeof container[item] == 'object')
addItemsRecursively (container[item], indent + "--", fontName);
}
}
}
// ====================================================================
function refreshManual()
{
if (selection.length != 0)
{
// Display portrait.
if (selection[0].traits.id.icon)
{
setPortrait ("mnPortrait", selection[0].traits.id.icon,
"Button" + toTitleCase(selection[0].traits.id.civ_code), selection[0].traits.id.icon_cell);
}
// Display rollover text.
if (selection[0].traits.id.rollover)
{
var manualRollover = getGUIObjectByName("mnRollover");
manualRollover.caption = selection[0].traits.id.rollover;
}
// Display history text.
if (selection[0].traits.id.rollover)
{
var manualHistory = getGUIObjectByName("mnHistory");
manualHistory.caption = selection[0].traits.id.history;
}
// Build manual text.
var manualText = "";
addItemsRecursively ( selection[0], "", "trebuchet14" );
manualText += recursiveString;
// Close the manual string.
manualText += "[/font]";
// Assign manual text to control.
getGUIObjectByName("mnText").caption = manualText;
}
else
{
// If the player has removed the selection while the manual is open, close the manual.
guiHide("mn");
guiUnHide("sn");
}
}
// ====================================================================
File diff suppressed because it is too large Load Diff
@@ -1,191 +1,191 @@
/*
DESCRIPTION : Functions for the "Status Pane" section of the session GUI.
NOTES :
*/
// ====================================================================
function refreshStatusPane()
{
// Update civilisation emblem.
if ( selectionChanged )
{
var emblemObject = getGUIObjectByName ("snStatusPaneEmblem");
if (selection[0].traits.id.civ_code != "gaia")
emblemObject.sprite = "snStatusPaneEmblem" + toTitleCase (selection[0].traits.id.civ_code);
else
emblemObject.sprite = "";
}
if ( shouldUpdateStat ( "traits.id.icon" ) )
{
// Update portrait
if (validProperty("selection[0].traits.id.icon"))
setPortrait ("snStatusPanePortrait", selection[0].traits.id.icon,
toTitleCase(selection[0].traits.id.civ_code), selection[0].traits.id.icon_cell);
}
// Update portrait tooltip.
if ( shouldUpdateStat ( "traits.id.generic" ) )
{
getGUIObjectByName ("snStatusPanePortrait").tooltip = selection[0].traits.id.generic;
}
// Update hitpoint bar.
if ( selectionChanged || shouldUpdateStat ( "traits.health.max" ) || shouldUpdateStat ( "traits.health.curr" ) )
{
var barObject = getGUIObjectByName ("snStatusPaneHealthBar");
var textObject = getGUIObjectByName ("snStatusPaneHealthBarText");
if (selection[0].traits.health.max && selection[0].traits.health.max != 0)
{
barObject.caption = (selection[0].traits.health.curr * 100) / selection[0].traits.health.max;
barObject.hidden = false;
textObject.caption = "[font=verdana8][color=white]" + selection[0].traits.health.curr + "[/color][/font]";
}
else
{
barObject.hidden = true;
textObject.caption = "";
}
}
// Update stamina bar.
if ( selectionChanged || shouldUpdateStat ( "traits.stamina.max" ) || shouldUpdateStat ( "traits.stamina.curr" ) )
{
var barObject = getGUIObjectByName ("snStatusPaneStaminaBar");
var textObject = getGUIObjectByName ("snStatusPaneStaminaBarText");
if (selection[0].traits.stamina.max && selection[0].traits.stamina.max != 0)
{
barObject.caption = (selection[0].traits.stamina.curr * 100) / selection[0].traits.stamina.max;
barObject.hidden = false;
textObject.caption = "[font=verdana8][color=white]" + selection[0].traits.stamina.curr + "[/color][/font]";
}
else
{
barObject.hidden = true;
textObject.caption = "";
}
}
// Update unit text panel.
if ( shouldUpdateStat ("player") || shouldUpdateStat ( "traits.id.civ" ) || shouldUpdateStat ( "traits.id.generic" ) || shouldUpdateStat ( "traits.id.specific" ) )
{
var textCaption = "";
textCaption += '[font=verdana10][color="' + Math.round(selection[0].player.getColour().r*255) + ' ' + Math.round(selection[0].player.getColour().g*255) + ' ' + Math.round(selection[0].player.getColour().b*255) + '"]' + selection[0].player.name + '[/color][/font]\n';
textCaption += "[font=verdana10][color=white]" + selection[0].traits.id.civ + "[/color][/font]\n";
textCaption += "[font=verdana10][color=white]" + selection[0].traits.id.specific + "[/color][/font]\n";
textCaption += "[font=optimus14b][color=gold]" + selection[0].traits.id.generic + "[/color][/font]";
getGUIObjectByName ("snStatusPaneText").caption = textCaption;
}
// Update rank icon.
if ( shouldUpdateStat ( "traits.promotion" ) )
{
var rankObject = getGUIObjectByName ("snStatusPaneRank");
// Don't show a rank icon for Basic or unranked units.
if (selection[0].traits.promotion && selection[0].traits.promotion.rank > 1)
{
rankObject.cell_id = selection[0].traits.promotion.rank-2;
rankObject.tooltip = "Next Promotion: " + selection[0].traits.promotion.curr + "/" + selection[0].traits.promotion.req;
rankObject.hidden = false;
}
else
rankObject.hidden = true;
}
// Update garrison capacity.
if( shouldUpdateStat( "traits.garrison" ) )
{
var guiObject = getGUIObjectByName("snStatusPaneGarrison");
guiObject.caption = '';
if (selection[0].traits.garrison)
{
// Set garrison icon.
getGUIObjectByName ("snStatusPaneGarrisonIcon").cell_id = cellGroup["Garrison"]["garrison"].id;
if (selection[0].traits.garrison.curr && selection[0].traits.garrison.max)
{
guiObject.caption += '[color="blue"]' + selection[0].traits.garrison.curr + '/' + selection[0].traits.garrison.max + '[/color] ';
}
guiObject.hidden = false;
getGUIObjectByName ("snStatusPaneGarrisonIcon").hidden = false;
}
else
{
guiObject.hidden = true;
getGUIObjectByName ("snStatusPaneGarrisonIcon").hidden = true;
}
}
if( shouldUpdateStat( "traits.supply" ) )
{
guiObject = getGUIObjectByName("snStatusPaneSupply");
guiObject.caption = '';
if (selection[0].traits.supply)
{
if (selection[0].traits.supply.curr && selection[0].traits.supply.max && selection[0].traits.supply.type)
{
// Set resource icon.
getGUIObjectByName ("snStatusPaneSupplyIcon").cell_id = cellGroup["Resource"][selection[0].traits.supply.type].id;
// Special case for infinity.
if (selection[0].traits.supply.curr == "0" && selection[0].traits.supply.max == "0")
guiObject.caption += '[color="brown"] [icon="iconInfinity"] [/color] ';
else
guiObject.caption += '[color="brown"]' + selection[0].traits.supply.curr + '/' + selection[0].traits.supply.max + '[/color] ';
}
guiObject.hidden = false;
getGUIObjectByName ("snStatusPaneSupplyIcon").hidden = false;
}
else
{
guiObject.hidden = true;
getGUIObjectByName ("snStatusPaneSupplyIcon").hidden = true;
}
}
// Update statistic icons.
statCurr = 1;
if (validProperty ("selection[0].actions.attack.melee.damage"))
updateStat ("snStatusPaneStat_", "Attack", "rating", selection[0].actions.attack.melee.damage);
if (validProperty ("selection[0].actions.attack.melee.range"))
updateStat ("snStatusPaneStat_", "Statistic", "range", selection[0].actions.attack.melee.range);
if (validProperty ("selection[0].actions.attack.ranged.damage"))
updateStat ("snStatusPaneStat_", "Attack", "rating", selection[0].actions.attack.ranged.damage);
if (validProperty ("selection[0].actions.attack.ranged.range"))
updateStat ("snStatusPaneStat_", "Statistic", "range", selection[0].actions.attack.ranged.range);
if (validProperty ("selection[0].traits.armour.value"))
updateStat ("snStatusPaneStat_", "Armour", "rating", selection[0].traits.armour.value);
if (validProperty ("selection[0].traits.vision.los"))
updateStat ("snStatusPaneStat_", "Statistic", "vision", selection[0].traits.vision.los);
// Refresh command buttons.
refreshCommandButtons();
}
// ====================================================================
function updateStat (baseName, cellSheet, cell, statistic)
{
var textStat = getGUIObjectByName (baseName + statCurr);
if( !textStat )
{
//console.write("No textStat for " + baseName + " " + statCurr);
return;
}
textStat.sprite = "snIconSheet" + cellSheet;
textStat.cell_id = cellGroup[cellSheet][cell].id;
textStat.tooltip = cellGroup[cellSheet][cell].name;
var iconStat = getGUIObjectByName (baseName + (statCurr + 1));
if (!isNaN(statistic)) {
statistic = Math.ceil(statistic);
}
iconStat.caption = statistic;
iconStat.tooltip = cellGroup[cellSheet][cell].name + ": " + statistic + ".";
statCurr = (statCurr + 2);
}
// ====================================================================
/*
DESCRIPTION : Functions for the "Status Pane" section of the session GUI.
NOTES :
*/
// ====================================================================
function refreshStatusPane()
{
// Update civilisation emblem.
if ( selectionChanged )
{
var emblemObject = getGUIObjectByName ("snStatusPaneEmblem");
if (selection[0].traits.id.civ_code != "gaia")
emblemObject.sprite = "snStatusPaneEmblem" + toTitleCase (selection[0].traits.id.civ_code);
else
emblemObject.sprite = "";
}
if ( shouldUpdateStat ( "traits.id.icon" ) )
{
// Update portrait
if (validProperty("selection[0].traits.id.icon"))
setPortrait ("snStatusPanePortrait", selection[0].traits.id.icon,
toTitleCase(selection[0].traits.id.civ_code), selection[0].traits.id.icon_cell);
}
// Update portrait tooltip.
if ( shouldUpdateStat ( "traits.id.generic" ) )
{
getGUIObjectByName ("snStatusPanePortrait").tooltip = selection[0].traits.id.generic;
}
// Update hitpoint bar.
if ( selectionChanged || shouldUpdateStat ( "traits.health.max" ) || shouldUpdateStat ( "traits.health.curr" ) )
{
var barObject = getGUIObjectByName ("snStatusPaneHealthBar");
var textObject = getGUIObjectByName ("snStatusPaneHealthBarText");
if (selection[0].traits.health.max && selection[0].traits.health.max != 0)
{
barObject.caption = (selection[0].traits.health.curr * 100) / selection[0].traits.health.max;
barObject.hidden = false;
textObject.caption = "[font=verdana8][color=white]" + selection[0].traits.health.curr + "[/color][/font]";
}
else
{
barObject.hidden = true;
textObject.caption = "";
}
}
// Update stamina bar.
if ( selectionChanged || shouldUpdateStat ( "traits.stamina.max" ) || shouldUpdateStat ( "traits.stamina.curr" ) )
{
var barObject = getGUIObjectByName ("snStatusPaneStaminaBar");
var textObject = getGUIObjectByName ("snStatusPaneStaminaBarText");
if (selection[0].traits.stamina.max && selection[0].traits.stamina.max != 0)
{
barObject.caption = (selection[0].traits.stamina.curr * 100) / selection[0].traits.stamina.max;
barObject.hidden = false;
textObject.caption = "[font=verdana8][color=white]" + selection[0].traits.stamina.curr + "[/color][/font]";
}
else
{
barObject.hidden = true;
textObject.caption = "";
}
}
// Update unit text panel.
if ( shouldUpdateStat ("player") || shouldUpdateStat ( "traits.id.civ" ) || shouldUpdateStat ( "traits.id.generic" ) || shouldUpdateStat ( "traits.id.specific" ) )
{
var textCaption = "";
textCaption += '[font=verdana10][color="' + Math.round(selection[0].player.getColour().r*255) + ' ' + Math.round(selection[0].player.getColour().g*255) + ' ' + Math.round(selection[0].player.getColour().b*255) + '"]' + selection[0].player.name + '[/color][/font]\n';
textCaption += "[font=verdana10][color=white]" + selection[0].traits.id.civ + "[/color][/font]\n";
textCaption += "[font=verdana10][color=white]" + selection[0].traits.id.specific + "[/color][/font]\n";
textCaption += "[font=optimus14b][color=gold]" + selection[0].traits.id.generic + "[/color][/font]";
getGUIObjectByName ("snStatusPaneText").caption = textCaption;
}
// Update rank icon.
if ( shouldUpdateStat ( "traits.promotion" ) )
{
var rankObject = getGUIObjectByName ("snStatusPaneRank");
// Don't show a rank icon for Basic or unranked units.
if (selection[0].traits.promotion && selection[0].traits.promotion.rank > 1)
{
rankObject.cell_id = selection[0].traits.promotion.rank-2;
rankObject.tooltip = "Next Promotion: " + selection[0].traits.promotion.curr + "/" + selection[0].traits.promotion.req;
rankObject.hidden = false;
}
else
rankObject.hidden = true;
}
// Update garrison capacity.
if( shouldUpdateStat( "traits.garrison" ) )
{
var guiObject = getGUIObjectByName("snStatusPaneGarrison");
guiObject.caption = '';
if (selection[0].traits.garrison)
{
// Set garrison icon.
getGUIObjectByName ("snStatusPaneGarrisonIcon").cell_id = cellGroup["Garrison"]["garrison"].id;
if (selection[0].traits.garrison.curr && selection[0].traits.garrison.max)
{
guiObject.caption += '[color="blue"]' + selection[0].traits.garrison.curr + '/' + selection[0].traits.garrison.max + '[/color] ';
}
guiObject.hidden = false;
getGUIObjectByName ("snStatusPaneGarrisonIcon").hidden = false;
}
else
{
guiObject.hidden = true;
getGUIObjectByName ("snStatusPaneGarrisonIcon").hidden = true;
}
}
if( shouldUpdateStat( "traits.supply" ) )
{
guiObject = getGUIObjectByName("snStatusPaneSupply");
guiObject.caption = '';
if (selection[0].traits.supply)
{
if (selection[0].traits.supply.curr && selection[0].traits.supply.max && selection[0].traits.supply.type)
{
// Set resource icon.
getGUIObjectByName ("snStatusPaneSupplyIcon").cell_id = cellGroup["Resource"][selection[0].traits.supply.type].id;
// Special case for infinity.
if (selection[0].traits.supply.curr == "0" && selection[0].traits.supply.max == "0")
guiObject.caption += '[color="brown"] [icon="iconInfinity"] [/color] ';
else
guiObject.caption += '[color="brown"]' + selection[0].traits.supply.curr + '/' + selection[0].traits.supply.max + '[/color] ';
}
guiObject.hidden = false;
getGUIObjectByName ("snStatusPaneSupplyIcon").hidden = false;
}
else
{
guiObject.hidden = true;
getGUIObjectByName ("snStatusPaneSupplyIcon").hidden = true;
}
}
// Update statistic icons.
statCurr = 1;
if (validProperty ("selection[0].actions.attack.melee.damage"))
updateStat ("snStatusPaneStat_", "Attack", "rating", selection[0].actions.attack.melee.damage);
if (validProperty ("selection[0].actions.attack.melee.range"))
updateStat ("snStatusPaneStat_", "Statistic", "range", selection[0].actions.attack.melee.range);
if (validProperty ("selection[0].actions.attack.ranged.damage"))
updateStat ("snStatusPaneStat_", "Attack", "rating", selection[0].actions.attack.ranged.damage);
if (validProperty ("selection[0].actions.attack.ranged.range"))
updateStat ("snStatusPaneStat_", "Statistic", "range", selection[0].actions.attack.ranged.range);
if (validProperty ("selection[0].traits.armour.value"))
updateStat ("snStatusPaneStat_", "Armour", "rating", selection[0].traits.armour.value);
if (validProperty ("selection[0].traits.vision.los"))
updateStat ("snStatusPaneStat_", "Statistic", "vision", selection[0].traits.vision.los);
// Refresh command buttons.
refreshCommandButtons();
}
// ====================================================================
function updateStat (baseName, cellSheet, cell, statistic)
{
var textStat = getGUIObjectByName (baseName + statCurr);
if( !textStat )
{
//console.write("No textStat for " + baseName + " " + statCurr);
return;
}
textStat.sprite = "snIconSheet" + cellSheet;
textStat.cell_id = cellGroup[cellSheet][cell].id;
textStat.tooltip = cellGroup[cellSheet][cell].name;
var iconStat = getGUIObjectByName (baseName + (statCurr + 1));
if (!isNaN(statistic)) {
statistic = Math.ceil(statistic);
}
iconStat.caption = statistic;
iconStat.tooltip = cellGroup[cellSheet][cell].name + ": " + statistic + ".";
statCurr = (statCurr + 2);
}
// ====================================================================
@@ -1,258 +1,258 @@
/*
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)
{
var controlling = true;
for (var i = 0; i < selection.length; i++) {
if (! (selection[i].player.name == localPlayer.name)) {
controlling = false;
break;
}
}
if (!controlling) {
return;
}
if (event.clicks == 1) {
cmd = event.order;
}
else if (event.clicks == 2)
{
// Use the secondary order, or, if the entites didn't vote for any order
// (i.e. we are using the default of NMT_GOTO), use the NMT_RUN
if (event.order == NMT_GOTO )
cmd = NMT_RUN;
else
cmd = event.secondaryOrder;
}
}
else
{
return;
}
//setting rally point
if ( getCursorName() == "cursor-rally" )
{
for ( var i=0; i<selection.length; i++ )
selection[i].setRallyPointAtCursor();
setCursor("arrow-default");
return;
}
switch (cmd)
{
// location target commands
case NMT_GOTO:
case NMT_RUN:
case NMT_PATROL:
if (event.queued)
cmd = NMT_ADD_WAYPOINT;
args[0]=event.x;
args[1]=event.y;
break;
case NMT_ADD_WAYPOINT:
args[0]=event.x;
args[1]=event.y;
break;
// entity target commands
case NMT_CONTACT_ACTION:
args[0]=event.entity;
if ( event.clicks == 1)
args[1]=event.action;
else
args[1]=event.secondaryAction;
break;
//TODO: get rid of order() calls.
case NMT_NOTIFY_REQUEST:
if (event.clicks == 1)
action = event.action;
else
action = event.secondaryAction;
if (event.entity.isIdle())
{
for (var i=0; i<selection.length;i++)
{
if (!selection[i].actions)
continue;
//console.write("Requesting notification for " + event.entity);
//selection[i].requestNotification( event.entity, action, true, false );
//selection[i].order( ORDER_GOTO, event.entity.position.x, event.entity.position.z - selection[i].actions.escort.distance, true);
}
}
else
{
for (var i=0; i<selection.length;i++)
{
if (!selection[i].actions)
continue;
//console.write("Requesting notification for " + event.entity);
//selection[i].requestNotification( event.entity, action, true, false );
}
}
return;
default:
console.write("worldClickHandler: Unknown order: "+cmd);
return;
}
if (cmd == NMT_CONTACT_ACTION) // For NMT_CONTACT_ACTION, add a third argument - whether to run
issueCommand (selection, isOrderQueued(), cmd, args[0], args[1], event.clicks > 1);
else
issueCommand (selection, isOrderQueued(), 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.
var dudeSpawnPoint = new Vector3D(x, y, z);
new Entity(getEntityTemplate(MakeUnitName), dudeSpawnPoint, 1.0);
// writeConsole(MakeUnitName + " created at " + DudeSpawnPoint);
}
// ====================================================================
function validProperty (propertyName)
{
// Accepts a string representing an entity property (eg "selection[0].traits.id.generic")
// and checks if all the elements (selection[0].traits, selection[0].traits.id, etc) are valid properties.
// Returns false if any invalids are found. Returns true if the whole property is valid.
// An empty string is always successful.
if (propertyName == "") return true;
// An undefined string is always unsuccessful.
if (propertyName == undefined) return false;
// Store elements of the property as an array of strings.
var splitArray = propertyName.toString().split (".");
// Seek through elements in array.
var arrayString = "";
for (var i = 0; i < splitArray.length; i++)
{
// Test each element combination of the string to ensure they are all valid.
if (i > 0) arrayString += ".";
arrayString += splitArray[i];
// If the property name is not valid, return false.
if (!(eval (arrayString)))
return false;
}
// If we managed to check them all, every element in the property is valid. Return true.
return true;
}
function killSelectedEntities()
{
var allOwned = true;
for (var i=0; i<selection.length && allOwned; i++)
{
if (localPlayer != selection[i].player)
{
allOwned = false;
}
}
if (allOwned)
{
for (i=0; i<selection.length; i++)
/*
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)
{
var controlling = true;
for (var i = 0; i < selection.length; i++) {
if (! (selection[i].player.name == localPlayer.name)) {
controlling = false;
break;
}
}
if (!controlling) {
return;
}
if (event.clicks == 1) {
cmd = event.order;
}
else if (event.clicks == 2)
{
//TODO: send network msg, so the unit is killed everywhere
console.write('killing....');
selection[i].kill();
issueCommand(selection[i], NMT_REMOVE_OBJECT);
}
}
}
// Use the secondary order, or, if the entites didn't vote for any order
// (i.e. we are using the default of NMT_GOTO), use the NMT_RUN
if (event.order == NMT_GOTO )
cmd = NMT_RUN;
else
cmd = event.secondaryOrder;
}
}
else
{
return;
}
//setting rally point
if ( getCursorName() == "cursor-rally" )
{
for ( var i=0; i<selection.length; i++ )
selection[i].setRallyPointAtCursor();
setCursor("arrow-default");
return;
}
switch (cmd)
{
// location target commands
case NMT_GOTO:
case NMT_RUN:
case NMT_PATROL:
if (event.queued)
cmd = NMT_ADD_WAYPOINT;
args[0]=event.x;
args[1]=event.y;
break;
case NMT_ADD_WAYPOINT:
args[0]=event.x;
args[1]=event.y;
break;
// entity target commands
case NMT_CONTACT_ACTION:
args[0]=event.entity;
if ( event.clicks == 1)
args[1]=event.action;
else
args[1]=event.secondaryAction;
break;
//TODO: get rid of order() calls.
case NMT_NOTIFY_REQUEST:
if (event.clicks == 1)
action = event.action;
else
action = event.secondaryAction;
if (event.entity.isIdle())
{
for (var i=0; i<selection.length;i++)
{
if (!selection[i].actions)
continue;
//console.write("Requesting notification for " + event.entity);
//selection[i].requestNotification( event.entity, action, true, false );
//selection[i].order( ORDER_GOTO, event.entity.position.x, event.entity.position.z - selection[i].actions.escort.distance, true);
}
}
else
{
for (var i=0; i<selection.length;i++)
{
if (!selection[i].actions)
continue;
//console.write("Requesting notification for " + event.entity);
//selection[i].requestNotification( event.entity, action, true, false );
}
}
return;
default:
console.write("worldClickHandler: Unknown order: "+cmd);
return;
}
if (cmd == NMT_CONTACT_ACTION) // For NMT_CONTACT_ACTION, add a third argument - whether to run
issueCommand (selection, isOrderQueued(), cmd, args[0], args[1], event.clicks > 1);
else
issueCommand (selection, isOrderQueued(), 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.
var dudeSpawnPoint = new Vector3D(x, y, z);
new Entity(getEntityTemplate(MakeUnitName), dudeSpawnPoint, 1.0);
// writeConsole(MakeUnitName + " created at " + DudeSpawnPoint);
}
// ====================================================================
function validProperty (propertyName)
{
// Accepts a string representing an entity property (eg "selection[0].traits.id.generic")
// and checks if all the elements (selection[0].traits, selection[0].traits.id, etc) are valid properties.
// Returns false if any invalids are found. Returns true if the whole property is valid.
// An empty string is always successful.
if (propertyName == "") return true;
// An undefined string is always unsuccessful.
if (propertyName == undefined) return false;
// Store elements of the property as an array of strings.
var splitArray = propertyName.toString().split (".");
// Seek through elements in array.
var arrayString = "";
for (var i = 0; i < splitArray.length; i++)
{
// Test each element combination of the string to ensure they are all valid.
if (i > 0) arrayString += ".";
arrayString += splitArray[i];
// If the property name is not valid, return false.
if (!(eval (arrayString)))
return false;
}
// If we managed to check them all, every element in the property is valid. Return true.
return true;
}
function killSelectedEntities()
{
var allOwned = true;
for (var i=0; i<selection.length && allOwned; i++)
{
if (localPlayer != selection[i].player)
{
allOwned = false;
}
}
if (allOwned)
{
for (i=0; i<selection.length; i++)
{
//TODO: send network msg, so the unit is killed everywhere
console.write('killing....');
selection[i].kill();
issueCommand(selection[i], NMT_REMOVE_OBJECT);
}
}
}
@@ -1,194 +1,194 @@
/*
DESCRIPTION : Functions for manipulating players and their properties (eg resources).
NOTES :
*/
// ====================================================================
function createResourceCounters()
{
resourceUIArray = new Array();
addResourceCounter(0, "food");
addResourceCounter(1, "wood");
addResourceCounter(2, "stone");
addResourceCounter(3, "metal");
addResourceCounter(4, "population");
refreshResource("Food", 0);
refreshResource("Wood", 1);
refreshResource("Stone", 2);
refreshResource("Metal", 3);
refreshResource("Population", 4);
}
// ====================================================================
function addResourceCounter (index, resourceName)
{
// Creates a resource counter widget.
// Ensure resource name is lower-case.
resourceName = resourceName.toLowerCase();
// We maintain a sorted array of the resource indexes so that the UI counters can be refreshed in centered order.
// (We don't include Housing in the list, though, as it does not have its own resource counter.)
if (resourceName != "housing")
{
// If it's an even index,
if (index % 2 == 0)
// Add it to the end of the UI array.
resourceUIArray.push ( index );
else
// Add it to the beginning of the UI array,
resourceUIArray.unshift ( index );
}
//console.write( "Added " + resourceName /*+ " (" + resourceQty + ")"*/ );
}
// ====================================================================
// HACK: Keep track of old resource values so we only update resource counters as necessary.
// We should really find a *much* faster way to render those counters, since resource values are bound to change quite quickly in a real game.
var oldResources = new Object();
function refreshResources ()
{
// Refreshes all resource counters after update.
var resourcePool = localPlayer.resources;
var shouldRefresh = false;
for (var currResource in resourcePool)
{
if( oldResources[currResource] != localPlayer.resources[currResource] )
{
oldResources[currResource] = localPlayer.resources[currResource].valueOf();
shouldRefresh = true;
}
}
if( shouldRefresh )
{
for( var i=0; i<2; i++ ) // 2 refreshes seem to be necessary for proper alignment
{
var resourceCount = 0;
for (var currResource in resourcePool)
{
if(currResource != "housing")
{
// Pass the array index of the resource as the second parameter (as we'll need that to determine the centered screen position of each counter).
refreshResource (toTitleCase(currResource), resourceUIArray[resourceCount]);
resourceCount++;
}
}
}
}
}
// ====================================================================
function refreshResource (resourceName, resourceIndex)
{
// Refresh the onscreen counter for a given resource (called to recalculate the size of the coordinates, as these dynamically adjust depending on character length).
// Ensure resource name is title-case.
resourceName = toTitleCase (resourceName);
// Ignore the "Housing" resource ... It doesn't work like normal resources and doesn't have a counter to resize.
if (resourceName == "Housing")
return;
// Get resource readout object.
var resourceObject = getGUIObjectByName ("snResourceCounter_" + (resourceIndex + 1));
// Get resource icon object.
var resourceIconObject = getGUIObjectByName ("snResourceCounterIcon_" + (resourceIndex + 1));
// Update counter caption (since we need to have up-to-date text to determine the length of the counter).
var caption = parseInt( localPlayer.resources[resourceName.toLowerCase()] );
// The Population counter also lists the amount of available housing.
if (resourceName == "Population")
caption += "/" + localPlayer.resources["housing"];
resourceObject.caption = caption;
// Update counter tooltip.
resourceObject.tooltip = resourceName + ": " + resourceObject.caption;
// Set resource icon.
resourceIconObject.cell_id = cellGroup["Resource"][resourceName.toLowerCase()].id;
// Get the index of the resource readout to be resized.
var crdResult = getCrd (resourceObject.name, true);
// Get the index of the resource icon.
var crdIconResult = getCrd (resourceIconObject.name, true);
// For each coordinate group stored for this control,
for (var coordGroup in Crd[crdResult].coord)
{
// Set width of readout based on length of caption.
Crd[crdResult].coord[coordGroup].width = snConst.MiniIcon.Width+5 + resourceObject.caption.length * 10;
// Set X and Y position and height so that resources always are immediately besides each other. (Except for the first resource (usually Food), which has the initial starting position)
// Determine starting position for the first resource (so that the resources wind up being centered across the screen).
if (resourceIndex == 0)
{
// The first coordinate is in the exact centre of the screen.
Crd[crdResult].coord[coordGroup].x = Math.round (-(Crd[crdResult].coord[coordGroup].width/2) - 5);
}
else
{ // Resources other than the first one get stacked in sequence to the sides of it.
// If we're dealing with an "even" resource index,
if (resourceIndex % 2 == 0)
{
// Put the counter to the right of the previous odd counter.
Crd[crdResult].coord[coordGroup].x
= Crd[crdResult-2].coord[coordGroup].x + Crd[crdResult-2].coord[coordGroup].width + 5;
}
else // We're dealing with an "odd" resource index.
{
// Put the counter to the left of the previous odd counter.
if (resourceIndex == 1)
Crd[crdResult].coord[coordGroup].x
= Crd[crdResult-1].coord[coordGroup].x - Crd[crdResult].coord[coordGroup].width - 5;
else
Crd[crdResult].coord[coordGroup].x
= Crd[crdResult-2].coord[coordGroup].x - Crd[crdResult].coord[coordGroup].width - 5;
}
// Set Y position to the same as the previous counter.
Crd[crdResult].coord[coordGroup].y
= Crd[crdResult-1].coord[coordGroup].y;
// Set height of readout to the same as the previous counter.
Crd[crdResult].coord[coordGroup].height
= Crd[crdResult-1].coord[coordGroup].height;
}
// Transfer to icon coordinates.
Crd[crdIconResult].coord[coordGroup].width = 32;
Crd[crdIconResult].coord[coordGroup].height = 32;
Crd[crdIconResult].coord[coordGroup].x = Crd[crdResult].coord[coordGroup].x;
Crd[crdIconResult].coord[coordGroup].y = Crd[crdResult].coord[coordGroup].y;
// Recalculate readout's size coordinates.
Crd[crdResult].size[coordGroup] = calcCrdArray (Crd[crdResult].coord[coordGroup].rx, Crd[crdResult].coord[coordGroup].ry, Crd[crdResult].coord[coordGroup].x, Crd[crdResult].coord[coordGroup].y, Crd[crdResult].coord[coordGroup].width, Crd[crdResult].coord[coordGroup].height, Crd[crdResult].coord[coordGroup].rx2, Crd[crdResult].coord[coordGroup].ry2);
// Recalculate icon's size coordinates.
Crd[crdIconResult].size[coordGroup] = calcCrdArray (Crd[crdIconResult].coord[coordGroup].rx, Crd[crdIconResult].coord[coordGroup].ry, Crd[crdIconResult].coord[coordGroup].x, Crd[crdIconResult].coord[coordGroup].y, Crd[crdIconResult].coord[coordGroup].width, Crd[crdIconResult].coord[coordGroup].height, Crd[crdIconResult].coord[coordGroup].rx2, Crd[crdIconResult].coord[coordGroup].ry2);
// If this coordinate is part of the currently active set, update the control onscreen too.
if (coordGroup == GUIType)
{
// Update counter size.
resourceObject.size = Crd[crdResult].size[GUIType];
resourceIconObject.size = Crd[crdIconResult].size[GUIType];
}
}
}
// ====================================================================
/*
DESCRIPTION : Functions for manipulating players and their properties (eg resources).
NOTES :
*/
// ====================================================================
function createResourceCounters()
{
resourceUIArray = new Array();
addResourceCounter(0, "food");
addResourceCounter(1, "wood");
addResourceCounter(2, "stone");
addResourceCounter(3, "metal");
addResourceCounter(4, "population");
refreshResource("Food", 0);
refreshResource("Wood", 1);
refreshResource("Stone", 2);
refreshResource("Metal", 3);
refreshResource("Population", 4);
}
// ====================================================================
function addResourceCounter (index, resourceName)
{
// Creates a resource counter widget.
// Ensure resource name is lower-case.
resourceName = resourceName.toLowerCase();
// We maintain a sorted array of the resource indexes so that the UI counters can be refreshed in centered order.
// (We don't include Housing in the list, though, as it does not have its own resource counter.)
if (resourceName != "housing")
{
// If it's an even index,
if (index % 2 == 0)
// Add it to the end of the UI array.
resourceUIArray.push ( index );
else
// Add it to the beginning of the UI array,
resourceUIArray.unshift ( index );
}
//console.write( "Added " + resourceName /*+ " (" + resourceQty + ")"*/ );
}
// ====================================================================
// HACK: Keep track of old resource values so we only update resource counters as necessary.
// We should really find a *much* faster way to render those counters, since resource values are bound to change quite quickly in a real game.
var oldResources = new Object();
function refreshResources ()
{
// Refreshes all resource counters after update.
var resourcePool = localPlayer.resources;
var shouldRefresh = false;
for (var currResource in resourcePool)
{
if( oldResources[currResource] != localPlayer.resources[currResource] )
{
oldResources[currResource] = localPlayer.resources[currResource].valueOf();
shouldRefresh = true;
}
}
if( shouldRefresh )
{
for( var i=0; i<2; i++ ) // 2 refreshes seem to be necessary for proper alignment
{
var resourceCount = 0;
for (var currResource in resourcePool)
{
if(currResource != "housing")
{
// Pass the array index of the resource as the second parameter (as we'll need that to determine the centered screen position of each counter).
refreshResource (toTitleCase(currResource), resourceUIArray[resourceCount]);
resourceCount++;
}
}
}
}
}
// ====================================================================
function refreshResource (resourceName, resourceIndex)
{
// Refresh the onscreen counter for a given resource (called to recalculate the size of the coordinates, as these dynamically adjust depending on character length).
// Ensure resource name is title-case.
resourceName = toTitleCase (resourceName);
// Ignore the "Housing" resource ... It doesn't work like normal resources and doesn't have a counter to resize.
if (resourceName == "Housing")
return;
// Get resource readout object.
var resourceObject = getGUIObjectByName ("snResourceCounter_" + (resourceIndex + 1));
// Get resource icon object.
var resourceIconObject = getGUIObjectByName ("snResourceCounterIcon_" + (resourceIndex + 1));
// Update counter caption (since we need to have up-to-date text to determine the length of the counter).
var caption = parseInt( localPlayer.resources[resourceName.toLowerCase()] );
// The Population counter also lists the amount of available housing.
if (resourceName == "Population")
caption += "/" + localPlayer.resources["housing"];
resourceObject.caption = caption;
// Update counter tooltip.
resourceObject.tooltip = resourceName + ": " + resourceObject.caption;
// Set resource icon.
resourceIconObject.cell_id = cellGroup["Resource"][resourceName.toLowerCase()].id;
// Get the index of the resource readout to be resized.
var crdResult = getCrd (resourceObject.name, true);
// Get the index of the resource icon.
var crdIconResult = getCrd (resourceIconObject.name, true);
// For each coordinate group stored for this control,
for (var coordGroup in Crd[crdResult].coord)
{
// Set width of readout based on length of caption.
Crd[crdResult].coord[coordGroup].width = snConst.MiniIcon.Width+5 + resourceObject.caption.length * 10;
// Set X and Y position and height so that resources always are immediately besides each other. (Except for the first resource (usually Food), which has the initial starting position)
// Determine starting position for the first resource (so that the resources wind up being centered across the screen).
if (resourceIndex == 0)
{
// The first coordinate is in the exact centre of the screen.
Crd[crdResult].coord[coordGroup].x = Math.round (-(Crd[crdResult].coord[coordGroup].width/2) - 5);
}
else
{ // Resources other than the first one get stacked in sequence to the sides of it.
// If we're dealing with an "even" resource index,
if (resourceIndex % 2 == 0)
{
// Put the counter to the right of the previous odd counter.
Crd[crdResult].coord[coordGroup].x
= Crd[crdResult-2].coord[coordGroup].x + Crd[crdResult-2].coord[coordGroup].width + 5;
}
else // We're dealing with an "odd" resource index.
{
// Put the counter to the left of the previous odd counter.
if (resourceIndex == 1)
Crd[crdResult].coord[coordGroup].x
= Crd[crdResult-1].coord[coordGroup].x - Crd[crdResult].coord[coordGroup].width - 5;
else
Crd[crdResult].coord[coordGroup].x
= Crd[crdResult-2].coord[coordGroup].x - Crd[crdResult].coord[coordGroup].width - 5;
}
// Set Y position to the same as the previous counter.
Crd[crdResult].coord[coordGroup].y
= Crd[crdResult-1].coord[coordGroup].y;
// Set height of readout to the same as the previous counter.
Crd[crdResult].coord[coordGroup].height
= Crd[crdResult-1].coord[coordGroup].height;
}
// Transfer to icon coordinates.
Crd[crdIconResult].coord[coordGroup].width = 32;
Crd[crdIconResult].coord[coordGroup].height = 32;
Crd[crdIconResult].coord[coordGroup].x = Crd[crdResult].coord[coordGroup].x;
Crd[crdIconResult].coord[coordGroup].y = Crd[crdResult].coord[coordGroup].y;
// Recalculate readout's size coordinates.
Crd[crdResult].size[coordGroup] = calcCrdArray (Crd[crdResult].coord[coordGroup].rx, Crd[crdResult].coord[coordGroup].ry, Crd[crdResult].coord[coordGroup].x, Crd[crdResult].coord[coordGroup].y, Crd[crdResult].coord[coordGroup].width, Crd[crdResult].coord[coordGroup].height, Crd[crdResult].coord[coordGroup].rx2, Crd[crdResult].coord[coordGroup].ry2);
// Recalculate icon's size coordinates.
Crd[crdIconResult].size[coordGroup] = calcCrdArray (Crd[crdIconResult].coord[coordGroup].rx, Crd[crdIconResult].coord[coordGroup].ry, Crd[crdIconResult].coord[coordGroup].x, Crd[crdIconResult].coord[coordGroup].y, Crd[crdIconResult].coord[coordGroup].width, Crd[crdIconResult].coord[coordGroup].height, Crd[crdIconResult].coord[coordGroup].rx2, Crd[crdIconResult].coord[coordGroup].ry2);
// If this coordinate is part of the currently active set, update the control onscreen too.
if (coordGroup == GUIType)
{
// Update counter size.
resourceObject.size = Crd[crdResult].size[GUIType];
resourceIconObject.size = Crd[crdIconResult].size[GUIType];
}
}
}
// ====================================================================
@@ -1,81 +1,81 @@
/*
DESCRIPTION : Generic utility functions.
NOTES :
*/
// ====================================================================
function getRandom(randomMin, randomMax)
{
// Returns a random whole number in a min..max range.
// NOTE: There should probably be an engine function for this,
// since we'd need to keep track of random seeds for replays.
var randomNum = randomMin + (randomMax-randomMin)*Math.random(); // num is random, from A to B
return Math.round(randomNum);
}
// ====================================================================
function parseDelimiterString (parseString, delimiter)
{
// Seeks through the delimiters in a string and populates the elements of an array with fields found between them.
// Declare local variables.
var parseLoop = 0;
var parseElement = 0;
var seekDelimiter = 0;
var parseArray = new Array();
// While we're still within the bounds of the string,
while (parseLoop <= parseString.length)
{
// Seek until we find a delimiter.
seekDelimiter = parseLoop;
while (parseString[seekDelimiter] != delimiter && seekDelimiter <= parseString.length)
seekDelimiter++;
// If we found a delimiter within the string,
if (seekDelimiter != parseString.length)
{
// Store sub-string between start point and delimiter in array element.
parseArray[parseElement] = parseString.substring(parseLoop, seekDelimiter);
parseElement++;
}
// Move to after delimiter position for next seek.
parseLoop = seekDelimiter+1;
}
// Store length of array.
parseArray.length = parseElement;
return parseArray;
}
// ====================================================================
function addArrayElement(Array)
{
// Adds an element to an array, updates its given index, and returns the index of the element.
Array[Array.last] = new Object();
Array.last++;
return (Array.last - 1);
}
// ====================================================================
function toTitleCase (string)
{
if (!string)
return string;
// Returns the title-case version of a given string.
string = string.toString();
string = string.substring(0,1).toUpperCase() + string.substring(1, string.length).toLowerCase();
return (string);
}
// ====================================================================
/*
DESCRIPTION : Generic utility functions.
NOTES :
*/
// ====================================================================
function getRandom(randomMin, randomMax)
{
// Returns a random whole number in a min..max range.
// NOTE: There should probably be an engine function for this,
// since we'd need to keep track of random seeds for replays.
var randomNum = randomMin + (randomMax-randomMin)*Math.random(); // num is random, from A to B
return Math.round(randomNum);
}
// ====================================================================
function parseDelimiterString (parseString, delimiter)
{
// Seeks through the delimiters in a string and populates the elements of an array with fields found between them.
// Declare local variables.
var parseLoop = 0;
var parseElement = 0;
var seekDelimiter = 0;
var parseArray = new Array();
// While we're still within the bounds of the string,
while (parseLoop <= parseString.length)
{
// Seek until we find a delimiter.
seekDelimiter = parseLoop;
while (parseString[seekDelimiter] != delimiter && seekDelimiter <= parseString.length)
seekDelimiter++;
// If we found a delimiter within the string,
if (seekDelimiter != parseString.length)
{
// Store sub-string between start point and delimiter in array element.
parseArray[parseElement] = parseString.substring(parseLoop, seekDelimiter);
parseElement++;
}
// Move to after delimiter position for next seek.
parseLoop = seekDelimiter+1;
}
// Store length of array.
parseArray.length = parseElement;
return parseArray;
}
// ====================================================================
function addArrayElement(Array)
{
// Adds an element to an array, updates its given index, and returns the index of the element.
Array[Array.last] = new Object();
Array.last++;
return (Array.last - 1);
}
// ====================================================================
function toTitleCase (string)
{
if (!string)
return string;
// Returns the title-case version of a given string.
string = string.toString();
string = string.substring(0,1).toUpperCase() + string.substring(1, string.length).toLowerCase();
return (string);
}
// ====================================================================
@@ -1,34 +1,34 @@
/*
DESCRIPTION : GUI animation functions (sliding in/out, fading, etc).
NOTES :
*/
// ====================================================================
function GUISlideIn(GUIObject, SlideSpeed)
{
// Just me testing some stuff :)
var SlideObject = getGUIObjectByName(GUIObject);
var SizeVar = SlideObject.size;
//var Sizes = SizeVar.split(" ");
//var x_s = Sizes[0];
//var y_s = Sizes[1];
//var x_e = Sizes[2];
//var y_e = Sizes[3];
//var height = x_e - x_s;
//var Time = new Date();
//var StartTime = Time.getTime();
var i = 0;
while(i <= 2) {
i++;
SlideObject.size = new GUISize(x_s, 0 + i, x_e, 0 + i + height);
}
}
// ====================================================================
/*
DESCRIPTION : GUI animation functions (sliding in/out, fading, etc).
NOTES :
*/
// ====================================================================
function GUISlideIn(GUIObject, SlideSpeed)
{
// Just me testing some stuff :)
var SlideObject = getGUIObjectByName(GUIObject);
var SizeVar = SlideObject.size;
//var Sizes = SizeVar.split(" ");
//var x_s = Sizes[0];
//var y_s = Sizes[1];
//var x_e = Sizes[2];
//var y_e = Sizes[3];
//var height = x_e - x_s;
//var Time = new Date();
//var StartTime = Time.getTime();
var i = 0;
while(i <= 2) {
i++;
SlideObject.size = new GUISize(x_s, 0 + i, x_e, 0 + i + height);
}
}
// ====================================================================
@@ -1,287 +1,287 @@
/*
DESCRIPTION : Functions that support the coordinate system (ability to maintain and swap between multiple
sizes for an object).
NOTES :
*/
// ====================================================================
function initCoord()
{
// Initialise coordinate set for this page.
Crd = new Array();
Crd.last = new Object(-1);
// Set corner constants.
rb = 0;
lb = 1;
lt = 2;
rt = 3;
}
// ====================================================================
// Add a new size coordinate to the array.
function addCrd (name, group, rx, ry, x, y, width, height, rx2, ry2)
{
// If no group is specified, default to the first one.
if (!group)
group = rb;
// Create new coordinate if necessary (it doesn't exist, or we have a new name).
if (group == rb || !Crd[Crd.last])
{
Crd.last++;
Crd[Crd.last] = new Object();
Crd[Crd.last].name = new Object(name);
Crd[Crd.last].size = new Object();
Crd[Crd.last].coord = new Object();
}
// Get coordinates from first element if not defined.
if (x == undefined)
x = Crd[Crd.last].coord[rb].x;
if (y == undefined)
y = Crd[Crd.last].coord[rb].y;
if (width == undefined)
width = Crd[Crd.last].coord[rb].width;
if (height == undefined)
height = Crd[Crd.last].coord[rb].height;
// Generate and save coordinates.
Crd[Crd.last].size[group] = calcCrdArray (rx, ry, x, y, width, height, rx2, ry2);
Crd[Crd.last].coord[group] = new Array();
Crd[Crd.last].coord[group].rx = rx;
Crd[Crd.last].coord[group].ry = ry;
Crd[Crd.last].coord[group].x = x;
Crd[Crd.last].coord[group].y = y;
Crd[Crd.last].coord[group].width = width;
Crd[Crd.last].coord[group].height = height;
}
// ====================================================================
function addCrds (name, rx, ry, x, y, width, height, rx2, ry2)
{
// This is a shortcut function that saves you having to call addCrd() for each coordinate group. Just do this once for the whole set.
// It creates the first, then assumes all the remaining coordinates are flipped to the opposite screen edge.
// (True in 90% of cases.)
addCrd (name, rb, rx, ry, x, y, width, height, rx2, ry2);
// Determine flip relatives.
switch (rx)
{
case 0:
var rx1 = 100;
var rx2 = 100;
var rx3 = 0;
break;
case 50:
var rx1 = 50;
var rx2 = 50;
var rx3 = 50;
break;
case 100:
var rx1 = 0;
var rx2 = 0;
var rx3 = 100;
break;
}
switch (ry)
{
case 0:
var ry1 = 0;
var ry2 = 100;
var ry3 = 100;
break;
case 50:
var ry1 = 50;
var ry2 = 50;
var ry3 = 50;
break;
case 100:
var ry1 = 100;
var ry2 = 0;
var ry3 = 0;
break;
}
// Define the rest of the coordinate set.
addCrd (name, lb, rx1, ry1);
addCrd (name, lt, rx2, ry2);
addCrd (name, rt, rx3, ry3);
}
// ====================================================================
// Return coordinate object with a given name.
// Optionally can choose to return the index to the coordinate, rather than the coordinate itself.
function getCrd (name, byIndex)
{
for (var getCrdLoop = 0; getCrdLoop <= Crd.last; getCrdLoop++)
{
if (Crd[getCrdLoop].name == name)
{
// If only index requested, just return index.
if (byIndex)
return getCrdLoop;
else
// Otherwise return the whole coordinate array for this object.
return Crd[getCrdLoop];
}
}
console.write ("Coordinate " + name + " not found in call to getCrd().");
// Return -1 to indicate failure.
return -1;
}
// ====================================================================
// 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, rx2, ry2)
{
if (!rx2 && !ry2)
{
// If two sets of relatives are not specified at the end of the parameter list, use the "shortcut" format:
// "Left Corner" (Relative X)
// "Top Corner" (Relative Y)
// X Position
// Y Position
// Width from X
// Height from Y
var setSizeContainer = new Object();
setSizeContainer.rleft = rx;
setSizeContainer.rtop = ry;
setSizeContainer.rright = rx;
setSizeContainer.rbottom = ry;
// Define size dimensions.
switch (setSizeContainer.rleft)
{
case 0:
case 50:
setSizeContainer.x1 = x;
break;
case 100:
setSizeContainer.x1 = -x-width;
break;
}
switch (setSizeContainer.rtop)
{
case 0:
case 50:
setSizeContainer.y1 = y;
break;
case 100:
setSizeContainer.y1 = -y-height;
break;
}
switch (setSizeContainer.rright)
{
case 0:
case 50:
setSizeContainer.x2 = x+width;
break;
case 100:
setSizeContainer.x2 = -x;
break;
}
switch (setSizeContainer.rbottom)
{
case 0:
case 50:
setSizeContainer.y2 = y+height;
break;
case 100:
setSizeContainer.y2 = -y;
break;
}
return new GUISize (setSizeContainer.x1, setSizeContainer.y1, setSizeContainer.x2, setSizeContainer.y2,
setSizeContainer.rleft, setSizeContainer.rtop, setSizeContainer.rright, setSizeContainer.rbottom);
}
else
{
// Use the standard "size" structure:
// RX
// RY
// X1
// X2
// Y1
// Y2
// RX2
// RY2
return new GUISize (x, y, width, height, rx, ry, rx2, ry2);
}
}
// ====================================================================
// Set an existing coord of a given name to a new value.
function setCrd (name, newCrd)
{
// Get the index to the given coordinate.
var crdResult = getCrd (name, true);
if (crdResult != -1)
{
// Set new value of this coordinate.
Crd[crdResult] = newCrd;
}
else
{
console.write ("Failed to setCrd() + " + name);
return -1;
}
}
// ====================================================================
function setSkin (skinName)
{
// (Unfortunately, this idea just isn't going to work until the GUI Engine allows us to set the value of a control's style (and therefore refresh its properties
// with those of the new style. As it stands, the style property is empty at runtime because styles are all set when the stuff is loaded. And since we're wrapping
// sprite info for skins in the styles, it won't be adequate to simply change the sprite properties. So commenting this out for now so we can adapt it later.)
/*
// Sets the sprites of all registered controls with a skin (eg *<skinname>*SpriteName) to the specified skin name.
// Obviously such sprite names must exist, or it all will go horribly wrong.
// Seek through all registered coordinates.
for (var i = 0; i <= Crd.last; i++)
{
var objectName = getGUIObjectByName (Crd[i].name);
// We need to deliberately ignore the minimap object as it has no sprite (and checking for the existence of the property or type doesn't work).
if (objectName.name != "snMiniMapDisplay")
{
// Get first asterisk position.
var startIndex = objectName.style.indexOf ("*", 1);
console.write (startIndex);
// If the coordinate begins with a "skin*" (and therefore qualifies for replacement),
if (startIndex != -1)
{
// Look for and return the ending asterisk.
var endIndex = objectName.style.indexOf ("*", 5);
console.write (endIndex);
if (endIndex != -1)
{
// Set new skin name for sprite.
objectName.style = "skin*" + skinName + "*" + objectName.style.substring (endIndex);
}
}
}
}
*/
}
/*
DESCRIPTION : Functions that support the coordinate system (ability to maintain and swap between multiple
sizes for an object).
NOTES :
*/
// ====================================================================
function initCoord()
{
// Initialise coordinate set for this page.
Crd = new Array();
Crd.last = new Object(-1);
// Set corner constants.
rb = 0;
lb = 1;
lt = 2;
rt = 3;
}
// ====================================================================
// Add a new size coordinate to the array.
function addCrd (name, group, rx, ry, x, y, width, height, rx2, ry2)
{
// If no group is specified, default to the first one.
if (!group)
group = rb;
// Create new coordinate if necessary (it doesn't exist, or we have a new name).
if (group == rb || !Crd[Crd.last])
{
Crd.last++;
Crd[Crd.last] = new Object();
Crd[Crd.last].name = new Object(name);
Crd[Crd.last].size = new Object();
Crd[Crd.last].coord = new Object();
}
// Get coordinates from first element if not defined.
if (x == undefined)
x = Crd[Crd.last].coord[rb].x;
if (y == undefined)
y = Crd[Crd.last].coord[rb].y;
if (width == undefined)
width = Crd[Crd.last].coord[rb].width;
if (height == undefined)
height = Crd[Crd.last].coord[rb].height;
// Generate and save coordinates.
Crd[Crd.last].size[group] = calcCrdArray (rx, ry, x, y, width, height, rx2, ry2);
Crd[Crd.last].coord[group] = new Array();
Crd[Crd.last].coord[group].rx = rx;
Crd[Crd.last].coord[group].ry = ry;
Crd[Crd.last].coord[group].x = x;
Crd[Crd.last].coord[group].y = y;
Crd[Crd.last].coord[group].width = width;
Crd[Crd.last].coord[group].height = height;
}
// ====================================================================
function addCrds (name, rx, ry, x, y, width, height, rx2, ry2)
{
// This is a shortcut function that saves you having to call addCrd() for each coordinate group. Just do this once for the whole set.
// It creates the first, then assumes all the remaining coordinates are flipped to the opposite screen edge.
// (True in 90% of cases.)
addCrd (name, rb, rx, ry, x, y, width, height, rx2, ry2);
// Determine flip relatives.
switch (rx)
{
case 0:
var rx1 = 100;
var rx2 = 100;
var rx3 = 0;
break;
case 50:
var rx1 = 50;
var rx2 = 50;
var rx3 = 50;
break;
case 100:
var rx1 = 0;
var rx2 = 0;
var rx3 = 100;
break;
}
switch (ry)
{
case 0:
var ry1 = 0;
var ry2 = 100;
var ry3 = 100;
break;
case 50:
var ry1 = 50;
var ry2 = 50;
var ry3 = 50;
break;
case 100:
var ry1 = 100;
var ry2 = 0;
var ry3 = 0;
break;
}
// Define the rest of the coordinate set.
addCrd (name, lb, rx1, ry1);
addCrd (name, lt, rx2, ry2);
addCrd (name, rt, rx3, ry3);
}
// ====================================================================
// Return coordinate object with a given name.
// Optionally can choose to return the index to the coordinate, rather than the coordinate itself.
function getCrd (name, byIndex)
{
for (var getCrdLoop = 0; getCrdLoop <= Crd.last; getCrdLoop++)
{
if (Crd[getCrdLoop].name == name)
{
// If only index requested, just return index.
if (byIndex)
return getCrdLoop;
else
// Otherwise return the whole coordinate array for this object.
return Crd[getCrdLoop];
}
}
console.write ("Coordinate " + name + " not found in call to getCrd().");
// Return -1 to indicate failure.
return -1;
}
// ====================================================================
// 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, rx2, ry2)
{
if (!rx2 && !ry2)
{
// If two sets of relatives are not specified at the end of the parameter list, use the "shortcut" format:
// "Left Corner" (Relative X)
// "Top Corner" (Relative Y)
// X Position
// Y Position
// Width from X
// Height from Y
var setSizeContainer = new Object();
setSizeContainer.rleft = rx;
setSizeContainer.rtop = ry;
setSizeContainer.rright = rx;
setSizeContainer.rbottom = ry;
// Define size dimensions.
switch (setSizeContainer.rleft)
{
case 0:
case 50:
setSizeContainer.x1 = x;
break;
case 100:
setSizeContainer.x1 = -x-width;
break;
}
switch (setSizeContainer.rtop)
{
case 0:
case 50:
setSizeContainer.y1 = y;
break;
case 100:
setSizeContainer.y1 = -y-height;
break;
}
switch (setSizeContainer.rright)
{
case 0:
case 50:
setSizeContainer.x2 = x+width;
break;
case 100:
setSizeContainer.x2 = -x;
break;
}
switch (setSizeContainer.rbottom)
{
case 0:
case 50:
setSizeContainer.y2 = y+height;
break;
case 100:
setSizeContainer.y2 = -y;
break;
}
return new GUISize (setSizeContainer.x1, setSizeContainer.y1, setSizeContainer.x2, setSizeContainer.y2,
setSizeContainer.rleft, setSizeContainer.rtop, setSizeContainer.rright, setSizeContainer.rbottom);
}
else
{
// Use the standard "size" structure:
// RX
// RY
// X1
// X2
// Y1
// Y2
// RX2
// RY2
return new GUISize (x, y, width, height, rx, ry, rx2, ry2);
}
}
// ====================================================================
// Set an existing coord of a given name to a new value.
function setCrd (name, newCrd)
{
// Get the index to the given coordinate.
var crdResult = getCrd (name, true);
if (crdResult != -1)
{
// Set new value of this coordinate.
Crd[crdResult] = newCrd;
}
else
{
console.write ("Failed to setCrd() + " + name);
return -1;
}
}
// ====================================================================
function setSkin (skinName)
{
// (Unfortunately, this idea just isn't going to work until the GUI Engine allows us to set the value of a control's style (and therefore refresh its properties
// with those of the new style. As it stands, the style property is empty at runtime because styles are all set when the stuff is loaded. And since we're wrapping
// sprite info for skins in the styles, it won't be adequate to simply change the sprite properties. So commenting this out for now so we can adapt it later.)
/*
// Sets the sprites of all registered controls with a skin (eg *<skinname>*SpriteName) to the specified skin name.
// Obviously such sprite names must exist, or it all will go horribly wrong.
// Seek through all registered coordinates.
for (var i = 0; i <= Crd.last; i++)
{
var objectName = getGUIObjectByName (Crd[i].name);
// We need to deliberately ignore the minimap object as it has no sprite (and checking for the existence of the property or type doesn't work).
if (objectName.name != "snMiniMapDisplay")
{
// Get first asterisk position.
var startIndex = objectName.style.indexOf ("*", 1);
console.write (startIndex);
// If the coordinate begins with a "skin*" (and therefore qualifies for replacement),
if (startIndex != -1)
{
// Look for and return the ending asterisk.
var endIndex = objectName.style.indexOf ("*", 5);
console.write (endIndex);
if (endIndex != -1)
{
// Set new skin name for sprite.
objectName.style = "skin*" + skinName + "*" + objectName.style.substring (endIndex);
}
}
}
}
*/
}
// ====================================================================
@@ -1,164 +1,164 @@
/*
DESCRIPTION : Functions to manipulate objects with a 'list' property
(used to handle the items in list, dropdown, etc.)
NOTES : To ensure the selection is properly updated, it is important to
use these functions and not manually access the list.
*/
// ====================================================================
// Remove the item at the given index (pos) from the given list object (objectName).
function removeItem (objectName, pos)
{
if (getGUIObjectByName (objectName) == null)
console.write ("removeItem(): " + objectName + " not found.");
var list = getGUIObjectByName (objectName).list;
var selected = getGUIObjectByName (objectName).selected;
list.splice(pos, 1);
getGUIObjectByName (objectName).list = list;
// It's important that we update the selection *after*
// we've committed the changes to the list.
// Update the selected so the same element remains selected.
if (selected == pos)
{
getGUIObjectByName (objectName).selected = -1;
}
else
if (selected > pos)
{
getGUIObjectByName (objectName).selected = selected - 1;
}
}
// ====================================================================
// Add the item at the given index (pos) to the given list object (objectName) with the given value (value).
function addItem (objectName, pos, value)
{
if (getGUIObjectByName (objectName) == null)
console.write ("addItem(): " + objectName + " not found.");
var list = getGUIObjectByName (objectName).list;
var selected = getGUIObjectByName (objectName).selected;
list.splice (pos, 0, value);
getGUIObjectByName (objectName).list = list;
// It's important that we update the selection *after*
// we've committed the changes to the list.
// Update the selected so the same element remains selected.
if (selected >= pos)
{
getGUIObjectByName (objectName).selected = selected + 1;
}
}
// ====================================================================
// Adds an element to the end of the list
function pushItem (objectName, value)
{
if (getGUIObjectByName (objectName) == null)
console.write ("pushItem(): " + objectName + " not found.");
var list = getGUIObjectByName (objectName).list;
list.push (value);
getGUIObjectByName (objectName).list = list;
// Point to the new item.
getGUIObjectByName(objectName).selected = getNumItems(objectName)-1;
}
// ====================================================================
// Removes the last element
function popItem (objectName)
{
if (getGUIObjectByName (objectName) == null)
console.write ("popItem(): " + objectName + " not found.");
var selected = getGUIObjectByName (objectName).selected;
removeItem(objectName, getNumItems(objectName)-1);
if (selected == getNumItems(objectName)-1)
{
getGUIObjectByName(objectName).selected = -1;
}
}
// ====================================================================
// Retrieves the number of elements in the list
function getNumItems (objectName)
{
if (getGUIObjectByName (objectName) == null)
console.write ("getNumItems(): " + objectName + " not found.");
var list = getGUIObjectByName(objectName).list;
return list.length;
}
// ====================================================================
// Retrieves the value of the item at 'pos'
function getItemValue (objectName, pos)
{
if (getGUIObjectByName (objectName) == null)
console.write ("getItemValue(): " + objectName + " not found.");
var list = getGUIObjectByName(objectName).list;
return list[pos];
}
// ====================================================================
// Retrieves the value of the currently selected item
function getCurrItemValue (objectName)
{
if (getGUIObjectByName (objectName) == null)
console.write ("getCurrItemValue(): " + objectName + " not found.");
if (getGUIObjectByName(objectName).selected == -1)
return "";
var list = getGUIObjectByName(objectName).list;
return list[getGUIObjectByName(objectName).selected];
}
// ====================================================================
// Sets current item to a given string (which must be one of those
// already in the list).
function setCurrItemValue (objectName, string)
{
if (getGUIObjectByName(objectName) == null) {
console.write ("setCurrItemValue(): " + objectName + " not found.");
return -1;
}
if (getGUIObjectByName(objectName).selected == -1)
return -1; // Return -1 if nothing selected.
var list = getGUIObjectByName(objectName).list;
// Seek through list.
for (ctr = 0; ctr < list.length; ctr++)
{
// If we have found the string in the list,
if (list[ctr] == string)
{
// Point selected to this item.
getGUIObjectByName(objectName).selected = ctr;
return ctr; // Return position of item.
}
}
// Return -2 if failed to find value in list.
console.write ("Requested string '" + string + "' not found in " + objectName + "'s list.");
return -2;
}
/*
DESCRIPTION : Functions to manipulate objects with a 'list' property
(used to handle the items in list, dropdown, etc.)
NOTES : To ensure the selection is properly updated, it is important to
use these functions and not manually access the list.
*/
// ====================================================================
// Remove the item at the given index (pos) from the given list object (objectName).
function removeItem (objectName, pos)
{
if (getGUIObjectByName (objectName) == null)
console.write ("removeItem(): " + objectName + " not found.");
var list = getGUIObjectByName (objectName).list;
var selected = getGUIObjectByName (objectName).selected;
list.splice(pos, 1);
getGUIObjectByName (objectName).list = list;
// It's important that we update the selection *after*
// we've committed the changes to the list.
// Update the selected so the same element remains selected.
if (selected == pos)
{
getGUIObjectByName (objectName).selected = -1;
}
else
if (selected > pos)
{
getGUIObjectByName (objectName).selected = selected - 1;
}
}
// ====================================================================
// Add the item at the given index (pos) to the given list object (objectName) with the given value (value).
function addItem (objectName, pos, value)
{
if (getGUIObjectByName (objectName) == null)
console.write ("addItem(): " + objectName + " not found.");
var list = getGUIObjectByName (objectName).list;
var selected = getGUIObjectByName (objectName).selected;
list.splice (pos, 0, value);
getGUIObjectByName (objectName).list = list;
// It's important that we update the selection *after*
// we've committed the changes to the list.
// Update the selected so the same element remains selected.
if (selected >= pos)
{
getGUIObjectByName (objectName).selected = selected + 1;
}
}
// ====================================================================
// Adds an element to the end of the list
function pushItem (objectName, value)
{
if (getGUIObjectByName (objectName) == null)
console.write ("pushItem(): " + objectName + " not found.");
var list = getGUIObjectByName (objectName).list;
list.push (value);
getGUIObjectByName (objectName).list = list;
// Point to the new item.
getGUIObjectByName(objectName).selected = getNumItems(objectName)-1;
}
// ====================================================================
// Removes the last element
function popItem (objectName)
{
if (getGUIObjectByName (objectName) == null)
console.write ("popItem(): " + objectName + " not found.");
var selected = getGUIObjectByName (objectName).selected;
removeItem(objectName, getNumItems(objectName)-1);
if (selected == getNumItems(objectName)-1)
{
getGUIObjectByName(objectName).selected = -1;
}
}
// ====================================================================
// Retrieves the number of elements in the list
function getNumItems (objectName)
{
if (getGUIObjectByName (objectName) == null)
console.write ("getNumItems(): " + objectName + " not found.");
var list = getGUIObjectByName(objectName).list;
return list.length;
}
// ====================================================================
// Retrieves the value of the item at 'pos'
function getItemValue (objectName, pos)
{
if (getGUIObjectByName (objectName) == null)
console.write ("getItemValue(): " + objectName + " not found.");
var list = getGUIObjectByName(objectName).list;
return list[pos];
}
// ====================================================================
// Retrieves the value of the currently selected item
function getCurrItemValue (objectName)
{
if (getGUIObjectByName (objectName) == null)
console.write ("getCurrItemValue(): " + objectName + " not found.");
if (getGUIObjectByName(objectName).selected == -1)
return "";
var list = getGUIObjectByName(objectName).list;
return list[getGUIObjectByName(objectName).selected];
}
// ====================================================================
// Sets current item to a given string (which must be one of those
// already in the list).
function setCurrItemValue (objectName, string)
{
if (getGUIObjectByName(objectName) == null) {
console.write ("setCurrItemValue(): " + objectName + " not found.");
return -1;
}
if (getGUIObjectByName(objectName).selected == -1)
return -1; // Return -1 if nothing selected.
var list = getGUIObjectByName(objectName).list;
// Seek through list.
for (ctr = 0; ctr < list.length; ctr++)
{
// If we have found the string in the list,
if (list[ctr] == string)
{
// Point selected to this item.
getGUIObjectByName(objectName).selected = ctr;
return ctr; // Return position of item.
}
}
// Return -2 if failed to find value in list.
console.write ("Requested string '" + string + "' not found in " + objectName + "'s list.");
return -2;
}
// ====================================================================
@@ -1,106 +1,106 @@
/*
DESCRIPTION : Audio functions (eg "pick a random sound from a list", "build a playlist") go here.
NOTES :
*/
// ====================================================================
// Quick run-down of the basic audio commands:
// Save the specified audio file to handle "s".
// s = new Sound( "audio/music/menu_track.ogg" );
// Play the sound stored at handle "s" one time (it'll be automatically freed when the playback ends):
// s.play();
// Play the sound stored at handle "s" continuously:
// s.loop();
// Close "s" and free it from memory (use in conjunction with loop()):
// s.free();
// Adjust the gain (volume) of a sound (floating point range between 0 (silent) and 1 (max volume)).
// s.setGain(value);
// ====================================================================
function newRandomSound(soundType, soundSubType, soundPrePath)
{
// Return a random audio file by category, to be assigned to a handle.
switch (soundType)
{
case "music":
var randomSoundPath = "audio/music/"
break;
case "voice":
randomSoundPath = soundPrePath + "/";
break;
default:
break;
}
// Get names of sounds (attack, command, select, hit, pain).
// or
// Get names of "peace", "menu" (theme) and "battle" tracks.
var soundArray = buildDirEntList(randomSoundPath, "*" + soundSubType + "*", false);
if (soundArray.length == 0)
{
console.write ("Failed to find sounds matching '*"+soundSubType+"*'");
return;
}
// Get a random number within the sound's range.
var randomSound = getRandom (0, soundArray.length-1);
// Set name of track.
var randomFileName = soundArray[randomSound];
// Build path to random audio file.
randomSoundPath = randomFileName;
//console.write("Playing " + randomSoundPath + " ...");
return new Sound(randomSoundPath);
}
// ====================================================================
function fadeOut (soundHandle, fadeDuration)
{
// Adjust the gain of a sound until it is zero.
// The sound is automatically freed when finished fading.
soundHandle.fade(-1, 0, fadeDuration)
return true;
}
// ====================================================================
function fadeIn (soundHandle, finalGain, fadeDuration)
{
// Adjust the gain of a sound from zero up to the given value.
soundHandle.fade(0, finalGain, fadeDuration)
return true;
}
// ====================================================================
function crossFade (outHandle, inHandle, fadeDuration)
{
// Accepts two sound handles. Over the given duration,
// fades out the first while fading in the second.
// Note that it plays the in and frees the out while it's at it.
if (outHandle)
fadeOut(outHandle, fadeDuration);
if (inHandle)
{
inHandle.play();
fadeIn(inHandle, g_ConfigDB.system["sound.mastergain"], fadeDuration);
}
return true;
}
/*
DESCRIPTION : Audio functions (eg "pick a random sound from a list", "build a playlist") go here.
NOTES :
*/
// ====================================================================
// Quick run-down of the basic audio commands:
// Save the specified audio file to handle "s".
// s = new Sound( "audio/music/menu_track.ogg" );
// Play the sound stored at handle "s" one time (it'll be automatically freed when the playback ends):
// s.play();
// Play the sound stored at handle "s" continuously:
// s.loop();
// Close "s" and free it from memory (use in conjunction with loop()):
// s.free();
// Adjust the gain (volume) of a sound (floating point range between 0 (silent) and 1 (max volume)).
// s.setGain(value);
// ====================================================================
function newRandomSound(soundType, soundSubType, soundPrePath)
{
// Return a random audio file by category, to be assigned to a handle.
switch (soundType)
{
case "music":
var randomSoundPath = "audio/music/"
break;
case "voice":
randomSoundPath = soundPrePath + "/";
break;
default:
break;
}
// Get names of sounds (attack, command, select, hit, pain).
// or
// Get names of "peace", "menu" (theme) and "battle" tracks.
var soundArray = buildDirEntList(randomSoundPath, "*" + soundSubType + "*", false);
if (soundArray.length == 0)
{
console.write ("Failed to find sounds matching '*"+soundSubType+"*'");
return;
}
// Get a random number within the sound's range.
var randomSound = getRandom (0, soundArray.length-1);
// Set name of track.
var randomFileName = soundArray[randomSound];
// Build path to random audio file.
randomSoundPath = randomFileName;
//console.write("Playing " + randomSoundPath + " ...");
return new Sound(randomSoundPath);
}
// ====================================================================
function fadeOut (soundHandle, fadeDuration)
{
// Adjust the gain of a sound until it is zero.
// The sound is automatically freed when finished fading.
soundHandle.fade(-1, 0, fadeDuration)
return true;
}
// ====================================================================
function fadeIn (soundHandle, finalGain, fadeDuration)
{
// Adjust the gain of a sound from zero up to the given value.
soundHandle.fade(0, finalGain, fadeDuration)
return true;
}
// ====================================================================
function crossFade (outHandle, inHandle, fadeDuration)
{
// Accepts two sound handles. Over the given duration,
// fades out the first while fading in the second.
// Note that it plays the in and frees the out while it's at it.
if (outHandle)
fadeOut(outHandle, fadeDuration);
if (inHandle)
{
inHandle.play();
fadeIn(inHandle, g_ConfigDB.system["sound.mastergain"], fadeDuration);
}
return true;
}
// ====================================================================
@@ -1,134 +1,134 @@
/*
DESCRIPTION : Utility functions that manipulate GUI objects.
NOTES :
*/
// ====================================================================
// Hide GUI object.
function guiHide (objectName)
{
var guiObject = getGUIObjectByName (objectName);
if( guiObject == "" || guiObject == null || guiObject == undefined || guiObject == "undefined" )
console.write ("guiHide(): GUI Object not found: " + objectName);
if( !guiObject.hidden )
guiObject.hidden = true;
}
// ====================================================================
// Reveal GUI object.
function guiUnHide (objectName)
{
var guiObject = getGUIObjectByName (objectName);
if (guiObject == "" || guiObject == null || guiObject == undefined || guiObject == "undefined")
console.write ("guiUnHide(): GUI Object not found: " + objectName);
if( guiObject.hidden )
guiObject.hidden = false;
}
// ====================================================================
// Toggle visibility of GUI object.
function guiToggle (objectName)
{
// Get our GUI object
var guiObject = getGUIObjectByName (objectName);
if (guiObject == "" || guiObject == null || guiObject == undefined || guiObject == "undefined")
console.write ("guiToggle(): GUI Object not found: " + objectName);
// Toggle it
guiObject.hidden = !guiObject.hidden;
}
// ====================================================================
// Enable GUI object.
function guiEnable (objectName)
{
var guiObject = getGUIObjectByName (objectName);
if (guiObject == "" || guiObject == null || guiObject == undefined || guiObject == "undefined")
console.write ("guiEnable(): GUI Object not found: " + objectName);
guiObject.enabled = true;
}
// ====================================================================
// Disable GUI object.
function guiDisable (objectName)
{
var guiObject = getGUIObjectByName (objectName);
if (guiObject == "" || guiObject == null || guiObject == undefined || guiObject == "undefined")
console.write ("guiDisable(): GUI Object not found: " + objectName);
guiObject.enabled = false;
}
// ====================================================================
// Change caption of GUI object and then make it visible.
function guiRenameAndReveal (objectName, objectCaption)
{
// Get our GUI object
var guiObject = getGUIObjectByName (objectName);
if (guiObject == "" || guiObject == null || guiObject == undefined || guiObject == "undefined")
console.write ("guiRenameAndReveal(): GUI Object not found: " + objectName);
// Rename it
guiObject.caption = objectCaption;
// Toggle it
guiObject.hidden = false;
}
// ====================================================================
// Increment/decrement the numeric caption of a GUI object.
function guiModifyCaption (objectName, objectModifier, objectPlaces)
{
// Adds a modifier to a GUI object's caption (eg increase a number by 1).
// Obviously don't use this unless you're sure the caption contains a number.
// objectPlaces specifies the number of decimal places to use for a floating point number.
// If not specified, it defaults to zero (whole number).
// Get our GUI object
var guiObject = getGUIObjectByName (objectName);
if (guiObject == "" || guiObject == null || guiObject == undefined || guiObject == "undefined")
console.write ("guiModifyCaption(): GUI Object not found: " + objectName);
if (!objectPlaces)
objectPlaces = 0;
objectPlaces = Math.pow (10, objectPlaces);
guiObject.caption = (Math.round (objectPlaces * guiObject.caption)
+ Math.round (objectPlaces * objectModifier) ) / objectPlaces;
}
// ====================================================================
// Set caption of a GUI object.
function guiSetCaption (objectName, objectCaption)
{
// Sets an object's caption to the specified value.
// Get our GUI object
var guiObject = getGUIObjectByName (objectName);
if (guiObject == "" || guiObject == null || guiObject == undefined || guiObject == "undefined")
console.write ("guiSetCaption(): GUI Object not found: " + objectName);
guiObject.caption = objectCaption;
}
// ====================================================================
// Helper function that closes a given window (usually the current parent) and opens another one.
function guiSwitch (closeWindowName, openWindowName)
{
guiHide (closeWindowName);
guiUnHide (openWindowName);
}
/*
DESCRIPTION : Utility functions that manipulate GUI objects.
NOTES :
*/
// ====================================================================
// Hide GUI object.
function guiHide (objectName)
{
var guiObject = getGUIObjectByName (objectName);
if( guiObject == "" || guiObject == null || guiObject == undefined || guiObject == "undefined" )
console.write ("guiHide(): GUI Object not found: " + objectName);
if( !guiObject.hidden )
guiObject.hidden = true;
}
// ====================================================================
// Reveal GUI object.
function guiUnHide (objectName)
{
var guiObject = getGUIObjectByName (objectName);
if (guiObject == "" || guiObject == null || guiObject == undefined || guiObject == "undefined")
console.write ("guiUnHide(): GUI Object not found: " + objectName);
if( guiObject.hidden )
guiObject.hidden = false;
}
// ====================================================================
// Toggle visibility of GUI object.
function guiToggle (objectName)
{
// Get our GUI object
var guiObject = getGUIObjectByName (objectName);
if (guiObject == "" || guiObject == null || guiObject == undefined || guiObject == "undefined")
console.write ("guiToggle(): GUI Object not found: " + objectName);
// Toggle it
guiObject.hidden = !guiObject.hidden;
}
// ====================================================================
// Enable GUI object.
function guiEnable (objectName)
{
var guiObject = getGUIObjectByName (objectName);
if (guiObject == "" || guiObject == null || guiObject == undefined || guiObject == "undefined")
console.write ("guiEnable(): GUI Object not found: " + objectName);
guiObject.enabled = true;
}
// ====================================================================
// Disable GUI object.
function guiDisable (objectName)
{
var guiObject = getGUIObjectByName (objectName);
if (guiObject == "" || guiObject == null || guiObject == undefined || guiObject == "undefined")
console.write ("guiDisable(): GUI Object not found: " + objectName);
guiObject.enabled = false;
}
// ====================================================================
// Change caption of GUI object and then make it visible.
function guiRenameAndReveal (objectName, objectCaption)
{
// Get our GUI object
var guiObject = getGUIObjectByName (objectName);
if (guiObject == "" || guiObject == null || guiObject == undefined || guiObject == "undefined")
console.write ("guiRenameAndReveal(): GUI Object not found: " + objectName);
// Rename it
guiObject.caption = objectCaption;
// Toggle it
guiObject.hidden = false;
}
// ====================================================================
// Increment/decrement the numeric caption of a GUI object.
function guiModifyCaption (objectName, objectModifier, objectPlaces)
{
// Adds a modifier to a GUI object's caption (eg increase a number by 1).
// Obviously don't use this unless you're sure the caption contains a number.
// objectPlaces specifies the number of decimal places to use for a floating point number.
// If not specified, it defaults to zero (whole number).
// Get our GUI object
var guiObject = getGUIObjectByName (objectName);
if (guiObject == "" || guiObject == null || guiObject == undefined || guiObject == "undefined")
console.write ("guiModifyCaption(): GUI Object not found: " + objectName);
if (!objectPlaces)
objectPlaces = 0;
objectPlaces = Math.pow (10, objectPlaces);
guiObject.caption = (Math.round (objectPlaces * guiObject.caption)
+ Math.round (objectPlaces * objectModifier) ) / objectPlaces;
}
// ====================================================================
// Set caption of a GUI object.
function guiSetCaption (objectName, objectCaption)
{
// Sets an object's caption to the specified value.
// Get our GUI object
var guiObject = getGUIObjectByName (objectName);
if (guiObject == "" || guiObject == null || guiObject == undefined || guiObject == "undefined")
console.write ("guiSetCaption(): GUI Object not found: " + objectName);
guiObject.caption = objectCaption;
}
// ====================================================================
// Helper function that closes a given window (usually the current parent) and opens another one.
function guiSwitch (closeWindowName, openWindowName)
{
guiHide (closeWindowName);
guiUnHide (openWindowName);
}
// ====================================================================
@@ -1,44 +1,44 @@
function updateOrbital()
{
if( !getGUIObjectByName( 'arena' ).hidden )
{
g_ballx += g_balldx;
g_bally += g_balldy;
if (g_ballx > 600)
{
g_balldx *= -0.9;
g_ballx = 600-(g_ballx-600);
}
else if (g_ballx < 0)
{
g_balldx *= -0.9;
g_ballx = -g_ballx;
}
if (g_bally > 400)
{
g_balldy *= -0.9;
g_bally = 400-(g_bally-400);
}
else if (g_bally < 0)
{
g_balldy *= -0.9;
g_bally = -g_bally;
}
// Gravitate towards the mouse
var vect_x = g_ballx-g_mousex;
var vect_y = g_bally-g_mousey;
var dsquared = vect_x*vect_x + vect_y*vect_y;
if (dsquared < 1000) dsquared = 1000;
var force = 10000.0 / dsquared;
var mag = Math.sqrt(dsquared);
vect_x /= mag; vect_y /= mag;
g_balldx -= force * vect_x;
g_balldy -= force * vect_y;
var ball = getGUIObjectByName('ball');
var r=5;
ball.size = new GUISize(g_ballx-r, g_bally-r, g_ballx+r, g_bally+r);
}
}
function updateOrbital()
{
if( !getGUIObjectByName( 'arena' ).hidden )
{
g_ballx += g_balldx;
g_bally += g_balldy;
if (g_ballx > 600)
{
g_balldx *= -0.9;
g_ballx = 600-(g_ballx-600);
}
else if (g_ballx < 0)
{
g_balldx *= -0.9;
g_ballx = -g_ballx;
}
if (g_bally > 400)
{
g_balldy *= -0.9;
g_bally = 400-(g_bally-400);
}
else if (g_bally < 0)
{
g_balldy *= -0.9;
g_bally = -g_bally;
}
// Gravitate towards the mouse
var vect_x = g_ballx-g_mousex;
var vect_y = g_bally-g_mousey;
var dsquared = vect_x*vect_x + vect_y*vect_y;
if (dsquared < 1000) dsquared = 1000;
var force = 10000.0 / dsquared;
var mag = Math.sqrt(dsquared);
vect_x /= mag; vect_y /= mag;
g_balldx -= force * vect_x;
g_balldy -= force * vect_y;
var ball = getGUIObjectByName('ball');
var r=5;
ball.size = new GUISize(g_ballx-r, g_bally-r, g_ballx+r, g_bally+r);
}
}
+13 -13
View File
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE objects SYSTEM "../gui.dtd">
<!--
==========================================
- TEST STUFF, MISCELLANEOUS, ARCHIVE -
==========================================
-->
<objects>
</objects>
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE objects SYSTEM "../gui.dtd">
<!--
==========================================
- TEST STUFF, MISCELLANEOUS, ARCHIVE -
==========================================
-->
<objects>
</objects>
+351 -351
View File
@@ -1,351 +1,351 @@
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE setup SYSTEM "..\gui.dtd">
<setup>
<!--
==========================================
- SETUP - SCROLLBARS
==========================================
-->
<scrollbar name="wheatScrollBar"
width="12"
minimum_bar_size="4"
alwaysshown="false"
sprite_button_top="wheatArrowUp"
sprite_button_top_over="wheatArrowUpOver"
sprite_button_top_pressed="wheatArrowUpOver"
sprite_button_bottom="wheatArrowDn"
sprite_button_bottom_over="wheatArrowDnOver"
sprite_button_bottom_pressed="wheatArrowDnOver"
sprite_back_vertical="wheatScrollSpriteBar"
sprite_bar_vertical="wheatCheckBoxOpen"
sprite_bar_vertical_over="bkWhiteBorderBlack"
sprite_bar_vertical_pressed="bkWhiteBorderBlack"
/>
<!--
==========================================
- SETUP - ICONS
==========================================
-->
<!--
==========================================
- SETUP - ICONS - GENERIC
==========================================
-->
<icon name="iconProduct"
sprite="iconProduct"
size="16 16"
/>
<icon name="iconBullet"
sprite="iconBullet"
size="8 8"
/>
<icon name="iconInfinity"
sprite="iconInfinity"
size="16 16"
/>
<!--
==========================================
- SETUP - ICONS - RESOURCE
==========================================
-->
<icon name="iconResourceFood"
sprite="snIconSheetResource"
cell_id="0"
size="30 30"
/>
<icon name="iconResourceWood"
sprite="snIconSheetResource"
cell_id="1"
size="30 30"
/>
<icon name="iconResourceStone"
sprite="snIconSheetResource"
cell_id="2"
size="30 30"
/>
<icon name="iconResourceOre"
sprite="snIconSheetResource"
cell_id="3"
size="30 30"
/>
<icon name="iconResourcePopulation"
sprite="snIconSheetResource"
cell_id="4"
size="30 30"
/>
<!--
==========================================
- SETUP - ICONS - STATISTICS
==========================================
-->
<icon name="iconGarrisonCapacity"
sprite="snIconSheetGarrison"
cell_id="0"
size="30 30"
/>
<!--
==========================================
- SETUP - TOOLTIPS
==========================================
-->
<tooltip name="pgToolTip"
use_object="pgToolTip"
delay="0"
hide_object="true"
/>
<tooltip name="pgSessionSetupToolTip"
use_object="pgSessionSetupToolTip"
delay="0"
hide_object="true"
/>
<tooltip name="pgFloatingToolTip"
anchor="top"
buffer_zone="4"
delay="500"
font="tahoma12"
maxwidth="300"
offset="16 32"
sprite="bkWhiteBorderBlack"
textcolor="0 0 0"
/>
<tooltip name="snToolTip"
anchor="top"
buffer_zone="4"
delay="500"
font="tahoma12"
maxwidth="300"
offset="16 32"
sprite="bkWhiteBorderBlack"
textcolor="0 0 0"
/>
<!--
==========================================
- SETUP - COLORS
==========================================
-->
<color name="black"
>0 0 0
</color>
<color name="gold"
>237 227 167
</color>
<color name="white"
>255 255 255
</color>
<color name="gray"
>243 242 240
</color>
<color name="darkgray"
>43 42 40
</color>
<color name="blue"
>0 0 255
</color>
<color name="green"
>0 200 0
</color>
<color name="mustard"
>191 191 2
</color>
<color name="brown"
>159 98 24
</color>
<!--
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
-->
<scrollbar name="sb"
width="18"
minimum_bar_size="5"
sprite_button_top="sprite2"
sprite_button_top_over="null"
sprite_button_bottom="sprite2"
sprite_button_bottom_over="null"
sprite_back_vertical="bkFillGray"
sprite_bar_vertical="sprite2"
sprite_bar_vertical_over="null"
sprite_bar_vertical_pressed="null"
sprite_button_bottom_pressed="sprite2_pressed"
sprite_button_top_pressed="sprite2_pressed"
/>
<scrollbar name="sb2"
width="37"
minimum_bar_size="5"
sprite_button_top="scroll"
sprite_button_top_over="null"
sprite_button_bottom="scroll"
sprite_button_bottom_over="null"
sprite_back_vertical="null"
sprite_bar_vertical="scroll_bar"
sprite_bar_vertical_over="null"
sprite_bar_vertical_pressed="null"
sprite_button_bottom_pressed="scroll"
sprite_button_top_pressed="scroll"
/>
<scrollbar name="manual_scrollbar"
width="12"
minimum_bar_size="4"
alwaysshown="false"
sprite_button_top="sprite2"
sprite_button_top_over="scroll"
sprite_button_bottom="sprite2"
sprite_button_bottom_over="scroll"
sprite_back_vertical="bkFillGray"
sprite_bar_vertical="sprite2"
sprite_bar_vertical_over="scroll"
sprite_bar_vertical_pressed="sprite2_pressed"
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"
/>
<!--
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 - ICONS - STATISTIC
==========================================
-->
<icon name="icon_statistic_garrison"
sprite="ui_icon_sheet_statistic"
cell_id="12"
size="20 20"
/>
<icon name="icon_statistic_rank1"
sprite="ui_icon_sheet_statistic"
cell_id="9"
size="20 20"
/>
<icon name="icon_statistic_rank2"
sprite="ui_icon_sheet_statistic"
cell_id="10"
size="20 20"
/>
<icon name="icon_statistic_rank3"
sprite="ui_icon_sheet_statistic"
cell_id="11"
size="20 20"
/>
<icon name="icon_statistic_hp"
sprite="ui_icon_sheet_statistic"
cell_id="13"
size="20 20"
/>
<icon name="icon_statistic_accuracy"
sprite="ui_icon_sheet_statistic"
cell_id="0"
size="20 20"
/>
<icon name="icon_statistic_armour"
sprite="ui_icon_sheet_statistic"
cell_id="2"
size="20 20"
/>
<icon name="icon_statistic_attack"
sprite="ui_icon_sheet_statistic"
cell_id="1"
size="20 20"
/>
<icon name="icon_statistic_crush"
sprite="ui_icon_sheet_statistic"
cell_id="8"
size="20 20"
/>
<icon name="icon_statistic_hack"
sprite="ui_icon_sheet_statistic"
cell_id="6"
size="20 20"
/>
<icon name="icon_statistic_los"
sprite="ui_icon_sheet_statistic"
cell_id="3"
size="20 20"
/>
<icon name="icon_statistic_pierce"
sprite="ui_icon_sheet_statistic"
cell_id="7"
size="20 20"
/>
<icon name="icon_statistic_range"
sprite="ui_icon_sheet_statistic"
cell_id="5"
size="20 20"
/>
<icon name="icon_statistic_speed"
sprite="ui_icon_sheet_statistic"
cell_id="4"
size="20 20"
/>
</setup>
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE setup SYSTEM "..\gui.dtd">
<setup>
<!--
==========================================
- SETUP - SCROLLBARS
==========================================
-->
<scrollbar name="wheatScrollBar"
width="12"
minimum_bar_size="4"
alwaysshown="false"
sprite_button_top="wheatArrowUp"
sprite_button_top_over="wheatArrowUpOver"
sprite_button_top_pressed="wheatArrowUpOver"
sprite_button_bottom="wheatArrowDn"
sprite_button_bottom_over="wheatArrowDnOver"
sprite_button_bottom_pressed="wheatArrowDnOver"
sprite_back_vertical="wheatScrollSpriteBar"
sprite_bar_vertical="wheatCheckBoxOpen"
sprite_bar_vertical_over="bkWhiteBorderBlack"
sprite_bar_vertical_pressed="bkWhiteBorderBlack"
/>
<!--
==========================================
- SETUP - ICONS
==========================================
-->
<!--
==========================================
- SETUP - ICONS - GENERIC
==========================================
-->
<icon name="iconProduct"
sprite="iconProduct"
size="16 16"
/>
<icon name="iconBullet"
sprite="iconBullet"
size="8 8"
/>
<icon name="iconInfinity"
sprite="iconInfinity"
size="16 16"
/>
<!--
==========================================
- SETUP - ICONS - RESOURCE
==========================================
-->
<icon name="iconResourceFood"
sprite="snIconSheetResource"
cell_id="0"
size="30 30"
/>
<icon name="iconResourceWood"
sprite="snIconSheetResource"
cell_id="1"
size="30 30"
/>
<icon name="iconResourceStone"
sprite="snIconSheetResource"
cell_id="2"
size="30 30"
/>
<icon name="iconResourceOre"
sprite="snIconSheetResource"
cell_id="3"
size="30 30"
/>
<icon name="iconResourcePopulation"
sprite="snIconSheetResource"
cell_id="4"
size="30 30"
/>
<!--
==========================================
- SETUP - ICONS - STATISTICS
==========================================
-->
<icon name="iconGarrisonCapacity"
sprite="snIconSheetGarrison"
cell_id="0"
size="30 30"
/>
<!--
==========================================
- SETUP - TOOLTIPS
==========================================
-->
<tooltip name="pgToolTip"
use_object="pgToolTip"
delay="0"
hide_object="true"
/>
<tooltip name="pgSessionSetupToolTip"
use_object="pgSessionSetupToolTip"
delay="0"
hide_object="true"
/>
<tooltip name="pgFloatingToolTip"
anchor="top"
buffer_zone="4"
delay="500"
font="tahoma12"
maxwidth="300"
offset="16 32"
sprite="bkWhiteBorderBlack"
textcolor="0 0 0"
/>
<tooltip name="snToolTip"
anchor="top"
buffer_zone="4"
delay="500"
font="tahoma12"
maxwidth="300"
offset="16 32"
sprite="bkWhiteBorderBlack"
textcolor="0 0 0"
/>
<!--
==========================================
- SETUP - COLORS
==========================================
-->
<color name="black"
>0 0 0
</color>
<color name="gold"
>237 227 167
</color>
<color name="white"
>255 255 255
</color>
<color name="gray"
>243 242 240
</color>
<color name="darkgray"
>43 42 40
</color>
<color name="blue"
>0 0 255
</color>
<color name="green"
>0 200 0
</color>
<color name="mustard"
>191 191 2
</color>
<color name="brown"
>159 98 24
</color>
<!--
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
-->
<scrollbar name="sb"
width="18"
minimum_bar_size="5"
sprite_button_top="sprite2"
sprite_button_top_over="null"
sprite_button_bottom="sprite2"
sprite_button_bottom_over="null"
sprite_back_vertical="bkFillGray"
sprite_bar_vertical="sprite2"
sprite_bar_vertical_over="null"
sprite_bar_vertical_pressed="null"
sprite_button_bottom_pressed="sprite2_pressed"
sprite_button_top_pressed="sprite2_pressed"
/>
<scrollbar name="sb2"
width="37"
minimum_bar_size="5"
sprite_button_top="scroll"
sprite_button_top_over="null"
sprite_button_bottom="scroll"
sprite_button_bottom_over="null"
sprite_back_vertical="null"
sprite_bar_vertical="scroll_bar"
sprite_bar_vertical_over="null"
sprite_bar_vertical_pressed="null"
sprite_button_bottom_pressed="scroll"
sprite_button_top_pressed="scroll"
/>
<scrollbar name="manual_scrollbar"
width="12"
minimum_bar_size="4"
alwaysshown="false"
sprite_button_top="sprite2"
sprite_button_top_over="scroll"
sprite_button_bottom="sprite2"
sprite_button_bottom_over="scroll"
sprite_back_vertical="bkFillGray"
sprite_bar_vertical="sprite2"
sprite_bar_vertical_over="scroll"
sprite_bar_vertical_pressed="sprite2_pressed"
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"
/>
<!--
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 - ICONS - STATISTIC
==========================================
-->
<icon name="icon_statistic_garrison"
sprite="ui_icon_sheet_statistic"
cell_id="12"
size="20 20"
/>
<icon name="icon_statistic_rank1"
sprite="ui_icon_sheet_statistic"
cell_id="9"
size="20 20"
/>
<icon name="icon_statistic_rank2"
sprite="ui_icon_sheet_statistic"
cell_id="10"
size="20 20"
/>
<icon name="icon_statistic_rank3"
sprite="ui_icon_sheet_statistic"
cell_id="11"
size="20 20"
/>
<icon name="icon_statistic_hp"
sprite="ui_icon_sheet_statistic"
cell_id="13"
size="20 20"
/>
<icon name="icon_statistic_accuracy"
sprite="ui_icon_sheet_statistic"
cell_id="0"
size="20 20"
/>
<icon name="icon_statistic_armour"
sprite="ui_icon_sheet_statistic"
cell_id="2"
size="20 20"
/>
<icon name="icon_statistic_attack"
sprite="ui_icon_sheet_statistic"
cell_id="1"
size="20 20"
/>
<icon name="icon_statistic_crush"
sprite="ui_icon_sheet_statistic"
cell_id="8"
size="20 20"
/>
<icon name="icon_statistic_hack"
sprite="ui_icon_sheet_statistic"
cell_id="6"
size="20 20"
/>
<icon name="icon_statistic_los"
sprite="ui_icon_sheet_statistic"
cell_id="3"
size="20 20"
/>
<icon name="icon_statistic_pierce"
sprite="ui_icon_sheet_statistic"
cell_id="7"
size="20 20"
/>
<icon name="icon_statistic_range"
sprite="ui_icon_sheet_statistic"
cell_id="5"
size="20 20"
/>
<icon name="icon_statistic_speed"
sprite="ui_icon_sheet_statistic"
cell_id="4"
size="20 20"
/>
</setup>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff