Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/gamesetup.js
Show First 20 Lines • Show All 913 Lines • ▼ Show 20 Lines | "disableSpies": { | ||||
g_GameAttributes.settings.DisableSpies = checked; | g_GameAttributes.settings.DisableSpies = checked; | ||||
}, | }, | ||||
"enabled": () => g_GameAttributes.mapType != "scenario", | "enabled": () => g_GameAttributes.mapType != "scenario", | ||||
"initOrder": 1000 | "initOrder": 1000 | ||||
}, | }, | ||||
"lockTeams": { | "lockTeams": { | ||||
"title": () => translate("Teams Locked"), | "title": () => translate("Teams Locked"), | ||||
"tooltip": () => translate("Toggle locked teams."), | "tooltip": () => translate("Toggle locked teams."), | ||||
"default": () => Engine.HasXmppClient(), | "default": () => Engine.HasXmppClient && Engine.HasXmppClient(), | ||||
"defined": () => g_GameAttributes.settings.LockTeams !== undefined, | "defined": () => g_GameAttributes.settings.LockTeams !== undefined, | ||||
"get": () => g_GameAttributes.settings.LockTeams, | "get": () => g_GameAttributes.settings.LockTeams, | ||||
"set": checked => { | "set": checked => { | ||||
g_GameAttributes.settings.LockTeams = checked; | g_GameAttributes.settings.LockTeams = checked; | ||||
g_GameAttributes.settings.LastManStanding = false; | g_GameAttributes.settings.LastManStanding = false; | ||||
}, | }, | ||||
"enabled": () => | "enabled": () => | ||||
g_GameAttributes.mapType != "scenario" && | g_GameAttributes.mapType != "scenario" && | ||||
Show All 23 Lines | "enableCheats": { | ||||
"get": () => g_GameAttributes.settings.CheatsEnabled, | "get": () => g_GameAttributes.settings.CheatsEnabled, | ||||
"set": checked => { | "set": checked => { | ||||
g_GameAttributes.settings.CheatsEnabled = !g_IsNetworked || | g_GameAttributes.settings.CheatsEnabled = !g_IsNetworked || | ||||
checked && !g_GameAttributes.settings.RatingEnabled; | checked && !g_GameAttributes.settings.RatingEnabled; | ||||
}, | }, | ||||
"enabled": () => !g_GameAttributes.settings.RatingEnabled, | "enabled": () => !g_GameAttributes.settings.RatingEnabled, | ||||
"initOrder": 1000 | "initOrder": 1000 | ||||
}, | }, | ||||
}, | |||||
Engine.HasXmppClient && { | |||||
"enableRating": { | "enableRating": { | ||||
"title": () => translate("Rated Game"), | "title": () => translate("Rated Game"), | ||||
"tooltip": () => translate("Toggle if this game will be rated for the leaderboard."), | "tooltip": () => translate("Toggle if this game will be rated for the leaderboard."), | ||||
"default": () => Engine.HasXmppClient(), | "default": () => Engine.HasXmppClient(), | ||||
"hidden": () => !Engine.HasXmppClient(), | "hidden": () => !Engine.HasXmppClient(), | ||||
"defined": () => g_GameAttributes.settings.RatingEnabled !== undefined, | "defined": () => g_GameAttributes.settings.RatingEnabled !== undefined, | ||||
"get": () => !!g_GameAttributes.settings.RatingEnabled, | "get": () => !!g_GameAttributes.settings.RatingEnabled, | ||||
"set": checked => { | "set": checked => { | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | "mapPreview": { | ||||
} | } | ||||
}, | }, | ||||
"cheatWarningText": { | "cheatWarningText": { | ||||
"hidden": () => !g_IsNetworked || !g_GameAttributes.settings.CheatsEnabled, | "hidden": () => !g_IsNetworked || !g_GameAttributes.settings.CheatsEnabled, | ||||
}, | }, | ||||
"cancelGame": { | "cancelGame": { | ||||
"caption": () => translate("Back"), | "caption": () => translate("Back"), | ||||
"tooltip": () => | "tooltip": () => | ||||
Engine.HasXmppClient() ? | Engine.HasXmppClient && Engine.HasXmppClient() ? | ||||
translate("Return to the lobby.") : | translate("Return to the lobby.") : | ||||
translate("Return to the main menu."), | translate("Return to the main menu."), | ||||
"onPress": () => cancelSetup, | "onPress": () => cancelSetup, | ||||
"size": () => { | "size": () => { | ||||
// Right align the button | // Right align the button | ||||
let offset = 10; | let offset = 10; | ||||
let startGame = Engine.GetGUIObjectByName("startGame"); | let startGame = Engine.GetGUIObjectByName("startGame"); | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | "onPress": () => function() { | ||||
g_GameAttributes.settings.PlayerData[i].Team = -1; | g_GameAttributes.settings.PlayerData[i].Team = -1; | ||||
updateGameAttributes(); | updateGameAttributes(); | ||||
}, | }, | ||||
"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.HasXmppClient()) | ||||
Engine.PushGuiPage("page_lobby.xml", { "dialog": true }); | Engine.PushGuiPage("page_lobby.xml", { "dialog": true }); | ||||
}, | }, | ||||
"hidden": () => !Engine.HasXmppClient() | "hidden": () => !Engine.HasXmppClient || !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 || | ||||
Engine.ConfigDB_GetValue("user", "gui.gamesetup.enabletips") !== "true" || | Engine.ConfigDB_GetValue("user", "gui.gamesetup.enabletips") !== "true" || | ||||
spTips.size.right > settingsPanel.getComputedSize().left; | spTips.size.right > settingsPanel.getComputedSize().left; | ||||
▲ Show 20 Lines • Show All 476 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/** | /** | ||||
* Called after every player is ready and the host decided to finally start the game. | * Called after every player is ready and the host decided to finally start the game. | ||||
*/ | */ | ||||
function handleGamestartMessage(message) | function handleGamestartMessage(message) | ||||
{ | { | ||||
// Immediately inform the lobby server instead of waiting for the load to finish | // Immediately inform the lobby server instead of waiting for the load to finish | ||||
if (g_IsController && Engine.HasXmppClient()) | if (g_IsController && Engine.HasXmppClient && Engine.HasXmppClient()) | ||||
{ | { | ||||
sendRegisterGameStanzaImmediate(); | sendRegisterGameStanzaImmediate(); | ||||
let clients = formatClientsForStanza(); | let clients = formatClientsForStanza(); | ||||
Engine.SendChangeStateGame(clients.connectedPlayers, clients.list); | Engine.SendChangeStateGame(clients.connectedPlayers, clients.list); | ||||
} | } | ||||
Engine.SwitchGuiPage("page_loading.xml", { | Engine.SwitchGuiPage("page_loading.xml", { | ||||
"attribs": g_GameAttributes, | "attribs": g_GameAttributes, | ||||
▲ Show 20 Lines • Show All 338 Lines • ▼ Show 20 Lines | function loadPersistMatchSettings() | ||||
if (mapSettings.PlayerData) | if (mapSettings.PlayerData) | ||||
sanitizePlayerData(mapSettings.PlayerData); | sanitizePlayerData(mapSettings.PlayerData); | ||||
// Reload, as the maptype or mapfilter might have changed | // Reload, as the maptype or mapfilter might have changed | ||||
reloadMapFilterList(); | reloadMapFilterList(); | ||||
reloadMapSpecific(); | reloadMapSpecific(); | ||||
if (Engine.HasXmppClient) | |||||
{ | |||||
g_GameAttributes.settings.RatingEnabled = Engine.HasXmppClient(); | g_GameAttributes.settings.RatingEnabled = Engine.HasXmppClient(); | ||||
Engine.SetRankedGame(g_GameAttributes.settings.RatingEnabled); | Engine.SetRankedGame(g_GameAttributes.settings.RatingEnabled); | ||||
} | |||||
supplementDefaults(); | supplementDefaults(); | ||||
g_IsInGuiUpdate = false; | g_IsInGuiUpdate = false; | ||||
} | } | ||||
function savePersistMatchSettings() | function savePersistMatchSettings() | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
function cancelSetup() | function cancelSetup() | ||||
{ | { | ||||
if (g_IsController) | if (g_IsController) | ||||
savePersistMatchSettings(); | savePersistMatchSettings(); | ||||
Engine.DisconnectNetworkGame(); | Engine.DisconnectNetworkGame(); | ||||
if (Engine.HasXmppClient()) | if (Engine.HasXmppClient && Engine.HasXmppClient()) | ||||
{ | { | ||||
Engine.LobbySetPlayerPresence("available"); | Engine.LobbySetPlayerPresence("available"); | ||||
if (g_IsController) | if (g_IsController) | ||||
Engine.SendUnregisterGame(); | Engine.SendUnregisterGame(); | ||||
Engine.SwitchGuiPage("page_lobby.xml", { "dialog": false }); | Engine.SwitchGuiPage("page_lobby.xml", { "dialog": false }); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 640 Lines • ▼ Show 20 Lines | function formatClientsForStanza() | ||||
}; | }; | ||||
} | } | ||||
/** | /** | ||||
* Send the relevant gamesettings to the lobbybot immediately. | * Send the relevant gamesettings to the lobbybot immediately. | ||||
*/ | */ | ||||
function sendRegisterGameStanzaImmediate() | function sendRegisterGameStanzaImmediate() | ||||
{ | { | ||||
if (!g_IsController || !Engine.HasXmppClient()) | if (!g_IsController || !Engine.HasXmppClient || !Engine.HasXmppClient()) | ||||
return; | return; | ||||
if (g_GameStanzaTimer !== undefined) | if (g_GameStanzaTimer !== undefined) | ||||
{ | { | ||||
clearTimeout(g_GameStanzaTimer); | clearTimeout(g_GameStanzaTimer); | ||||
g_GameStanzaTimer = undefined; | g_GameStanzaTimer = undefined; | ||||
} | } | ||||
Show All 24 Lines | function sendRegisterGameStanzaImmediate() | ||||
Engine.SendRegisterGame(stanza); | Engine.SendRegisterGame(stanza); | ||||
} | } | ||||
/** | /** | ||||
* Send the relevant gamesettings to the lobbybot in a deferred manner. | * Send the relevant gamesettings to the lobbybot in a deferred manner. | ||||
*/ | */ | ||||
function sendRegisterGameStanza() | function sendRegisterGameStanza() | ||||
{ | { | ||||
if (!g_IsController || !Engine.HasXmppClient()) | if (!g_IsController || !Engine.HasXmppClient || !Engine.HasXmppClient()) | ||||
return; | return; | ||||
if (g_GameStanzaTimer !== undefined) | if (g_GameStanzaTimer !== undefined) | ||||
clearTimeout(g_GameStanzaTimer); | clearTimeout(g_GameStanzaTimer); | ||||
g_GameStanzaTimer = setTimeout(sendRegisterGameStanzaImmediate, g_GameStanzaTimeout * 1000); | g_GameStanzaTimer = setTimeout(sendRegisterGameStanzaImmediate, g_GameStanzaTimeout * 1000); | ||||
} | } | ||||
Show All 10 Lines |
Wildfire Games · Phabricator