1
0
forked from 0ad/0ad

Updated the MP screen, connecting and chatting now work. Starting a game doesn't work, due to startGame() somehow being non-functional in MP mode.

This was SVN commit r1876.
This commit is contained in:
Fire Giant 2005-01-30 14:40:25 +00:00
parent 462369a244
commit 3760b15b51
4 changed files with 444 additions and 424 deletions

View File

@ -1,233 +1,243 @@
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE objects SYSTEM "../gui.dtd">
<objects>
<!--
==========================================
- MAIN MENU -
==========================================
-->
<object type="empty" name="PREGAME_GUI" size="0 0 100% 100%" z="1" hidden="false">
<action on="Load"><![CDATA[
// Play main 0 A.D. theme when the main menu starts.
curr_music = newRandomSound("music", "theme");
curr_music.loop();
]]></action>
<object type="image" name="pregame_mainmenu_background_image" sprite="pregame_mainmenu_background" size="0 0 100% 100%" z="100" hidden="false" ghost="true"/>
<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[
GUIObjectUnhide("pregame_subwindow_bkg");
GUIObjectUnhide("pregame_sp_mapsel");
]]></action>
</object>
<object type="button" name="pregame_mainmenu_mp_button" sprite_over="pregame_mainmenu_mpbt" size="60.9375% 48.567708333% 74.21875% 66.53645833333%" z="101" hidden="false"
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_mp_ip").hidden = false;
]]></action>
</object>
<object type="button" name="pregame_mainmenu_ed_button" sprite_over="pregame_mainmenu_edbt" size="43.65234375% 61.71875% 63.57421875% 82.8125%" 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[
GUIObjectHide("PREGAME_GUI");
GUIObjectUnhide("ATLAS_GUI");
]]></action>
</object>
<object type="image" name="pregame_mainmenu_0ad_logo" sprite="pregame_mainmenu_0ad_logo_480x218" size="21.1914062% 3.125% 68.0664062% 31.5104166%" z="102" hidden="false" ghost="true"/>
<object type="text" name="pregame_mainmenu_versionnumber" size="43% 24% 43%+282 24%+25" z="103" textcolor="237 227 167" font="prospero16" hidden="false" ghost="true">
{buildTime}
<action on="Load"><![CDATA[
this.caption = "Build: " + buildTime(0) + " " + getLanguageID();
]]></action>
</object>
<object type="button" name="pregame_mainmenu_wfg_logo" sprite="pregame_mainmenu_wfg_logo_256x64" size="10 91.666666%-30 25.9765% 100%-30" z="102" hidden="false"
tooltip_style="pregame_mainmenu_tooltip" tooltip="These are the guys who made this game. Visit them at http://www.wildfiregames.com/0ad/">
<action on="Press"><![CDATA[
btCode = new Array("GUIObjectHide('mb_main');");
messageBox(420, 420, "[icon=0ad_icon] A.D. - History Is Yours For The Taking\nby Wildfire Games, 2002-2005\n\nVersion 0.1.2 (PASAP II)\n\n" +
"This is a confidental pre-release version of the game!\n\nVisit http://www.wildfiregames.com/0ad/ " +
"to learn more about [icon=0ad_icon] A.D., participate in the community and meet the developers.\n\n", "About [icon=0ad_icon] A.D.", 2, new Array(), btCode);
]]></action>
</object>
<object type="text" name="pregame_mainmenu_tooltip" sprite="pregame_mainmenu_tooltip_background" size="69% 6.3802% 97.0703125% 28.125%" font="prospero16" textcolor="255 255 255" z="104" hidden="true" ghost="true">tooltipText</object>
<object type="button" name="exit_button" sprite="exit_sprite" sprite_over="exit_sprite_over" size="100%-18 2 100%-2 18" z="104" hidden="false"
tooltip_style="pregame_mainmenu_tooltip" tooltip="Tired of 0 A.D. ? Click here to leave and reenter the real world.">
<action on="Press"><![CDATA[
btCaptions = new Array("Yes, let me out!", "Nooooo!");
btCode = new Array("exit();", "");
messageBox(400, 200, "Do you really want to quit [icon=0ad_icon] A.D.? This will cause a sudden return to reality.", "Confirmation", 0, btCaptions, btCode);
]]></action>
</object>
</object>
<object type="empty" name="pregame_subwindows" size="0 0 100% 100%" z="1" hidden="false">
<object type="image" name="pregame_subwindow_bkg" sprite="translucent_background" size="0 0 100% 100%" z="105" hidden="true"/>
<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[
setSizeCoord("pregame_ip_host_exit_button", crd_pregame_iphost_exit_button_x, crd_pregame_iphost_exit_button_y, crd_pregame_iphost_exit_button_x+crd_pregame_iphost_exit_button_width, crd_pregame_iphost_exit_button_y+crd_pregame_iphost_exit_button_height, mid_screen, mid_screen, mid_screen, mid_screen);
]]></action>
<action on="Press"><![CDATA[
getGUIObjectByName("pregame_subwindow_bkg").hidden = true;
getGUIObjectByName("pregame_mp_ip").hidden = true;
]]></action>
</object>
<object type="text" name="pregame_ip_infotext">
<action on="Load"><![CDATA[
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 entered IP.";
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 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="255 255 255">
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="255 255 255">
test01.pmp
</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="255 255 255">
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 into the box. The name is relative 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="255 255 255">
ph2
</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>
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE objects SYSTEM "../gui.dtd">
<objects>
<!--
==========================================
- MAIN MENU -
==========================================
-->
<object type="empty" name="PREGAME_GUI" size="0 0 100% 100%" z="1" hidden="false">
<action on="Load"><![CDATA[
// Play main 0 A.D. theme when the main menu starts.
curr_music = newRandomSound("music", "theme");
curr_music.loop();
]]></action>
<object type="image" name="pregame_mainmenu_background_image" sprite="pregame_mainmenu_background" size="0 0 100% 100%" z="100" hidden="false" ghost="true"/>
<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[
GUIObjectUnhide("pregame_subwindow_bkg");
GUIObjectUnhide("pregame_sp_mapsel");
]]></action>
</object>
<object type="button" name="pregame_mainmenu_mp_button" sprite_over="pregame_mainmenu_mpbt" size="60.9375% 48.567708333% 74.21875% 66.53645833333%" z="101" hidden="false"
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_mp_ip").hidden = false;
]]></action>
</object>
<object type="button" name="pregame_mainmenu_ed_button" sprite_over="pregame_mainmenu_edbt" size="43.65234375% 61.71875% 63.57421875% 82.8125%" 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[
GUIObjectHide("PREGAME_GUI");
GUIObjectUnhide("ATLAS_GUI");
]]></action>
</object>
<object type="image" name="pregame_mainmenu_0ad_logo" sprite="pregame_mainmenu_0ad_logo_480x218" size="21.1914062% 3.125% 68.0664062% 31.5104166%" z="102" hidden="false" ghost="true"/>
<object type="text" name="pregame_mainmenu_versionnumber" size="43% 24% 43%+282 24%+25" z="103" textcolor="237 227 167" font="prospero16" hidden="false" ghost="true">
{buildTime}
<action on="Load"><![CDATA[
this.caption = "Build: " + buildTime(0) + " " + getLanguageID();
]]></action>
</object>
<object type="button" name="pregame_mainmenu_wfg_logo" sprite="pregame_mainmenu_wfg_logo_256x64" size="10 91.666666%-30 25.9765% 100%-30" z="102" hidden="false"
tooltip_style="pregame_mainmenu_tooltip" tooltip="These are the guys who made this game. Visit them at http://www.wildfiregames.com/0ad/">
<action on="Press"><![CDATA[
btCode = new Array("GUIObjectHide('mb_main');");
messageBox(420, 420, "[icon=0ad_icon] A.D. - History Is Yours For The Taking\nby Wildfire Games, 2002-2005\n\nVersion 0.1.2 (PASAP II)\n\n" +
"This is a confidental pre-release version of the game!\n\nVisit http://www.wildfiregames.com/0ad/ " +
"to learn more about [icon=0ad_icon] A.D., participate in the community and meet the developers.\n\n", "About [icon=0ad_icon] A.D.", 2, new Array(), btCode);
]]></action>
</object>
<object type="text" name="pregame_mainmenu_tooltip" sprite="pregame_mainmenu_tooltip_background" size="69% 6.3802% 97.0703125% 28.125%" font="prospero16" textcolor="255 255 255" z="104" hidden="true" ghost="true">tooltipText</object>
<object type="button" name="exit_button" sprite="exit_sprite" sprite_over="exit_sprite_over" size="100%-18 2 100%-2 18" z="104" hidden="false"
tooltip_style="pregame_mainmenu_tooltip" tooltip="Tired of 0 A.D. ? Click here to leave and reenter the real world.">
<action on="Press"><![CDATA[
btCaptions = new Array("Yes, let me out!", "Nooooo!");
btCode = new Array("exit();", "");
messageBox(400, 200, "Do you really want to quit [icon=0ad_icon] A.D.? This will cause a sudden return to reality.", "Confirmation", 0, btCaptions, btCode);
]]></action>
</object>
</object>
<object type="empty" name="pregame_subwindows" size="0 0 100% 100%" z="1" hidden="false">
<object type="image" name="pregame_subwindow_bkg" sprite="translucent_background" size="0 0 100% 100%" z="105" hidden="true"/>
<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[
setSizeCoord("pregame_ip_host_exit_button", crd_pregame_iphost_exit_button_x, crd_pregame_iphost_exit_button_y, crd_pregame_iphost_exit_button_x+crd_pregame_iphost_exit_button_width, crd_pregame_iphost_exit_button_y+crd_pregame_iphost_exit_button_height, mid_screen, mid_screen, mid_screen, mid_screen);
]]></action>
<action on="Press"><![CDATA[
getGUIObjectByName("pregame_subwindow_bkg").hidden = true;
getGUIObjectByName("pregame_mp_ip").hidden = true;
]]></action>
</object>
<object type="text" name="pregame_ip_infotext">
<action on="Load"><![CDATA[
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 entered IP.";
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 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">
<action on="Load"><![CDATA[
getGUIObjectByName("pregame_mp_ip_playername_txt").caption = "Player Name (temporary):";
]]></action>
</object>
<object type="input" name="pregame_mp_ip_playername" sprite="only_black_border" 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">
<action on="Load"><![CDATA[
getGUIObjectByName("pregame_mp_ip_mapname_txt").caption = "Map Name:";
]]></action>
</object>
<object type="input" name="pregame_mp_ip_host_mapname" sprite="only_black_border" absolute="false" size="50 150 200 170" textcolor="0 0 0">
test01.pmp
</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">
<action on="Load"><![CDATA[
getGUIObjectByName("pregame_mp_ip_joinip_txt").caption = "IP Address:";
]]></action>
</object>
<object type="input" name="pregame_mp_ip_joinip" sprite="only_black_border" 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 into the box. The name is relative 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_border" absolute="false" size="130 90 290 110" textcolor="0 0 0">
ph2
</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

@ -1,100 +1,103 @@
function startLoadingScreen()
{
// HACK: Added to increase number of players from its default 2, until we have a session creation screen.
g_GameAttributes.numPlayers = 9;
// 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.";
// Begin game session.
setTimeout( loadSession, 200 );
}
// ====================================================================
function loadSession()
{
if (! startGame())
{
// Failed to start the game; go back to the main menu. TODO: display an error message.
GUIObjectHide("loading_screen");
GUIObjectUnhide("PREGAME_GUI");
return;
}
// Create resource pools for each player, etc.
setupSession();
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);
// Switch GUI from main menu to game session.
GUIObjectHide("loading_screen");
GUIObjectUnhide("SESSION_GUI");
}
// ====================================================================
function setupSession()
{
// Do essentials that can only be done when the session has been loaded ...
// For example, create the resource types.
// Initialise Resource Pools by attaching them to the Player object.
// (CPlayer code takes care of giving a copy to each player.)
player = new Object(); // I shouldn't need to do this. Need to find the existing Player to add these to.
player.resource = new Object();
player.resource.food = 0;
player.resource.wood = 0;
player.resource.stone = 0;
player.resource.ore = 0;
player.resource.pop = new Object();
player.resource.pop.curr = 0;
player.resource.pop.housing = 0;
// Start refreshing the session controls.
setInterval( getObjectInfo, 1, 1000 );
}
// ====================================================================
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', 'theme');
CrossFade(curr_session_playlist_1, curr_music, 0.0001);
// Swap GUIs to display main menu.
GUIObjectHide('SESSION_GUI');
GUIObjectUnhide('PREGAME_GUI');
break;
case ("exit"):
// If the player has chosen to shutdown and immediately return to operating system,
exit();
break;
}
}
// ====================================================================
function startLoadingScreen()
{
// HACK: Added to increase number of players from its default 2, until we have a session creation screen.
g_GameAttributes.numPlayers = 9;
// 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.";
// Begin game session.
setTimeout( loadSession, 200 );
}
// ====================================================================
function loadSession()
{
if (! startGame())
{
// Failed to start the game; go back to the main menu. TODO: display an error message.
GUIObjectHide("loading_screen");
GUIObjectUnhide("PREGAME_GUI");
// 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);
}
// Create resource pools for each player, etc.
setupSession();
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);
// Switch GUI from main menu to game session.
GUIObjectHide("loading_screen");
GUIObjectUnhide("SESSION_GUI");
}
// ====================================================================
function setupSession()
{
// Do essentials that can only be done when the session has been loaded ...
// For example, create the resource types.
// Initialise Resource Pools by attaching them to the Player object.
// (CPlayer code takes care of giving a copy to each player.)
player = new Object(); // I shouldn't need to do this. Need to find the existing Player to add these to.
player.resource = new Object();
player.resource.food = 0;
player.resource.wood = 0;
player.resource.stone = 0;
player.resource.ore = 0;
player.resource.pop = new Object();
player.resource.pop.curr = 0;
player.resource.pop.housing = 0;
// Start refreshing the session controls.
setInterval( getObjectInfo, 1, 1000 );
}
// ====================================================================
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', 'theme');
CrossFade(curr_session_playlist_1, curr_music, 0.0001);
// Swap GUIs to display main menu.
GUIObjectHide('SESSION_GUI');
GUIObjectUnhide('PREGAME_GUI');
break;
case ("exit"):
// If the player has chosen to shutdown and immediately return to operating system,
exit();
break;
}
}
// ====================================================================

View File

@ -1,90 +1,97 @@
function initIPHost()
{
// 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 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)
{
var server = createServer();
// Set basic server options, such as:
// server.port = 20595; // Default is 20595 - you can also explicitly set to -1 for default port
server.serverPlayerName=playerName;
server.serverName=playerName+"'s Server";
server.welcomeMessage="Welcome to "+server.serverName;
// Actually start listening for connections.. This should probably not be
// done until there's been a dialog for filling in the previous options ;-)
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());
}
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)
{
var client=createClient();
client.playerName=playerName;
client.onStartGame=function () {
messageBox(400, 200, "The game starts now!!!", "Get Ready!", 2, new Array(), new Array());
startLoadingScreen();
};
client.onChat=function (event) {
messageBox(400, 200, event.message, "Chat Message", 2, new Array(), new Array());
};
client.onConnectComplete=function (event) {
messageBox(400, 200, "Result message: "+event.message, "Connect complete", 2, new Array(), new Array());
};
// Join MP game
var success = client.beginConnect(serverIP);
if(!success) {
messageBox(400, 200, "Failed to join game. Please review the logfile for more information on the problem.", "Failure", 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);*/
}
// ====================================================================
function initIPHost()
{
// 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 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)
{
var server = createServer();
// Set the map to use
g_GameAttributes.mapFile = mapName;
// Set basic server options, such as:
// server.port = 20595; // Default is 20595 - you can also explicitly set to -1 for default port
server.serverPlayerName=playerName;
server.serverName=playerName+"'s Server";
server.welcomeMessage="Welcome to "+server.serverName;
// Actually start listening for connections.. This should probably not be
// done until there's been a dialog for filling in the previous options ;-)
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());
}
server.onChat=function (event) {
messageBox(400, 200, event.message, "Chat Message", 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("startGame();");
messageBox(400, 200, "Waiting for clients to join - Click OK to start the game.", "Ready", 0, btCaptions, btCode);
}
// ====================================================================
function initMPSessionClient(playerName, serverIP)
{
var client=createClient();
client.playerName=playerName;
client.onStartGame=function () {
messageBox(400, 200, "The game starts now!!!", "Get Ready!", 2, new Array(), new Array());
startLoadingScreen();
};
client.onChat=function (event) {
messageBox(400, 200, event.message, "Chat Message", 2, new Array(), new Array());
};
client.onConnectComplete=function (event) {
messageBox(400, 200, "Result message: "+event.message, "Connect complete", 2, new Array(), new Array());
};
// Join MP game
var success = client.beginConnect(serverIP);
if(!success) {
messageBox(400, 200, "Failed to join game. Please review the logfile for more information on the problem.", "Failure", 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

@ -298,7 +298,7 @@
<sprite name="pregame_mainmenu_tooltip_background">
<image backcolor="0 0 0 85" size="0 0 100% 100%"/>
</sprite>
<!--
==========================================
PREGAME GUI - TEXTURE SPRITES