Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/gamesetup.js
Show First 20 Lines • Show All 1,002 Lines • ▼ Show 20 Lines | var g_MiscControls = { | ||||
"civResetButton": { | "civResetButton": { | ||||
"hidden": () => g_GameAttributes.mapType == "scenario" || !g_IsController, | "hidden": () => g_GameAttributes.mapType == "scenario" || !g_IsController, | ||||
}, | }, | ||||
"teamResetButton": { | "teamResetButton": { | ||||
"hidden": () => g_GameAttributes.mapType == "scenario" || !g_IsController, | "hidden": () => g_GameAttributes.mapType == "scenario" || !g_IsController, | ||||
}, | }, | ||||
"lobbyButton": { | "lobbyButton": { | ||||
"onPress": () => function() { | "onPress": () => function() { | ||||
if (Engine.HasXmppClient()) | if (!Engine.HasXmppClient()) | ||||
Engine.PushGuiPage("page_lobby.xml", { "dialog": true }); | return; | ||||
setLobbyButtonIcon(false); | |||||
g_LobbyDialogOpened = true; | |||||
Engine.PushGuiPage("page_lobby.xml", { "dialog": true, "callback": "setLobbyDialogClosed" }); | |||||
}, | }, | ||||
"hidden": () => !Engine.HasXmppClient() | "hidden": () => !Engine.HasXmppClient() | ||||
}, | }, | ||||
"spTips": { | "spTips": { | ||||
"hidden": () => { | "hidden": () => { | ||||
let settingsPanel = Engine.GetGUIObjectByName("settingsPanel"); | let settingsPanel = Engine.GetGUIObjectByName("settingsPanel"); | ||||
let spTips = Engine.GetGUIObjectByName("spTips"); | let spTips = Engine.GetGUIObjectByName("spTips"); | ||||
return g_IsNetworked || | return g_IsNetworked || | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | function init(attribs) | ||||
g_IsNetworked = attribs.type != "offline"; | g_IsNetworked = attribs.type != "offline"; | ||||
g_IsController = attribs.type != "client"; | g_IsController = attribs.type != "client"; | ||||
g_IsTutorial = !!attribs.tutorial; | g_IsTutorial = !!attribs.tutorial; | ||||
g_ServerName = attribs.serverName; | g_ServerName = attribs.serverName; | ||||
g_ServerPort = attribs.serverPort; | g_ServerPort = attribs.serverPort; | ||||
g_StunEndpoint = attribs.stunEndpoint; | g_StunEndpoint = attribs.stunEndpoint; | ||||
setLobbyButtonIcon(false); | |||||
if (Engine.HasXmppClient()) | |||||
g_UpdateLobbyNotification = setLobbyButtonIcon; | |||||
if (!g_IsNetworked) | if (!g_IsNetworked) | ||||
g_PlayerAssignments = { | g_PlayerAssignments = { | ||||
"local": { | "local": { | ||||
"name": singleplayerName(), | "name": singleplayerName(), | ||||
"player": 1 | "player": 1 | ||||
} | } | ||||
}; | }; | ||||
// Replace empty playername when entering a singleplayermatch for the first time | // Replace empty playername when entering a singleplayermatch for the first time | ||||
if (!g_IsNetworked) | if (!g_IsNetworked) | ||||
{ | { | ||||
Engine.ConfigDB_CreateValue("user", "playername.singleplayer", singleplayerName()); | Engine.ConfigDB_CreateValue("user", "playername.singleplayer", singleplayerName()); | ||||
Engine.ConfigDB_WriteValueToFile("user", "playername.singleplayer", singleplayerName(), "config/user.cfg"); | Engine.ConfigDB_WriteValueToFile("user", "playername.singleplayer", singleplayerName(), "config/user.cfg"); | ||||
} | } | ||||
initDefaults(); | initDefaults(); | ||||
supplementDefaults(); | supplementDefaults(); | ||||
setTimeout(displayGamestateNotifications, 1000); | setTimeout(displayGamestateNotifications, 1000); | ||||
} | } | ||||
function setLobbyButtonIcon(notify) | |||||
{ | |||||
Engine.GetGUIObjectByName("lobbyButton").sprite = notify ? "iconBubbleWhite" : "iconBubbleGold"; | |||||
Engine.GetGUIObjectByName("lobbyButton").tooltip = | |||||
sprintf(translate("Show the multiplayer lobby in a dialog window. %(notification)s"), { | |||||
"notification": notify ? translate("(You have new lobby notifications.)") : "" | |||||
}); | |||||
if (notify) | |||||
Engine.GetGUIObjectByName("onscreenToolTip").caption = translate("You have new lobby notifications. (Click the lobby icon button.)"); | |||||
} | |||||
function initDefaults() | function initDefaults() | ||||
{ | { | ||||
// Remove gaia from both arrays | // Remove gaia from both arrays | ||||
g_DefaultPlayerData = clone(g_Settings.PlayerDefaults.slice(1)); | g_DefaultPlayerData = clone(g_Settings.PlayerDefaults.slice(1)); | ||||
let aiDifficulty = +Engine.ConfigDB_GetValue("user", "gui.gamesetup.aidifficulty"); | let aiDifficulty = +Engine.ConfigDB_GetValue("user", "gui.gamesetup.aidifficulty"); | ||||
let aiBehavior = Engine.ConfigDB_GetValue("user", "gui.gamesetup.aibehavior"); | let aiBehavior = Engine.ConfigDB_GetValue("user", "gui.gamesetup.aibehavior"); | ||||
▲ Show 20 Lines • Show All 786 Lines • ▼ Show 20 Lines | function onTick() | ||||
if (g_LoadingState == 0) | if (g_LoadingState == 0) | ||||
++g_LoadingState; | ++g_LoadingState; | ||||
else if (g_LoadingState == 1) | else if (g_LoadingState == 1) | ||||
{ | { | ||||
initGUIObjects(); | initGUIObjects(); | ||||
++g_LoadingState; | ++g_LoadingState; | ||||
} | } | ||||
else if (g_LoadingState == 2) | else if (g_LoadingState == 2) | ||||
{ | |||||
handleNetMessages(); | handleNetMessages(); | ||||
handleNetLobbyMessagesInBackground(); | |||||
} | |||||
updateTimers(); | updateTimers(); | ||||
let now = Date.now(); | let now = Date.now(); | ||||
let tickLength = now - g_LastTickTime; | let tickLength = now - g_LastTickTime; | ||||
g_LastTickTime = now; | g_LastTickTime = now; | ||||
updateSettingsPanelPosition(tickLength); | updateSettingsPanelPosition(tickLength); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 760 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator