Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/gamesetup/gamesetup.js
Show First 20 Lines • Show All 2,431 Lines • ▼ Show 20 Lines | function updateGUIObjects() | ||||
distributeSettings(); | distributeSettings(); | ||||
g_IsInGuiUpdate = false; | g_IsInGuiUpdate = false; | ||||
// Refresh AI config page | // Refresh AI config page | ||||
if (g_LastViewedAIPlayer != -1) | if (g_LastViewedAIPlayer != -1) | ||||
{ | { | ||||
let playerIndex = g_LastViewedAIPlayer; | |||||
Engine.PopGuiPage(); | Engine.PopGuiPage(); | ||||
openAIConfig(g_LastViewedAIPlayer); | openAIConfig(playerIndex); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Broadcast the changed settings to all clients and the lobbybot. | * Broadcast the changed settings to all clients and the lobbybot. | ||||
*/ | */ | ||||
function updateGameAttributes() | function updateGameAttributes() | ||||
{ | { | ||||
if (g_IsInGuiUpdate || !g_IsController) | if (g_IsInGuiUpdate || !g_IsController) | ||||
return; | return; | ||||
if (g_IsNetworked) | if (g_IsNetworked) | ||||
{ | { | ||||
Engine.SetNetworkGameAttributes(g_GameAttributes); | Engine.SetNetworkGameAttributes(g_GameAttributes); | ||||
if (g_LoadingState >= 2) | if (g_LoadingState >= 2) | ||||
sendRegisterGameStanza(); | sendRegisterGameStanza(); | ||||
resetReadyData(); | resetReadyData(); | ||||
} | } | ||||
else | else | ||||
updateGUIObjects(); | updateGUIObjects(); | ||||
} | } | ||||
function openAIConfig(playerSlot) | function openAIConfig(playerSlot) | ||||
{ | { | ||||
if (!g_GameAttributes.settings.PlayerData[playerSlot]) | |||||
return; | |||||
g_LastViewedAIPlayer = playerSlot; | g_LastViewedAIPlayer = playerSlot; | ||||
Engine.PushGuiPage( | Engine.PushGuiPage( | ||||
"page_aiconfig.xml", | "page_aiconfig.xml", | ||||
{ | { | ||||
"playerSlot": playerSlot, | "playerSlot": playerSlot, | ||||
"id": g_GameAttributes.settings.PlayerData[playerSlot].AI, | "id": g_GameAttributes.settings.PlayerData[playerSlot].AI, | ||||
"difficulty": g_GameAttributes.settings.PlayerData[playerSlot].AIDiff, | "difficulty": g_GameAttributes.settings.PlayerData[playerSlot].AIDiff, | ||||
"behavior": g_GameAttributes.settings.PlayerData[playerSlot].AIBehavior | "behavior": g_GameAttributes.settings.PlayerData[playerSlot].AIBehavior | ||||
}, | }, | ||||
ai => { | ai => { | ||||
g_LastViewedAIPlayer = -1; | g_LastViewedAIPlayer = -1; | ||||
if (!ai.save || !g_IsController) | if (!ai || !ai.save || !g_IsController) | ||||
return; | return; | ||||
g_GameAttributes.settings.PlayerData[ai.playerSlot].AI = ai.id; | g_GameAttributes.settings.PlayerData[ai.playerSlot].AI = ai.id; | ||||
g_GameAttributes.settings.PlayerData[ai.playerSlot].AIDiff = ai.difficulty; | g_GameAttributes.settings.PlayerData[ai.playerSlot].AIDiff = ai.difficulty; | ||||
g_GameAttributes.settings.PlayerData[ai.playerSlot].AIBehavior = ai.behavior; | g_GameAttributes.settings.PlayerData[ai.playerSlot].AIBehavior = ai.behavior; | ||||
updateGameAttributes(); | updateGameAttributes(); | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 285 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator