1
0
forked from 0ad/0ad

Initial IP Hosting and map selection screens from Malte. Committed on his behalf as he's having problems with his authorisation.

This was SVN commit r1555.
This commit is contained in:
Acumen 2004-12-23 17:22:22 +00:00
parent 0382cdd9b1
commit 47842863c4
4 changed files with 355 additions and 183 deletions

View File

@ -22,7 +22,8 @@
<object type="button" name="pregame-mainmenu-sp-button" sprite-over="pregame-mainmenu-spbt" size="52.9296875% 23.95833333% 67.578125% 42.317708333%" z="101" hidden="false"
tooltip-style="pregame-mainmenu-tooltip" tooltip="Want to move some Dudes around or test something ? Click here to start a new game on the default map.">
<action on="Press"><![CDATA[
startLoadingScreen();
GUIObjectUnhide("pregame_subwindow_bkg");
GUIObjectUnhide("pregame_sp_mapsel");
]]></action>
</object>
@ -30,11 +31,10 @@
tooltip-style="pregame-mainmenu-tooltip" tooltip="Tired of playing with yourself? Fight against one or more human players in a multiplayer game.">
<action on="Press"><![CDATA[
getGUIObjectByName("pregame_subwindow_bkg").hidden = false;
getGUIObjectByName("pregame_ip_host").hidden = false;
getGUIObjectByName("pregame_mp_ip").hidden = false;
]]></action>
</object>
<object type="button" name="pregame-mainmenu-ed-button" sprite-over="pregame-mainmenu-edbt" size="44.00% 61.50% 62.45% 83.55%" z="101" hidden="false"
tooltip-style="pregame-mainmenu-tooltip" tooltip="Come forth and witness a totally non-functioning Editor, a mere shadow of its potential self!">
<action on="Press"><![CDATA[
@ -74,13 +74,19 @@
<object type="empty" name="pregame_subwindows" size="0 0 100% 100%" z="1" hidden="false">
<object type="image" name="pregame_subwindow_bkg" sprite="tooltip-background" size="0 0 100% 100%" z="105" hidden="true"/>
<object type="image" name="pregame_subwindow_bkg" sprite="pregame-mainmenu-tooltip-background" size="0 0 100% 100%" z="105" hidden="true"/>
<object type="button" name="pregame_ip_host" sprite="0ad_window" z="106" hidden="true">
<action on="Load"><![CDATA[
getGUIObjectByName("pregame_ip_host").caption = "Mary had a little lamb; her fleece was white as snow (the lamb's fleece; that is. Not Mary's. It'd be pretty silly if Mary had a fleece. Though I guess it's possible. I mean in this modern avant-garde world of ours, who am I to say that Mary doesn't come with a fleece at no additional cost? Ah, forget it.)";
setSizeCoord("pregame_ip_host", crd_pregame_iphost_bkg_x, crd_pregame_iphost_bkg_y, crd_pregame_iphost_bkg_x+crd_pregame_iphost_bkg_width, crd_pregame_iphost_bkg_y+crd_pregame_iphost_bkg_height, mid_screen, mid_screen, mid_screen, mid_screen);
]]></action>
<object type="button" name="pregame_mp_ip" sprite="0ad_window" z="106" hidden="true">
<action on="Load"><![CDATA[
setSizeCoord("pregame_mp_ip", crd_pregame_iphost_bkg_x, crd_pregame_iphost_bkg_y, crd_pregame_iphost_bkg_x+crd_pregame_iphost_bkg_width, crd_pregame_iphost_bkg_y+crd_pregame_iphost_bkg_height, mid_screen, mid_screen, mid_screen, mid_screen);
]]></action>
<object type="button" name="pregame_ip_host_titlebar" sprite="0ad_window_title" font="prospero18" z="165" text-align="center" text-valign="center">
<action on="Load"><![CDATA[
getGUIObjectByName("pregame_ip_host_titlebar").caption = "Direct IP Connect";
setSizeCoord("pregame_ip_host_titlebar", crd_pregame_iphost_titlebar_x, crd_pregame_iphost_titlebar_y, crd_pregame_iphost_titlebar_x+crd_pregame_iphost_titlebar_width, crd_pregame_iphost_titlebar_y+crd_pregame_iphost_titlebar_height, mid_screen, mid_screen, mid_screen, mid_screen);
]]></action>
</object>
<object type="button" name="pregame_ip_host_exit_button" sprite="exit_sprite" sprite-over="exit_sprite-over">
<action on="Load"><![CDATA[
@ -88,18 +94,138 @@
]]></action>
<action on="Press"><![CDATA[
getGUIObjectByName("pregame_subwindow_bkg").hidden = true;
getGUIObjectByName("pregame_ip_host").hidden = true;
getGUIObjectByName("pregame_mp_ip").hidden = true;
]]></action>
</object>
<object type="button" name="pregame_ip_host_titlebar" sprite="0ad_window_title" font="prospero18" z="165" text-align="center" text-valign="center">
<object type="text" name="pregame_ip_infotext">
<action on="Load"><![CDATA[
getGUIObjectByName("pregame_ip_host_titlebar").caption = "Direct IP Connect";
setSizeCoord("pregame_ip_host_titlebar", crd_pregame_iphost_titlebar_x, crd_pregame_iphost_titlebar_y, crd_pregame_iphost_titlebar_x+crd_pregame_iphost_titlebar_width, crd_pregame_iphost_titlebar_y+crd_pregame_iphost_titlebar_height, mid_screen, mid_screen, mid_screen, mid_screen);
getGUIObjectByName("pregame_ip_infotext").caption = "You can start a multiplayer game by Direct-IP connect from here. Either \n- enter a map name and click 'Host Game' to host a game or \n- enter an IP and click 'Join Game' to join a game on the IP entered.";
setSizeCoord("pregame_ip_infotext", crd_pregame_iphost_bkg_x, crd_pregame_iphost_bkg_y, crd_pregame_iphost_bkg_x+crd_pregame_iphost_bkg_width, crd_pregame_iphost_bkg_y+crd_pregame_iphost_bkg_height, mid_screen, mid_screen, mid_screen, mid_screen);
]]></action>
</object>
</object>
</object>
<object type="image" name="pregame_mp_ip_divider1" sprite="only-black-border">
<action on="Load"><![CDATA[
setSizeCoord("pregame_mp_ip_divider1", -230, -130, 230, -130, mid_screen, mid_screen, mid_screen, mid_screen);
]]></action>
</object>
<!-- PLAYER NAME controls -->
<object type="text" name="pregame_mp_ip_playername_txt" absolute="false" size="45 80 200 100" textcolor="0 0 0">
Player Name (temporary):
</object>
<object type="input" name="pregame_mp_ip_playername" sprite="only-black" absolute="false" size="220 80 350 100" textcolor="0 0 0">
Player
</object>
<!-- END PLAYER NAME controls -->
<!-- HOST GAME controls -->
<object type="image" name="pregame_mp_ip_divider2" sprite="only-black-border">
<action on="Load"><![CDATA[
setSizeCoord("pregame_mp_ip_divider2", -230, -75, 230, -75, mid_screen, mid_screen, mid_screen, mid_screen);
]]></action>
</object>
<object type="text" name="pregame_mp_ip_mapname_txt" absolute="false" size="45 130 200 150" textcolor="0 0 0">
Map Name:
</object>
<object type="input" name="pregame_mp_ip_host_mapname" sprite="only-black" absolute="false" size="50 150 200 170" textcolor="0 0 0">
test01
</object>
<object type="button" name="pregame_mp_ip_host_bt" sprite="message_box-button-normal" sprite-over="message_box-button-over" text-align="center" text-valign="center">
Host Game
<action on="Load"><![CDATA[
setSizeCoord("pregame_mp_ip_host_bt", 50, -60, 150, -30, mid_screen, mid_screen, mid_screen, mid_screen);
]]></action>
<action on="Press"><![CDATA[
initMPSessionHost(getGUIObjectByName("pregame_mp_ip_playername").caption, getGUIObjectByName("pregame_mp_ip_host_mapname").caption);
]]></action>
</object>
<!-- END HOST GAME controls -->
<!-- JOIN GAME controls -->
<object type="image" name="pregame_mp_ip_divider3" sprite="only-black-border">
<action on="Load"><![CDATA[
setSizeCoord("pregame_mp_ip_divider3", -230, -20, 230, -20, mid_screen, mid_screen, mid_screen, mid_screen);
]]></action>
</object>
<object type="text" name="pregame_mp_ip_joinip_txt" absolute="false" size="45 190 200 210" textcolor="0 0 0">
IP address:
</object>
<object type="input" name="pregame_mp_ip_joinip" sprite="only-black" absolute="false" size="50 210 200 230" textcolor="0 0 0">
127.0.0.1
</object>
<object type="button" name="pregame_mp_ip_join_bt" sprite="message_box-button-normal" sprite-over="message_box-button-over" text-align="center" text-valign="center">
Join Game
<action on="Load"><![CDATA[
setSizeCoord("pregame_mp_ip_join_bt", 50, 0, 150, 30, mid_screen, mid_screen, mid_screen, mid_screen);
]]></action>
<action on="Press"><![CDATA[
initMPSessionClient(getGUIObjectByName("pregame_mp_ip_playername").caption, getGUIObjectByName("pregame_mp_ip_joinip").caption);
]]></action>
</object>
<!-- END JOIN GAME controls -->
</object>
<!-- SINGLEPLAYER TEMPORARY MAP SELECTION DIALOG -->
<object type="button" name="pregame_sp_mapsel" sprite="0ad_window" z="106" hidden="true" size="50%-150 50%-90 50%+150 50%+90">
<!-- The placement of this titlebar object is VERY hackish (see y-placement), but it doesn't work any other way so far, and this dialog will be temporary anyway -->
<object type="button" name="pregame_sp_mapsel_titlebar" sprite="0ad_window_title" font="prospero18" z="165" text-align="center" text-valign="center" absolute="false" size="50%-130 0%-22 50%+130 0%-14">
Map selection
</object>
<object type="text" name="pregame_sp_infotext" absolute="false" size="10 10 290 60">
Type the name of the map you want to start the game at into the box. The name is realtive to /data/mods/official/maps/scenarios/.
</object>
<object type="text" name="pregame_sp_mapname_txt" absolute="false" textcolor="0 0 0" size="10 90 120 110">
Map Name:
</object>
<object type="input" name="pregame_sp_mapname" sprite="only-black" absolute="false" size="130 90 290 110" textcolor="0 0 0">
test01.pmp
</object>
<object type="button" name="pregame_sp_start_bt" sprite="message_box-button-normal" sprite-over="message_box-button-over" text-align="center" text-valign="center" absolute="false" size="50%-100 100%-50 50%-10 100%-20">
Start Game
<action on="Press"><![CDATA[
// Check wheter we have a correct file extension, to avoid crashes
var mapName = getGUIObjectByName("pregame_sp_mapname").caption;
var extension = mapName.substring(mapName.length, mapName.length-4);
if(extension != ".pmp") {
// Add .pmp to the file name - shouldn't help if the name is mistyped, but may be useful in some cases
mapName = mapName + ".pmp";
console.write("Trying to fix the map name (probably missing extension).");
}
// Set up game
GUIObjectHide("pregame_subwindow_bkg");
GUIObjectHide("pregame_sp_mapsel");
g_GameAttributes.mapFile = mapName;
startLoadingScreen();
]]></action>
</object>
<object type="button" name="pregame_sp_mapsel_abort_button" sprite="message_box-button-normal" sprite-over="message_box-button-over" text-align="center" text-valign="center" absolute="false" size="50%+10 100%-50 50%+90 100%-20">
Abort
<action on="Press"><![CDATA[
GUIObjectHide("pregame_subwindow_bkg");
GUIObjectHide("pregame_sp_mapsel");
]]></action>
</object>
</object>
</object>
</objects>

View File

@ -5,30 +5,72 @@
function initPreGame()
{
initIPHost();
initIPHost();
}
// ====================================================================
function initIPHost()
{
// IP Host Window background.
crd_pregame_iphost_bkg_x = -350;
crd_pregame_iphost_bkg_y = -200;
crd_pregame_iphost_bkg_width = (crd_pregame_iphost_bkg_x * -1) * 2;
crd_pregame_iphost_bkg_height = (crd_pregame_iphost_bkg_y * -1) * 2;
// IP Host Window background.
crd_pregame_iphost_bkg_x = -250;
crd_pregame_iphost_bkg_y = -200;
crd_pregame_iphost_bkg_width = (crd_pregame_iphost_bkg_x * -1) * 2;
crd_pregame_iphost_bkg_height = (crd_pregame_iphost_bkg_y * -1) * 2;
// IP Host Window exit button.
crd_pregame_iphost_exit_button_width = 16;
crd_pregame_iphost_exit_button_height = crd_pregame_iphost_exit_button_width;
crd_pregame_iphost_exit_button_x = crd_pregame_iphost_bkg_x+crd_pregame_iphost_bkg_width+10;
crd_pregame_iphost_exit_button_y = crd_pregame_iphost_bkg_y-25;
// IP Host Window exit button.
crd_pregame_iphost_exit_button_width = 16;
crd_pregame_iphost_exit_button_height = crd_pregame_iphost_exit_button_width;
crd_pregame_iphost_exit_button_x = crd_pregame_iphost_bkg_x+crd_pregame_iphost_bkg_width+10;
crd_pregame_iphost_exit_button_y = crd_pregame_iphost_bkg_y-25;
// IP Host Window titlebar.
crd_pregame_iphost_titlebar_width = crd_pregame_iphost_bkg_width;
crd_pregame_iphost_titlebar_height = 16;
crd_pregame_iphost_titlebar_x = crd_pregame_iphost_bkg_x;
crd_pregame_iphost_titlebar_y = crd_pregame_iphost_bkg_y-25;
// IP Host Window titlebar.
crd_pregame_iphost_titlebar_width = crd_pregame_iphost_bkg_width;
crd_pregame_iphost_titlebar_height = 16;
crd_pregame_iphost_titlebar_x = crd_pregame_iphost_bkg_x;
crd_pregame_iphost_titlebar_y = crd_pregame_iphost_bkg_y-25;
}
// ====================================================================
// ====================================================================
function initMPSessionHost(playerName, mapName)
{
// Code here
var success = startServer(80);
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());
}
GUIObjectHide("pregame_mp_ip");
GUIObjectHide("pregame_subwindow_bkg");
// Need "waiting for more players to join and start game" code here
/*btCaptions = new Array("OK");
btCode = new Array("");
messageBox(400, 200, "Data: " + playerName + ";" + mapName + ";", "Test", 0, btCaptions, btCode);*/
}
// ====================================================================
function initMPSessionClient(playerName, serverIP)
{
// Join MP game
var success = joinGame(playerName, serverIP);
if(!success) {
messageBox(400, 200, "Failed to join game. Please review the logfile for more information on the problem.", 2, new Array(), new Array());
}
GUIObjectHide("pregame_mp_ip");
GUIObjectHide("pregame_subwindow_bkg");
// Need "waiting for game to start" code here - it should automatically start if the client recieves the start signal from the server,
// but I currently don't know how that could be done.
/*btCaptions = new Array("OK");
btCode = new Array("");
messageBox(400, 200, "Data: " + playerName + ";" + serverIP + ";", "Test", 0, btCaptions, btCode);*/
}
// ====================================================================

View File

@ -1,218 +1,218 @@
function initSession()
{
initGroupPane();
initResourcePool();
initStatusOrb();
initMapOrb();
initTeamTray();
initSubWindows();
initGroupPane();
initResourcePool();
initStatusOrb();
initMapOrb();
initTeamTray();
initSubWindows();
}
// ====================================================================
function initCellReference()
{
// Define cell reference constants for icon sheets.
// Define cell reference constants for icon sheets.
// icon_sheet_statistic
stat_accuracy = 0;
stat_attack = 1;
stat_armour = 2;
stat_los = 3;
stat_speed = 4;
stat_range = 5;
stat_hack = 6;
stat_pierce = 7;
stat_crush = 8;
stat_rank1 = 9;
stat_rank2 = 10;
stat_rank3 = 11;
stat_garrison = 12;
stat_heart = 13;
// icon_sheet_statistic
stat_accuracy = 0;
stat_attack = 1;
stat_armour = 2;
stat_los = 3;
stat_speed = 4;
stat_range = 5;
stat_hack = 6;
stat_pierce = 7;
stat_crush = 8;
stat_rank1 = 9;
stat_rank2 = 10;
stat_rank3 = 11;
stat_garrison = 12;
stat_heart = 13;
// portrait_sheet_action
// generic actions
action_empty = 0;
action_attack = 1;
action_patrol = 2;
action_stop = 3;
action_gather_food = 4;
action_gather_wood = 5;
action_gather_stone = 6;
action_gather_ore = 7;
action_rally = 8;
action_repair = 9;
action_heal = 10;
action_scout = 11;
action_townbell = 12;
action_lock = 13;
action_unlock = 14;
// formation actions
action_formation_box = 23;
action_formation_column_c = 24;
action_formation_column_o = 25;
action_formation_line_c = 26;
action_formation_line_o = 27;
action_formation_phalanx = 28;
action_formation_skirmish = 29;
action_formation_testudo = 30;
action_formation_wedge = 31;
// stance actions
action_stance_aggress = 39;
action_stance_avoid = 40;
action_stance_defend = 41;
action_stance_hold = 42;
action_stance_stand = 43;
// tab actions
action_tab_command = 48;
action_tab_train = 49;
action_tab_buildciv = 50;
action_tab_buildmil = 51;
action_tab_research = 52;
action_tab_formation = 53;
action_tab_stance = 54;
action_tab_barter = 55;
// portrait_sheet_action
// generic actions
action_empty = 0;
action_attack = 1;
action_patrol = 2;
action_stop = 3;
action_gather_food = 4;
action_gather_wood = 5;
action_gather_stone = 6;
action_gather_ore = 7;
action_rally = 8;
action_repair = 9;
action_heal = 10;
action_scout = 11;
action_townbell = 12;
action_lock = 13;
action_unlock = 14;
// formation actions
action_formation_box = 23;
action_formation_column_c = 24;
action_formation_column_o = 25;
action_formation_line_c = 26;
action_formation_line_o = 27;
action_formation_phalanx = 28;
action_formation_skirmish = 29;
action_formation_testudo = 30;
action_formation_wedge = 31;
// stance actions
action_stance_aggress = 39;
action_stance_avoid = 40;
action_stance_defend = 41;
action_stance_hold = 42;
action_stance_stand = 43;
// tab actions
action_tab_command = 48;
action_tab_train = 49;
action_tab_buildciv = 50;
action_tab_buildmil = 51;
action_tab_research = 52;
action_tab_formation = 53;
action_tab_stance = 54;
action_tab_barter = 55;
}
// ====================================================================
function startLoadingScreen()
{
// Setup loading screen.
// Setup loading screen.
// Switch screens from main menu to loading screen.
GUIObjectHide("pregame_gui");
GUIObjectUnhide("loading_screen");
console.write("Loading " + g_GameAttributes.mapFile + " (" + g_GameAttributes.numPlayers + " players) ...");
// Switch screens from main menu to loading screen.
GUIObjectHide("pregame_gui");
GUIObjectUnhide("loading_screen");
console.write("Loading " + g_GameAttributes.mapFile + " (" + g_GameAttributes.numPlayers + " players) ...");
getGUIObjectByName("loading_screen_titlebar-text").caption = "Loading Scenario ...";
getGUIObjectByName("loading_screen_progress_bar_text").caption = "... Reticulating splines ...";
getGUIObjectByName("loading_screen_progress_bar").caption = 80;
getGUIObjectByName("loading_screen_text").caption = "LOADING " + g_GameAttributes.mapFile + " ...\nPlease wait ...\n(Yes, we know the progress bar doesn't do diddly squat right now)\nJust keep waiting ...\nIt'll get there ...\nAlmost done ...\nTrust me!";
getGUIObjectByName("loading_screen_tip").caption = "Wise man once say ...\nHe who thinks slow, he act in haste, be rash and quick and foolish. But he that thinks too much, acts too slowly. The stupid always win, Commandersan. Remember that. You are tiny grasshopper.";
getGUIObjectByName("loading_screen_titlebar-text").caption = "Loading Scenario ...";
getGUIObjectByName("loading_screen_progress_bar_text").caption = "... Reticulating splines ...";
getGUIObjectByName("loading_screen_progress_bar").caption = 80;
getGUIObjectByName("loading_screen_text").caption = "LOADING " + g_GameAttributes.mapFile + " ...\nPlease wait ...\n(Yes, we know the progress bar doesn't do diddly squat right now)\nJust keep waiting ...\nIt'll get there ...\nAlmost done ...\nTrust me!";
getGUIObjectByName("loading_screen_tip").caption = "Wise man once say ...\nHe who thinks slow, he act in haste, be rash and quick and foolish. But he that thinks too much, acts too slowly. The stupid always win, Commandersan. Remember that. You are tiny grasshopper.";
// Begin game session.
setTimeout( loadSession, 5 );
// Begin game session.
setTimeout( loadSession, 10 );
}
// ====================================================================
function loadSession()
{
startGame();
GUIObjectHide("loading_screen");
GUIObjectUnhide("session_gui");
FlipGUI(GUIType);
startGame();
GUIObjectHide("loading_screen");
GUIObjectUnhide("session_gui");
FlipGUI(GUIType);
// 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, 0.0001);
// 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, 0.0001);
}
// ====================================================================
function setPortrait(objectName, portraitString, portraitCell)
{
// Use this function as a shortcut to change a portrait object to a different portrait image.
// 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 (grey) sprites.
// Sprite Format: "ui_portrait_"portraitString
// Sprite Format: "ui_portrait_"portraitString"-lit"
// Sprite Format: "ui_portrait_"portraitString"-grey"
// Note: Make sure the file follows this naming convention or bad things could happen.
// Accepts an object and specifies its default, rollover (lit) and disabled (grey) sprites.
// Sprite Format: "ui_portrait_"portraitString
// Sprite Format: "ui_portrait_"portraitString"-lit"
// Sprite Format: "ui_portrait_"portraitString"-grey"
// Note: Make sure the file follows this naming convention or bad things could happen.
// Get GUI object
GUIObject = getGUIObjectByName(objectName);
// Set the three portraits.
GUIObject.sprite = "ui_portrait_" + portraitString;
// Note we need to use a special syntax here (object["param"] instead of object.param because dashes aren't actually in JS's variable-naming conventions.
GUIObject["sprite-over"] = GUIObject.sprite + "-lit";
GUIObject["sprite-disabled"] = GUIObject.sprite + "-grey";
// Set the three portraits.
GUIObject.sprite = "ui_portrait_" + portraitString;
// Note we need to use a special syntax here (object["param"] instead of object.param because dashes aren't actually in JS's variable-naming conventions.
GUIObject["sprite-over"] = GUIObject.sprite + "-lit";
GUIObject["sprite-disabled"] = GUIObject.sprite + "-grey";
// If the source texture is a multi-frame image (icon sheet), specify correct cell.
if (portraitCell)
GUIObject["cell-id"] = portraitCell;
// If the source texture is a multi-frame image (icon sheet), specify correct cell.
if (portraitCell)
GUIObject["cell-id"] = portraitCell;
}
// ====================================================================
function getObjectInfo()
{
// Updated each tick to extract entity information from selected unit(s).
// Updated each tick to extract entity information from selected unit(s).
// Don't process GUI when we're full-screen.
if (GUIType != "none")
{
if (!selection.length) // If no entity selected,
{
// Hide Status Orb
getGUIObjectByName("session_status_orb").hidden = true;
// Don't process GUI when we're full-screen.
if (GUIType != "none")
{
if (!selection.length) // If no entity selected,
{
// Hide Status Orb
getGUIObjectByName("session_status_orb").hidden = true;
// Hide Group Pane.
getGUIObjectByName("session_group_pane").hidden = true;
// Hide Group Pane.
getGUIObjectByName("session_group_pane").hidden = true;
getGlobal().MultipleEntitiesSelected = 0;
}
else // If at least one entity selected,
{
// Store globals for entity information.
// strString = "" + selection[0].position;
// EntityPos = strString.substring(20,strString.length-3);
getGlobal().MultipleEntitiesSelected = 0;
}
else // If at least one entity selected,
{
// Store globals for entity information.
// strString = "" + selection[0].position;
// EntityPos = strString.substring(20,strString.length-3);
UpdateStatusOrb(); // (later, we need to base this on the selected unit's stats changing)
UpdateStatusOrb(); // (later, we need to base this on the selected unit's stats changing)
// Check if a group of entities selected
if (selection.length > 1)
{
// If a group pane isn't already open, and we don't have the same set as last time,
// NOTE: This "if" is an optimisation because the game crawls if this set of processing occurs every frame.
// It's quite possible for the player to select another group of the same size and for it to not be recognised.
// Best solution would be to base this off a "new entities selected" instead of an on-tick.
if (
// getGUIObjectByName("session_group_pane").hidden == true ||
selection.length != getGlobal().MultipleEntitiesSelected)
{
UpdateGroupPane(); // (later, we need to base this on the selection changing)
getGlobal().MultipleEntitiesSelected = selection.length;
}
}
else
{
getGlobal().MultipleEntitiesSelected = 0;
// Check if a group of entities selected
if (selection.length > 1)
{
// If a group pane isn't already open, and we don't have the same set as last time,
// NOTE: This "if" is an optimisation because the game crawls if this set of processing occurs every frame.
// It's quite possible for the player to select another group of the same size and for it to not be recognised.
// Best solution would be to base this off a "new entities selected" instead of an on-tick.
if (
// getGUIObjectByName("session_group_pane").hidden == true ||
selection.length != getGlobal().MultipleEntitiesSelected)
{
UpdateGroupPane(); // (later, we need to base this on the selection changing)
getGlobal().MultipleEntitiesSelected = selection.length;
}
}
else
{
getGlobal().MultipleEntitiesSelected = 0;
// Hide Group Pane.
getGUIObjectByName("session_group_pane").hidden = true;
}
}
// Hide Group Pane.
getGUIObjectByName("session_group_pane").hidden = true;
}
}
// Modify any resources given/taken (later, we need to base this on a resource-changing event).
UpdateResourcePool();
// Modify any resources given/taken (later, we need to base this on a resource-changing event).
UpdateResourcePool();
// Update Team Tray (later, we need to base this on the player creating a group).
UpdateTeamTray();
}
// Update Team Tray (later, we need to base this on the player creating a group).
UpdateTeamTray();
}
}
// ====================================================================
function MakeUnit(x, y, z, MakeUnitName)
{
// Spawn an entity at the given coordinates.
// Spawn an entity at the given coordinates.
DudeSpawnPoint = new Vector3D(x, y, z);
new Entity(getEntityTemplate(MakeUnitName), DudeSpawnPoint, 1.0);
// writeConsole(MakeUnitName + " created at " + DudeSpawnPoint);
DudeSpawnPoint = new Vector3D(x, y, z);
new Entity(getEntityTemplate(MakeUnitName), DudeSpawnPoint, 1.0);
// writeConsole(MakeUnitName + " created at " + DudeSpawnPoint);
}
// ====================================================================
function selected()
{
// Returns how many units selected.
// Returns how many units selected.
if( selection.length > 0 )
return( selection[0] );
return( null );
if( selection.length > 0 )
return( selection[0] );
return( null );
}

View File

@ -159,6 +159,10 @@
<image backcolor="0 0 0" size="100% 0 100%+1 100%" />
</sprite>
<sprite name="only-black">
<image backcolor="0 0 0" size="0 0 100% 100%" />
</sprite>
<!-- Standard 0 A.D.-style framed window -->
<sprite name="0ad_window">
<!-- middle -->