Refactor `yield`ing methods to direct, stateless returns
This commit is contained in:
parent
166f1d537e
commit
dfe8b1308c
|
@ -72,14 +72,14 @@ namespace BizHawk.Client.Common
|
||||||
=> new(sysID, "Cheats", Path.Combine(".", "Cheats"));
|
=> new(sysID, "Cheats", Path.Combine(".", "Cheats"));
|
||||||
|
|
||||||
private static IEnumerable<PathEntry> CommonEntriesFor(string sysID, string basePath, bool omitSaveRAM = false)
|
private static IEnumerable<PathEntry> CommonEntriesFor(string sysID, string basePath, bool omitSaveRAM = false)
|
||||||
{
|
=> [
|
||||||
yield return BaseEntryFor(sysID, basePath);
|
BaseEntryFor(sysID, basePath),
|
||||||
yield return ROMEntryFor(sysID);
|
ROMEntryFor(sysID),
|
||||||
yield return SavestatesEntryFor(sysID);
|
SavestatesEntryFor(sysID),
|
||||||
if (!omitSaveRAM) yield return SaveRAMEntryFor(sysID);
|
..(omitSaveRAM ? [ ] : new[] { SaveRAMEntryFor(sysID) }),
|
||||||
yield return ScreenshotsEntryFor(sysID);
|
ScreenshotsEntryFor(sysID),
|
||||||
yield return CheatsEntryFor(sysID);
|
CheatsEntryFor(sysID),
|
||||||
}
|
];
|
||||||
|
|
||||||
public static string GetDisplayNameFor(string sysID)
|
public static string GetDisplayNameFor(string sysID)
|
||||||
=> _displayNameLookup.GetValueOrPut(sysID, static s => s + " (INTERIM)");
|
=> _displayNameLookup.GetValueOrPut(sysID, static s => s + " (INTERIM)");
|
||||||
|
|
|
@ -35,16 +35,12 @@ namespace BizHawk.Client.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets an enumeration of <see cref="WatchDisplayType"/> that are valid for a <see cref="ByteWatch"/>
|
/// Gets an enumeration of <see cref="WatchDisplayType"/> that are valid for a <see cref="ByteWatch"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static IEnumerable<WatchDisplayType> ValidTypes
|
public static IEnumerable<WatchDisplayType> ValidTypes { get; } = [
|
||||||
{
|
WatchDisplayType.Unsigned,
|
||||||
get
|
WatchDisplayType.Signed,
|
||||||
{
|
WatchDisplayType.Hex,
|
||||||
yield return WatchDisplayType.Unsigned;
|
WatchDisplayType.Binary,
|
||||||
yield return WatchDisplayType.Signed;
|
];
|
||||||
yield return WatchDisplayType.Hex;
|
|
||||||
yield return WatchDisplayType.Binary;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a list a <see cref="WatchDisplayType"/> that can be used for this <see cref="ByteWatch"/>
|
/// Get a list a <see cref="WatchDisplayType"/> that can be used for this <see cref="ByteWatch"/>
|
||||||
|
|
|
@ -36,19 +36,15 @@ namespace BizHawk.Client.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list of <see cref="WatchDisplayType"/> for a <see cref="DWordWatch"/>
|
/// Gets a list of <see cref="WatchDisplayType"/> for a <see cref="DWordWatch"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static IEnumerable<WatchDisplayType> ValidTypes
|
public static IEnumerable<WatchDisplayType> ValidTypes { get; } = [
|
||||||
{
|
WatchDisplayType.Unsigned,
|
||||||
get
|
WatchDisplayType.Signed,
|
||||||
{
|
WatchDisplayType.Hex,
|
||||||
yield return WatchDisplayType.Unsigned;
|
WatchDisplayType.Binary,
|
||||||
yield return WatchDisplayType.Signed;
|
WatchDisplayType.FixedPoint_20_12,
|
||||||
yield return WatchDisplayType.Hex;
|
WatchDisplayType.FixedPoint_16_16,
|
||||||
yield return WatchDisplayType.Binary;
|
WatchDisplayType.Float,
|
||||||
yield return WatchDisplayType.FixedPoint_20_12;
|
];
|
||||||
yield return WatchDisplayType.FixedPoint_16_16;
|
|
||||||
yield return WatchDisplayType.Float;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a list of <see cref="WatchDisplayType"/> that can be used for a <see cref="DWordWatch"/>
|
/// Get a list of <see cref="WatchDisplayType"/> that can be used for a <see cref="DWordWatch"/>
|
||||||
|
|
|
@ -34,9 +34,7 @@ namespace BizHawk.Client.Common
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>WatchDisplayType.Separator nothing else</returns>
|
/// <returns>WatchDisplayType.Separator nothing else</returns>
|
||||||
public override IEnumerable<WatchDisplayType> AvailableTypes()
|
public override IEnumerable<WatchDisplayType> AvailableTypes()
|
||||||
{
|
=> [ WatchDisplayType.Separator ];
|
||||||
yield return WatchDisplayType.Separator;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ignore that stuff
|
/// Ignore that stuff
|
||||||
|
|
|
@ -35,17 +35,13 @@ namespace BizHawk.Client.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets an Enumeration of <see cref="WatchDisplayType"/>s that are valid for a <see cref="WordWatch"/>
|
/// Gets an Enumeration of <see cref="WatchDisplayType"/>s that are valid for a <see cref="WordWatch"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static IEnumerable<WatchDisplayType> ValidTypes
|
public static IEnumerable<WatchDisplayType> ValidTypes { get; } = [
|
||||||
{
|
WatchDisplayType.Unsigned,
|
||||||
get
|
WatchDisplayType.Signed,
|
||||||
{
|
WatchDisplayType.Hex,
|
||||||
yield return WatchDisplayType.Unsigned;
|
WatchDisplayType.Binary,
|
||||||
yield return WatchDisplayType.Signed;
|
WatchDisplayType.FixedPoint_12_4,
|
||||||
yield return WatchDisplayType.Hex;
|
];
|
||||||
yield return WatchDisplayType.Binary;
|
|
||||||
yield return WatchDisplayType.FixedPoint_12_4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a list a <see cref="WatchDisplayType"/> that can be used for this <see cref="WordWatch"/>
|
/// Get a list a <see cref="WatchDisplayType"/> that can be used for this <see cref="WordWatch"/>
|
||||||
|
|
|
@ -977,8 +977,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public IEnumerable<ToolStripItem> GenerateContextMenuItems()
|
public IEnumerable<ToolStripItem> GenerateContextMenuItems()
|
||||||
{
|
{
|
||||||
if (!Rotatable) yield break;
|
if (!Rotatable) return [ ];
|
||||||
yield return new ToolStripSeparator();
|
|
||||||
var rotate = new ToolStripMenuItem
|
var rotate = new ToolStripMenuItem
|
||||||
{
|
{
|
||||||
Name = "RotateMenuItem",
|
Name = "RotateMenuItem",
|
||||||
|
@ -986,7 +985,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
ShortcutKeyDisplayString = RotateHotkeyStr
|
ShortcutKeyDisplayString = RotateHotkeyStr
|
||||||
};
|
};
|
||||||
rotate.Click += (_, _) => HorizontalOrientation = !HorizontalOrientation;
|
rotate.Click += (_, _) => HorizontalOrientation = !HorizontalOrientation;
|
||||||
yield return rotate;
|
return [ new ToolStripSeparator(), rotate ];
|
||||||
}
|
}
|
||||||
|
|
||||||
public string RotateHotkeyStr => "Ctrl+Shift+F";
|
public string RotateHotkeyStr => "Ctrl+Shift+F";
|
||||||
|
|
|
@ -10,13 +10,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
||||||
private IDebuggable _selectedDebuggable;
|
private IDebuggable _selectedDebuggable;
|
||||||
|
|
||||||
private IEnumerable<IDebuggable> GetAvailableDebuggables()
|
private IEnumerable<IDebuggable> GetAvailableDebuggables()
|
||||||
{
|
=> _board.DiskDrive is IDebuggable dd ? [ _board.Cpu, dd ] : [ _board.Cpu ];
|
||||||
yield return _board.Cpu;
|
|
||||||
if (_board.DiskDrive != null)
|
|
||||||
{
|
|
||||||
yield return _board.DiskDrive;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetDefaultDebuggable()
|
private void SetDefaultDebuggable()
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,13 +10,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
||||||
private IDisassemblable _selectedDisassemblable;
|
private IDisassemblable _selectedDisassemblable;
|
||||||
|
|
||||||
private IEnumerable<IDisassemblable> GetAvailableDisassemblables()
|
private IEnumerable<IDisassemblable> GetAvailableDisassemblables()
|
||||||
{
|
=> _board.DiskDrive is IDisassemblable dd ? [ _board.Cpu, dd ] : [ _board.Cpu ];
|
||||||
yield return _board.Cpu;
|
|
||||||
if (_board.DiskDrive != null)
|
|
||||||
{
|
|
||||||
yield return _board.DiskDrive;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetDefaultDisassemblable()
|
private void SetDefaultDisassemblable()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue