mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Revised structure of mainmenu script (better property visibility, more use of styles, removal of redundant default properties).
This was SVN commit r2478.
This commit is contained in:
parent
ad182999eb
commit
0342f01580
6 changed files with 959 additions and 526 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
<objects>
|
||||
|
||||
<object type="empty" name="ATLAS_GUI" size="0 0 100% 100%" z="1" hidden="true">
|
||||
<object type="empty" name="atlas_gui" size="0 0 100% 100%" z="1" hidden="true">
|
||||
|
||||
<!-- Simply black out the lowest level of the GUI, until such time as we're capable of starting an editor session of a scenario. -->
|
||||
<object type="text" name="ATLAS_GUI_BKG" sprite="black" size="0 0 100% 100%" z="1" ghost="true" />
|
||||
|
|
@ -524,8 +524,8 @@
|
|||
<object type="button" name="ATLAS_MAINBORDER_LT_CORNER" sprite="atlas_mainborder_lt_corner" tooltip_style="atlas_tooltip" tooltip="[font=tahoma10b]0 A.D. Logo[font=tahoma10]\nMmm, nothing like the smell of blatant self-promotion in the morning ... Oh, you can click this to return to the Main Menu too." ><action on="Load"><![CDATA[ setSizeArray(this.name, Crd[ATLAS_MAINBORDER_LT_CORNER]); ]]></action>
|
||||
<action on="Press"><![CDATA[
|
||||
// Jason asked for an exit button to be put here, until we're able to exit via the drop-down File menu.
|
||||
GUIObjectUnhide("PREGAME_GUI");
|
||||
GUIObjectHide("ATLAS_GUI");
|
||||
GUIObjectUnhide("pregame_gui");
|
||||
GUIObjectHide("atlas_gui");
|
||||
]]></action>
|
||||
</object>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,38 @@
|
|||
|
||||
// ====================================================================
|
||||
|
||||
function initPreGame()
|
||||
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();
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
|
|
|||
|
|
@ -1,3 +1,36 @@
|
|||
// ====================================================================
|
||||
|
||||
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()
|
||||
|
|
@ -11,6 +44,8 @@ function setupSPPlayers()
|
|||
}
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
function startLoadingScreen()
|
||||
{
|
||||
// Switch screens from main menu to loading screen.
|
||||
|
|
|
|||
|
|
@ -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);*/
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,110 @@
|
|||
sprite2_disabled="sprite2_disabled"
|
||||
/>
|
||||
|
||||
<style name="empty"
|
||||
size="0 0 100% 100%"
|
||||
/>
|
||||
|
||||
<style name="backdrop"
|
||||
size="0 0 100% 100%"
|
||||
ghost="true"
|
||||
/>
|
||||
|
||||
<style name="text_prospero16_gold"
|
||||
ghost="true"
|
||||
font="prospero16"
|
||||
textcolor="237 227 167"
|
||||
/>
|
||||
|
||||
<style name="text_prospero16_white"
|
||||
ghost="true"
|
||||
font="prospero16"
|
||||
textcolor="255 255 255"
|
||||
/>
|
||||
|
||||
<style name="text_tahoma16_black"
|
||||
ghost="true"
|
||||
font="tahoma16"
|
||||
textcolor="0 0 0"
|
||||
/>
|
||||
|
||||
<style name="text_tahoma16_black_right"
|
||||
ghost="true"
|
||||
font="tahoma16"
|
||||
text_align="right"
|
||||
textcolor="0 0 0"
|
||||
/>
|
||||
|
||||
<style name="text_giovanni22bold_black"
|
||||
ghost="true"
|
||||
font="giovanni22bold"
|
||||
text_align="center"
|
||||
textcolor="0 0 0"
|
||||
/>
|
||||
|
||||
<style name="border_box_black"
|
||||
sprite="only_black_border"
|
||||
sprite_selectarea="GeeTemp_selected"
|
||||
textcolor="0 0 0"
|
||||
textcolor_selected="255 255 255"
|
||||
/>
|
||||
|
||||
<style name="border_box_black_verdana9"
|
||||
font="verdana9"
|
||||
sprite="only_black_border"
|
||||
sprite_selectarea="GeeTemp_selected"
|
||||
textcolor="0 0 0"
|
||||
textcolor_selected="255 255 255"
|
||||
/>
|
||||
|
||||
<style name="divider_black"
|
||||
sprite="only_black_border"
|
||||
sprite_selectarea="GeeTemp_selected"
|
||||
textcolor="0 0 0"
|
||||
textcolor_selected="255 255 255"
|
||||
/>
|
||||
|
||||
<style name="pregame_mainmenu_button"
|
||||
tooltip_style="pregame_mainmenu_tooltip"
|
||||
/>
|
||||
|
||||
<style name="pregame_mainmenu_checkbox"
|
||||
sprite="exit_sprite"
|
||||
sprite_over="exit_sprite_over"
|
||||
tooltip="Close this window and return to the previous screen."
|
||||
tooltip_style="pregame_mainmenu_tooltip"
|
||||
/>
|
||||
|
||||
<style name="0ad_window"
|
||||
sprite="0ad_window"
|
||||
/>
|
||||
|
||||
<style name="0ad_window_titlebar"
|
||||
absolute="false"
|
||||
size="50%-150 0%-25 50%+150 0%-9"
|
||||
font="prospero18"
|
||||
sprite="0ad_window_title"
|
||||
text_align="center"
|
||||
text_valign="center"
|
||||
/>
|
||||
|
||||
<style name="0ad_window_button"
|
||||
absolute="false"
|
||||
sprite="message_box_button_normal"
|
||||
sprite_over="message_box_button_over"
|
||||
text_align="center"
|
||||
text_valign="center"
|
||||
/>
|
||||
|
||||
<style name="0ad_window_checkbox"
|
||||
absolute="false"
|
||||
size="100%+9 0%-25 100%+25 0%-9"
|
||||
sprite="exit_sprite"
|
||||
sprite_over="exit_sprite_over"
|
||||
tooltip="Close this window and return to the previous screen."
|
||||
tooltip_style="pregame_mainmenu_tooltip"
|
||||
/>
|
||||
|
||||
<style name="resource_counter"
|
||||
text_valign="bottom"
|
||||
text_align="right"
|
||||
|
|
|
|||
Loading…
Reference in a new issue