Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/lobby/lobby.js
Show First 20 Lines • Show All 361 Lines • ▼ Show 20 Lines | "quit": { | ||||
"description": translate("Return to the main menu."), | "description": translate("Return to the main menu."), | ||||
"handler": args => { | "handler": args => { | ||||
returnToMainMenu(); | returnToMainMenu(); | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
let g_Replays = Engine.GetReplays(false).filter(replay => | |||||
replay.attribs.settings.PlayerData.filter(player => player && !player.AI).length > 1 ).sort((a, b) => | |||||
{ | |||||
let cmpA, cmpB; | |||||
switch ("months") | |||||
{ | |||||
case 'months': | |||||
cmpA = +a.attribs.timestamp; | |||||
cmpB = +b.attribs.timestamp; | |||||
break; | |||||
} | |||||
if (cmpA < cmpB) | |||||
return +1; | |||||
else if (cmpA > cmpB) | |||||
return -1; | |||||
return 0; | |||||
}); | |||||
/** | /** | ||||
* Called after the XmppConnection succeeded and when returning from a game. | * Called after the XmppConnection succeeded and when returning from a game. | ||||
* | * | ||||
* @param {Object} attribs | * @param {Object} attribs | ||||
*/ | */ | ||||
function init(attribs) | function init(attribs) | ||||
{ | { | ||||
if (!g_Settings) | if (!g_Settings) | ||||
▲ Show 20 Lines • Show All 1,079 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
if (!attr.totalGamesPlayed) | if (!attr.totalGamesPlayed) | ||||
return translateWithContext("Used for an undefined winning rate", "-"); | return translateWithContext("Used for an undefined winning rate", "-"); | ||||
return sprintf(translate("%(percentage)s%%"), { | return sprintf(translate("%(percentage)s%%"), { | ||||
"percentage": (attr.wins / attr.totalGamesPlayed * 100).toFixed(2) | "percentage": (attr.wins / attr.totalGamesPlayed * 100).toFixed(2) | ||||
}); | }); | ||||
} | } | ||||
function showLastSummary() | |||||
{ | |||||
if (!g_Replays) | |||||
return; | |||||
let simData = Engine.GetReplayMetadata(g_Replays[0].directory); | |||||
if (!simData) | |||||
{ | |||||
messageBox(500, 200, translate("No summary data available."), translate("Error")); | |||||
return; | |||||
} | |||||
Engine.PushGuiPage("page_summary.xml", { | |||||
"sim": simData, | |||||
"gui": { | |||||
"replayDirectory": g_Replays[0].directory | |||||
} | |||||
}); | |||||
} |
Wildfire Games · Phabricator