Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/summary/summary.js
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | var g_SummaryTypes = { | ||||
} | } | ||||
}; | }; | ||||
// Translation: Unicode encoded infinity symbol indicating a division by zero in the summary screen. | // Translation: Unicode encoded infinity symbol indicating a division by zero in the summary screen. | ||||
var g_InfinitySymbol = translate("\u221E"); | var g_InfinitySymbol = translate("\u221E"); | ||||
var g_Teams = []; | var g_Teams = []; | ||||
// TODO set g_PlayerCount as playerCounters.length | var g_PlayerCount; | ||||
var g_PlayerCount = 0; | |||||
var g_GameData; | var g_GameData; | ||||
var g_ResourceData = new Resources(); | var g_ResourceData = new Resources(); | ||||
/** | /** | ||||
* Selected chart indexes. | * Selected chart indexes. | ||||
*/ | */ | ||||
var g_SelectedChart = { | var g_SelectedChart = { | ||||
"category": [0, 0], | "category": [0, 0], | ||||
"value": [0, 1], | "value": [0, 1], | ||||
"type": [0, 0] | "type": [0, 0] | ||||
}; | }; | ||||
/** | /** | ||||
* Array of the panel button names. | * Array of the panel button names. | ||||
*/ | */ | ||||
var g_PanelButtons = []; | var g_PanelButtons = []; | ||||
/** | /** | ||||
* Remember the name of the currently opened view panel. | * Remember the name of the currently opened view panel. | ||||
*/ | */ | ||||
var g_SelectedPanel = ""; | var g_SelectedPanel; | ||||
function init(data) | function init(data) | ||||
{ | { | ||||
// Fill globals | initSummaryData(data); | ||||
initGUISummary(); | |||||
} | |||||
function initSummaryData(data) | |||||
{ | |||||
g_GameData = data; | g_GameData = data; | ||||
g_ScorePanelsData = getScorePanelsData(); | g_ScorePanelsData = getScorePanelsData(); | ||||
g_PanelButtons = Object.keys(g_ScorePanelsData).concat(["charts"]).map(panel => panel + "PanelButton"); | g_PanelButtons = Object.keys(g_ScorePanelsData).concat(["charts"]).map(panel => panel + "PanelButton"); | ||||
g_SelectedPanel = g_PanelButtons[0]; | g_SelectedPanel = g_PanelButtons[0]; | ||||
if (data && data.selectedData) | if (data && data.gui && data.gui.summarySelection) | ||||
{ | { | ||||
g_SelectedPanel = data.selectedData.panel; | g_SelectedPanel = data.gui.summarySelection.panel; | ||||
g_SelectedChart = data.selectedData.charts; | g_SelectedChart = data.gui.summarySelection.charts; | ||||
} | } | ||||
initTeamData(); | initTeamData(); | ||||
calculateTeamCounterDataHelper(); | calculateTeamCounterDataHelper(); | ||||
} | |||||
// Output globals | function initGUISummary() | ||||
{ | |||||
initGUIWindow(); | initGUIWindow(); | ||||
initPlayerBoxPositions(); | initPlayerBoxPositions(); | ||||
initGUICharts(); | initGUICharts(); | ||||
initGUILabelsAndButtons(); | initGUILabelsAndButtons(); | ||||
selectPanel(Engine.GetGUIObjectByName(g_SelectedPanel)); | selectPanel(Engine.GetGUIObjectByName(g_SelectedPanel)); | ||||
for (let button of g_PanelButtons) | for (let button of g_PanelButtons) | ||||
{ | { | ||||
let tab = Engine.GetGUIObjectByName(button); | let tab = Engine.GetGUIObjectByName(button); | ||||
▲ Show 20 Lines • Show All 277 Lines • ▼ Show 20 Lines | messageBox( | ||||
[null, startReplay] | [null, startReplay] | ||||
); | ); | ||||
else | else | ||||
startReplay(); | startReplay(); | ||||
} | } | ||||
function continueButton() | function continueButton() | ||||
{ | { | ||||
let summarySelectedData = { | let summarySelection = { | ||||
"panel": g_SelectedPanel, | "panel": g_SelectedPanel, | ||||
"charts": g_SelectedChart | "charts": g_SelectedChart | ||||
}; | }; | ||||
if (g_GameData.gui.isInGame) | if (g_GameData.gui.isInGame) | ||||
Engine.PopGuiPageCB({ | Engine.PopGuiPageCB({ | ||||
"explicitResume": 0, | "explicitResume": 0, | ||||
"summarySelectedData": summarySelectedData | "summarySelection": summarySelection | ||||
}); | }); | ||||
else if (g_GameData.gui.dialog) | else if (g_GameData.gui.dialog) | ||||
Engine.PopGuiPage(); | Engine.PopGuiPage(); | ||||
else if (g_GameData.gui.isReplay) | else if (g_GameData.gui.isReplay) | ||||
Engine.SwitchGuiPage("page_replaymenu.xml", { | Engine.SwitchGuiPage("page_replaymenu.xml", { | ||||
"replaySelectionData": g_GameData.gui.replaySelectionData, | "replaySelectionData": g_GameData.gui.replaySelectionData, | ||||
"summarySelectedData": summarySelectedData | "summarySelection": summarySelection | ||||
}); | }); | ||||
else if (Engine.HasXmppClient()) | else if (Engine.HasXmppClient()) | ||||
Engine.SwitchGuiPage("page_lobby.xml", { "dialog": false }); | Engine.SwitchGuiPage("page_lobby.xml", { "dialog": false }); | ||||
else | else | ||||
Engine.SwitchGuiPage("page_pregame.xml"); | Engine.SwitchGuiPage("page_pregame.xml"); | ||||
} | } | ||||
function startReplay() | function startReplay() | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator