diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index abf1f1e500..baa4b7d712 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -723,32 +723,19 @@ namespace BizHawk.MultiClient private void LoadRomFromRecent(string rom) { - bool r = LoadRom(rom); - if (!r) + if (!LoadRom(rom)) { - Global.Sound.StopSound(); - DialogResult result = MessageBox.Show("Could not open " + rom + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); - if (result == DialogResult.Yes) - { - Global.Config.RecentRoms.Remove(rom); - } - Global.Sound.StartSound(); + Global.Config.RecentRoms.HandleLoadError(rom); } } - private void LoadMoviesFromRecent(string movie) + private void LoadMoviesFromRecent(string path) { - Movie m = new Movie(movie); + Movie m = new Movie(path); if (!m.Loaded) { - Global.Sound.StopSound(); - DialogResult result = MessageBox.Show("Could not open " + movie + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); - if (result == DialogResult.Yes) - { - Global.Config.RecentMovies.Remove(movie); - } - Global.Sound.StartSound(); + Global.Config.RecentMovies.HandleLoadError(path); } else { diff --git a/BizHawk.MultiClient/RecentFiles.cs b/BizHawk.MultiClient/RecentFiles.cs index 1734257ce7..997bd3a0e1 100644 --- a/BizHawk.MultiClient/RecentFiles.cs +++ b/BizHawk.MultiClient/RecentFiles.cs @@ -96,6 +96,18 @@ namespace BizHawk.MultiClient } } + public void HandleLoadError(string path) + { + Global.Sound.StopSound(); + DialogResult result = MessageBox.Show("Could not open " + path + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); + if (result == DialogResult.Yes) + { + Remove(path); + } + + Global.Sound.StartSound(); + } + public ToolStripItem[] GenerateRecentMenu(Action loadFileCallback) { var items = new List(); diff --git a/BizHawk.MultiClient/tools/Cheats.cs b/BizHawk.MultiClient/tools/Cheats.cs index 6c940b9fb5..20b42f1afc 100644 --- a/BizHawk.MultiClient/tools/Cheats.cs +++ b/BizHawk.MultiClient/tools/Cheats.cs @@ -236,23 +236,27 @@ namespace BizHawk.MultiClient Global.MainForm.HexEditor1.UpdateValues(); } - public void LoadCheatFromRecent(string file) + public void LoadCheatFromRecent(string path) { - bool z = true; + bool doload = true; - if (Global.CheatList.Changes) z = AskSave(); - - if (z) + if (Global.CheatList.Changes) { - bool r = LoadCheatFile(file, false); - if (!r) + doload = AskSave(); + } + + if (doload) + { + bool result = LoadCheatFile(path, false); + if (!result) { - DialogResult result = MessageBox.Show("Could not open " + file + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); - if (result == DialogResult.Yes) - Global.Config.RecentCheats.Remove(file); + Global.Config.RecentCheats.HandleLoadError(path); + } + else + { + DisplayCheatsList(); + Global.CheatList.Changes = false; } - DisplayCheatsList(); - Global.CheatList.Changes = false; } } diff --git a/BizHawk.MultiClient/tools/Lua/LuaConsole.cs b/BizHawk.MultiClient/tools/Lua/LuaConsole.cs index fc82079470..12e4ec070a 100644 --- a/BizHawk.MultiClient/tools/Lua/LuaConsole.cs +++ b/BizHawk.MultiClient/tools/Lua/LuaConsole.cs @@ -973,14 +973,7 @@ namespace BizHawk.MultiClient private void fileToolStripMenuItem_DropDownOpened(object sender, EventArgs e) { - if (!changes) - { - saveToolStripMenuItem.Enabled = false; - } - else - { - saveToolStripMenuItem.Enabled = true; - } + saveToolStripMenuItem.Enabled = changes; } private void recentSessionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e) @@ -989,26 +982,25 @@ namespace BizHawk.MultiClient recentSessionsToolStripMenuItem.DropDownItems.AddRange(Global.Config.RecentLuaSession.GenerateRecentMenu(LoadSessionFromRecent)); } - public void LoadSessionFromRecent(string file) + public void LoadSessionFromRecent(string path) { - bool z = true; - if (changes) z = AskSave(); + bool doload = true; + if (changes) doload = AskSave(); - if (z) + if (doload) { - bool r = LoadLuaSession(file); - if (!r) + if (!LoadLuaSession(path)) { - DialogResult result = MessageBox.Show("Could not open " + file + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); - if (result == DialogResult.Yes) - Global.Config.RecentLuaSession.Remove(file); + Global.Config.RecentLuaSession.HandleLoadError(path); + } + else + { + RunLuaScripts(); + DisplayLuaList(); + LuaListView.Refresh(); + currentSessionFile = path; + Changes(false); } - RunLuaScripts(); - DisplayLuaList(); - //ClearOutput(); - LuaListView.Refresh(); - currentSessionFile = file; - Changes(false); } } diff --git a/BizHawk.MultiClient/tools/Watch/NewRamWatch.cs b/BizHawk.MultiClient/tools/Watch/NewRamWatch.cs index e3c4addbbb..479d6c6aea 100644 --- a/BizHawk.MultiClient/tools/Watch/NewRamWatch.cs +++ b/BizHawk.MultiClient/tools/Watch/NewRamWatch.cs @@ -298,7 +298,7 @@ namespace BizHawk.MultiClient } } - public void LoadWatchFromRecent(string file) + public void LoadWatchFromRecent(string path) { bool ask_result = true; if (Watches.Changes) @@ -308,26 +308,19 @@ namespace BizHawk.MultiClient if (ask_result) { - bool load_result = Watches.Load(file, details: true, append: false); - if (load_result) + bool load_result = Watches.Load(path, details: true, append: false); + if (!load_result) { - Global.Config.RecentWatches.Add(file); - + Global.Config.RecentWatches.HandleLoadError(path); } else { - DialogResult result = MessageBox.Show("Could not open " + file + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); - if (result == DialogResult.Yes) - { - Global.Config.RecentWatches.Remove(file); - } + Global.Config.RecentWatches.Add(path); + DisplayWatches(); + UpdateWatchCount(); + MessageLabel.Text = Path.GetFileName(Watches.CurrentFileName) + " *"; + Watches.Changes = false; } - - DisplayWatches(); - UpdateWatchCount(); - MessageLabel.Text = Path.GetFileName(Watches.CurrentFileName) + " *"; - Watches.Changes = false; - } } diff --git a/BizHawk.MultiClient/tools/Watch/RamSearch.cs b/BizHawk.MultiClient/tools/Watch/RamSearch.cs index 5fe8e87c06..a8d4f3c50f 100644 --- a/BizHawk.MultiClient/tools/Watch/RamSearch.cs +++ b/BizHawk.MultiClient/tools/Watch/RamSearch.cs @@ -1819,16 +1819,16 @@ namespace BizHawk.MultiClient } } - private void LoadSearchFromRecent(string file) + private void LoadSearchFromRecent(string path) { - bool r = LoadSearchFile(file, false, Searches); - if (!r) + if (!LoadSearchFile(path, false, Searches)) { - DialogResult result = MessageBox.Show("Could not open " + file + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); - if (result == DialogResult.Yes) - Global.Config.RecentSearches.Remove(file); + Global.Config.RecentSearches.HandleLoadError(path); + } + else + { + DisplaySearchList(); } - DisplaySearchList(); } bool LoadSearchFile(string path, bool append, List list) @@ -1848,10 +1848,11 @@ namespace BizHawk.MultiClient Global.Config.RecentSearches.Add(path); SetMemoryDomain(WatchCommon.GetDomainPos(domain)); return true; - } else + { return false; + } } private void recentToolStripMenuItem_DropDownOpened(object sender, EventArgs e) diff --git a/BizHawk.MultiClient/tools/Watch/RamWatch.cs b/BizHawk.MultiClient/tools/Watch/RamWatch.cs index 33e3a24e6e..de3bf53eb7 100644 --- a/BizHawk.MultiClient/tools/Watch/RamWatch.cs +++ b/BizHawk.MultiClient/tools/Watch/RamWatch.cs @@ -290,22 +290,22 @@ namespace BizHawk.MultiClient return true; } - public void LoadWatchFromRecent(string file) + public void LoadWatchFromRecent(string path) { - bool z = true; - if (changes) z = AskSave(); + bool ask_result = true; + if (changes) ask_result = AskSave(); - if (z) + if (ask_result) { - bool r = LoadWatchFile(file, false); - if (!r) + if (!LoadWatchFile(path, false)) { - DialogResult result = MessageBox.Show("Could not open " + file + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); - if (result == DialogResult.Yes) - Global.Config.RecentWatches.Remove(file); + Global.Config.RecentWatches.HandleLoadError(path); + } + else + { + DisplayWatchList(); + changes = false; } - DisplayWatchList(); - changes = false; } }