From cb721a39da961b7f0d77645774485d59b5badc8e Mon Sep 17 00:00:00 2001 From: adelikat Date: Thu, 25 May 2023 15:01:30 -0500 Subject: [PATCH] de-engineer some movie stuff, ILogEntryGenerator is not an important abstrations now that Bkm is gone --- .../movie/bk2/Bk2Controller.cs | 4 +- .../movie/bk2/Bk2LogEntryGenerator.cs | 19 ++++++++-- .../movie/bk2/Bk2Movie.cs | 2 +- .../movie/interfaces/ILogEntryGenerator.cs | 38 ------------------- .../movie/interfaces/IMovie.cs | 2 +- .../tools/BasicBot/BasicBot.cs | 2 +- 6 files changed, 21 insertions(+), 46 deletions(-) delete mode 100644 src/BizHawk.Client.Common/movie/interfaces/ILogEntryGenerator.cs diff --git a/src/BizHawk.Client.Common/movie/bk2/Bk2Controller.cs b/src/BizHawk.Client.Common/movie/bk2/Bk2Controller.cs index 804a7f6bcb..84b35ab071 100755 --- a/src/BizHawk.Client.Common/movie/bk2/Bk2Controller.cs +++ b/src/BizHawk.Client.Common/movie/bk2/Bk2Controller.cs @@ -9,8 +9,8 @@ namespace BizHawk.Client.Common { internal class Bk2Controller : IMovieController { - private readonly WorkingDictionary _myBoolButtons = new WorkingDictionary(); - private readonly WorkingDictionary _myAxisControls = new WorkingDictionary(); + private readonly WorkingDictionary _myBoolButtons = new(); + private readonly WorkingDictionary _myAxisControls = new(); private readonly Bk2ControllerDefinition _type; diff --git a/src/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs b/src/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs index df48add0a8..7b5d10ea3f 100644 --- a/src/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs +++ b/src/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs @@ -7,7 +7,7 @@ using BizHawk.Emulation.Common; namespace BizHawk.Client.Common { // Designed to be able to last the lifetime of an IMovie - internal class Bk2LogEntryGenerator : ILogEntryGenerator + public sealed class Bk2LogEntryGenerator { private readonly string _systemId; private readonly IController _source; @@ -29,12 +29,22 @@ namespace BizHawk.Client.Common } } - public bool IsEmpty => EmptyEntry == GenerateLogEntry(); - + /// + /// Gets an input log entry that is considered empty. (booleans will be false, axes will be 0) + /// public string EmptyEntry => CreateLogEntry(createEmpty: true); + /// + /// Generates an input log entry for the current state of Source + /// public string GenerateLogEntry() => CreateLogEntry(); + /// + /// Generates a human readable key that will specify the names of the + /// buttons and the order they are in. This is intended to simply be + /// documentation of the meaning of the mnemonics and not to be used to + /// enforce the mnemonic values + /// public string GenerateLogKey() { var sb = new StringBuilder(); @@ -52,6 +62,9 @@ namespace BizHawk.Client.Common return sb.ToString(); } + /// + /// Generates a dictionary of button names to their corresponding mnemonic values + /// public IDictionary Map() { var dict = new Dictionary(); diff --git a/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.cs b/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.cs index c0c803b0a0..5936bff173 100755 --- a/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.cs +++ b/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.cs @@ -32,7 +32,7 @@ namespace BizHawk.Client.Common public virtual bool Changes { get; protected set; } public bool IsCountingRerecords { get; set; } = true; - public ILogEntryGenerator LogGeneratorInstance(IController source) + public Bk2LogEntryGenerator LogGeneratorInstance(IController source) { // Hack because initial movie loading is a mess, and you will immediate create a file with an undefined controller if (!source.Definition.Any()) diff --git a/src/BizHawk.Client.Common/movie/interfaces/ILogEntryGenerator.cs b/src/BizHawk.Client.Common/movie/interfaces/ILogEntryGenerator.cs deleted file mode 100644 index d7558f37f9..0000000000 --- a/src/BizHawk.Client.Common/movie/interfaces/ILogEntryGenerator.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Collections.Generic; - -namespace BizHawk.Client.Common -{ - /// - /// Specifies a class that can take an input source and generate a movie input log entry - /// - public interface ILogEntryGenerator - { - /// - /// Generates an input log entry for the current state of Source - /// - string GenerateLogEntry(); - - /// - /// Generates a human readable key that will specify the names of the - /// buttons and the order they are in. This is intended to simply be - /// documentation of the meaning of the mnemonics and not to be used to - /// enforce the mnemonic values - /// - string GenerateLogKey(); - - /// - /// Generates a dictionary of button names to their corresponding mnemonic values - /// - IDictionary Map(); - - /// - /// Gets a value indicating whether or not the current controller state is "empty" - /// - bool IsEmpty { get; } - - /// - /// Gets an input log entry that is considered empty. (booleans will be false, axes will be 0) - /// - string EmptyEntry { get; } - } -} \ No newline at end of file diff --git a/src/BizHawk.Client.Common/movie/interfaces/IMovie.cs b/src/BizHawk.Client.Common/movie/interfaces/IMovie.cs index d6e1b64933..3ccefb589b 100644 --- a/src/BizHawk.Client.Common/movie/interfaces/IMovie.cs +++ b/src/BizHawk.Client.Common/movie/interfaces/IMovie.cs @@ -77,7 +77,7 @@ namespace BizHawk.Client.Common /// /// Creates a log generator using the given input source /// - ILogEntryGenerator LogGeneratorInstance(IController source); + Bk2LogEntryGenerator LogGeneratorInstance(IController source); /// /// Instructs the movie to save the current contents to Filename diff --git a/src/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs b/src/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs index 9ab14b2d10..fd4b67794d 100644 --- a/src/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs +++ b/src/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs @@ -59,7 +59,7 @@ namespace BizHawk.Client.EmuHawk private int _dataSize; private Dictionary _cachedControlProbabilities; - private ILogEntryGenerator _logGenerator; + private Bk2LogEntryGenerator _logGenerator; private bool _previousDisplayMessage; private bool _previousInvisibleEmulation;