forked from mirrors/0ad
Remove Engine.SwitchGuiPage from replay menu
This commit is contained in:
@@ -37,17 +37,30 @@ function createReplaySelectionData(selectedDirectory)
|
|||||||
/**
|
/**
|
||||||
* Starts the selected visual replay, or shows an error message in case of incompatibility.
|
* Starts the selected visual replay, or shows an error message in case of incompatibility.
|
||||||
*/
|
*/
|
||||||
function startReplay()
|
function startReplayHandler()
|
||||||
{
|
{
|
||||||
var selected = Engine.GetGUIObjectByName("replaySelection").selected;
|
return new Promise(resolve =>
|
||||||
|
{
|
||||||
|
const startReplay = () =>
|
||||||
|
{
|
||||||
|
const selected = Engine.GetGUIObjectByName("replaySelection").selected;
|
||||||
if (selected == -1)
|
if (selected == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var replay = g_ReplaysFiltered[selected];
|
const replay = g_ReplaysFiltered[selected];
|
||||||
if (isReplayCompatible(replay))
|
if (!isReplayCompatible(replay))
|
||||||
reallyStartVisualReplay(replay.directory);
|
{
|
||||||
else
|
|
||||||
displayReplayCompatibilityError(replay);
|
displayReplayCompatibilityError(replay);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ret = reallyStartVisualReplay(replay.directory);
|
||||||
|
if (ret !== undefined)
|
||||||
|
resolve(ret);
|
||||||
|
};
|
||||||
|
Engine.GetGUIObjectByName("startReplayButton").onPress = startReplay;
|
||||||
|
Engine.GetGUIObjectByName("replaySelection").onMouseLeftDoubleClickItem = startReplay;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,10 +73,12 @@ function reallyStartVisualReplay(replayDirectory)
|
|||||||
if (!Engine.StartVisualReplay(replayDirectory))
|
if (!Engine.StartVisualReplay(replayDirectory))
|
||||||
{
|
{
|
||||||
warn('Replay "' + escapeText(Engine.GetReplayDirectoryName(replayDirectory)) + '" not found! Please click on reload cache.');
|
warn('Replay "' + escapeText(Engine.GetReplayDirectoryName(replayDirectory)) + '" not found! Please click on reload cache.');
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine.SwitchGuiPage("page_loading.xml", {
|
return {
|
||||||
|
"page": "page_loading.xml",
|
||||||
|
"argument": {
|
||||||
"attribs": Engine.GetReplayAttributes(replayDirectory),
|
"attribs": Engine.GetReplayAttributes(replayDirectory),
|
||||||
"playerAssignments": {
|
"playerAssignments": {
|
||||||
"local": {
|
"local": {
|
||||||
@@ -73,7 +88,8 @@ function reallyStartVisualReplay(replayDirectory)
|
|||||||
},
|
},
|
||||||
"savedGUIData": "",
|
"savedGUIData": "",
|
||||||
"replaySelectionData": createReplaySelectionData(replayDirectory)
|
"replaySelectionData": createReplaySelectionData(replayDirectory)
|
||||||
});
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,16 +121,27 @@ function displayReplayCompatibilityError(replay)
|
|||||||
* Opens the summary screen of the given replay, if its data was found in that directory, , or shows an error message in case of incompatibility.
|
* Opens the summary screen of the given replay, if its data was found in that directory, , or shows an error message in case of incompatibility.
|
||||||
*/
|
*/
|
||||||
function showReplaySummary()
|
function showReplaySummary()
|
||||||
|
{
|
||||||
|
return new Promise(closePageCallback =>
|
||||||
|
{
|
||||||
|
Engine.GetGUIObjectByName("summaryButton").onPress = () =>
|
||||||
{
|
{
|
||||||
const selected = Engine.GetGUIObjectByName("replaySelection").selected;
|
const selected = Engine.GetGUIObjectByName("replaySelection").selected;
|
||||||
if (selected == -1)
|
if (selected == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const replay = g_ReplaysFiltered[selected];
|
const replay = g_ReplaysFiltered[selected];
|
||||||
if (isReplayCompatible(replay))
|
if (!isReplayCompatible(replay))
|
||||||
reallyShowReplaySummary(replay.directory);
|
{
|
||||||
else
|
|
||||||
displayReplayCompatibilityError(replay);
|
displayReplayCompatibilityError(replay);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ret = reallyShowReplaySummary(replay.directory);
|
||||||
|
if (ret !== undefined)
|
||||||
|
closePageCallback(ret);
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function reallyShowReplaySummary(directory)
|
function reallyShowReplaySummary(directory)
|
||||||
@@ -125,10 +152,12 @@ function reallyShowReplaySummary(directory)
|
|||||||
if (!simData)
|
if (!simData)
|
||||||
{
|
{
|
||||||
messageBox(500, 200, translate("No summary data available."), translate("Error"));
|
messageBox(500, 200, translate("No summary data available."), translate("Error"));
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine.SwitchGuiPage("page_summary.xml", {
|
return {
|
||||||
|
"page": "page_summary.xml",
|
||||||
|
"argument": {
|
||||||
"sim": simData,
|
"sim": simData,
|
||||||
"gui": {
|
"gui": {
|
||||||
"dialog": false,
|
"dialog": false,
|
||||||
@@ -137,7 +166,8 @@ function reallyShowReplaySummary(directory)
|
|||||||
"replaySelectionData": createReplaySelectionData(directory),
|
"replaySelectionData": createReplaySelectionData(directory),
|
||||||
"summarySelection": g_SummarySelection
|
"summarySelection": g_SummarySelection
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function reloadCache()
|
function reloadCache()
|
||||||
|
|||||||
@@ -58,12 +58,13 @@ var g_MapCache = new MapCache();
|
|||||||
/**
|
/**
|
||||||
* Initializes globals, loads replays and displays the list.
|
* Initializes globals, loads replays and displays the list.
|
||||||
*/
|
*/
|
||||||
function init(data)
|
async function init(data)
|
||||||
{
|
{
|
||||||
if (!g_Settings)
|
if (!g_Settings)
|
||||||
{
|
{
|
||||||
Engine.SwitchGuiPage("page_pregame.xml");
|
return { [Engine.openRequest]: {
|
||||||
return;
|
"page": "page_pregame.xml"
|
||||||
|
} };
|
||||||
}
|
}
|
||||||
|
|
||||||
g_SummarySelection = data && data.summarySelection;
|
g_SummarySelection = data && data.summarySelection;
|
||||||
@@ -72,12 +73,23 @@ function init(data)
|
|||||||
|
|
||||||
if (!g_Replays)
|
if (!g_Replays)
|
||||||
{
|
{
|
||||||
Engine.SwitchGuiPage("page_pregame.xml");
|
return { [Engine.openRequest]: {
|
||||||
return;
|
"page": "page_pregame.xml"
|
||||||
|
} };
|
||||||
}
|
}
|
||||||
|
|
||||||
initHotkeyTooltips();
|
initHotkeyTooltips();
|
||||||
displayReplayList();
|
displayReplayList();
|
||||||
|
|
||||||
|
const closePromise = new Promise(closePageCallback =>
|
||||||
|
{
|
||||||
|
Engine.GetGUIObjectByName("mainMenu").onPress = closePageCallback.bind(undefined, {
|
||||||
|
"page": "page_pregame.xml"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const ret = await Promise.race([ closePromise, startReplayHandler(), showReplaySummary() ]);
|
||||||
|
return { [Engine.openRequest]: ret };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -64,7 +64,6 @@
|
|||||||
|
|
||||||
<action on="SelectionChange">displayReplayDetails();</action>
|
<action on="SelectionChange">displayReplayDetails();</action>
|
||||||
<action on="SelectionColumnChange">displayReplayList();</action>
|
<action on="SelectionColumnChange">displayReplayList();</action>
|
||||||
<action on="MouseLeftDoubleClickItem">startReplay();</action>
|
|
||||||
|
|
||||||
<!-- Columns -->
|
<!-- Columns -->
|
||||||
<column id="months" textcolor="172 172 212" width="12%">
|
<column id="months" textcolor="172 172 212" width="12%">
|
||||||
@@ -224,9 +223,8 @@
|
|||||||
<object name="bottomPanel" size="25 100%-56 100%-5 100%-24" >
|
<object name="bottomPanel" size="25 100%-56 100%-5 100%-24" >
|
||||||
|
|
||||||
<!-- Main Menu Button -->
|
<!-- Main Menu Button -->
|
||||||
<object type="button" style="StoneButton" size="0 0 19% 100%">
|
<object name="mainMenu" type="button" style="StoneButton" size="0 0 19% 100%">
|
||||||
<translatableAttribute id="caption">Main Menu</translatableAttribute>
|
<translatableAttribute id="caption">Main Menu</translatableAttribute>
|
||||||
<action on="Press">Engine.SwitchGuiPage("page_pregame.xml");</action>
|
|
||||||
</object>
|
</object>
|
||||||
|
|
||||||
<!-- Delete Button -->
|
<!-- Delete Button -->
|
||||||
@@ -245,13 +243,11 @@
|
|||||||
<!-- Summary Button -->
|
<!-- Summary Button -->
|
||||||
<object name="summaryButton" type="button" style="StoneButton" size="60% 0 79% 100%" hotkey="summary">
|
<object name="summaryButton" type="button" style="StoneButton" size="60% 0 79% 100%" hotkey="summary">
|
||||||
<translatableAttribute id="caption">Summary</translatableAttribute>
|
<translatableAttribute id="caption">Summary</translatableAttribute>
|
||||||
<action on="Press">showReplaySummary();</action>
|
|
||||||
</object>
|
</object>
|
||||||
|
|
||||||
<!-- Start Replay Button -->
|
<!-- Start Replay Button -->
|
||||||
<object name="startReplayButton" type="button" style="StoneButton" size="80% 0 99% 100%">
|
<object name="startReplayButton" type="button" style="StoneButton" size="80% 0 99% 100%">
|
||||||
<translatableAttribute id="caption">Start Replay</translatableAttribute>
|
<translatableAttribute id="caption">Start Replay</translatableAttribute>
|
||||||
<action on="Press">startReplay();</action>
|
|
||||||
</object>
|
</object>
|
||||||
|
|
||||||
</object>
|
</object>
|
||||||
|
|||||||
Reference in New Issue
Block a user