Misc cleanups in Client.Common, documentation fixes
This commit is contained in:
parent
f576cb14b0
commit
dfea029fe4
|
@ -325,8 +325,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public BinaryStateSaver(string path, bool notamovie = true) // notamovie is hack, really should have separate something
|
||||
{
|
||||
_zip = new IonicZipWriter(path, notamovie ? Global.Config.SaveStateCompressionLevelNormal
|
||||
: Global.Config.MovieCompressionLevel);
|
||||
_zip = new IonicZipWriter(path, notamovie ? Global.Config.SaveStateCompressionLevelNormal : Global.Config.MovieCompressionLevel);
|
||||
////_zip = new SharpZipWriter(path, Global.Config.SaveStateCompressionLevelNormal);
|
||||
////_zip = new SevenZipWriter(path, Global.Config.SaveStateCompressionLevelNormal);
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ namespace BizHawk.Client.Common
|
|||
return PathManager.SaveRamPath(Global.Game);
|
||||
}
|
||||
|
||||
|
||||
public string GetRetroSaveRAMDirectory()
|
||||
{
|
||||
return PathManager.RetroSaveRAMDirectory(Global.Game);
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
using BizHawk.Emulation.Common;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
|
||||
using BizHawk.Emulation.Cores.Sega.MasterSystem;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
// ReSharper disable StyleCop.SA1401
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public static class Global
|
||||
|
@ -23,7 +24,7 @@ namespace BizHawk.Client.Common
|
|||
public static bool DisableSecondaryThrottling;
|
||||
|
||||
/// <summary>
|
||||
/// The maximum number of millseconds the sound output buffer can go below full before causing a noticable sound interruption.
|
||||
/// The maximum number of milliseconds the sound output buffer can go below full before causing a noticeable sound interruption.
|
||||
/// </summary>
|
||||
public static int SoundMaxBufferDeficitMs;
|
||||
|
||||
|
|
|
@ -158,7 +158,6 @@ namespace BizHawk.Client.Common
|
|||
// output[i + 3] = source[i];
|
||||
// output[i + 1] = source[i + 2];
|
||||
// output[i + 2] = source[i + 1];
|
||||
|
||||
byte temp = pSource[i];
|
||||
pSource[i] = source[i + 3];
|
||||
pSource[i + 3] = temp;
|
||||
|
@ -192,7 +191,10 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { } // No need for errors in patching to propagate.
|
||||
catch (Exception)
|
||||
{
|
||||
// No need for errors in patching to propagate.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,7 +124,9 @@ namespace BizHawk.Client.Common
|
|||
buff[i] = j;
|
||||
}
|
||||
}
|
||||
catch (EndOfStreamException) { }
|
||||
catch (EndOfStreamException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -308,11 +308,11 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
SevenZip.SevenZipCompressor svc;
|
||||
private SevenZip.SevenZipCompressor svc;
|
||||
|
||||
bool first = true;
|
||||
string path;
|
||||
int compressionlevel;
|
||||
private bool first = true;
|
||||
private string path;
|
||||
private int compressionlevel;
|
||||
|
||||
public SevenZipWriter(string path, int compressionlevel)
|
||||
{
|
||||
|
@ -325,16 +325,28 @@ namespace BizHawk.Client.Common
|
|||
switch (compressionlevel)
|
||||
{
|
||||
default:
|
||||
case 0: svc.CompressionLevel = SevenZip.CompressionLevel.None; break;
|
||||
case 0:
|
||||
svc.CompressionLevel = SevenZip.CompressionLevel.None;
|
||||
break;
|
||||
case 1:
|
||||
case 2: svc.CompressionLevel = SevenZip.CompressionLevel.Fast; break;
|
||||
case 2:
|
||||
svc.CompressionLevel = SevenZip.CompressionLevel.Fast;
|
||||
break;
|
||||
case 3:
|
||||
case 4: svc.CompressionLevel = SevenZip.CompressionLevel.Low; break;
|
||||
case 4:
|
||||
svc.CompressionLevel = SevenZip.CompressionLevel.Low;
|
||||
break;
|
||||
case 5:
|
||||
case 6: svc.CompressionLevel = SevenZip.CompressionLevel.Normal; break;
|
||||
case 6:
|
||||
svc.CompressionLevel = SevenZip.CompressionLevel.Normal;
|
||||
break;
|
||||
case 7:
|
||||
case 8: svc.CompressionLevel = SevenZip.CompressionLevel.High; break;
|
||||
case 9: svc.CompressionLevel = SevenZip.CompressionLevel.Ultra; break;
|
||||
case 8:
|
||||
svc.CompressionLevel = SevenZip.CompressionLevel.High;
|
||||
break;
|
||||
case 9:
|
||||
svc.CompressionLevel = SevenZip.CompressionLevel.Ultra;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace BizHawk.Client.Common
|
|||
#region cTor(s)
|
||||
|
||||
/// <summary>
|
||||
/// Initialize a new instance of <see cref="SystemInfo"/>
|
||||
/// Initializes a new instance of the <see cref="SystemInfo"/> class
|
||||
/// </summary>
|
||||
/// <param name="displayName">A <see cref="string"/> that specify how the system name is displayed</param>
|
||||
/// <param name="system">A <see cref="CoreSystem"/> that specify what core is used</param>
|
||||
|
@ -45,17 +45,17 @@ namespace BizHawk.Client.Common
|
|||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SystemInfo"/> instance for Apple II
|
||||
/// </summary
|
||||
/// </summary>
|
||||
public static SystemInfo Libretro { get; } = new SystemInfo("Libretro", CoreSystem.Libretro, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SystemInfo"/> instance for Apple II
|
||||
/// </summary
|
||||
/// </summary>
|
||||
public static SystemInfo AppleII { get; } = new SystemInfo("Apple II", CoreSystem.AppleII, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SystemInfo"/> instance for Atari 2600
|
||||
/// </summary
|
||||
/// </summary>
|
||||
public static SystemInfo Atari2600 { get; } = new SystemInfo("Atari 2600", CoreSystem.Atari2600, 1);
|
||||
|
||||
/// <summary>
|
||||
|
@ -184,7 +184,7 @@ namespace BizHawk.Client.Common
|
|||
/// Get a <see cref="SystemInfo"/> by its <see cref="CoreSystem"/>
|
||||
/// </summary>
|
||||
/// <param name="system"><see cref="CoreSystem"/> you're looking for</param>
|
||||
/// <returns>Mathing <see cref="SystemInfo"/></returns>
|
||||
/// <returns><see cref="SystemInfo"/></returns>
|
||||
public static SystemInfo FindByCoreSystem(CoreSystem system)
|
||||
{
|
||||
return _allSystemInfos.Find(s => s.System == system);
|
||||
|
@ -193,7 +193,7 @@ namespace BizHawk.Client.Common
|
|||
/// <summary>
|
||||
/// Determine if this <see cref="SystemInfo"/> is equal to specified <see cref="object"/>
|
||||
/// </summary>
|
||||
/// <param name="obj"><see cref="object"/> to comapre to</param>
|
||||
/// <param name="obj"><see cref="object"/> to compare to</param>
|
||||
/// <returns>True if object is equal to this instance; otherwise, false</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
|
@ -218,7 +218,6 @@ namespace BizHawk.Client.Common
|
|||
/// Returns a <see cref="string"/> representation of current <see cref="SystemInfo"/>
|
||||
/// In fact, return the same as DisplayName property
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return DisplayName;
|
||||
|
@ -258,7 +257,7 @@ namespace BizHawk.Client.Common
|
|||
public JoypadButton AvailableButtons { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sytem name as <see cref="string"/>
|
||||
/// Gets the system name as <see cref="string"/>
|
||||
/// </summary>
|
||||
public string DisplayName { get; }
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public static class ConfigService
|
||||
{
|
||||
private static JsonSerializer Serializer;
|
||||
private static readonly JsonSerializer Serializer;
|
||||
|
||||
static ConfigService()
|
||||
{
|
||||
|
|
|
@ -44,7 +44,6 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
_wndx = value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,12 +61,11 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
_wndy = value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the top left corner coordinate, if Wndx and Wndy form a valid point
|
||||
/// Gets a value that represents the top left corner coordinate, if Wndx and Wndy form a valid point
|
||||
/// Throws an InvalidOperationException if Wndx or Wndy is null
|
||||
/// It is expected to check for this before using this property
|
||||
/// </summary>
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
public readonly int Loop = 0;
|
||||
private int _index = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Autohold.
|
||||
/// </summary>
|
||||
public AutoPatternBool()
|
||||
{
|
||||
Pattern = new[] { true };
|
||||
|
|
|
@ -184,7 +184,10 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
}
|
||||
catch { /*Eat it*/ }
|
||||
catch
|
||||
{
|
||||
/*Eat it*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,13 +15,11 @@ namespace BizHawk.Client.Common
|
|||
public MemoryLuaLibrary(Lua lua)
|
||||
: base(lua)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public MemoryLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override string Name => "memory";
|
||||
|
@ -41,14 +39,12 @@ namespace BizHawk.Client.Common
|
|||
|
||||
return _currentMemoryDomain;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var error = $"Error: {Emulator.Attributes().CoreName} does not implement memory domains";
|
||||
Log(error);
|
||||
throw new NotImplementedException(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Unique Library Methods
|
||||
|
||||
|
|
|
@ -28,12 +28,9 @@ namespace BizHawk.Client.Common
|
|||
public IMovie QueuedMovie { get; set; }
|
||||
|
||||
// This wrapper but the logic could change, don't make the client code understand these details
|
||||
public bool MovieIsQueued
|
||||
{
|
||||
get { return QueuedMovie != null; }
|
||||
}
|
||||
public bool MovieIsQueued => QueuedMovie != null;
|
||||
|
||||
public MultitrackRecorder MultiTrack { get; private set; }
|
||||
public MultitrackRecorder MultiTrack { get; }
|
||||
public IMovieController MovieControllerAdapter { get; set; }
|
||||
|
||||
public IMovie Movie { get; set; }
|
||||
|
@ -54,7 +51,6 @@ namespace BizHawk.Client.Common
|
|||
/// <summary>
|
||||
/// Simply shortens the verbosity necessary otherwise
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ILogEntryGenerator LogGeneratorInstance()
|
||||
{
|
||||
return Movie.LogGeneratorInstance();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Common.IOExtensions;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
|
@ -23,10 +24,10 @@ namespace BizHawk.Client.Common
|
|||
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;
|
||||
if (directory_info != null)
|
||||
var directoryInfo = new FileInfo(backupName).Directory;
|
||||
if (directoryInfo != null)
|
||||
{
|
||||
Directory.CreateDirectory(directory_info.FullName);
|
||||
Directory.CreateDirectory(directoryInfo.FullName);
|
||||
}
|
||||
|
||||
Write(backupName, backup: true);
|
||||
|
@ -109,7 +110,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
bl.GetLump(BinaryStateLump.Input, true, delegate(TextReader tr)
|
||||
{
|
||||
var errorMessage = "";
|
||||
string errorMessage;
|
||||
IsCountingRerecords = false;
|
||||
ExtractInputLog(tr, out errorMessage);
|
||||
IsCountingRerecords = true;
|
||||
|
@ -131,10 +132,11 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
SavestateFramebuffer = new int[length / sizeof(int)];
|
||||
for (int i = 0; i < SavestateFramebuffer.Length; i++)
|
||||
{
|
||||
SavestateFramebuffer[i] = br.ReadInt32();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
else if (StartsFromSaveRam)
|
||||
{
|
||||
bl.GetLump(BinaryStateLump.MovieSaveRam, false,
|
||||
|
@ -191,8 +193,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (SavestateFramebuffer != null)
|
||||
{
|
||||
bs.PutLump(BinaryStateLump.Framebuffer,
|
||||
(BinaryWriter bw) => BizHawk.Common.IOExtensions.IOExtensions.Write(bw, SavestateFramebuffer));
|
||||
bs.PutLump(BinaryStateLump.Framebuffer, (BinaryWriter bw) => bw.Write(SavestateFramebuffer));
|
||||
}
|
||||
}
|
||||
else if (StartsFromSaveRam)
|
||||
|
|
|
@ -314,10 +314,10 @@ namespace BizHawk.Client.Common
|
|||
|
||||
/// <summary>
|
||||
/// Takes a log entry from a line in an input log,
|
||||
/// If the log key differs from the system's, it will be coverted
|
||||
/// If the log key differs from the system's, it will be converted
|
||||
/// </summary>
|
||||
/// <param name="line">a log entry line of text from the input log</param>
|
||||
/// <param name="logKey">a log entry line of text from the input log</param>
|
||||
/// <param name="logKey">a key used to describe the mnemonic values and positions in the log</param>
|
||||
private string ConvertLogEntryFromFile(string line, string logKey)
|
||||
{
|
||||
var adapter = new Bk2LogEntryGenerator(logKey).MovieControllerAdapter;
|
||||
|
|
|
@ -484,7 +484,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
foreach (string name in BkmMnemonicConstants.ANALOGS[ControlType].Keys)
|
||||
{
|
||||
Force("P" + player + " " + name, Int32.Parse(mnemonic.Substring(srcindex + start, 4)));
|
||||
Force("P" + player + " " + name, int.Parse(mnemonic.Substring(srcindex + start, 4)));
|
||||
start += 5;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,10 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public partial class BkmMovie
|
||||
{
|
||||
private enum Moviemode { Inactive, Play, Record, Finished }
|
||||
private enum Moviemode
|
||||
{
|
||||
Inactive, Play, Record, Finished
|
||||
}
|
||||
|
||||
private Moviemode _mode = Moviemode.Inactive;
|
||||
|
||||
|
|
|
@ -28,7 +28,8 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
continue;
|
||||
}
|
||||
else if (line[0] == '|')
|
||||
|
||||
if (line[0] == '|')
|
||||
{
|
||||
// TODO: import a frame of input
|
||||
// TODO: report any errors importing this frame and bail out if so
|
||||
|
@ -44,8 +45,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else if (line.ToLower().StartsWith("emuversion"))
|
||||
{
|
||||
Result.Movie.Comments.Add(
|
||||
string.Format("{0} {1} version {2}", EMULATIONORIGIN, emulator, ParseHeader(line, "emuVersion")));
|
||||
Result.Movie.Comments.Add($"{EMULATIONORIGIN} {emulator} version {ParseHeader(line, "emuVersion")}");
|
||||
}
|
||||
else if (line.ToLower().StartsWith("version"))
|
||||
{
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
using BizHawk.Emulation.Cores.Sony.PSX;
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using BizHawk.Emulation.Cores.Sony.PSX;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
[ImportExtension(".pjm")]
|
||||
|
@ -435,8 +436,8 @@ namespace BizHawk.Client.Common
|
|||
protected class MiscHeaderInfo
|
||||
{
|
||||
public bool binaryFormat = true;
|
||||
public UInt32 controllerDataOffset;
|
||||
public UInt32 frameCount;
|
||||
public uint controllerDataOffset;
|
||||
public uint frameCount;
|
||||
public OctoshockDll.ePeripheralType player1Type;
|
||||
public OctoshockDll.ePeripheralType player2Type;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System.IO;
|
||||
|
||||
namespace BizHawk.Client.Common.movie.import
|
||||
namespace BizHawk.Client.Common.Movie.Import
|
||||
{
|
||||
// PXM files are directly compatible with binary-format PJM files, with the only
|
||||
// difference being fewer flags implemented in the header, hence just calling the
|
||||
|
|
|
@ -7,34 +7,32 @@ namespace BizHawk.Client.Common
|
|||
/// <summary>
|
||||
/// Sets the controller source used to generate an input log entry
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
void SetSource(IController source);
|
||||
|
||||
/// <summary>
|
||||
/// Generates an input log entry for the current state of Source
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
string GenerateLogEntry();
|
||||
|
||||
/// <summary>
|
||||
/// Generates a display friendly verion of the input log entry
|
||||
/// Generates a display friendly version of the input log entry
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
string GenerateInputDisplay();
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether or not the current controller state is "empty"
|
||||
/// Gets a value indicating whether or not the current controller state is "empty"
|
||||
/// </summary>
|
||||
bool IsEmpty { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns an input log entry that is considered empty. (booleans will be false, floats will be 0)
|
||||
/// Gets an input log entry that is considered empty. (booleans will be false, floats will be 0)
|
||||
/// </summary>
|
||||
string EmptyEntry { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a movie controller adapter in the same state
|
||||
/// Gets a movie controller adapter in the same state as the log entry
|
||||
/// </summary>
|
||||
/// <seealso cref="IMovieController"/>
|
||||
IMovieController MovieControllerAdapter { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,12 +35,12 @@ namespace BizHawk.Client.Common
|
|||
int InputLogLength { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the file extension for this implementation
|
||||
/// Gets the file extension for the current <see cref="IMovie"/> implementation
|
||||
/// </summary>
|
||||
string PreferredExtension { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Sync Settings from the Core
|
||||
/// Gets or sets the Sync Settings from the Core
|
||||
/// </summary>
|
||||
string SyncSettingsJson { get; set; }
|
||||
|
||||
|
@ -74,7 +74,7 @@ namespace BizHawk.Client.Common
|
|||
bool PreLoadHeaderAndLength(HawkFile hawkFile);
|
||||
|
||||
/// <summary>
|
||||
/// Returns header key value pairs stored in the movie file
|
||||
/// Gets the header key value pairs stored in the movie file
|
||||
/// </summary>
|
||||
IDictionary<string, string> HeaderEntries { get; }
|
||||
|
||||
|
@ -111,7 +111,7 @@ namespace BizHawk.Client.Common
|
|||
/// This is provided as the means for putting the input log into savestates,
|
||||
/// for the purpose of out of order savestate loading (known as "bullet-proof rerecording")
|
||||
/// </summary>
|
||||
/// <returns>returns a string represntation of the input log in its current state</returns>
|
||||
/// <returns>returns a string representation of the input log in its current state</returns>
|
||||
string GetInputLog();
|
||||
|
||||
/// <summary>
|
||||
|
@ -123,7 +123,6 @@ namespace BizHawk.Client.Common
|
|||
/// Gets one frame from the input log.
|
||||
/// </summary>
|
||||
/// <param name="frame">The frame to get.</param>
|
||||
/// <returns></returns>
|
||||
string GetInputLogEntry(int frame);
|
||||
|
||||
/// <summary>
|
||||
|
@ -140,7 +139,6 @@ namespace BizHawk.Client.Common
|
|||
/// </summary>
|
||||
/// <param name="reader">The reader containing the contents of the input log</param>
|
||||
/// <param name="errorMessage">Returns an error message, if any</param>
|
||||
/// <returns></returns>
|
||||
bool ExtractInputLog(TextReader reader, out string errorMessage);
|
||||
|
||||
#endregion
|
||||
|
@ -209,7 +207,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
/// <summary>
|
||||
/// Instructs the movie to remove all input from its input log after frame,
|
||||
/// AFter truncating, frame will be the last frame of input in the movie's input log
|
||||
/// After truncating, frame will be the last frame of input in the movie's input log
|
||||
/// </summary>
|
||||
/// <param name="frame">The frame at which to truncate</param>
|
||||
void Truncate(int frame);
|
||||
|
|
|
@ -132,7 +132,7 @@ namespace BizHawk.Client.Common
|
|||
var header = (dynamic)JsonConvert.DeserializeObject(tr.ReadLine());
|
||||
b.Frame = (int)header.Frame;
|
||||
|
||||
var timestamp = (dynamic)header.TimeStamp;
|
||||
var timestamp = header.TimeStamp;
|
||||
|
||||
if (timestamp != null)
|
||||
{
|
||||
|
@ -143,7 +143,7 @@ namespace BizHawk.Client.Common
|
|||
b.TimeStamp = DateTime.Now;
|
||||
}
|
||||
|
||||
var identifier = (dynamic)header.UniqueIdentifier;
|
||||
var identifier = header.UniqueIdentifier;
|
||||
if (identifier != null)
|
||||
{
|
||||
b.UniqueIdentifier = (Guid)identifier;
|
||||
|
@ -168,7 +168,9 @@ namespace BizHawk.Client.Common
|
|||
b.InputLog = StringLogUtil.MakeStringLog();
|
||||
string line;
|
||||
while ((line = tr.ReadLine()) != null)
|
||||
{
|
||||
b.InputLog.Add(line);
|
||||
}
|
||||
});
|
||||
|
||||
bl.GetLump(nframebuffer, true, delegate(Stream s, long length)
|
||||
|
|
|
@ -19,12 +19,12 @@ namespace BizHawk.Client.Common
|
|||
|
||||
base.RecordFrame(frame, source);
|
||||
|
||||
LagLog.RemoveFrom(frame);
|
||||
LagLog[frame] = Global.Emulator.AsInputPollable().IsLagFrame;
|
||||
_lagLog.RemoveFrom(frame);
|
||||
_lagLog[frame] = Global.Emulator.AsInputPollable().IsLagFrame;
|
||||
|
||||
if (IsRecording)
|
||||
{
|
||||
StateManager.Invalidate(frame + 1);
|
||||
_stateManager.Invalidate(frame + 1);
|
||||
}
|
||||
|
||||
if (frame != 0)
|
||||
|
@ -45,8 +45,8 @@ namespace BizHawk.Client.Common
|
|||
|
||||
base.Truncate(frame);
|
||||
|
||||
LagLog.RemoveFrom(frame);
|
||||
StateManager.Invalidate(frame);
|
||||
_lagLog.RemoveFrom(frame);
|
||||
_stateManager.Invalidate(frame);
|
||||
Markers.TruncateAt(frame);
|
||||
|
||||
ChangeLog.SetGeneralRedo();
|
||||
|
@ -70,7 +70,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
ChangeLog.AddGeneralUndo(frame, frame, "Set Frame At: " + frame);
|
||||
|
||||
base.SetFrameAt(frame, source);
|
||||
SetFrameAt(frame, source);
|
||||
InvalidateAfter(frame);
|
||||
|
||||
ChangeLog.SetGeneralRedo();
|
||||
|
@ -163,6 +163,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
ChangeLog.IsRecording = wasRecording;
|
||||
}
|
||||
}
|
||||
|
@ -367,7 +368,6 @@ namespace BizHawk.Client.Common
|
|||
ChangeLog.IsRecording = wasRecording;
|
||||
}
|
||||
|
||||
|
||||
Changes = true;
|
||||
InvalidateAfter(frame - 1);
|
||||
|
||||
|
@ -534,8 +534,10 @@ namespace BizHawk.Client.Common
|
|||
_log[frame + i] = lg.GenerateLogEntry();
|
||||
|
||||
if (changed == -1 && old != val)
|
||||
{
|
||||
changed = frame + i;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed != -1)
|
||||
{
|
||||
|
@ -550,16 +552,17 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void RemoveLagHistory(int frame)
|
||||
{
|
||||
LagLog.RemoveHistoryAt(frame);
|
||||
_lagLog.RemoveHistoryAt(frame);
|
||||
}
|
||||
|
||||
public void InsertLagHistory(int frame, bool isLag)
|
||||
{
|
||||
LagLog.InsertHistoryAt(frame, isLag);
|
||||
_lagLog.InsertHistoryAt(frame, isLag);
|
||||
}
|
||||
|
||||
public void SetLag(int frame, bool? value)
|
||||
{
|
||||
LagLog[frame] = value;
|
||||
_lagLog[frame] = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -9,23 +9,31 @@ namespace BizHawk.Client.Common
|
|||
private readonly List<List<IMovieAction>> History;
|
||||
public List<string> Names;
|
||||
public int UndoIndex = -1;
|
||||
int _maxSteps = 100;
|
||||
private int _maxSteps = 100;
|
||||
|
||||
public int MaxSteps
|
||||
{
|
||||
get { return _maxSteps; }
|
||||
get
|
||||
{
|
||||
return _maxSteps;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_maxSteps = value;
|
||||
if (History.Count > value)
|
||||
{
|
||||
if (History.Count <= value)
|
||||
{
|
||||
ClearLog();
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearLog(History.Count - value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int _totalSteps = 0;
|
||||
private bool RecordingBatch = false;
|
||||
|
@ -48,17 +56,23 @@ namespace BizHawk.Client.Common
|
|||
public void ClearLog(int upTo = -1)
|
||||
{
|
||||
if (upTo == -1)
|
||||
{
|
||||
upTo = History.Count;
|
||||
}
|
||||
|
||||
History.RemoveRange(0, upTo);
|
||||
Names.RemoveRange(0, upTo);
|
||||
UndoIndex -= upTo;
|
||||
if (UndoIndex < -1)
|
||||
{
|
||||
UndoIndex = -1;
|
||||
}
|
||||
|
||||
if (History.Count == 0)
|
||||
{
|
||||
RecordingBatch = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void TruncateLog(int from)
|
||||
{
|
||||
|
@ -66,7 +80,9 @@ namespace BizHawk.Client.Common
|
|||
Names.RemoveRange(from, Names.Count - from);
|
||||
|
||||
if (UndoIndex < History.Count - 1)
|
||||
{
|
||||
UndoIndex = History.Count - 1;
|
||||
}
|
||||
|
||||
if (RecordingBatch)
|
||||
{
|
||||
|
@ -79,26 +95,34 @@ namespace BizHawk.Client.Common
|
|||
/// All changes made between calling Begin and End will be one Undo.
|
||||
/// If already recording in a batch, calls EndBatch.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the batch</param>
|
||||
/// <param name="keepOldBatch">If set and a batch is in progress, a new batch will not be created.</param>
|
||||
/// <returns>Returns true if a new batch was started; otherwise false.</returns>
|
||||
public bool BeginNewBatch(string name = "", bool keepOldBatch = false)
|
||||
{
|
||||
if (!IsRecording)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret = true;
|
||||
if (RecordingBatch)
|
||||
{
|
||||
if (keepOldBatch)
|
||||
{
|
||||
ret = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
EndBatch();
|
||||
}
|
||||
}
|
||||
|
||||
if (ret)
|
||||
{
|
||||
ret = AddMovieAction(name);
|
||||
}
|
||||
|
||||
RecordingBatch = true;
|
||||
|
||||
return ret;
|
||||
|
@ -111,7 +135,9 @@ namespace BizHawk.Client.Common
|
|||
public void EndBatch()
|
||||
{
|
||||
if (!IsRecording || !RecordingBatch)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RecordingBatch = false;
|
||||
List<IMovieAction> last = History.Last();
|
||||
|
@ -122,8 +148,10 @@ namespace BizHawk.Client.Common
|
|||
UndoIndex--;
|
||||
}
|
||||
else
|
||||
{
|
||||
last.Capacity = last.Count;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Undoes the most recent action batch, if any exist.
|
||||
|
@ -132,11 +160,16 @@ namespace BizHawk.Client.Common
|
|||
public int Undo()
|
||||
{
|
||||
if (UndoIndex == -1)
|
||||
{
|
||||
return Movie.InputLogLength;
|
||||
}
|
||||
|
||||
List<IMovieAction> batch = History[UndoIndex];
|
||||
for (int i = batch.Count - 1; i >= 0; i--)
|
||||
{
|
||||
batch[i].Undo(Movie);
|
||||
}
|
||||
|
||||
UndoIndex--;
|
||||
|
||||
RecordingBatch = false;
|
||||
|
@ -156,12 +189,16 @@ namespace BizHawk.Client.Common
|
|||
public int Redo()
|
||||
{
|
||||
if (UndoIndex == History.Count - 1)
|
||||
{
|
||||
return Movie.InputLogLength;
|
||||
}
|
||||
|
||||
UndoIndex++;
|
||||
List<IMovieAction> batch = History[UndoIndex];
|
||||
for (int i = 0; i < batch.Count; i++)
|
||||
batch[i].Redo(Movie);
|
||||
foreach (IMovieAction b in batch)
|
||||
{
|
||||
b.Redo(Movie);
|
||||
}
|
||||
|
||||
RecordingBatch = false;
|
||||
|
||||
|
@ -268,7 +305,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
// TODO: These probably aren't the best way to handle undo/redo.
|
||||
private int lastGeneral;
|
||||
private int _lastGeneral;
|
||||
|
||||
public void AddGeneralUndo(int first, int last, string name = "", bool force = false)
|
||||
{
|
||||
|
@ -276,7 +313,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
AddMovieAction(name);
|
||||
History.Last().Add(new MovieAction(first, last, Movie));
|
||||
lastGeneral = History.Last().Count - 1;
|
||||
_lastGeneral = History.Last().Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -284,7 +321,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (IsRecording || force)
|
||||
{
|
||||
(History.Last()[lastGeneral] as MovieAction).SetRedoLog(Movie);
|
||||
(History.Last()[_lastGeneral] as MovieAction).SetRedoLog(Movie);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -311,9 +348,13 @@ namespace BizHawk.Client.Common
|
|||
if (IsRecording || force)
|
||||
{
|
||||
if (oldPosition == -1)
|
||||
{
|
||||
name = "Set Marker at frame " + newMarker.Frame;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = "Remove Marker at frame " + oldPosition;
|
||||
}
|
||||
|
||||
AddMovieAction(name);
|
||||
History.Last().Add(new MovieActionMarker(newMarker, oldPosition, old_message));
|
||||
|
@ -348,37 +389,37 @@ namespace BizHawk.Client.Common
|
|||
public int FirstFrame { get; }
|
||||
public int LastFrame { get; }
|
||||
|
||||
private int undoLength;
|
||||
private int redoLength;
|
||||
private readonly int _undoLength;
|
||||
private int _redoLength;
|
||||
|
||||
private int length => LastFrame - FirstFrame + 1;
|
||||
|
||||
private List<string> oldLog;
|
||||
private List<string> newLog;
|
||||
private bool bindMarkers;
|
||||
private readonly List<string> _oldLog;
|
||||
private List<string> _newLog;
|
||||
private readonly bool _bindMarkers;
|
||||
|
||||
public MovieAction(int firstFrame, int lastFrame, TasMovie movie)
|
||||
{
|
||||
FirstFrame = firstFrame;
|
||||
LastFrame = lastFrame;
|
||||
oldLog = new List<string>(length);
|
||||
undoLength = Math.Min(LastFrame + 1, movie.InputLogLength) - FirstFrame;
|
||||
_oldLog = new List<string>(length);
|
||||
_undoLength = Math.Min(LastFrame + 1, movie.InputLogLength) - FirstFrame;
|
||||
|
||||
for (int i = 0; i < undoLength; i++)
|
||||
for (int i = 0; i < _undoLength; i++)
|
||||
{
|
||||
oldLog.Add(movie.GetLogEntries()[FirstFrame + i]);
|
||||
_oldLog.Add(movie.GetLogEntries()[FirstFrame + i]);
|
||||
}
|
||||
|
||||
bindMarkers = movie.BindMarkersToInput;
|
||||
_bindMarkers = movie.BindMarkersToInput;
|
||||
}
|
||||
|
||||
public void SetRedoLog(TasMovie movie)
|
||||
{
|
||||
redoLength = Math.Min(LastFrame + 1, movie.InputLogLength) - FirstFrame;
|
||||
newLog = new List<string>();
|
||||
for (int i = 0; i < redoLength; i++)
|
||||
_redoLength = Math.Min(LastFrame + 1, movie.InputLogLength) - FirstFrame;
|
||||
_newLog = new List<string>();
|
||||
for (int i = 0; i < _redoLength; i++)
|
||||
{
|
||||
newLog.Add(movie.GetLogEntries()[FirstFrame + i]);
|
||||
_newLog.Add(movie.GetLogEntries()[FirstFrame + i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,18 +428,25 @@ namespace BizHawk.Client.Common
|
|||
bool wasRecording = movie.ChangeLog.IsRecording;
|
||||
bool wasBinding = movie.BindMarkersToInput;
|
||||
movie.ChangeLog.IsRecording = false;
|
||||
movie.BindMarkersToInput = bindMarkers;
|
||||
movie.BindMarkersToInput = _bindMarkers;
|
||||
|
||||
if (redoLength != length)
|
||||
movie.InsertEmptyFrame(FirstFrame, length - redoLength, true);
|
||||
if (undoLength != length)
|
||||
movie.RemoveFrames(FirstFrame, movie.InputLogLength - undoLength, true);
|
||||
if (_redoLength != length)
|
||||
{
|
||||
movie.InsertEmptyFrame(FirstFrame, length - _redoLength, true);
|
||||
}
|
||||
|
||||
for (int i = 0; i < undoLength; i++)
|
||||
movie.SetFrame(FirstFrame + i, oldLog[i]);
|
||||
if (_undoLength != length)
|
||||
{
|
||||
movie.RemoveFrames(FirstFrame, movie.InputLogLength - _undoLength, true);
|
||||
}
|
||||
|
||||
for (int i = 0; i < _undoLength; i++)
|
||||
{
|
||||
movie.SetFrame(FirstFrame + i, _oldLog[i]);
|
||||
}
|
||||
|
||||
movie.ChangeLog.IsRecording = wasRecording;
|
||||
movie.BindMarkersToInput = bindMarkers;
|
||||
movie.BindMarkersToInput = _bindMarkers;
|
||||
}
|
||||
|
||||
public void Redo(TasMovie movie)
|
||||
|
@ -406,18 +454,24 @@ namespace BizHawk.Client.Common
|
|||
bool wasRecording = movie.ChangeLog.IsRecording;
|
||||
bool wasBinding = movie.BindMarkersToInput;
|
||||
movie.ChangeLog.IsRecording = false;
|
||||
movie.BindMarkersToInput = bindMarkers;
|
||||
movie.BindMarkersToInput = _bindMarkers;
|
||||
|
||||
if (undoLength != length)
|
||||
movie.InsertEmptyFrame(FirstFrame, length - undoLength);
|
||||
if (redoLength != length)
|
||||
movie.RemoveFrames(FirstFrame, movie.InputLogLength - redoLength);
|
||||
if (_undoLength != length)
|
||||
{
|
||||
movie.InsertEmptyFrame(FirstFrame, length - _undoLength);
|
||||
}
|
||||
if (_redoLength != length)
|
||||
{
|
||||
movie.RemoveFrames(FirstFrame, movie.InputLogLength - _redoLength);
|
||||
}
|
||||
|
||||
for (int i = 0; i < redoLength; i++)
|
||||
movie.SetFrame(FirstFrame + i, newLog[i]);
|
||||
for (int i = 0; i < _redoLength; i++)
|
||||
{
|
||||
movie.SetFrame(FirstFrame + i, _newLog[i]);
|
||||
}
|
||||
|
||||
movie.ChangeLog.IsRecording = wasRecording;
|
||||
movie.BindMarkersToInput = bindMarkers;
|
||||
movie.BindMarkersToInput = _bindMarkers;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -426,8 +480,8 @@ namespace BizHawk.Client.Common
|
|||
public int FirstFrame { get; }
|
||||
public int LastFrame { get; }
|
||||
|
||||
private string oldMessage;
|
||||
private string newMessage;
|
||||
private readonly string _oldMessage;
|
||||
private readonly string _newMessage;
|
||||
|
||||
public MovieActionMarker(TasMovieMarker marker, int oldPosition = -1, string old_message = "")
|
||||
{
|
||||
|
@ -435,69 +489,77 @@ namespace BizHawk.Client.Common
|
|||
if (marker == null)
|
||||
{
|
||||
LastFrame = -1;
|
||||
oldMessage = old_message;
|
||||
_oldMessage = old_message;
|
||||
}
|
||||
else
|
||||
{
|
||||
LastFrame = marker.Frame;
|
||||
if (old_message == "")
|
||||
oldMessage = marker.Message;
|
||||
else
|
||||
oldMessage = old_message;
|
||||
newMessage = marker.Message;
|
||||
_oldMessage = old_message == "" ? marker.Message : old_message;
|
||||
_newMessage = marker.Message;
|
||||
}
|
||||
}
|
||||
|
||||
public void Undo(TasMovie movie)
|
||||
{
|
||||
if (FirstFrame == -1) // Action: Place marker
|
||||
{
|
||||
movie.Markers.Remove(movie.Markers.Get(LastFrame), true);
|
||||
}
|
||||
else if (LastFrame == -1) // Action: Remove marker
|
||||
movie.Markers.Add(FirstFrame, oldMessage, true);
|
||||
{
|
||||
movie.Markers.Add(FirstFrame, _oldMessage, true);
|
||||
}
|
||||
else // Action: Move/rename marker
|
||||
{
|
||||
movie.Markers.Move(LastFrame, FirstFrame, true);
|
||||
movie.Markers.Get(LastFrame).Message = oldMessage;
|
||||
movie.Markers.Get(LastFrame).Message = _oldMessage;
|
||||
}
|
||||
}
|
||||
|
||||
public void Redo(TasMovie movie)
|
||||
{
|
||||
if (FirstFrame == -1) // Action: Place marker
|
||||
movie.Markers.Add(LastFrame, oldMessage, true);
|
||||
{
|
||||
movie.Markers.Add(LastFrame, _oldMessage, true);
|
||||
}
|
||||
else if (LastFrame == -1) // Action: Remove marker
|
||||
{
|
||||
movie.Markers.Remove(movie.Markers.Get(FirstFrame), true);
|
||||
}
|
||||
else // Action: Move/rename marker
|
||||
{
|
||||
movie.Markers.Move(FirstFrame, LastFrame, true);
|
||||
movie.Markers.Get(LastFrame).Message = newMessage;
|
||||
movie.Markers.Get(LastFrame).Message = _newMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MovieActionFrameEdit : IMovieAction
|
||||
{
|
||||
public int FirstFrame { get; private set; }
|
||||
public int LastFrame { get { return FirstFrame; } }
|
||||
private float oldState, newState;
|
||||
private string buttonName;
|
||||
private bool isFloat = false;
|
||||
public int FirstFrame { get; }
|
||||
public int LastFrame => FirstFrame;
|
||||
|
||||
private readonly float _oldState;
|
||||
private readonly float _newState;
|
||||
|
||||
private readonly string _buttonName;
|
||||
private readonly bool _isFloat;
|
||||
|
||||
public MovieActionFrameEdit(int frame, string button, bool oldS, bool newS)
|
||||
{
|
||||
oldState = oldS ? 1 : 0;
|
||||
newState = newS ? 1 : 0;
|
||||
_oldState = oldS ? 1 : 0;
|
||||
_newState = newS ? 1 : 0;
|
||||
FirstFrame = frame;
|
||||
buttonName = button;
|
||||
_buttonName = button;
|
||||
}
|
||||
|
||||
public MovieActionFrameEdit(int frame, string button, float oldS, float newS)
|
||||
{
|
||||
oldState = oldS;
|
||||
newState = newS;
|
||||
_oldState = oldS;
|
||||
_newState = newS;
|
||||
FirstFrame = frame;
|
||||
buttonName = button;
|
||||
isFloat = true;
|
||||
_buttonName = button;
|
||||
_isFloat = true;
|
||||
}
|
||||
|
||||
public void Undo(TasMovie movie)
|
||||
|
@ -505,10 +567,14 @@ namespace BizHawk.Client.Common
|
|||
bool wasRecording = movie.ChangeLog.IsRecording;
|
||||
movie.ChangeLog.IsRecording = false;
|
||||
|
||||
if (isFloat)
|
||||
movie.SetFloatState(FirstFrame, buttonName, oldState);
|
||||
if (_isFloat)
|
||||
{
|
||||
movie.SetFloatState(FirstFrame, _buttonName, _oldState);
|
||||
}
|
||||
else
|
||||
movie.SetBoolState(FirstFrame, buttonName, oldState == 1);
|
||||
{
|
||||
movie.SetBoolState(FirstFrame, _buttonName, _oldState == 1);
|
||||
}
|
||||
|
||||
movie.ChangeLog.IsRecording = wasRecording;
|
||||
}
|
||||
|
@ -518,10 +584,14 @@ namespace BizHawk.Client.Common
|
|||
bool wasRecording = movie.ChangeLog.IsRecording;
|
||||
movie.ChangeLog.IsRecording = false;
|
||||
|
||||
if (isFloat)
|
||||
movie.SetFloatState(FirstFrame, buttonName, newState);
|
||||
if (_isFloat)
|
||||
{
|
||||
movie.SetFloatState(FirstFrame, _buttonName, _newState);
|
||||
}
|
||||
else
|
||||
movie.SetBoolState(FirstFrame, buttonName, newState == 1);
|
||||
{
|
||||
movie.SetBoolState(FirstFrame, _buttonName, _newState == 1);
|
||||
}
|
||||
|
||||
movie.ChangeLog.IsRecording = wasRecording;
|
||||
}
|
||||
|
@ -529,36 +599,40 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public class MovieActionPaint : IMovieAction
|
||||
{
|
||||
public int FirstFrame { get; private set; }
|
||||
public int LastFrame { get; private set; }
|
||||
private List<float> oldState;
|
||||
private float newState;
|
||||
private string buttonName;
|
||||
private bool isFloat = false;
|
||||
public int FirstFrame { get; }
|
||||
public int LastFrame { get; }
|
||||
private readonly List<float> _oldState;
|
||||
private readonly float _newState;
|
||||
private readonly string _buttonName;
|
||||
private readonly bool _isFloat = false;
|
||||
|
||||
public MovieActionPaint(int startFrame, int endFrame, string button, bool newS, TasMovie movie)
|
||||
{
|
||||
newState = newS ? 1 : 0;
|
||||
_newState = newS ? 1 : 0;
|
||||
FirstFrame = startFrame;
|
||||
LastFrame = endFrame;
|
||||
buttonName = button;
|
||||
oldState = new List<float>(endFrame - startFrame + 1);
|
||||
_buttonName = button;
|
||||
_oldState = new List<float>(endFrame - startFrame + 1);
|
||||
|
||||
for (int i = 0; i < endFrame - startFrame + 1; i++)
|
||||
oldState.Add(movie.BoolIsPressed(startFrame + i, button) ? 1 : 0);
|
||||
{
|
||||
_oldState.Add(movie.BoolIsPressed(startFrame + i, button) ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
public MovieActionPaint(int startFrame, int endFrame, string button, float newS, TasMovie movie)
|
||||
{
|
||||
newState = newS;
|
||||
_newState = newS;
|
||||
FirstFrame = startFrame;
|
||||
LastFrame = endFrame;
|
||||
buttonName = button;
|
||||
isFloat = true;
|
||||
oldState = new List<float>(endFrame - startFrame + 1);
|
||||
_buttonName = button;
|
||||
_isFloat = true;
|
||||
_oldState = new List<float>(endFrame - startFrame + 1);
|
||||
|
||||
for (int i = 0; i < endFrame - startFrame + 1; i++)
|
||||
oldState.Add(movie.BoolIsPressed(startFrame + i, button) ? 1 : 0);
|
||||
{
|
||||
_oldState.Add(movie.BoolIsPressed(startFrame + i, button) ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void Undo(TasMovie movie)
|
||||
|
@ -566,15 +640,19 @@ namespace BizHawk.Client.Common
|
|||
bool wasRecording = movie.ChangeLog.IsRecording;
|
||||
movie.ChangeLog.IsRecording = false;
|
||||
|
||||
if (isFloat)
|
||||
if (_isFloat)
|
||||
{
|
||||
for (int i = 0; i < oldState.Count; i++)
|
||||
movie.SetFloatState(FirstFrame + i, buttonName, oldState[i]);
|
||||
for (int i = 0; i < _oldState.Count; i++)
|
||||
{
|
||||
movie.SetFloatState(FirstFrame + i, _buttonName, _oldState[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < oldState.Count; i++)
|
||||
movie.SetBoolState(FirstFrame + i, buttonName, oldState[i] == 1);
|
||||
for (int i = 0; i < _oldState.Count; i++)
|
||||
{
|
||||
movie.SetBoolState(FirstFrame + i, _buttonName, _oldState[i] == 1);
|
||||
}
|
||||
}
|
||||
|
||||
movie.ChangeLog.IsRecording = wasRecording;
|
||||
|
@ -585,10 +663,14 @@ namespace BizHawk.Client.Common
|
|||
bool wasRecording = movie.ChangeLog.IsRecording;
|
||||
movie.ChangeLog.IsRecording = false;
|
||||
|
||||
if (isFloat)
|
||||
movie.SetFloatStates(FirstFrame, LastFrame - FirstFrame + 1, buttonName, newState);
|
||||
if (_isFloat)
|
||||
{
|
||||
movie.SetFloatStates(FirstFrame, LastFrame - FirstFrame + 1, _buttonName, _newState);
|
||||
}
|
||||
else
|
||||
movie.SetBoolStates(FirstFrame, LastFrame - FirstFrame + 1, buttonName, newState == 1);
|
||||
{
|
||||
movie.SetBoolStates(FirstFrame, LastFrame - FirstFrame + 1, _buttonName, _newState == 1);
|
||||
}
|
||||
|
||||
movie.ChangeLog.IsRecording = wasRecording;
|
||||
}
|
||||
|
@ -596,20 +678,20 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public class MovieActionBindInput : IMovieAction
|
||||
{
|
||||
public int FirstFrame { get; private set; }
|
||||
public int LastFrame { get; private set; }
|
||||
public int FirstFrame { get; }
|
||||
public int LastFrame { get; }
|
||||
|
||||
private string log;
|
||||
private bool delete;
|
||||
private readonly string _log;
|
||||
private readonly bool _delete;
|
||||
|
||||
private bool bindMarkers;
|
||||
private readonly bool _bindMarkers;
|
||||
|
||||
public MovieActionBindInput(TasMovie movie, int frame, bool isDelete)
|
||||
{
|
||||
FirstFrame = LastFrame = frame;
|
||||
log = movie.GetInputLogEntry(frame);
|
||||
delete = isDelete;
|
||||
bindMarkers = movie.BindMarkersToInput;
|
||||
_log = movie.GetInputLogEntry(frame);
|
||||
_delete = isDelete;
|
||||
_bindMarkers = movie.BindMarkersToInput;
|
||||
}
|
||||
|
||||
public void Undo(TasMovie movie)
|
||||
|
@ -617,11 +699,11 @@ namespace BizHawk.Client.Common
|
|||
bool wasRecording = movie.ChangeLog.IsRecording;
|
||||
bool wasBinding = movie.BindMarkersToInput;
|
||||
movie.ChangeLog.IsRecording = false;
|
||||
movie.BindMarkersToInput = bindMarkers;
|
||||
movie.BindMarkersToInput = _bindMarkers;
|
||||
|
||||
if (delete) // Insert
|
||||
if (_delete) // Insert
|
||||
{
|
||||
movie.InsertInput(FirstFrame, log);
|
||||
movie.InsertInput(FirstFrame, _log);
|
||||
movie.InsertLagHistory(FirstFrame + 1, true);
|
||||
}
|
||||
else // Delete
|
||||
|
@ -631,7 +713,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
movie.ChangeLog.IsRecording = wasRecording;
|
||||
movie.BindMarkersToInput = bindMarkers;
|
||||
movie.BindMarkersToInput = _bindMarkers;
|
||||
}
|
||||
|
||||
public void Redo(TasMovie movie)
|
||||
|
@ -639,21 +721,21 @@ namespace BizHawk.Client.Common
|
|||
bool wasRecording = movie.ChangeLog.IsRecording;
|
||||
bool wasBinding = movie.BindMarkersToInput;
|
||||
movie.ChangeLog.IsRecording = false;
|
||||
movie.BindMarkersToInput = bindMarkers;
|
||||
movie.BindMarkersToInput = _bindMarkers;
|
||||
|
||||
if (delete)
|
||||
if (_delete)
|
||||
{
|
||||
movie.RemoveFrame(FirstFrame);
|
||||
movie.RemoveLagHistory(FirstFrame + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
movie.InsertInput(FirstFrame, log);
|
||||
movie.InsertInput(FirstFrame, _log);
|
||||
movie.InsertLagHistory(FirstFrame + 1, true);
|
||||
}
|
||||
|
||||
movie.ChangeLog.IsRecording = wasRecording;
|
||||
movie.BindMarkersToInput = bindMarkers;
|
||||
movie.BindMarkersToInput = _bindMarkers;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,9 +27,9 @@ namespace BizHawk.Client.Common
|
|||
bs.PutLump(BinaryStateLump.Input, tw => WriteInputLog(tw));
|
||||
|
||||
// TasProj extras
|
||||
bs.PutLump(BinaryStateLump.StateHistorySettings, tw => tw.WriteLine(StateManager.Settings.ToString()));
|
||||
bs.PutLump(BinaryStateLump.StateHistorySettings, tw => tw.WriteLine(_stateManager.Settings.ToString()));
|
||||
|
||||
bs.PutLump(BinaryStateLump.LagLog, (BinaryWriter bw) => LagLog.Save(bw));
|
||||
bs.PutLump(BinaryStateLump.LagLog, (BinaryWriter bw) => _lagLog.Save(bw));
|
||||
bs.PutLump(BinaryStateLump.Markers, tw => tw.WriteLine(Markers.ToString()));
|
||||
|
||||
if (StartsFromSavestate)
|
||||
|
@ -62,17 +62,17 @@ namespace BizHawk.Client.Common
|
|||
if (Branches.Any())
|
||||
{
|
||||
Branches.Save(bs);
|
||||
if (StateManager.Settings.BranchStatesInTasproj)
|
||||
if (_stateManager.Settings.BranchStatesInTasproj)
|
||||
{
|
||||
bs.PutLump(BinaryStateLump.BranchStateHistory, (BinaryWriter bw) => StateManager.SaveBranchStates(bw));
|
||||
bs.PutLump(BinaryStateLump.BranchStateHistory, (BinaryWriter bw) => _stateManager.SaveBranchStates(bw));
|
||||
}
|
||||
}
|
||||
|
||||
bs.PutLump(BinaryStateLump.Session, tw => tw.WriteLine(Session.ToString()));
|
||||
|
||||
if (StateManager.Settings.SaveStateHistory)
|
||||
if (_stateManager.Settings.SaveStateHistory)
|
||||
{
|
||||
bs.PutLump(BinaryStateLump.StateHistory, (BinaryWriter bw) => StateManager.Save(bw));
|
||||
bs.PutLump(BinaryStateLump.StateHistory, (BinaryWriter bw) => _stateManager.Save(bw));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,12 +183,12 @@ namespace BizHawk.Client.Common
|
|||
// TasMovie enhanced information
|
||||
bl.GetLump(BinaryStateLump.LagLog, false, delegate(BinaryReader br, long length)
|
||||
{
|
||||
LagLog.Load(br);
|
||||
_lagLog.Load(br);
|
||||
});
|
||||
|
||||
bl.GetLump(BinaryStateLump.StateHistorySettings, false, delegate(TextReader tr)
|
||||
{
|
||||
StateManager.Settings.PopulateFromString(tr.ReadToEnd());
|
||||
_stateManager.Settings.PopulateFromString(tr.ReadToEnd());
|
||||
});
|
||||
|
||||
bl.GetLump(BinaryStateLump.Markers, false, delegate(TextReader tr)
|
||||
|
@ -243,11 +243,11 @@ namespace BizHawk.Client.Common
|
|||
});
|
||||
|
||||
Branches.Load(bl, this);
|
||||
if (StateManager.Settings.BranchStatesInTasproj)
|
||||
if (_stateManager.Settings.BranchStatesInTasproj)
|
||||
{
|
||||
bl.GetLump(BinaryStateLump.BranchStateHistory, false, delegate(BinaryReader br, long length)
|
||||
{
|
||||
StateManager.LoadBranchStates(br);
|
||||
_stateManager.LoadBranchStates(br);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -258,17 +258,17 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (!preload)
|
||||
{
|
||||
if (StateManager.Settings.SaveStateHistory)
|
||||
if (_stateManager.Settings.SaveStateHistory)
|
||||
{
|
||||
bl.GetLump(BinaryStateLump.StateHistory, false, delegate(BinaryReader br, long length)
|
||||
{
|
||||
StateManager.Load(br);
|
||||
_stateManager.Load(br);
|
||||
});
|
||||
}
|
||||
|
||||
// Movie should always have a state at frame 0.
|
||||
if (!StartsFromSavestate && Global.Emulator.Frame == 0)
|
||||
StateManager.Capture();
|
||||
_stateManager.Capture();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -278,8 +278,8 @@ namespace BizHawk.Client.Common
|
|||
|
||||
private void ClearTasprojExtras()
|
||||
{
|
||||
LagLog.Clear();
|
||||
StateManager.Clear();
|
||||
_lagLog.Clear();
|
||||
_stateManager.Clear();
|
||||
Markers.Clear();
|
||||
ChangeLog.ClearLog();
|
||||
}
|
||||
|
|
|
@ -12,37 +12,45 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public sealed partial class TasMovie : Bk2Movie, INotifyPropertyChanged
|
||||
{
|
||||
private readonly Bk2MnemonicConstants _mnemonics = new Bk2MnemonicConstants();
|
||||
private readonly TasStateManager _stateManager;
|
||||
private readonly TasLagLog _lagLog = new TasLagLog();
|
||||
private readonly Dictionary<int, IController> _inputStateCache = new Dictionary<int, IController>();
|
||||
|
||||
private BackgroundWorker _progressReportWorker;
|
||||
|
||||
public new const string Extension = "tasproj";
|
||||
public const string DefaultProjectName = "default";
|
||||
public BackgroundWorker _progressReportWorker = null;
|
||||
public bool LastPositionStable = true;
|
||||
public string NewBranchText = "";
|
||||
|
||||
public bool LastPositionStable { get; set; } = true;
|
||||
public string NewBranchText { get; set; } = "";
|
||||
|
||||
public readonly IStringLog VerificationLog = StringLogUtil.MakeStringLog(); // For movies that do not begin with power-on, this is the input required to get into the initial state
|
||||
public readonly TasBranchCollection Branches = new TasBranchCollection();
|
||||
public readonly TasSession Session;
|
||||
private readonly Bk2MnemonicConstants Mnemonics = new Bk2MnemonicConstants();
|
||||
private readonly TasStateManager StateManager;
|
||||
private readonly TasLagLog LagLog = new TasLagLog();
|
||||
private readonly Dictionary<int, IController> InputStateCache = new Dictionary<int, IController>();
|
||||
public TasLagLog TasLagLog { get { return LagLog; } }
|
||||
public IStringLog InputLog { get { return _log; } }
|
||||
public TasMovieMarkerList Markers { get; set; }
|
||||
|
||||
public TasLagLog TasLagLog => _lagLog;
|
||||
|
||||
public IStringLog InputLog => _log;
|
||||
|
||||
public TasMovieMarkerList Markers { get; private set; }
|
||||
|
||||
public bool BindMarkersToInput { get; set; }
|
||||
public bool UseInputCache { get; set; }
|
||||
public int CurrentBranch { get; set; }
|
||||
|
||||
public int BranchCount => Branches.Count;
|
||||
public int LastValidFrame => LagLog.LastValidFrame;
|
||||
public int LastValidFrame => _lagLog.LastValidFrame;
|
||||
public override string PreferredExtension => Extension;
|
||||
public TasStateManager TasStateManager => StateManager;
|
||||
public TasStateManager TasStateManager => _stateManager;
|
||||
|
||||
public TasMovieRecord this[int index] => new TasMovieRecord
|
||||
{
|
||||
// State = StateManager[index],
|
||||
HasState = StateManager.HasState(index),
|
||||
HasState = _stateManager.HasState(index),
|
||||
LogEntry = GetInputLogEntry(index),
|
||||
Lagged = LagLog[index + 1],
|
||||
WasLagged = LagLog.History(index + 1)
|
||||
Lagged = _lagLog[index + 1],
|
||||
WasLagged = _lagLog.History(index + 1)
|
||||
};
|
||||
|
||||
public TasMovie(string path, bool startsFromSavestate = false, BackgroundWorker progressReportWorker = null)
|
||||
|
@ -56,7 +64,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
ChangeLog = new TasMovieChangeLog(this);
|
||||
StateManager = new TasStateManager(this);
|
||||
_stateManager = new TasStateManager(this);
|
||||
Session = new TasSession(this);
|
||||
Header[HeaderKeys.MOVIEVERSION] = "BizHawk v2.0 Tasproj v1.0";
|
||||
Markers = new TasMovieMarkerList(this);
|
||||
|
@ -75,7 +83,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
ChangeLog = new TasMovieChangeLog(this);
|
||||
StateManager = new TasStateManager(this);
|
||||
_stateManager = new TasStateManager(this);
|
||||
Session = new TasSession(this);
|
||||
Header[HeaderKeys.MOVIEVERSION] = "BizHawk v2.0 Tasproj v1.0";
|
||||
Markers = new TasMovieMarkerList(this);
|
||||
|
@ -145,8 +153,8 @@ namespace BizHawk.Client.Common
|
|||
/// <param name="frame">The last frame that can be valid.</param>
|
||||
private void InvalidateAfter(int frame)
|
||||
{
|
||||
var anyInvalidated = LagLog.RemoveFrom(frame);
|
||||
StateManager.Invalidate(frame + 1);
|
||||
var anyInvalidated = _lagLog.RemoveFrom(frame);
|
||||
_stateManager.Invalidate(frame + 1);
|
||||
Changes = true; // TODO check if this actually removed anything before flagging changes
|
||||
|
||||
if (anyInvalidated && Global.MovieSession.Movie.IsCountingRerecords)
|
||||
|
@ -161,16 +169,16 @@ namespace BizHawk.Client.Common
|
|||
/// </summary>
|
||||
public string DisplayValue(int frame, string buttonName)
|
||||
{
|
||||
if (UseInputCache && InputStateCache.ContainsKey(frame))
|
||||
if (UseInputCache && _inputStateCache.ContainsKey(frame))
|
||||
{
|
||||
return CreateDisplayValueForButton(InputStateCache[frame], buttonName);
|
||||
return CreateDisplayValueForButton(_inputStateCache[frame], buttonName);
|
||||
}
|
||||
|
||||
var adapter = GetInputState(frame);
|
||||
|
||||
if (UseInputCache)
|
||||
{
|
||||
InputStateCache.Add(frame, adapter);
|
||||
_inputStateCache.Add(frame, adapter);
|
||||
}
|
||||
|
||||
return CreateDisplayValueForButton(adapter, buttonName);
|
||||
|
@ -178,7 +186,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void FlushInputCache()
|
||||
{
|
||||
InputStateCache.Clear();
|
||||
_inputStateCache.Clear();
|
||||
}
|
||||
|
||||
public string CreateDisplayValueForButton(IController adapter, string buttonName)
|
||||
|
@ -186,7 +194,7 @@ namespace BizHawk.Client.Common
|
|||
if (adapter.Definition.BoolButtons.Contains(buttonName))
|
||||
{
|
||||
return adapter.IsPressed(buttonName)
|
||||
? Mnemonics[buttonName].ToString()
|
||||
? _mnemonics[buttonName].ToString()
|
||||
: "";
|
||||
}
|
||||
|
||||
|
@ -212,9 +220,9 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void ClearGreenzone()
|
||||
{
|
||||
if (StateManager.Any())
|
||||
if (_stateManager.Any())
|
||||
{
|
||||
StateManager.ClearStateHistory();
|
||||
_stateManager.ClearStateHistory();
|
||||
Changes = true;
|
||||
}
|
||||
}
|
||||
|
@ -227,17 +235,17 @@ namespace BizHawk.Client.Common
|
|||
LastPositionStable = false;
|
||||
}
|
||||
|
||||
LagLog[Global.Emulator.Frame] = Global.Emulator.AsInputPollable().IsLagFrame;
|
||||
_lagLog[Global.Emulator.Frame] = Global.Emulator.AsInputPollable().IsLagFrame;
|
||||
|
||||
if (!StateManager.HasState(Global.Emulator.Frame))
|
||||
if (!_stateManager.HasState(Global.Emulator.Frame))
|
||||
{
|
||||
StateManager.Capture();
|
||||
_stateManager.Capture();
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearLagLog()
|
||||
{
|
||||
LagLog.Clear();
|
||||
_lagLog.Clear();
|
||||
}
|
||||
|
||||
public void DeleteLogBefore(int frame)
|
||||
|
@ -426,7 +434,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (TimelineBranchFrame.HasValue)
|
||||
{
|
||||
LagLog.RemoveFrom(TimelineBranchFrame.Value);
|
||||
_lagLog.RemoveFrom(TimelineBranchFrame.Value);
|
||||
TasStateManager.Invalidate(TimelineBranchFrame.Value);
|
||||
}
|
||||
|
||||
|
@ -512,16 +520,16 @@ namespace BizHawk.Client.Common
|
|||
// but if there's none, or only *after* divergent point, don't invalidate the entire movie anymore
|
||||
if (divergentPoint.HasValue)
|
||||
{
|
||||
StateManager.Invalidate(divergentPoint.Value);
|
||||
LagLog.FromLagLog(branch.LagLog); // don't truncate LagLog if the branch's one is shorter, but input is the same
|
||||
_stateManager.Invalidate(divergentPoint.Value);
|
||||
_lagLog.FromLagLog(branch.LagLog); // don't truncate LagLog if the branch's one is shorter, but input is the same
|
||||
}
|
||||
else
|
||||
{
|
||||
StateManager.Invalidate(branch.InputLog.Count);
|
||||
_stateManager.Invalidate(branch.InputLog.Count);
|
||||
}
|
||||
|
||||
StateManager.LoadBranch(Branches.IndexOf(branch));
|
||||
StateManager.SetState(branch.Frame, branch.CoreData);
|
||||
_stateManager.LoadBranch(Branches.IndexOf(branch));
|
||||
_stateManager.SetState(branch.Frame, branch.CoreData);
|
||||
|
||||
////ChangeLog = branch.ChangeLog;
|
||||
if (BindMarkersToInput) // pretty critical not to erase them
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses a Marker from a line of text
|
||||
/// Initializes a new instance of the <see cref="TasMovieMarker"/> class from a line of text
|
||||
/// </summary>
|
||||
public TasMovieMarker(string line)
|
||||
{
|
||||
|
|
|
@ -666,7 +666,9 @@ namespace BizHawk.Client.Common
|
|||
////Used += len;
|
||||
}
|
||||
}
|
||||
catch (EndOfStreamException) { }
|
||||
catch (EndOfStreamException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveBranchStates(BinaryWriter bw)
|
||||
|
@ -707,7 +709,10 @@ namespace BizHawk.Client.Common
|
|||
c--;
|
||||
}
|
||||
}
|
||||
catch (EndOfStreamException) { } // Bad!
|
||||
catch (EndOfStreamException)
|
||||
{
|
||||
// Bad!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,45 +32,45 @@ namespace BizHawk.Client.Common
|
|||
/// </summary>
|
||||
[DisplayName("Save History")]
|
||||
[Description("Whether or not to use savestate history")]
|
||||
public bool SaveStateHistory { get { return DiskSaveCapacitymb != 0; } }
|
||||
public bool SaveStateHistory => DiskSaveCapacitymb != 0;
|
||||
|
||||
/// <summary>
|
||||
/// The size limit to use when saving the tas project to disk.
|
||||
/// Gets or sets the size limit to use when saving the TAS project to disk.
|
||||
/// </summary>
|
||||
[DisplayName("Save Capacity (in megabytes)")]
|
||||
[Description("The size limit to use when saving the tas project to disk.")]
|
||||
public int DiskSaveCapacitymb { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The total amount of memory to devote to state history in megabytes
|
||||
/// Gets or sets the total amount of memory to devote to state history in megabytes
|
||||
/// </summary>
|
||||
[DisplayName("Capacity (in megabytes)")]
|
||||
[Description("The size limit of the state history buffer. When this limit is reached it will start moving to disk.")]
|
||||
public int Capacitymb { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The total amount of disk space to devote to state history in megabytes
|
||||
/// Gets or sets the total amount of disk space to devote to state history in megabytes
|
||||
/// </summary>
|
||||
[DisplayName("Disk Capacity (in megabytes)")]
|
||||
[Description("The size limit of the state history buffer on the disk. When this limit is reached it will start removing previous savestates")]
|
||||
public int DiskCapacitymb { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The amount of states to skip during project saving
|
||||
/// Gets or sets the amount of states to skip during project saving
|
||||
/// </summary>
|
||||
[DisplayName("State interval for .tasproj")]
|
||||
[Description("The actual state gap in frames is calculated as Nth power on 2")]
|
||||
public int StateGap { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Put branch states to .tasproj
|
||||
/// Gets or sets a value indicating whether or not to save branch states into the movie file
|
||||
/// </summary>
|
||||
[DisplayName("Put branch states to .tasproj")]
|
||||
[Description("Put branch states to .tasproj")]
|
||||
public bool BranchStatesInTasproj { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Erase branch states before greenzone states when capacity is met
|
||||
/// Gets or sets a value indicating whether or not to erase branch states before greenzone states when capacity is met
|
||||
/// </summary>
|
||||
[DisplayName("Erase branch states first")]
|
||||
[Description("Erase branch states before greenzone states when capacity is met")]
|
||||
|
@ -116,33 +116,20 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (!int.TryParse(lines[0], out refCapacity))
|
||||
{
|
||||
if (bool.Parse(lines[0]))
|
||||
DiskSaveCapacitymb = Capacitymb;
|
||||
else
|
||||
DiskSaveCapacitymb = 0;
|
||||
DiskSaveCapacitymb = bool.Parse(lines[0]) ? Capacitymb : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DiskSaveCapacitymb = refCapacity;
|
||||
}
|
||||
|
||||
if (lines.Length > 2)
|
||||
DiskCapacitymb = int.Parse(lines[2]);
|
||||
else
|
||||
DiskCapacitymb = 512;
|
||||
DiskCapacitymb = lines.Length > 2 ? int.Parse(lines[2]) : 512;
|
||||
|
||||
if (lines.Length > 3)
|
||||
BranchStatesInTasproj = bool.Parse(lines[3]);
|
||||
else
|
||||
BranchStatesInTasproj = false;
|
||||
BranchStatesInTasproj = lines.Length > 3 && bool.Parse(lines[3]);
|
||||
|
||||
if (lines.Length > 4)
|
||||
EraseBranchStatesFirst = bool.Parse(lines[4]);
|
||||
else
|
||||
EraseBranchStatesFirst = true;
|
||||
EraseBranchStatesFirst = lines.Length <= 4 || bool.Parse(lines[4]);
|
||||
|
||||
if (lines.Length > 5)
|
||||
StateGap = int.Parse(lines[5]);
|
||||
else
|
||||
StateGap = 4;
|
||||
StateGap = lines.Length > 5 ? int.Parse(lines[5]) : 4;
|
||||
}
|
||||
catch (Exception) // TODO: this is bad
|
||||
{
|
||||
|
|
|
@ -16,11 +16,10 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
private readonly Watch _watch;
|
||||
private readonly COMPARISONTYPE _comparisonType;
|
||||
private int? _compare;
|
||||
private int _val;
|
||||
private bool _enabled;
|
||||
private readonly COMPARISONTYPE _comparisonType;
|
||||
|
||||
|
||||
public Cheat(Watch watch, int value, int? compare = null, bool enabled = true, COMPARISONTYPE comparisonType = COMPARISONTYPE.NONE)
|
||||
{
|
||||
|
|
|
@ -283,6 +283,7 @@ namespace BizHawk.Client.Common
|
|||
/// Returns the value of a given cheat, or a partial value of a multi-byte cheat
|
||||
/// Note that address + size MUST NOT exceed the range of the cheat or undefined behavior will occur
|
||||
/// </summary>
|
||||
/// <param name="domain">The <seealso cref="MemoryDomain"/> to apply cheats to</param>
|
||||
/// <param name="addr">The starting address for which you will get the number of bytes</param>
|
||||
/// <param name="size">The number of bytes of the cheat to return</param>
|
||||
/// <returns>The value, or null if it can't resolve the address with a given cheat</returns>
|
||||
|
|
|
@ -587,7 +587,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating the endianess of current <see cref="Watch"/>
|
||||
/// True for big endian, flase for little endian
|
||||
/// True for big endian, false for little endian
|
||||
/// </summary>
|
||||
public bool BigEndian { get; set; }
|
||||
|
||||
|
|
|
@ -29,30 +29,27 @@ namespace BizHawk.Client.Common
|
|||
public const string DOMAIN = "DomainColumn";
|
||||
public const string NOTES = "NotesColumn";
|
||||
|
||||
private static readonly WatchDomainComparer domainComparer = new WatchDomainComparer();
|
||||
private static readonly WatchAddressComparer addressComparer = new WatchAddressComparer();
|
||||
private static readonly WatchValueComparer valueComparer = new WatchValueComparer();
|
||||
private static readonly WatchPreviousValueComparer previousValueComparer = new WatchPreviousValueComparer();
|
||||
private static readonly WatchValueDifferenceComparer valueDifferenceComparer = new WatchValueDifferenceComparer();
|
||||
private static readonly WatchChangeCountComparer changeCountComparer = new WatchChangeCountComparer();
|
||||
private static readonly WatchNoteComparer noteComparer = new WatchNoteComparer();
|
||||
private static readonly WatchDomainComparer DomainComparer = new WatchDomainComparer();
|
||||
private static readonly WatchAddressComparer AddressComparer = new WatchAddressComparer();
|
||||
private static readonly WatchValueComparer ValueComparer = new WatchValueComparer();
|
||||
private static readonly WatchPreviousValueComparer PreviousValueComparer = new WatchPreviousValueComparer();
|
||||
private static readonly WatchValueDifferenceComparer ValueDifferenceComparer = new WatchValueDifferenceComparer();
|
||||
private static readonly WatchChangeCountComparer ChangeCountComparer = new WatchChangeCountComparer();
|
||||
private static readonly WatchNoteComparer NoteComparer = new WatchNoteComparer();
|
||||
|
||||
private readonly List<Watch> _watchList = new List<Watch>(0);
|
||||
private readonly string _systemid;
|
||||
private IMemoryDomains _memoryDomains;
|
||||
|
||||
private List<Watch> _watchList = new List<Watch>(0);
|
||||
private string _currentFilename = "";
|
||||
private string _systemid;
|
||||
|
||||
#endregion
|
||||
|
||||
#region cTor(s)
|
||||
|
||||
/// <summary>
|
||||
/// Initialize a new instance of <see cref="WatchList"/> that will
|
||||
/// contains a set of <see cref="Watch"/>
|
||||
/// Initializes a new instance of the <see cref="WatchList"/> class
|
||||
/// that will contains a set of <see cref="Watch"/>
|
||||
/// </summary>
|
||||
/// <param name="core">All available memomry domains</param>
|
||||
/// <param name="domain">Domain you want to watch</param>
|
||||
/// <param name="core">All available memory domains</param>
|
||||
/// <param name="systemid">System identifier (NES, SNES, ...)</param>
|
||||
public WatchList(IMemoryDomains core, string systemid)
|
||||
{
|
||||
|
@ -84,7 +81,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
_watchList.Clear();
|
||||
Changes = false;
|
||||
_currentFilename = "";
|
||||
CurrentFileName = "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -92,7 +89,6 @@ namespace BizHawk.Client.Common
|
|||
/// specified <see cref="Watch"/>
|
||||
/// </summary>
|
||||
/// <param name="watch">The object to</param>
|
||||
/// <returns></returns>
|
||||
public bool Contains(Watch watch)
|
||||
{
|
||||
return _watchList.Contains(watch);
|
||||
|
@ -196,7 +192,7 @@ namespace BizHawk.Client.Common
|
|||
/// <param name="watches"><see cref="IEnumerable{Watch}"/> of watch to merge</param>
|
||||
public void AddRange(IEnumerable<Watch> watches)
|
||||
{
|
||||
Parallel.ForEach<Watch>(watches, watch =>
|
||||
Parallel.ForEach(watches, watch =>
|
||||
{
|
||||
if (!_watchList.Contains(watch))
|
||||
{
|
||||
|
@ -211,14 +207,14 @@ namespace BizHawk.Client.Common
|
|||
/// </summary>
|
||||
public void ClearChangeCounts()
|
||||
{
|
||||
Parallel.ForEach<Watch>(_watchList, watch => watch.ClearChangeCount());
|
||||
Parallel.ForEach(_watchList, watch => watch.ClearChangeCount());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sort the current list based on one of the constant
|
||||
/// </summary>
|
||||
/// <param name="column">Value that specify sorting base</param>
|
||||
/// <param name="reverse">Value that define the ordering. Ascending (true) or desceding (false)</param>
|
||||
/// <param name="reverse">Value that define the ordering. Ascending (true) or descending (false)</param>
|
||||
public void OrderWatches(string column, bool reverse)
|
||||
{
|
||||
switch (column)
|
||||
|
@ -226,7 +222,7 @@ namespace BizHawk.Client.Common
|
|||
case ADDRESS:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList.Sort(addressComparer);
|
||||
_watchList.Sort(AddressComparer);
|
||||
_watchList.Reverse();
|
||||
}
|
||||
else
|
||||
|
@ -239,12 +235,12 @@ namespace BizHawk.Client.Common
|
|||
case VALUE:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList.Sort(valueComparer);
|
||||
_watchList.Sort(ValueComparer);
|
||||
_watchList.Reverse();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList.Sort(valueComparer);
|
||||
_watchList.Sort(ValueComparer);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -252,12 +248,12 @@ namespace BizHawk.Client.Common
|
|||
case PREV:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList.Sort(previousValueComparer);
|
||||
_watchList.Sort(PreviousValueComparer);
|
||||
_watchList.Reverse();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList.Sort(previousValueComparer);
|
||||
_watchList.Sort(PreviousValueComparer);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -265,24 +261,25 @@ namespace BizHawk.Client.Common
|
|||
case DIFF:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList.Sort(valueDifferenceComparer);
|
||||
_watchList.Sort(ValueDifferenceComparer);
|
||||
_watchList.Reverse();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList.Sort(valueDifferenceComparer);
|
||||
_watchList.Sort(ValueDifferenceComparer);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case CHANGES:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList.Sort(changeCountComparer);
|
||||
_watchList.Sort(ChangeCountComparer);
|
||||
_watchList.Reverse();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList.Sort(changeCountComparer);
|
||||
_watchList.Sort(ChangeCountComparer);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -290,12 +287,12 @@ namespace BizHawk.Client.Common
|
|||
case DOMAIN:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList.Sort(domainComparer);
|
||||
_watchList.Sort(DomainComparer);
|
||||
_watchList.Reverse();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList.Sort(domainComparer);
|
||||
_watchList.Sort(DomainComparer);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -303,12 +300,12 @@ namespace BizHawk.Client.Common
|
|||
case NOTES:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList.Sort(noteComparer);
|
||||
_watchList.Sort(NoteComparer);
|
||||
_watchList.Reverse();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList.Sort(noteComparer);
|
||||
_watchList.Sort(NoteComparer);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -323,7 +320,7 @@ namespace BizHawk.Client.Common
|
|||
public void RefreshDomains(IMemoryDomains core)
|
||||
{
|
||||
_memoryDomains = core;
|
||||
Parallel.ForEach<Watch>(_watchList, watch =>
|
||||
Parallel.ForEach(_watchList, watch =>
|
||||
{
|
||||
if (watch.IsSeparator)
|
||||
{
|
||||
|
@ -338,11 +335,11 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates all <see cref="Watch"/> ine the current collection
|
||||
/// Updates all <see cref="Watch"/> in the current collection
|
||||
/// </summary>
|
||||
public void UpdateValues()
|
||||
{
|
||||
Parallel.ForEach<Watch>(_watchList, watch =>
|
||||
Parallel.ForEach(_watchList, watch =>
|
||||
{
|
||||
watch.Update();
|
||||
});
|
||||
|
@ -357,25 +354,13 @@ namespace BizHawk.Client.Common
|
|||
/// <summary>
|
||||
/// Gets the number of elements contained in this <see cref="WatchList"/>
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return _watchList.Count;
|
||||
}
|
||||
}
|
||||
public int Count => _watchList.Count;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="WatchList"/> is alsways read-write
|
||||
/// <see cref="WatchList"/> is always read-write
|
||||
/// so this value will be always false
|
||||
/// </summary>
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public bool IsReadOnly => false;
|
||||
|
||||
#endregion ICollection<Watch>
|
||||
|
||||
|
@ -392,6 +377,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
return _watchList[index];
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_watchList[index] = value;
|
||||
|
@ -401,24 +387,14 @@ namespace BizHawk.Client.Common
|
|||
#endregion IList<Watch>
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating if collection has changed or not
|
||||
/// Gets or sets a value indicating whether the collection has changed or not
|
||||
/// </summary>
|
||||
public bool Changes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets current <see cref="WatchList"/>'s filename
|
||||
/// </summary>
|
||||
public string CurrentFileName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _currentFilename;
|
||||
}
|
||||
set
|
||||
{
|
||||
_currentFilename = value;
|
||||
}
|
||||
}
|
||||
public string CurrentFileName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of <see cref="Watch"/> that are not <see cref="SeparatorWatch"/>
|
||||
|
@ -427,7 +403,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
get
|
||||
{
|
||||
return _watchList.Count<Watch>(watch => !watch.IsSeparator);
|
||||
return _watchList.Count(watch => !watch.IsSeparator);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -613,7 +589,7 @@ namespace BizHawk.Client.Common
|
|||
notes));
|
||||
}
|
||||
|
||||
_currentFilename = path;
|
||||
CurrentFileName = path;
|
||||
}
|
||||
|
||||
if (!append)
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OSD/@EntryIndexedValue">OSD</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PAL/@EntryIndexedValue">PAL</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PC/@EntryIndexedValue">PC</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PCE/@EntryIndexedValue">PCE</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PCECD/@EntryIndexedValue">PCECD</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PSP/@EntryIndexedValue">PSP</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PSX/@EntryIndexedValue">PSX</s:String>
|
||||
|
|
Loading…
Reference in New Issue