From 06fb794da9b92b4e455c41b213d6918e7186e738 Mon Sep 17 00:00:00 2001 From: elexis Date: Fri, 25 Nov 2016 03:30:16 +0000 Subject: [PATCH] Implement noconfirmation hotkey for deleting savegames in the save dialog. Refs #3962. Remove the deleteGame duplicate. git-svn-id: http://svn.wildfiregames.com/public/ps/trunk@18996 3db68df2-c116-0410-a063-a993310a9797 --- .../gui/common/functions_utility_loadsave.js | 22 ++++++++++++++++++++++ binaries/data/mods/public/gui/savedgames/load.js | 22 ---------------------- binaries/data/mods/public/gui/savedgames/save.js | 16 ---------------- binaries/data/mods/public/gui/savedgames/save.xml | 2 +- 4 files changed, 23 insertions(+), 39 deletions(-) diff --git a/binaries/data/mods/public/gui/common/functions_utility_loadsave.js b/binaries/data/mods/public/gui/common/functions_utility_loadsave.js index cad6e099d6..c6254ca5a2 100644 --- a/binaries/data/mods/public/gui/common/functions_utility_loadsave.js +++ b/binaries/data/mods/public/gui/common/functions_utility_loadsave.js @@ -67,6 +67,28 @@ function hasSameMods(metadata, engineInfo) return modsA.every((mod, index) => mod == modsB[index]); } +function deleteGame() +{ + let gameSelection = Engine.GetGUIObjectByName("gameSelection"); + let gameID = gameSelection.list_data[gameSelection.selected]; + + if (!gameID) + return; + + if (Engine.HotkeyIsPressed("session.savedgames.noconfirmation")) + reallyDeleteGame(gameID); + else + messageBox( + 500, 200, + sprintf(translate("\"%(label)s\""), { + "label": gameSelection.list[gameSelection.selected] + }) + "\n" + translate("Saved game will be permanently deleted, are you sure?"), + translate("DELETE"), + [translate("No"), translate("Yes")], + [null, function(){ reallyDeleteGame(gameID); }] + ); +} + function reallyDeleteGame(gameID) { if (!Engine.DeleteSavedGame(gameID)) diff --git a/binaries/data/mods/public/gui/savedgames/load.js b/binaries/data/mods/public/gui/savedgames/load.js index 9f3e6c571d..0a28e3ca6a 100644 --- a/binaries/data/mods/public/gui/savedgames/load.js +++ b/binaries/data/mods/public/gui/savedgames/load.js @@ -160,25 +160,3 @@ function reallyLoadGame(gameId) "savedGUIData": metadata.gui }); } - -function deleteGame() -{ - let gameSelection = Engine.GetGUIObjectByName("gameSelection"); - let gameID = gameSelection.list_data[gameSelection.selected]; - - if (!gameID) - return; - - if (Engine.HotkeyIsPressed("session.savedgames.noconfirmation")) - reallyDeleteGame(gameID); - else - messageBox( - 500, 200, - sprintf(translate("\"%(label)s\""), { - "label": gameSelection.list[gameSelection.selected] - }) + "\n" + translate("Saved game will be permanently deleted, are you sure?"), - translate("DELETE"), - [translate("No"), translate("Yes")], - [null, function(){ reallyDeleteGame(gameID); }] - ); -} diff --git a/binaries/data/mods/public/gui/savedgames/save.js b/binaries/data/mods/public/gui/savedgames/save.js index cdb6c3a3a8..c702b96dc4 100644 --- a/binaries/data/mods/public/gui/savedgames/save.js +++ b/binaries/data/mods/public/gui/savedgames/save.js @@ -80,22 +80,6 @@ function closeSave() Engine.PopGuiPageCB(0); } -function deleteGame() -{ - let gameSelection = Engine.GetGUIObjectByName("gameSelection"); - let gameLabel = gameSelection.list[gameSelection.selected]; - let gameID = gameSelection.list_data[gameSelection.selected]; - - messageBox( - 500, 200, - sprintf(translate("\"%(label)s\""), { "label": gameLabel }) + "\n" + - translate("Saved game will be permanently deleted, are you sure?"), - translate("DELETE"), - [translate("No"), translate("Yes")], - [null, function(){ reallyDeleteGame(gameID); }] - ); -} - // HACK: Engine.SaveGame* expects this function to be defined on the current page. // That's why we have to pass the data to this page even if we don't need it. function getSavedGameData() diff --git a/binaries/data/mods/public/gui/savedgames/save.xml b/binaries/data/mods/public/gui/savedgames/save.xml index f66d16b334..a14e0831b5 100644 --- a/binaries/data/mods/public/gui/savedgames/save.xml +++ b/binaries/data/mods/public/gui/savedgames/save.xml @@ -39,7 +39,7 @@ closeSave(true); - + Delete deleteGame(); -- 2.11.4.GIT