Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/session/menu.js
Show All 23 Lines | |||||
// Shown in the trade dialog. | // Shown in the trade dialog. | ||||
var g_IdleTraderTextColor = "orange"; | var g_IdleTraderTextColor = "orange"; | ||||
/** | /** | ||||
* Store civilization code and page (structree or history) opened in civilization info. | * Store civilization code and page (structree or history) opened in civilization info. | ||||
*/ | */ | ||||
var g_CivInfo = { | var g_CivInfo = { | ||||
"code": "", | "civ": "", | ||||
"page": "page_structree.xml" | "page": "page_structree.xml" | ||||
}; | }; | ||||
/** | /** | ||||
* The barter constants should match with the simulation | * The barter constants should match with the simulation | ||||
* Quantity of goods to sell per click. | * Quantity of goods to sell per click. | ||||
*/ | */ | ||||
const g_BarterResourceSellQuantity = 100; | const g_BarterResourceSellQuantity = 100; | ||||
▲ Show 20 Lines • Show All 179 Lines • ▼ Show 20 Lines | function openDeleteDialog(selection) | ||||
); | ); | ||||
} | } | ||||
function openSave() | function openSave() | ||||
{ | { | ||||
closeOpenDialogs(); | closeOpenDialogs(); | ||||
pauseGame(); | pauseGame(); | ||||
Engine.PushGuiPage("page_savegame.xml", { | Engine.PushGuiPage( | ||||
"savedGameData": getSavedGameData(), | "page_savegame.xml", | ||||
"callback": "resumeGame" | { "savedGameData": getSavedGameData() }, | ||||
}); | 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(); | ||||
Engine.PushGuiPage( | |||||
page, | |||||
{ | |||||
"civ": g_CivInfo.civ || g_Players[g_ViewedPlayer].civ | |||||
// TODO add info about researched techs and unlocked entities | // TODO add info about researched techs and unlocked entities | ||||
}, | |||||
Engine.PushGuiPage(g_CivInfo.page, { | storeCivInfoPage); | ||||
"civ": g_CivInfo.code || g_Players[g_ViewedPlayer].civ, | |||||
"callback": "storeCivInfoPage" | |||||
}); | |||||
} | } | ||||
function storeCivInfoPage(data) | function storeCivInfoPage(data) | ||||
{ | { | ||||
g_CivInfo.code = data.civ; | if (data.nextPage) | ||||
g_CivInfo.page = data.page; | Engine.PushGuiPage( | ||||
data.nextPage, | |||||
{ "civ": data.civ }, | |||||
storeCivInfoPage); | |||||
else | |||||
{ | |||||
g_CivInfo = data; | |||||
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 105 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator