de-engineer some movie stuff, ILogEntryGenerator is not an important abstrations now that Bkm is gone

This commit is contained in:
adelikat 2023-05-25 15:01:30 -05:00
parent 33ed05b20c
commit cb721a39da
6 changed files with 21 additions and 46 deletions

View File

@ -9,8 +9,8 @@ namespace BizHawk.Client.Common
{
internal class Bk2Controller : IMovieController
{
private readonly WorkingDictionary<string, bool> _myBoolButtons = new WorkingDictionary<string, bool>();
private readonly WorkingDictionary<string, int> _myAxisControls = new WorkingDictionary<string, int>();
private readonly WorkingDictionary<string, bool> _myBoolButtons = new();
private readonly WorkingDictionary<string, int> _myAxisControls = new();
private readonly Bk2ControllerDefinition _type;

View File

@ -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();
/// <summary>
/// Gets an input log entry that is considered empty. (booleans will be false, axes will be 0)
/// </summary>
public string EmptyEntry => CreateLogEntry(createEmpty: true);
/// <summary>
/// Generates an input log entry for the current state of Source
/// </summary>
public string GenerateLogEntry() => CreateLogEntry();
/// <summary>
/// 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
/// </summary>
public string GenerateLogKey()
{
var sb = new StringBuilder();
@ -52,6 +62,9 @@ namespace BizHawk.Client.Common
return sb.ToString();
}
/// <summary>
/// Generates a dictionary of button names to their corresponding mnemonic values
/// </summary>
public IDictionary<string, string> Map()
{
var dict = new Dictionary<string, string>();

View File

@ -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())

View File

@ -1,38 +0,0 @@
using System.Collections.Generic;
namespace BizHawk.Client.Common
{
/// <summary>
/// Specifies a class that can take an input source and generate a movie input log entry
/// </summary>
public interface ILogEntryGenerator
{
/// <summary>
/// Generates an input log entry for the current state of Source
/// </summary>
string GenerateLogEntry();
/// <summary>
/// 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
/// </summary>
string GenerateLogKey();
/// <summary>
/// Generates a dictionary of button names to their corresponding mnemonic values
/// </summary>
IDictionary<string, string> Map();
/// <summary>
/// Gets a value indicating whether or not the current controller state is "empty"
/// </summary>
bool IsEmpty { get; }
/// <summary>
/// Gets an input log entry that is considered empty. (booleans will be false, axes will be 0)
/// </summary>
string EmptyEntry { get; }
}
}

View File

@ -77,7 +77,7 @@ namespace BizHawk.Client.Common
/// <summary>
/// Creates a log generator using the given input source
/// </summary>
ILogEntryGenerator LogGeneratorInstance(IController source);
Bk2LogEntryGenerator LogGeneratorInstance(IController source);
/// <summary>
/// Instructs the movie to save the current contents to Filename

View File

@ -59,7 +59,7 @@ namespace BizHawk.Client.EmuHawk
private int _dataSize;
private Dictionary<string, double> _cachedControlProbabilities;
private ILogEntryGenerator _logGenerator;
private Bk2LogEntryGenerator _logGenerator;
private bool _previousDisplayMessage;
private bool _previousInvisibleEmulation;