Skip to content

Commit

Permalink
Unimplement IEnumerable on RecentFiles and PathEntryCollection
Browse files Browse the repository at this point in the history
  • Loading branch information
YoshiRulz committed Jun 6, 2024
1 parent fab1fae commit 75502e7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
5 changes: 1 addition & 4 deletions src/BizHawk.Client.Common/RecentFiles.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;

namespace BizHawk.Client.Common
{
[JsonObject]
public class RecentFiles : IEnumerable<string>
public class RecentFiles
{
// ReSharper disable once FieldCanBeMadeReadOnly.Local
private List<string> recentlist;
Expand Down Expand Up @@ -43,7 +41,6 @@ public RecentFiles(int max)
public string this[int index] => recentlist.Any() ? recentlist[index] : "";

public IEnumerator<string> GetEnumerator() => recentlist.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

public void Clear()
{
Expand Down
7 changes: 1 addition & 6 deletions src/BizHawk.Client.Common/config/PathEntryCollection.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand All @@ -12,8 +11,7 @@

namespace BizHawk.Client.Common
{
[JsonObject]
public class PathEntryCollection : IEnumerable<PathEntry>
public class PathEntryCollection
{
private static readonly string COMBINED_SYSIDS_GB = string.Join("_", VSystemID.Raw.GB, VSystemID.Raw.GBC, VSystemID.Raw.SGB);

Expand Down Expand Up @@ -120,9 +118,6 @@ public PathEntryCollection() : this(new List<PathEntry>(Defaults.Value)) {}
public bool UseRecentForRoms { get; set; }
public string LastRomPath { get; set; } = ".";

public IEnumerator<PathEntry> GetEnumerator() => Paths.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

public PathEntry this[string system, string type]
=> Paths.Find(p => p.IsSystem(system) && p.Type == type) ?? TryGetDebugPath(system, type);

Expand Down
6 changes: 3 additions & 3 deletions src/BizHawk.Client.EmuHawk/config/PathConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private void LoadSettings()
{
RecentForROMs.Checked = _pathEntries.UseRecentForRoms;

DoTabs(_pathEntries.ToList(), _sysID);
DoTabs(_pathEntries.Paths, focusTabOfSystem: _sysID);
DoRomToggle();
}

Expand Down Expand Up @@ -135,7 +135,7 @@ void AddTabPageForSystem(string system, string systemDisplayName)
tcMain.Visible = false;

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)))
.OrderBy(tuple => tuple.DisplayName)
.ToList();
Expand Down Expand Up @@ -218,7 +218,7 @@ private void SaveSettings()

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;
}

Expand Down

0 comments on commit 75502e7

Please sign in to comment.