Delete some old unused GUI scripts

This was SVN commit r7767.
This commit is contained in:
Ykkrosh 2010-07-19 22:55:30 +00:00
parent 0be1713b2b
commit 544afca570
6 changed files with 0 additions and 685 deletions

View File

@ -1,60 +0,0 @@
/*
DESCRIPTION : Functions used load/end the game session and manipulate the loading screen.
NOTES :
*/
// ====================================================================
function launchGame ()
{
// Starts the map, closing the session setup window.
var mapName = getCurrItemValue("pgSessionSetupMapName");
var gameMode = getCurrItemValue("pgSessionSetupGameMode");
var screenshotMode = getGUIObjectByName("pgSessionSetupScreenshotMode").checked;
var losSetting = getGUIObjectByName("pgSessionSetupLosSetting").selected;
var fogOfWar = getGUIObjectByName("pgSessionSetupFoW").checked;
if(screenshotMode)
{
losSetting = 2;
fogOfWar = false;
}
// Check whether we have a correct file extension, to avoid crashes
var extension = mapName.substring (mapName.length, mapName.length-4);
if (extension != ".pmp")
{
// Add .pmp to the file name.
var mapName = mapName + ".pmp";
}
// Set up game
g_GameAttributes.mapFile = mapName;
g_GameAttributes.losSetting = losSetting;
g_GameAttributes.fogOfWar = fogOfWar;
g_GameAttributes.gameMode = gameMode
g_GameAttributes.screenshotMode = screenshotMode;
// Close setup window
closeMainMenuSubWindow ("pgSessionSetup");
// Display loading screen.
Engine.SwitchGuiPage("page_loading.xml");
console.write( "running startGame()" );
// Begin game session.
if (! startGame())
{
// Failed to start the game; go back to the main menu.
Engine.SwitchGuiPage("page_pregame.xml");
// Restore default cursor.
setCursor ("arrow-default");
// Show an error message
messageBox(400, 200, "The game could not be started with the given parameters. You probably have entered an invalid map name.", "Error", 0, ["OK"], [undefined]);
}
console.write( "done running startGame()" );
}
// ====================================================================

View File

@ -1,147 +0,0 @@
/*
DESCRIPTION : Functions for the hosting and joining multiplayer games.
NOTES :
*/
// ====================================================================
function initMPHost (parentWindow, gameName, welcomeMessage)
{
// Set up the server
var server = createServer();
// Welcome message
server.welcomeMessage = welcomeMessage;
// Server Name
server.serverName = gameName;
// Host Name
server.serverPlayerName = "Player";
// start listening
var success = server.open();
if (!success)
{
messageBox(400, 200, "Failed to start server. Please review the logfile for more information on the problem.", "Problem", 2, new Array(), new Array());
return 1;
}
else
{
console.write ("Host has started listening for client connections.");
// Switch to Session Setup screen.
sessionType = "Host";
openSessionSetup (parentWindow);
}
// -------------------------
// INCOMING CONNECTIONS
// -------------------------
server.onClientConnect = function (event)
{
console.write ("Client connected.");
console.write("A new client has successfully connected! ID: " + event.id + ", Name: " + event.name + ", Session: " + event.session);
// Assign newly connected client to next available slot.
var playerSlot = g_GameAttributes.getOpenSlot();
playerSlot.assignToSession (event.session);
// Set player slot to new player's name
var slotID = g_GameAttributes.getUsedSlotsAmount;
pushItem ("pgSessionSetupP" + slotID, g_GameAttributes.slots[slotID-1].player.name);
}
server.onClientDisconnect = function (event)
{
// Client has disconnected; free their slot.
var slotID = g_GameAttributes.getUsedSlotsAmount-1;
g_GameAttributes.slots[slotID].assignOpen();
var result = setCurrItemValue ("pgSessionSetupP" + slotID, "Open");
messageBox(400, 200, "Client " + event.name + "(" + event.id + ") disconnected from " + event.session + ".", "Client Disconnected", 2, new Array(), new Array());
}
server.onChat = function (event)
{
messageBox(400, 200, "(" + event.sender + ")" + event.message, "Host Chat Message", 2, new Array(), new Array());
}
// Need "waiting for more players to join and start game" code here
}
// ====================================================================
function initMPClient (mpParentWindow, ipAddress)
{
// Create the client instance
var client = createClient();
// Player Name
client.playerName = "Player";
client.onClientConnect = function (event)
{
// Set player slot to new player's name.
console.write("onClientConnect: name is " + event.name + ", event id is " + event.id);
var slotID = g_GameAttributes.getUsedSlotsAmount;
console.write("slotID="+slotID);
pushItem ("pgSessionSetupP" + eval(slotID+1), g_GameAttributes.slots[slotID].player.name);
}
client.onConnectComplete = function (event)
{
console.write("onConnectComplete: " + event.message);
if (event.success)
{
// Switch to Session Setup screen.
sessionType = "Client";
openSessionSetup ("pgMPJoin");
messageBox (400, 200, "Client connected " + event.message + ".",
"Connect Complete", 2, new Array(), new Array());
}
else
{
messageBox (400, 200, "Client failed to complete connection: " + event.message + ".",
"Connect Failure", 2, new Array(), new Array());
}
}
client.onChat = function (event)
{
messageBox (400, 200, "(" + event.sender + ")" + event.message,
"Client Chat Message", 2, new Array(), new Array());
}
client.onDisconnect = function (event)
{
console.write("onDisconnect: " + event.message);
messageBox (400, 200, event.message,
"Host Disconnected", 2, new Array(), new Array());
}
client.onClientDisconnect = function (event)
{
console.write("onClientDisconnect: " + event.message);
messageBox (400, 200, event.session,
"Client " + event.name + "(" + event.id + ") Disconnected", 2, new Array(), new Array());
}
client.onStartGame = function (event)
{
// The server has called Start Game!, so we better switch to the session GUI and stuff like that.
launchGame();
}
var success = client.beginConnect (ipAddress);
if (!success)
{
messageBox(400, 200, "Failed to connect to server. Please check the network connection.",
"Client Failure", 2, new Array(), new Array());
return 1;
}
else
{
console.write ("Client successfully started to connect to " + ipAddress + ".");
}
}
// ====================================================================

View File

@ -1,151 +0,0 @@
/*
DESCRIPTION : Functions for configuring a game prior to the loading screen (hosting, joining, or skirmish).
NOTES :
*/
// ====================================================================
// Open the Session Setup screen.
function openSessionSetup (sessionReturnWindow)
{
var titleBar = getGUIObjectByName ("pgSessionSetupTitleBar");
// Setup remaining slots.
for (var i = 1; i <= g_GameAttributes.numSlots; i++)
{
if (i == 1)
{
// Set the host player's name on the setup screen.
getGUIObjectByName ("pgSessionSetupP" + i).caption = "(Host)";
}
else
{
if (getNumItems("pgSessionSetupP" + i) == 0)
{
//pushItem ("pgSessionSetupP" + i, "session");
pushItem ("pgSessionSetupP" + i, "Open");
pushItem ("pgSessionSetupP" + i, "Closed");
//pushItem ("pgSessionSetupP" + i, "local");
//pushItem ("pgSessionSetupP" + i, "AI");
// Set other slots to Open.
var result = setCurrItemValue ("pgSessionSetupP" + i, "Open");
// Setup onchange event (closing and opening affects host slots).
getGUIObjectByName ("pgSessionSetupP" + i).onSelectionChange = function (event)
{
var slotNumber = this.name.substring (this.name.length-1, this.name.length);
switch (getCurrItemValue (this.name))
{
case "Open":
// If "Open" selected,
// Open the slot.
g_GameAttributes.slots[slotNumber-1].assignOpen();
//console.write ("Opened slot " + this.name);
break;
case "Closed":
// If "Closed" selected,
// And slot is occupied,
if (g_GameAttributes.slots[slotNumber-1].assignment == "session")
{
// Remove player name from slot list.
removeItem (this.name, g_GameAttributes.slots[slotNumber-1].player);
// Prompt that player was kicked.
// (Change this to a chat message when functionality available.)
console.write (g_GameAttributes.slots[slotNumber-1].player + " was kicked by the host.");
}
// Close the slot.
g_GameAttributes.slots[slotNumber-1].assignClosed();
//console.write ("Closed slot " + this.name);
break;
default:
break;
}
}
}
}
// Make objects non-interactive to client.
if (sessionType == "Client") guiDisable ("pgSessionSetupP" + i);
}
// Set the title for the setup screen
switch (sessionType)
{
case "Host":
titleBar.caption = "Hosting: " + g_NetServer.serverName;
// Reveal type-specific Session Setup objects.
guiUnHide ("pgSessionSetupMP");
guiUnHide ("pgSessionSetupMPHost");
guiUnHide ("pgSessionSetupMaster");
break;
case "Client":
titleBar.caption = "Joining: " // g_NetServer.serverName;
// Reveal type-specific Session Setup objects.
guiUnHide ("pgSessionSetupMP");
guiUnHide ("pgSessionSetupMPClient");
// Disable objects that clients shouldn't be able to modify.
guiDisable ("pgSessionSetupMapName");
guiDisable ("pgSessionSetupStartButton");
break;
case "Skirmish":
titleBar.caption = "Skirmish";
// Reveal type-specific Session Setup objects.
guiUnHide ("pgSessionSetupSkirmish");
guiUnHide ("pgSessionSetupMaster");
break;
default:
break;
}
// Reveal GUI.
guiHide ("pgVersionNumber");
if (sessionReturnWindow != "")
guiSwitch (sessionReturnWindow, "pgSessionSetup");
else
openMainMenuSubWindow ("pgSessionSetup");
}
// ====================================================================
// Close/cancel the Session Setup screen.
function closeSessionSetup ()
{
// Hide type-specific objects.
guiHide ("pgSessionSetupMP");
guiHide ("pgSessionSetupMPHost");
guiHide ("pgSessionSetupMPClient");
guiHide ("pgSessionSetupSkirmish");
guiHide ("pgSessionSetupMaster");
// Return to previous screen.
switch (sessionType)
{
case "Host":
case "Client":
// terminate the multiplayer server session
endGame();
// Go back to multiplayer mode selection screen.
guiSwitch ("pgSessionSetup", "pgMPModeSel");
break;
case "Skirmish":
// Go back to main menu.
closeMainMenuSubWindow ("pgSessionSetup");
break;
default:
break;
}
guiUnHide ("pgVersionNumber");
}
// ====================================================================

View File

@ -1,34 +0,0 @@
/*
DESCRIPTION : GUI animation functions (sliding in/out, fading, etc).
NOTES :
*/
// ====================================================================
function GUISlideIn(GUIObject, SlideSpeed)
{
// Just me testing some stuff :)
var SlideObject = getGUIObjectByName(GUIObject);
var SizeVar = SlideObject.size;
//var Sizes = SizeVar.split(" ");
//var x_s = Sizes[0];
//var y_s = Sizes[1];
//var x_e = Sizes[2];
//var y_e = Sizes[3];
//var height = x_e - x_s;
//var Time = new Date();
//var StartTime = Time.getTime();
var i = 0;
while(i <= 2) {
i++;
SlideObject.size = new GUISize(x_s, 0 + i, x_e, 0 + i + height);
}
}
// ====================================================================

View File

@ -1,283 +0,0 @@
/*
DESCRIPTION : Functions that support the coordinate system (ability to maintain and swap between multiple
sizes for an object).
NOTES :
*/
// ====================================================================
// Initialise coordinate set for this page.
Crd = { last: -1 };
// Set corner constants.
rb = 0;
lb = 1;
lt = 2;
rt = 3;
// ====================================================================
// Add a new size coordinate to the array.
function addCrd (name, group, rx, ry, x, y, width, height, rx2, ry2)
{
// If no group is specified, default to the first one.
if (!group)
group = rb;
// Create new coordinate if necessary (it doesn't exist, or we have a new name).
if (group == rb || !Crd[Crd.last])
{
Crd.last++;
Crd[Crd.last] = new Object();
Crd[Crd.last].name = new Object(name);
Crd[Crd.last].size = new Object();
Crd[Crd.last].coord = new Object();
}
// Get coordinates from first element if not defined.
if (x == undefined)
x = Crd[Crd.last].coord[rb].x;
if (y == undefined)
y = Crd[Crd.last].coord[rb].y;
if (width == undefined)
width = Crd[Crd.last].coord[rb].width;
if (height == undefined)
height = Crd[Crd.last].coord[rb].height;
// Generate and save coordinates.
Crd[Crd.last].size[group] = calcCrdArray (rx, ry, x, y, width, height, rx2, ry2);
Crd[Crd.last].coord[group] = new Array();
Crd[Crd.last].coord[group].rx = rx;
Crd[Crd.last].coord[group].ry = ry;
Crd[Crd.last].coord[group].x = x;
Crd[Crd.last].coord[group].y = y;
Crd[Crd.last].coord[group].width = width;
Crd[Crd.last].coord[group].height = height;
}
// ====================================================================
function addCrds (name, rx, ry, x, y, width, height, rx2, ry2)
{
// This is a shortcut function that saves you having to call addCrd() for each coordinate group. Just do this once for the whole set.
// It creates the first, then assumes all the remaining coordinates are flipped to the opposite screen edge.
// (True in 90% of cases.)
addCrd (name, rb, rx, ry, x, y, width, height, rx2, ry2);
// Determine flip relatives.
switch (rx)
{
case 0:
var rx1 = 100;
var rx2 = 100;
var rx3 = 0;
break;
case 50:
var rx1 = 50;
var rx2 = 50;
var rx3 = 50;
break;
case 100:
var rx1 = 0;
var rx2 = 0;
var rx3 = 100;
break;
}
switch (ry)
{
case 0:
var ry1 = 0;
var ry2 = 100;
var ry3 = 100;
break;
case 50:
var ry1 = 50;
var ry2 = 50;
var ry3 = 50;
break;
case 100:
var ry1 = 100;
var ry2 = 0;
var ry3 = 0;
break;
}
// Define the rest of the coordinate set.
addCrd (name, lb, rx1, ry1);
addCrd (name, lt, rx2, ry2);
addCrd (name, rt, rx3, ry3);
}
// ====================================================================
// Return coordinate object with a given name.
// Optionally can choose to return the index to the coordinate, rather than the coordinate itself.
function getCrd (name, byIndex)
{
for (var getCrdLoop = 0; getCrdLoop <= Crd.last; getCrdLoop++)
{
if (Crd[getCrdLoop].name == name)
{
// If only index requested, just return index.
if (byIndex)
return getCrdLoop;
else
// Otherwise return the whole coordinate array for this object.
return Crd[getCrdLoop];
}
}
console.write ("Coordinate " + name + " not found in call to getCrd().");
// Return -1 to indicate failure.
return -1;
}
// ====================================================================
// Calculates and returns "size" string from a given x/y/width/height and relative x and y.
function calcCrdArray (rx, ry, x, y, width, height, rx2, ry2)
{
if (!rx2 && !ry2)
{
// If two sets of relatives are not specified at the end of the parameter list, use the "shortcut" format:
// "Left Corner" (Relative X)
// "Top Corner" (Relative Y)
// X Position
// Y Position
// Width from X
// Height from Y
var setSizeContainer = new Object();
setSizeContainer.rleft = rx;
setSizeContainer.rtop = ry;
setSizeContainer.rright = rx;
setSizeContainer.rbottom = ry;
// Define size dimensions.
switch (setSizeContainer.rleft)
{
case 0:
case 50:
setSizeContainer.x1 = x;
break;
case 100:
setSizeContainer.x1 = -x-width;
break;
}
switch (setSizeContainer.rtop)
{
case 0:
case 50:
setSizeContainer.y1 = y;
break;
case 100:
setSizeContainer.y1 = -y-height;
break;
}
switch (setSizeContainer.rright)
{
case 0:
case 50:
setSizeContainer.x2 = x+width;
break;
case 100:
setSizeContainer.x2 = -x;
break;
}
switch (setSizeContainer.rbottom)
{
case 0:
case 50:
setSizeContainer.y2 = y+height;
break;
case 100:
setSizeContainer.y2 = -y;
break;
}
return new GUISize (setSizeContainer.x1, setSizeContainer.y1, setSizeContainer.x2, setSizeContainer.y2,
setSizeContainer.rleft, setSizeContainer.rtop, setSizeContainer.rright, setSizeContainer.rbottom);
}
else
{
// Use the standard "size" structure:
// RX
// RY
// X1
// X2
// Y1
// Y2
// RX2
// RY2
return new GUISize (x, y, width, height, rx, ry, rx2, ry2);
}
}
// ====================================================================
// Set an existing coord of a given name to a new value.
function setCrd (name, newCrd)
{
// Get the index to the given coordinate.
var crdResult = getCrd (name, true);
if (crdResult != -1)
{
// Set new value of this coordinate.
Crd[crdResult] = newCrd;
}
else
{
console.write ("Failed to setCrd() + " + name);
return -1;
}
}
// ====================================================================
function setSkin (skinName)
{
// (Unfortunately, this idea just isn't going to work until the GUI Engine allows us to set the value of a control's style (and therefore refresh its properties
// with those of the new style. As it stands, the style property is empty at runtime because styles are all set when the stuff is loaded. And since we're wrapping
// sprite info for skins in the styles, it won't be adequate to simply change the sprite properties. So commenting this out for now so we can adapt it later.)
/*
// Sets the sprites of all registered controls with a skin (eg *<skinname>*SpriteName) to the specified skin name.
// Obviously such sprite names must exist, or it all will go horribly wrong.
// Seek through all registered coordinates.
for (var i = 0; i <= Crd.last; i++)
{
var objectName = getGUIObjectByName (Crd[i].name);
// We need to deliberately ignore the minimap object as it has no sprite (and checking for the existence of the property or type doesn't work).
if (objectName.name != "snMiniMapDisplay")
{
// Get first asterisk position.
var startIndex = objectName.style.indexOf ("*", 1);
console.write (startIndex);
// If the coordinate begins with a "skin*" (and therefore qualifies for replacement),
if (startIndex != -1)
{
// Look for and return the ending asterisk.
var endIndex = objectName.style.indexOf ("*", 5);
console.write (endIndex);
if (endIndex != -1)
{
// Set new skin name for sprite.
objectName.style = "skin*" + skinName + "*" + objectName.style.substring (endIndex);
}
}
}
}
*/
}
// ====================================================================

View File

@ -16,12 +16,8 @@
<script file="gui/common/functions_utility_object.js" />
<script file="gui/common/functions_utility_coord.js" />
<script file="gui/common/functions_utility_music.js" />
<script file="gui/common/functions_utility_animation.js" />
<!--
==========================================
- INCLUDE SCRIPT - GLOBAL OBJECT FUNCTIONS
@ -38,10 +34,4 @@
<script file="gui/common/functions_page_pregame.js" />
<script file="gui/common/functions_page_pregame_multiplayer.js" />
<script file="gui/common/functions_page_pregame_setup.js" />
<script file="gui/common/functions_page_pregame_load.js" />
</objects>