Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/menu.js
Show First 20 Lines • Show All 230 Lines • ▼ Show 20 Lines | function openDeleteDialog(selection) | ||||
); | ); | ||||
} | } | ||||
function openSave() | function openSave() | ||||
{ | { | ||||
closeOpenDialogs(); | closeOpenDialogs(); | ||||
pauseGame(); | pauseGame(); | ||||
Engine.PushGuiPage("page_savegame.xml", { | Engine.PushGuiPage( | ||||
"page_savegame.xml", | |||||
{ | |||||
"savedGameData": getSavedGameData(), | "savedGameData": getSavedGameData(), | ||||
"callback": "resumeGame" | }, | ||||
}); | resumeGame); | ||||
} | } | ||||
function openOptions() | function openOptions() | ||||
{ | { | ||||
closeOpenDialogs(); | closeOpenDialogs(); | ||||
pauseGame(); | pauseGame(); | ||||
Engine.PushGuiPage("page_options.xml", { | Engine.PushGuiPage( | ||||
"callback": "optionsPageClosed" | "page_options.xml", | ||||
}); | {}, | ||||
} | callbackFunctionNames => { | ||||
for (let functionName of callbackFunctionNames) | |||||
function optionsPageClosed(data) | if (global[functionName]) | ||||
{ | global[functionName](); | ||||
for (let callback of data) | |||||
if (global[callback]) | |||||
global[callback](); | |||||
resumeGame(); | resumeGame(); | ||||
}); | |||||
} | } | ||||
function openChat(command = "") | function openChat(command = "") | ||||
{ | { | ||||
if (g_Disconnected) | if (g_Disconnected) | ||||
return; | return; | ||||
closeOpenDialogs(); | closeOpenDialogs(); | ||||
▲ Show 20 Lines • Show All 826 Lines • ▼ Show 20 Lines | |||||
* If they have shared ally vision researched, they are able to see the summary of there allies too. | * If they have shared ally vision researched, they are able to see the summary of there allies too. | ||||
*/ | */ | ||||
function openGameSummary() | function openGameSummary() | ||||
{ | { | ||||
closeOpenDialogs(); | closeOpenDialogs(); | ||||
pauseGame(); | pauseGame(); | ||||
let extendedSimState = Engine.GuiInterfaceCall("GetExtendedSimulationState"); | let extendedSimState = Engine.GuiInterfaceCall("GetExtendedSimulationState"); | ||||
Engine.PushGuiPage("page_summary.xml", { | Engine.PushGuiPage( | ||||
"page_summary.xml", | |||||
{ | |||||
"sim": { | "sim": { | ||||
"mapSettings": g_GameAttributes.settings, | "mapSettings": g_GameAttributes.settings, | ||||
"playerStates": extendedSimState.players.filter((state, player) => | "playerStates": extendedSimState.players.filter((state, player) => | ||||
g_IsObserver || player == 0 || player == g_ViewedPlayer || | g_IsObserver || player == 0 || player == g_ViewedPlayer || | ||||
extendedSimState.players[g_ViewedPlayer].hasSharedLos && g_Players[player].isMutualAlly[g_ViewedPlayer]), | extendedSimState.players[g_ViewedPlayer].hasSharedLos && g_Players[player].isMutualAlly[g_ViewedPlayer]), | ||||
"timeElapsed": extendedSimState.timeElapsed | "timeElapsed": extendedSimState.timeElapsed | ||||
}, | }, | ||||
"gui": { | "gui": { | ||||
"dialog": true, | "dialog": true, | ||||
"isInGame": true | "isInGame": true | ||||
}, | }, | ||||
"selectedData": g_SummarySelectedData, | "selectedData": g_SummarySelectedData | ||||
"callback": "resumeGameAndSaveSummarySelectedData" | }, | ||||
}); | resumeGameAndSaveSummarySelectedData); | ||||
} | } | ||||
function openStrucTree() | function openStrucTree(page) | ||||
{ | { | ||||
closeOpenDialogs(); | closeOpenDialogs(); | ||||
pauseGame(); | pauseGame(); | ||||
// TODO add info about researched techs and unlocked entities | // TODO add info about researched techs and unlocked entities | ||||
Engine.PushGuiPage( | |||||
Engine.PushGuiPage(g_CivInfo.page, { | page, | ||||
"civ": g_CivInfo.code || g_Players[g_ViewedPlayer].civ, | |||||
"callback": "storeCivInfoPage" | |||||
}); | |||||
} | |||||
function storeCivInfoPage(data) | |||||
{ | { | ||||
"civ": g_CivInfo.code || g_Players[g_ViewedPlayer].civ | |||||
}, | |||||
data => { | |||||
g_CivInfo.code = data.civ; | g_CivInfo.code = data.civ; | ||||
g_CivInfo.page = data.page; | |||||
if (data.lastPage) | |||||
g_CivInfo.page = data.lastPage; | |||||
if (data.nextPage) | |||||
openStrucTree(data.nextPage) | |||||
else | |||||
resumeGame(); | resumeGame(); | ||||
}); | |||||
} | } | ||||
/** | /** | ||||
* Pause or resume the game. | * Pause or resume the game. | ||||
* | * | ||||
* @param explicit - true if the player explicitly wants to pause or resume. | * @param explicit - true if the player explicitly wants to pause or resume. | ||||
* If this argument isn't set, a multiplayer game won't be paused and the pause overlay | * If this argument isn't set, a multiplayer game won't be paused and the pause overlay | ||||
* won't be shown in single player. | * won't be shown in single player. | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | function updatePauseOverlay() | ||||
Engine.GetGUIObjectByName("pauseOverlay").hidden = !(g_Paused || g_PausingClients.length); | Engine.GetGUIObjectByName("pauseOverlay").hidden = !(g_Paused || g_PausingClients.length); | ||||
Engine.GetGUIObjectByName("pauseOverlay").onPress = g_Paused ? togglePause : function() {}; | Engine.GetGUIObjectByName("pauseOverlay").onPress = g_Paused ? togglePause : function() {}; | ||||
} | } | ||||
function openManual() | function openManual() | ||||
{ | { | ||||
closeOpenDialogs(); | closeOpenDialogs(); | ||||
pauseGame(); | pauseGame(); | ||||
Engine.PushGuiPage("page_manual.xml", {}, resumeGame); | |||||
Engine.PushGuiPage("page_manual.xml", { | |||||
"page": "manual/intro", | |||||
"title": translate("Manual"), | |||||
"url": "https://trac.wildfiregames.com/wiki/0adManual", | |||||
"callback": "resumeGame" | |||||
}); | |||||
} | } | ||||
function closeOpenDialogs() | function closeOpenDialogs() | ||||
{ | { | ||||
closeMenu(); | closeMenu(); | ||||
closeChat(); | closeChat(); | ||||
closeDiplomacy(); | closeDiplomacy(); | ||||
closeTrade(); | closeTrade(); | ||||
Show All 12 Lines |
Wildfire Games · Phabricator