From fdf540b8b546a095ef3da4935cc56736c3780ce2 Mon Sep 17 00:00:00 2001 From: elexis Date: Fri, 25 Nov 2016 03:35:08 +0000 Subject: [PATCH] Load and save dialog cleanup. Unfiy delete and load button disabling (to remove a duplicate line and support a hypothetical reload button). Remove an unneeded selectionChanged call (which is automatically done when changing the selection index). git-svn-id: http://svn.wildfiregames.com/public/ps/trunk@18998 3db68df2-c116-0410-a063-a993310a9797 --- binaries/data/mods/public/gui/savedgames/load.js | 5 ++--- binaries/data/mods/public/gui/savedgames/save.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/binaries/data/mods/public/gui/savedgames/load.js b/binaries/data/mods/public/gui/savedgames/load.js index 9d34511583..3c81f984b3 100644 --- a/binaries/data/mods/public/gui/savedgames/load.js +++ b/binaries/data/mods/public/gui/savedgames/load.js @@ -14,9 +14,6 @@ function init() { gameSelection.list = [translate("No saved games found")]; gameSelection.selected = -1; - selectionChanged(); - Engine.GetGUIObjectByName("loadGameButton").enabled = false; - Engine.GetGUIObjectByName("deleteGameButton").enabled = false; return; } @@ -43,6 +40,8 @@ function selectionChanged() let metadata = g_SavedGamesMetadata[Engine.GetGUIObjectByName("gameSelection").selected]; Engine.GetGUIObjectByName("invalidGame").hidden = !!metadata; Engine.GetGUIObjectByName("validGame").hidden = !metadata; + Engine.GetGUIObjectByName("loadGameButton").enabled = !!metadata; + Engine.GetGUIObjectByName("deleteGameButton").enabled = !!metadata; if (!metadata) return; diff --git a/binaries/data/mods/public/gui/savedgames/save.js b/binaries/data/mods/public/gui/savedgames/save.js index 2ae0c46d2d..5a5495f7df 100644 --- a/binaries/data/mods/public/gui/savedgames/save.js +++ b/binaries/data/mods/public/gui/savedgames/save.js @@ -5,10 +5,11 @@ function selectDescription() { let gameSelection = Engine.GetGUIObjectByName("gameSelection"); let gameID = gameSelection.list_data[gameSelection.selected]; + Engine.GetGUIObjectByName("deleteGameButton").enabled = !!gameID; + if (!gameID) return; - Engine.GetGUIObjectByName("deleteGameButton").enabled = true; Engine.GetGUIObjectByName("saveGameDesc").caption = g_Descriptions[gameID]; } @@ -20,7 +21,6 @@ function init(data) g_SavedGameData.states = simulationState.players.map(pState => pState.state); let gameSelection = Engine.GetGUIObjectByName("gameSelection"); - Engine.GetGUIObjectByName("deleteGameButton").enabled = false; let savedGames = Engine.GetSavedGames().sort(sortDecreasingDate); if (!savedGames.length) -- 2.11.4.GIT