misc cleanups in Client.Common

This commit is contained in:
adelikat 2020-12-04 15:39:52 -06:00
parent 206817dab8
commit e0c1fc4a4d
24 changed files with 70 additions and 78 deletions

View File

@ -95,6 +95,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IRQ/@EntryIndexedValue">IRQ</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IRQ/@EntryIndexedValue">IRQ</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=LR/@EntryIndexedValue">LR</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=LR/@EntryIndexedValue">LR</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MGBA/@EntryIndexedValue">MGBA</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MGBA/@EntryIndexedValue">MGBA</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NDS/@EntryIndexedValue">NDS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NES/@EntryIndexedValue">NES</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NES/@EntryIndexedValue">NES</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NMI/@EntryIndexedValue">NMI</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NMI/@EntryIndexedValue">NMI</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NT/@EntryIndexedValue">NT</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NT/@EntryIndexedValue">NT</s:String>
@ -117,6 +118,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SGX/@EntryIndexedValue">SGX</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SGX/@EntryIndexedValue">SGX</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SHA/@EntryIndexedValue">SHA</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SHA/@EntryIndexedValue">SHA</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SNES/@EntryIndexedValue">SNES</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SNES/@EntryIndexedValue">SNES</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SQ/@EntryIndexedValue">SQ</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TA/@EntryIndexedValue">TA</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TA/@EntryIndexedValue">TA</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TAS/@EntryIndexedValue">TAS</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TAS/@EntryIndexedValue">TAS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TI/@EntryIndexedValue">TI</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TI/@EntryIndexedValue">TI</s:String>
@ -261,6 +263,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=colesced/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=colesced/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Colour/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Colour/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Commavid/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Commavid/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Comparers/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Compositing/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Compositing/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Compumate/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Compumate/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Conout/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Conout/@EntryIndexedValue">True</s:Boolean>
@ -272,6 +275,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=curr/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=curr/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=CURRINDEX/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=CURRINDEX/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=CURRTRACK/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=CURRTRACK/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Cygne/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Cyotek/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Cyotek/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Daaaaaaa/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Daaaaaaa/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=databus/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=databus/@EntryIndexedValue">True</s:Boolean>
@ -306,6 +310,8 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=endianess/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=endianess/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=endrift/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=endrift/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=EPRO/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=EPRO/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Exts/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Faaaaaaa/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Faaaaaaa/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Fairchild/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Fairchild/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Famicom/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Famicom/@EntryIndexedValue">True</s:Boolean>

View File

@ -8,7 +8,7 @@ using BizHawk.Client.Common;
namespace BizHawk.Bizware.DirectX namespace BizHawk.Bizware.DirectX
{ {
public sealed class DirectInputAdapter : HostInputAdapter public sealed class DirectInputAdapter : IHostInputAdapter
{ {
private Config? _config; private Config? _config;

View File

@ -196,7 +196,7 @@ namespace BizHawk.Client.Common
QuickNES quickNes => quickNes.GetSettings(), QuickNES quickNes => quickNes.GetSettings(),
SMS sms => sms.GetSettings(), SMS sms => sms.GetSettings(),
WonderSwan ws => ws.GetSettings(), WonderSwan ws => ws.GetSettings(),
_ => (object) null _ => null
}; };
public PutSettingsDirtyBits PutSettings(object settings) => Emulator switch public PutSettingsDirtyBits PutSettings(object settings) => Emulator switch
@ -214,7 +214,7 @@ namespace BizHawk.Client.Common
public void SetRenderPlanes(params bool[] args) public void SetRenderPlanes(params bool[] args)
{ {
static bool GetSetting(bool[] settings, int index) => index >= settings.Length || settings[index]; static bool GetSetting(bool[] settings, int index) => index >= settings.Length || settings[index];
void SetBSNES(LibsnesCore core) void SetBsnes(LibsnesCore core)
{ {
var s = core.GetSettings(); var s = core.GetSettings();
s.ShowBG1_0 = s.ShowBG1_1 = GetSetting(args, 0); s.ShowBG1_0 = s.ShowBG1_1 = GetSetting(args, 0);
@ -273,7 +273,7 @@ namespace BizHawk.Client.Common
else if (!showSp && s.NumSprites > 0) s.NumSprites = 0; else if (!showSp && s.NumSprites > 0) s.NumSprites = 0;
quicknes.PutSettings(s); quicknes.PutSettings(s);
} }
void SetSMSHawk(SMS sms) void SetSmsHawk(SMS sms)
{ {
var s = sms.GetSettings(); var s = sms.GetSettings();
s.DispOBJ = GetSetting(args, 0); s.DispOBJ = GetSetting(args, 0);
@ -286,7 +286,7 @@ namespace BizHawk.Client.Common
SetGPGX(gpgx); SetGPGX(gpgx);
break; break;
case LibsnesCore snes: case LibsnesCore snes:
SetBSNES(snes); SetBsnes(snes);
break; break;
case NES nes: case NES nes:
SetNesHawk(nes); SetNesHawk(nes);
@ -298,7 +298,7 @@ namespace BizHawk.Client.Common
SetQuickNES(quicknes); SetQuickNES(quicknes);
break; break;
case SMS sms: case SMS sms:
SetSMSHawk(sms); SetSmsHawk(sms);
break; break;
case WonderSwan ws: case WonderSwan ws:
SetCygne(ws); SetCygne(ws);

View File

@ -165,7 +165,7 @@ namespace BizHawk.Client.Common
} }
case 4: case 4:
{ {
d.PokeUint(addr, (uint)value, _isBigEndian); d.PokeUint(addr, value, _isBigEndian);
break; break;
} }
} }

View File

@ -36,8 +36,8 @@ namespace BizHawk.Client.Common.Filters
var output = FindOutput(channel); var output = FindOutput(channel);
if (input != null && output != null) if (input != null && output != null)
{ {
point.X *= ((float)input.SurfaceFormat.Size.Width) / (float)output.SurfaceFormat.Size.Width; point.X *= input.SurfaceFormat.Size.Width / (float)output.SurfaceFormat.Size.Width;
point.Y *= ((float)input.SurfaceFormat.Size.Height) / (float)output.SurfaceFormat.Size.Height; point.Y *= input.SurfaceFormat.Size.Height / (float)output.SurfaceFormat.Size.Height;
} }
return point; return point;
} }
@ -49,8 +49,8 @@ namespace BizHawk.Client.Common.Filters
var output = FindOutput(channel); var output = FindOutput(channel);
if (input != null && output != null) if (input != null && output != null)
{ {
point.X *= ((float)output.SurfaceFormat.Size.Width) / (float)input.SurfaceFormat.Size.Width; point.X *= output.SurfaceFormat.Size.Width / (float)input.SurfaceFormat.Size.Width;
point.Y *= ((float)output.SurfaceFormat.Size.Height) / (float)input.SurfaceFormat.Size.Height; point.Y *= output.SurfaceFormat.Size.Height / (float)input.SurfaceFormat.Size.Height;
} }
return point; return point;
} }

View File

@ -40,8 +40,8 @@ namespace BizHawk.Client.Common.Filters
//zero 02-jun-2014 - we passed these in, but ignored them. kind of weird.. //zero 02-jun-2014 - we passed these in, but ignored them. kind of weird..
int oldSourceWidth = sourceWidth; int oldSourceWidth = sourceWidth;
int oldSourceHeight = sourceHeight; int oldSourceHeight = sourceHeight;
sourceWidth = (int)virtualWidth; sourceWidth = virtualWidth;
sourceHeight = (int)virtualHeight; sourceHeight = virtualHeight;
// this doesn't make sense // this doesn't make sense
if (!maintainAspect) if (!maintainAspect)
@ -83,7 +83,7 @@ namespace BizHawk.Client.Common.Filters
PS + new Vector2(1, 1) PS + new Vector2(1, 1)
}; };
bool[] trialsLimited = new bool[3] { false,false,false}; bool[] trialsLimited = new bool[] { false, false, false};
int bestIndex = -1; int bestIndex = -1;
float bestValue = 1000.0f; float bestValue = 1000.0f;
for (int t = 0; t < trials.Length; t++) for (int t = 0; t < trials.Length; t++)
@ -177,7 +177,7 @@ namespace BizHawk.Client.Common.Filters
public IGL GL; public IGL GL;
public IGuiRenderer GuiRenderer; public IGuiRenderer GuiRenderer;
private MelonDS nds; private readonly MelonDS nds;
//TODO: actually use this //TODO: actually use this
private bool nop = false; private bool nop = false;
@ -344,7 +344,7 @@ namespace BizHawk.Client.Common.Filters
{ {
point = Transform(matBotInvert, point); point = Transform(matBotInvert, point);
//hack to accomodate input tracking system's float-point sense (based on the core's videobuffer height) //hack to accomodate input tracking system's float-point sense (based on the core's VideoBuffer height)
//actually, this is needed for a reason similar to the "TouchScreenStart" that I removed. //actually, this is needed for a reason similar to the "TouchScreenStart" that I removed.
//So, something like that needs readding if we're to get rid of this hack. //So, something like that needs readding if we're to get rid of this hack.
//(should redo it as a mouse coordinate offset or something.. but the key is to pipe it to the point where this is needed.. that is where MainForm does DisplayManager.UntransformPoint() //(should redo it as a mouse coordinate offset or something.. but the key is to pipe it to the point where this is needed.. that is where MainForm does DisplayManager.UntransformPoint()
@ -425,7 +425,7 @@ namespace BizHawk.Client.Common.Filters
public FinalPresentation(Size size) public FinalPresentation(Size size)
{ {
this.OutputSize = size; OutputSize = size;
} }
private Size OutputSize, InputSize; private Size OutputSize, InputSize;
@ -489,13 +489,7 @@ namespace BizHawk.Client.Common.Filters
public override void SetInputFormat(string channel, SurfaceState state) public override void SetInputFormat(string channel, SurfaceState state)
{ {
bool need = false; bool need = state.SurfaceFormat.Size != OutputSize || FilterOption != eFilterOption.None || Flip;
if (state.SurfaceFormat.Size != OutputSize)
need = true;
if (FilterOption != eFilterOption.None)
need = true;
if (Flip)
need = true;
if (!need) if (!need)
{ {

View File

@ -153,7 +153,7 @@ namespace BizHawk.Client.Common.Filters
Passes.Add(sp); Passes.Add(sp);
sp.InputFilterLinear = FetchBool(dict, $"filter_linear{i}", false); //Should this value not be defined, the filtering option is implementation defined. sp.InputFilterLinear = FetchBool(dict, $"filter_linear{i}", false); //Should this value not be defined, the filtering option is implementation defined.
sp.OuputFloat = FetchBool(dict, $"float_framebuffer{i}", false); sp.OutputFloat = FetchBool(dict, $"float_framebuffer{i}", false);
sp.FrameCountMod = FetchInt(dict, $"frame_count_mod{i}", 1); sp.FrameCountMod = FetchInt(dict, $"frame_count_mod{i}", 1);
sp.ShaderPath = FetchString(dict, $"shader{i}", "?"); //todo - change extension to .cg for better compatibility? just change .cg to .glsl transparently at last second? sp.ShaderPath = FetchString(dict, $"shader{i}", "?"); //todo - change extension to .cg for better compatibility? just change .cg to .glsl transparently at last second?
@ -191,24 +191,24 @@ namespace BizHawk.Client.Common.Filters
public int Index; public int Index;
public string ShaderPath; public string ShaderPath;
public bool InputFilterLinear; public bool InputFilterLinear;
public bool OuputFloat; public bool OutputFloat;
public int FrameCountMod; public int FrameCountMod;
public ScaleType ScaleTypeX; public ScaleType ScaleTypeX;
public ScaleType ScaleTypeY; public ScaleType ScaleTypeY;
public Vector2 Scale; public Vector2 Scale;
} }
private string FetchString(IDictionary<string, string> dict, string key, string @default) private static string FetchString(IDictionary<string, string> dict, string key, string @default)
{ {
return dict.TryGetValue(key, out var str) ? str : @default; return dict.TryGetValue(key, out var str) ? str : @default;
} }
private int FetchInt(IDictionary<string, string> dict, string key, int @default) private static int FetchInt(IDictionary<string, string> dict, string key, int @default)
{ {
return dict.TryGetValue(key, out var str) ? int.Parse(str) : @default; return dict.TryGetValue(key, out var str) ? int.Parse(str) : @default;
} }
private float FetchFloat(IDictionary<string, string> dict, string key, float @default) private static float FetchFloat(IDictionary<string, string> dict, string key, float @default)
{ {
return dict.TryGetValue(key, out var str) ? float.Parse(str) : @default; return dict.TryGetValue(key, out var str) ? float.Parse(str) : @default;
} }

View File

@ -14,7 +14,7 @@ namespace BizHawk.Client.Common
{ {
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{ {
return ((sourceType == typeof(string)) || base.CanConvertFrom(context, sourceType)); return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
} }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
@ -44,7 +44,7 @@ namespace BizHawk.Client.Common
{ {
if (destinationType == null) if (destinationType == null)
{ {
throw new ArgumentNullException("destinationType"); throw new ArgumentNullException(nameof(destinationType));
} }
if (destinationType == typeof(string)) if (destinationType == typeof(string))

View File

@ -5,6 +5,7 @@ using System.Runtime.InteropServices;
using BizHawk.Common; using BizHawk.Common;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
// ReSharper disable FieldCanBeMadeReadOnly.Local
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
// ReSharper disable StyleCop.SA1304 // ReSharper disable StyleCop.SA1304
// ReSharper disable StyleCop.SA1307 // ReSharper disable StyleCop.SA1307

View File

@ -98,11 +98,6 @@ namespace BizHawk.Client.Common
// For not throwing errors but simply outputting information to the screen // For not throwing errors but simply outputting information to the screen
public Action<string> MessageCallback { get; set; } public Action<string> MessageCallback { get; set; }
private void DoMessageCallback(string message)
{
MessageCallback?.Invoke(message);
}
// TODO: reconsider the need for exposing these; // TODO: reconsider the need for exposing these;
public IEmulator LoadedEmulator { get; private set; } public IEmulator LoadedEmulator { get; private set; }
public GameInfo Game { get; private set; } public GameInfo Game { get; private set; }
@ -237,7 +232,6 @@ namespace BizHawk.Client.Common
private GameInfo MakeGameFromDisc(Disc disc, string ext, string name) private GameInfo MakeGameFromDisc(Disc disc, string ext, string name)
{ {
GameInfo game;
// TODO - use more sophisticated IDer // TODO - use more sophisticated IDer
var discType = new DiscIdentifier(disc).DetectDiscType(); var discType = new DiscIdentifier(disc).DetectDiscType();
var discHasher = new DiscHasher(disc); var discHasher = new DiscHasher(disc);
@ -245,7 +239,7 @@ namespace BizHawk.Client.Common
? discHasher.Calculate_PSX_BizIDHash().ToString("X8") ? discHasher.Calculate_PSX_BizIDHash().ToString("X8")
: discHasher.OldHash(); : discHasher.OldHash();
game = Database.CheckDatabase(discHash); var game = Database.CheckDatabase(discHash);
if (game == null) if (game == null)
{ {
// try to use our wizard methods // try to use our wizard methods

View File

@ -21,7 +21,7 @@ namespace BizHawk.Client.Common
* Why use this, when each core has it's own Async sound output? * Why use this, when each core has it's own Async sound output?
* *
* It is true that each emulation core provides its own async sound output, either through directly * It is true that each emulation core provides its own async sound output, either through directly
* rendering to arbitrary buffers (pce not turbocd, sms), or using one of the metaspus (nes, turbocd). * rendering to arbitrary buffers (pce not TurboCD, sms), or using one of the metaspus (nes, TurboCD).
* *
* Unfortunately, the vecna metaspu is not perfect, and for maintaining near-realtime playback (the usual * Unfortunately, the vecna metaspu is not perfect, and for maintaining near-realtime playback (the usual
* situation which we want to optimize for), it simply sounds better with a BufferedAsync on top of it. * situation which we want to optimize for), it simply sounds better with a BufferedAsync on top of it.

View File

@ -47,7 +47,7 @@ namespace BizHawk.Client.Common.cheats
}; };
private IDecodeResult GameBoy(string code) private static IDecodeResult GameBoy(string code)
{ {
// Game Genie // Game Genie
if (code.LastIndexOf("-") == 7 && code.IndexOf("-") == 3) if (code.LastIndexOf("-") == 7 && code.IndexOf("-") == 3)
@ -65,7 +65,7 @@ namespace BizHawk.Client.Common.cheats
return new InvalidCheatCode($"Unknown code type: {code}"); return new InvalidCheatCode($"Unknown code type: {code}");
} }
private IDecodeResult Gba(string code) private static IDecodeResult Gba(string code)
{ {
if (code.Length == 12) if (code.Length == 12)
{ {
@ -75,7 +75,7 @@ namespace BizHawk.Client.Common.cheats
return GbaGameSharkDecoder.Decode(code); return GbaGameSharkDecoder.Decode(code);
} }
private IDecodeResult Gen(string code) private static IDecodeResult Gen(string code)
{ {
// Game Genie only // Game Genie only
if (code.Length == 9 && code.Contains("-")) if (code.Length == 9 && code.Contains("-"))
@ -99,15 +99,15 @@ namespace BizHawk.Client.Common.cheats
return new InvalidCheatCode($"Unknown code type: {code}"); return new InvalidCheatCode($"Unknown code type: {code}");
} }
private IDecodeResult N64(string code) => N64GameSharkDecoder.Decode(code); private static IDecodeResult N64(string code) => N64GameSharkDecoder.Decode(code);
private IDecodeResult Nes(string code) => NesGameGenieDecoder.Decode(code); private static IDecodeResult Nes(string code) => NesGameGenieDecoder.Decode(code);
private IDecodeResult Psx(string code) => PsxGameSharkDecoder.Decode(code); private static IDecodeResult Psx(string code) => PsxGameSharkDecoder.Decode(code);
private IDecodeResult Saturn(string code) => SaturnGameSharkDecoder.Decode(code); private static IDecodeResult Saturn(string code) => SaturnGameSharkDecoder.Decode(code);
private IDecodeResult Sms(string code) private static IDecodeResult Sms(string code)
{ {
// Game Genie // Game Genie
if (code.LastIndexOf("-") == 7 && code.IndexOf("-") == 3) if (code.LastIndexOf("-") == 7 && code.IndexOf("-") == 3)
@ -124,7 +124,7 @@ namespace BizHawk.Client.Common.cheats
return new InvalidCheatCode($"Unknown code type: {code}"); return new InvalidCheatCode($"Unknown code type: {code}");
} }
private IDecodeResult Snes(string code) private static IDecodeResult Snes(string code)
{ {
if (code.Contains("-") && code.Length == 9) if (code.Contains("-") && code.Length == 9)
{ {

View File

@ -1,5 +1,8 @@
#nullable enable #nullable enable
// ReSharper disable CommentTypo
// ReSharper disable IdentifierTypo
// ReSharper disable UnusedMember.Global
namespace BizHawk.Client.Common namespace BizHawk.Client.Common
{ {
/// <summary>values are one-to-one with <c>System.Windows.Input.Key</c> except <see cref="NumPadEnter"/> and <see cref="Unknown"/> which were added for this project</summary> /// <summary>values are one-to-one with <c>System.Windows.Input.Key</c> except <see cref="NumPadEnter"/> and <see cref="Unknown"/> which were added for this project</summary>

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
namespace BizHawk.Client.Common namespace BizHawk.Client.Common
{ {
/// <remarks>this was easier than trying to make static classes instantiable...</remarks> /// <remarks>this was easier than trying to make static classes instantiable...</remarks>
public interface HostInputAdapter public interface IHostInputAdapter
{ {
void DeInitAll(); void DeInitAll();

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Net.WebSockets;
using System.Text; using System.Text;
namespace BizHawk.Client.Common namespace BizHawk.Client.Common

View File

@ -48,7 +48,7 @@ namespace BizHawk.Client.Common
public void SetDefaultBackgroundColor(Color color) => APIs.Gui.SetDefaultBackgroundColor(color); public void SetDefaultBackgroundColor(Color color) => APIs.Gui.SetDefaultBackgroundColor(color);
[LuaMethodExample("gui.defaultTextBackground( 0x000000FF );")] [LuaMethodExample("gui.defaultTextBackground( 0x000000FF );")]
[LuaMethod("defaultTextBackground", "Sets the default backgroiund color to use in text drawing methods, half-transparent black by default")] [LuaMethod("defaultTextBackground", "Sets the default background color to use in text drawing methods, half-transparent black by default")]
public void SetDefaultTextBackground(Color color) => APIs.Gui.SetDefaultTextBackground(color); public void SetDefaultTextBackground(Color color) => APIs.Gui.SetDefaultTextBackground(color);
[LuaMethodExample("gui.defaultPixelFont( \"Arial Narrow\");")] [LuaMethodExample("gui.defaultPixelFont( \"Arial Narrow\");")]

View File

@ -209,20 +209,17 @@ namespace BizHawk.Client.Common
{ {
if (string.IsNullOrWhiteSpace(movie.Core)) if (string.IsNullOrWhiteSpace(movie.Core))
{ {
if (preferredCores.TryGetValue(systemId, out var coreName)) PopupMessage(preferredCores.TryGetValue(systemId, out _)
{ ? $"No core specified in the movie file, using the preferred core {preferredCores[systemId]} instead."
PopupMessage($"No core specified in the movie file, using the preferred core {preferredCores[systemId]} instead."); : "No core specified in the movie file, using the default core instead.");
}
else
{
PopupMessage($"No core specified in the movie file, using the default core instead.");
}
} }
else else
{ {
var keys = preferredCores.Keys.ToList(); var keys = preferredCores.Keys.ToList();
foreach (var k in keys) foreach (var k in keys)
{
preferredCores[k] = movie.Core; preferredCores[k] = movie.Core;
}
} }
} }

View File

@ -23,18 +23,18 @@ namespace BizHawk.Client.Common
["SNES_PAL"] = 21281370.0 / (4 * 341 * 312), // 50.0069789082 ["SNES_PAL"] = 21281370.0 / (4 * 341 * 312), // 50.0069789082
["SGB"] = 21477272.0 / (4 * 341 * 262), // 60.098475521 ["SGB"] = 21477272.0 / (4 * 341 * 262), // 60.098475521
["SGB_PAL"] = 21281370.0 / (4 * 341 * 312), // 50.0069789082 ["SGB_PAL"] = 21281370.0 / (4 * 341 * 312), // 50.0069789082
["PCE"] = (7159090.90909090 / 455 / 263), // 59.8261054535 ["PCE"] = 7159090.90909090 / 455 / 263, // 59.8261054535
["PCECD"] = (7159090.90909090 / 455 / 263), // 59.8261054535 ["PCECD"] = 7159090.90909090 / 455 / 263, // 59.8261054535
["SMS"] = (3579545 / 262.0 / 228.0), // 59.9227434043 ["SMS"] = 3579545 / 262.0 / 228.0, // 59.9227434043
["SMS_PAL"] = (3546893 / 313.0 / 228.0), // 49.7014320946 ["SMS_PAL"] = 3546893 / 313.0 / 228.0, // 49.7014320946
["GG"] = (3579545 / 262.0 / 228.0), // 59.9227434043 ["GG"] = 3579545 / 262.0 / 228.0, // 59.9227434043
["GG_PAL"] = (3546893 / 313.0 / 228.0), // 49.7014320946 ["GG_PAL"] = 3546893 / 313.0 / 228.0, // 49.7014320946
["SG"] = (3579545 / 262.0 / 228.0), // 59.9227434043 ["SG"] = 3579545 / 262.0 / 228.0, // 59.9227434043
["SG_PAL"] = (3546893 / 313.0 / 228.0), // 49.7014320946 ["SG_PAL"] = 3546893 / 313.0 / 228.0, // 49.7014320946
["NGP"] = (6144000.0 / (515 * 198)), // 60.2530155928 ["NGP"] = 6144000.0 / (515 * 198), // 60.2530155928
["VB"] = (20000000.0 / (259 * 384 * 4)), // 50.2734877735 ["VB"] = 20000000.0 / (259 * 384 * 4), // 50.2734877735
["Lynx"] = 16000000.0 / (16 * 105 * 159), // 59.89817310572028 ["Lynx"] = 16000000.0 / (16 * 105 * 159), // 59.89817310572028
["WSWAN"] = (3072000.0 / (159 * 256)), // 75.4716981132 ["WSWAN"] = 3072000.0 / (159 * 256), // 75.4716981132
["GB"] = 262144.0 / 4389.0, // 59.7275005696 ["GB"] = 262144.0 / 4389.0, // 59.7275005696
["GBC"] = 262144.0 / 4389.0, // 59.7275005696 ["GBC"] = 262144.0 / 4389.0, // 59.7275005696

View File

@ -95,7 +95,7 @@ namespace BizHawk.Client.Common
} }
} }
private void CreateDirectoryIfNotExists(string fn) private static void CreateDirectoryIfNotExists(string fn)
{ {
var file = new FileInfo(fn); var file = new FileInfo(fn);
if (file.Directory != null && !file.Directory.Exists) if (file.Directory != null && !file.Directory.Exists)

View File

@ -83,7 +83,7 @@ namespace BizHawk.Client.Common
// Just to simplify some other code. // Just to simplify some other code.
public RewindConfig Current() public RewindConfig Current()
{ {
return new RewindConfig() return new RewindConfig
{ {
UseCompression = CurrentUseCompression, UseCompression = CurrentUseCompression,
BufferSize = CurrentBufferSize, BufferSize = CurrentBufferSize,
@ -92,7 +92,7 @@ namespace BizHawk.Client.Common
} }
public RewindConfig Recent() public RewindConfig Recent()
{ {
return new RewindConfig() return new RewindConfig
{ {
UseCompression = RecentUseCompression, UseCompression = RecentUseCompression,
BufferSize = RecentBufferSize, BufferSize = RecentBufferSize,
@ -101,7 +101,7 @@ namespace BizHawk.Client.Common
} }
public RewindConfig GapFiller() public RewindConfig GapFiller()
{ {
return new RewindConfig() return new RewindConfig
{ {
UseCompression = GapsUseCompression, UseCompression = GapsUseCompression,
BufferSize = GapsBufferSize, BufferSize = GapsBufferSize,

View File

@ -1,7 +1,6 @@
using System; using System;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Runtime.InteropServices;
using BizHawk.BizInvoke; using BizHawk.BizInvoke;
using BizHawk.Common; using BizHawk.Common;

View File

@ -5,7 +5,6 @@ using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;

View File

@ -110,7 +110,7 @@ namespace BizHawk.Client.EmuHawk
private readonly Thread _updateThread; private readonly Thread _updateThread;
public readonly HostInputAdapter Adapter; public readonly IHostInputAdapter Adapter;
private readonly Func<Config> _getConfigCallback; private readonly Func<Config> _getConfigCallback;

View File

@ -7,7 +7,7 @@ using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public sealed class OpenTKInputAdapter : HostInputAdapter public sealed class OpenTKInputAdapter : IHostInputAdapter
{ {
public void DeInitAll() {} public void DeInitAll() {}