diff --git a/BizHawk.MultiClient/MainForm.MenuItems.cs b/BizHawk.MultiClient/MainForm.MenuItems.cs index c70c6b4c4d..ff4d67063a 100644 --- a/BizHawk.MultiClient/MainForm.MenuItems.cs +++ b/BizHawk.MultiClient/MainForm.MenuItems.cs @@ -744,7 +744,7 @@ namespace BizHawk.MultiClient //repopulate it with an up to date list recentROMToolStripMenuItem.DropDownItems.Clear(); - if (Global.Config.RecentRoms.IsEmpty()) + if (Global.Config.RecentRoms.IsEmpty) { var none = new ToolStripMenuItem(); none.Enabled = false; @@ -753,7 +753,7 @@ namespace BizHawk.MultiClient } else { - for (int x = 0; x < Global.Config.RecentRoms.Length(); x++) + for (int x = 0; x < Global.Config.RecentRoms.Count; x++) { string path = Global.Config.RecentRoms.GetRecentFileByPosition(x); var item = new ToolStripMenuItem(); @@ -787,7 +787,7 @@ namespace BizHawk.MultiClient recentToolStripMenuItem.DropDownItems.Clear(); - if (Global.Config.RecentMovies.IsEmpty()) + if (Global.Config.RecentMovies.IsEmpty) { var none = new ToolStripMenuItem(); none.Enabled = false; @@ -796,7 +796,7 @@ namespace BizHawk.MultiClient } else { - for (int x = 0; x < Global.Config.RecentMovies.Length(); x++) + for (int x = 0; x < Global.Config.RecentMovies.Count; x++) { string path = Global.Config.RecentMovies.GetRecentFileByPosition(x); var item = new ToolStripMenuItem(); @@ -1003,9 +1003,14 @@ namespace BizHawk.MultiClient private void contextMenuStrip1_Opening(object sender, System.ComponentModel.CancelEventArgs e) { if (EmulatorPaused) + { wasPaused = true; + } else + { wasPaused = false; + } + didMenuPause = true; PauseEmulator(); @@ -1089,23 +1094,29 @@ namespace BizHawk.MultiClient } cmiUndoSavestate.Visible = true; - cmiSeparator20.Visible = true; - cmiScreenshot.Visible = true; cmiScreenshotClipboard.Visible = true; cmiCloseRom.Visible = true; } - if (Global.Config.RecentRoms.Length() == 0) - cmiLoadLastRom.Enabled = false; - else + if (Global.Config.RecentRoms.Count > 0) + { cmiLoadLastRom.Enabled = true; - - if (Global.Config.RecentMovies.Length() == 0) - cmiLoadLastMovie.Enabled = false; + } else + { + cmiLoadLastRom.Enabled = false; + } + + if (Global.Config.RecentMovies.Count > 0) + { cmiLoadLastMovie.Enabled = true; + } + else + { + cmiLoadLastMovie.Enabled = false; + } string path = PathManager.SaveStatePrefix(Global.Game) + "." + "QuickSave" + Global.Config.SaveSlot + ".State.bak"; var file = new FileInfo(path); @@ -1140,7 +1151,9 @@ namespace BizHawk.MultiClient cmiShowMenu.Text = "Show Menu"; } else + { cmiShowMenu.Visible = false; + } } diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index a223cea075..e7ed33dde8 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -228,7 +228,7 @@ namespace BizHawk.MultiClient MessageBox.Show("Failed to load " + cmdRom + " specified on commandline"); } } - else if (Global.Config.AutoLoadMostRecentRom && !Global.Config.RecentRoms.IsEmpty()) + else if (Global.Config.AutoLoadMostRecentRom && !Global.Config.RecentRoms.IsEmpty) LoadRomFromRecent(Global.Config.RecentRoms.GetRecentFileByPosition(0)); if (cmdMovie != null) @@ -250,7 +250,7 @@ namespace BizHawk.MultiClient Global.Config.RecentMovies.Add(cmdMovie); } } - else if (Global.Config.AutoLoadMostRecentMovie && !Global.Config.RecentMovies.IsEmpty()) + else if (Global.Config.AutoLoadMostRecentMovie && !Global.Config.RecentMovies.IsEmpty) { if (Global.Game == null) { @@ -2245,7 +2245,7 @@ namespace BizHawk.MultiClient //restarts the lua console if a different rom is loaded. //im not really a fan of how this is done.. - if (Global.Config.RecentRoms.IsEmpty() || Global.Config.RecentRoms.GetRecentFileByPosition(0) != file.CanonicalFullPath) + if (Global.Config.RecentRoms.IsEmpty || Global.Config.RecentRoms.GetRecentFileByPosition(0) != file.CanonicalFullPath) { #if WINDOWS LuaConsole1.Restart(); @@ -3840,7 +3840,7 @@ namespace BizHawk.MultiClient if (!RamWatch1.IsHandleCreated || RamWatch1.IsDisposed) { RamWatch1 = new RamWatch(); - if (Global.Config.AutoLoadRamWatch && Global.Config.RecentWatches.Length() > 0) + if (Global.Config.AutoLoadRamWatch && Global.Config.RecentWatches.Count > 0) { RamWatch1.LoadWatchFromRecent(Global.Config.RecentWatches.GetRecentFileByPosition(0)); } diff --git a/BizHawk.MultiClient/RecentFiles.cs b/BizHawk.MultiClient/RecentFiles.cs index 9c4b504d4f..109f9e63f3 100644 --- a/BizHawk.MultiClient/RecentFiles.cs +++ b/BizHawk.MultiClient/RecentFiles.cs @@ -20,17 +20,14 @@ namespace BizHawk.MultiClient recentlist.Clear(); } - public bool IsEmpty() + public bool IsEmpty { - if (recentlist.Count == 0) - return true; - else - return false; + get { return recentlist.Count > 0 ? false : true; } } - public int Length() + public int Count { - return recentlist.Count; + get { return recentlist.Count; } } public void Add(string newFile) @@ -44,7 +41,9 @@ namespace BizHawk.MultiClient } recentlist.Insert(0, newFile); if (recentlist.Count > MAX_RECENT_FILES) + { recentlist.Remove(recentlist[recentlist.Count - 1]); + } } public bool Remove(string newFile) @@ -57,16 +56,10 @@ namespace BizHawk.MultiClient recentlist.Remove(newFile); //intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place removed = true; } - } return removed; } - public List GetRecentList() - { - return recentlist; - } - public List GetRecentListTruncated(int length) { //iterate through list, truncating each item to length, and return the result in a List @@ -80,9 +73,14 @@ namespace BizHawk.MultiClient public string GetRecentFileByPosition(int position) { - if (recentlist.Count == 0) + if (recentlist.Count > 0) + { + return recentlist[position]; + } + else + { return ""; - return recentlist[position]; + } } } } diff --git a/BizHawk.MultiClient/tools/Cheats.cs b/BizHawk.MultiClient/tools/Cheats.cs index 6f5ddc9ba7..b14b5f15e6 100644 --- a/BizHawk.MultiClient/tools/Cheats.cs +++ b/BizHawk.MultiClient/tools/Cheats.cs @@ -262,7 +262,7 @@ namespace BizHawk.MultiClient //repopulate it with an up to date list recentToolStripMenuItem.DropDownItems.Clear(); - if (Global.Config.RecentCheats.IsEmpty()) + if (Global.Config.RecentCheats.IsEmpty) { var none = new ToolStripMenuItem(); none.Enabled = false; @@ -271,7 +271,7 @@ namespace BizHawk.MultiClient } else { - for (int x = 0; x < Global.Config.RecentCheats.Length(); x++) + for (int x = 0; x < Global.Config.RecentCheats.Count; x++) { string path = Global.Config.RecentCheats.GetRecentFileByPosition(x); var item = new ToolStripMenuItem(); diff --git a/BizHawk.MultiClient/tools/LuaConsole.cs b/BizHawk.MultiClient/tools/LuaConsole.cs index 389583bd85..507cd52dd1 100644 --- a/BizHawk.MultiClient/tools/LuaConsole.cs +++ b/BizHawk.MultiClient/tools/LuaConsole.cs @@ -97,7 +97,7 @@ namespace BizHawk.MultiClient LoadConfigSettings(); if (Global.Config.AutoLoadLuaSession) { - if (!Global.Config.RecentLuaSession.IsEmpty()) + if (!Global.Config.RecentLuaSession.IsEmpty) { LoadSessionFromRecent(Global.Config.RecentLuaSession.GetRecentFileByPosition(0)); } @@ -548,7 +548,7 @@ namespace BizHawk.MultiClient //repopulate it with an up to date list recentToolStripMenuItem.DropDownItems.Clear(); - if (Global.Config.RecentLua.IsEmpty()) + if (Global.Config.RecentLua.IsEmpty) { var none = new ToolStripMenuItem(); none.Enabled = false; @@ -557,7 +557,7 @@ namespace BizHawk.MultiClient } else { - for (int x = 0; x < Global.Config.RecentLua.Length(); x++) + for (int x = 0; x < Global.Config.RecentLua.Count; x++) { string path = Global.Config.RecentLua.GetRecentFileByPosition(x); var item = new ToolStripMenuItem(); @@ -1039,7 +1039,7 @@ namespace BizHawk.MultiClient //repopulate it with an up to date list recentSessionsToolStripMenuItem.DropDownItems.Clear(); - if (Global.Config.RecentLuaSession.IsEmpty()) + if (Global.Config.RecentLuaSession.IsEmpty) { var none = new ToolStripMenuItem(); none.Enabled = false; @@ -1048,7 +1048,7 @@ namespace BizHawk.MultiClient } else { - for (int x = 0; x < Global.Config.RecentLuaSession.Length(); x++) + for (int x = 0; x < Global.Config.RecentLuaSession.Count; x++) { string path = Global.Config.RecentLuaSession.GetRecentFileByPosition(x); var item = new ToolStripMenuItem(); diff --git a/BizHawk.MultiClient/tools/RamSearch.cs b/BizHawk.MultiClient/tools/RamSearch.cs index 89f6e57302..12064c37cd 100644 --- a/BizHawk.MultiClient/tools/RamSearch.cs +++ b/BizHawk.MultiClient/tools/RamSearch.cs @@ -1842,7 +1842,7 @@ namespace BizHawk.MultiClient //repopulate it with an up to date list recentToolStripMenuItem.DropDownItems.Clear(); - if (Global.Config.RecentSearches.IsEmpty()) + if (Global.Config.RecentSearches.IsEmpty) { var none = new ToolStripMenuItem(); none.Enabled = false; @@ -1851,7 +1851,7 @@ namespace BizHawk.MultiClient } else { - for (int x = 0; x < Global.Config.RecentSearches.Length(); x++) + for (int x = 0; x < Global.Config.RecentSearches.Count; x++) { string path = Global.Config.RecentSearches.GetRecentFileByPosition(x); var item = new ToolStripMenuItem(); diff --git a/BizHawk.MultiClient/tools/RamWatch.cs b/BizHawk.MultiClient/tools/RamWatch.cs index a354e77f0d..c0f9f91d5e 100644 --- a/BizHawk.MultiClient/tools/RamWatch.cs +++ b/BizHawk.MultiClient/tools/RamWatch.cs @@ -732,7 +732,7 @@ namespace BizHawk.MultiClient //repopulate it with an up to date list recentToolStripMenuItem.DropDownItems.Clear(); - if (Global.Config.RecentWatches.IsEmpty()) + if (Global.Config.RecentWatches.IsEmpty) { var none = new ToolStripMenuItem(); none.Enabled = false; @@ -741,7 +741,7 @@ namespace BizHawk.MultiClient } else { - for (int x = 0; x < Global.Config.RecentWatches.Length(); x++) + for (int x = 0; x < Global.Config.RecentWatches.Count; x++) { string path = Global.Config.RecentWatches.GetRecentFileByPosition(x); var item = new ToolStripMenuItem();