Index: ps/trunk/binaries/data/mods/public/gui/common/modern/sprites.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/common/modern/sprites.xml (revision 15068)
+++ ps/trunk/binaries/data/mods/public/gui/common/modern/sprites.xml (revision 15069)
@@ -1,474 +1,474 @@
-
-
-
-
-
-
Index: ps/trunk/binaries/data/mods/public/gui/lobby/prelobby.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/lobby/prelobby.js (revision 15068)
+++ ps/trunk/binaries/data/mods/public/gui/lobby/prelobby.js (revision 15069)
@@ -1,183 +1,256 @@
var g_LobbyIsConnecting = false;
var g_EncrytedPassword = "";
var g_PasswordInputIsHidden = false;
+var g_TermsOfServiceRead = false;
+var g_TermsOfUseRead = false;
+var g_hasSystemMessage = false;
function init()
{
g_EncrytedPassword = Engine.ConfigDB_GetValue("user", "lobby.password");
+ if (Engine.ConfigDB_GetValue("user", "lobby.login") && g_EncrytedPassword)
+ switchPage("connect");
}
function lobbyStop()
{
Engine.GetGUIObjectByName("feedback").caption = "";
if (g_LobbyIsConnecting == false)
return;
g_LobbyIsConnecting = false;
Engine.StopXmppClient();
}
-function lobbyStart()
+function lobbyStartConnect()
{
if (g_LobbyIsConnecting)
return;
if (Engine.HasXmppClient())
Engine.StopXmppClient();
var username = Engine.GetGUIObjectByName("connectUsername").caption;
var password = Engine.GetGUIObjectByName("connectPassword").caption;
var feedback = Engine.GetGUIObjectByName("feedback");
var room = Engine.ConfigDB_GetValue("user", "lobby.room");
var history = Number(Engine.ConfigDB_GetValue("user", "lobby.history"));
feedback.caption = translate("Connecting...");
// If they enter a different password, re-encrypt.
if (password != g_EncrytedPassword.substring(0, 10))
g_EncrytedPassword = Engine.EncryptPassword(password, username);
// We just use username as nick for simplicity.
Engine.StartXmppClient(username, g_EncrytedPassword, room, username, history);
g_LobbyIsConnecting = true;
Engine.ConnectXmppClient();
}
function lobbyStartRegister()
{
- if (g_LobbyIsConnecting != false)
+ if (g_LobbyIsConnecting)
return;
if (Engine.HasXmppClient())
Engine.StopXmppClient();
- var account = Engine.GetGUIObjectByName("connectUsername").caption;
- var password = Engine.GetGUIObjectByName("connectPassword").caption;
- var passwordAgain = Engine.GetGUIObjectByName("registerPasswordAgain").caption;
+ var account = Engine.GetGUIObjectByName("registerUsername").caption;
+ var password = Engine.GetGUIObjectByName("registerPassword").caption;
var feedback = Engine.GetGUIObjectByName("feedback");
- // Check the passwords match.
- if (password != passwordAgain)
- {
- feedback.caption = translate("Passwords do not match");
- Engine.GetGUIObjectByName("connectPassword").caption = "";
- Engine.GetGUIObjectByName("registerPasswordAgain").caption = "";
- switchRegister();
- return;
- }
-
feedback.caption = translate("Registering...");
g_EncrytedPassword = Engine.EncryptPassword(password, account);
Engine.StartRegisterXmppClient(account, g_EncrytedPassword);
g_LobbyIsConnecting = true;
Engine.ConnectXmppClient();
}
-function switchRegister()
+function onTick()
{
- if (Engine.GetGUIObjectByName("pageRegister").hidden)
+ var pageRegisterHidden = Engine.GetGUIObjectByName("pageRegister").hidden;
+ if (pageRegisterHidden)
{
- lobbyStop();
- Engine.GetGUIObjectByName("pageRegister").hidden = false;
- Engine.GetGUIObjectByName("pageConnect").hidden = true;
- Engine.GetGUIObjectByName("connect").enabled = false;
+ var username = Engine.GetGUIObjectByName("connectUsername").caption;
+ var password = Engine.GetGUIObjectByName("connectPassword").caption;
}
else
{
- Engine.GetGUIObjectByName("pageRegister").hidden = true;
- Engine.GetGUIObjectByName("pageConnect").hidden = false;
- Engine.GetGUIObjectByName("connect").enabled = true;
+ var username = Engine.GetGUIObjectByName("registerUsername").caption;
+ var password = Engine.GetGUIObjectByName("registerPassword").caption;
}
-}
-
-function onTick()
-{
- //
- var username = Engine.GetGUIObjectByName("connectUsername").caption;
- var password = Engine.GetGUIObjectByName("connectPassword").caption;
var passwordAgain = Engine.GetGUIObjectByName("registerPasswordAgain").caption;
+ var agreeTerms = Engine.GetGUIObjectByName("registerAgreeTerms");
var feedback = Engine.GetGUIObjectByName("feedback");
- var pageRegisterHidden = Engine.GetGUIObjectByName("pageRegister").hidden;
- var connectButton = Engine.GetGUIObjectByName("connect");
- var registerButton = Engine.GetGUIObjectByName("register");
- var sanitizedName = sanitizePlayerName(username, true, true)
- // If there aren't a username and password entered, we can't start registration or connection.
- if (!username || !password)
- {
- connectButton.enabled = false;
- registerButton.enabled = false;
- if (!username && !password)
- feedback.caption = translate("Please enter existing login or desired registration credentials.");
+ var continueButton = Engine.GetGUIObjectByName("continue");
+ var sanitizedName = sanitizePlayerName(username, true, true);
+
+ // Do not change feedback while connecting.
+ if (g_LobbyIsConnecting) {}
+ // Do not show feedback on the welcome screen.
+ else if (!Engine.GetGUIObjectByName("pageWelcome").hidden)
+ {
+ feedback.caption = "";
+ }
+ // Check that they entered a username.
+ else if (!username)
+ {
+ continueButton.enabled = false;
+ feedback.caption = translate("Please enter your username");
}
- // Check they are using a valid account name.
+ // Check that they are using a valid username.
else if (username != sanitizedName)
{
- feedback.caption = translate("Usernames can't contain [, ], unicode, whitespace, or commas.");
- connectButton.enabled = false;
- registerButton.enabled = false;
+ continueButton.enabled = false;
+ feedback.caption = translate("Usernames can't contain [, ], unicode, whitespace, or commas");
+ }
+ // Check that they entered a password.
+ else if (!password)
+ {
+ continueButton.enabled = false;
+ feedback.caption = translate("Please enter your password");
}
- // Allow them to connect/begin registation if there aren't any problems.
+ // Allow them to connect if tests pass up to this point.
else if (pageRegisterHidden)
{
- // TODO Do this without comparing the caption
- if (feedback.caption == translate("Usernames can't contain [, ], unicode, whitespace, or commas.") ||
- feedback.caption == translate("Please enter existing login or desired registration credentials."))
+ if (!g_hasSystemMessage)
+ feedback.caption = "";
+ continueButton.enabled = true;
+ }
+ // Check that they entered their password again.
+ else if (!passwordAgain)
+ {
+ continueButton.enabled = false;
+ feedback.caption = translate("Please enter your password again");
+ }
+ // Check that the passwords match.
+ else if (passwordAgain != password)
+ {
+ continueButton.enabled = false;
+ feedback.caption = translate("Passwords do not match");
+ }
+ // Check that they read the Terms of Service.
+ else if (!g_TermsOfServiceRead)
+ {
+ continueButton.enabled = false;
+ feedback.caption = translate("Please read the Terms of Service");
+ }
+ // Check that they read the Terms of Use.
+ else if (!g_TermsOfUseRead)
+ {
+ continueButton.enabled = false;
+ feedback.caption = translate("Please read the Terms of Use");
+ }
+ // Check that they agree to the terms of service and use.
+ else if (!agreeTerms.checked)
+ {
+ continueButton.enabled = false;
+ feedback.caption = translate("Please agree to the Terms of Service and Terms of Use");
+ }
+ // Allow them to register.
+ else
+ {
+ if (!g_hasSystemMessage)
feedback.caption = "";
- connectButton.enabled = true;
- registerButton.enabled = true;
+ continueButton.enabled = true;
}
- // If the password hasn't been entered again, we can't complete registation.
- if (!pageRegisterHidden && !passwordAgain)
- registerButton.enabled = false;
- else if (!pageRegisterHidden)
- registerButton.enabled = true;
if (!g_LobbyIsConnecting)
// The Xmpp Client has not been created
return;
// The XmppClient has been created, we are waiting
// to be connected or to receive an error.
//Receive messages
while (true)
{
var message = Engine.LobbyGuiPollMessage();
if (!message)
break;
if (message.type == "muc" && message.level == "join")
{
// We are connected, switch to the lobby page
Engine.PopGuiPage();
// Use username as nick.
var nick = sanitizePlayerName(username, true, true);
// Switch to lobby
Engine.SwitchGuiPage("page_lobby.xml");
// Store nick, login, and password
Engine.ConfigDB_CreateValue("user", "playername", nick);
Engine.ConfigDB_CreateValue("user", "lobby.login", username);
// We only store the encrypted password, so make sure to re-encrypt it if changed before saving.
if (password != g_EncrytedPassword.substring(0, 10))
g_EncrytedPassword = Engine.EncryptPassword(password, username);
Engine.ConfigDB_CreateValue("user", "lobby.password", g_EncrytedPassword);
Engine.ConfigDB_WriteFile("user", "config/user.cfg");
return;
}
else if (message.type == "system" && message.text == "registered")
{
// Great, we are registered. Switch to the connection window.
feedback.caption = toTitleCase(message.text);
Engine.StopXmppClient();
g_LobbyIsConnecting = false;
- switchRegister();
+ Engine.GetGUIObjectByName("connectUsername").caption = username;
+ Engine.GetGUIObjectByName("connectPassword").caption = password;
+ switchPage("connect");
}
else if(message.type == "system" && (message.level == "error" || message.text == "disconnected"))
{
+ g_hasSystemMessage = true;
feedback.caption = toTitleCase(message.text);
Engine.StopXmppClient();
g_LobbyIsConnecting = false;
}
}
}
+
+function switchPage(page)
+{
+ // First hide everything.
+ if (!Engine.GetGUIObjectByName("pageWelcome").hidden)
+ {
+ Engine.GetGUIObjectByName("pageWelcome").hidden = true;
+ }
+ else if (!Engine.GetGUIObjectByName("pageRegister").hidden)
+ {
+ Engine.GetGUIObjectByName("pageRegister").hidden = true;
+ Engine.GetGUIObjectByName("continue").hidden = true;
+ var dialog = Engine.GetGUIObjectByName("dialog");
+ var newSize = dialog.size;
+ newSize.bottom -= 150;
+ dialog.size = newSize;
+ }
+ else if (!Engine.GetGUIObjectByName("pageConnect").hidden)
+ {
+ Engine.GetGUIObjectByName("pageConnect").hidden = true;
+ Engine.GetGUIObjectByName("continue").hidden = true;
+ }
+
+ // Then show appropriate page.
+ switch(page)
+ {
+ case "welcome":
+ Engine.GetGUIObjectByName("pageWelcome").hidden = false;
+ break;
+ case "register":
+ var dialog = Engine.GetGUIObjectByName("dialog");
+ var newSize = dialog.size;
+ newSize.bottom += 150;
+ dialog.size = newSize;
+ Engine.GetGUIObjectByName("pageRegister").hidden = false;
+ Engine.GetGUIObjectByName("continue").caption = translate("Register");
+ Engine.GetGUIObjectByName("continue").hidden = false;
+ break;
+ case "connect":
+ Engine.GetGUIObjectByName("pageConnect").hidden = false;
+ Engine.GetGUIObjectByName("continue").caption = translate("Connect");
+ Engine.GetGUIObjectByName("continue").hidden = false;
+ break;
+ }
+}
+
Index: ps/trunk/binaries/data/mods/public/gui/lobby/prelobby.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/lobby/prelobby.xml (revision 15068)
+++ ps/trunk/binaries/data/mods/public/gui/lobby/prelobby.xml (revision 15069)
@@ -1,98 +1,132 @@
Index: ps/trunk/binaries/data/mods/public/gui/manual/manual.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/manual/manual.js (revision 15068)
+++ ps/trunk/binaries/data/mods/public/gui/manual/manual.js (revision 15069)
@@ -1,16 +1,29 @@
var hasCallback = false;
function init(data)
{
- Engine.GetGUIObjectByName("mainText").caption = Engine.TranslateLines(Engine.ReadFile("gui/manual/" + data.page + ".txt"));
+ Engine.GetGUIObjectByName("mainText").caption = Engine.TranslateLines(Engine.ReadFile("gui/" + data.page + ".txt"));
if (data.callback)
hasCallback = true;
+ if (data.title)
+ Engine.GetGUIObjectByName("title").caption = data.title;
+ if (data.url)
+ {
+ var urlButton = Engine.GetGUIObjectByName("url");
+ var callback = function(url)
+ {
+ return function()
+ openURL(url);
+ }(data.url)
+ urlButton.onPress = callback;
+ urlButton.hidden = false;
+ }
}
function closeManual()
{
if (hasCallback)
Engine.PopGuiPageCB();
else
Engine.PopGuiPage();
}
Index: ps/trunk/binaries/data/mods/public/gui/manual/manual.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/manual/manual.xml (revision 15068)
+++ ps/trunk/binaries/data/mods/public/gui/manual/manual.xml (revision 15069)
@@ -1,31 +1,28 @@
-
- Manual
+
+ Information
-
- Online Manual
-
+
+ View Online
Close
Index: ps/trunk/binaries/data/mods/public/gui/pregame/mainmenu.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/pregame/mainmenu.xml (revision 15068)
+++ ps/trunk/binaries/data/mods/public/gui/pregame/mainmenu.xml (revision 15069)
@@ -1,595 +1,595 @@
onTick();
tooltipText
[font="sans-bold-16"]
Help improve 0 A.D.!
[/font]\n
You can automatically send us anonymous feedback that will help us fix bugs, and improve performance and compatibility.
Enable feedback
EnableUserReport(true);
Technical details
- Engine.PushGuiPage("page_manual.xml", { "page": "userreport" });
+ Engine.PushGuiPage("page_manual.xml", {"page":"manual/userreport", "title":translate("Technical Details")});
[font="sans-bold-16"]
Thank you for helping improve 0 A.D.!
[/font]\n\n
Anonymous feedback is currently enabled.
\n
Status: $status.
Disable feedback
EnableUserReport(false);
Technical details
- Engine.PushGuiPage("page_manual.xml", { "page": "userreport" });
+ Engine.PushGuiPage("page_manual.xml", {"page":"manual/userreport", "title":translate("Technical Details")});
closeMenu();
Matches
Click here to start a new single player game.
Engine.SwitchGuiPage("page_gamesetup.xml", { type: "offline" });
Campaigns
Relive history through historical military campaigns. [NOT YET IMPLEMENTED]
closeMenu();
Load Game
Click here to load a saved game.
closeMenu();
Engine.PushGuiPage("page_loadgame.xml", { type: "offline" });
Join Game
Joining an existing multiplayer game.
closeMenu();
// Open Multiplayer connection window with join option.
Engine.PushGuiPage("page_gamesetup_mp.xml", { multiplayerGameType: "join" });
Host Game
Host a multiplayer game.\n\nRequires UDP port 20595 to be open.
closeMenu();
// Open Multiplayer connection window with host option.
Engine.PushGuiPage("page_gamesetup_mp.xml", { multiplayerGameType: "host" });
Game Lobby
Launch the multiplayer lobby.
closeMenu();
// Open Multiplayer game lobby.
Engine.PushGuiPage("page_prelobby.xml", []);
if (!Engine.StartXmppClient)
{
this.enabled = false;
this.tooltip = getLobbyDisabledByBuild();
}
Options
Adjust game settings.
closeMenu();
Language
Choose the language of the game.
Scenario Editor
Open the Atlas Scenario Editor in a new window. You can run this more reliably by starting the game with the command-line argument "-editor".
pressedScenarioEditorButton();
Welcome Screen
Show the Welcome Screen. Useful if you hid it by mistake.
Learn To Play
Open the 0 A.D. Game Manual.
closeMenu();
Single Player
Challenge the computer player to a single player match.
closeMenu();
openMenu("submenuSinglePlayer", (this.parent.size.top+this.size.top), (this.size.bottom-this.size.top), 3);
Multiplayer
Fight against one or more human players in a multiplayer game.
closeMenu();
openMenu("submenuMultiplayer", (this.parent.size.top+this.size.top), (this.size.bottom-this.size.top), 3);
Tools & Options
Game options and scenario design tools.
closeMenu();
openMenu("submenuToolsAndOptions", (this.parent.size.top+this.size.top), (this.size.bottom-this.size.top), 4);
History
Learn about the many civilizations featured in 0 A.D.
closeMenu();
Exit
Exits the game.
exitGamePressed();
[font="sans-bold-16"]
Alpha XV: Osiris
[/font]\n\n
WARNING: This is an early development version of the game. Many features have not been added yet.
\n\n
Get involved at: play0ad.com
Help with the translation!
Click to open the 0 A.D translate page in your browser.
Website
Click to open play0ad.com in your web browser.
Chat
Click to open the 0 A.D. IRC chat in your browser. (#0ad on webchat.quakenet.org)
Report a Bug
Click to visit 0 A.D. Trac to report a bug, crash, or error.
-
WILDFIRE GAMES
this.caption = getBuildString();
Index: ps/trunk/binaries/data/mods/public/gui/session/menu.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/session/menu.js (revision 15068)
+++ ps/trunk/binaries/data/mods/public/gui/session/menu.js (revision 15069)
@@ -1,699 +1,699 @@
const PAUSE = translate("Pause");
const RESUME = translate("Resume");
/*
* MENU POSITION CONSTANTS
*/
// Menu / panel border size
const MARGIN = 4;
// Includes the main menu button
const NUM_BUTTONS = 8;
// Regular menu buttons
const BUTTON_HEIGHT = 32;
// The position where the bottom of the menu will end up (currently 228)
const END_MENU_POSITION = (BUTTON_HEIGHT * NUM_BUTTONS) + MARGIN;
// Menu starting position: bottom
const MENU_BOTTOM = 0;
// Menu starting position: top
const MENU_TOP = MENU_BOTTOM - END_MENU_POSITION;
// Menu starting position: overall
const INITIAL_MENU_POSITION = "100%-164 " + MENU_TOP + " 100% " + MENU_BOTTOM;
// Number of pixels per millisecond to move
const MENU_SPEED = 1.2;
// Trade menu: available resources and step for probability changes
const RESOURCES = ["food", "wood", "stone", "metal"];
const STEP = 5;
var isMenuOpen = false;
var menu;
var isDiplomacyOpen = false;
var isTradeOpen = false;
// Redefined every time someone makes a tribute (so we can save some data in a closure). Called in input.js handleInputBeforeGui.
var flushTributing = function() {};
// Ignore size defined in XML and set the actual menu size here
function initMenuPosition()
{
menu = Engine.GetGUIObjectByName("menu");
menu.size = INITIAL_MENU_POSITION;
}
// =============================================================================
// Overall Menu
// =============================================================================
//
// Slide menu
function updateMenuPosition(dt)
{
if (isMenuOpen)
{
var maxOffset = END_MENU_POSITION - menu.size.bottom;
if (maxOffset > 0)
{
var offset = Math.min(MENU_SPEED * dt, maxOffset);
var size = menu.size;
size.top += offset;
size.bottom += offset;
menu.size = size;
}
}
else
{
var maxOffset = menu.size.top - MENU_TOP;
if (maxOffset > 0)
{
var offset = Math.min(MENU_SPEED * dt, maxOffset);
var size = menu.size;
size.top -= offset;
size.bottom -= offset;
menu.size = size;
}
}
}
// Opens the menu by revealing the screen which contains the menu
function openMenu()
{
isMenuOpen = true;
}
// Closes the menu and resets position
function closeMenu()
{
isMenuOpen = false;
}
function toggleMenu()
{
if (isMenuOpen == true)
closeMenu();
else
openMenu();
}
// Menu buttons
// =============================================================================
function settingsMenuButton()
{
closeMenu();
closeOpenDialogs();
openSettings();
}
function chatMenuButton()
{
closeMenu();
closeOpenDialogs();
openChat();
}
function diplomacyMenuButton()
{
closeMenu();
closeOpenDialogs();
openDiplomacy();
}
function pauseMenuButton()
{
togglePause();
}
function resignMenuButton()
{
closeMenu();
closeOpenDialogs();
pauseGame();
var btCaptions = [translate("Yes"), translate("No")];
var btCode = [resignGame, resumeGame];
messageBox(400, 200, translate("Are you sure you want to resign?"), translate("Confirmation"), 0, btCaptions, btCode);
}
function exitMenuButton()
{
closeMenu();
closeOpenDialogs();
pauseGame();
if (g_IsNetworked && g_IsController)
{
var btCode = [leaveGame, resumeGame];
var message = translate("Are you sure you want to quit? Leaving will disconnect all other players.");
}
else if (g_IsNetworked && !g_GameEnded && !g_IsObserver)
{
var btCode = [networkReturnQuestion, resumeGame];
var message = translate("Are you sure you want to quit?");
}
else
{
var btCode = [leaveGame, resumeGame];
var message = translate("Are you sure you want to quit?");
}
messageBox(400, 200, message, translate("Confirmation"), 0, [translate("Yes"), translate("No")], btCode);
}
function networkReturnQuestion()
{
var btCaptions = [translate("I resign"), translate("I will return")];
var btCode = [leaveGame, leaveGame];
var btArgs = [false, true];
messageBox(400, 200, translate("Do you want to resign or will you return soon?"), translate("Confirmation"), 0, btCaptions, btCode, btArgs);
}
function openDeleteDialog(selection)
{
closeMenu();
closeOpenDialogs();
var deleteSelectedEntities = function (selectionArg)
{
Engine.PostNetworkCommand({"type": "delete-entities", "entities": selectionArg});
};
var btCaptions = [translate("Yes"), translate("No")];
var btCode = [deleteSelectedEntities, resumeGame];
messageBox(400, 200, translate("Destroy everything currently selected?"), translate("Delete"), 0, btCaptions, btCode, [selection, null]);
}
// Menu functions
// =============================================================================
function openSave()
{
closeMenu();
closeOpenDialogs();
pauseGame();
var savedGameData = getSavedGameData();
Engine.PushGuiPage("page_savegame.xml", {"savedGameData": savedGameData, "callback": "resumeGame"});
}
function openSettings()
{
pauseGame();
Engine.PushGuiPage("page_options.xml");
}
function openChat()
{
Engine.GetGUIObjectByName("chatInput").focus(); // Grant focus to the input area
Engine.GetGUIObjectByName("chatDialogPanel").hidden = false;
}
function closeChat()
{
Engine.GetGUIObjectByName("chatInput").caption = ""; // Clear chat input
Engine.GetGUIObjectByName("chatInput").blur(); // Remove focus
Engine.GetGUIObjectByName("chatDialogPanel").hidden = true;
}
function toggleChatWindow(teamChat)
{
var chatWindow = Engine.GetGUIObjectByName("chatDialogPanel");
var chatInput = Engine.GetGUIObjectByName("chatInput");
if (chatWindow.hidden)
chatInput.focus(); // Grant focus to the input area
else
{
if (chatInput.caption.length)
{
submitChatInput();
return;
}
chatInput.caption = ""; // Clear chat input
}
Engine.GetGUIObjectByName("toggleTeamChat").checked = teamChat;
chatWindow.hidden = !chatWindow.hidden;
}
function setDiplomacy(data)
{
Engine.PostNetworkCommand({"type": "diplomacy", "to": data.to, "player": data.player});
}
function tributeResource(data)
{
Engine.PostNetworkCommand({"type": "tribute", "player": data.player, "amounts": data.amounts});
}
function openDiplomacy()
{
if (isTradeOpen)
closeTrade();
isDiplomacyOpen = true;
var we = Engine.GetPlayerID();
var players = getPlayerData(g_PlayerAssignments);
// Get offset for one line
var onesize = Engine.GetGUIObjectByName("diplomacyPlayer[0]").size;
var rowsize = onesize.bottom - onesize.top;
// We don't include gaia
for (var i = 1; i < players.length; i++)
{
// Apply offset
var row = Engine.GetGUIObjectByName("diplomacyPlayer["+(i-1)+"]");
var size = row.size;
size.top = rowsize*(i-1);
size.bottom = rowsize*i;
row.size = size;
// Set background colour
var playerColor = players[i].color.r+" "+players[i].color.g+" "+players[i].color.b;
row.sprite = "colour: "+playerColor + " 32";
Engine.GetGUIObjectByName("diplomacyPlayerName["+(i-1)+"]").caption = "[color=\"" + playerColor + "\"]" + players[i].name + "[/color]";
Engine.GetGUIObjectByName("diplomacyPlayerCiv["+(i-1)+"]").caption = g_CivData[players[i].civ].Name;
Engine.GetGUIObjectByName("diplomacyPlayerTeam["+(i-1)+"]").caption = (players[i].team < 0) ? translateWithContext("team", "None") : players[i].team+1;
if (i != we)
Engine.GetGUIObjectByName("diplomacyPlayerTheirs["+(i-1)+"]").caption = (players[i].isAlly[we] ? translate("Ally") : (players[i].isNeutral[we] ? translate("Neutral") : translate("Enemy")));
// Don't display the options for ourself, or if we or the other player aren't active anymore
if (i == we || players[we].state != "active" || players[i].state != "active")
{
// Hide the unused/unselectable options
for each (var a in ["TributeFood", "TributeWood", "TributeStone", "TributeMetal", "Ally", "Neutral", "Enemy"])
Engine.GetGUIObjectByName("diplomacyPlayer"+a+"["+(i-1)+"]").hidden = true;
continue;
}
// Tribute
for each (var resource in ["food", "wood", "stone", "metal"])
{
var button = Engine.GetGUIObjectByName("diplomacyPlayerTribute"+toTitleCase(resource)+"["+(i-1)+"]");
button.onpress = (function(player, resource, button){
// Implement something like how unit batch training works. Shift+click to send 500, shift+click+click to send 1000, etc.
// Also see input.js (searching for "INPUT_MASSTRIBUTING" should get all the relevant parts).
var multiplier = 1;
return function() {
var isBatchTrainPressed = Engine.HotkeyIsPressed("session.masstribute");
if (isBatchTrainPressed)
{
inputState = INPUT_MASSTRIBUTING;
multiplier += multiplier == 1 ? 4 : 5;
}
var amounts = {
"food": (resource == "food" ? 100 : 0) * multiplier,
"wood": (resource == "wood" ? 100 : 0) * multiplier,
"stone": (resource == "stone" ? 100 : 0) * multiplier,
"metal": (resource == "metal" ? 100 : 0) * multiplier,
};
button.tooltip = formatTributeTooltip(players[player], resource, amounts[resource]);
// This is in a closure so that we have access to `player`, `amounts`, and `multiplier` without some
// evil global variable hackery.
flushTributing = function() {
tributeResource({"player": player, "amounts": amounts});
multiplier = 1;
button.tooltip = formatTributeTooltip(players[player], resource, 100);
};
if (!isBatchTrainPressed)
flushTributing();
};
})(i, resource, button);
button.hidden = false;
button.tooltip = formatTributeTooltip(players[i], resource, 100);
}
// Skip our own teams on teams locked
if (players[we].teamsLocked && players[we].team != -1 && players[we].team == players[i].team)
continue;
// Diplomacy settings
// Set up the buttons
for each (var setting in ["ally", "neutral", "enemy"])
{
var button = Engine.GetGUIObjectByName("diplomacyPlayer"+toTitleCase(setting)+"["+(i-1)+"]");
if (setting == "ally")
{
if (players[we].isAlly[i])
button.caption = translate("x");
else
button.caption = "";
}
else if (setting == "neutral")
{
if (players[we].isNeutral[i])
button.caption = translate("x");
else
button.caption = "";
}
else // "enemy"
{
if (players[we].isEnemy[i])
button.caption = translate("x");
else
button.caption = "";
}
button.onpress = (function(e){ return function() { setDiplomacy(e) } })({"player": i, "to": setting});
button.hidden = false;
}
}
Engine.GetGUIObjectByName("diplomacyDialogPanel").hidden = false;
}
function closeDiplomacy()
{
isDiplomacyOpen = false;
Engine.GetGUIObjectByName("diplomacyDialogPanel").hidden = true;
}
function toggleDiplomacy()
{
if (isDiplomacyOpen)
closeDiplomacy();
else
openDiplomacy();
}
function openTrade()
{
if (isDiplomacyOpen)
closeDiplomacy();
isTradeOpen = true;
var updateButtons = function()
{
for (var res in button)
{
button[res].label.caption = proba[res] + "%";
if (res == selec)
{
button[res].res.enabled = false;
button[res].sel.hidden = false;
button[res].up.hidden = true;
button[res].dn.hidden = true;
}
else
{
button[res].res.enabled = true;
button[res].sel.hidden = true;
button[res].up.hidden = (proba[res] == 100 || proba[selec] == 0);
button[res].dn.hidden = (proba[res] == 0 || proba[selec] == 100);
}
}
}
var proba = Engine.GuiInterfaceCall("GetTradingGoods");
var button = {};
var selec = RESOURCES[0];
for (var i = 0; i < RESOURCES.length; ++i)
{
var buttonResource = Engine.GetGUIObjectByName("tradeResource["+i+"]");
if (i > 0)
{
var size = Engine.GetGUIObjectByName("tradeResource["+(i-1)+"]").size;
var width = size.right - size.left;
size.left += width;
size.right += width;
Engine.GetGUIObjectByName("tradeResource["+i+"]").size = size;
}
var resource = RESOURCES[i];
proba[resource] = (proba[resource] ? proba[resource] : 0);
var buttonResource = Engine.GetGUIObjectByName("tradeResourceButton["+i+"]");
var icon = Engine.GetGUIObjectByName("tradeResourceIcon["+i+"]");
icon.sprite = "stretched:session/icons/resources/" + resource + ".png";
var label = Engine.GetGUIObjectByName("tradeResourceText["+i+"]");
var buttonUp = Engine.GetGUIObjectByName("tradeArrowUp["+i+"]");
var buttonDn = Engine.GetGUIObjectByName("tradeArrowDn["+i+"]");
var iconSel = Engine.GetGUIObjectByName("tradeResourceSelection["+i+"]");
button[resource] = { "res": buttonResource, "up": buttonUp, "dn": buttonDn, "label": label, "sel": iconSel };
buttonResource.onpress = (function(resource){
return function() {
if (selec == resource)
return;
selec = resource;
updateButtons();
}
})(resource);
buttonUp.onpress = (function(resource){
return function() {
proba[resource] += Math.min(STEP, proba[selec]);
proba[selec] -= Math.min(STEP, proba[selec]);
Engine.PostNetworkCommand({"type": "set-trading-goods", "tradingGoods": proba});
updateButtons();
}
})(resource);
buttonDn.onpress = (function(resource){
return function() {
proba[selec] += Math.min(STEP, proba[resource]);
proba[resource] -= Math.min(STEP, proba[resource]);
Engine.PostNetworkCommand({"type": "set-trading-goods", "tradingGoods": proba});
updateButtons();
}
})(resource);
}
updateButtons();
var traderNumber = Engine.GuiInterfaceCall("GetTraderNumber");
var caption = "";
if (traderNumber.landTrader.total == 0)
caption = translate("There are no land traders.");
else
{
var inactive = traderNumber.landTrader.total - traderNumber.landTrader.trading - traderNumber.landTrader.garrisoned;
var inactiveString = "";
if (inactive > 0)
inactiveString = "[color=\"orange\"]" + sprintf(translatePlural("%(numberOfLandTraders)s inactive", "%(numberOfLandTraders)s inactive", inactive), { numberOfLandTraders: inactive }) + "[/color]";
if (traderNumber.landTrader.trading > 0)
{
var openingTradingString = sprintf(translatePlural("There is %(numberTrading)s land trader trading", "There are %(numberTrading)s land traders trading", traderNumber.landTrader.trading), { numberTrading: traderNumber.landTrader.trading });
if (traderNumber.landTrader.garrisoned > 0)
{
var garrisonedString = sprintf(translatePlural("%(numberGarrisoned)s garrisoned on a trading merchant ship", "%(numberGarrisoned)s garrisoned on a trading merchant ship", traderNumber.landTrader.garrisoned), { numberGarrisoned: traderNumber.landTrader.garrisoned });
if (inactive > 0)
{
caption = sprintf(translate("%(openingTradingString)s, %(garrisonedString)s, and %(inactiveString)s."), {
openingTradingString: openingTradingString,
garrisonedString: garrisonedString,
inactiveString: inactiveString
});
}
else
{
caption = sprintf(translate("%(openingTradingString)s, and %(garrisonedString)s."), {
openingTradingString: openingTradingString,
garrisonedString: garrisonedString
});
}
}
else
{
if (inactive > 0)
{
caption = sprintf(translate("%(openingTradingString)s, and %(inactiveString)s."), {
openingTradingString: openingTradingString,
inactiveString: inactiveString
});
}
else
{
caption = sprintf(translate("%(openingTradingString)s."), {
openingTradingString: openingTradingString,
});
}
}
}
else
{
if (traderNumber.landTrader.garrisoned > 0)
{
var openingGarrisonedString = sprintf(translatePlural("There is %(numberGarrisoned)s land trader garrisoned on a trading merchant ship", "There are %(numberGarrisoned)s land traders garrisoned on a trading merchant ship", traderNumber.landTrader.garrisoned), { numberGarrisoned: traderNumber.landTrader.garrisoned });
if (inactive > 0)
{
caption = sprintf(translate("%(openingGarrisonedString)s, and %(inactiveString)s."), {
openingGarrisonedString: openingGarrisonedString,
inactiveString: inactiveString
});
}
else
{
caption = sprintf(translate("%(openingGarrisonedString)s."), {
openingGarrisonedString: openingGarrisonedString
});
}
}
else
{
if (inactive > 0)
{
inactiveString = "[color=\"orange\"]" + sprintf(translatePlural("%(numberOfLandTraders)s land trader inactive", "%(numberOfLandTraders)s land traders inactive", inactive), { numberOfLandTraders: inactive }) + "[/color]";
caption = sprintf(translatePlural("There is %(inactiveString)s.", "There are %(inactiveString)s.", inactive), {
inactiveString: inactiveString
});
}
// The “else” here is already handled by “if (traderNumber.landTrader.total == 0)” above.
}
}
}
Engine.GetGUIObjectByName("landTraders").caption = caption;
caption = "";
if (traderNumber.shipTrader.total == 0)
caption = translate("There are no merchant ships.");
else
{
var inactive = traderNumber.shipTrader.total - traderNumber.shipTrader.trading;
var inactiveString = "";
if (inactive > 0)
inactiveString = "[color=\"orange\"]" + sprintf(translatePlural("%(numberOfShipTraders)s inactive", "%(numberOfShipTraders)s inactive", inactive), { numberOfShipTraders: inactive }) + "[/color]";
if (traderNumber.shipTrader.trading > 0)
{
var openingTradingString = sprintf(translatePlural("There is %(numberTrading)s merchant ship trading", "There are %(numberTrading)s merchant ships trading", traderNumber.shipTrader.trading), { numberTrading: traderNumber.shipTrader.trading });
if (inactive > 0)
{
caption = sprintf(translate("%(openingTradingString)s, and %(inactiveString)s."), {
openingTradingString: openingTradingString,
inactiveString: inactiveString
});
}
else
{
caption = sprintf(translate("%(openingTradingString)s."), {
openingTradingString: openingTradingString,
});
}
}
else
{
if (inactive > 0)
{
inactiveString = "[color=\"orange\"]" + sprintf(translatePlural("%(numberOfShipTraders)s merchant ship inactive", "%(numberOfShipTraders)s merchant ships inactive", inactive), { numberOfShipTraders: inactive }) + "[/color]";
caption = sprintf(translatePlural("There is %(inactiveString)s.", "There are %(inactiveString)s.", inactive), {
inactiveString: inactiveString
});
}
// The “else” here is already handled by “if (traderNumber.shipTrader.total == 0)” above.
}
}
Engine.GetGUIObjectByName("shipTraders").caption = caption;
Engine.GetGUIObjectByName("tradeDialogPanel").hidden = false;
}
function closeTrade()
{
isTradeOpen = false;
Engine.GetGUIObjectByName("tradeDialogPanel").hidden = true;
}
function toggleTrade()
{
if (isTradeOpen)
closeTrade();
else
openTrade();
}
function toggleGameSpeed()
{
var gameSpeed = Engine.GetGUIObjectByName("gameSpeed");
gameSpeed.hidden = !gameSpeed.hidden;
}
/**
* Pause the game in single player mode.
*/
function pauseGame()
{
if (g_IsNetworked)
return;
Engine.GetGUIObjectByName("pauseButtonText").caption = RESUME;
Engine.GetGUIObjectByName("pauseOverlay").hidden = false;
Engine.SetPaused(true);
}
function resumeGame()
{
Engine.GetGUIObjectByName("pauseButtonText").caption = PAUSE;
Engine.GetGUIObjectByName("pauseOverlay").hidden = true;
Engine.SetPaused(false);
}
function togglePause()
{
closeMenu();
closeOpenDialogs();
var pauseOverlay = Engine.GetGUIObjectByName("pauseOverlay");
if (pauseOverlay.hidden)
{
Engine.GetGUIObjectByName("pauseButtonText").caption = RESUME;
Engine.SetPaused(true);
}
else
{
Engine.SetPaused(false);
Engine.GetGUIObjectByName("pauseButtonText").caption = PAUSE;
}
pauseOverlay.hidden = !pauseOverlay.hidden;
}
function openManual()
{
closeMenu();
closeOpenDialogs();
pauseGame();
- Engine.PushGuiPage("page_manual.xml", {"page": "intro", "callback": "resumeGame"});
+ Engine.PushGuiPage("page_manual.xml", {"page": "intro", "title":translate("Manual"), "url":"http://trac.wildfiregames.com/wiki/0adManual", "callback": "resumeGame"});
}
function toggleDeveloperOverlay()
{
if (Engine.HasXmppClient() && Engine.IsRankedGame())
return;
var devCommands = Engine.GetGUIObjectByName("devCommands");
if (devCommands.hidden)
submitChatDirectly(translate("The Developer Overlay was opened."));
else
submitChatDirectly(translate("The Developer Overlay was closed."));
// Update the options dialog
devCommands.hidden = !devCommands.hidden;
// Save the changes
Engine.ConfigDB_CreateValue("user", "developeroverlay.enable", String(!devCommands.hidden) );
}
function closeOpenDialogs()
{
closeMenu();
closeChat();
closeDiplomacy();
closeTrade();
}
function formatTributeTooltip(player, resource, amount)
{
var playerColor = player.color.r + " " + player.color.g + " " + player.color.b;
return sprintf(translate("Tribute %(resourceAmount)s %(resourceType)s to %(playerName)s. Shift-click to tribute %(greaterAmount)s."), {
resourceAmount: amount,
resourceType: getLocalizedResourceName(resource, "withinSentence"),
playerName: "[color=\"" + playerColor + "\"]" + player.name + "[/color]",
greaterAmount: (amount < 500 ? 500 : amount + 500)
});
}