diff --git a/BizHawk.Client.Common/Api/CoreSystem.cs b/BizHawk.Client.Common/Api/CoreSystem.cs index c7114e509c..f81654fe77 100644 --- a/BizHawk.Client.Common/Api/CoreSystem.cs +++ b/BizHawk.Client.Common/Api/CoreSystem.cs @@ -3,7 +3,7 @@ /// /// Enumeration of each system emulated by BizHawk /// - public enum CoreSystem : int + public enum CoreSystem { Null = 0, TI83, diff --git a/BizHawk.Client.Common/Api/JoypadButton.cs b/BizHawk.Client.Common/Api/JoypadButton.cs index 4647961741..542a0d7023 100644 --- a/BizHawk.Client.Common/Api/JoypadButton.cs +++ b/BizHawk.Client.Common/Api/JoypadButton.cs @@ -7,7 +7,7 @@ namespace BizHawk.Client.ApiHawk /// for all existing controllers /// [Flags] - public enum JoypadButton : int + public enum JoypadButton { A = 1, B = 2, @@ -28,6 +28,7 @@ namespace BizHawk.Client.ApiHawk /// Master system Button 1 /// B1 = 16384, + /// /// Master system Button 1 /// @@ -37,18 +38,22 @@ namespace BizHawk.Client.ApiHawk /// N64 C up /// CUp = 65536, + /// /// N64 C down /// CDown = 131072, + /// /// N64 C Left /// CLeft = 262144, + /// /// N64 C Right /// CRight = 524288, + /// /// N64 Analog stick /// diff --git a/BizHawk.Client.Common/BinarySaveStates.cs b/BizHawk.Client.Common/BinarySaveStates.cs index 0e3c093b88..d5f9b2a11f 100644 --- a/BizHawk.Client.Common/BinarySaveStates.cs +++ b/BizHawk.Client.Common/BinarySaveStates.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Reflection; using ICSharpCode.SharpZipLib.Zip; -//using Ionic.Zip; namespace BizHawk.Client.Common { diff --git a/BizHawk.Client.Common/ControllerBinding.cs b/BizHawk.Client.Common/ControllerBinding.cs index fcda6c78bc..90fac267ec 100644 --- a/BizHawk.Client.Common/ControllerBinding.cs +++ b/BizHawk.Client.Common/ControllerBinding.cs @@ -19,12 +19,9 @@ namespace BizHawk.Client.Common } } - public ControllerDefinition Definition - { - get { return _type; } - } + public ControllerDefinition Definition => _type; - public bool IsPressed(string button) + public bool IsPressed(string button) { return _buttons[button]; } @@ -105,11 +102,11 @@ namespace BizHawk.Client.Common } } - //zero 09-mar-2015 - not sure if adding + 1 here is correct.. but... maybe? + // zero 09-mar-2015 - not sure if adding + 1 here is correct.. but... maybe? var output = (input * multiplier + 10000.0f) * (range.Max - range.Min + 1) / 20000.0f + range.Min; - //zero 09-mar-2015 - at this point, we should only have integers, since thats all 100% of consoles ever see - //if this becomes a problem we can add flags to the range and update GUIs to be able to display floats + // zero 09-mar-2015 - at this point, we should only have integers, since thats all 100% of consoles ever see + // if this becomes a problem we can add flags to the range and update GUIs to be able to display floats output = (int)output; float lbound = Math.Min(range.Min, range.Max); @@ -160,7 +157,7 @@ namespace BizHawk.Client.Common } } - //it's not sure where this should happen, so for backwards compatibility.. do it every time + // it's not sure where this should happen, so for backwards compatibility.. do it every time NormalizeFloats(controller); } @@ -288,7 +285,10 @@ namespace BizHawk.Client.Common _buttonStarts.Clear(); } - public float GetFloat(string name) { throw new NotImplementedException(); } + public float GetFloat(string name) + { + throw new NotImplementedException(); + } // look for bindings which are activated by the supplied physical button. public List SearchBindings(string button) @@ -304,9 +304,9 @@ namespace BizHawk.Client.Common { foreach (var kvp in _bindings) { - foreach (var bound_button in kvp.Value) + foreach (var boundBtn in kvp.Value) { - if (_buttons[kvp.Key] == false && controller.IsPressed(bound_button)) + if (_buttons[kvp.Key] == false && controller.IsPressed(boundBtn)) { _buttonStarts[kvp.Key] = _emulator.Frame; } diff --git a/BizHawk.Client.Common/ExceptionClasses.cs b/BizHawk.Client.Common/ExceptionClasses.cs index 0ab10d959d..c63eeff6e2 100644 --- a/BizHawk.Client.Common/ExceptionClasses.cs +++ b/BizHawk.Client.Common/ExceptionClasses.cs @@ -6,7 +6,6 @@ namespace BizHawk.Client.Common { public MoviePlatformMismatchException(string message) : base(message) { - } } } diff --git a/BizHawk.Client.Common/FirmwareManager.cs b/BizHawk.Client.Common/FirmwareManager.cs index 701713da02..c052126e7a 100644 --- a/BizHawk.Client.Common/FirmwareManager.cs +++ b/BizHawk.Client.Common/FirmwareManager.cs @@ -17,7 +17,7 @@ namespace BizHawk.Client.Common public string Hash { get; set; } } - public List RecentlyServed { get; private set; } + public List RecentlyServed { get; } public class ResolutionInfo { @@ -53,12 +53,10 @@ namespace BizHawk.Client.Common public ResolutionInfo Resolve(FirmwareDatabase.FirmwareRecord record, bool forbidScan = false) { - //purpose of forbidScan: sometimes this is called from a loop in Scan(). we dont want to repeatedly DoScanAndResolve in that case, its already been done. - + // purpose of forbidScan: sometimes this is called from a loop in Scan(). we dont want to repeatedly DoScanAndResolve in that case, its already been done. bool first = true; RETRY: - ResolutionInfo resolved; _resolutionDictionary.TryGetValue(record, out resolved); @@ -66,7 +64,10 @@ namespace BizHawk.Client.Common // NOTE: this could result in bad performance in some cases if the scanning happens repeatedly.. if (resolved == null && first) { - if(!forbidScan) DoScanAndResolve(); + if (!forbidScan) + { + DoScanAndResolve(); + } first = false; goto RETRY; } @@ -78,14 +79,19 @@ namespace BizHawk.Client.Common public string Request(string sysId, string firmwareId) { var resolved = Resolve(sysId, firmwareId); - if (resolved == null) return null; + if (resolved == null) + { + return null; + } + RecentlyServed.Add(new FirmwareEventArgs - { - SystemId = sysId, - FirmwareId = firmwareId, - Hash = resolved.Hash, - Size = resolved.Size - }); + { + SystemId = sysId, + FirmwareId = firmwareId, + Hash = resolved.Hash, + Size = resolved.Size + }); + return resolved.FilePath; } @@ -119,12 +125,14 @@ namespace BizHawk.Client.Common public void DoScanAndResolve() { - //build a list of file sizes. Only those will be checked during scanning + // build a list of file sizes. Only those will be checked during scanning HashSet sizes = new HashSet(); foreach (var ff in FirmwareDatabase.FirmwareFiles) + { sizes.Add(ff.size); + } - using(var reader = new RealFirmwareReader()) + using (var reader = new RealFirmwareReader()) { // build a list of files under the global firmwares path, and build a hash for each of them while we're at it var todo = new Queue(); @@ -135,7 +143,9 @@ namespace BizHawk.Client.Common var di = todo.Dequeue(); if (!di.Exists) + { continue; + } // we're going to allow recursing into subdirectories, now. its been verified to work OK foreach (var disub in di.GetDirectories()) @@ -145,8 +155,10 @@ namespace BizHawk.Client.Common foreach (var fi in di.GetFiles()) { - if(sizes.Contains(fi.Length)) + if (sizes.Contains(fi.Length)) + { reader.Read(fi); + } } } @@ -203,6 +215,7 @@ namespace BizHawk.Client.Common ri = new ResolutionInfo(); _resolutionDictionary[fr] = ri; } + ri.UserSpecified = true; ri.KnownFirmwareFile = null; ri.FilePath = userSpec; @@ -239,11 +252,8 @@ namespace BizHawk.Client.Common } } } - - } //foreach(firmware record) - } //using(new RealFirmwareReader()) - } //DoScanAndResolve() - - } //class FirmwareManager - -} //namespace \ No newline at end of file + } // foreach(firmware record) + } // using(new RealFirmwareReader()) + } // DoScanAndResolve() + } // class FirmwareManager +} // namespace \ No newline at end of file diff --git a/BizHawk.Client.Common/Global.cs b/BizHawk.Client.Common/Global.cs index 05d5977950..15faccb5a1 100644 --- a/BizHawk.Client.Common/Global.cs +++ b/BizHawk.Client.Common/Global.cs @@ -29,23 +29,23 @@ namespace BizHawk.Client.Common public static AutofireController AutofireNullControls; - //the movie will be spliced inbetween these if it is present + // the movie will be spliced inbetween these if it is present public static CopyControllerAdapter MovieInputSourceAdapter = new CopyControllerAdapter(); public static CopyControllerAdapter MovieOutputHardpoint = new CopyControllerAdapter(); public static MultitrackRewiringControllerAdapter MultitrackRewiringAdapter = new MultitrackRewiringControllerAdapter(); - //dont take my word for it, since the final word is actually in RewireInputChain, but here is a guide... - //user -> Input -> ActiveController -> UDLR -> StickyXORPlayerInputAdapter -> TurboAdapter(TBD) -> Lua(?TBD?) -> .. - //.. -> MultitrackRewiringControllerAdapter -> MovieInputSourceAdapter -> (MovieSession) -> MovieOutputAdapter -> ControllerOutput(1) -> Game - //(1)->Input Display + // dont take my word for it, since the final word is actually in RewireInputChain, but here is a guide... + // user -> Input -> ActiveController -> UDLR -> StickyXORPlayerInputAdapter -> TurboAdapter(TBD) -> Lua(?TBD?) -> .. + // .. -> MultitrackRewiringControllerAdapter -> MovieInputSourceAdapter -> (MovieSession) -> MovieOutputAdapter -> ControllerOutput(1) -> Game + // (1)->Input Display - //the original source controller, bound to the user, sort of the "input" port for the chain, i think + // the original source controller, bound to the user, sort of the "input" port for the chain, i think public static Controller ActiveController; //rapid fire version on the user controller, has its own key bindings and is OR'ed against ActiveController public static AutofireController AutoFireController; - //the "output" port for the controller chain. + // the "output" port for the controller chain. public static CopyControllerAdapter ControllerOutput = new CopyControllerAdapter(); public static UD_LR_ControllerAdapter UD_LR_ControllerAdapter = new UD_LR_ControllerAdapter(); @@ -95,7 +95,8 @@ namespace BizHawk.Client.Common { return SystemInfo.GG; } - else if ((Emulator as SMS).IsSG1000) + + if ((Emulator as SMS).IsSG1000) { return SystemInfo.SG; } diff --git a/BizHawk.Client.Common/IPS.cs b/BizHawk.Client.Common/IPS.cs index ccc9122b4f..6014d55ed5 100644 --- a/BizHawk.Client.Common/IPS.cs +++ b/BizHawk.Client.Common/IPS.cs @@ -21,7 +21,7 @@ namespace BizHawk.Client.Common } // header verified, loop over patch entries - uint EOF = ('E' * 0x10000 + 'O' * 0x100 + 'F'); + uint eof = ('E' * 0x10000) + ('O' * 0x100) + 'F'; var ret = new MemoryStream(rom.Length); ret.Write(rom, 0, rom.Length); @@ -29,8 +29,11 @@ namespace BizHawk.Client.Common while (true) { uint offset = Read24(patch); - if (offset == EOF) + if (offset == eof) + { return ret.ToArray(); + } + ushort size = Read16(patch); ret.Seek(offset, SeekOrigin.Begin); @@ -56,17 +59,17 @@ namespace BizHawk.Client.Common private static ushort Read16(Stream patch) { - int Upper = patch.ReadByte(); - int Lower = patch.ReadByte(); - return (ushort)(Upper * 0x100 + Lower); + int upper = patch.ReadByte(); + int lower = patch.ReadByte(); + return (ushort)((upper * 0x100) + lower); } private static uint Read24(Stream patch) { - int Upper = patch.ReadByte(); - int Middle = patch.ReadByte(); - int Lower = patch.ReadByte(); - return (uint)(Upper * 0x10000 + Middle * 0x100 + Lower); + int upper = patch.ReadByte(); + int middle = patch.ReadByte(); + int lower = patch.ReadByte(); + return (uint)((upper * 0x10000) + (middle * 0x100) + lower); } } } \ No newline at end of file diff --git a/BizHawk.Client.Common/IZipWriter.cs b/BizHawk.Client.Common/IZipWriter.cs index 919de6c469..0ae00237c6 100644 --- a/BizHawk.Client.Common/IZipWriter.cs +++ b/BizHawk.Client.Common/IZipWriter.cs @@ -1,12 +1,9 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.IO; namespace BizHawk.Client.Common { - interface IZipWriter : IDisposable + public interface IZipWriter : IDisposable { void WriteItem(string name, Action callback); } diff --git a/BizHawk.Client.Common/IonicZipWriter.cs b/BizHawk.Client.Common/IonicZipWriter.cs index de1f1befc7..3e10be3a00 100644 --- a/BizHawk.Client.Common/IonicZipWriter.cs +++ b/BizHawk.Client.Common/IonicZipWriter.cs @@ -1,10 +1,7 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.IO; using Ionic.Zip; -using System.IO; namespace BizHawk.Client.Common { @@ -28,9 +25,14 @@ namespace BizHawk.Client.Common { var e = z.PutNextEntry(name); if (level == 0) + { e.CompressionMethod = CompressionMethod.None; + } else + { e.CompressionMethod = CompressionMethod.Deflate; + } + callback(z); // there is no CloseEntry() call } diff --git a/BizHawk.Client.Common/KeyTurbo.cs b/BizHawk.Client.Common/KeyTurbo.cs index 4bf0ab628b..d04306cfde 100644 --- a/BizHawk.Client.Common/KeyTurbo.cs +++ b/BizHawk.Client.Common/KeyTurbo.cs @@ -2,6 +2,10 @@ { public class TurboKey { + private int _upTime, _downTime, _timer; + + public bool Value { get; set; } + public void Reset(int downTime, int upTime) { Value = false; @@ -22,15 +26,15 @@ Value = true; if (_timer > _downTime) + { Value = false; - if(_timer > (_upTime+_downTime)) + } + + if (_timer > _upTime + _downTime) { _timer = 0; Value = true; } } - - public bool Value; - private int _upTime, _downTime, _timer; } } \ No newline at end of file diff --git a/BizHawk.Client.Common/PathManager.cs b/BizHawk.Client.Common/PathManager.cs index 2aafa47795..730502b64a 100644 --- a/BizHawk.Client.Common/PathManager.cs +++ b/BizHawk.Client.Common/PathManager.cs @@ -3,7 +3,6 @@ using System.Linq; using System.IO; using System.Reflection; -using BizHawk.Common; using BizHawk.Common.StringExtensions; using BizHawk.Emulation.Common; using BizHawk.Emulation.Common.IEmulatorExtensions; @@ -24,28 +23,27 @@ namespace BizHawk.Client.Common return path; } - /// - /// Makes a path relative to the %exe% dir - /// - public static string MakeProgramRelativePath(string path) { return MakeAbsolutePath("%exe%/" + path, null); } + /// + /// Makes a path relative to the %exe% directory + /// + public static string MakeProgramRelativePath(string path) + { + return MakeAbsolutePath("%exe%/" + path, null); + } - public static string GetDllDirectory() { return Path.Combine(GetExeDirectoryAbsolute(), "dll"); } + public static string GetDllDirectory() + { + return Path.Combine(GetExeDirectoryAbsolute(), "dll"); + } /// /// The location of the default INI file /// - public static string DefaultIniPath - { - get - { - return MakeProgramRelativePath("config.ini"); - } - } + public static string DefaultIniPath => MakeProgramRelativePath("config.ini"); /// /// Gets absolute base as derived from EXE /// - /// public static string GetBasePathAbsolute() { if (Global.Config.PathEntries.GlobalBaseFragment.Length < 1) // If empty, then EXE path @@ -105,7 +103,6 @@ namespace BizHawk.Client.Common } // This function translates relative path and special identifiers in absolute paths - if (path.Length < 1) { return GetBasePathAbsolute(); @@ -183,7 +180,7 @@ namespace BizHawk.Client.Common int z = workingpath.HowMany("\\"); if (y >= z) { - //Return drive letter only, working path must be absolute? + // Return drive letter only, working path must be absolute? } return string.Empty; @@ -259,7 +256,7 @@ namespace BizHawk.Client.Common var filesystemSafeName = game.Name .Replace("|", "+") .Replace(":", " -") // adelikat - Path.GetFileName scraps everything to the left of a colon unfortunately, so we need this hack here - .Replace("\"", ""); // adelikat - Ivan Ironman Stewart's Super Off-Road has quotes in game name + .Replace("\"", string.Empty); // adelikat - Ivan Ironman Stewart's Super Off-Road has quotes in game name // zero 06-nov-2015 - regarding the below, i changed my mind. for libretro i want subdirectories here. var filesystemDir = Path.GetDirectoryName(filesystemSafeName); @@ -297,10 +294,10 @@ namespace BizHawk.Client.Common public static string RetroSaveRAMDirectory(GameInfo game) { - //hijinx here to get the core name out of the game name + // hijinx here to get the core name out of the game name var name = FilesystemSafeName(game); name = Path.GetDirectoryName(name); - if (name == "") name = FilesystemSafeName(game); + if (name == string.Empty) name = FilesystemSafeName(game); if (Global.MovieSession.Movie.IsActive) { @@ -316,10 +313,13 @@ namespace BizHawk.Client.Common public static string RetroSystemPath(GameInfo game) { - //hijinx here to get the core name out of the game name + // hijinx here to get the core name out of the game name var name = FilesystemSafeName(game); name = Path.GetDirectoryName(name); - if(name == "") name = FilesystemSafeName(game); + if (name == string.Empty) + { + name = FilesystemSafeName(game); + } var pathEntry = Global.Config.PathEntries[game.System, "System"] ?? Global.Config.PathEntries[game.System, "Base"]; @@ -403,9 +403,6 @@ namespace BizHawk.Client.Common /// Takes an absolute path and attempts to convert it to a relative, based on the system, /// or global base if no system is supplied, if it is not a subfolder of the base, it will return the path unaltered /// - /// - /// - /// public static string TryMakeRelative(string absolutePath, string system = null) { var parentPath = string.IsNullOrWhiteSpace(system) ? @@ -430,8 +427,8 @@ namespace BizHawk.Client.Common return absolutePath; } - //http://stackoverflow.com/questions/3525775/how-to-check-if-directory-1-is-a-subdirectory-of-dir2-and-vice-versa - public static bool IsSubfolder(string parentPath, string childPath) + // http://stackoverflow.com/questions/3525775/how-to-check-if-directory-1-is-a-subdirectory-of-dir2-and-vice-versa + private static bool IsSubfolder(string parentPath, string childPath) { var parentUri = new Uri(parentPath); @@ -454,14 +451,12 @@ namespace BizHawk.Client.Common /// Don't only valid system ids to system ID, pathType is ROM, Screenshot, etc /// Returns the desired path, if does not exist, returns platform base, else it returns base /// - /// - /// - public static PathEntry GetPathEntryWithFallback(string pathType, string systemID) + private static PathEntry GetPathEntryWithFallback(string pathType, string systemId) { - var entry = Global.Config.PathEntries[systemID, pathType]; + var entry = Global.Config.PathEntries[systemId, pathType]; if (entry == null) { - entry = Global.Config.PathEntries[systemID, "Base"]; + entry = Global.Config.PathEntries[systemId, "Base"]; } if (entry == null) diff --git a/BizHawk.Client.Common/QuickBmpFile.cs b/BizHawk.Client.Common/QuickBmpFile.cs index 4bab0dc427..47e7299f23 100644 --- a/BizHawk.Client.Common/QuickBmpFile.cs +++ b/BizHawk.Client.Common/QuickBmpFile.cs @@ -1,16 +1,15 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using BizHawk.Emulation.Common; -using System.Runtime.InteropServices; using System.IO; +using System.Runtime.InteropServices; + +using BizHawk.Emulation.Common; namespace BizHawk.Client.Common { public class QuickBmpFile { - #region structs + #region Structs + [StructLayout(LayoutKind.Sequential, Pack = 1)] class BITMAPFILEHEADER { @@ -29,7 +28,10 @@ namespace BizHawk.Client.Common { var ret = GetObject(s); if (ret.bfSize != Marshal.SizeOf(typeof(BITMAPFILEHEADER))) + { throw new InvalidOperationException(); + } + return ret; } } @@ -58,12 +60,15 @@ namespace BizHawk.Client.Common { var ret = GetObject(s); if (ret.biSize != Marshal.SizeOf(typeof(BITMAPINFOHEADER))) + { throw new InvalidOperationException(); + } + return ret; } } - enum BitmapCompressionMode : uint + private enum BitmapCompressionMode : uint { BI_RGB = 0, BI_RLE8 = 1, @@ -72,9 +77,10 @@ namespace BizHawk.Client.Common BI_JPEG = 4, BI_PNG = 5 } + #endregion - private unsafe static byte[] GetBytes(object o) + private static unsafe byte[] GetBytes(object o) { byte[] ret = new byte[Marshal.SizeOf(o)]; fixed (byte* p = ret) @@ -84,7 +90,7 @@ namespace BizHawk.Client.Common return ret; } - private unsafe static T GetObject(Stream s) + private static unsafe T GetObject(Stream s) { byte[] tmp = new byte[Marshal.SizeOf(typeof(T))]; s.Read(tmp, 0, tmp.Length); @@ -94,35 +100,42 @@ namespace BizHawk.Client.Common } } - unsafe struct BMP + private unsafe struct BMP { public int* Data; public int Width; public int Height; } - static void Blit(BMP src, BMP dst) + private static void Blit(BMP src, BMP dst) { if (src.Width == dst.Width && src.Height == dst.Height) + { Blit_Same(src, dst); + } else + { Blit_Any(src, dst); + } } - unsafe static void Blit_Same(BMP src, BMP dst) + private static unsafe void Blit_Same(BMP src, BMP dst) { - int* sp = src.Data + src.Width * (src.Height - 1); + int* sp = src.Data + (src.Width * (src.Height - 1)); int* dp = dst.Data; for (int j = 0; j < src.Height; j++) { for (int i = 0; i < src.Width; i++) + { dp[i] = sp[i]; + } + sp -= src.Width; dp += src.Width; } } - unsafe static void Blit_Any(BMP src, BMP dst) + private static unsafe void Blit_Any(BMP src, BMP dst) { int w = dst.Width; int h = dst.Height; @@ -143,7 +156,7 @@ namespace BizHawk.Client.Common } } - unsafe static void Blit_Any_NoFlip(BMP src, BMP dst) + private static unsafe void Blit_Any_NoFlip(BMP src, BMP dst) { int w = dst.Width; int h = dst.Height; @@ -163,7 +176,7 @@ namespace BizHawk.Client.Common } } - public unsafe static void Copy(IVideoProvider src, IVideoProvider dst) + public static unsafe void Copy(IVideoProvider src, IVideoProvider dst) { if (src.BufferWidth == dst.BufferWidth && src.BufferHeight == dst.BufferHeight) { @@ -194,16 +207,23 @@ namespace BizHawk.Client.Common /// public class LoadedBMP : IVideoProvider { - public int[] VideoBuffer { get; set; } - public int[] GetVideoBuffer() { return VideoBuffer; } - public int VirtualWidth { get { return BufferWidth; } } - public int VirtualHeight { get { return BufferHeight; } } - public int BufferWidth { get; set; } + public int[] VideoBuffer { get; set; } + + public int[] GetVideoBuffer() + { + return VideoBuffer; + } + + public int VirtualWidth => BufferWidth; + + public int VirtualHeight => BufferHeight; + + public int BufferWidth { get; set; } public int BufferHeight { get; set; } - public int BackgroundColor { get { return unchecked((int)0xff000000); } } + public int BackgroundColor => unchecked((int)0xff000000); } - public unsafe static bool Load(IVideoProvider v, Stream s) + public static unsafe bool Load(IVideoProvider v, Stream s) { var bf = BITMAPFILEHEADER.FromStream(s); var bi = BITMAPINFOHEADER.FromStream(s); @@ -212,7 +232,10 @@ namespace BizHawk.Client.Common || bi.biPlanes != 1 || bi.biBitCount != 32 || bi.biCompression != BitmapCompressionMode.BI_RGB) + { return false; + } + int in_w = bi.biWidth; int in_h = bi.biHeight; @@ -225,9 +248,10 @@ namespace BizHawk.Client.Common l.BufferHeight = in_h; l.VideoBuffer = new int[in_w * in_h]; } + int[] dst = v.GetVideoBuffer(); - fixed (byte *srcp = src) + fixed (byte* srcp = src) fixed (int* dstp = dst) { using (new BizHawk.Common.SimpleTime("Blit")) @@ -248,7 +272,7 @@ namespace BizHawk.Client.Common return true; } - public unsafe static void Save(IVideoProvider v, Stream s, int w, int h) + public static unsafe void Save(IVideoProvider v, Stream s, int w, int h) { var bf = new BITMAPFILEHEADER(); var bi = new BITMAPINFOHEADER(); diff --git a/BizHawk.Client.Common/RecentFiles.cs b/BizHawk.Client.Common/RecentFiles.cs index 8c602ebda2..75c97d12cd 100644 --- a/BizHawk.Client.Common/RecentFiles.cs +++ b/BizHawk.Client.Common/RecentFiles.cs @@ -9,8 +9,13 @@ namespace BizHawk.Client.Common [JsonObject] public class RecentFiles : IEnumerable { - private List recentlist; - public RecentFiles() : this(8) { } + private readonly List recentlist; + + public RecentFiles() + : this(8) + { + } + public RecentFiles(int max) { recentlist = new List(); @@ -26,27 +31,15 @@ namespace BizHawk.Client.Common public bool Frozen { get; set; } [JsonIgnore] - public bool Empty - { - get { return !recentlist.Any(); } - } + public bool Empty => !recentlist.Any(); - [JsonIgnore] - public int Count - { - get { return recentlist.Count; } - } + [JsonIgnore] + public int Count => recentlist.Count; - [JsonIgnore] - public string MostRecent - { - get - { - return recentlist.Any() ? recentlist[0] : string.Empty; - } - } + [JsonIgnore] + public string MostRecent => recentlist.Any() ? recentlist[0] : string.Empty; - public string this[int index] + public string this[int index] { get { diff --git a/BizHawk.Client.Common/RomGame.cs b/BizHawk.Client.Common/RomGame.cs index 165caf8f9e..17edf7ae09 100644 --- a/BizHawk.Client.Common/RomGame.cs +++ b/BizHawk.Client.Common/RomGame.cs @@ -9,16 +9,21 @@ namespace BizHawk.Client.Common { public class RomGame { - public byte[] RomData { get; set; } - public byte[] FileData { get; set; } - public GameInfo GameInfo { get; set; } - public string Extension { get; set; } + public byte[] RomData { get; } + public byte[] FileData { get; } + public GameInfo GameInfo { get; } + public string Extension { get; } private const int BankSize = 1024; - public RomGame() { } + public RomGame() + { + } - public RomGame(HawkFile file) : this(file, null) { } + public RomGame(HawkFile file) + : this(file, null) + { + } public RomGame(HawkFile file, string patch) { @@ -101,7 +106,6 @@ namespace BizHawk.Client.Common { // SMD files are interleaved in pages of 16k, with the first 8k containing all // odd bytes and the second 8k containing all even bytes. - int size = source.Length; if (size > 0x400000) { @@ -122,7 +126,7 @@ namespace BizHawk.Client.Common return output; } - private unsafe static byte[] MutateSwapN64(byte[] source) + private static unsafe byte[] MutateSwapN64(byte[] source) { // N64 roms are in one of the following formats: // .Z64 = No swapping diff --git a/BizHawk.Client.Common/RomLoader.cs b/BizHawk.Client.Common/RomLoader.cs index 23569d593f..dceeb2b93c 100644 --- a/BizHawk.Client.Common/RomLoader.cs +++ b/BizHawk.Client.Common/RomLoader.cs @@ -1,32 +1,25 @@ using System; using System.Collections.Generic; -using System.Linq; using System.IO; +using System.Linq; + using BizHawk.Common; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores; -using BizHawk.Emulation.Cores.Atari.Atari2600; using BizHawk.Emulation.Cores.Atari.Atari7800; using BizHawk.Emulation.Cores.Calculators; -using BizHawk.Emulation.Cores.ColecoVision; +using BizHawk.Emulation.Cores.Computers.AppleII; using BizHawk.Emulation.Cores.Computers.Commodore64; -using BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES; using BizHawk.Emulation.Cores.Consoles.Sega.gpgx; -using GPGX64=BizHawk.Emulation.Cores.Consoles.Sega.gpgx64; -using BizHawk.Emulation.Cores.Intellivision; using BizHawk.Emulation.Cores.Nintendo.Gameboy; -using BizHawk.Emulation.Cores.Nintendo.GBA; -using BizHawk.Emulation.Cores.Nintendo.N64; -using BizHawk.Emulation.Cores.Nintendo.NES; using BizHawk.Emulation.Cores.Nintendo.SNES; using BizHawk.Emulation.Cores.PCEngine; -using BizHawk.Emulation.Cores.Sega.MasterSystem; using BizHawk.Emulation.Cores.Sega.Saturn; using BizHawk.Emulation.Cores.Sony.PSP; using BizHawk.Emulation.Cores.Sony.PSX; using BizHawk.Emulation.DiscSystem; -using BizHawk.Emulation.Cores.WonderSwan; -using BizHawk.Emulation.Cores.Computers.AppleII; + +using GPGX64 = BizHawk.Emulation.Cores.Consoles.Sega.gpgx64; namespace BizHawk.Client.Common { @@ -50,36 +43,23 @@ namespace BizHawk.Client.Common private object GetCoreSettings(Type t) { var e = new SettingsLoadArgs(t); - if (OnLoadSettings != null) - { - OnLoadSettings(this, e); - } + OnLoadSettings?.Invoke(this, e); return e.Settings; } + private object GetCoreSyncSettings(Type t) { var e = new SettingsLoadArgs(t); - if (OnLoadSyncSettings != null) - { - OnLoadSyncSettings(this, e); - } + OnLoadSyncSettings?.Invoke(this, e); return e.Settings; } - public RomLoader() - { - - } - // For not throwing errors but simply outputing information to the screen public Action MessageCallback { get; set; } private void DoMessageCallback(string message) { - if (MessageCallback != null) - { - MessageCallback(message); - } + MessageCallback?.Invoke(message); } // TODO: reconsider the need for exposing these; @@ -138,11 +118,13 @@ namespace BizHawk.Client.Common public Func ChoosePlatform { get; set; } // in case we get sent back through the picker more than once, use the same choice the second time - int? previouschoice; + private int? previouschoice; private int? HandleArchive(HawkFile file) { if (previouschoice.HasValue) + { return previouschoice; + } if (ChooseArchive != null) { @@ -153,21 +135,15 @@ namespace BizHawk.Client.Common return null; } - //May want to phase out this method in favor of the overload with more paramaters + // May want to phase out this method in favor of the overload with more paramaters private void DoLoadErrorCallback(string message, string systemId, LoadErrorType type = LoadErrorType.Unknown) { - if (OnLoadError != null) - { - OnLoadError(this, new RomErrorArgs(message, systemId, type)); - } + OnLoadError?.Invoke(this, new RomErrorArgs(message, systemId, type)); } private void DoLoadErrorCallback(string message, string systemId, string path, bool det, LoadErrorType type = LoadErrorType.Unknown) { - if (OnLoadError != null) - { - OnLoadError(this, new RomErrorArgs(message, systemId, path, det, type)); - } + OnLoadError?.Invoke(this, new RomErrorArgs(message, systemId, path, det, type)); } private bool PreferredPlatformIsDefined(string extension) @@ -180,9 +156,9 @@ namespace BizHawk.Client.Common return false; } - public bool AsLibretro; + public bool AsLibretro { get; set; } - bool HandleArchiveBinding(HawkFile file) + private bool HandleArchiveBinding(HawkFile file) { var romExtensions = new[] { "SMS", "SMC", "SFC", "PCE", "SGX", "GG", "SG", "BIN", "GEN", "MD", "SMD", "GB", "NES", "FDS", "ROM", "INT", "GBC", "UNF", "A78", "CRT", "COL", "XML", "Z64", "V64", "N64", "WS", "WSC", "GBA" }; @@ -216,7 +192,7 @@ namespace BizHawk.Client.Common { if (recursiveCount > 1) // hack to stop recursive calls from endlessly rerunning if we can't load it { - DoLoadErrorCallback("Failed multiple attempts to load ROM.", ""); + DoLoadErrorCallback("Failed multiple attempts to load ROM.", string.Empty); return false; } @@ -230,7 +206,7 @@ namespace BizHawk.Client.Common using (var file = new HawkFile()) { - //only try mounting a file if a filename was given + // only try mounting a file if a filename was given if (!string.IsNullOrEmpty(path)) { // lets not use this unless we need to @@ -261,17 +237,17 @@ namespace BizHawk.Client.Common var retro = new LibRetroEmulator(nextComm, nextComm.LaunchLibretroCore); nextEmulator = retro; - //kind of dirty.. we need to stash this, and then we can unstash it in a moment, in case the core doesnt fail + // kind of dirty.. we need to stash this, and then we can unstash it in a moment, in case the core doesnt fail var oldGame = Global.Game; if (retro.Description.SupportsNoGame && string.IsNullOrEmpty(path)) { - //must be done before LoadNoGame (which triggers retro_init and the paths to be consumed by the core) - //game name == name of core + // must be done before LoadNoGame (which triggers retro_init and the paths to be consumed by the core) + // game name == name of core var gameName = codePathPart; Global.Game = game = new GameInfo { Name = gameName, System = "Libretro" }; - //if we are allowed to run NoGame and we dont have a game, boot up the core that way + // if we are allowed to run NoGame and we dont have a game, boot up the core that way bool ret = retro.LoadNoGame(); Global.Game = oldGame; @@ -287,32 +263,41 @@ namespace BizHawk.Client.Common { bool ret; - //must be done before LoadNoGame (which triggers retro_init and the paths to be consumed by the core) - //game name == name of core + extensionless_game_filename + // must be done before LoadNoGame (which triggers retro_init and the paths to be consumed by the core) + // game name == name of core + extensionless_game_filename var gameName = Path.Combine(codePathPart, Path.GetFileNameWithoutExtension(file.Name)); Global.Game = game = new GameInfo { Name = gameName, System = "Libretro" }; - //if the core requires an archive file, then try passing the filename of the archive - //(but do we ever need to actually load the contents of the archive file into ram?) + // if the core requires an archive file, then try passing the filename of the archive + // (but do we ever need to actually load the contents of the archive file into ram?) if (retro.Description.NeedsArchives) { if (file.IsArchiveMember) + { throw new InvalidOperationException("Should not have bound file member for libretro block_extract core"); + } + ret = retro.LoadPath(file.FullPathWithoutMember); } else { - //otherwise load the data or pass the filename, as requested. but.. + // otherwise load the data or pass the filename, as requested. but.. if (retro.Description.NeedsRomAsPath && file.IsArchiveMember) + { throw new InvalidOperationException("Cannot pass archive member to libretro needs_fullpath core"); + } if (retro.Description.NeedsRomAsPath) + { ret = retro.LoadPath(file.FullPathWithoutMember); + } else { ret = HandleArchiveBinding(file); if (ret) + { ret = retro.LoadData(file.ReadAllBytes()); + } } } @@ -325,31 +310,39 @@ namespace BizHawk.Client.Common return false; } } - - } else { - //if not libretro: - - //do extension checknig + // if not libretro: + // do extension checknig ext = file.Extension.ToLowerInvariant(); - //do the archive binding we had to skip + // do the archive binding we had to skip if (!HandleArchiveBinding(file)) + { return false; + } } - if (string.IsNullOrEmpty(ext)) { } + if (string.IsNullOrEmpty(ext)) + { + + } else if (ext == ".m3u") { - //HACK ZONE - currently only psx supports m3u + // HACK ZONE - currently only psx supports m3u M3U_File m3u; - using(var sr = new StreamReader(path)) + using (var sr = new StreamReader(path)) + { m3u = M3U_File.Read(sr); - if(m3u.Entries.Count == 0) + } + + if (m3u.Entries.Count == 0) + { throw new InvalidOperationException("Can't load an empty M3U"); - //load discs for all the m3u + } + + // load discs for all the m3u m3u.Rebase(Path.GetDirectoryName(path)); List discs = new List(); List discNames = new List(); @@ -367,15 +360,19 @@ namespace BizHawk.Client.Common if (discMountJob.OUT_SlowLoadAborted) { - DoLoadErrorCallback("This disc would take too long to load. Run it through discohawk first, or find a new rip because this one is probably junk", "", LoadErrorType.DiscError); + DoLoadErrorCallback("This disc would take too long to load. Run it through discohawk first, or find a new rip because this one is probably junk", string.Empty, LoadErrorType.DiscError); return false; } if (discMountJob.OUT_ErrorLevel) + { throw new InvalidOperationException("\r\n" + discMountJob.OUT_Log); + } - if(disc == null) + if (disc == null) + { throw new InvalidOperationException("Can't load one of the files specified in the M3U"); + } var discName = Path.GetFileNameWithoutExtension(discPath); discNames.Add(discName); @@ -388,7 +385,9 @@ namespace BizHawk.Client.Common string discHash = new DiscHasher(disc).Calculate_PSX_BizIDHash().ToString("X8"); game = Database.CheckDatabase(discHash); if (game == null || game.IsRomStatusBad() || game.Status == RomStatus.NotInDatabase) + { sw.WriteLine("Disc could not be identified as known-good. Look for a better rip."); + } else { sw.WriteLine("Disc was identified (99.99% confidently) as known good with disc id hash CRC32:{0:X8}",discHash); @@ -402,13 +401,17 @@ namespace BizHawk.Client.Common { sw.WriteLine("Not a PSX disc"); } + sw.WriteLine("-------------------------"); } nextEmulator = new Octoshock(nextComm, discs, discNames, null, GetCoreSettings(), GetCoreSyncSettings()); nextEmulator.CoreComm.RomStatusDetails = sw.ToString(); - game = new GameInfo { Name = Path.GetFileNameWithoutExtension(file.Name) }; - game.System = "PSX"; + game = new GameInfo + { + Name = Path.GetFileNameWithoutExtension(file.Name), + System = "PSX" + }; } else if (ext == ".iso" || ext == ".cue" || ext == ".ccd") { @@ -420,27 +423,33 @@ namespace BizHawk.Client.Common string discHash = null; //--- load the disc in a context which will let us abort if it's going to take too long - var discMountJob = new DiscMountJob { IN_FromPath = path }; - discMountJob.IN_SlowLoadAbortThreshold = 8; + var discMountJob = new DiscMountJob { IN_FromPath = path, IN_SlowLoadAbortThreshold = 8 }; discMountJob.Run(); if (discMountJob.OUT_SlowLoadAborted) { - DoLoadErrorCallback("This disc would take too long to load. Run it through discohawk first, or find a new rip because this one is probably junk", "", LoadErrorType.DiscError); + DoLoadErrorCallback("This disc would take too long to load. Run it through discohawk first, or find a new rip because this one is probably junk", string.Empty, LoadErrorType.DiscError); return false; } if (discMountJob.OUT_ErrorLevel) + { throw new InvalidOperationException("\r\n" + discMountJob.OUT_Log); + } var disc = discMountJob.OUT_Disc; - //----------- - - //TODO - use more sophisticated IDer + + // ----------- + // TODO - use more sophisticated IDer var discType = new DiscIdentifier(disc).DetectDiscType(); if (discType == DiscType.SonyPSX) + { discHash = new DiscHasher(disc).Calculate_PSX_BizIDHash().ToString("X8"); - else discHash = new DiscHasher(disc).OldHash(); + } + else + { + discHash = new DiscHasher(disc).OldHash(); + } game = Database.CheckDatabase(discHash); if (game == null) @@ -493,9 +502,11 @@ namespace BizHawk.Client.Common nextEmulator = new PSP(nextComm, file.Name); break; case "PSX": - nextEmulator = new Octoshock(nextComm, new List(new[]{disc}), new List(new[]{Path.GetFileNameWithoutExtension(path)}), null, GetCoreSettings(), GetCoreSyncSettings()); + nextEmulator = new Octoshock(nextComm, new List(new[] { disc }), new List(new[] { Path.GetFileNameWithoutExtension(path) }), null, GetCoreSettings(), GetCoreSyncSettings()); if (game.IsRomStatusBad() || game.Status == RomStatus.NotInDatabase) + { nextEmulator.CoreComm.RomStatusDetails = "Disc could not be identified as known-good. Look for a better rip."; + } else { StringWriter sw = new StringWriter(); @@ -554,10 +565,9 @@ namespace BizHawk.Client.Common case "C64": nextEmulator = new C64( nextComm, - xmlGame.Assets.Select(a => a.Value), + xmlGame.Assets.Select(a => a.Value), (C64.C64Settings)GetCoreSettings(), - (C64.C64SyncSettings)GetCoreSyncSettings() - ); + (C64.C64SyncSettings)GetCoreSyncSettings()); break; case "PSX": var entries = xmlGame.AssetFullPaths; @@ -570,8 +580,7 @@ namespace BizHawk.Client.Common string discPath = e; //--- load the disc in a context which will let us abort if it's going to take too long - var discMountJob = new DiscMountJob { IN_FromPath = discPath }; - discMountJob.IN_SlowLoadAbortThreshold = 8; + var discMountJob = new DiscMountJob { IN_FromPath = discPath, IN_SlowLoadAbortThreshold = 8 }; discMountJob.Run(); disc = discMountJob.OUT_Disc; @@ -582,10 +591,14 @@ namespace BizHawk.Client.Common } if (discMountJob.OUT_ErrorLevel) + { throw new InvalidOperationException("\r\n" + discMountJob.OUT_Log); + } if (disc == null) + { throw new InvalidOperationException("Can't load one of the files specified in the M3U"); + } var discName = Path.GetFileNameWithoutExtension(discPath); discNames.Add(discName); @@ -598,7 +611,9 @@ namespace BizHawk.Client.Common string discHash = new DiscHasher(disc).Calculate_PSX_BizIDHash().ToString("X8"); game = Database.CheckDatabase(discHash); if (game == null || game.IsRomStatusBad() || game.Status == RomStatus.NotInDatabase) + { sw.WriteLine("Disc could not be identified as known-good. Look for a better rip."); + } else { sw.WriteLine("Disc was identified (99.99% confidently) as known good with disc id hash CRC32:{0:X8}", discHash); @@ -612,15 +627,18 @@ namespace BizHawk.Client.Common { sw.WriteLine("Not a PSX disc"); } + sw.WriteLine("-------------------------"); } // todo: copy pasta from PSX .cue section nextEmulator = new Octoshock(nextComm, discs, discNames, null, GetCoreSettings(), GetCoreSyncSettings()); nextEmulator.CoreComm.RomStatusDetails = sw.ToString(); - game = new GameInfo { Name = Path.GetFileNameWithoutExtension(file.Name) }; - game.System = "PSX"; - + game = new GameInfo + { + Name = Path.GetFileNameWithoutExtension(file.Name), + System = "PSX" + }; break; default: return false; @@ -672,11 +690,15 @@ namespace BizHawk.Client.Common { rom = new RomGame(file); - //hacky for now + // hacky for now if (file.Extension.ToLowerInvariant() == ".exe") + { rom.GameInfo.System = "PSX"; + } else if (file.Extension.ToLowerInvariant() == ".nsf") + { rom.GameInfo.System = "NES"; + } if (string.IsNullOrEmpty(rom.GameInfo.System)) @@ -753,16 +775,24 @@ namespace BizHawk.Client.Common break; case "NES": { - //apply main spur-of-the-moment switcheroo as lowest priority + // apply main spur-of-the-moment switcheroo as lowest priority string preference = "neshawk"; - if(Global.Config.NES_InQuickNES) preference = "quicknes"; + if (Global.Config.NES_InQuickNES) + { + preference = "quicknes"; + } - //if user has saw fit to override in gamedb, apply that + // if user has saw fit to override in gamedb, apply that if (Global.Config.CoreForcingViaGameDB && !string.IsNullOrEmpty(game.ForcedCore)) + { preference = game.ForcedCore; + } - //but only neshawk is accurate - if (forceAccurateCore) preference = "neshawk"; + // but only neshawk is accurate + if (forceAccurateCore) + { + preference = "neshawk"; + } if (preference == "neshawk") { @@ -809,7 +839,7 @@ namespace BizHawk.Client.Common nextEmulator = c64; break; case "GBA": - //core = CoreInventory.Instance["GBA", "Meteor"]; + // core = CoreInventory.Instance["GBA", "Meteor"]; if (Global.Config.GBA_UsemGBA) { core = CoreInventory.Instance["GBA", "mGBA"]; @@ -825,10 +855,15 @@ namespace BizHawk.Client.Common break; case "GEN": // discard "Genplus-gx64", auto-added due to implementing IEmulator // HUH? - //core = CoreInventory.Instance["GEN", "Genplus-gx"]; + // core = CoreInventory.Instance["GEN", "Genplus-gx"]; if (Environment.Is64BitProcess) + { core = CoreInventory.Instance["GEN", "Genplus-gx64"]; - else core = CoreInventory.Instance["GEN", "Genplus-gx"]; + } + else + { + core = CoreInventory.Instance["GEN", "Genplus-gx"]; + } break; } @@ -845,6 +880,7 @@ namespace BizHawk.Client.Common { DoLoadErrorCallback("No core could load the rom.", null); } + return false; } } @@ -859,7 +895,9 @@ namespace BizHawk.Client.Common // all of the specific exceptions we're trying to catch here aren't expected to have inner exceptions, // so drill down in case we got a TargetInvocationException or something like that while (ex.InnerException != null) + { ex = ex.InnerException; + } // Specific hack here, as we get more cores of the same system, this isn't scalable if (ex is UnsupportedGameException) diff --git a/BizHawk.Client.Common/SaveSlotManager.cs b/BizHawk.Client.Common/SaveSlotManager.cs index c6a3f150d1..5996ac4a9c 100644 --- a/BizHawk.Client.Common/SaveSlotManager.cs +++ b/BizHawk.Client.Common/SaveSlotManager.cs @@ -30,8 +30,7 @@ namespace BizHawk.Client.Common for (int i = 0; i < 10; i++) { var file = new FileInfo( - PathManager.SaveStatePrefix(Global.Game) + "." + "QuickSave" + i + ".State" - ); + PathManager.SaveStatePrefix(Global.Game) + "." + "QuickSave" + i + ".State"); if (file.Directory != null && file.Directory.Exists == false) { file.Directory.Create(); diff --git a/BizHawk.Client.Common/SavestateManager.cs b/BizHawk.Client.Common/SavestateManager.cs index bc238cab4d..9b69e86ccc 100644 --- a/BizHawk.Client.Common/SavestateManager.cs +++ b/BizHawk.Client.Common/SavestateManager.cs @@ -1,13 +1,10 @@ -using System; +using System.Collections.Generic; using System.IO; using System.Linq; using BizHawk.Common; using BizHawk.Common.BufferExtensions; -using BizHawk.Common.IOExtensions; -using BizHawk.Emulation.Common; using BizHawk.Emulation.Common.IEmulatorExtensions; -using System.Collections.Generic; namespace BizHawk.Client.Common { @@ -16,6 +13,7 @@ namespace BizHawk.Client.Common public static void SaveStateFile(string filename, string name) { var core = Global.Emulator.AsStatable(); + // the old method of text savestate save is now gone. // a text savestate is just like a binary savestate, but with a different core lump using (var bs = new BinaryStateSaver(filename)) @@ -25,13 +23,17 @@ namespace BizHawk.Client.Common { // text savestate format using (new SimpleTime("Save Core")) + { bs.PutLump(BinaryStateLump.CorestateText, (tw) => core.SaveStateText(tw)); + } } else { // binary core lump format using (new SimpleTime("Save Core")) + { bs.PutLump(BinaryStateLump.Corestate, bw => core.SaveStateBinary(bw)); + } } if (Global.Config.SaveScreenshotWithStates && Global.Emulator.HasVideoProvider()) @@ -40,11 +42,11 @@ namespace BizHawk.Client.Common var buff = vp.GetVideoBuffer(); if (buff.Length == 1) { - //is a hacky opengl texture ID. can't handle this now! - //need to discuss options - //1. cores must be able to provide a pixels videoprovider in addition to a texture ID, on command (not very hard overall but interface changing and work per core) - //2. SavestateManager must be setup with a mechanism for resolving texture IDs (even less work, but sloppy) - //There are additional problems with AVWriting. They depend on VideoProvider providing pixels. + // is a hacky opengl texture ID. can't handle this now! + // need to discuss options + // 1. cores must be able to provide a pixels videoprovider in addition to a texture ID, on command (not very hard overall but interface changing and work per core) + // 2. SavestateManager must be setup with a mechanism for resolving texture IDs (even less work, but sloppy) + // There are additional problems with AVWriting. They depend on VideoProvider providing pixels. } else { @@ -57,8 +59,11 @@ namespace BizHawk.Client.Common out_w /= 2; out_h /= 2; } + using (new SimpleTime("Save Framebuffer")) + { bs.PutLump(BinaryStateLump.Framebuffer, (s) => QuickBmpFile.Save(Global.Emulator.AsVideoProvider(), s, out_w, out_h)); + } } } @@ -104,7 +109,9 @@ namespace BizHawk.Client.Common try { using (new SimpleTime("Load Framebuffer")) + { QuickBmpFile.Load(Global.Emulator.AsVideoProvider(), br.BaseStream); + } } catch { @@ -160,7 +167,9 @@ namespace BizHawk.Client.Common } using (new SimpleTime("Load Core")) + { bl.GetCoreState(br => core.LoadStateBinary(br), tr => core.LoadStateText(tr)); + } bl.GetLump(BinaryStateLump.Framebuffer, false, PopulateFramebuffer); diff --git a/BizHawk.Client.Common/SevenZipWriter.cs b/BizHawk.Client.Common/SevenZipWriter.cs index 58f7ef4d8d..4842b9d58b 100644 --- a/BizHawk.Client.Common/SevenZipWriter.cs +++ b/BizHawk.Client.Common/SevenZipWriter.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.IO; using System.Threading.Tasks; using System.Threading; @@ -26,8 +24,8 @@ namespace BizHawk.Client.Common ManualResetEvent full = new ManualResetEvent(true); ManualResetEvent empty = new ManualResetEvent(false); - public Stream W { get; private set; } - public Stream R { get; private set; } + public Stream W { get; } + public Stream R { get; } public RangBuffer() { diff --git a/BizHawk.Client.Common/SharpZipWriter.cs b/BizHawk.Client.Common/SharpZipWriter.cs index 1845c24559..b5c8292c47 100644 --- a/BizHawk.Client.Common/SharpZipWriter.cs +++ b/BizHawk.Client.Common/SharpZipWriter.cs @@ -1,47 +1,49 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.IO; using ICSharpCode.SharpZipLib.Zip; -using System.IO; namespace BizHawk.Client.Common { public class SharpZipWriter : IZipWriter { - private ZipOutputStream z; - private int level; + private readonly int _level; + private ZipOutputStream _zipOutputStream; public SharpZipWriter(string path, int compressionlevel) { - level = compressionlevel; - z = new ZipOutputStream(new FileStream(path, FileMode.Create, FileAccess.Write)) + _level = compressionlevel; + _zipOutputStream = new ZipOutputStream(new FileStream(path, FileMode.Create, FileAccess.Write)) { IsStreamOwner = true, UseZip64 = UseZip64.Off }; - z.SetLevel(level); + _zipOutputStream.SetLevel(_level); } public void WriteItem(string name, Action callback) { var e = new ZipEntry(name); - if (level == 0) + if (_level == 0) + { e.CompressionMethod = CompressionMethod.Stored; + } else + { e.CompressionMethod = CompressionMethod.Deflated; - z.PutNextEntry(e); - callback(z); - z.CloseEntry(); + } + + _zipOutputStream.PutNextEntry(e); + callback(_zipOutputStream); + _zipOutputStream.CloseEntry(); } public void Dispose() { - if (z != null) + if (_zipOutputStream != null) { - z.Dispose(); - z = null; + _zipOutputStream.Dispose(); + _zipOutputStream = null; } } } diff --git a/BizHawk.Client.Common/SystemInfo.cs b/BizHawk.Client.Common/SystemInfo.cs index 58d2e81a19..937d953bb7 100644 --- a/BizHawk.Client.Common/SystemInfo.cs +++ b/BizHawk.Client.Common/SystemInfo.cs @@ -5,7 +5,7 @@ namespace BizHawk.Client.Common { /// /// This class holds logic for System information. - /// That means specifiactions about a system that BizHawk emulate + /// That means specifications about a system that BizHawk emulates /// public sealed class SystemInfo { @@ -26,39 +26,43 @@ namespace BizHawk.Client.Common #region cTor(s) /// + /// Initializes static members of the class. /// Global initialization stuff /// - /// DO NOT CHANGE List order because properties depends on it (and it is hardcoded) + /// + /// DO NOT CHANGE List order because properties depends on it (and it is hardcoded) + /// static SystemInfo() { - allSystemInfos = new List(26); - - allSystemInfos.Add(new SystemInfo(string.Empty)); - allSystemInfos.Add(new SystemInfo("NES", CoreSystem.NES, 2, StandardButtons)); - allSystemInfos.Add(new SystemInfo("Intellivision", CoreSystem.Intellivision, 2)); - allSystemInfos.Add(new SystemInfo("Sega Master System", CoreSystem.MasterSystem, 2, UpDownLeftRight | JoypadButton.B1 | JoypadButton.B2)); - allSystemInfos.Add(new SystemInfo("SG-1000", CoreSystem.MasterSystem, 1)); - allSystemInfos.Add(new SystemInfo("Game Gear", CoreSystem.MasterSystem, 1, UpDownLeftRight | JoypadButton.B1 | JoypadButton.B2)); - allSystemInfos.Add(new SystemInfo("TurboGrafx-16", CoreSystem.PCEngine, 1)); - allSystemInfos.Add(new SystemInfo("TurboGrafx - 16(CD)", CoreSystem.PCEngine, 1)); - allSystemInfos.Add(new SystemInfo("SuperGrafx", CoreSystem.PCEngine, 1)); - allSystemInfos.Add(new SystemInfo("Genesis", CoreSystem.Genesis, 2, UpDownLeftRight | JoypadButton.A | JoypadButton.B | JoypadButton.C | JoypadButton.X | JoypadButton.Y | JoypadButton.Z)); - allSystemInfos.Add(new SystemInfo("TI - 83", CoreSystem.TI83, 1)); - allSystemInfos.Add(new SystemInfo("SNES", CoreSystem.SNES, 8, StandardButtons | JoypadButton.X | JoypadButton.Y | JoypadButton.L | JoypadButton.R)); - allSystemInfos.Add(new SystemInfo("GB", CoreSystem.GameBoy, 1, StandardButtons)); - allSystemInfos.Add(new SystemInfo("Gameboy Color", CoreSystem.GameBoy, 1, StandardButtons)); //13 (0 based) - allSystemInfos.Add(new SystemInfo("Atari 2600", CoreSystem.Atari2600, 1)); - allSystemInfos.Add(new SystemInfo("Atari 7800", CoreSystem.Atari7800, 1)); - allSystemInfos.Add(new SystemInfo("Commodore 64", CoreSystem.Commodore64, 1)); - allSystemInfos.Add(new SystemInfo("ColecoVision", CoreSystem.ColecoVision, 1)); - allSystemInfos.Add(new SystemInfo("Gameboy Advance", CoreSystem.GameBoyAdvance, 1, StandardButtons | JoypadButton.L | JoypadButton.R)); - allSystemInfos.Add(new SystemInfo("Nintendo 64", CoreSystem.Nintendo64, 4, StandardButtons ^ JoypadButton.Select | JoypadButton.Z | JoypadButton.CUp | JoypadButton.CDown | JoypadButton.CLeft | JoypadButton.CRight | JoypadButton.AnalogStick | JoypadButton.L | JoypadButton.R)); - allSystemInfos.Add(new SystemInfo("Saturn", CoreSystem.Saturn, 2, UpDownLeftRight | JoypadButton.A | JoypadButton.B | JoypadButton.C | JoypadButton.X | JoypadButton.Y | JoypadButton.Z)); - allSystemInfos.Add(new SystemInfo("Game Boy Link", CoreSystem.DualGameBoy, 2, StandardButtons)); - allSystemInfos.Add(new SystemInfo("WonderSwan", CoreSystem.WonderSwan, 1)); - allSystemInfos.Add(new SystemInfo("Lynx", CoreSystem.Lynx, 1)); - allSystemInfos.Add(new SystemInfo("PlayStation", CoreSystem.Playstation, 2)); - allSystemInfos.Add(new SystemInfo("Apple II", CoreSystem.AppleII, 1)); + allSystemInfos = new List(26) + { + new SystemInfo(string.Empty), + new SystemInfo("NES", CoreSystem.NES, 2, StandardButtons), + new SystemInfo("Intellivision", CoreSystem.Intellivision, 2), + new SystemInfo("Sega Master System", CoreSystem.MasterSystem, 2, UpDownLeftRight | JoypadButton.B1 | JoypadButton.B2), + new SystemInfo("SG-1000", CoreSystem.MasterSystem, 1), + new SystemInfo("Game Gear", CoreSystem.MasterSystem, 1, UpDownLeftRight | JoypadButton.B1 | JoypadButton.B2), + new SystemInfo("TurboGrafx-16", CoreSystem.PCEngine, 1), + new SystemInfo("TurboGrafx - 16(CD)", CoreSystem.PCEngine, 1), + new SystemInfo("SuperGrafx", CoreSystem.PCEngine, 1), + new SystemInfo("Genesis", CoreSystem.Genesis, 2, UpDownLeftRight | JoypadButton.A | JoypadButton.B | JoypadButton.C | JoypadButton.X | JoypadButton.Y | JoypadButton.Z), + new SystemInfo("TI - 83", CoreSystem.TI83, 1), + new SystemInfo("SNES", CoreSystem.SNES, 8, StandardButtons | JoypadButton.X | JoypadButton.Y | JoypadButton.L | JoypadButton.R), + new SystemInfo("GB", CoreSystem.GameBoy, 1, StandardButtons), + new SystemInfo("Gameboy Color", CoreSystem.GameBoy, 1, StandardButtons), // 13 (0 based) + new SystemInfo("Atari 2600", CoreSystem.Atari2600, 1), + new SystemInfo("Atari 7800", CoreSystem.Atari7800, 1), + new SystemInfo("Commodore 64", CoreSystem.Commodore64, 1), + new SystemInfo("ColecoVision", CoreSystem.ColecoVision, 1), + new SystemInfo("Gameboy Advance", CoreSystem.GameBoyAdvance, 1, StandardButtons | JoypadButton.L | JoypadButton.R), + new SystemInfo("Nintendo 64", CoreSystem.Nintendo64, 4, StandardButtons ^ JoypadButton.Select | JoypadButton.Z | JoypadButton.CUp | JoypadButton.CDown | JoypadButton.CLeft | JoypadButton.CRight | JoypadButton.AnalogStick | JoypadButton.L | JoypadButton.R), + new SystemInfo("Saturn", CoreSystem.Saturn, 2, UpDownLeftRight | JoypadButton.A | JoypadButton.B | JoypadButton.C | JoypadButton.X | JoypadButton.Y | JoypadButton.Z), + new SystemInfo("Game Boy Link", CoreSystem.DualGameBoy, 2, StandardButtons), + new SystemInfo("WonderSwan", CoreSystem.WonderSwan, 1), + new SystemInfo("Lynx", CoreSystem.Lynx, 1), + new SystemInfo("PlayStation", CoreSystem.Playstation, 2), + new SystemInfo("Apple II", CoreSystem.AppleII, 1) + }; } /// @@ -84,7 +88,8 @@ namespace BizHawk.Client.Common /// Maximum controller allowed by this system private SystemInfo(string displayName, CoreSystem system, int maxControllers) : this(displayName, system, maxControllers, 0) - { } + { + } /// /// Initialize a new instance of @@ -92,324 +97,145 @@ namespace BizHawk.Client.Common /// A that specify how the system name is displayed private SystemInfo(string displayName) : this(displayName, CoreSystem.Null, 0, 0) - { } + { + } #endregion - #region Methods + #region Methods #region Get SystemInfo + /// /// Gets the instance for Apple II /// allSystemInfos[25]; /// /// Gets the instance for Atari 2600 /// allSystemInfos[14]; /// /// Gets the instance for Atari 7800 /// - public static SystemInfo Atari7800 - { - get - { - return allSystemInfos[15]; - } - } - + public static SystemInfo Atari7800 => allSystemInfos[15]; /// /// Gets the instance for Commodore 64 /// - public static SystemInfo C64 - { - get - { - return allSystemInfos[16]; - } - } - + public static SystemInfo C64 => allSystemInfos[16]; /// /// Gets the instance for Coleco Vision /// - public static SystemInfo Coleco - { - get - { - return allSystemInfos[17]; - } - } - + public static SystemInfo Coleco => allSystemInfos[17]; /// /// Gets the instance for Dual Gameboy /// - public static SystemInfo DualGB - { - get - { - return allSystemInfos[21]; - } - } - + public static SystemInfo DualGB => allSystemInfos[21]; /// /// Gets the instance for Gameboy /// - public static SystemInfo GB - { - get - { - return allSystemInfos[12]; - } - } - + public static SystemInfo GB => allSystemInfos[12]; /// /// Gets the instance for Gameboy Advance /// - public static SystemInfo GBA - { - get - { - return allSystemInfos[18]; - } - } - + public static SystemInfo GBA => allSystemInfos[18]; /// /// Gets the instance for Gameboy Color /// - public static SystemInfo GBC - { - get - { - return allSystemInfos[13]; - } - } - + public static SystemInfo GBC => allSystemInfos[13]; /// /// Gets the instance for Genesis /// - public static SystemInfo Genesis - { - get - { - return allSystemInfos[9]; - } - } - + public static SystemInfo Genesis => allSystemInfos[9]; /// /// Gets the instance for Game Gear /// - public static SystemInfo GG - { - get - { - return allSystemInfos[5]; - } - } - + public static SystemInfo GG => allSystemInfos[5]; /// /// Gets the instance for Intellivision /// - public static SystemInfo Intellivision - { - get - { - return allSystemInfos[2]; - } - } - + public static SystemInfo Intellivision => allSystemInfos[2]; /// /// Gets the instance for Lynx /// - public static SystemInfo Lynx - { - get - { - return allSystemInfos[23]; - } - } - + public static SystemInfo Lynx => allSystemInfos[23]; /// /// Gets the instance for NES /// - public static SystemInfo Nes - { - get - { - return allSystemInfos[1]; - } - } - + public static SystemInfo Nes => allSystemInfos[1]; /// /// Gets the instance for Nintendo 64 /// - public static SystemInfo N64 - { - get - { - return allSystemInfos[19]; - } - } - + public static SystemInfo N64 => allSystemInfos[19]; /// /// Gets the instance for Null (i.e. nothing is emulated) emulator /// - public static SystemInfo Null - { - get - { - return allSystemInfos[0]; - } - } - + public static SystemInfo Null => allSystemInfos[0]; /// /// Gets the instance for PCEngine (TurboGrafx-16) /// - public static SystemInfo PCE - { - get - { - return allSystemInfos[6]; - } - } - + public static SystemInfo PCE => allSystemInfos[6]; /// /// Gets the instance for PCEngine (TurboGrafx-16) + CD /// - public static SystemInfo PCECD - { - get - { - return allSystemInfos[7]; - } - } - + public static SystemInfo PCECD => allSystemInfos[7]; /// /// Gets the instance for PlayStation /// - public static SystemInfo PSX - { - get - { - return allSystemInfos[24]; - } - } - + public static SystemInfo PSX => allSystemInfos[24]; /// /// Gets the instance for Sega Saturn /// - public static SystemInfo Saturn - { - get - { - return allSystemInfos[20]; - } - } - + public static SystemInfo Saturn => allSystemInfos[20]; /// /// Gets the instance for SG-1000 (Sega Game 1000) /// - public static SystemInfo SG - { - get - { - return allSystemInfos[4]; - } - } - - + public static SystemInfo SG => allSystemInfos[4]; /// /// Gets the instance for PCEngine (Supergraph FX) /// - public static SystemInfo SGX - { - get - { - return allSystemInfos[8]; - } - } - + public static SystemInfo SGX => allSystemInfos[8]; /// /// Gets the instance for Sega Master System /// - public static SystemInfo SMS - { - get - { - return allSystemInfos[3]; - } - } - + public static SystemInfo SMS => allSystemInfos[3]; /// /// Gets the instance for SNES /// - public static SystemInfo SNES - { - get - { - return allSystemInfos[11]; - } - } - + public static SystemInfo SNES => allSystemInfos[11]; /// /// Gets the instance for TI-83 /// - public static SystemInfo TI83 - { - get - { - return allSystemInfos[10]; - } - } - + public static SystemInfo TI83 => allSystemInfos[10]; /// /// Gets the instance for TI-83 /// - public static SystemInfo WonderSwan - { - get - { - return allSystemInfos[22]; - } - } + public static SystemInfo WonderSwan => allSystemInfos[22]; + #endregion Get SystemInfo /// @@ -433,10 +259,8 @@ namespace BizHawk.Client.Common { return this == (SystemInfo)obj; } - else - { - return base.Equals(obj); - } + + return base.Equals(obj); } /// @@ -490,48 +314,23 @@ namespace BizHawk.Client.Common /// /// Gets available for this system /// - public JoypadButton AvailableButtons - { - get - { - return _AvailableButtons; - } - } + public JoypadButton AvailableButtons => _AvailableButtons; - /// + /// /// Gets the sytem name as /// - public string DisplayName - { - get - { - return _DisplayName; - } - } + public string DisplayName => _DisplayName; - - /// + /// /// Gets the maximum amount of controller allowed for this system /// - public int MaxControllers - { - get - { - return _MaxControllers; - } - } + public int MaxControllers => _MaxControllers; - /// + /// /// Gets core used for this system as enum /// - public CoreSystem System - { - get - { - return _System; - } - } + public CoreSystem System => _System; - #endregion + #endregion } } diff --git a/BizHawk.Client.Common/XmlGame.cs b/BizHawk.Client.Common/XmlGame.cs index 4b6f65999d..39a2fd60e8 100644 --- a/BizHawk.Client.Common/XmlGame.cs +++ b/BizHawk.Client.Common/XmlGame.cs @@ -21,9 +21,9 @@ namespace BizHawk.Client.Common } public XmlDocument Xml { get; set; } - public GameInfo GI { get; set; } - public IList> Assets { get; set; } - public IList AssetFullPaths { get; set; } // TODO: Hack work around, to avoid having to refactor Assets into a object array, should be refactored! + public GameInfo GI { get; } + public IList> Assets { get; } + public IList AssetFullPaths { get; } // TODO: Hack work around, to avoid having to refactor Assets into a object array, should be refactored! public static XmlGame Create(HawkFile f) { @@ -38,15 +38,15 @@ namespace BizHawk.Client.Common } var ret = new XmlGame + { + GI = { - GI = - { - System = y.Attributes["System"].Value, - Name = y.Attributes["Name"].Value, - Status = RomStatus.Unknown - }, - Xml = x - }; + System = y.Attributes["System"].Value, + Name = y.Attributes["Name"].Value, + Status = RomStatus.Unknown + }, + Xml = x + }; string fullpath = string.Empty; var n = y.SelectSingleNode("./LoadAssets"); @@ -100,8 +100,6 @@ namespace BizHawk.Client.Common data = File.ReadAllBytes(fullpath.Split('|').First()); } } - - } catch { diff --git a/BizHawk.Client.Common/config/Binding.cs b/BizHawk.Client.Common/config/Binding.cs index d7929747a6..d245dd9396 100644 --- a/BizHawk.Client.Common/config/Binding.cs +++ b/BizHawk.Client.Common/config/Binding.cs @@ -2,16 +2,15 @@ using System.Collections.Generic; using System.Linq; -//TODO [LARP] - It's pointless and annoying to store such a big structure filled with static information -//use this instead -//public class UserBinding -//{ +// TODO [LARP] - It's pointless and annoying to store such a big structure filled with static information +// use this instead +// public class UserBinding +// { // public string DisplayName; // public string Bindings; -//} -//...also. We should consider using something other than DisplayName for keying, maybe make a KEYNAME distinct from displayname. -//displayname is OK for now though. - +// } +// ...also. We should consider using something other than DisplayName for keying, maybe make a KEYNAME distinct from displayname. +// displayname is OK for now though. namespace BizHawk.Client.Common { public class Binding @@ -27,7 +26,7 @@ namespace BizHawk.Client.Common [Newtonsoft.Json.JsonObject] public class BindingCollection : IEnumerable { - public List Bindings { get; private set; } + public List Bindings { get; } [Newtonsoft.Json.JsonConstructor] public BindingCollection(List Bindings) @@ -75,7 +74,7 @@ namespace BizHawk.Client.Common { //TODO - this method is potentially disastrously O(N^2) slow due to linear search nested in loop - //Add missing entries + // Add missing entries foreach (Binding default_binding in DefaultValues) { var binding = Bindings.FirstOrDefault(x => x.DisplayName == default_binding.DisplayName); @@ -85,7 +84,7 @@ namespace BizHawk.Client.Common } else { - //patch entries with updated settings (necessary because of TODO LARP + // patch entries with updated settings (necessary because of TODO LARP binding.Ordinal = default_binding.Ordinal; binding.DefaultBinding = default_binding.DefaultBinding; binding.TabGroup = default_binding.TabGroup; @@ -96,13 +95,11 @@ namespace BizHawk.Client.Common List entriesToRemove = (from entry in Bindings let binding = DefaultValues.FirstOrDefault(x => x.DisplayName == entry.DisplayName) where binding == null select entry).ToList(); - //Remove entries that no longer exist in defaults - + // Remove entries that no longer exist in defaults foreach (Binding entry in entriesToRemove) { Bindings.Remove(entry); } - } static List s_DefaultValues; @@ -257,13 +254,14 @@ namespace BizHawk.Client.Common Bind("Analog", "X Down Large", toolTip: "For Virtual Pad"), Bind("Tools", "Toggle All Cheats"), - }; - //set ordinals based on order in list + // set ordinals based on order in list for (int i = 0; i < s_DefaultValues.Count; i++) + { s_DefaultValues[i].Ordinal = i; - } //if (s_DefaultValues == null) + } + } // if (s_DefaultValues == null) return s_DefaultValues; } diff --git a/BizHawk.Client.Common/config/ConfigPersistAttribute.cs b/BizHawk.Client.Common/config/ConfigPersistAttribute.cs index ed1fbb1148..1cbd45ab39 100644 --- a/BizHawk.Client.Common/config/ConfigPersistAttribute.cs +++ b/BizHawk.Client.Common/config/ConfigPersistAttribute.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace BizHawk.Client.EmuHawk { diff --git a/BizHawk.Client.Common/config/ConfigService.cs b/BizHawk.Client.Common/config/ConfigService.cs index 49cda3e79a..112349a557 100644 --- a/BizHawk.Client.Common/config/ConfigService.cs +++ b/BizHawk.Client.Common/config/ConfigService.cs @@ -10,7 +10,7 @@ namespace BizHawk.Client.Common { public static class ConfigService { - static JsonSerializer Serializer; + private static JsonSerializer Serializer; static ConfigService() { @@ -39,11 +39,13 @@ namespace BizHawk.Client.Common { var file = new FileInfo(filepath); if (file.Exists) + { using (var reader = file.OpenText()) { var r = new JsonTextReader(reader); config = (T)Serializer.Deserialize(r, typeof(T)); } + } } catch (Exception ex) { @@ -51,7 +53,9 @@ namespace BizHawk.Client.Common } if (config == null) + { return new T(); + } return config; } @@ -74,7 +78,6 @@ namespace BizHawk.Client.Common } // movie 1.0 header stuff - private class TypeNameEncapsulator { public object o; @@ -86,12 +89,10 @@ namespace BizHawk.Client.Common using (JsonTextReader jr = new JsonTextReader(tr)) { TypeNameEncapsulator tne = (TypeNameEncapsulator)Serializer.Deserialize(jr, typeof(TypeNameEncapsulator)); + // in the case of trying to deserialize nothing, tne will be nothing // we want to return nothing - if (tne != null) - return tne.o; - else - return null; + return tne?.o; } } diff --git a/BizHawk.Client.Common/config/PathEntry.cs b/BizHawk.Client.Common/config/PathEntry.cs index 19ded05e81..a9779b3fe7 100644 --- a/BizHawk.Client.Common/config/PathEntry.cs +++ b/BizHawk.Client.Common/config/PathEntry.cs @@ -27,7 +27,7 @@ namespace BizHawk.Client.Common [Newtonsoft.Json.JsonObject] public class PathEntryCollection : IEnumerable { - public List Paths { get; private set; } + public List Paths { get; } public PathEntryCollection() { @@ -36,9 +36,9 @@ namespace BizHawk.Client.Common } [Newtonsoft.Json.JsonConstructor] - public PathEntryCollection(List Paths) + public PathEntryCollection(List paths) { - this.Paths = Paths; + Paths = paths; } public void Add(PathEntry p) @@ -78,12 +78,12 @@ namespace BizHawk.Client.Common Paths.AddRange(new[] { - new PathEntry { System = system, SystemDisplayName=systemdisp, Type = "Base", Path= Path.Combine(".", systempath), Ordinal = 0 }, - new PathEntry { System = system, SystemDisplayName=systemdisp, Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = system, SystemDisplayName=systemdisp, Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = system, SystemDisplayName=systemdisp, Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry { System = system, SystemDisplayName=systemdisp, Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = system, SystemDisplayName=systemdisp, Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 } + new PathEntry { System = system, SystemDisplayName = systemdisp, Type = "Base", Path = Path.Combine(".", systempath), Ordinal = 0 }, + new PathEntry { System = system, SystemDisplayName = systemdisp, Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = system, SystemDisplayName = systemdisp, Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = system, SystemDisplayName = systemdisp, Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = system, SystemDisplayName = systemdisp, Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = system, SystemDisplayName = systemdisp, Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 } }); return this[system, type]; @@ -91,7 +91,7 @@ namespace BizHawk.Client.Common public void ResolveWithDefaults() { - //Add missing entries + // Add missing entries foreach (PathEntry defaultpath in DefaultValues) { var path = Paths.FirstOrDefault(x => x.System == defaultpath.System && x.Type == defaultpath.Type); @@ -103,7 +103,7 @@ namespace BizHawk.Client.Common List entriesToRemove = new List(); - //Remove entries that no longer exist in defaults + // Remove entries that no longer exist in defaults foreach (PathEntry pathEntry in Paths) { var path = DefaultValues.FirstOrDefault(x => x.System == pathEntry.System && x.Type == pathEntry.Type); @@ -118,21 +118,15 @@ namespace BizHawk.Client.Common Paths.Remove(entry); } - //Add missing displaynames + // Add missing displaynames var missingDisplayPaths = Paths.Where(x => x.SystemDisplayName == null).ToList(); foreach (PathEntry path in missingDisplayPaths) { path.SystemDisplayName = DefaultValues.FirstOrDefault(x => x.System == path.System).SystemDisplayName; - } } - public string ToolsPathFragment - { - get { return Global.Config.PathEntries["Global", "Tools"].Path; } - } - - private static string ResolveToolsPath(string subPath) + private static string ResolveToolsPath(string subPath) { if (Path.IsPathRooted(subPath)) { @@ -150,216 +144,206 @@ namespace BizHawk.Client.Common return Path.Combine(toolsPath, subPath); } - //Some frequently requested paths, made into a property for convenience - public string WatchPathFragment + // Some frequently requested paths, made into a property for convenience + public string ToolsPathFragment => Global.Config.PathEntries["Global", "Tools"].Path; + + public string WatchPathFragment => ResolveToolsPath(Global.Config.PathEntries["Global", "Watch (.wch)"].Path); + + public string MultiDiskBundlesFragment => ResolveToolsPath(Global.Config.PathEntries["Global", "Multi-Disk Bundles"].Path); + + public string LogPathFragment => ResolveToolsPath(Global.Config.PathEntries["Global", "Debug Logs"].Path); + + public string MoviesPathFragment => Global.Config.PathEntries["Global", "Movies"].Path; + + public string LuaPathFragment => Global.Config.PathEntries["Global", "Lua"].Path; + + public string FirmwaresPathFragment => Global.Config.PathEntries["Global", "Firmware"].Path; + + public string AvPathFragment => Global.Config.PathEntries["Global", "A/V Dumps"].Path; + + public string GlobalRomFragment => Global.Config.PathEntries["Global", "ROM"].Path; + + // this one is special + public string GlobalBaseFragment => Global.Config.PathEntries["Global", "Base"].Path; + + public static List DefaultValues => new List { - get { return ResolveToolsPath(Global.Config.PathEntries["Global", "Watch (.wch)"].Path); } - } + new PathEntry { System = "Global_NULL", SystemDisplayName = "Global", Type = "Base", Path = ".", Ordinal = 1 }, + new PathEntry { System = "Global_NULL", SystemDisplayName = "Global", Type = "ROM", Path = ".", Ordinal = 2 }, + new PathEntry { System = "Global_NULL", SystemDisplayName = "Global", Type = "Firmware", Path = Path.Combine(".", "Firmware"), Ordinal = 3 }, + new PathEntry { System = "Global_NULL", SystemDisplayName = "Global", Type = "Movies", Path = Path.Combine(".", "Movies"), Ordinal = 4 }, + new PathEntry { System = "Global_NULL", SystemDisplayName = "Global", Type = "Movie backups", Path = Path.Combine(".", "Movies", "backup"), Ordinal = 5 }, + new PathEntry { System = "Global_NULL", SystemDisplayName = "Global", Type = "A/V Dumps", Path = ".", Ordinal = 6 }, + new PathEntry { System = "Global_NULL", SystemDisplayName = "Global", Type = "Tools", Path = Path.Combine(".", "Tools"), Ordinal = 7 }, + new PathEntry { System = "Global_NULL", SystemDisplayName = "Global", Type = "Lua", Path = Path.Combine(".", "Lua"), Ordinal = 8 }, + new PathEntry { System = "Global_NULL", SystemDisplayName = "Global", Type = "Watch (.wch)", Path = Path.Combine(".", "."), Ordinal = 9 }, + new PathEntry { System = "Global_NULL", SystemDisplayName = "Global", Type = "Debug Logs", Path = Path.Combine(".", string.Empty), Ordinal = 10 }, + new PathEntry { System = "Global_NULL", SystemDisplayName = "Global", Type = "Macros", Path = Path.Combine(".", "Movies", "Macros"), Ordinal = 11 }, + new PathEntry { System = "Global_NULL", SystemDisplayName = "Global", Type = "TAStudio states", Path = Path.Combine(".", "Movies", "TAStudio states"), Ordinal = 12 }, + new PathEntry { System = "Global_NULL", SystemDisplayName = "Global", Type = "Multi-Disk Bundles", Path = Path.Combine(".", string.Empty), Ordinal = 13 }, + new PathEntry { System = "Global_NULL", SystemDisplayName = "Global", Type = "External Tools", Path = Path.Combine(".", "ExternalTools"), Ordinal = 14 }, - public string MultiDiskBundlesFragment - { - get { return ResolveToolsPath(Global.Config.PathEntries["Global", "Multi-Disk Bundles"].Path); } - } + new PathEntry { System = "INTV", SystemDisplayName = "Intellivision", Type = "Base", Path = Path.Combine(".", "Intellivision"), Ordinal = 0 }, + new PathEntry { System = "INTV", SystemDisplayName = "Intellivision", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "INTV", SystemDisplayName = "Intellivision", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "INTV", SystemDisplayName = "Intellivision", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "INTV", SystemDisplayName = "Intellivision", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "INTV", SystemDisplayName = "Intellivision", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + new PathEntry { System = "INTV", SystemDisplayName = "Intellivision", Type = "Palettes", Path = Path.Combine(".", "Palettes"), Ordinal = 6 }, - public string LogPathFragment - { - get { return ResolveToolsPath(Global.Config.PathEntries["Global", "Debug Logs"].Path); } - } + new PathEntry { System = "NES", SystemDisplayName = "NES", Type = "Base", Path = Path.Combine(".", "NES"), Ordinal = 0 }, + new PathEntry { System = "NES", SystemDisplayName = "NES", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "NES", SystemDisplayName = "NES", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "NES", SystemDisplayName = "NES", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "NES", SystemDisplayName = "NES", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "NES", SystemDisplayName = "NES", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + new PathEntry { System = "NES", SystemDisplayName = "NES", Type = "Palettes", Path = Path.Combine(".", "Palettes"), Ordinal = 6 }, - public string MoviesPathFragment { get { return Global.Config.PathEntries["Global", "Movies"].Path; } } - public string LuaPathFragment { get { return Global.Config.PathEntries["Global", "Lua"].Path; } } - public string FirmwaresPathFragment { get { return Global.Config.PathEntries["Global", "Firmware"].Path; } } - public string AvPathFragment { get { return Global.Config.PathEntries["Global", "A/V Dumps"].Path; } } - public string GlobalRomFragment { get { return Global.Config.PathEntries["Global", "ROM"].Path; } } + new PathEntry { System = "SNES_SGB", SystemDisplayName = "SNES", Type = "Base", Path = Path.Combine(".", "SNES"), Ordinal = 0 }, + new PathEntry { System = "SNES_SGB", SystemDisplayName = "SNES", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "SNES_SGB", SystemDisplayName = "SNES", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "SNES_SGB", SystemDisplayName = "SNES", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "SNES_SGB", SystemDisplayName = "SNES", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "SNES_SGB", SystemDisplayName = "SNES", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - //this one is special - public string GlobalBaseFragment { get { return Global.Config.PathEntries["Global", "Base"].Path; } } + new PathEntry { System = "GBA", SystemDisplayName = "GBA", Type = "Base", Path = Path.Combine(".", "GBA"), Ordinal = 0 }, + new PathEntry { System = "GBA", SystemDisplayName = "GBA", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "GBA", SystemDisplayName = "GBA", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "GBA", SystemDisplayName = "GBA", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "GBA", SystemDisplayName = "GBA", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "GBA", SystemDisplayName = "GBA", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - public static List DefaultValues - { - get - { - return new List - { - new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Base", Path = ".", Ordinal = 1 }, - new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "ROM", Path = ".", Ordinal = 2 }, - new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Firmware", Path = Path.Combine(".", "Firmware"), Ordinal = 3 }, - new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Movies", Path = Path.Combine(".", "Movies"), Ordinal = 4 }, - new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Movie backups", Path = Path.Combine(".", "Movies", "backup"), Ordinal = 5 }, - new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "A/V Dumps", Path = ".", Ordinal = 6 }, - new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Tools", Path = Path.Combine(".", "Tools"), Ordinal = 7 }, - new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Lua", Path = Path.Combine(".", "Lua"), Ordinal = 8 }, - new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Watch (.wch)", Path = Path.Combine(".", "."), Ordinal = 9 }, - new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Debug Logs", Path = Path.Combine(".", ""), Ordinal = 10 }, - new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Macros", Path = Path.Combine(".", "Movies", "Macros"), Ordinal = 11 }, - new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "TAStudio states", Path = Path.Combine(".", "Movies", "TAStudio states"), Ordinal = 12 }, - new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "Multi-Disk Bundles", Path = Path.Combine(".", ""), Ordinal = 13 }, - new PathEntry { System = "Global_NULL", SystemDisplayName="Global", Type = "External Tools", Path = Path.Combine(".", "ExternalTools"), Ordinal = 14 }, + new PathEntry { System = "SMS", SystemDisplayName = "SMS", Type = "Base", Path = Path.Combine(".", "SMS"), Ordinal = 0 }, + new PathEntry { System = "SMS", SystemDisplayName = "SMS", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "SMS", SystemDisplayName = "SMS", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "SMS", SystemDisplayName = "SMS", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "SMS", SystemDisplayName = "SMS", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "SMS", SystemDisplayName = "SMS", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "INTV", SystemDisplayName="Intellivision", Type = "Base", Path = Path.Combine(".", "Intellivision"), Ordinal = 0 }, - new PathEntry { System = "INTV", SystemDisplayName="Intellivision", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "INTV", SystemDisplayName="Intellivision", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "INTV", SystemDisplayName="Intellivision", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry { System = "INTV", SystemDisplayName="Intellivision", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "INTV", SystemDisplayName="Intellivision", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "INTV", SystemDisplayName="Intellivision", Type = "Palettes", Path = Path.Combine(".", "Palettes"), Ordinal = 6 }, + new PathEntry { System = "GG", SystemDisplayName = "GG", Type = "Base", Path = Path.Combine(".", "Game Gear"), Ordinal = 0 }, + new PathEntry { System = "GG", SystemDisplayName = "GG", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "GG", SystemDisplayName = "GG", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "GG", SystemDisplayName = "GG", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "GG", SystemDisplayName = "GG", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "GG", SystemDisplayName = "GG", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "NES", SystemDisplayName="NES", Type = "Base", Path = Path.Combine(".", "NES"), Ordinal = 0 }, - new PathEntry { System = "NES", SystemDisplayName="NES", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "NES", SystemDisplayName="NES", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "NES", SystemDisplayName="NES", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry { System = "NES", SystemDisplayName="NES", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "NES", SystemDisplayName="NES", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "NES", SystemDisplayName="NES", Type = "Palettes", Path = Path.Combine(".", "Palettes"), Ordinal = 6 }, + new PathEntry { System = "SG", SystemDisplayName = "SG", Type = "Base", Path = Path.Combine(".", "SG-1000"), Ordinal = 0 }, + new PathEntry { System = "SG", SystemDisplayName = "SG", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "SG", SystemDisplayName = "SG", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "SG", SystemDisplayName = "SG", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "SG", SystemDisplayName = "SG", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "SG", SystemDisplayName = "SG", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "SNES_SGB", SystemDisplayName="SNES", Type = "Base", Path = Path.Combine(".", "SNES"), Ordinal = 0 }, - new PathEntry { System = "SNES_SGB", SystemDisplayName="SNES", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "SNES_SGB", SystemDisplayName="SNES", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "SNES_SGB", SystemDisplayName="SNES", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry { System = "SNES_SGB", SystemDisplayName="SNES", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "SNES_SGB", SystemDisplayName="SNES", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + new PathEntry { System = "GEN", SystemDisplayName = "Genesis", Type = "Base", Path = Path.Combine(".", "Genesis"), Ordinal = 0 }, + new PathEntry { System = "GEN", SystemDisplayName = "Genesis", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "GEN", SystemDisplayName = "Genesis", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "GEN", SystemDisplayName = "Genesis", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "GEN", SystemDisplayName = "Genesis", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "GEN", SystemDisplayName = "Genesis", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "GBA", SystemDisplayName="GBA", Type = "Base", Path = Path.Combine(".", "GBA"), Ordinal = 0 }, - new PathEntry { System = "GBA", SystemDisplayName="GBA", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "GBA", SystemDisplayName="GBA", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "GBA", SystemDisplayName="GBA", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry { System = "GBA", SystemDisplayName="GBA", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "GBA", SystemDisplayName="GBA", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + new PathEntry { System = "PCE_PCECD_SGX", SystemDisplayName = "PC Engine", Type = "Base", Path = Path.Combine(".", "PC Engine"), Ordinal = 0 }, + new PathEntry { System = "PCE_PCECD_SGX", SystemDisplayName = "PC Engine", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "PCE_PCECD_SGX", SystemDisplayName = "PC Engine", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "PCE_PCECD_SGX", SystemDisplayName = "PC Engine", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "PCE_PCECD_SGX", SystemDisplayName = "PC Engine", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "PCE_PCECD_SGX", SystemDisplayName = "PC Engine", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "SMS", SystemDisplayName="SMS", Type = "Base", Path= Path.Combine(".", "SMS"), Ordinal = 0 }, - new PathEntry { System = "SMS", SystemDisplayName="SMS", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "SMS", SystemDisplayName="SMS", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "SMS", SystemDisplayName="SMS", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry { System = "SMS", SystemDisplayName="SMS", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "SMS", SystemDisplayName="SMS", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + new PathEntry { System = "GB_GBC", SystemDisplayName = "Gameboy", Type = "Base", Path = Path.Combine(".", "Gameboy"), Ordinal = 0 }, + new PathEntry { System = "GB_GBC", SystemDisplayName = "Gameboy", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "GB_GBC", SystemDisplayName = "Gameboy", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "GB_GBC", SystemDisplayName = "Gameboy", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "GB_GBC", SystemDisplayName = "Gameboy", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "GB_GBC", SystemDisplayName = "Gameboy", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + new PathEntry { System = "GB_GBC", SystemDisplayName = "Gameboy", Type = "Palettes", Path = Path.Combine(".", "Palettes"), Ordinal = 6 }, - new PathEntry { System = "GG", SystemDisplayName="GG", Type = "Base", Path = Path.Combine(".", "Game Gear"), Ordinal = 0 }, - new PathEntry { System = "GG", SystemDisplayName="GG", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "GG", SystemDisplayName="GG", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "GG", SystemDisplayName="GG", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry { System = "GG", SystemDisplayName="GG", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "GG", SystemDisplayName="GG", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + new PathEntry { System = "DGB", SystemDisplayName = "Dual Gameboy", Type = "Base", Path = Path.Combine(".", "Dual Gameboy"), Ordinal = 0 }, + new PathEntry { System = "DGB", SystemDisplayName = "Dual Gameboy", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "DGB", SystemDisplayName = "Dual Gameboy", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "DGB", SystemDisplayName = "Dual Gameboy", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "DGB", SystemDisplayName = "Dual Gameboy", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "DGB", SystemDisplayName = "Dual Gameboy", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + new PathEntry { System = "DGB", SystemDisplayName = "Dual Gameboy", Type = "Palettes", Path = Path.Combine(".", "Palettes"), Ordinal = 6 }, - new PathEntry { System = "SG", SystemDisplayName="SG", Type = "Base", Path = Path.Combine(".", "SG-1000"), Ordinal = 0 }, - new PathEntry { System = "SG", SystemDisplayName="SG", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "SG", SystemDisplayName="SG", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "SG", SystemDisplayName="SG", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry { System = "SG", SystemDisplayName="SG", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "SG", SystemDisplayName="SG", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + new PathEntry { System = "TI83", SystemDisplayName = "TI83", Type = "Base", Path = Path.Combine(".", "TI83"), Ordinal = 0 }, + new PathEntry { System = "TI83", SystemDisplayName = "TI83", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "TI83", SystemDisplayName = "TI83", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "TI83", SystemDisplayName = "TI83", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "TI83", SystemDisplayName = "TI83", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "TI83", SystemDisplayName = "TI83", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "GEN", SystemDisplayName="Genesis", Type = "Base", Path = Path.Combine(".", "Genesis"), Ordinal = 0 }, - new PathEntry { System = "GEN", SystemDisplayName="Genesis", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "GEN", SystemDisplayName="Genesis", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "GEN", SystemDisplayName="Genesis", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry { System = "GEN", SystemDisplayName="Genesis", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "GEN", SystemDisplayName="Genesis", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + new PathEntry { System = "A26", SystemDisplayName = "Atari 2600", Type = "Base", Path = Path.Combine(".", "Atari 2600"), Ordinal = 0 }, + new PathEntry { System = "A26", SystemDisplayName = "Atari 2600", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "A26", SystemDisplayName = "Atari 2600", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "A26", SystemDisplayName = "Atari 2600", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "A26", SystemDisplayName = "Atari 2600", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "PCE_PCECD_SGX", SystemDisplayName="PC Engine", Type = "Base", Path = Path.Combine(".", "PC Engine"), Ordinal = 0 }, - new PathEntry { System = "PCE_PCECD_SGX", SystemDisplayName="PC Engine", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "PCE_PCECD_SGX", SystemDisplayName="PC Engine", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "PCE_PCECD_SGX", SystemDisplayName="PC Engine", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry { System = "PCE_PCECD_SGX", SystemDisplayName="PC Engine", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "PCE_PCECD_SGX", SystemDisplayName="PC Engine", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + new PathEntry { System = "A78", SystemDisplayName = "Atari 7800", Type = "Base", Path = Path.Combine(".", "Atari 7800"), Ordinal = 0 }, + new PathEntry { System = "A78", SystemDisplayName = "Atari 7800", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "A78", SystemDisplayName = "Atari 7800", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "A78", SystemDisplayName = "Atari 7800", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "A78", SystemDisplayName = "Atari 7800", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "A78", SystemDisplayName = "Atari 7800", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "GB_GBC", SystemDisplayName="Gameboy", Type = "Base", Path= Path.Combine(".", "Gameboy"), Ordinal = 0 }, - new PathEntry { System = "GB_GBC", SystemDisplayName="Gameboy", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "GB_GBC", SystemDisplayName="Gameboy", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "GB_GBC", SystemDisplayName="Gameboy", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry { System = "GB_GBC", SystemDisplayName="Gameboy", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "GB_GBC", SystemDisplayName="Gameboy", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "GB_GBC", SystemDisplayName="Gameboy", Type = "Palettes", Path = Path.Combine(".", "Palettes"), Ordinal = 6 }, + new PathEntry { System = "C64", SystemDisplayName = "Commodore 64", Type = "Base", Path = Path.Combine(".", "C64"), Ordinal = 0 }, + new PathEntry { System = "C64", SystemDisplayName = "Commodore 64", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "C64", SystemDisplayName = "Commodore 64", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "C64", SystemDisplayName = "Commodore 64", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "C64", SystemDisplayName = "Commodore 64", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "DGB", SystemDisplayName="Dual Gameboy", Type = "Base", Path= Path.Combine(".", "Dual Gameboy"), Ordinal = 0 }, - new PathEntry { System = "DGB", SystemDisplayName="Dual Gameboy", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "DGB", SystemDisplayName="Dual Gameboy", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "DGB", SystemDisplayName="Dual Gameboy", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry { System = "DGB", SystemDisplayName="Dual Gameboy", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "DGB", SystemDisplayName="Dual Gameboy", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "DGB", SystemDisplayName="Dual Gameboy", Type = "Palettes", Path = Path.Combine(".", "Palettes"), Ordinal = 6 }, + new PathEntry { System = "PSX", SystemDisplayName = "Playstation", Type = "Base", Path = Path.Combine(".", "PSX"), Ordinal = 0 }, + new PathEntry { System = "PSX", SystemDisplayName = "Playstation", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "PSX", SystemDisplayName = "Playstation", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "PSX", SystemDisplayName = "Playstation", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "PSX", SystemDisplayName = "Playstation", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "PSX", SystemDisplayName = "Playstation", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "TI83", SystemDisplayName="TI83", Type = "Base", Path = Path.Combine(".", "TI83"), Ordinal = 0 }, - new PathEntry { System = "TI83", SystemDisplayName="TI83", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "TI83", SystemDisplayName="TI83", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "TI83", SystemDisplayName="TI83", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry { System = "TI83", SystemDisplayName="TI83", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "TI83", SystemDisplayName="TI83", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + new PathEntry { System = "Coleco", SystemDisplayName = "Coleco", Type = "Base", Path = Path.Combine(".", "Coleco"), Ordinal = 0 }, + new PathEntry { System = "Coleco", SystemDisplayName = "Coleco", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "Coleco", SystemDisplayName = "Coleco", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "Coleco", SystemDisplayName = "Coleco", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "Coleco", SystemDisplayName = "Coleco", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "A26", SystemDisplayName="Atari 2600", Type = "Base", Path = Path.Combine(".", "Atari 2600"), Ordinal = 0 }, - new PathEntry { System = "A26", SystemDisplayName="Atari 2600", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "A26", SystemDisplayName="Atari 2600", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "A26", SystemDisplayName="Atari 2600", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "A26", SystemDisplayName="Atari 2600", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + new PathEntry { System = "N64", SystemDisplayName = "N64", Type = "Base", Path = Path.Combine(".", "N64"), Ordinal = 0 }, + new PathEntry { System = "N64", SystemDisplayName = "N64", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "N64", SystemDisplayName = "N64", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "N64", SystemDisplayName = "N64", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "N64", SystemDisplayName = "N64", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "N64", SystemDisplayName = "N64", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "A78", SystemDisplayName="Atari 7800", Type = "Base", Path = Path.Combine(".", "Atari 7800"), Ordinal = 0 }, - new PathEntry { System = "A78", SystemDisplayName="Atari 7800", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "A78", SystemDisplayName="Atari 7800", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "A78", SystemDisplayName="Atari 7800", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry { System = "A78", SystemDisplayName="Atari 7800", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "A78", SystemDisplayName="Atari 7800", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + new PathEntry { System = "SAT", SystemDisplayName = "Saturn", Type = "Base", Path = Path.Combine(".", "Saturn"), Ordinal = 0 }, + new PathEntry { System = "SAT", SystemDisplayName = "Saturn", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "SAT", SystemDisplayName = "Saturn", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "SAT", SystemDisplayName = "Saturn", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "SAT", SystemDisplayName = "Saturn", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "SAT", SystemDisplayName = "Saturn", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "C64", SystemDisplayName="Commodore 64", Type = "Base", Path = Path.Combine(".", "C64"), Ordinal = 0 }, - new PathEntry { System = "C64", SystemDisplayName="Commodore 64", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "C64", SystemDisplayName="Commodore 64", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "C64", SystemDisplayName="Commodore 64", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "C64", SystemDisplayName="Commodore 64", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + new PathEntry { System = "WSWAN", SystemDisplayName = "WonderSwan", Type = "Base", Path = Path.Combine(".", "WonderSwan"), Ordinal = 0 }, + new PathEntry { System = "WSWAN", SystemDisplayName = "WonderSwan", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "WSWAN", SystemDisplayName = "WonderSwan", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "WSWAN", SystemDisplayName = "WonderSwan", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "WSWAN", SystemDisplayName = "WonderSwan", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "WSWAN", SystemDisplayName = "WonderSwan", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "PSX", SystemDisplayName="Playstation", Type = "Base", Path = Path.Combine(".", "PSX"), Ordinal = 0 }, - new PathEntry { System = "PSX", SystemDisplayName="Playstation", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "PSX", SystemDisplayName="Playstation", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "PSX", SystemDisplayName="Playstation", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry { System = "PSX", SystemDisplayName="Playstation", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "PSX", SystemDisplayName="Playstation", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + new PathEntry { System = "Lynx", SystemDisplayName = "Lynx", Type = "Base", Path = Path.Combine(".", "Lynx"), Ordinal = 0 }, + new PathEntry { System = "Lynx", SystemDisplayName = "Lynx", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "Lynx", SystemDisplayName = "Lynx", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "Lynx", SystemDisplayName = "Lynx", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "Lynx", SystemDisplayName = "Lynx", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "Lynx", SystemDisplayName = "Lynx", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "Coleco", SystemDisplayName = "Coleco", Type = "Base", Path = Path.Combine(".", "Coleco"), Ordinal = 0 }, - new PathEntry { System = "Coleco", SystemDisplayName = "Coleco", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "Coleco", SystemDisplayName = "Coleco", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "Coleco", SystemDisplayName = "Coleco", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "Coleco", SystemDisplayName = "Coleco", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "Base", Path = Path.Combine(".", "Apple II"), Ordinal = 0 }, + new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry { System = "N64", SystemDisplayName = "N64", Type = "Base", Path= Path.Combine(".", "N64"), Ordinal = 0 }, - new PathEntry { System = "N64", SystemDisplayName = "N64", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "N64", SystemDisplayName = "N64", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "N64", SystemDisplayName = "N64", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry { System = "N64", SystemDisplayName = "N64", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "N64", SystemDisplayName = "N64", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - - new PathEntry { System = "SAT", SystemDisplayName = "Saturn", Type = "Base", Path = Path.Combine(".", "Saturn"), Ordinal = 0 }, - new PathEntry { System = "SAT", SystemDisplayName = "Saturn", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "SAT", SystemDisplayName = "Saturn", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "SAT", SystemDisplayName = "Saturn", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry { System = "SAT", SystemDisplayName = "Saturn", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "SAT", SystemDisplayName = "Saturn", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - - new PathEntry { System = "WSWAN", SystemDisplayName = "WonderSwan", Type = "Base", Path = Path.Combine(".", "WonderSwan"), Ordinal = 0 }, - new PathEntry { System = "WSWAN", SystemDisplayName = "WonderSwan", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "WSWAN", SystemDisplayName = "WonderSwan", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "WSWAN", SystemDisplayName = "WonderSwan", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry { System = "WSWAN", SystemDisplayName = "WonderSwan", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "WSWAN", SystemDisplayName = "WonderSwan", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - - new PathEntry { System = "Lynx", SystemDisplayName = "Lynx", Type = "Base", Path = Path.Combine(".", "Lynx"), Ordinal = 0 }, - new PathEntry { System = "Lynx", SystemDisplayName = "Lynx", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "Lynx", SystemDisplayName = "Lynx", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "Lynx", SystemDisplayName = "Lynx", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry { System = "Lynx", SystemDisplayName = "Lynx", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "Lynx", SystemDisplayName = "Lynx", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - - new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "Base", Path = Path.Combine(".", "Apple II"), Ordinal = 0 }, - new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry { System = "AppleII", SystemDisplayName = "Apple II", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - - new PathEntry { System = "Libretro", SystemDisplayName = "Libretro", Type = "Base", Path = Path.Combine(".", "Libretro"), Ordinal = 0 }, - new PathEntry { System = "Libretro", SystemDisplayName = "Libretro", Type = "Cores", Path = Path.Combine(".", "Cores"), Ordinal = 1 }, - new PathEntry { System = "Libretro", SystemDisplayName = "Libretro", Type = "System", Path = Path.Combine(".", "System"), Ordinal = 2 }, - new PathEntry { System = "Libretro", SystemDisplayName = "Libretro", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 3 }, - new PathEntry { System = "Libretro", SystemDisplayName = "Libretro", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 4 }, - new PathEntry { System = "Libretro", SystemDisplayName = "Libretro", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 5 }, - new PathEntry { System = "Libretro", SystemDisplayName = "Libretro", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 6 }, - - }; - } - } + new PathEntry { System = "Libretro", SystemDisplayName = "Libretro", Type = "Base", Path = Path.Combine(".", "Libretro"), Ordinal = 0 }, + new PathEntry { System = "Libretro", SystemDisplayName = "Libretro", Type = "Cores", Path = Path.Combine(".", "Cores"), Ordinal = 1 }, + new PathEntry { System = "Libretro", SystemDisplayName = "Libretro", Type = "System", Path = Path.Combine(".", "System"), Ordinal = 2 }, + new PathEntry { System = "Libretro", SystemDisplayName = "Libretro", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 3 }, + new PathEntry { System = "Libretro", SystemDisplayName = "Libretro", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 4 }, + new PathEntry { System = "Libretro", SystemDisplayName = "Libretro", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 5 }, + new PathEntry { System = "Libretro", SystemDisplayName = "Libretro", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 6 }, + }; } } diff --git a/BizHawk.Client.Common/config/ToolDialogSettings.cs b/BizHawk.Client.Common/config/ToolDialogSettings.cs index 530d0ced44..fcd2eee0bb 100644 --- a/BizHawk.Client.Common/config/ToolDialogSettings.cs +++ b/BizHawk.Client.Common/config/ToolDialogSettings.cs @@ -33,7 +33,11 @@ namespace BizHawk.Client.Common [JsonIgnore] public int? Wndx { - get { return _wndx; } + get + { + return _wndx; + } + set { if (value != -32000) @@ -47,7 +51,11 @@ namespace BizHawk.Client.Common [JsonIgnore] public int? Wndy { - get { return _wndy; } + get + { + return _wndy; + } + set { if (value != -32000) diff --git a/BizHawk.Client.Common/inputAdapters/AutoPattern.cs b/BizHawk.Client.Common/inputAdapters/AutoPattern.cs index aa28922245..f924142b1f 100644 --- a/BizHawk.Client.Common/inputAdapters/AutoPattern.cs +++ b/BizHawk.Client.Common/inputAdapters/AutoPattern.cs @@ -12,25 +12,28 @@ /// public AutoPatternBool() { - Pattern = new bool[] { true }; + Pattern = new[] { true }; } + /// - /// Simple on/off pattern. + /// Initializes a new instance of the class. + /// A simple on/off pattern. /// - /// - /// - public AutoPatternBool(int on, int off, bool skip_lag = true, int offset = 0, int loop = 0) + public AutoPatternBool(int on, int off, bool skipLag = true, int offset = 0, int loop = 0) { - SkipsLag = skip_lag; + SkipsLag = skipLag; _index = offset; Pattern = new bool[on + off]; Loop = loop; for (int i = 0; i < on; i++) + { Pattern[i] = true; + } } - public AutoPatternBool(bool[] pattern, bool skip_lag = true, int offset = 0, int loop = 0) + + public AutoPatternBool(bool[] pattern, bool skipLag = true, int offset = 0, int loop = 0) { - SkipsLag = skip_lag; + SkipsLag = skipLag; Pattern = pattern; _index = offset; Loop = loop; @@ -39,7 +42,6 @@ /// /// Gets the next value and increments index. /// - /// public bool GetNextValue(bool isLag = false) { bool ret = Pattern[_index]; @@ -47,7 +49,9 @@ { _index++; if (_index == Pattern.Length) + { _index = Loop; + } } return ret; @@ -56,12 +60,15 @@ /// /// Gets the next value without incrementing index. /// - /// public bool PeekNextValue() - { return Pattern[_index]; } + { + return Pattern[_index]; + } public void Reset() - { _index = 0; } + { + _index = 0; + } } public class AutoPatternFloat @@ -72,12 +79,14 @@ private int _index; /// + /// Initializes a new instance of the class. /// Defaults to 0. /// public AutoPatternFloat() { - Pattern = new float[] { 0f }; + Pattern = new[] { 0f }; } + /// /// Sinple on/off pattern, using the given values as on/off. /// @@ -88,10 +97,16 @@ Loop = loop; Pattern = new float[on + off]; for (int i = 0; i < on; i++) + { Pattern[i] = valueOn; + } + for (int i = on; i < Pattern.Length; i++) + { Pattern[i] = valueOff; + } } + public AutoPatternFloat(float[] pattern, bool skip_lag = true, int offset = 0, int loop = 0) { SkipsLag = skip_lag; @@ -103,7 +118,6 @@ /// /// Gets the next value and increments index. /// - /// public float GetNextValue(bool isLag = false) { float ret = Pattern[_index]; @@ -111,7 +125,9 @@ { _index++; if (_index == Pattern.Length) + { _index = Loop; + } } return ret; @@ -120,11 +136,14 @@ /// /// Gets the next value without incrementing index. /// - /// public float PeekNextValue() - { return Pattern[_index]; } + { + return Pattern[_index]; + } public void Reset() - { _index = 0; } + { + _index = 0; + } } } diff --git a/BizHawk.Client.Common/inputAdapters/BitwiseAdapters.cs b/BizHawk.Client.Common/inputAdapters/BitwiseAdapters.cs index 7ec0a2e7d3..fef8b9d401 100644 --- a/BizHawk.Client.Common/inputAdapters/BitwiseAdapters.cs +++ b/BizHawk.Client.Common/inputAdapters/BitwiseAdapters.cs @@ -4,12 +4,9 @@ namespace BizHawk.Client.Common { public class AndAdapter : IController { - public ControllerDefinition Definition - { - get { return Source.Definition; } - } + public ControllerDefinition Definition => Source.Definition; - public bool IsPressed(string button) + public bool IsPressed(string button) { if (Source != null && SourceAnd != null) { @@ -32,15 +29,12 @@ namespace BizHawk.Client.Common public class ORAdapter : IController { - public ControllerDefinition Definition - { - get { return Source.Definition; } - } + public ControllerDefinition Definition => Source.Definition; - public bool IsPressed(string button) + public bool IsPressed(string button) { - return (Source != null ? Source.IsPressed(button) : false) - | (SourceOr != null ? SourceOr.IsPressed(button) : false); + return (Source?.IsPressed(button) ?? false) + | (SourceOr?.IsPressed(button) ?? false); } // pass floats solely from the original source diff --git a/BizHawk.Client.Common/inputAdapters/ClickyVirtualPadController.cs b/BizHawk.Client.Common/inputAdapters/ClickyVirtualPadController.cs index d6d897867c..2157fa6d17 100644 --- a/BizHawk.Client.Common/inputAdapters/ClickyVirtualPadController.cs +++ b/BizHawk.Client.Common/inputAdapters/ClickyVirtualPadController.cs @@ -69,5 +69,4 @@ namespace BizHawk.Client.Common private readonly HashSet _pressed = new HashSet(); } - } diff --git a/BizHawk.Client.Common/inputAdapters/CopyController.cs b/BizHawk.Client.Common/inputAdapters/CopyController.cs index 4118a5639e..709ce9d1d8 100644 --- a/BizHawk.Client.Common/inputAdapters/CopyController.cs +++ b/BizHawk.Client.Common/inputAdapters/CopyController.cs @@ -3,16 +3,13 @@ namespace BizHawk.Client.Common { /// - /// Just copies source to sink, or returns whatever a NullController would if it is disconnected. useful for immovable hardpoints. + /// Just copies source to sink, or returns whatever a NullController would if it is disconnected. useful for immovable hard-points. /// public class CopyControllerAdapter : IController { - public ControllerDefinition Definition - { - get { return Curr.Definition; } - } + public ControllerDefinition Definition => Curr.Definition; - public bool IsPressed(string button) + public bool IsPressed(string button) { return Curr.IsPressed(button); } @@ -24,14 +21,6 @@ namespace BizHawk.Client.Common public IController Source { get; set; } - private IController Curr - { - get - { - return Source == null - ? NullController.Instance - : Source; - } - } + private IController Curr => Source ?? NullController.Instance; } } diff --git a/BizHawk.Client.Common/inputAdapters/InputManager.cs b/BizHawk.Client.Common/inputAdapters/InputManager.cs index 2963b419be..e4e998d650 100644 --- a/BizHawk.Client.Common/inputAdapters/InputManager.cs +++ b/BizHawk.Client.Common/inputAdapters/InputManager.cs @@ -2,6 +2,7 @@ using BizHawk.Emulation.Common; using BizHawk.Client.Common.InputAdapterExtensions; + namespace BizHawk.Client.Common { public static class InputManager diff --git a/BizHawk.Client.Common/inputAdapters/SimpleController.cs b/BizHawk.Client.Common/inputAdapters/SimpleController.cs index 12d19d83c1..4f44267885 100644 --- a/BizHawk.Client.Common/inputAdapters/SimpleController.cs +++ b/BizHawk.Client.Common/inputAdapters/SimpleController.cs @@ -16,13 +16,13 @@ namespace BizHawk.Client.Common protected WorkingDictionary Buttons = new WorkingDictionary(); protected WorkingDictionary Floats = new WorkingDictionary(); - public virtual void Clear() + public void Clear() { Buttons = new WorkingDictionary(); Floats = new WorkingDictionary(); } - public virtual bool this[string button] + public bool this[string button] { get { return Buttons[button]; } set { Buttons[button] = value; } @@ -43,7 +43,7 @@ namespace BizHawk.Client.Common return Buttons; } - public virtual void LatchFrom(IController source) + public void LatchFrom(IController source) { foreach (var button in source.Definition.BoolButtons) { diff --git a/BizHawk.Client.Common/inputAdapters/StickyAdapters.cs b/BizHawk.Client.Common/inputAdapters/StickyAdapters.cs index f5981f9dd3..4963ab651e 100644 --- a/BizHawk.Client.Common/inputAdapters/StickyAdapters.cs +++ b/BizHawk.Client.Common/inputAdapters/StickyAdapters.cs @@ -17,12 +17,9 @@ namespace BizHawk.Client.Common /// public class StickyOrAdapter : IController { - public ControllerDefinition Definition - { - get { return Source.Definition; } - } + public ControllerDefinition Definition => Source.Definition; - public bool IsPressed(string button) + public bool IsPressed(string button) { return Source.StickyIsInEffect(button) || SourceStickyOr.StickyIsInEffect(button); @@ -56,12 +53,9 @@ namespace BizHawk.Client.Common return false; } - public ControllerDefinition Definition - { - get { return Source.Definition; } - } + public ControllerDefinition Definition => Source.Definition; - public bool IsPressed(string button) + public bool IsPressed(string button) { var source = Source.IsPressed(button); source ^= stickySet.Contains(button); @@ -137,13 +131,7 @@ namespace BizHawk.Client.Common return stickySet.Contains(button); } - public HashSet CurrentStickies - { - get - { - return stickySet; - } - } + public HashSet CurrentStickies => stickySet; public void ClearStickies() { @@ -229,12 +217,13 @@ namespace BizHawk.Client.Common Off = Global.Config.AutofireOff < 1 ? 0 : Global.Config.AutofireOff; } - private WorkingDictionary _boolPatterns = new WorkingDictionary(); - private WorkingDictionary _floatPatterns = new WorkingDictionary(); + private readonly WorkingDictionary _boolPatterns = new WorkingDictionary(); + private readonly WorkingDictionary _floatPatterns = new WorkingDictionary(); public AutoFireStickyXorAdapter() { - On = 1; Off = 1; + On = 1; + Off = 1; } public IController Source { get; set; } @@ -246,7 +235,10 @@ namespace BizHawk.Client.Common if (value.HasValue) { if (pattern == null) + { pattern = new AutoPatternFloat(value.Value, On, 0, Off); + } + _floatPatterns[name] = pattern; } else @@ -265,7 +257,10 @@ namespace BizHawk.Client.Common if (isSticky) { if (pattern == null) + { pattern = new AutoPatternBool(On, Off); + } + _boolPatterns[button] = pattern; } else @@ -285,15 +280,9 @@ namespace BizHawk.Client.Common return _boolPatterns.ContainsKey(button) || _floatPatterns.ContainsKey(button); } - public HashSet CurrentStickies - { - get - { - return new HashSet(_boolPatterns.Keys); - } - } + public HashSet CurrentStickies => new HashSet(_boolPatterns.Keys); - public void ClearStickies() + public void ClearStickies() { _boolPatterns.Clear(); _floatPatterns.Clear(); @@ -302,9 +291,14 @@ namespace BizHawk.Client.Common public void IncrementLoops(bool lagged) { for (int i = 0; i < _boolPatterns.Count; i++) + { _boolPatterns.ElementAt(i).Value.GetNextValue(lagged); + } + for (int i = 0; i < _floatPatterns.Count; i++) + { _floatPatterns.ElementAt(i).Value.GetNextValue(lagged); + } } private List _justPressed = new List(); @@ -313,10 +307,7 @@ namespace BizHawk.Client.Common { foreach (var button in buttons.Where(button => !_justPressed.Contains(button))) { - if (_boolPatterns.ContainsKey(button)) - SetSticky(button, false); - else - SetSticky(button, true); + SetSticky(button, !_boolPatterns.ContainsKey(button)); } _justPressed = buttons; diff --git a/BizHawk.Client.Common/inputAdapters/UDLRController.cs b/BizHawk.Client.Common/inputAdapters/UDLRController.cs index 08ee3cea68..e29629cf7d 100644 --- a/BizHawk.Client.Common/inputAdapters/UDLRController.cs +++ b/BizHawk.Client.Common/inputAdapters/UDLRController.cs @@ -11,15 +11,10 @@ namespace BizHawk.Client.Common /// public class UD_LR_ControllerAdapter : IController { - public ControllerDefinition Definition - { - get { return Source.Definition; } - } + public ControllerDefinition Definition => Source.Definition; public bool IsPressed(string button) { - bool PriorityUD_LR = !Global.Config.AllowUD_LR && !Global.Config.ForbidUD_LR; // implied by neither of the others being set (left as non-enum for back-compatibility) - if (Global.Config.AllowUD_LR) { return Source.IsPressed(button); @@ -27,10 +22,8 @@ namespace BizHawk.Client.Common string prefix; - //" C " is for N64 "P1 C Up" and the like, which should not be subject to mutexing - - //regarding the unpressing and UDLR logic...... don't think about it. don't question it. don't look at it. - + // " C " is for N64 "P1 C Up" and the like, which should not be subject to mutexing + // regarding the unpressing and UDLR logic...... don't think about it. don't question it. don't look at it. if (button.Contains("Down") && !button.Contains(" C ")) { if (!Source.IsPressed(button)) diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Bit.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Bit.cs index ee86b2c51d..a7efe23b01 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Bit.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Bit.cs @@ -14,9 +14,9 @@ namespace BizHawk.Client.Common public BitLuaLibrary(Lua lua, Action logOutputCallback) : base(lua, logOutputCallback) { } - public override string Name { get { return "bit"; } } + public override string Name => "bit"; - [LuaMethodAttributes( + [LuaMethodAttributes( "band", "Bitwise AND of 'val' against 'amt'" )] diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs index 090e884a5b..9ea964b6c0 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; using System.ComponentModel; -using System.Linq; -using System.Reflection; using BizHawk.Emulation.Common; using BizHawk.Emulation.Common.IEmulatorExtensions; @@ -46,9 +43,9 @@ namespace BizHawk.Client.Common public EmulatorLuaLibrary(Lua lua, Action logOutputCallback) : base(lua, logOutputCallback) { } - public override string Name { get { return "emu"; } } + public override string Name => "emu"; - [LuaMethodAttributes( + [LuaMethodAttributes( "displayvsync", "Sets the display vsync property of the emulator" )] @@ -157,9 +154,7 @@ namespace BizHawk.Client.Common } catch (NotImplementedException) { - Log(string.Format( - "Error: {0} does not yet implement getregisters()", - Emulator.Attributes().CoreName)); + Log($"Error: {Emulator.Attributes().CoreName} does not yet implement getregisters()"); } return table; @@ -182,9 +177,7 @@ namespace BizHawk.Client.Common } catch (NotImplementedException) { - Log(string.Format( - "Error: {0} does not yet implement setregister()", - Emulator.Attributes().CoreName)); + Log($"Error: {Emulator.Attributes().CoreName} does not yet implement setregister()"); } } @@ -232,11 +225,9 @@ namespace BizHawk.Client.Common { return InputPollableCore.IsLagFrame; } - else - { - Log(string.Format("Can not get lag information, {0} does not implement IInputPollable", Emulator.Attributes().CoreName)); - return false; - } + + Log($"Can not get lag information, {Emulator.Attributes().CoreName} does not implement IInputPollable"); + return false; } [LuaMethodAttributes( @@ -251,7 +242,7 @@ namespace BizHawk.Client.Common } else { - Log(string.Format("Can not set lag information, {0} does not implement IInputPollable", Emulator.Attributes().CoreName)); + Log($"Can not set lag information, {Emulator.Attributes().CoreName} does not implement IInputPollable"); } } @@ -265,11 +256,9 @@ namespace BizHawk.Client.Common { return InputPollableCore.LagCount; } - else - { - Log(string.Format("Can not get lag information, {0} does not implement IInputPollable", Emulator.Attributes().CoreName)); - return 0; - } + + Log($"Can not get lag information, {Emulator.Attributes().CoreName} does not implement IInputPollable"); + return 0; } [LuaMethodAttributes( @@ -326,12 +315,18 @@ namespace BizHawk.Client.Common { var quicknes = Emulator as QuickNES; var s = quicknes.GetSettings(); + // this core doesn't support disabling BG bool showsp = GetSetting(0, luaParam); if (showsp && s.NumSprites == 0) + { s.NumSprites = 8; + } else if (!showsp && s.NumSprites > 0) + { s.NumSprites = 0; + } + quicknes.PutSettings(s); } else if (Emulator is PCEngine) diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs index ac030c808e..77fd445d92 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs @@ -30,9 +30,9 @@ namespace BizHawk.Client.Common public EventLuaLibrary(Lua lua, Action logOutputCallback) : base(lua, logOutputCallback) { } - public override string Name { get { return "event"; } } + public override string Name => "event"; - #region Events Library Helpers + #region Events Library Helpers public void CallExitEvent(Lua thread) { @@ -202,11 +202,9 @@ namespace BizHawk.Client.Common return Guid.Empty.ToString(); } } - else - { - LogNotImplemented(); - return Guid.Empty.ToString(); - } + + LogNotImplemented(); + return Guid.Empty.ToString(); } private void LogNotImplemented() @@ -237,7 +235,9 @@ namespace BizHawk.Client.Common DebuggableCore.MemoryCallbacks.ExecuteCallbacksAvailable) { if (N64CoreTypeDynarec()) + { return Guid.Empty.ToString(); + } var nlf = new NamedLuaFunction(luaf, "OnMemoryExecute", LogOutputCallback, CurrentThread, name); _luaFunctions.Add(nlf); @@ -247,7 +247,7 @@ namespace BizHawk.Client.Common return nlf.Guid.ToString(); } } - catch(NotImplementedException) + catch (NotImplementedException) { LogMemoryExecuteCallbacksNotImplemented(); return Guid.Empty.ToString(); @@ -268,7 +268,9 @@ namespace BizHawk.Client.Common if (DebuggableCore != null && DebuggableCore.MemoryCallbacksAvailable()) { if (N64CoreTypeDynarec()) + { return Guid.Empty.ToString(); + } var nlf = new NamedLuaFunction(luaf, "OnMemoryRead", LogOutputCallback, CurrentThread, name); _luaFunctions.Add(nlf); @@ -299,7 +301,9 @@ namespace BizHawk.Client.Common if (DebuggableCore != null && DebuggableCore.MemoryCallbacksAvailable()) { if (N64CoreTypeDynarec()) + { return Guid.Empty.ToString(); + } var nlf = new NamedLuaFunction(luaf, "OnMemoryWrite", LogOutputCallback, CurrentThread, name); _luaFunctions.Add(nlf); diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.GameInfo.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.GameInfo.cs index a8e45df62a..76b67ab5ff 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.GameInfo.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.GameInfo.cs @@ -15,9 +15,9 @@ namespace BizHawk.Client.Common public GameInfoLuaLibrary(Lua lua, Action logOutputCallback) : base(lua, logOutputCallback) { } - public override string Name { get { return "gameinfo"; } } + public override string Name => "gameinfo"; - [LuaMethodAttributes( + [LuaMethodAttributes( "getromname", "returns the path of the currently loaded rom, if a rom is loaded" )] @@ -93,7 +93,7 @@ namespace BizHawk.Client.Common )] public string GetBoardType() { - return Emulator.BoardName ?? ""; + return Emulator.BoardName ?? string.Empty; } [LuaMethodAttributes( diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Genesis.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Genesis.cs index 939d4edd5b..3359c80f08 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Genesis.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Genesis.cs @@ -18,9 +18,9 @@ namespace BizHawk.Client.Common public GenesisLuaLibrary(Lua lua, Action logOutputCallback) : base(lua, logOutputCallback) { } - public override string Name { get { return "genesis"; } } + public override string Name => "genesis"; - private GPGX.GPGXSettings GetSettings() + private GPGX.GPGXSettings GetSettings() { if (Genesis != null) { @@ -32,10 +32,7 @@ namespace BizHawk.Client.Common private void PutSettings(GPGX.GPGXSettings settings) { - if (Genesis != null) - { - Genesis.PutSettings(settings); - } + Genesis?.PutSettings(settings); } [LuaMethodAttributes( diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs index 5d4617265d..76348b99cd 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs @@ -11,9 +11,9 @@ namespace BizHawk.Client.Common public JoypadLuaLibrary(Lua lua, Action logOutputCallback) : base(lua, logOutputCallback) { } - public override string Name { get { return "joypad"; } } + public override string Name => "joypad"; - [LuaMethodAttributes( + [LuaMethodAttributes( "get", "returns a lua table of the controller buttons pressed. If supplied, it will only return a table of buttons for the given controller" )] @@ -109,7 +109,7 @@ namespace BizHawk.Client.Common bool? theValue; var theValueStr = buttons[button].ToString(); - if (!String.IsNullOrWhiteSpace(theValueStr)) + if (!string.IsNullOrWhiteSpace(theValueStr)) { if (theValueStr.ToLower() == "false") { @@ -175,11 +175,13 @@ namespace BizHawk.Client.Common var theValueStr = controls[name].ToString(); float? theValue = null; - if (!String.IsNullOrWhiteSpace(theValueStr)) + if (!string.IsNullOrWhiteSpace(theValueStr)) { float f; if (float.TryParse(theValueStr, out f)) + { theValue = f; + } } if (controller == null) @@ -190,7 +192,6 @@ namespace BizHawk.Client.Common { Global.StickyXORAdapter.SetFloat("P" + controller + " " + name, theValue); } - } } catch { /*Eat it*/ } diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.MainMemory.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.MainMemory.cs index c30e657e97..2a514f905a 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.MainMemory.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.MainMemory.cs @@ -16,9 +16,9 @@ namespace BizHawk.Client.Common public MainMemoryLuaLibrary(Lua lua, Action logOutputCallback) : base(lua, logOutputCallback) { } - public override string Name { get { return "mainmemory"; } } + public override string Name => "mainmemory"; - protected override MemoryDomain Domain + protected override MemoryDomain Domain { get { @@ -28,7 +28,7 @@ namespace BizHawk.Client.Common } else { - var error = string.Format("Error: {0} does not implement memory domains", Emulator.Attributes().CoreName); + var error = $"Error: {Emulator.Attributes().CoreName} does not implement memory domains"; Log(error); throw new NotImplementedException(error); } diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Memory.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Memory.cs index 25303256bd..c8ef9528aa 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Memory.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Memory.cs @@ -24,9 +24,9 @@ namespace BizHawk.Client.Common } - public override string Name { get { return "memory"; } } + public override string Name => "memory"; - protected override MemoryDomain Domain + protected override MemoryDomain Domain { get { @@ -34,21 +34,16 @@ namespace BizHawk.Client.Common { if (_currentMemoryDomain == null) { - if (MemoryDomainCore.HasSystemBus) - { - _currentMemoryDomain = MemoryDomainCore.SystemBus; - } - else - { - _currentMemoryDomain = MemoryDomainCore.MainMemory; - } + _currentMemoryDomain = MemoryDomainCore.HasSystemBus + ? MemoryDomainCore.SystemBus + : MemoryDomainCore.MainMemory; } return _currentMemoryDomain; } else { - var error = string.Format("Error: {0} does not implement memory domains", Emulator.Attributes().CoreName); + var error = $"Error: {Emulator.Attributes().CoreName} does not implement memory domains"; Log(error); throw new NotImplementedException(error); } @@ -120,14 +115,14 @@ namespace BizHawk.Client.Common } else { - Log(string.Format("Unable to find domain: {0}", domain)); + Log($"Unable to find domain: {domain}"); return false; } } catch // Just in case { - Log(string.Format("Unable to find domain: {0}", domain)); + Log($"Unable to find domain: {domain}"); } return false; diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.MemorySavestate.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.MemorySavestate.cs index c0602d8da3..5840b106cb 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.MemorySavestate.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.MemorySavestate.cs @@ -1,84 +1,83 @@ -using System; -using System.Collections.Generic; -using System.IO; - -using LuaInterface; - -using BizHawk.Emulation.Common; -using BizHawk.Emulation.Common.IEmulatorExtensions; - -namespace BizHawk.Client.Common -{ - public sealed class MemorySavestateEmuLuaLibrary : LuaLibraryBase - { - public MemorySavestateEmuLuaLibrary(Lua lua) - : base(lua) { } - - public MemorySavestateEmuLuaLibrary(Lua lua, Action logOutputCallback) - : base(lua, logOutputCallback) { } - - public override string Name { get { return "memorysavestate"; } } - - private readonly Dictionary MemorySavestates = new Dictionary(); - - [RequiredService] - private IStatable _statableCore { get; set; } - - [LuaMethodAttributes( - "savecorestate", - "creates a core savestate and stores it in memory. Note: a core savestate is only the raw data from the core, and not extras such as movie input logs, or framebuffers. Returns a unique identifer for the savestate" - )] - public string SaveCoreStateToMemory() - { - var guid = Guid.NewGuid(); - var bytes = (byte[])_statableCore.SaveStateBinary().Clone(); - +using System; +using System.Collections.Generic; +using System.IO; + +using LuaInterface; + +using BizHawk.Emulation.Common; + +namespace BizHawk.Client.Common +{ + public sealed class MemorySavestateEmuLuaLibrary : LuaLibraryBase + { + public MemorySavestateEmuLuaLibrary(Lua lua) + : base(lua) { } + + public MemorySavestateEmuLuaLibrary(Lua lua, Action logOutputCallback) + : base(lua, logOutputCallback) { } + + public override string Name => "memorysavestate"; + + private readonly Dictionary MemorySavestates = new Dictionary(); + + [RequiredService] + private IStatable _statableCore { get; set; } + + [LuaMethodAttributes( + "savecorestate", + "creates a core savestate and stores it in memory. Note: a core savestate is only the raw data from the core, and not extras such as movie input logs, or framebuffers. Returns a unique identifer for the savestate" + )] + public string SaveCoreStateToMemory() + { + var guid = Guid.NewGuid(); + var bytes = (byte[])_statableCore.SaveStateBinary().Clone(); + MemorySavestates.Add(guid, bytes); - return guid.ToString(); - } - - [LuaMethodAttributes( - "loadcorestate", - "loads an in memory state with the given identifier" - )] - public void LoadCoreStateFromMemory(string identifier) - { - var guid = new Guid(identifier); - - try - { - var state = MemorySavestates[guid]; - - using (MemoryStream ms = new MemoryStream(state)) - using (BinaryReader br = new BinaryReader(ms)) - { - _statableCore.LoadStateBinary(br); - } - } - catch - { - Log("Unable to find the given savestate in memory"); - } - } - - [LuaMethodAttributes( - "removestate", - "removes the savestate with the given identifier from memory" - )] - public void DeleteState(string identifier) - { - var guid = new Guid(identifier); - MemorySavestates.Remove(guid); - } - - [LuaMethodAttributes( - "clearstatesfrommemory", - "clears all savestates stored in memory" - )] - public void ClearInMemoryStates() - { - MemorySavestates.Clear(); - } - } -} + return guid.ToString(); + } + + [LuaMethodAttributes( + "loadcorestate", + "loads an in memory state with the given identifier" + )] + public void LoadCoreStateFromMemory(string identifier) + { + var guid = new Guid(identifier); + + try + { + var state = MemorySavestates[guid]; + + using (var ms = new MemoryStream(state)) + using (var br = new BinaryReader(ms)) + { + _statableCore.LoadStateBinary(br); + } + } + catch + { + Log("Unable to find the given savestate in memory"); + } + } + + [LuaMethodAttributes( + "removestate", + "removes the savestate with the given identifier from memory" + )] + public void DeleteState(string identifier) + { + var guid = new Guid(identifier); + MemorySavestates.Remove(guid); + } + + [LuaMethodAttributes( + "clearstatesfrommemory", + "clears all savestates stored in memory" + )] + public void ClearInMemoryStates() + { + MemorySavestates.Clear(); + } + } +} diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Movie.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Movie.cs index 9c3ddaae2c..4d4f60abd5 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Movie.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Movie.cs @@ -13,9 +13,9 @@ namespace BizHawk.Client.Common : base(lua, logOutputCallback) { } - public override string Name { get { return "movie"; } } + public override string Name => "movie"; - [LuaMethodAttributes( + [LuaMethodAttributes( "startsfromsavestate", "Returns whether or not the movie is a savestate-anchored movie" )] @@ -177,7 +177,9 @@ namespace BizHawk.Client.Common public void Save(string filename = "") { if (!Global.MovieSession.Movie.IsActive) + { return; + } if (!string.IsNullOrEmpty(filename)) { @@ -185,11 +187,13 @@ namespace BizHawk.Client.Common var test = new FileInfo(filename); if (test.Exists) { - Log(string.Format("File {0} already exists, will not overwrite", filename)); + Log($"File {filename} already exists, will not overwrite"); return; } + Global.MovieSession.Movie.Filename = filename; } + Global.MovieSession.Movie.Save(); } @@ -210,10 +214,12 @@ namespace BizHawk.Client.Common { // Lua numbers are always double, integer precision holds up // to 53 bits, so throw an error if it's bigger than that. - const double precisionLimit = 9007199254740992d; + const double PrecisionLimit = 9007199254740992d; - if (count > precisionLimit) + if (count > PrecisionLimit) + { throw new Exception("Rerecord count exceeds Lua integer precision."); + } Global.MovieSession.Movie.Rerecords = (ulong)count; } diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs index b210c0cecb..87dc1002d5 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs @@ -29,16 +29,16 @@ namespace BizHawk.Client.Common [OptionalService] private IMemoryDomains _memoryDomains { get; set; } - private bool NESAvailable { get { return _neshawk != null || _quicknes != null; } } + private bool NESAvailable => _neshawk != null || _quicknes != null; - private bool HasMemoryDOmains { get { return _memoryDomains != null; } } + private bool HasMemoryDOmains => _memoryDomains != null; - public NesLuaLibrary(Lua lua, Action logOutputCallback) + public NesLuaLibrary(Lua lua, Action logOutputCallback) : base(lua, logOutputCallback) { } - public override string Name { get { return "nes"; } } + public override string Name => "nes"; - [LuaMethodAttributes( + [LuaMethodAttributes( "addgamegenie", "Adds the specified game genie code. If an NES game is not currently loaded or the code is not a valid game genie code, this will have no effect" )] @@ -72,6 +72,7 @@ namespace BizHawk.Client.Common { return _quicknes.GetSettings().NumSprites != 8; } + if (_neshawk != null) { return _neshawk.GetSettings().AllowMoreThanEightSprites; @@ -210,7 +211,6 @@ namespace BizHawk.Client.Common var s = _quicknes.GetSettings(); s.NumSprites = allow ? 64 : 8; _quicknes.PutSettings(s); - } } diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.SNES.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.SNES.cs index 262ddf2182..ff5f5e540c 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.SNES.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.SNES.cs @@ -18,9 +18,9 @@ namespace BizHawk.Client.Common public SnesLuaLibrary(Lua lua, Action logOutputCallback) : base(lua, logOutputCallback) { } - public override string Name { get { return "snes"; } } + public override string Name => "snes"; - private LibsnesCore.SnesSettings GetSettings() + private LibsnesCore.SnesSettings GetSettings() { if (Snes != null) { @@ -32,10 +32,7 @@ namespace BizHawk.Client.Common private void PutSettings(LibsnesCore.SnesSettings settings) { - if (Snes != null) - { - Snes.PutSettings(settings); - } + Snes?.PutSettings(settings); } [LuaMethodAttributes( diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.String.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.String.cs index 51f3bc7bce..3bdc06ec35 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.String.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.String.cs @@ -9,9 +9,9 @@ namespace BizHawk.Client.Common [Description("A library exposing standard .NET string methods")] public sealed class StringLuaLibrary : LuaLibraryBase { - public override string Name { get { return "bizstring"; } } + public override string Name => "bizstring"; - public StringLuaLibrary(Lua lua) + public StringLuaLibrary(Lua lua) : base(lua) { } public StringLuaLibrary(Lua lua, Action logOutputCallback) @@ -23,7 +23,7 @@ namespace BizHawk.Client.Common )] public static string Hex(long num) { - var hex = string.Format("{0:X}", num); + var hex = $"{num:X}"; if (hex.Length == 1) { hex = "0" + hex; diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.UserData.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.UserData.cs index 4d58ab6424..4d941681f0 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.UserData.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.UserData.cs @@ -19,9 +19,9 @@ namespace BizHawk.Client.EmuHawk public UserDataLibrary(Lua lua, Action logOutputCallback) : base(lua, logOutputCallback) { } - public override string Name { get { return "userdata"; } } + public override string Name => "userdata"; - [LuaMethodAttributes( + [LuaMethodAttributes( "set", "adds or updates the data with the given key with the given value" )] diff --git a/BizHawk.Client.Common/lua/EnvironmentSandbox.cs b/BizHawk.Client.Common/lua/EnvironmentSandbox.cs index a00a5fae86..3042a821c9 100644 --- a/BizHawk.Client.Common/lua/EnvironmentSandbox.cs +++ b/BizHawk.Client.Common/lua/EnvironmentSandbox.cs @@ -1,17 +1,13 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -//TODO - kill this file (or renew the concept as distinct from the LuaSandbox?) +// TODO - kill this file (or renew the concept as distinct from the LuaSandbox?) namespace BizHawk.Client.Common { public class EnvironmentSandbox { public static void Sandbox(Action callback) { - //just a stub for right now + // just a stub for right now callback(); } } diff --git a/BizHawk.Client.Common/lua/LuaAttributes.cs b/BizHawk.Client.Common/lua/LuaAttributes.cs index a95687a714..64f3fdd825 100644 --- a/BizHawk.Client.Common/lua/LuaAttributes.cs +++ b/BizHawk.Client.Common/lua/LuaAttributes.cs @@ -11,8 +11,8 @@ namespace BizHawk.Client.Common Description = description; } - public string Name { get; set; } - public string Description { get; set; } + public string Name { get; } + public string Description { get; } } [AttributeUsage(AttributeTargets.Class)] @@ -23,6 +23,6 @@ namespace BizHawk.Client.Common Released = released; } - public bool Released { get; set; } + public bool Released { get; } } } diff --git a/BizHawk.Client.Common/lua/LuaDocumentation.cs b/BizHawk.Client.Common/lua/LuaDocumentation.cs index 7afbdf9e17..6f83d44422 100644 --- a/BizHawk.Client.Common/lua/LuaDocumentation.cs +++ b/BizHawk.Client.Common/lua/LuaDocumentation.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.IO; using System.Linq; using System.Reflection; using System.Text; @@ -10,7 +9,7 @@ namespace BizHawk.Client.Common public class LuaDocumentation : List { public LuaDocumentation() - :base() { } + : base() { } public string ToTASVideosWikiMarkup() { @@ -114,7 +113,7 @@ __Types and notation__ if (f.ParameterList.Any()) { sb - .Append(string.Format("{0}.{1}(", f.Library, f.Name)); + .Append($"{f.Library}.{f.Name}("); var parameters = f.Method.GetParameters() .ToList(); @@ -128,7 +127,7 @@ __Types and notation__ if (parameters[i].IsOptional) { - sb.Append(string.Format("[{0}]", parameters[i].Name)); + sb.Append($"[{parameters[i].Name}]"); } else { @@ -147,7 +146,7 @@ __Types and notation__ } else { - sb.Append(string.Format("{0}.{1}()", f.Library, f.Name)); + sb.Append($"{f.Library}.{f.Name}()"); } completion.Contents = sb.ToString(); @@ -178,22 +177,16 @@ __Types and notation__ LibraryDescription = libraryDescription; } - public string Library { get; private set; } - public string LibraryDescription { get; private set; } + public string Library { get; } + public string LibraryDescription { get; } - public MethodInfo Method { get { return _method; } } + public MethodInfo Method => _method; - public string Name - { - get { return _luaAttributes.Name; } - } + public string Name => _luaAttributes.Name; - public string Description - { - get { return _luaAttributes.Description; } - } + public string Description => _luaAttributes.Description; - private string _paramterList = null; + private string _paramterList = null; public string ParameterList { diff --git a/BizHawk.Client.Common/lua/LuaFile.cs b/BizHawk.Client.Common/lua/LuaFile.cs index 9d189dc7b0..7f31bcf2bd 100644 --- a/BizHawk.Client.Common/lua/LuaFile.cs +++ b/BizHawk.Client.Common/lua/LuaFile.cs @@ -30,8 +30,8 @@ public string Name { get; set; } public string Path { get; set; } - public bool Enabled { get { return State != RunState.Disabled; } } - public bool Paused { get { return State == RunState.Paused; } } + public bool Enabled => State != RunState.Disabled; + public bool Paused => State == RunState.Paused; public bool IsSeparator { get; set; } public LuaInterface.Lua Thread { get; set; } public bool FrameWaiting { get; set; } @@ -44,12 +44,9 @@ public RunState State { get; set; } - public static LuaFile SeparatorInstance - { - get { return new LuaFile(true); } - } + public static LuaFile SeparatorInstance => new LuaFile(true); - public void Stop() + public void Stop() { State = RunState.Disabled; Thread = null; @@ -75,9 +72,13 @@ public void TogglePause() { if (State == RunState.Paused) + { State = RunState.Running; - else if(State == RunState.Running) + } + else if (State == RunState.Running) + { State = RunState.Paused; + } } } } diff --git a/BizHawk.Client.Common/lua/LuaFileList.cs b/BizHawk.Client.Common/lua/LuaFileList.cs index 2c17124155..135fb0a6d1 100644 --- a/BizHawk.Client.Common/lua/LuaFileList.cs +++ b/BizHawk.Client.Common/lua/LuaFileList.cs @@ -105,10 +105,9 @@ namespace BizHawk.Client.Common Add(new LuaFile(scriptPath) { - State = ( - !Global.Config.DisableLuaScriptsOnLoad - && line.Substring(0, 1) == "1" - ) ? LuaFile.RunState.Running : LuaFile.RunState.Disabled + State = !Global.Config.DisableLuaScriptsOnLoad && line.Substring(0, 1) == "1" + ? LuaFile.RunState.Running + : LuaFile.RunState.Disabled }); } } diff --git a/BizHawk.Client.Common/lua/LuaFunctionList.cs b/BizHawk.Client.Common/lua/LuaFunctionList.cs index 6150c2abd6..b8ca167846 100644 --- a/BizHawk.Client.Common/lua/LuaFunctionList.cs +++ b/BizHawk.Client.Common/lua/LuaFunctionList.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Linq; -using BizHawk.Emulation.Common; using BizHawk.Emulation.Common.IEmulatorExtensions; namespace BizHawk.Client.Common @@ -40,8 +39,8 @@ namespace BizHawk.Client.Common if (Global.Emulator.MemoryCallbacksAvailable()) { - var cbSys = Global.Emulator.AsDebuggable().MemoryCallbacks; - cbSys.RemoveAll(this.Select(x => x.Callback)); + var memoryCallbacks = Global.Emulator.AsDebuggable().MemoryCallbacks; + memoryCallbacks.RemoveAll(this.Select(x => x.Callback)); } Clear(); diff --git a/BizHawk.Client.Common/lua/LuaHelper.cs b/BizHawk.Client.Common/lua/LuaHelper.cs index 9180ec421f..2301df1a62 100644 --- a/BizHawk.Client.Common/lua/LuaHelper.cs +++ b/BizHawk.Client.Common/lua/LuaHelper.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using LuaInterface; -using System.Reflection; +using LuaInterface; namespace BizHawk.Client.Common { @@ -20,7 +15,7 @@ namespace BizHawk.Client.Common { if (method.IsPublic) { - table[method.Name] = lua.RegisterFunction("", obj, method); + table[method.Name] = lua.RegisterFunction(string.Empty, obj, method); } } diff --git a/BizHawk.Client.Common/lua/LuaLibraryBase.cs b/BizHawk.Client.Common/lua/LuaLibraryBase.cs index 18e0621473..7fb67bb411 100644 --- a/BizHawk.Client.Common/lua/LuaLibraryBase.cs +++ b/BizHawk.Client.Common/lua/LuaLibraryBase.cs @@ -43,7 +43,10 @@ namespace BizHawk.Client.Common lock (ThreadMutex) { if (CurrentHostThread != null) + { throw new InvalidOperationException("Can't have lua running in two host threads at a time!"); + } + CurrentHostThread = Thread.CurrentThread; CurrentThread = luaThread; } @@ -52,10 +55,7 @@ namespace BizHawk.Client.Common protected void Log(object message) { - if (LogOutputCallback != null) - { - LogOutputCallback(message.ToString()); - } + LogOutputCallback?.Invoke(message.ToString()); } public virtual void LuaRegister(Type callingLibrary, LuaDocumentation docs = null) @@ -74,10 +74,7 @@ namespace BizHawk.Client.Common var luaName = Name + "." + luaMethodAttr.Name; Lua.RegisterFunction(luaName, this, method); - if (docs != null) - { - docs.Add(new LibraryFunction(Name, callingLibrary.Description(), method)); - } + docs?.Add(new LibraryFunction(Name, callingLibrary.Description(), method)); } } diff --git a/BizHawk.Client.Common/lua/LuaMemoryBase.cs b/BizHawk.Client.Common/lua/LuaMemoryBase.cs index bc1ed3acaf..ce1bee05bd 100644 --- a/BizHawk.Client.Common/lua/LuaMemoryBase.cs +++ b/BizHawk.Client.Common/lua/LuaMemoryBase.cs @@ -32,12 +32,10 @@ namespace BizHawk.Client.Common { return MemoryDomainCore; } - else - { - var error = string.Format("Error: {0} does not implement memory domains", Emulator.Attributes().CoreName); - Log(error); - throw new NotImplementedException(error); - } + + var error = $"Error: {Emulator.Attributes().CoreName} does not implement memory domains"; + Log(error); + throw new NotImplementedException(error); } } @@ -47,25 +45,22 @@ namespace BizHawk.Client.Common { if (DomainList[domain] == null) { - Log(string.Format("Unable to find domain: {0}, falling back to current", domain)); + Log($"Unable to find domain: {domain}, falling back to current"); return Domain.Name; } - else - { - return domain; - } + return domain; } catch // Just in case { - Log(string.Format("Unable to find domain: {0}, falling back to current", domain)); + Log($"Unable to find domain: {domain}, falling back to current"); } return Domain.Name; } protected uint ReadUnsignedByte(int addr, string domain = null) { - var d = (string.IsNullOrEmpty(domain)) ? Domain : DomainList[VerifyMemoryDomain(domain)]; + var d = string.IsNullOrEmpty(domain) ? Domain : DomainList[VerifyMemoryDomain(domain)]; if (addr < d.Size) { return d.PeekByte(addr); @@ -78,7 +73,7 @@ namespace BizHawk.Client.Common protected void WriteUnsignedByte(int addr, uint v, string domain = null) { - var d = (string.IsNullOrEmpty(domain)) ? Domain : DomainList[VerifyMemoryDomain(domain)]; + var d = string.IsNullOrEmpty(domain) ? Domain : DomainList[VerifyMemoryDomain(domain)]; if (d.CanPoke()) { if (addr < Domain.Size) @@ -93,7 +88,7 @@ namespace BizHawk.Client.Common } else { - Log(string.Format("Error: the domain {0} is not writable", d.Name)); + Log($"Error: the domain {d.Name} is not writable"); } } @@ -178,12 +173,12 @@ namespace BizHawk.Client.Common protected LuaTable ReadByteRange(int addr, int length, string domain = null) { - var d = (string.IsNullOrEmpty(domain)) ? Domain : DomainList[VerifyMemoryDomain(domain)]; + var d = string.IsNullOrEmpty(domain) ? Domain : DomainList[VerifyMemoryDomain(domain)]; var lastAddr = length + addr; var table = Lua.NewTable(); if (lastAddr < d.Size) { - for (var i = 0; i Logger; static System.Runtime.CompilerServices.ConditionalWeakTable SandboxForThread = new System.Runtime.CompilerServices.ConditionalWeakTable(); public static Action DefaultLogger; - public void SetLogger(Action logger) - { - Logger = logger; + public void SetLogger(Action logger) + { + Logger = logger; } public void SetSandboxCurrentDirectory(string dir) @@ -39,26 +35,26 @@ namespace BizHawk.Client.Common { string target = CurrentDirectory + "\\"; - //first we'll bypass it with a general hack: dont do any setting if the value's already there (even at the OS level, setting the directory can be slow) - //yeah I know, not the smoothest move to compare strings here, in case path normalization is happening at some point - //but you got any better ideas? + // first we'll bypass it with a general hack: dont do any setting if the value's already there (even at the OS level, setting the directory can be slow) + // yeah I know, not the smoothest move to compare strings here, in case path normalization is happening at some point + // but you got any better ideas? if (currDirSpeedHack == null) currDirSpeedHack = CoolGetCurrentDirectory(); if (currDirSpeedHack == path) return true; //WARNING: setting the current directory is SLOW!!! security checks for some reason. - //so we're bypassing it with windows hacks + //so we're bypassing it with windows hacks #if WINDOWS fixed (byte* pstr = &System.Text.Encoding.Unicode.GetBytes(target + "\0")[0]) - return SetCurrentDirectoryW(pstr); - #else - if(System.IO.Directory.Exists(CurrentDirectory)) //race condition for great justice - { - Environment.CurrentDirectory = CurrentDirectory; //thats right, you can't set a directory as current that doesnt exist because .net's got to do SENSELESS SLOW-ASS SECURITY CHECKS on it and it can't do that on a NONEXISTENT DIRECTORY - return true; - } - else return false + return SetCurrentDirectoryW(pstr); + #else + if(System.IO.Directory.Exists(CurrentDirectory)) //race condition for great justice + { + Environment.CurrentDirectory = CurrentDirectory; //thats right, you can't set a directory as current that doesnt exist because .net's got to do SENSELESS SLOW-ASS SECURITY CHECKS on it and it can't do that on a NONEXISTENT DIRECTORY + return true; + } + else return false #endif } @@ -69,43 +65,40 @@ namespace BizHawk.Client.Common //AS IF ASKING FOR THE CURRENT DIRECTORY IS EQUIVALENT TO TRYING TO ACCESS IT //SCREW YOU #if WINDOWS - var buf = new byte[32768]; - fixed(byte* pBuf = &buf[0]) + var buf = new byte[32768]; + fixed(byte* pBuf = &buf[0]) { uint ret = GetCurrentDirectoryW(32767, pBuf); return System.Text.Encoding.Unicode.GetString(buf, 0, (int)ret*2); } - #else - return Environment.CurrentDirectory; + #else + return Environment.CurrentDirectory; #endif } void Sandbox(Action callback, Action exceptionCallback) { - string savedEnvironmentCurrDir = null; - try - { + string savedEnvironmentCurrDir = null; + try + { savedEnvironmentCurrDir = Environment.CurrentDirectory; if (CurrentDirectory != null) - CoolSetCurrentDirectory(CurrentDirectory, savedEnvironmentCurrDir); - - EnvironmentSandbox.Sandbox(callback); - } - catch (LuaException ex) + CoolSetCurrentDirectory(CurrentDirectory, savedEnvironmentCurrDir); + + EnvironmentSandbox.Sandbox(callback); + } + catch (LuaException ex) { - Console.WriteLine(ex); - Logger(ex.ToString()); - if (exceptionCallback != null) - { - exceptionCallback(); - } - } - finally + Console.WriteLine(ex); + Logger(ex.ToString()); + exceptionCallback?.Invoke(); + } + finally { if (CurrentDirectory != null) - CoolSetCurrentDirectory(savedEnvironmentCurrDir); - } + CoolSetCurrentDirectory(savedEnvironmentCurrDir); + } } public static LuaSandbox CreateSandbox(Lua thread, string initialDirectory) @@ -119,8 +112,8 @@ namespace BizHawk.Client.Common public static LuaSandbox GetSandbox(Lua thread) { - //this is just placeholder. - //we shouldnt be calling a sandbox with no thread--construct a sandbox properly + // this is just placeholder. + // we shouldnt be calling a sandbox with no thread--construct a sandbox properly if (thread == null) { return new LuaSandbox(); @@ -133,8 +126,8 @@ namespace BizHawk.Client.Common return sandbox; else { - //for now: throw exception (I want to manually creating them) - //return CreateSandbox(thread); + // for now: throw exception (I want to manually creating them) + // return CreateSandbox(thread); throw new InvalidOperationException("HOARY GORILLA HIJINX"); } } @@ -143,6 +136,6 @@ namespace BizHawk.Client.Common public static void Sandbox(Lua thread, Action callback, Action exceptionCallback = null) { GetSandbox(thread).Sandbox(callback, exceptionCallback); - } - } -} + } + } +} diff --git a/BizHawk.Client.Common/movie/PlatformFrameRates.cs b/BizHawk.Client.Common/movie/PlatformFrameRates.cs index b88127231d..a8bf3655db 100644 --- a/BizHawk.Client.Common/movie/PlatformFrameRates.cs +++ b/BizHawk.Client.Common/movie/PlatformFrameRates.cs @@ -50,7 +50,7 @@ namespace BizHawk.Client.Common { "A78", 59.9227510135505 }, { "Coleco", 59.9227510135505 }, - //according to http://problemkaputt.de/psx-spx.htm + // according to http://problemkaputt.de/psx-spx.htm { "PSX", 44100.0*768*11/7/263/3413 }, // 59.292862562 { "PSX_PAL", 44100.0*768*11/7/314/3406 }, // 49.7645593576 @@ -60,7 +60,6 @@ namespace BizHawk.Client.Common { "C64_DREAN", PAL_N_CARRIER*2/7/312/65 }, { "INTV", 59.92 } - // according to ryphecha, using // clocks[2] = { 53.693182e06, 53.203425e06 }; //ntsc console, pal console // lpf[2][2] = { { 263, 262.5 }, { 314, 312.5 } }; //ntsc,pal; noninterlaced, interlaced diff --git a/BizHawk.Client.Common/movie/bk2/Bk2ControllerAdapter.cs b/BizHawk.Client.Common/movie/bk2/Bk2ControllerAdapter.cs index 61a73f0221..107f36929e 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2ControllerAdapter.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2ControllerAdapter.cs @@ -30,7 +30,7 @@ namespace BizHawk.Client.Common { var groups = _logKey.Split(new[] { "#" }, StringSplitOptions.RemoveEmptyEntries); var controls = groups - .Select(@group => @group.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries).ToList()) + .Select(group => group.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries).ToList()) .ToList(); _type.ControlsFromLog = controls; @@ -162,7 +162,7 @@ namespace BizHawk.Client.Common if (!string.IsNullOrWhiteSpace(mnemonic)) { var def = Global.Emulator.ControllerDefinition; - var trimmed = mnemonic.Replace("|", ""); + var trimmed = mnemonic.Replace("|", string.Empty); var buttons = Definition.ControlsOrdered.SelectMany(x => x).ToList(); var iterator = 0; @@ -177,7 +177,7 @@ namespace BizHawk.Client.Common { var temp = trimmed.Substring(iterator, 5); var val = int.Parse(temp.Trim()); - this.MyFloatControls[key] = val; + MyFloatControls[key] = val; iterator += 6; } diff --git a/BizHawk.Client.Common/movie/bk2/Bk2FloatConstants.cs b/BizHawk.Client.Common/movie/bk2/Bk2FloatConstants.cs index e222e58c80..f68201f46e 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2FloatConstants.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2FloatConstants.cs @@ -9,11 +9,11 @@ namespace BizHawk.Client.Common get { var key = button - .Replace("P1 ", "") - .Replace("P2 ", "") - .Replace("P3 ", "") - .Replace("P4 ", "") - .Replace("Key ", ""); + .Replace("P1 ", string.Empty) + .Replace("P2 ", string.Empty) + .Replace("P3 ", string.Empty) + .Replace("P4 ", string.Empty) + .Replace("Key ", string.Empty); if (SystemOverrides.ContainsKey(Global.Emulator.SystemId) && SystemOverrides[Global.Emulator.SystemId].ContainsKey(key)) { diff --git a/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs b/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs index a283565143..fb74bd385e 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs @@ -1,8 +1,8 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; using System.Text; using BizHawk.Emulation.Common; -using System.Collections.Generic; namespace BizHawk.Client.Common { @@ -19,15 +19,9 @@ namespace BizHawk.Client.Common _logKey = logKey; } - public IMovieController MovieControllerAdapter - { - get - { - return new Bk2ControllerAdapter(_logKey); - } - } + public IMovieController MovieControllerAdapter => new Bk2ControllerAdapter(_logKey); - #region ILogEntryGenerator Implementation + #region ILogEntryGenerator Implementation public void SetSource(IController source) { @@ -39,23 +33,11 @@ namespace BizHawk.Client.Common return CreateLogEntry(forInputDisplay: true); } - public bool IsEmpty - { - get - { - return EmptyEntry == GenerateLogEntry(); - } - } + public bool IsEmpty => EmptyEntry == GenerateLogEntry(); - public string EmptyEntry - { - get - { - return CreateLogEntry(createEmpty: true); - } - } + public string EmptyEntry => CreateLogEntry(createEmpty: true); - public string GenerateLogEntry() + public string GenerateLogEntry() { return CreateLogEntry(); } @@ -107,7 +89,9 @@ namespace BizHawk.Client.Common var sb = new StringBuilder(); if (!forInputDisplay) + { sb.Append('|'); + } foreach (var group in _source.Definition.ControlsOrdered) { @@ -131,9 +115,13 @@ namespace BizHawk.Client.Common } if (forInputDisplay && val == mid) + { sb.Append(" "); + } else + { sb.Append(val.ToString().PadLeft(5, ' ')).Append(','); + } } else if (_source.Definition.BoolButtons.Contains(button)) { @@ -149,7 +137,9 @@ namespace BizHawk.Client.Common } if (!forInputDisplay) + { sb.Append('|'); + } } } diff --git a/BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs b/BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs index ca791a60a7..87873d04ca 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs @@ -8,9 +8,11 @@ namespace BizHawk.Client.Common { get { - var key = button.Replace("Key ", ""); + var key = button.Replace("Key ", string.Empty); if (key.StartsWith("P") && key.Length > 1 && key[1] >= '0' && key[1] <= '9') + { key = key.Substring(3); + } if (SystemOverrides.ContainsKey(Global.Emulator.SystemId) && SystemOverrides[Global.Emulator.SystemId].ContainsKey(key)) { diff --git a/BizHawk.Client.Common/movie/bk2/Bk2Movie.HeaderApi.cs b/BizHawk.Client.Common/movie/bk2/Bk2Movie.HeaderApi.cs index ddc3e1b5da..a90a7e0f8a 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2Movie.HeaderApi.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2Movie.HeaderApi.cs @@ -8,17 +8,18 @@ namespace BizHawk.Client.Common protected readonly Bk2Header Header = new Bk2Header(); private string _syncSettingsJson = string.Empty; - public IDictionary HeaderEntries - { - get { return Header; } - } + public IDictionary HeaderEntries => Header; - public SubtitleList Subtitles { get; private set; } - public IList Comments { get; private set; } + public SubtitleList Subtitles { get; } + public IList Comments { get; } public string SyncSettingsJson { - get { return _syncSettingsJson; } + get + { + return _syncSettingsJson; + } + set { if (_syncSettingsJson != value) @@ -147,7 +148,11 @@ namespace BizHawk.Client.Common public string Hash { - get { return Header[HeaderKeys.SHA1]; } + get + { + return Header[HeaderKeys.SHA1]; + } + set { if (Header[HeaderKeys.SHA1] != value) @@ -160,7 +165,11 @@ namespace BizHawk.Client.Common public string Author { - get { return Header[HeaderKeys.AUTHOR]; } + get + { + return Header[HeaderKeys.AUTHOR]; + } + set { if (Header[HeaderKeys.AUTHOR] != value) @@ -173,7 +182,11 @@ namespace BizHawk.Client.Common public string Core { - get { return Header[HeaderKeys.CORE]; } + get + { + return Header[HeaderKeys.CORE]; + } + set { if (Header[HeaderKeys.CORE] != value) @@ -186,7 +199,11 @@ namespace BizHawk.Client.Common public string BoardName { - get { return Header[HeaderKeys.BOARDNAME]; } + get + { + return Header[HeaderKeys.BOARDNAME]; + } + set { if (Header[HeaderKeys.BOARDNAME] != value) @@ -199,7 +216,11 @@ namespace BizHawk.Client.Common public string EmulatorVersion { - get { return Header[HeaderKeys.EMULATIONVERSION]; } + get + { + return Header[HeaderKeys.EMULATIONVERSION]; + } + set { if (Header[HeaderKeys.EMULATIONVERSION] != value) @@ -212,7 +233,11 @@ namespace BizHawk.Client.Common public string FirmwareHash { - get { return Header[HeaderKeys.FIRMWARESHA1]; } + get + { + return Header[HeaderKeys.FIRMWARESHA1]; + } + set { if (Header[HeaderKeys.FIRMWARESHA1] != value) @@ -253,7 +278,7 @@ namespace BizHawk.Client.Common { var sb = new StringBuilder(); - foreach(var comment in Comments) + foreach (var comment in Comments) { sb.AppendLine(comment); } diff --git a/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs b/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs index 429174b7b2..f2e0c805fb 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs @@ -21,7 +21,7 @@ namespace BizHawk.Client.Common } var backupName = Filename; - backupName = backupName.Insert(Filename.LastIndexOf("."), string.Format(".{0:yyyy-MM-dd HH.mm.ss}", DateTime.Now)); + backupName = backupName.Insert(Filename.LastIndexOf("."), $".{DateTime.Now:yyyy-MM-dd HH.mm.ss}"); backupName = Path.Combine(Global.Config.PathEntries["Global", "Movie backups"].Path, Path.GetFileName(backupName)); var directory_info = new FileInfo(backupName).Directory; @@ -197,6 +197,7 @@ namespace BizHawk.Client.Common { bs.PutLump(BinaryStateLump.Corestate, (BinaryWriter bw) => bw.Write(BinarySavestate)); } + if (SavestateFramebuffer != null) { bs.PutLump(BinaryStateLump.Framebuffer, @@ -210,7 +211,9 @@ namespace BizHawk.Client.Common } if (!backup) + { Changes = false; + } } protected void ClearBeforeLoad() diff --git a/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs b/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs index 9b58f0f3c6..571c0fa5d0 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs @@ -77,9 +77,10 @@ namespace BizHawk.Client.Common { break; } - // in BK2, this is part of the input log, and not involved with the core state at all - // accordingly, this case (for special neshawk format frame numbers) is irrelevant - // probably + + // in BK2, this is part of the input log, and not involved with the core state at all + // accordingly, this case (for special neshawk format frame numbers) is irrelevant + // probably else if (line.Contains("Frame 0x")) // NES stores frame count in hex, yay { var strs = line.Split('x'); @@ -317,7 +318,7 @@ namespace BizHawk.Client.Common /// If the log key differs from the system's, it will be coverted /// /// a log entry line of text from the input log - /// /// a log entry line of text from the input log + /// a log entry line of text from the input log private string ConvertLogEntryFromFile(string line, string logKey) { var adapter = new Bk2LogEntryGenerator(logKey).MovieControllerAdapter; diff --git a/BizHawk.Client.Common/movie/bk2/Bk2Movie.ModeApi.cs b/BizHawk.Client.Common/movie/bk2/Bk2Movie.ModeApi.cs index 7269adf65f..99a5d9a1a4 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2Movie.ModeApi.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2Movie.ModeApi.cs @@ -7,27 +7,15 @@ namespace BizHawk.Client.Common protected enum Moviemode { Inactive, Play, Record, Finished } protected Moviemode _mode = Moviemode.Inactive; - public bool IsActive - { - get { return _mode != Moviemode.Inactive; } - } + public bool IsActive => _mode != Moviemode.Inactive; - public bool IsPlaying - { - get { return _mode == Moviemode.Play || _mode == Moviemode.Finished; } - } + public bool IsPlaying => _mode == Moviemode.Play || _mode == Moviemode.Finished; - public bool IsRecording - { - get { return _mode == Moviemode.Record; } - } + public bool IsRecording => _mode == Moviemode.Record; - public bool IsFinished - { - get { return _mode == Moviemode.Finished; } - } + public bool IsFinished => _mode == Moviemode.Finished; - public virtual void StartNewRecording() + public virtual void StartNewRecording() { _mode = Moviemode.Record; if (Global.Config.EnableBackupMovies && MakeBackup && _log.Any()) diff --git a/BizHawk.Client.Common/movie/bk2/Bk2Movie.cs b/BizHawk.Client.Common/movie/bk2/Bk2Movie.cs index 65705b81cf..1baa11da3d 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2Movie.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2Movie.cs @@ -46,8 +46,9 @@ namespace BizHawk.Client.Common public string Name { get; private set; } - public virtual string PreferredExtension { get { return Extension; } } - public const string Extension = "bk2"; + public virtual string PreferredExtension => Extension; + + public const string Extension = "bk2"; public virtual bool Changes { get; protected set; } public bool IsCountingRerecords { get; set; } @@ -70,12 +71,9 @@ namespace BizHawk.Client.Common } } - public int InputLogLength - { - get { return _log.Count; } - } + public int InputLogLength => _log.Count; - #region Log Editing + #region Log Editing public void AppendFrame(IController source) { @@ -112,8 +110,6 @@ namespace BizHawk.Client.Common { _log.RemoveRange(frame, _log.Count - frame); Changes = true; - - } } } @@ -122,7 +118,6 @@ namespace BizHawk.Client.Common { if (frame < FrameCount && frame >= 0) { - int getframe; if (LoopOffset.HasValue) diff --git a/BizHawk.Client.Common/movie/bk2/StringLogs.cs b/BizHawk.Client.Common/movie/bk2/StringLogs.cs index 08c3e4b28e..3df10d02c8 100644 --- a/BizHawk.Client.Common/movie/bk2/StringLogs.cs +++ b/BizHawk.Client.Common/movie/bk2/StringLogs.cs @@ -1,210 +1,225 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; - -using BizHawk.Common; - -namespace BizHawk.Client.Common -{ - public static class StringLogUtil - { +using System; +using System.Collections.Generic; +using System.IO; + +using BizHawk.Common; + +namespace BizHawk.Client.Common +{ + public static class StringLogUtil + { public static bool DefaultToDisk; - public static bool DefaultToAWE; - public static IStringLog MakeStringLog() - { - if (DefaultToDisk) - return new StreamStringLog(true); - else if(DefaultToAWE) - return new StreamStringLog(false); - else return new ListStringLog(); - } - } - - public interface IStringLog : IDisposable, IEnumerable - { - void RemoveAt(int index); - int Count { get; } - void Clear(); - void Add(string str); - string this[int index] { get; set; } - void Insert(int index, string val); - void InsertRange(int index, IEnumerable collection); - void AddRange(IEnumerable collection); - void RemoveRange(int index, int count); - IStringLog Clone(); - void CopyTo(string[] array); - void CopyTo(int index, string[] array, int arrayIndex, int count); - } - - class ListStringLog : List, IStringLog - { - public IStringLog Clone() - { - ListStringLog ret = new ListStringLog(); - ret.AddRange(this); - return ret; - } - - public void Dispose() { } - } - - /// - /// A dumb-ish IStringLog with storage on disk with no provision for recovering lost space, except upon Clear() - /// The purpose here is to avoid having too complicated buggy logic or a dependency on sqlite or such. - /// It should be faster than those alternatives, but wasteful of disk space. - /// It should also be easier to add new IList-like methods than dealing with a database - /// - class StreamStringLog : IStringLog - { - List Offsets = new List(); - long cursor = 0; - BinaryWriter bw; + public static bool DefaultToAWE; + public static IStringLog MakeStringLog() + { + if (DefaultToDisk) + { + return new StreamStringLog(true); + } + + if (DefaultToAWE) + { + return new StreamStringLog(false); + } + + return new ListStringLog(); + } + } + + public interface IStringLog : IDisposable, IEnumerable + { + void RemoveAt(int index); + int Count { get; } + void Clear(); + void Add(string str); + string this[int index] { get; set; } + void Insert(int index, string val); + void InsertRange(int index, IEnumerable collection); + void AddRange(IEnumerable collection); + void RemoveRange(int index, int count); + IStringLog Clone(); + void CopyTo(string[] array); + void CopyTo(int index, string[] array, int arrayIndex, int count); + } + + class ListStringLog : List, IStringLog + { + public IStringLog Clone() + { + ListStringLog ret = new ListStringLog(); + ret.AddRange(this); + return ret; + } + + public void Dispose() { } + } + + /// + /// A dumb-ish IStringLog with storage on disk with no provision for recovering lost space, except upon Clear() + /// The purpose here is to avoid having too complicated buggy logic or a dependency on sqlite or such. + /// It should be faster than those alternatives, but wasteful of disk space. + /// It should also be easier to add new IList-like methods than dealing with a database + /// + class StreamStringLog : IStringLog + { + List Offsets = new List(); + long cursor = 0; + BinaryWriter bw; BinaryReader br; - bool mDisk; - - Stream stream; - public StreamStringLog(bool disk) - { - mDisk = disk; - if (disk) - { - var path = TempFileCleaner.GetTempFilename("movieOnDisk"); - stream = new FileStream(path, FileMode.Create, System.Security.AccessControl.FileSystemRights.FullControl, FileShare.None, 4 * 1024, FileOptions.DeleteOnClose); - } - else - { - stream = new AWEMemoryStream(); - } - bw = new BinaryWriter(stream); - br = new BinaryReader(stream); - } - - public IStringLog Clone() + bool mDisk; + + Stream stream; + public StreamStringLog(bool disk) { - StreamStringLog ret = new StreamStringLog(mDisk); //doesnt necessarily make sense to copy the mDisk value, they could be designated for different targets... - for (int i = 0; i < Count; i++) - ret.Add(this[i]); - return ret; - } - - public void Dispose() - { - stream.Dispose(); - } - - public int Count { get { return Offsets.Count; } } - - public void Clear() - { - stream.SetLength(0); - Offsets.Clear(); - cursor = 0; - } - - public void Add(string str) + mDisk = disk; + if (disk) + { + var path = TempFileCleaner.GetTempFilename("movieOnDisk"); + stream = new FileStream(path, FileMode.Create, System.Security.AccessControl.FileSystemRights.FullControl, FileShare.None, 4 * 1024, FileOptions.DeleteOnClose); + } + else + { + stream = new AWEMemoryStream(); + } + + bw = new BinaryWriter(stream); + br = new BinaryReader(stream); + } + + public IStringLog Clone() { - stream.Position = stream.Length; - Offsets.Add(stream.Position); - bw.Write(str); - bw.Flush(); - } - - public void RemoveAt(int index) - { - Offsets.RemoveAt(index); - //no garbage collection in the disk file... oh well. - } - - public string this[int index] - { - get - { - stream.Position = Offsets[index]; - return br.ReadString(); - } - set - { - stream.Position = stream.Length; - Offsets[index] = stream.Position; - bw.Write(value); - bw.Flush(); - } - } - - public void Insert(int index, string val) + StreamStringLog ret = new StreamStringLog(mDisk); // doesnt necessarily make sense to copy the mDisk value, they could be designated for different targets... + for (int i = 0; i < Count; i++) + { + ret.Add(this[i]); + } + + return ret; + } + + public void Dispose() { - stream.Position = stream.Length; - Offsets.Insert(index, stream.Position); - bw.Write(val); - bw.Flush(); - } - - public void InsertRange(int index, IEnumerable collection) - { - foreach(var item in collection) - Insert(index++,item); - } - - public void AddRange(IEnumerable collection) - { - foreach (var item in collection) - Add(item); - } - - class Enumerator : IEnumerator - { - public StreamStringLog log; - int index = -1; - public string Current { get { return log[index]; } } - object System.Collections.IEnumerator.Current { get { return log[index]; } } - bool System.Collections.IEnumerator.MoveNext() - { - index++; - if (index >= log.Count) - { - index = log.Count; - return false; - } - return true; - } - void System.Collections.IEnumerator.Reset() { index = -1; } - - public void Dispose() { } - } - - IEnumerator IEnumerable.GetEnumerator() - { - return new Enumerator() { log = this }; - } - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return new Enumerator() { log = this }; - } - - public void RemoveRange(int index, int count) - { - int end = index + count - 1; - for (int i = 0; i < count; i++) - { - RemoveAt(end); - end--; - } - } - - public void CopyTo(string[] array) - { - for (int i = 0; i < Count; i++) - array[i] = this[i]; - } - - public void CopyTo(int index, string[] array, int arrayIndex, int count) - { - for (int i = 0; i < count; i++) - array[i + arrayIndex] = this[index + i]; - } - } -} + stream.Dispose(); + } + + public int Count => Offsets.Count; + + public void Clear() + { + stream.SetLength(0); + Offsets.Clear(); + cursor = 0; + } + + public void Add(string str) + { + stream.Position = stream.Length; + Offsets.Add(stream.Position); + bw.Write(str); + bw.Flush(); + } + + public void RemoveAt(int index) + { + // no garbage collection in the disk file... oh well. + Offsets.RemoveAt(index); + } + + public string this[int index] + { + get + { + stream.Position = Offsets[index]; + return br.ReadString(); + } + set + { + stream.Position = stream.Length; + Offsets[index] = stream.Position; + bw.Write(value); + bw.Flush(); + } + } + + public void Insert(int index, string val) + { + stream.Position = stream.Length; + Offsets.Insert(index, stream.Position); + bw.Write(val); + bw.Flush(); + } + + public void InsertRange(int index, IEnumerable collection) + { + foreach (var item in collection) + { + Insert(index++,item); + } + } + + public void AddRange(IEnumerable collection) + { + foreach (var item in collection) + { + Add(item); + } + } + + class Enumerator : IEnumerator + { + public StreamStringLog log; + int index = -1; + public string Current { get { return log[index]; } } + object System.Collections.IEnumerator.Current { get { return log[index]; } } + bool System.Collections.IEnumerator.MoveNext() + { + index++; + if (index >= log.Count) + { + index = log.Count; + return false; + } + return true; + } + void System.Collections.IEnumerator.Reset() { index = -1; } + + public void Dispose() { } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return new Enumerator { log = this }; + } + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return new Enumerator { log = this }; + } + + public void RemoveRange(int index, int count) + { + int end = index + count - 1; + for (int i = 0; i < count; i++) + { + RemoveAt(end); + end--; + } + } + + public void CopyTo(string[] array) + { + for (int i = 0; i < Count; i++) + { + array[i] = this[i]; + } + } + + public void CopyTo(int index, string[] array, int arrayIndex, int count) + { + for (int i = 0; i < count; i++) + { + array[i + arrayIndex] = this[index + i]; + } + } + } +} diff --git a/BizHawk.Client.Common/movie/bkm/BkmControllerAdapter.cs b/BizHawk.Client.Common/movie/bkm/BkmControllerAdapter.cs index 38527cb516..b878d283b9 100644 --- a/BizHawk.Client.Common/movie/bkm/BkmControllerAdapter.cs +++ b/BizHawk.Client.Common/movie/bkm/BkmControllerAdapter.cs @@ -236,7 +236,7 @@ namespace BizHawk.Client.Common { return; } - string prefix = ""; + string prefix = string.Empty; if (ControlType != "Gameboy Controller" && ControlType != "TI83 Controller") { prefix = "P" + player + " "; @@ -277,9 +277,9 @@ namespace BizHawk.Client.Common MyFloatControls[name] = state; } - private string ControlType { get { return Definition.Name; } } + private string ControlType => Definition.Name; - private void SetGBAControllersAsMnemonic(string mnemonic) + private void SetGBAControllersAsMnemonic(string mnemonic) { MnemonicChecker c = new MnemonicChecker(mnemonic); MyBoolButtons.Clear(); diff --git a/BizHawk.Client.Common/movie/bkm/BkmHeader.cs b/BizHawk.Client.Common/movie/bkm/BkmHeader.cs index 3b94bed257..2dd4f85957 100644 --- a/BizHawk.Client.Common/movie/bkm/BkmHeader.cs +++ b/BizHawk.Client.Common/movie/bkm/BkmHeader.cs @@ -17,8 +17,8 @@ namespace BizHawk.Client.Common this[HeaderKeys.RERECORDS] = "0"; } - public List Comments { get; private set; } - public SubtitleList Subtitles { get; private set; } + public List Comments { get; } + public SubtitleList Subtitles { get; } public string SavestateBinaryBase64Blob { diff --git a/BizHawk.Client.Common/movie/bkm/BkmLogEntryGenerator.cs b/BizHawk.Client.Common/movie/bkm/BkmLogEntryGenerator.cs index b2f7d9760c..ff1a8a187d 100644 --- a/BizHawk.Client.Common/movie/bkm/BkmLogEntryGenerator.cs +++ b/BizHawk.Client.Common/movie/bkm/BkmLogEntryGenerator.cs @@ -163,7 +163,7 @@ namespace BizHawk.Client.Common for (int player = 1; player <= BkmMnemonicConstants.PLAYERS[_controlType]; player++) { - var prefix = String.Empty; + var prefix = string.Empty; if (_controlType != "Gameboy Controller" && _controlType != "TI83 Controller") { prefix = "P" + player + " "; @@ -199,19 +199,13 @@ namespace BizHawk.Client.Common { return GenerateLogEntry() .Replace(".", " ") - .Replace("|", "") + .Replace("|", string.Empty) .Replace(" 000, 000", " "); } - public bool IsEmpty - { - get - { - return EmptyEntry == GenerateLogEntry(); - } - } + public bool IsEmpty => EmptyEntry == GenerateLogEntry(); - public string EmptyEntry + public string EmptyEntry { get { @@ -260,15 +254,9 @@ namespace BizHawk.Client.Common } } - public IMovieController MovieControllerAdapter - { - get - { - return new BkmControllerAdapter(); - } - } + public IMovieController MovieControllerAdapter => new BkmControllerAdapter(); - #region Privates + #region Privates private bool IsBasePressed(string name) { @@ -511,7 +499,7 @@ namespace BizHawk.Client.Common input.Append(' '); } - input.Append(String.Format("{0:000}", val)).Append(','); + input.Append($"{val:000}").Append(','); } input.Remove(input.Length - 1, 1); diff --git a/BizHawk.Client.Common/movie/bkm/BkmMnemonicConstants.cs b/BizHawk.Client.Common/movie/bkm/BkmMnemonicConstants.cs index 44a1e2b84e..f158e27455 100644 --- a/BizHawk.Client.Common/movie/bkm/BkmMnemonicConstants.cs +++ b/BizHawk.Client.Common/movie/bkm/BkmMnemonicConstants.cs @@ -10,7 +10,7 @@ namespace BizHawk.Client.Common { "Gameboy Controller", new Dictionary { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Select", "s"}, {"Start", "S"}, {"B", "B"}, {"A", "A"} + { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" }, { "A", "A" } } }, { diff --git a/BizHawk.Client.Common/movie/bkm/BkmMovie.HeaderApi.cs b/BizHawk.Client.Common/movie/bkm/BkmMovie.HeaderApi.cs index 79027e5a65..c700e38895 100644 --- a/BizHawk.Client.Common/movie/bkm/BkmMovie.HeaderApi.cs +++ b/BizHawk.Client.Common/movie/bkm/BkmMovie.HeaderApi.cs @@ -4,25 +4,13 @@ namespace BizHawk.Client.Common { public partial class BkmMovie { - public IDictionary HeaderEntries - { - get - { - return Header; - } - } - - public SubtitleList Subtitles - { - get { return Header.Subtitles; } - } + public IDictionary HeaderEntries => Header; - public IList Comments - { - get { return Header.Comments; } - } + public SubtitleList Subtitles => Header.Subtitles; - public string SyncSettingsJson + public IList Comments => Header.Comments; + + public string SyncSettingsJson { get { return Header[HeaderKeys.SYNCSETTINGS]; } set { Header[HeaderKeys.SYNCSETTINGS] = value; } @@ -41,7 +29,10 @@ namespace BizHawk.Client.Common } // Bkm doesn't support saveram anchored movies - public bool StartsFromSaveRam { get { return false; } set { } } + public bool StartsFromSaveRam + { + get { return false; } set { } + } public string GameName { diff --git a/BizHawk.Client.Common/movie/bkm/BkmMovie.IO.cs b/BizHawk.Client.Common/movie/bkm/BkmMovie.IO.cs index f104de55de..230a41261a 100644 --- a/BizHawk.Client.Common/movie/bkm/BkmMovie.IO.cs +++ b/BizHawk.Client.Common/movie/bkm/BkmMovie.IO.cs @@ -46,7 +46,7 @@ namespace BizHawk.Client.Common } var backupName = Filename; - backupName = backupName.Insert(Filename.LastIndexOf("."), string.Format(".{0:yyyy-MM-dd HH.mm.ss}", DateTime.Now)); + backupName = backupName.Insert(Filename.LastIndexOf("."), $".{DateTime.Now:yyyy-MM-dd HH.mm.ss}"); backupName = Path.Combine(Global.Config.PathEntries["Global", "Movie backups"].Path, Path.GetFileName(backupName)); var directory_info = new FileInfo(backupName).Directory; @@ -107,8 +107,11 @@ namespace BizHawk.Client.Common } } } + if (Header.SavestateBinaryBase64Blob != null) + { BinarySavestate = Convert.FromBase64String(Header.SavestateBinaryBase64Blob); + } Loaded = true; _changes = false; @@ -138,9 +141,9 @@ namespace BizHawk.Client.Common // No using block because we're sharing the stream and need to give it back undisposed. var sr = new StreamReader(hawkFile.GetStream()); - for (; ; ) + for (;;) { - //read to first space (key/value delimeter), or pipe, or EOF + // read to first space (key/value delimeter), or pipe, or EOF int first = sr.Read(); if (first == -1) @@ -148,16 +151,16 @@ namespace BizHawk.Client.Common break; } // EOF - if (first == '|') //pipe: begin input log + if (first == '|') // pipe: begin input log { - //NOTE - this code is a bit convoluted due to its predating the basic outline of the parser which was upgraded in may 2014 + // NOTE - this code is a bit convoluted due to its predating the basic outline of the parser which was upgraded in may 2014 var line = '|' + sr.ReadLine(); - //how many bytes are left, total? + // how many bytes are left, total? long remain = sr.BaseStream.Length - sr.BaseStream.Position; - //try to find out whether we use \r\n or \n - //but only look for 1K characters. + // try to find out whether we use \r\n or \n + // but only look for 1K characters. bool usesR = false; for (int i = 0; i < 1024; i++) { @@ -173,19 +176,22 @@ namespace BizHawk.Client.Common break; } - int lineLen = line.Length + 1; //account for \n - if (usesR) lineLen++; //account for \r + int lineLen = line.Length + 1; // account for \n + if (usesR) + { + lineLen++; // account for \r + } - _preloadFramecount = (int)(remain / lineLen); //length is remaining bytes / length per line - _preloadFramecount++; //account for the current line + _preloadFramecount = (int)(remain / lineLen); // length is remaining bytes / length per line + _preloadFramecount++; // account for the current line break; } else { - //a header line. finish reading key token, to make sure it isn't one of the FORBIDDEN keys + // a header line. finish reading key token, to make sure it isn't one of the FORBIDDEN keys var sbLine = new StringBuilder(); sbLine.Append((char)first); - for (; ; ) + for (;;) { int c = sr.Read(); if (c == -1) break; @@ -196,21 +202,22 @@ namespace BizHawk.Client.Common var line = sbLine.ToString(); - //ignore these suckers, theyre way too big for preloading. seriously, we will get out of memory errors. + // ignore these suckers, theyre way too big for preloading. seriously, we will get out of memory errors. var skip = line == HeaderKeys.SAVESTATEBINARYBASE64BLOB; if (skip) { - //skip remainder of the line + // skip remainder of the line sr.DiscardBufferedData(); var stream = sr.BaseStream; - for (; ; ) + for (;;) { int c = stream.ReadByte(); if (c == -1) break; if (c == '\n') break; } - //proceed to next line + + // proceed to next line continue; } @@ -236,10 +243,9 @@ namespace BizHawk.Client.Common private void Write(string fn) { - if (BinarySavestate != null) - Header.SavestateBinaryBase64Blob = Convert.ToBase64String(BinarySavestate); - else - Header.SavestateBinaryBase64Blob = null; + Header.SavestateBinaryBase64Blob = BinarySavestate != null + ? Convert.ToBase64String(BinarySavestate) + : null; using (var fs = new FileStream(fn, FileMode.Create, FileAccess.Write, FileShare.Read)) { diff --git a/BizHawk.Client.Common/movie/bkm/BkmMovie.ModeApi.cs b/BizHawk.Client.Common/movie/bkm/BkmMovie.ModeApi.cs index 27c562eb99..bd5df0b42e 100644 --- a/BizHawk.Client.Common/movie/bkm/BkmMovie.ModeApi.cs +++ b/BizHawk.Client.Common/movie/bkm/BkmMovie.ModeApi.cs @@ -8,27 +8,15 @@ namespace BizHawk.Client.Common private Moviemode _mode = Moviemode.Inactive; - public bool IsPlaying - { - get { return _mode == Moviemode.Play || _mode == Moviemode.Finished; } - } + public bool IsPlaying => _mode == Moviemode.Play || _mode == Moviemode.Finished; - public bool IsRecording - { - get { return _mode == Moviemode.Record; } - } + public bool IsRecording => _mode == Moviemode.Record; - public bool IsActive - { - get { return _mode != Moviemode.Inactive; } - } + public bool IsActive => _mode != Moviemode.Inactive; - public bool IsFinished - { - get { return _mode == Moviemode.Finished; } - } + public bool IsFinished => _mode == Moviemode.Finished; - public void StartNewRecording() + public void StartNewRecording() { _mode = Moviemode.Record; if (Global.Config.EnableBackupMovies && _makeBackup && _log.Any()) diff --git a/BizHawk.Client.Common/movie/bkm/BkmMovie.cs b/BizHawk.Client.Common/movie/bkm/BkmMovie.cs index 25fbe38c4a..6478acb5e9 100644 --- a/BizHawk.Client.Common/movie/bkm/BkmMovie.cs +++ b/BizHawk.Client.Common/movie/bkm/BkmMovie.cs @@ -18,8 +18,7 @@ namespace BizHawk.Client.Common public BkmMovie() { - Header = new BkmHeader(); - Header[HeaderKeys.MOVIEVERSION] = "BizHawk v0.0.1"; + Header = new BkmHeader { [HeaderKeys.MOVIEVERSION] = "BizHawk v0.0.1" }; Filename = string.Empty; _preloadFramecount = 0; @@ -35,20 +34,18 @@ namespace BizHawk.Client.Common return new BkmLogEntryGenerator(); } - public string PreferredExtension { get { return Extension; } } - public const string Extension = "bkm"; + public string PreferredExtension => Extension; - public BkmHeader Header { get; private set; } + public const string Extension = "bkm"; + + public BkmHeader Header { get; } public string Filename { get; set; } public bool IsCountingRerecords { get; set; } public bool Loaded { get; private set; } - public int InputLogLength - { - get { return _log.Count; } - } + public int InputLogLength => _log.Count; - public double FrameCount + public double FrameCount { get { @@ -66,10 +63,7 @@ namespace BizHawk.Client.Common } } - public bool Changes - { - get { return _changes; } - } + public bool Changes => _changes; #endregion @@ -79,7 +73,6 @@ namespace BizHawk.Client.Common { if (frame < FrameCount && frame >= 0) { - int getframe; if (_loopOffset.HasValue) diff --git a/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs b/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs index b10a6ab1e7..c671b41f0f 100644 --- a/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs +++ b/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs @@ -115,7 +115,9 @@ namespace BizHawk.Client.Common.MovieConversionExtensions bk2.SaveRam = old.SaveRam; if (!backup) + { bk2.Save(); + } return bk2; } @@ -142,7 +144,7 @@ namespace BizHawk.Client.Common.MovieConversionExtensions } } - TasMovie tas = new TasMovie(newFilename, true); + var tas = new TasMovie(newFilename, true); tas.BinarySavestate = savestate; tas.ClearLagLog(); @@ -185,7 +187,9 @@ namespace BizHawk.Client.Common.MovieConversionExtensions foreach (TasMovieMarker marker in old.Markers) { if (marker.Frame > frame) + { tas.Markers.Add(new TasMovieMarker(marker.Frame - frame, marker.Message)); + } } tas.TasStateManager.Settings = old.TasStateManager.Settings; @@ -216,7 +220,7 @@ namespace BizHawk.Client.Common.MovieConversionExtensions } } - TasMovie tas = new TasMovie(newFilename, true); + var tas = new TasMovie(newFilename, true); tas.SaveRam = saveRam; tas.TasStateManager.Clear(); tas.ClearLagLog(); diff --git a/BizHawk.Client.Common/tools/Interfaces/IToolForm.cs b/BizHawk.Client.Common/tools/Interfaces/IToolForm.cs index 67c1e25ebc..5dd0807d63 100644 --- a/BizHawk.Client.Common/tools/Interfaces/IToolForm.cs +++ b/BizHawk.Client.Common/tools/Interfaces/IToolForm.cs @@ -2,10 +2,10 @@ { public enum ToolFormUpdateType { - //reserved + // reserved Legacy, LegacyFast, - //reserved concept: we can run other events through here (should probably rename then) + // reserved concept: we can run other events through here (should probably rename then) Reset, /// @@ -60,7 +60,7 @@ /// bool UpdateBefore { get; } - //Necessary winform calls + // Necessary winform calls bool Focus(); bool ContainsFocus { get; } void Show(); @@ -69,4 +69,3 @@ bool IsHandleCreated { get; } } } - diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings index 349bc31605..80238f2d02 100644 --- a/BizHawk.sln.DotSettings +++ b/BizHawk.sln.DotSettings @@ -16,9 +16,27 @@ DO_NOT_SHOW DO_NOT_SHOW DO_NOT_SHOW + AF ARGB + BMP CDL CGB DB - IO + GB + GBA + GBC + GG + II + IO + IPS + NES + OR + PC + PCECD + PSP + PSX + SG + SGX + SNES + TI \ No newline at end of file