Recent files - be case insensitive when comparing file paths. Firmwares config - some progress, basic scanning started, only FDS and SNES done so far.

This commit is contained in:
adelikat 2013-07-31 18:44:35 +00:00
parent 3dc4611263
commit d0071f58d2
2 changed files with 51 additions and 25 deletions

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
@ -6,54 +7,57 @@ namespace BizHawk.MultiClient
public class RecentFiles public class RecentFiles
{ {
private readonly int MAX_RECENT_FILES; //Maximum number of files private readonly int MAX_RECENT_FILES; //Maximum number of files
private readonly List<string> recentlist; //List of recent files private readonly List<string> _recent_list; //List of recent files
public RecentFiles()
: this(8) { }
public RecentFiles() : this(8) { }
public RecentFiles(int max) public RecentFiles(int max)
{ {
recentlist = new List<string>(); _recent_list = new List<string>();
MAX_RECENT_FILES = max; MAX_RECENT_FILES = max;
} }
public void Clear() public void Clear()
{ {
recentlist.Clear(); _recent_list.Clear();
} }
public bool Empty public bool Empty
{ {
get { return recentlist.Count == 0; } get { return _recent_list.Count == 0; }
} }
public int Count public int Count
{ {
get { return recentlist.Count; } get { return _recent_list.Count; }
} }
public void Add(string newFile) public void Add(string newFile)
{ {
for (int x = 0; x < recentlist.Count; x++) foreach (string recent in _recent_list)
{
if (String.Compare(newFile, recent, true) == 0)
{
_recent_list.Remove(newFile); //intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place
}
}
_recent_list.Insert(0, newFile);
if (_recent_list.Count > MAX_RECENT_FILES)
{ {
if (string.Compare(newFile, recentlist[x]) == 0) _recent_list.Remove(_recent_list[_recent_list.Count - 1]);
{
recentlist.Remove(newFile); //intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place
}
}
recentlist.Insert(0, newFile);
if (recentlist.Count > MAX_RECENT_FILES)
{
recentlist.Remove(recentlist[recentlist.Count - 1]);
} }
} }
public bool Remove(string newFile) public bool Remove(string newFile)
{ {
bool removed = false; bool removed = false;
for (int x = 0; x < recentlist.Count; x++) foreach(string recent in _recent_list)
{ {
if (string.Compare(newFile, recentlist[x]) == 0) if (string.Compare(newFile, recent, true) == 0)
{ {
recentlist.Remove(newFile); //intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place _recent_list.Remove(newFile); //intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place
removed = true; removed = true;
} }
} }
@ -63,14 +67,14 @@ namespace BizHawk.MultiClient
public List<string> GetRecentListTruncated(int length) public List<string> GetRecentListTruncated(int length)
{ {
//iterate through list, truncating each item to length, and return the result in a List<string> //iterate through list, truncating each item to length, and return the result in a List<string>
return recentlist.Select(t => t.Substring(0, length)).ToList(); return _recent_list.Select(t => t.Substring(0, length)).ToList();
} }
public string GetRecentFileByPosition(int position) public string GetRecentFileByPosition(int position)
{ {
if (recentlist.Count > 0) if (_recent_list.Count > 0)
{ {
return recentlist[position]; return _recent_list[position];
} }
else else
{ {

View File

@ -41,8 +41,30 @@ namespace BizHawk.MultiClient
string p = Global.Config.FirmwaresPath; string p = Global.Config.FirmwaresPath;
FileInfo file; FileInfo file;
file = new FileInfo(Path.Combine(p, Global.Config.FilenameFDSBios)); //FDS
if (file.Exists) Disksys_ROM_PicBox.Image = MultiClient.Properties.Resources.GreenCheck; else Disksys_ROM_PicBox.Image = MultiClient.Properties.Resources.ExclamationRed; CheckFile(Global.Config.FilenameFDSBios, Disksys_ROM_PicBox);
//SNES
CheckFile("cx4.rom", CX4_PicBox);
CheckFile("dsp1b.rom", DSP1B_ROM_PicBox);
CheckFile("dsp2.rom", DSP2_ROM_PicBox);
CheckFile("dsp3.rom", DSP3_ROM_PicBox);
CheckFile("dsp4.rom", DSP4_ROM_PicBox);
CheckFile("st010.rom", ST010_ROM_PicBox);
CheckFile("st011.rom", ST011_ROM_PicBox);
CheckFile("st018.rom", ST018_ROM_PicBox);
//SGB
CheckFile("sgb.sfc", SGB_SFC_PicBox);
//PCE
//CheckFile(Global.Config.Path
}
private void CheckFile(string filename, PictureBox pic)
{
FileInfo file = new FileInfo(Path.Combine(Global.Config.FirmwaresPath, filename));
if (file.Exists) pic.Image = MultiClient.Properties.Resources.GreenCheck; else pic.Image = MultiClient.Properties.Resources.ExclamationRed;
} }
} }
} }