Recent Files - refactor - remove GetFileByPosition() in place of making the object indexable

This commit is contained in:
adelikat 2013-09-06 21:23:59 +00:00
parent 4be0fa49f8
commit 195b002ec1
7 changed files with 29 additions and 26 deletions

View File

@ -730,7 +730,7 @@ namespace BizHawk.MultiClient
{
for (int x = 0; x < Global.Config.RecentRoms.Count; x++)
{
string path = Global.Config.RecentRoms.GetRecentFileByPosition(x);
string path = Global.Config.RecentRoms[x];
var item = new ToolStripMenuItem {Text = path};
item.Click += (o, ev) => LoadRomFromRecent(path);
recentROMToolStripMenuItem.DropDownItems.Add(item);
@ -763,7 +763,7 @@ namespace BizHawk.MultiClient
{
for (int x = 0; x < Global.Config.RecentMovies.Count; x++)
{
string path = Global.Config.RecentMovies.GetRecentFileByPosition(x);
string path = Global.Config.RecentMovies[x];
var item = new ToolStripMenuItem {Text = path};
item.Click += (o, ev) => LoadMoviesFromRecent(path);
recentToolStripMenuItem.DropDownItems.Add(item);
@ -879,7 +879,7 @@ namespace BizHawk.MultiClient
private void loadLastROMToolStripMenuItem_Click(object sender, EventArgs e)
{
LoadRomFromRecent(Global.Config.RecentRoms.GetRecentFileByPosition(0));
LoadRomFromRecent(Global.Config.RecentRoms[0]);
}
private void enableContextMenuToolStripMenuItem_Click(object sender, EventArgs e)
@ -907,7 +907,7 @@ namespace BizHawk.MultiClient
private void loadLastMovieToolStripMenuItem_Click(object sender, EventArgs e)
{
LoadMoviesFromRecent(Global.Config.RecentMovies.GetRecentFileByPosition(0));
LoadMoviesFromRecent(Global.Config.RecentMovies[0]);
}
private void AddSubtitleToolStripMenuItem_Click(object sender, EventArgs e)

View File

@ -277,7 +277,7 @@ namespace BizHawk.MultiClient
}
}
else if (Global.Config.AutoLoadMostRecentRom && !Global.Config.RecentRoms.Empty)
LoadRomFromRecent(Global.Config.RecentRoms.GetRecentFileByPosition(0));
LoadRomFromRecent(Global.Config.RecentRoms[0]);
if (cmdMovie != null)
{
@ -306,7 +306,7 @@ namespace BizHawk.MultiClient
}
else
{
Movie m = new Movie(Global.Config.RecentMovies.GetRecentFileByPosition(0));
Movie m = new Movie(Global.Config.RecentMovies[0]);
StartNewMovie(m, false);
}
}
@ -1546,7 +1546,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.Empty || Global.Config.RecentRoms.GetRecentFileByPosition(0) != file.CanonicalFullPath)
if (Global.Config.RecentRoms.Empty || Global.Config.RecentRoms[0] != file.CanonicalFullPath)
{
#if WINDOWS
LuaConsole1.Restart();
@ -3348,7 +3348,7 @@ namespace BizHawk.MultiClient
RamWatch1 = new RamWatch();
if (Global.Config.AutoLoadRamWatch && Global.Config.RecentWatches.Count > 0)
{
RamWatch1.LoadWatchFromRecent(Global.Config.RecentWatches.GetRecentFileByPosition(0));
RamWatch1.LoadWatchFromRecent(Global.Config.RecentWatches[0]);
}
if (load_dialog)
{
@ -4203,7 +4203,7 @@ namespace BizHawk.MultiClient
NewRamWatch1 = new NewRamWatch();
if (Global.Config.AutoLoadRamWatch && Global.Config.RecentWatches.Count > 0)
{
NewRamWatch1.LoadWatchFromRecent(Global.Config.RecentWatches.GetRecentFileByPosition(0));
NewRamWatch1.LoadWatchFromRecent(Global.Config.RecentWatches[0]);
}
if (load_dialog)
{

View File

@ -66,16 +66,19 @@ namespace BizHawk.MultiClient
return recentlist.Select(t => t.Substring(0, length)).ToList();
}
public string GetRecentFileByPosition(int position)
{
if (recentlist.Count > 0)
{
return recentlist[position];
}
else
{
return "";
}
}
public string this[int index]
{
get
{
if (recentlist.Any())
{
return recentlist[index];
}
else
{
return "";
}
}
}
}
}

View File

@ -267,7 +267,7 @@ namespace BizHawk.MultiClient
{
for (int x = 0; x < Global.Config.RecentCheats.Count; x++)
{
string path = Global.Config.RecentCheats.GetRecentFileByPosition(x);
string path = Global.Config.RecentCheats[x];
var item = new ToolStripMenuItem {Text = path};
item.Click += (o, ev) => LoadCheatFromRecent(path);
recentToolStripMenuItem.DropDownItems.Add(item);

View File

@ -102,7 +102,7 @@ namespace BizHawk.MultiClient
{
if (!Global.Config.RecentLuaSession.Empty)
{
LoadSessionFromRecent(Global.Config.RecentLuaSession.GetRecentFileByPosition(0));
LoadSessionFromRecent(Global.Config.RecentLuaSession[0]);
}
}
@ -545,7 +545,7 @@ namespace BizHawk.MultiClient
{
for (int x = 0; x < Global.Config.RecentLua.Count; x++)
{
string path = Global.Config.RecentLua.GetRecentFileByPosition(x);
string path = Global.Config.RecentLua[x];
var item = new ToolStripMenuItem {Text = path};
item.Click += (o, ev) => LoadLuaFromRecent(path);
recentToolStripMenuItem.DropDownItems.Add(item);
@ -1021,7 +1021,7 @@ namespace BizHawk.MultiClient
{
for (int x = 0; x < Global.Config.RecentLuaSession.Count; x++)
{
string path = Global.Config.RecentLuaSession.GetRecentFileByPosition(x);
string path = Global.Config.RecentLuaSession[x];
var item = new ToolStripMenuItem {Text = path};
item.Click += (o, ev) => LoadSessionFromRecent(path);
recentSessionsToolStripMenuItem.DropDownItems.Add(item);

View File

@ -1869,7 +1869,7 @@ namespace BizHawk.MultiClient
{
for (int x = 0; x < Global.Config.RecentSearches.Count; x++)
{
string path = Global.Config.RecentSearches.GetRecentFileByPosition(x);
string path = Global.Config.RecentSearches[x];
var item = new ToolStripMenuItem { Text = path };
item.Click += (o, ev) => LoadSearchFromRecent(path);
recentToolStripMenuItem.DropDownItems.Add(item);

View File

@ -710,7 +710,7 @@ namespace BizHawk.MultiClient
{
for (int x = 0; x < Global.Config.RecentWatches.Count; x++)
{
string path = Global.Config.RecentWatches.GetRecentFileByPosition(x);
string path = Global.Config.RecentWatches[x];
var item = new ToolStripMenuItem {Text = path};
item.Click += (o, ev) => LoadWatchFromRecent(path);
recentToolStripMenuItem.DropDownItems.Add(item);