Unimplement `IEnumerable` on `RecentFiles` and `PathEntryCollection`
This commit is contained in:
parent
fab1fae66a
commit
75502e7ffb
|
@ -1,13 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace BizHawk.Client.Common
|
namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
[JsonObject]
|
public class RecentFiles
|
||||||
public class RecentFiles : IEnumerable<string>
|
|
||||||
{
|
{
|
||||||
// ReSharper disable once FieldCanBeMadeReadOnly.Local
|
// ReSharper disable once FieldCanBeMadeReadOnly.Local
|
||||||
private List<string> recentlist;
|
private List<string> recentlist;
|
||||||
|
@ -43,7 +41,6 @@ namespace BizHawk.Client.Common
|
||||||
public string this[int index] => recentlist.Any() ? recentlist[index] : "";
|
public string this[int index] => recentlist.Any() ? recentlist[index] : "";
|
||||||
|
|
||||||
public IEnumerator<string> GetEnumerator() => recentlist.GetEnumerator();
|
public IEnumerator<string> GetEnumerator() => recentlist.GetEnumerator();
|
||||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
||||||
|
|
||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -12,8 +11,7 @@ using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace BizHawk.Client.Common
|
namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
[JsonObject]
|
public class PathEntryCollection
|
||||||
public class PathEntryCollection : IEnumerable<PathEntry>
|
|
||||||
{
|
{
|
||||||
private static readonly string COMBINED_SYSIDS_GB = string.Join("_", VSystemID.Raw.GB, VSystemID.Raw.GBC, VSystemID.Raw.SGB);
|
private static readonly string COMBINED_SYSIDS_GB = string.Join("_", VSystemID.Raw.GB, VSystemID.Raw.GBC, VSystemID.Raw.SGB);
|
||||||
|
|
||||||
|
@ -120,9 +118,6 @@ namespace BizHawk.Client.Common
|
||||||
public bool UseRecentForRoms { get; set; }
|
public bool UseRecentForRoms { get; set; }
|
||||||
public string LastRomPath { get; set; } = ".";
|
public string LastRomPath { get; set; } = ".";
|
||||||
|
|
||||||
public IEnumerator<PathEntry> GetEnumerator() => Paths.GetEnumerator();
|
|
||||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
||||||
|
|
||||||
public PathEntry this[string system, string type]
|
public PathEntry this[string system, string type]
|
||||||
=> Paths.Find(p => p.IsSystem(system) && p.Type == type) ?? TryGetDebugPath(system, type);
|
=> Paths.Find(p => p.IsSystem(system) && p.Type == type) ?? TryGetDebugPath(system, type);
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
RecentForROMs.Checked = _pathEntries.UseRecentForRoms;
|
RecentForROMs.Checked = _pathEntries.UseRecentForRoms;
|
||||||
|
|
||||||
DoTabs(_pathEntries.ToList(), _sysID);
|
DoTabs(_pathEntries.Paths, focusTabOfSystem: _sysID);
|
||||||
DoRomToggle();
|
DoRomToggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
tcMain.Visible = false;
|
tcMain.Visible = false;
|
||||||
|
|
||||||
PathTabControl.TabPages.Clear();
|
PathTabControl.TabPages.Clear();
|
||||||
var systems = _pathEntries.Select(e => e.System).Distinct() // group entries by "system" (intentionally using instance field here, not parameter)
|
var systems = _pathEntries.Paths.Select(static e => e.System).Distinct() // group entries by "system" (intentionally using instance field here, not parameter)
|
||||||
.Select(sys => (SysGroup: sys, DisplayName: PathEntryCollection.GetDisplayNameFor(sys)))
|
.Select(sys => (SysGroup: sys, DisplayName: PathEntryCollection.GetDisplayNameFor(sys)))
|
||||||
.OrderBy(tuple => tuple.DisplayName)
|
.OrderBy(tuple => tuple.DisplayName)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
@ -218,7 +218,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
foreach (var t in AllPathControls.OfType<TextBox>())
|
foreach (var t in AllPathControls.OfType<TextBox>())
|
||||||
{
|
{
|
||||||
var pathEntry = _pathEntries.First(p => p.System == t.Parent.Name && p.Type == t.Name);
|
var pathEntry = _pathEntries.Paths.First(p => p.System == t.Parent.Name && p.Type == t.Name);
|
||||||
pathEntry.Path = t.Text;
|
pathEntry.Path = t.Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue