Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/replaymenu/replay_actions.js
Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | else | ||||
deleteReplay(); | deleteReplay(); | ||||
} | } | ||||
/** | /** | ||||
* Shows a confirmation dialog and deletes the selected replay from the disk in case. | * Shows a confirmation dialog and deletes the selected replay from the disk in case. | ||||
*/ | */ | ||||
function deleteReplay() | function deleteReplay() | ||||
{ | { | ||||
// Get selected replay | // Get selected replay | ||||
var selected = Engine.GetGUIObjectByName("replaySelection").selected; | let replaySelection = Engine.GetGUIObjectByName("replaySelection"); | ||||
Stan: Let | |||||
if (selected == -1) | if (!replaySelection.multiSelected.length) | ||||
return; | return; | ||||
let directories = []; | |||||
var replay = g_ReplaysFiltered[selected]; | let directoryNames = []; | ||||
for (let selected of replaySelection.multiSelected) | |||||
{ | |||||
directories.push(g_ReplaysFiltered[selected].directory); | |||||
directoryNames.push(Engine.GetReplayDirectoryName(g_ReplaysFiltered[selected].directory)); | |||||
} | |||||
messageBox( | messageBox( | ||||
500, 200, | 500, 200, | ||||
translate("Are you sure you want to delete this replay permanently?") + "\n" + | translatePlural("Are you sure you want to delete this replay permanently?", | ||||
Not Done Inline ActionsFor of Stan: For of | |||||
escapeText(Engine.GetReplayDirectoryName(replay.directory)), | "Are you sure you want to delete these replays permanently?", | ||||
translate("Delete replay"), | directories.length | ||||
) + "\n" + | |||||
escapeText(directoryNames.join("\n")), | |||||
translatePlural("Delete replay", "Delete replays", directories.length), | |||||
[translate("No"), translate("Yes")], | [translate("No"), translate("Yes")], | ||||
[null, function() { reallyDeleteReplay(replay.directory); }] | [null, function() { reallyDeleteReplay(directories); }] | ||||
); | ); | ||||
} | } | ||||
/** | /** | ||||
* Attempts to delete the selected replay from the disk. | * Attempts to delete the selected replay from the disk. | ||||
*/ | */ | ||||
function deleteReplayWithoutConfirmation() | function deleteReplayWithoutConfirmation() | ||||
{ | { | ||||
var selected = Engine.GetGUIObjectByName("replaySelection").selected; | let replaySelection = Engine.GetGUIObjectByName("replaySelection"); | ||||
if (selected > -1) | if (!replaySelection.multiSelected.length) | ||||
Not Done Inline ActionsLet Stan: Let | |||||
reallyDeleteReplay(g_ReplaysFiltered[selected].directory); | return; | ||||
let directories = []; | |||||
for (selected of replaySelection.multiSelected) | |||||
directories.push(g_ReplaysFiltered[selected].directory); | |||||
reallyDeleteReplay(directories); | |||||
} | } | ||||
Not Done Inline Actionsremove braces Stan: remove braces | |||||
/** | /** | ||||
* Attempts to delete the given replay directory from the disk. | * Attempts to delete the given replay directory from the disk. | ||||
* | * | ||||
* @param replayDirectory {string} | * @param replayDirectories {string[]} | ||||
*/ | */ | ||||
function reallyDeleteReplay(replayDirectory) | function reallyDeleteReplay(replayDirectories) | ||||
{ | { | ||||
var replaySelection = Engine.GetGUIObjectByName("replaySelection"); | let replaySelection = Engine.GetGUIObjectByName("replaySelection"); | ||||
var selectedIndex = replaySelection.selected; | |||||
for (let replayDirectory of replayDirectories) | |||||
if (!Engine.DeleteReplay(replayDirectory)) | if (!Engine.DeleteReplay(replayDirectory)) | ||||
Not Done Inline Actionsremove braces. Stan: remove braces. | |||||
error("Could not delete replay!"); | error("Could not delete replay!"); | ||||
// Refresh replay list | // Refresh replay list | ||||
init(); | init(); | ||||
replaySelection.selected = Math.min(selectedIndex, g_ReplaysFiltered.length - 1); | replaySelection.selected = Math.min(selectedIndex, g_ReplaysFiltered.length - 1); | ||||
elexisUnsubmitted Not Done Inline ActionsRefers to selectedIndex, but that was deleted. elexis: Refers to `selectedIndex`, but that was deleted. | |||||
} | } |
Wildfire Games · Phabricator
Let