Some code refactoring, no functional changes
This commit is contained in:
parent
240a9e3a45
commit
5dc8733ae1
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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<string> GetRecentList()
|
||||
{
|
||||
return recentlist;
|
||||
}
|
||||
|
||||
public List<string> GetRecentListTruncated(int length)
|
||||
{
|
||||
//iterate through list, truncating each item to length, and return the result in a List<string>
|
||||
|
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue