Client.Common code refactoring and some misc things to do
This commit is contained in:
parent
3f410a771c
commit
9473f6840b
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ICSharpCode.SharpZipLib.Zip;
|
||||
using System.IO;
|
||||
|
||||
|
@ -9,16 +6,16 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public class BinaryStateFileNames
|
||||
{
|
||||
public const string versiontag = "BizState 1.0";
|
||||
public const string corestate = "Core";
|
||||
public const string framebuffer = "Framebuffer";
|
||||
public const string input = "Input Log";
|
||||
public const string Versiontag = "BizState 1.0";
|
||||
public const string Corestate = "Core";
|
||||
public const string Framebuffer = "Framebuffer";
|
||||
public const string Input = "Input Log";
|
||||
}
|
||||
|
||||
|
||||
public class BinaryStateLoader : IDisposable
|
||||
{
|
||||
private bool isDisposed = false;
|
||||
private bool isDisposed;
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
@ -50,7 +47,7 @@ namespace BizHawk.Client.Common
|
|||
try
|
||||
{
|
||||
ret.zip = new ZipFile(Filename);
|
||||
var e = ret.zip.GetEntry(BinaryStateFileNames.versiontag);
|
||||
var e = ret.zip.GetEntry(BinaryStateFileNames.Versiontag);
|
||||
if (e == null)
|
||||
{
|
||||
ret.zip.Close();
|
||||
|
@ -87,23 +84,23 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void GetCoreState(Action<Stream> callback)
|
||||
{
|
||||
GetFileByName(BinaryStateFileNames.corestate, true, callback);
|
||||
GetFileByName(BinaryStateFileNames.Corestate, true, callback);
|
||||
}
|
||||
|
||||
public bool GetFrameBuffer(Action<Stream> callback)
|
||||
{
|
||||
return GetFileByName(BinaryStateFileNames.framebuffer, false, callback);
|
||||
return GetFileByName(BinaryStateFileNames.Framebuffer, false, callback);
|
||||
}
|
||||
|
||||
public void GetInputLogRequired(Action<Stream> callback)
|
||||
{
|
||||
GetFileByName(BinaryStateFileNames.input, true, callback);
|
||||
GetFileByName(BinaryStateFileNames.Input, true, callback);
|
||||
}
|
||||
}
|
||||
|
||||
public class BinaryStateSaver : IDisposable
|
||||
{
|
||||
ZipOutputStream zip;
|
||||
private readonly ZipOutputStream zip;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
@ -111,18 +108,19 @@ namespace BizHawk.Client.Common
|
|||
/// <param name="s">not closed when finished!</param>
|
||||
public BinaryStateSaver(Stream s)
|
||||
{
|
||||
zip = new ZipOutputStream(s);
|
||||
zip.IsStreamOwner = false;
|
||||
zip = new ZipOutputStream(s)
|
||||
{
|
||||
IsStreamOwner = false,
|
||||
UseZip64 = UseZip64.Off
|
||||
};
|
||||
zip.SetLevel(0);
|
||||
zip.UseZip64 = UseZip64.Off;
|
||||
|
||||
PutFileByName(BinaryStateFileNames.versiontag, (ss) => { });
|
||||
PutFileByName(BinaryStateFileNames.Versiontag, ss => { });
|
||||
}
|
||||
|
||||
void PutFileByName(string Name, Action<Stream> callback)
|
||||
{
|
||||
var e = new ZipEntry(Name);
|
||||
e.CompressionMethod = CompressionMethod.Stored;
|
||||
var e = new ZipEntry(Name) {CompressionMethod = CompressionMethod.Stored};
|
||||
zip.PutNextEntry(e);
|
||||
callback(zip);
|
||||
zip.CloseEntry();
|
||||
|
@ -130,20 +128,20 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void PutCoreState(Action<Stream> callback)
|
||||
{
|
||||
PutFileByName(BinaryStateFileNames.corestate, callback);
|
||||
PutFileByName(BinaryStateFileNames.Corestate, callback);
|
||||
}
|
||||
|
||||
public void PutFrameBuffer(Action<Stream> callback)
|
||||
{
|
||||
PutFileByName(BinaryStateFileNames.framebuffer, callback);
|
||||
PutFileByName(BinaryStateFileNames.Framebuffer, callback);
|
||||
}
|
||||
|
||||
public void PutInputLog(Action<Stream> callback)
|
||||
{
|
||||
PutFileByName(BinaryStateFileNames.input, callback);
|
||||
PutFileByName(BinaryStateFileNames.Input, callback);
|
||||
}
|
||||
|
||||
private bool isDisposed = false;
|
||||
private bool isDisposed;
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
private readonly Dictionary<string, ControllerDefinition.FloatRange> FloatRanges = new WorkingDictionary<string, ControllerDefinition.FloatRange>();
|
||||
|
||||
private readonly Dictionary<string, BizHawk.Client.Common.Config.AnalogBind> FloatBinds = new Dictionary<string, Config.AnalogBind>();
|
||||
private readonly Dictionary<string, Config.AnalogBind> FloatBinds = new Dictionary<string, Config.AnalogBind>();
|
||||
|
||||
public Controller(ControllerDefinition definition)
|
||||
{
|
||||
|
@ -43,32 +43,13 @@ namespace BizHawk.Client.Common
|
|||
//look for bindings which are activated by the supplied physical button.
|
||||
public List<string> SearchBindings(string button)
|
||||
{
|
||||
var ret = new List<string>();
|
||||
foreach (var kvp in bindings)
|
||||
{
|
||||
foreach (var bound_button in kvp.Value)
|
||||
{
|
||||
if (bound_button == button)
|
||||
ret.Add(kvp.Key);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
return (from kvp in bindings from bound_button in kvp.Value where bound_button == button select kvp.Key).ToList();
|
||||
}
|
||||
|
||||
//Searches bindings for the controller and returns true if this binding is mapped somewhere in this controller
|
||||
public bool HasBinding(string button)
|
||||
{
|
||||
foreach (var kvp in bindings)
|
||||
{
|
||||
foreach (var bound_button in kvp.Value)
|
||||
{
|
||||
if (bound_button == button)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return bindings.SelectMany(kvp => kvp.Value).Any(bound_button => bound_button == button);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -153,7 +134,7 @@ namespace BizHawk.Client.Common
|
|||
bindings[button].Add(control.Trim());
|
||||
}
|
||||
|
||||
public void BindFloat(string button, BizHawk.Client.Common.Config.AnalogBind bind)
|
||||
public void BindFloat(string button, Config.AnalogBind bind)
|
||||
{
|
||||
FloatBinds[button] = bind;
|
||||
}
|
||||
|
@ -164,17 +145,7 @@ namespace BizHawk.Client.Common
|
|||
/// <returns></returns>
|
||||
public List<KeyValuePair<string, string>> MappingList()
|
||||
{
|
||||
List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
|
||||
|
||||
foreach (KeyValuePair<string, List<string>> key in bindings)
|
||||
{
|
||||
foreach (string binding in key.Value)
|
||||
{
|
||||
list.Add(new KeyValuePair<string, string>(binding, key.Key));
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
return (from key in bindings from binding in key.Value select new KeyValuePair<string, string>(binding, key.Key)).ToList();
|
||||
}
|
||||
|
||||
public List<string> PressedButtons
|
||||
|
@ -188,9 +159,9 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public class AutofireController : IController
|
||||
{
|
||||
private ControllerDefinition type;
|
||||
private WorkingDictionary<string, List<string>> bindings = new WorkingDictionary<string, List<string>>();
|
||||
private WorkingDictionary<string, bool> buttons = new WorkingDictionary<string, bool>();
|
||||
private readonly ControllerDefinition type;
|
||||
private readonly WorkingDictionary<string, List<string>> bindings = new WorkingDictionary<string, List<string>>();
|
||||
private readonly WorkingDictionary<string, bool> buttons = new WorkingDictionary<string, bool>();
|
||||
public WorkingDictionary<string, int> buttonStarts = new WorkingDictionary<string, int>();
|
||||
|
||||
private bool autofire = true;
|
||||
|
@ -229,16 +200,7 @@ namespace BizHawk.Client.Common
|
|||
//look for bindings which are activated by the supplied physical button.
|
||||
public List<string> SearchBindings(string button)
|
||||
{
|
||||
var ret = new List<string>();
|
||||
foreach (var kvp in bindings)
|
||||
{
|
||||
foreach (var bound_button in kvp.Value)
|
||||
{
|
||||
if (bound_button == button)
|
||||
ret.Add(kvp.Key);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
return (from kvp in bindings from bound_button in kvp.Value where bound_button == button select kvp.Key).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
|
@ -22,7 +21,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public string PathSubfile(string fname)
|
||||
{
|
||||
return Path.Combine(Path.GetDirectoryName(SubfileDirectory), fname);
|
||||
return Path.Combine(Path.GetDirectoryName(SubfileDirectory) ?? String.Empty, fname);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
@ -27,7 +26,7 @@ namespace BizHawk.Client.Common
|
|||
public string Hash;
|
||||
}
|
||||
|
||||
Dictionary<FirmwareDatabase.FirmwareRecord, ResolutionInfo> ResolutionDictionary = new Dictionary<FirmwareDatabase.FirmwareRecord, ResolutionInfo>();
|
||||
readonly Dictionary<FirmwareDatabase.FirmwareRecord, ResolutionInfo> ResolutionDictionary = new Dictionary<FirmwareDatabase.FirmwareRecord, ResolutionInfo>();
|
||||
|
||||
|
||||
public ResolutionInfo Resolve(string sysId, string firmwareId)
|
||||
|
@ -41,7 +40,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
RETRY:
|
||||
|
||||
ResolutionInfo resolved = null;
|
||||
ResolutionInfo resolved;
|
||||
ResolutionDictionary.TryGetValue(record, out resolved);
|
||||
|
||||
//couldnt find it! do a scan and resolve to try harder
|
||||
|
@ -68,8 +67,7 @@ namespace BizHawk.Client.Common
|
|||
byte[] buffer = new byte[0];
|
||||
public RealFirmwareFile Read(FileInfo fi)
|
||||
{
|
||||
RealFirmwareFile rff = new RealFirmwareFile();
|
||||
rff.fi = fi;
|
||||
RealFirmwareFile rff = new RealFirmwareFile {fi = fi};
|
||||
long len = fi.Length;
|
||||
if (len > buffer.Length) buffer = new byte[len];
|
||||
using (var fs = fi.OpenRead()) fs.Read(buffer, 0, (int)len);
|
||||
|
@ -78,8 +76,8 @@ namespace BizHawk.Client.Common
|
|||
files.Add(rff);
|
||||
return rff;
|
||||
}
|
||||
public Dictionary<string, RealFirmwareFile> dict = new Dictionary<string, RealFirmwareFile>();
|
||||
public List<RealFirmwareFile> files = new List<RealFirmwareFile>();
|
||||
public readonly Dictionary<string, RealFirmwareFile> dict = new Dictionary<string, RealFirmwareFile>();
|
||||
private readonly List<RealFirmwareFile> files = new List<RealFirmwareFile>();
|
||||
}
|
||||
|
||||
public void DoScanAndResolve()
|
||||
|
@ -109,9 +107,10 @@ namespace BizHawk.Client.Common
|
|||
ResolutionDictionary.Remove(fr);
|
||||
|
||||
//get all options for this firmware (in order)
|
||||
FirmwareDatabase.FirmwareRecord fr1 = fr;
|
||||
var options =
|
||||
from fo in FirmwareDatabase.FirmwareOptions
|
||||
where fo.systemId == fr.systemId && fo.firmwareId == fr.firmwareId
|
||||
where fo.systemId == fr1.systemId && fo.firmwareId == fr1.firmwareId
|
||||
select fo;
|
||||
|
||||
//try each option
|
||||
|
@ -122,10 +121,12 @@ namespace BizHawk.Client.Common
|
|||
if (reader.dict.ContainsKey(hash))
|
||||
{
|
||||
//rad! then we can use it
|
||||
var ri = new ResolutionInfo();
|
||||
ri.FilePath = reader.dict[hash].fi.FullName;
|
||||
ri.KnownFirmwareFile = FirmwareDatabase.FirmwareFilesByHash[hash];
|
||||
ri.Hash = hash;
|
||||
var ri = new ResolutionInfo
|
||||
{
|
||||
FilePath = reader.dict[hash].fi.FullName,
|
||||
KnownFirmwareFile = FirmwareDatabase.FirmwareFilesByHash[hash],
|
||||
Hash = hash
|
||||
};
|
||||
ResolutionDictionary[fr] = ri;
|
||||
goto DONE_FIRMWARE;
|
||||
}
|
||||
|
@ -138,13 +139,13 @@ namespace BizHawk.Client.Common
|
|||
//apply user overrides
|
||||
foreach (var fr in FirmwareDatabase.FirmwareRecords)
|
||||
{
|
||||
string userSpec = null;
|
||||
string userSpec;
|
||||
|
||||
//do we have a user specification for this firmware record?
|
||||
if (Global.Config.FirmwareUserSpecifications.TryGetValue(fr.ConfigKey, out userSpec))
|
||||
{
|
||||
//flag it as user specified
|
||||
ResolutionInfo ri = null;
|
||||
ResolutionInfo ri;
|
||||
if (!ResolutionDictionary.TryGetValue(fr, out ri))
|
||||
{
|
||||
ri = new ResolutionInfo();
|
||||
|
@ -168,7 +169,7 @@ namespace BizHawk.Client.Common
|
|||
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)
|
||||
FirmwareDatabase.FirmwareFile ff = null;
|
||||
FirmwareDatabase.FirmwareFile ff;
|
||||
if(FirmwareDatabase.FirmwareFilesByHash.TryGetValue(rff.hash,out ff))
|
||||
{
|
||||
ri.KnownFirmwareFile = ff;
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace BizHawk.Client.Common
|
|||
/// </summary>
|
||||
public bool IsArchive { get { return extractor != null; } }
|
||||
|
||||
int? BoundIndex = null;
|
||||
int? BoundIndex;
|
||||
|
||||
public int? GetBoundIndex()
|
||||
{
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
|
@ -196,12 +195,7 @@ namespace BizHawk.Client.Common
|
|||
return Environment.SpecialFolder.Recent.ToString();
|
||||
}
|
||||
|
||||
PathEntry path = Global.Config.PathEntries[sysID, "ROM"];
|
||||
|
||||
if (path == null)
|
||||
{
|
||||
path = Global.Config.PathEntries[sysID, "Base"];
|
||||
}
|
||||
PathEntry path = Global.Config.PathEntries[sysID, "ROM"] ?? Global.Config.PathEntries[sysID, "Base"];
|
||||
|
||||
return MakeAbsolutePath(path.Path, sysID);
|
||||
}
|
||||
|
@ -231,24 +225,16 @@ namespace BizHawk.Client.Common
|
|||
name += "." + Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename);
|
||||
}
|
||||
|
||||
PathEntry pathEntry = Global.Config.PathEntries[game.System, "Save RAM"];
|
||||
|
||||
if (pathEntry == null)
|
||||
{
|
||||
pathEntry = Global.Config.PathEntries[game.System, "Base"];
|
||||
}
|
||||
PathEntry pathEntry = Global.Config.PathEntries[game.System, "Save RAM"] ??
|
||||
Global.Config.PathEntries[game.System, "Base"];
|
||||
|
||||
return Path.Combine(MakeAbsolutePath(pathEntry.Path, game.System), name) + ".SaveRAM";
|
||||
}
|
||||
|
||||
public static string GetSaveStatePath(GameInfo game)
|
||||
{
|
||||
PathEntry pathEntry = Global.Config.PathEntries[game.System, "Savestates"];
|
||||
|
||||
if (pathEntry == null)
|
||||
{
|
||||
pathEntry = Global.Config.PathEntries[game.System, "Base"];
|
||||
}
|
||||
PathEntry pathEntry = Global.Config.PathEntries[game.System, "Savestates"] ??
|
||||
Global.Config.PathEntries[game.System, "Base"];
|
||||
|
||||
return MakeAbsolutePath(pathEntry.Path, game.System);
|
||||
}
|
||||
|
@ -262,24 +248,16 @@ namespace BizHawk.Client.Common
|
|||
name += "." + Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename);
|
||||
}
|
||||
|
||||
PathEntry pathEntry = Global.Config.PathEntries[game.System, "Savestates"];
|
||||
|
||||
if (pathEntry == null)
|
||||
{
|
||||
pathEntry = Global.Config.PathEntries[game.System, "Base"];
|
||||
}
|
||||
PathEntry pathEntry = Global.Config.PathEntries[game.System, "Savestates"] ??
|
||||
Global.Config.PathEntries[game.System, "Base"];
|
||||
|
||||
return Path.Combine(MakeAbsolutePath(pathEntry.Path, game.System), name);
|
||||
}
|
||||
|
||||
public static string GetCheatsPath(GameInfo game)
|
||||
{
|
||||
PathEntry pathEntry = Global.Config.PathEntries[game.System, "Cheats"];
|
||||
|
||||
if (pathEntry == null)
|
||||
{
|
||||
pathEntry = Global.Config.PathEntries[game.System, "Base"];
|
||||
}
|
||||
PathEntry pathEntry = Global.Config.PathEntries[game.System, "Cheats"] ??
|
||||
Global.Config.PathEntries[game.System, "Base"];
|
||||
|
||||
return MakeAbsolutePath(pathEntry.Path, game.System);
|
||||
}
|
||||
|
@ -288,12 +266,8 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
string name = FilesystemSafeName(game);
|
||||
|
||||
PathEntry pathEntry = Global.Config.PathEntries[game.System, "Screenshots"];
|
||||
|
||||
if (pathEntry == null)
|
||||
{
|
||||
pathEntry = Global.Config.PathEntries[game.System, "Base"];
|
||||
}
|
||||
PathEntry pathEntry = Global.Config.PathEntries[game.System, "Screenshots"] ??
|
||||
Global.Config.PathEntries[game.System, "Base"];
|
||||
|
||||
return Path.Combine(MakeAbsolutePath(pathEntry.Path, game.System), name);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
||||
|
@ -23,11 +21,16 @@ namespace BizHawk.Client.Common
|
|||
if (y == null)
|
||||
return null;
|
||||
|
||||
var ret = new XmlGame();
|
||||
ret.GI.System = y.Attributes["System"].Value;
|
||||
ret.GI.Name = y.Attributes["Name"].Value;
|
||||
ret.GI.Status = RomStatus.Unknown;
|
||||
ret.Xml = x;
|
||||
var ret = new XmlGame
|
||||
{
|
||||
GI =
|
||||
{
|
||||
System = y.Attributes["System"].Value,
|
||||
Name = y.Attributes["Name"].Value,
|
||||
Status = RomStatus.Unknown
|
||||
},
|
||||
Xml = x
|
||||
};
|
||||
|
||||
var n = y.SelectSingleNode("./LoadAssets");
|
||||
if (n != null)
|
||||
|
@ -61,7 +64,7 @@ namespace BizHawk.Client.Common
|
|||
else
|
||||
{
|
||||
// relative path
|
||||
string fullpath = Path.GetDirectoryName(f.CanonicalFullPath.Split('|')[0]);
|
||||
string fullpath = Path.GetDirectoryName(f.CanonicalFullPath.Split('|')[0]) ?? String.Empty;
|
||||
fullpath = Path.Combine(fullpath, filename);
|
||||
try
|
||||
{
|
||||
|
|
|
@ -22,8 +22,12 @@ namespace BizHawk.Client.Common
|
|||
config = (T)s.Deserialize(r, typeof(T));
|
||||
}
|
||||
}
|
||||
catch (Exception e) { /*TODO MessageBox.Show(e.ToString(), "Config Error"); */ }
|
||||
if (config == null) return new T();
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InvalidOperationException("Config Error", ex);
|
||||
}
|
||||
|
||||
//if (config == null) return new T();
|
||||
|
||||
//patch up arrays in the config with the minimum number of things
|
||||
foreach(var fi in typeof(T).GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public))
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
|
@ -109,7 +108,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public IEnumerable<KeyValuePair<string, bool>> BoolButtons()
|
||||
{
|
||||
foreach (var kvp in Buttons) yield return kvp;
|
||||
return Buttons;
|
||||
}
|
||||
|
||||
public virtual void LatchFrom(IController source)
|
||||
|
@ -200,7 +199,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
// if SetFloat() is called (typically virtual pads), then that float will entirely override the Source input
|
||||
// otherwise, the source is passed thru.
|
||||
WorkingDictionary<string,float?> FloatSet = new WorkingDictionary<string,float?>();
|
||||
readonly WorkingDictionary<string,float?> FloatSet = new WorkingDictionary<string,float?>();
|
||||
public void SetFloat(string name, float? value)
|
||||
{
|
||||
if (value.HasValue)
|
||||
|
|
|
@ -370,7 +370,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
string BackupName = Filename;
|
||||
BackupName = BackupName.Insert(Filename.LastIndexOf("."), String.Format(".{0:yyyy-MM-dd HH.mm.ss}", DateTime.Now));
|
||||
BackupName = Path.Combine(Global.Config.PathEntries["Global", "Movie backups"].Path, Path.GetFileName(BackupName));
|
||||
BackupName = Path.Combine(Global.Config.PathEntries["Global", "Movie backups"].Path, Path.GetFileName(BackupName) ?? String.Empty);
|
||||
|
||||
var directory_info = new FileInfo(BackupName).Directory;
|
||||
if (directory_info != null) Directory.CreateDirectory(directory_info.FullName);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
|
@ -108,16 +107,16 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
},
|
||||
{
|
||||
"Nintento 64 Controller", new Dictionary<string, string>()
|
||||
{
|
||||
"Nintento 64 Controller", new Dictionary<string, string>
|
||||
{
|
||||
{"DPad U", "U"}, {"DPad D", "D"}, {"DPad L", "L"}, {"DPad R", "R"},
|
||||
{"B", "B"}, {"A", "A"}, {"Z", "Z"}, {"Start", "S"}, {"L", "L"}, {"R", "R"},
|
||||
{"C Up", "u"}, {"C Down", "d"}, {"C Left", "l"}, {"C Right", "r"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Saturn Controller", new Dictionary<string, string>()
|
||||
{
|
||||
"Saturn Controller", new Dictionary<string, string>
|
||||
{
|
||||
{"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"},
|
||||
{"Start", "S"}, {"X", "X"}, {"Y", "Y"}, {"Z", "Z"}, {"A", "A"}, {"B", "B"}, {"C", "C"},
|
||||
{"L", "l"}, {"R", "r"},
|
||||
|
@ -139,9 +138,9 @@ namespace BizHawk.Client.Common
|
|||
{"Genesis 3-Button Controller", new Dictionary<string, string> {{"Reset", "r"}}},
|
||||
{"NES Controller", new Dictionary<string, string> {{"Reset", "r"}, {"Power", "P"}, {"FDS Eject", "E"}, {"FDS Insert 0", "0"}, {"FDS Insert 1", "1"}, {"VS Coin 1", "c"}, {"VS Coin 2", "C"}}},
|
||||
{"SNES Controller", new Dictionary<string, string> {{"Power", "P"}, {"Reset", "r"}}},
|
||||
{"PC Engine Controller", new Dictionary<string, string> {}},
|
||||
{"PC Engine Controller", new Dictionary<string, string>()},
|
||||
{"SMS Controller", new Dictionary<string, string> {{"Pause", "p"}, {"Reset", "r"}}},
|
||||
{"TI83 Controller", new Dictionary<string, string> {}},
|
||||
{"TI83 Controller", new Dictionary<string, string>()},
|
||||
{"Nintento 64 Controller", new Dictionary<string, string> {{"Power", "P"}, {"Reset", "r"}}},
|
||||
{"Saturn Controller", new Dictionary<string, string> {{"Power", "P"}, {"Reset", "r"}}},
|
||||
};
|
||||
|
@ -155,7 +154,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
// just experimenting with different possibly more painful ways to handle mnemonics
|
||||
// |P|UDLRsSBA|
|
||||
public static Tuple<string, char>[] DGBMnemonic = new Tuple<string, char>[]
|
||||
public static Tuple<string, char>[] DGBMnemonic = new[]
|
||||
{
|
||||
new Tuple<string, char>(null, '|'),
|
||||
new Tuple<string, char>("P1 Power", 'P'),
|
||||
|
@ -406,7 +405,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
foreach (string name in MnemonicConstants.ANALOGS[ControlType].Keys)
|
||||
{
|
||||
int val = 0;
|
||||
int val;
|
||||
|
||||
//Nasty hackery
|
||||
if (name == "Y Axis")
|
||||
|
|
|
@ -3,7 +3,6 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
|
||||
|
@ -15,7 +14,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public SubtitleList() { }
|
||||
|
||||
public SubtitleList(SubtitleList subtitles)
|
||||
public SubtitleList(IEnumerable<Subtitle> subtitles)
|
||||
{
|
||||
foreach (var subtitle in subtitles)
|
||||
{
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
|
@ -52,14 +47,14 @@ namespace BizHawk.Client.Common
|
|||
public enum ComparisonOperator { Equal, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual, NotEqual, DifferentBy };
|
||||
public enum Compare { Previous, SpecificValue, SpecificAddress, Changes, Difference }
|
||||
|
||||
private int? _differentBy = null;
|
||||
private int? _differentBy;
|
||||
private Compare _compareTo = Compare.Previous;
|
||||
private long? _compareValue = null;
|
||||
private long? _compareValue;
|
||||
private ComparisonOperator _operator = ComparisonOperator.Equal;
|
||||
|
||||
private List<IMiniWatch> _watchList = new List<IMiniWatch>();
|
||||
private Settings _settings = new Settings();
|
||||
private UndoHistory<IMiniWatch> _history = new UndoHistory<IMiniWatch>(true);
|
||||
private readonly Settings _settings = new Settings();
|
||||
private readonly UndoHistory<IMiniWatch> _history = new UndoHistory<IMiniWatch>(true);
|
||||
private bool _keepHistory = true;
|
||||
|
||||
public RamSearchEngine(Settings settings)
|
||||
|
@ -189,19 +184,19 @@ namespace BizHawk.Client.Common
|
|||
switch (_compareTo)
|
||||
{
|
||||
default:
|
||||
case RamSearchEngine.Compare.Previous:
|
||||
case Compare.Previous:
|
||||
_watchList = ComparePrevious(_watchList).ToList();
|
||||
break;
|
||||
case RamSearchEngine.Compare.SpecificValue:
|
||||
case Compare.SpecificValue:
|
||||
_watchList = CompareSpecificValue(_watchList).ToList();
|
||||
break;
|
||||
case RamSearchEngine.Compare.SpecificAddress:
|
||||
case Compare.SpecificAddress:
|
||||
_watchList = CompareSpecificAddress(_watchList).ToList();
|
||||
break;
|
||||
case RamSearchEngine.Compare.Changes:
|
||||
case Compare.Changes:
|
||||
_watchList = CompareChanges(_watchList).ToList();
|
||||
break;
|
||||
case RamSearchEngine.Compare.Difference:
|
||||
case Compare.Difference:
|
||||
_watchList = CompareDifference(_watchList).ToList();
|
||||
break;
|
||||
}
|
||||
|
@ -229,16 +224,16 @@ namespace BizHawk.Client.Common
|
|||
switch (_compareTo)
|
||||
{
|
||||
default:
|
||||
case RamSearchEngine.Compare.Previous:
|
||||
return ComparePrevious(listOfOne).Count() == 0;
|
||||
case RamSearchEngine.Compare.SpecificValue:
|
||||
return CompareSpecificValue(listOfOne).Count() == 0;
|
||||
case RamSearchEngine.Compare.SpecificAddress:
|
||||
return CompareSpecificAddress(listOfOne).Count() == 0;
|
||||
case RamSearchEngine.Compare.Changes:
|
||||
return CompareChanges(listOfOne).Count() == 0;
|
||||
case RamSearchEngine.Compare.Difference:
|
||||
return CompareDifference(listOfOne).Count() == 0;
|
||||
case Compare.Previous:
|
||||
return !ComparePrevious(listOfOne).Any();
|
||||
case Compare.SpecificValue:
|
||||
return !CompareSpecificValue(listOfOne).Any();
|
||||
case Compare.SpecificAddress:
|
||||
return !CompareSpecificAddress(listOfOne).Any();
|
||||
case Compare.Changes:
|
||||
return !CompareChanges(listOfOne).Any();
|
||||
case Compare.Difference:
|
||||
return !CompareDifference(listOfOne).Any();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -745,7 +740,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else
|
||||
{
|
||||
return (uint)theDWord;
|
||||
return theDWord;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -758,7 +753,7 @@ namespace BizHawk.Client.Common
|
|||
case Settings.SearchMode.Detailed:
|
||||
return true;
|
||||
case Settings.SearchMode.Fast:
|
||||
return !(compareType == Compare.Changes);
|
||||
return compareType != Compare.Changes;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -851,7 +846,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public int Address { get; private set; }
|
||||
private byte _previous;
|
||||
int _changecount = 0;
|
||||
int _changecount;
|
||||
|
||||
public MiniByteWatchDetailed(MemoryDomain domain, int addr)
|
||||
{
|
||||
|
@ -903,7 +898,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public int Address { get; private set; }
|
||||
private ushort _previous;
|
||||
int _changecount = 0;
|
||||
int _changecount;
|
||||
|
||||
public MiniWordWatchDetailed(MemoryDomain domain, int addr, bool bigEndian)
|
||||
{
|
||||
|
@ -954,7 +949,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public int Address { get; private set; }
|
||||
private uint _previous;
|
||||
int _changecount = 0;
|
||||
int _changecount;
|
||||
|
||||
public MiniDWordWatchDetailed(MemoryDomain domain, int addr, bool bigEndian)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue