Client.Common cleanups - mostly using higher language features
This commit is contained in:
parent
6bcbe11eae
commit
5386b8b18c
|
@ -1,6 +1,4 @@
|
||||||
using System;
|
using BizHawk.Emulation.Common;
|
||||||
|
|
||||||
using BizHawk.Emulation.Common;
|
|
||||||
|
|
||||||
namespace BizHawk.Client.Common
|
namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
|
|
|
@ -242,8 +242,7 @@ namespace BizHawk.Client.Common
|
||||||
/// <exception cref="Exception">stream not found and <paramref name="abort"/> is <see langword="true"/></exception>
|
/// <exception cref="Exception">stream not found and <paramref name="abort"/> is <see langword="true"/></exception>
|
||||||
public bool GetLump(BinaryStateLump lump, bool abort, Action<Stream, long> callback)
|
public bool GetLump(BinaryStateLump lump, bool abort, Action<Stream, long> callback)
|
||||||
{
|
{
|
||||||
ZipEntry e;
|
if (_entriesByName.TryGetValue(lump.ReadName, out var e))
|
||||||
if (_entriesByName.TryGetValue(lump.ReadName, out e))
|
|
||||||
{
|
{
|
||||||
using (var zs = _zip.GetInputStream(e))
|
using (var zs = _zip.GetInputStream(e))
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,14 +53,13 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
public ResolutionInfo Resolve(FirmwareDatabase.FirmwareRecord record, bool forbidScan = false)
|
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 don't want to repeatedly DoScanAndResolve in that case, its already been done.
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
RETRY:
|
RETRY:
|
||||||
ResolutionInfo resolved;
|
_resolutionDictionary.TryGetValue(record, out var resolved);
|
||||||
_resolutionDictionary.TryGetValue(record, out resolved);
|
|
||||||
|
|
||||||
// couldnt find it! do a scan and resolve to try harder
|
// couldn't find it! do a scan and resolve to try harder
|
||||||
// NOTE: this could result in bad performance in some cases if the scanning happens repeatedly..
|
// NOTE: this could result in bad performance in some cases if the scanning happens repeatedly..
|
||||||
if (resolved == null && first)
|
if (resolved == null && first)
|
||||||
{
|
{
|
||||||
|
@ -76,7 +75,7 @@ namespace BizHawk.Client.Common
|
||||||
return resolved;
|
return resolved;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Requests the spcified firmware. tries really hard to scan and resolve as necessary
|
// Requests the specified firmware. tries really hard to scan and resolve as necessary
|
||||||
public string Request(string sysId, string firmwareId)
|
public string Request(string sysId, string firmwareId)
|
||||||
{
|
{
|
||||||
var resolved = Resolve(sysId, firmwareId);
|
var resolved = Resolve(sysId, firmwareId);
|
||||||
|
@ -138,17 +137,15 @@ namespace BizHawk.Client.Common
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// weed out filesizes first to reduce the unnecessary overhead of a hashing operation
|
// weed out filesizes first to reduce the unnecessary overhead of a hashing operation
|
||||||
if (FirmwareDatabase.FirmwareFiles.Where(a => a.Size == fi.Length).FirstOrDefault() == null)
|
if (FirmwareDatabase.FirmwareFiles.FirstOrDefault(a => a.Size == fi.Length) == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// check the hash
|
// check the hash
|
||||||
using (var reader = new RealFirmwareReader())
|
using var reader = new RealFirmwareReader();
|
||||||
{
|
|
||||||
reader.Read(fi);
|
reader.Read(fi);
|
||||||
if (FirmwareDatabase.FirmwareFiles.Where(a => a.Hash == reader.Dict.FirstOrDefault().Value.Hash).FirstOrDefault() != null)
|
if (FirmwareDatabase.FirmwareFiles.FirstOrDefault(a => a.Hash == reader.Dict.FirstOrDefault().Value.Hash) != null)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -157,14 +154,13 @@ namespace BizHawk.Client.Common
|
||||||
public void DoScanAndResolve()
|
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<long> sizes = new HashSet<long>();
|
var sizes = new HashSet<long>();
|
||||||
foreach (var ff in FirmwareDatabase.FirmwareFiles)
|
foreach (var ff in FirmwareDatabase.FirmwareFiles)
|
||||||
{
|
{
|
||||||
sizes.Add(ff.Size);
|
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
|
// 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<DirectoryInfo>();
|
var todo = new Queue<DirectoryInfo>();
|
||||||
todo.Enqueue(new DirectoryInfo(PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPathFragment, null)));
|
todo.Enqueue(new DirectoryInfo(PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPathFragment, null)));
|
||||||
|
@ -233,14 +229,11 @@ namespace BizHawk.Client.Common
|
||||||
// apply user overrides
|
// apply user overrides
|
||||||
foreach (var fr in FirmwareDatabase.FirmwareRecords)
|
foreach (var fr in FirmwareDatabase.FirmwareRecords)
|
||||||
{
|
{
|
||||||
string userSpec;
|
|
||||||
|
|
||||||
// do we have a user specification for this firmware record?
|
// do we have a user specification for this firmware record?
|
||||||
if (Global.Config.FirmwareUserSpecifications.TryGetValue(fr.ConfigKey, out userSpec))
|
if (Global.Config.FirmwareUserSpecifications.TryGetValue(fr.ConfigKey, out var userSpec))
|
||||||
{
|
{
|
||||||
// flag it as user specified
|
// flag it as user specified
|
||||||
ResolutionInfo ri;
|
if (!_resolutionDictionary.TryGetValue(fr, out ResolutionInfo ri))
|
||||||
if (!_resolutionDictionary.TryGetValue(fr, out ri))
|
|
||||||
{
|
{
|
||||||
ri = new ResolutionInfo();
|
ri = new ResolutionInfo();
|
||||||
_resolutionDictionary[fr] = ri;
|
_resolutionDictionary[fr] = ri;
|
||||||
|
@ -265,8 +258,7 @@ namespace BizHawk.Client.Common
|
||||||
ri.Hash = rff.Hash;
|
ri.Hash = rff.Hash;
|
||||||
|
|
||||||
// check whether it was a known file anyway, and go ahead and bind to the known file, as a perk (the firmwares config doesnt really use this information right now)
|
// check whether it was a known file anyway, and go ahead and bind to the known file, as a perk (the firmwares config doesnt really use this information right now)
|
||||||
FirmwareDatabase.FirmwareFile ff;
|
if (FirmwareDatabase.FirmwareFilesByHash.TryGetValue(rff.Hash, out var ff))
|
||||||
if (FirmwareDatabase.FirmwareFilesByHash.TryGetValue(rff.Hash, out ff))
|
|
||||||
{
|
{
|
||||||
ri.KnownFirmwareFile = ff;
|
ri.KnownFirmwareFile = ff;
|
||||||
|
|
||||||
|
@ -283,7 +275,6 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // foreach(firmware record)
|
} // foreach(firmware record)
|
||||||
} // using(new RealFirmwareReader())
|
|
||||||
} // DoScanAndResolve()
|
} // DoScanAndResolve()
|
||||||
} // class FirmwareManager
|
} // class FirmwareManager
|
||||||
} // namespace
|
} // namespace
|
|
@ -2,9 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace BizHawk.Client.Common
|
namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,9 +46,8 @@ namespace BizHawk.Client.Common
|
||||||
// maps to|1|6|7|8|H|2|3|4|-|I|J|K|L|A|B|C|D|M|N|O|5|E|F|G|
|
// maps to|1|6|7|8|H|2|3|4|-|I|J|K|L|A|B|C|D|M|N|O|5|E|F|G|
|
||||||
Value = 0;
|
Value = 0;
|
||||||
Address = 0x8000;
|
Address = 0x8000;
|
||||||
int x;
|
|
||||||
|
|
||||||
_gameGenieTable.TryGetValue(_code[0], out x);
|
_gameGenieTable.TryGetValue(_code[0], out var x);
|
||||||
Value |= x & 0x07;
|
Value |= x & 0x07;
|
||||||
Value |= (x & 0x08) << 4;
|
Value |= (x & 0x08) << 4;
|
||||||
|
|
||||||
|
@ -79,9 +78,8 @@ namespace BizHawk.Client.Common
|
||||||
Value = 0;
|
Value = 0;
|
||||||
Address = 0x8000;
|
Address = 0x8000;
|
||||||
Compare = 0;
|
Compare = 0;
|
||||||
int x;
|
|
||||||
|
|
||||||
_gameGenieTable.TryGetValue(_code[0], out x);
|
_gameGenieTable.TryGetValue(_code[0], out var x);
|
||||||
Value |= x & 0x07;
|
Value |= x & 0x07;
|
||||||
Value |= (x & 0x08) << 4;
|
Value |= (x & 0x08) << 4;
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Text;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
using BizHawk.Emulation.Cores;
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
//this file contains some cumbersome self-"serialization" in order to gain a modicum of control over what the serialized output looks like
|
//this file contains some cumbersome self-"serialization" in order to gain a modicum of control over what the serialized output looks like
|
||||||
|
@ -47,7 +42,7 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
if (text.StartsWith("*"))
|
if (text.StartsWith("*"))
|
||||||
return Deserialize(text.Substring(1));
|
return Deserialize(text.Substring(1));
|
||||||
else return new OpenAdvanced_OpenRom { Path = text };
|
return new OpenAdvanced_OpenRom { Path = text };
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IOpenAdvanced Deserialize(string text)
|
private static IOpenAdvanced Deserialize(string text)
|
||||||
|
@ -106,11 +101,11 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
public string Path, CorePath;
|
public string Path, CorePath;
|
||||||
}
|
}
|
||||||
public Token token = new Token();
|
public Token token;
|
||||||
|
|
||||||
public string TypeName { get { return "Libretro"; } }
|
public string TypeName => "Libretro";
|
||||||
public string DisplayName { get { return $"{Path.GetFileNameWithoutExtension(token.CorePath)}: {token.Path}"; } }
|
public string DisplayName => $"{Path.GetFileNameWithoutExtension(token.CorePath)}: {token.Path}";
|
||||||
public string SimplePath { get { return token.Path; } }
|
public string SimplePath => token.Path;
|
||||||
|
|
||||||
public void Deserialize(string str)
|
public void Deserialize(string str)
|
||||||
{
|
{
|
||||||
|
@ -132,26 +127,25 @@ namespace BizHawk.Client.Common
|
||||||
public class OpenAdvanced_LibretroNoGame : IOpenAdvanced, IOpenAdvancedLibretro
|
public class OpenAdvanced_LibretroNoGame : IOpenAdvanced, IOpenAdvancedLibretro
|
||||||
{
|
{
|
||||||
// you might think ideally we'd fetch the libretro core name from the core info inside it
|
// you might think ideally we'd fetch the libretro core name from the core info inside it
|
||||||
//but that would involve spinning up excess libretro core instances, which probably isnt good for stability, no matter how much we wish otherwise, not to mention slow.
|
// but that would involve spinning up excess libretro core instances, which probably isn't good for stability, no matter how much we wish otherwise, not to mention slow.
|
||||||
// moreover it's kind of complicated here,
|
// moreover it's kind of complicated here,
|
||||||
//and finally, I think the Displayname should really be file-based in all cases, since the user is going to be loading cores by filename and
|
// and finally, I think the DisplayName should really be file-based in all cases, since the user is going to be loading cores by filename and
|
||||||
// this is related to the recent roms filename management.
|
// this is related to the recent roms filename management.
|
||||||
// so, leave it.
|
// so, leave it.
|
||||||
|
|
||||||
public OpenAdvanced_LibretroNoGame()
|
public OpenAdvanced_LibretroNoGame()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public OpenAdvanced_LibretroNoGame(string corepath)
|
public OpenAdvanced_LibretroNoGame(string corePath)
|
||||||
{
|
{
|
||||||
_corePath = corepath;
|
_corePath = corePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
string _corePath;
|
string _corePath;
|
||||||
|
|
||||||
public string TypeName { get { return "LibretroNoGame"; } }
|
public string TypeName => "LibretroNoGame";
|
||||||
public string DisplayName { get { return Path.GetFileName(_corePath); } } //assume we like the filename of the core
|
public string DisplayName => Path.GetFileName(_corePath); // assume we like the filename of the core
|
||||||
public string SimplePath { get { return ""; } } //effectively a signal to not use a game
|
public string SimplePath => ""; // effectively a signal to not use a game
|
||||||
|
|
||||||
public void Deserialize(string str)
|
public void Deserialize(string str)
|
||||||
{
|
{
|
||||||
|
@ -177,9 +171,9 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
public string Path;
|
public string Path;
|
||||||
|
|
||||||
public string TypeName { get { return "OpenRom"; } }
|
public string TypeName => "OpenRom";
|
||||||
public string DisplayName { get { return Path; } }
|
public string DisplayName => Path;
|
||||||
public string SimplePath { get { return Path; } }
|
public string SimplePath => Path;
|
||||||
|
|
||||||
public void Deserialize(string str)
|
public void Deserialize(string str)
|
||||||
{
|
{
|
||||||
|
@ -199,9 +193,9 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
public string Path;
|
public string Path;
|
||||||
|
|
||||||
public string TypeName { get { return "MAME"; } }
|
public string TypeName => "MAME";
|
||||||
public string DisplayName { get { return $"{TypeName}: {Path}"; } }
|
public string DisplayName => $"{TypeName}: {Path}";
|
||||||
public string SimplePath { get { return Path; } }
|
public string SimplePath => Path;
|
||||||
|
|
||||||
public void Deserialize(string str)
|
public void Deserialize(string str)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,10 +16,6 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
private const int BankSize = 1024;
|
private const int BankSize = 1024;
|
||||||
|
|
||||||
public RomGame()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public RomGame(HawkFile file)
|
public RomGame(HawkFile file)
|
||||||
: this(file, null)
|
: this(file, null)
|
||||||
{
|
{
|
||||||
|
@ -39,7 +35,7 @@ namespace BizHawk.Client.Common
|
||||||
int fileLength = (int)stream.Length;
|
int fileLength = (int)stream.Length;
|
||||||
|
|
||||||
// read the entire contents of the file into memory.
|
// read the entire contents of the file into memory.
|
||||||
// unfortunate in the case of large files, but thats what we've got to work with for now.
|
// unfortunate in the case of large files, but that's what we've got to work with for now.
|
||||||
|
|
||||||
// if we're offset exactly 512 bytes from a 1024-byte boundary,
|
// if we're offset exactly 512 bytes from a 1024-byte boundary,
|
||||||
// assume we have a header of that size. Otherwise, assume it's just all rom.
|
// assume we have a header of that size. Otherwise, assume it's just all rom.
|
||||||
|
@ -70,14 +66,14 @@ namespace BizHawk.Client.Common
|
||||||
else if (file.Extension == ".DSK" || file.Extension == ".TAP" || file.Extension == ".TZX" ||
|
else if (file.Extension == ".DSK" || file.Extension == ".TAP" || file.Extension == ".TZX" ||
|
||||||
file.Extension == ".PZX" || file.Extension == ".CSW" || file.Extension == ".WAV" || file.Extension == ".CDT")
|
file.Extension == ".PZX" || file.Extension == ".CSW" || file.Extension == ".WAV" || file.Extension == ".CDT")
|
||||||
{
|
{
|
||||||
// these are not roms. unforunately if treated as such there are certain edge-cases
|
// these are not roms. unfortunately if treated as such there are certain edge-cases
|
||||||
// where a header offset is detected. This should mitigate this issue until a cleaner solution is found
|
// where a header offset is detected. This should mitigate this issue until a cleaner solution is found
|
||||||
// (-Asnivor)
|
// (-Asnivor)
|
||||||
RomData = FileData;
|
RomData = FileData;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// if there was a header offset, read the whole file into FileData and then copy it into RomData (this is unfortunate, in case RomData isnt needed)
|
// if there was a header offset, read the whole file into FileData and then copy it into RomData (this is unfortunate, in case RomData isn't needed)
|
||||||
int romLength = fileLength - headerOffset;
|
int romLength = fileLength - headerOffset;
|
||||||
RomData = new byte[romLength];
|
RomData = new byte[romLength];
|
||||||
Buffer.BlockCopy(FileData, headerOffset, RomData, 0, romLength);
|
Buffer.BlockCopy(FileData, headerOffset, RomData, 0, romLength);
|
||||||
|
@ -107,8 +103,7 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
if (patch != null)
|
if (patch != null)
|
||||||
{
|
{
|
||||||
using (var patchFile = new HawkFile(patch))
|
using var patchFile = new HawkFile(patch);
|
||||||
{
|
|
||||||
patchFile.BindFirstOf("IPS");
|
patchFile.BindFirstOf("IPS");
|
||||||
if (patchFile.IsBound)
|
if (patchFile.IsBound)
|
||||||
{
|
{
|
||||||
|
@ -116,7 +111,6 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static byte[] DeInterleaveSMD(byte[] source)
|
private static byte[] DeInterleaveSMD(byte[] source)
|
||||||
{
|
{
|
||||||
|
|
|
@ -259,8 +259,7 @@ namespace BizHawk.Client.Common
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var file = new HawkFile())
|
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))
|
if (!string.IsNullOrEmpty(path))
|
||||||
{
|
{
|
||||||
|
@ -1220,4 +1219,3 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -37,13 +37,13 @@ namespace BizHawk.Client.Common
|
||||||
offset = 0;
|
offset = 0;
|
||||||
isExecutable = false;
|
isExecutable = false;
|
||||||
|
|
||||||
var pathExt = Path.GetExtension(fileName).ToLower();
|
var pathExt = Path.GetExtension(fileName)?.ToLower();
|
||||||
if (!ArchiveExtensions.Contains(pathExt))
|
if (!ArchiveExtensions.Contains(pathExt))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var arcTest = ArchiveFactory.Open(fileName))
|
using var arcTest = ArchiveFactory.Open(fileName);
|
||||||
switch (arcTest.Type)
|
switch (arcTest.Type)
|
||||||
{
|
{
|
||||||
case ArchiveType.Zip:
|
case ArchiveType.Zip:
|
||||||
|
@ -51,7 +51,7 @@ namespace BizHawk.Client.Common
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception _)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
public void ExtractFile(int index, Stream stream)
|
public void ExtractFile(int index, Stream stream)
|
||||||
{
|
{
|
||||||
using (var entryStream = _archive.Entries.Where(e => !e.IsDirectory).ElementAt(index).OpenEntryStream())
|
using var entryStream = _archive.Entries.Where(e => !e.IsDirectory).ElementAt(index).OpenEntryStream();
|
||||||
entryStream.CopyTo(stream);
|
entryStream.CopyTo(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,13 +40,11 @@ namespace BizHawk.Client.Common
|
||||||
var file = new FileInfo(filepath);
|
var file = new FileInfo(filepath);
|
||||||
if (file.Exists)
|
if (file.Exists)
|
||||||
{
|
{
|
||||||
using (var reader = file.OpenText())
|
using var reader = file.OpenText();
|
||||||
{
|
|
||||||
var r = new JsonTextReader(reader);
|
var r = new JsonTextReader(reader);
|
||||||
config = (T)Serializer.Deserialize(r, typeof(T));
|
config = (T)Serializer.Deserialize(r, typeof(T));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Config Error", ex);
|
throw new InvalidOperationException("Config Error", ex);
|
||||||
|
@ -65,12 +63,10 @@ namespace BizHawk.Client.Common
|
||||||
var file = new FileInfo(filepath);
|
var file = new FileInfo(filepath);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var writer = file.CreateText())
|
using var writer = file.CreateText();
|
||||||
{
|
|
||||||
var w = new JsonTextWriter(writer) { Formatting = Formatting.Indented };
|
var w = new JsonTextWriter(writer) { Formatting = Formatting.Indented };
|
||||||
Serializer.Serialize(w, config);
|
Serializer.Serialize(w, config);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
/* Eat it */
|
/* Eat it */
|
||||||
|
@ -85,22 +81,19 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
public static object LoadWithType(string serialized)
|
public static object LoadWithType(string serialized)
|
||||||
{
|
{
|
||||||
using (TextReader tr = new StringReader(serialized))
|
using TextReader tr = new StringReader(serialized);
|
||||||
using (JsonTextReader jr = new JsonTextReader(tr))
|
using JsonTextReader jr = new JsonTextReader(tr);
|
||||||
{
|
|
||||||
TypeNameEncapsulator tne = (TypeNameEncapsulator)Serializer.Deserialize(jr, typeof(TypeNameEncapsulator));
|
TypeNameEncapsulator tne = (TypeNameEncapsulator)Serializer.Deserialize(jr, typeof(TypeNameEncapsulator));
|
||||||
|
|
||||||
// in the case of trying to deserialize nothing, tne will be nothing
|
// in the case of trying to deserialize nothing, tne will be nothing
|
||||||
// we want to return nothing
|
// we want to return nothing
|
||||||
return tne?.o;
|
return tne?.o;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static string SaveWithType(object o)
|
public static string SaveWithType(object o)
|
||||||
{
|
{
|
||||||
using (StringWriter sw = new StringWriter())
|
using StringWriter sw = new StringWriter();
|
||||||
using (JsonTextWriter jw = new JsonTextWriter(sw) { Formatting = Formatting.None })
|
using JsonTextWriter jw = new JsonTextWriter(sw) { Formatting = Formatting.None };
|
||||||
{
|
|
||||||
TypeNameEncapsulator tne = new TypeNameEncapsulator { o = o };
|
TypeNameEncapsulator tne = new TypeNameEncapsulator { o = o };
|
||||||
Serializer.Serialize(jw, tne, typeof(TypeNameEncapsulator));
|
Serializer.Serialize(jw, tne, typeof(TypeNameEncapsulator));
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
|
@ -108,4 +101,3 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
using NLua;
|
using NLua;
|
||||||
|
|
||||||
using BizHawk.Emulation.Common;
|
|
||||||
using BizHawk.Emulation.Cores.Consoles.Sega.gpgx;
|
using BizHawk.Emulation.Cores.Consoles.Sega.gpgx;
|
||||||
|
|
||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
using NLua;
|
using NLua;
|
||||||
|
|
||||||
using BizHawk.Emulation.Common;
|
|
||||||
|
|
||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
// ReSharper disable UnusedAutoPropertyAccessor.Local
|
// ReSharper disable UnusedAutoPropertyAccessor.Local
|
||||||
namespace BizHawk.Client.Common
|
namespace BizHawk.Client.Common
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using NLua;
|
using NLua;
|
||||||
using BizHawk.Client.Common;
|
|
||||||
|
|
||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
namespace BizHawk.Client.Common
|
namespace BizHawk.Client.Common
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
using BizHawk.Common;
|
using BizHawk.Common;
|
||||||
|
|
||||||
using NLua;
|
using NLua;
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace BizHawk.Client.Common.Miniz
|
namespace BizHawk.Client.Common.Miniz
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace BizHawk.Client.Common.Miniz
|
namespace BizHawk.Client.Common.Miniz
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
using BizHawk.Client.Common.MovieConversionExtensions;
|
namespace BizHawk.Client.Common.movie.import
|
||||||
|
|
||||||
namespace BizHawk.Client.Common.movie.import
|
|
||||||
{
|
{
|
||||||
// ReSharper disable once UnusedMember.Global
|
// ReSharper disable once UnusedMember.Global
|
||||||
[ImporterFor("BizHawk", ".bkm")]
|
[ImporterFor("BizHawk", ".bkm")]
|
||||||
|
|
|
@ -15,8 +15,7 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
bool lag;
|
var result = _lagLog.TryGetValue(frame, out var lag);
|
||||||
var result = _lagLog.TryGetValue(frame, out lag);
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
return lag;
|
return lag;
|
||||||
|
|
|
@ -100,9 +100,7 @@ namespace BizHawk.Client.Common
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
long address;
|
if (long.TryParse(parts[0], NumberStyles.HexNumber, CultureInfo.CurrentCulture, out var address))
|
||||||
|
|
||||||
if (long.TryParse(parts[0], NumberStyles.HexNumber, CultureInfo.CurrentCulture, out address))
|
|
||||||
{
|
{
|
||||||
WatchSize size = SizeFromChar(parts[1][0]);
|
WatchSize size = SizeFromChar(parts[1][0]);
|
||||||
DisplayType type = DisplayTypeFromChar(parts[2][0]);
|
DisplayType type = DisplayTypeFromChar(parts[2][0]);
|
||||||
|
|
|
@ -265,6 +265,7 @@
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=ffmpeg/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=ffmpeg/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=filenames/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=filenames/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=filesize/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=filesize/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=filesizes/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Finetuned/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Finetuned/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Fmpeg/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Fmpeg/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=fname/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=fname/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
|
Loading…
Reference in New Issue