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:
parent
3dc4611263
commit
d0071f58d2
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
|
@ -6,54 +7,57 @@ namespace BizHawk.MultiClient
|
|||
public class RecentFiles
|
||||
{
|
||||
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)
|
||||
{
|
||||
recentlist = new List<string>();
|
||||
_recent_list = new List<string>();
|
||||
MAX_RECENT_FILES = max;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
recentlist.Clear();
|
||||
_recent_list.Clear();
|
||||
}
|
||||
|
||||
public bool Empty
|
||||
{
|
||||
get { return recentlist.Count == 0; }
|
||||
get { return _recent_list.Count == 0; }
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return recentlist.Count; }
|
||||
get { return _recent_list.Count; }
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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]);
|
||||
_recent_list.Remove(_recent_list[_recent_list.Count - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Remove(string newFile)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -63,14 +67,14 @@ namespace BizHawk.MultiClient
|
|||
public List<string> GetRecentListTruncated(int length)
|
||||
{
|
||||
//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)
|
||||
{
|
||||
if (recentlist.Count > 0)
|
||||
if (_recent_list.Count > 0)
|
||||
{
|
||||
return recentlist[position];
|
||||
return _recent_list[position];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -41,8 +41,30 @@ namespace BizHawk.MultiClient
|
|||
string p = Global.Config.FirmwaresPath;
|
||||
FileInfo file;
|
||||
|
||||
file = new FileInfo(Path.Combine(p, Global.Config.FilenameFDSBios));
|
||||
if (file.Exists) Disksys_ROM_PicBox.Image = MultiClient.Properties.Resources.GreenCheck; else Disksys_ROM_PicBox.Image = MultiClient.Properties.Resources.ExclamationRed;
|
||||
//FDS
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue