Index: ps/trunk/binaries/data/mods/official/gui/test/functions_pregame_mp.js
===================================================================
--- ps/trunk/binaries/data/mods/official/gui/test/functions_pregame_mp.js (revision 2477)
+++ ps/trunk/binaries/data/mods/official/gui/test/functions_pregame_mp.js (revision 2478)
@@ -1,97 +1,76 @@
-function initIPHost()
-{
- // IP Host Window background.
- crd_pregame_iphost_bkg_x = -400;
- crd_pregame_iphost_bkg_y = -300;
- 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/2;
- crd_pregame_iphost_titlebar_height = 16;
- crd_pregame_iphost_titlebar_x = crd_pregame_iphost_bkg_x+crd_pregame_iphost_bkg_width/4;
- crd_pregame_iphost_titlebar_y = crd_pregame_iphost_bkg_y-25;
-}
-
-// ====================================================================
-
-function initMPSessionHost(playerName, mapName)
-{
- GUIObjectHide("pregame_mp_ip");
- GUIObjectHide("pregame_subwindow_bkg");
-
- 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.sender+" says: "+event.message, "Chat Message", 2, new Array(), new Array());
- };
-
- // Need "waiting for more players to join and start game" code here
-
- btCaptions = new Array("OK");
- btCode = new Array("startLoadingScreen();");
- messageBox(400, 200, "Waiting for clients to join - Click OK to start the game.", "Ready", 0, btCaptions, btCode);
-}
-
-// ====================================================================
-
-function initMPSessionClient(playerName, serverIP)
-{
- GUIObjectHide("pregame_mp_ip");
- GUIObjectHide("pregame_subwindow_bkg");
-
- 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.sender+" says: "+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());
- }
-
- // 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 initMPSessionHost(playerName, mapName)
+{
+ GUIObjectHide("pregame_mp_ip");
+ GUIObjectHide("pregame_subwindow_bkg");
+
+ 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.sender+" says: "+event.message, "Chat Message", 2, new Array(), new Array());
+ };
+
+ // Need "waiting for more players to join and start game" code here
+
+ btCaptions = new Array("OK");
+ btCode = new Array("startLoadingScreen();");
+ messageBox(400, 200, "Waiting for clients to join - Click OK to start the game.", "Ready", 0, btCaptions, btCode);
+}
+
+// ====================================================================
+
+function initMPSessionClient(playerName, serverIP)
+{
+ GUIObjectHide("pregame_mp_ip");
+ GUIObjectHide("pregame_subwindow_bkg");
+
+ 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.sender+" says: "+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());
+ }
+
+ // 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);*/
+}
+
+// ====================================================================
+
Index: ps/trunk/binaries/data/mods/official/gui/test/functions_pregame.js
===================================================================
--- ps/trunk/binaries/data/mods/official/gui/test/functions_pregame.js (revision 2477)
+++ ps/trunk/binaries/data/mods/official/gui/test/functions_pregame.js (revision 2478)
@@ -1,12 +1,41 @@
// Main Pregame JS Script file
// Contains functions and code for Main Menu.
// ====================================================================
+function OpenMainMenuSubWindow(WindowName)
+{
+ // Helper function that enables the dark background mask, then reveals a given subwindow object.
+
+ GUIObjectUnhide ("pregame_subwindow_bkg");
+ GUIObjectUnhide (WindowName);
+}
+
+// ====================================================================
+
+function CloseMainMenuSubWindow(WindowName)
+{
+ // Helper function that disables the dark background mask, then hides a given subwindow object.
+
+ GUIObjectHide ("pregame_subwindow_bkg");
+ GUIObjectHide (WindowName);
+}
+
+// ====================================================================
+
+function SwitchMainMenuSubWindow(CloseWindowName, OpenWindowName)
+{
+ // Helper function that closes a given window (usually the current parent) and opens another one.
+
+ GUIObjectHide (CloseWindowName);
+ GUIObjectUnhide (OpenWindowName);
+}
+
+// ====================================================================
+
function initPreGame()
{
- initIPHost();
}
// ====================================================================
Index: ps/trunk/binaries/data/mods/official/gui/test/7_atlas.xml
===================================================================
--- ps/trunk/binaries/data/mods/official/gui/test/7_atlas.xml (revision 2477)
+++ ps/trunk/binaries/data/mods/official/gui/test/7_atlas.xml (revision 2478)
@@ -1,547 +1,547 @@
-
Index: ps/trunk/binaries/data/mods/official/gui/test/functions_pregame_load.js
===================================================================
--- ps/trunk/binaries/data/mods/official/gui/test/functions_pregame_load.js (revision 2477)
+++ ps/trunk/binaries/data/mods/official/gui/test/functions_pregame_load.js (revision 2478)
@@ -1,140 +1,175 @@
+// ====================================================================
+
+function StartMap (MapName, OpenWindow, GameMode)
+{
+ // Starts the map, closing the current window.
+ // MapName: .pmp to load.
+ // OpenWindow: Window group (usually parent string) of control that called the function. It'll be hidden.
+ // GameMode: 0: SP
+ // 1: MP
+
+ // Check whether we have a correct file extension, to avoid crashes
+ 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";
+ }
+
+ // Close setup window
+ CloseMainMenuSubWindow (OpenWindow);
+ // Set up game
+ g_GameAttributes.mapFile = MapName;
+ if (GameMode == "0")
+ {
+ // Set up a bunch of players so we can see them pretty colours. :P
+ setupSPPlayers();
+ }
+ startLoadingScreen();
+}
+
+// ====================================================================
+
// HACK: This replaces the old numPlayers hack to set up a bunch of sample
// players in SP games to show off some player colours and fights
function setupSPPlayers()
{
// 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 (i=0;i<7;i++)
{
g_GameAttributes.slots[i+1].assignLocal();
console.write("Slot "+(i+1)+" is assigned: "+g_GameAttributes.slots[i+1].assignment);
}
}
+// ====================================================================
+
function startLoadingScreen()
{
// Switch screens from main menu to loading screen.
GUIObjectHide("PREGAME_GUI");
GUIObjectUnhide("loading_screen");
console.write("Loading " + g_GameAttributes.mapFile + " (" + g_GameAttributes.numPlayers + " players) ...");
// Generate random number for random concept art (should be depending on the selected civ later)
randvar = getRandom(1, 6);
switch (randvar) {
case 1:
sprite = "load_concept_he";
break;
case 2:
sprite = "load_concept_ce";
break;
case 3:
sprite = "load_concept_pe";
break;
case 4:
sprite = "load_concept_ro";
break;
case 5:
sprite = "load_concept_ca";
break;
case 6:
sprite = "load_concept_ib";
break;
}
getGUIObjectByName("loading_screen_background_concept").sprite = sprite;
console.write(getGUIObjectByName("loading_screen_background_concept").sprite);
// janwas: main loop now sets progress / description, but that won't
// happen until the first timeslice completes, so set initial values.
getGUIObjectByName("loading_screen_titlebar_text").caption = "Loading Scenario ...";
getGUIObjectByName("loading_screen_progress_bar_text").caption = "";
getGUIObjectByName("loading_screen_progress_bar").caption = 0;
getGUIObjectByName("loading_screen_text").caption = "LOADING " + g_GameAttributes.mapFile + " ...\nPlease wait ...";
// Pick a random tip of the day (each line is a separate tip).
tipArray = readFileLines("gui/text/tips.txt");
// Set tip string.
getGUIObjectByName("loading_screen_tip").caption = tipArray[getRandom(0, tipArray.length-1)];
// Begin game session.
if (! startGame())
{
// Failed to start the game; go back to the main menu.
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);
}
}
// ====================================================================
function reallyStartGame()
{
// 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.1);
// janwas: greatly accelerate this timesink;
// will be replaced soon by native version that doesn't block.
// 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.)
CreateResources();
// Start refreshing the session controls.
setInterval( getObjectInfo, 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, 0.1);
// janwas: greatly accelerate this timesink;
// will be replaced soon by native version that doesn't block.
// 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;
}
}
// ====================================================================
Index: ps/trunk/binaries/data/mods/official/gui/test/styles.xml
===================================================================
--- ps/trunk/binaries/data/mods/official/gui/test/styles.xml (revision 2477)
+++ ps/trunk/binaries/data/mods/official/gui/test/styles.xml (revision 2478)
@@ -1,362 +1,466 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: ps/trunk/binaries/data/mods/official/gui/test/2_mainmenu.xml
===================================================================
--- ps/trunk/binaries/data/mods/official/gui/test/2_mainmenu.xml (revision 2477)
+++ ps/trunk/binaries/data/mods/official/gui/test/2_mainmenu.xml (revision 2478)
@@ -1,512 +1,798 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
- {buildTime}
+
+
+
+
+
-
-
-
-
- tooltipText
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+ tooltipText
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
- Please enter the Player name you would like to use during the game.
-
-
-
- Player Name (temporary):
-
-
-
- Player
-
-
-
-
-
-
-
-
- Please select whether you want to join a game or host your own game.
-
+
+ Multiplayer
+
+
+
+
+
+
+
+
+ Please enter the Player name you would like to use during the game.
+
+
+ Player Name (temporary):
+
+
+ Player
+
+
+
+
+
+
+ Please select whether you want to join a game or host your own game.
+
-
- Game Mode
-
-
-
- Join Game
-
-
+ Game Mode
+
+
+ Join Game
+
+
-
-
-
- Host Game
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Setting up your server.
-
-
-
- Game (Server) Name:
-
-
-
- My Game
-
-
-
-
-
-
- Welcome Message:
-
-
-
- You can enter some message which is displayed to new players upon joining here.
-
-
-
- Uhm, welcome to my game. Have fun!
-
-
-
-
- Continue
- Host Game
+
+
+
+
+
+
+
+
+ Host a game
+
+
+
+
+
+
+
+
+ Setting up your server.
+
+
+ Game (Server) Name:
+
+
+ My Game
+
+
+
+
+ Welcome Message:
+
+
+ You can enter some message which is displayed to new players upon joining here.
+
+
+ Uhm, welcome to my game. Have fun!
+
+
+
+
+ Continue
+
-
-
-
- Back
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Joining an existing game.
-
-
-
- Server Hostname or IP:
-
-
-
- 127.0.0.1
-
-
-
-
- Continue
-
-
-
-
- Back
-
-
-
-
-
-
+ // start listening
+ res = server.open();
+ if (!res)
+ {
+ messageBox(400, 200, "Error creating server.", "Error", 0, new array(), new array());
+ }
+
+ server.onClientConnect = function (event)
+ {
+ console.write("A new client has successfully connected! ID: " + event.id + ", Name: " + event.name + ", Session: " + event.session);
+ var playerSlot = g_GameAttributes.getOpenSlot();
+ // assign a slot
+ playerSlot.assignToSession(event.session);
+ console.write("slot: " + playerSlot.player);
+ // need to refresh the dialog control data here
+ }
+ ]]>
+
+
+ Back
+
+
+
+
+
+
+
+ Join a game
+
+
+
+
+
+
+
+
+ Joining an existing game.
+
+
+ Server Hostname or IP:
+
+
+ 127.0.0.1
+
+
+
+
+ Continue
+
+
+
+ Back
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+ Player Slots
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Map name:
+
+
+ gathertest
+
+
+
- ]]>
-
-
-
-
-
-
-
-
-
-
-
- Player Slots
-
-
-
- Player1
-
-
-
-
- Player2
-
-
-
-
- Player3
-
-
-
-
- Player4
-
-
-
-
- Player5
-
-
-
-
- Player6
-
-
-
-
-
-
- Map name:
-
-
- gathertest
-
-
-
-
-
-
-
- Start!
-
-
-
-
- Cancel
-
-
-
-
-
-
-
-
-
-
-
+ Start!
+
+
+
+ Cancel
+
+
+
+
+
+
+
+
+
-
- Map selection
-
-
-
- Type the name of the map you want to start into the box. The name is relative to /data/mods/official/maps/scenarios/.
-
-
-
- Map Name:
-
-
-
- gathertest2
-
-
-
- Start Game
-
+ Map selection
+
+
+
+
+
+
+
+
+ Type the name of the map you want to start into the box. The name is relative to /data/mods/official/maps/scenarios/.
-
- Abort
-
+ Map Name:
+ gathertest2
+
+
+
+
+ Start Game
+
+
+
+ Abort
+
+