new movie mnemonic generators - some more baking of ideas, a basic mockup of NES done. Note: none of this is hooked up to anything yet
This commit is contained in:
parent
92c4df38c3
commit
86024d2347
|
@ -12,10 +12,16 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
IController Source { get; set; }
|
||||
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The
|
||||
/// Will be prepended to all button names
|
||||
/// Example: "P1"
|
||||
/// </summary>
|
||||
string ControllerPrefix { get; set; }
|
||||
|
||||
void Add(string key, char value);
|
||||
|
||||
char this[string key] { get; }
|
||||
bool IsEmpty { get; }
|
||||
string MnemonicString { get; }
|
||||
|
@ -32,22 +38,51 @@ namespace BizHawk.Client.Common
|
|||
IDictionary<string, bool> ParseMnemonicSegment(string mnemonicSegment);
|
||||
}
|
||||
|
||||
public interface IMnemonicGeneratorCollection
|
||||
/// <summary>
|
||||
/// A console specific collection of Mnemonic generators
|
||||
/// This handles includes all the "business" logic specific to the console
|
||||
/// </summary>
|
||||
public interface IMnemonicPorts
|
||||
{
|
||||
IEnumerable<IMnemonicGenerator> Generators { get; }
|
||||
/// <summary>
|
||||
/// Total number of available controller ports (this does not include the console controls
|
||||
/// </summary>
|
||||
int Count { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the given port with an IMnemonicGenerator implementation
|
||||
/// Ports are zero based
|
||||
/// Set will throw an InvalidOperationException if a particular implementation is not allowed, this is platform specific logic such as NES doesn't allow a zapper in port 0, etc
|
||||
/// Both will throw an ArgumentOutOfRangeException exception if portNum is not less than Count
|
||||
/// </summary>
|
||||
IMnemonicGenerator this[int portNum] { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets an IMnemonicGenerator implementation that represents the buttons and controls on the console itself (Reset, Power, etc)
|
||||
/// </summary>
|
||||
IMnemonicGenerator ConsoleControls { get; }
|
||||
}
|
||||
|
||||
public class BooleanControllerMnemonicGenerator : IMnemonicGenerator
|
||||
{
|
||||
private NamedDictionary<string, char> _controllerMnemonics;
|
||||
|
||||
public BooleanControllerMnemonicGenerator(string name)
|
||||
public BooleanControllerMnemonicGenerator(string name, IDictionary<string, char> mnemonics)
|
||||
{
|
||||
_controllerMnemonics = new NamedDictionary<string, char>(name);
|
||||
}
|
||||
|
||||
public void Add(string key, char value)
|
||||
{
|
||||
_controllerMnemonics.Add(key, value);
|
||||
}
|
||||
|
||||
public IController Source { get; set; }
|
||||
public string ControllerPrefix { get; set; }
|
||||
public string Name
|
||||
{
|
||||
get { return _controllerMnemonics.Name; }
|
||||
}
|
||||
|
||||
public char this[string key]
|
||||
{
|
||||
|
|
|
@ -5,19 +5,160 @@ using System.Text;
|
|||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public class NesMnemonicGenerator : IMnemonicGeneratorCollection
|
||||
public class NesMnemonicGenerator : IMnemonicPorts
|
||||
{
|
||||
public NesMnemonicGenerator()
|
||||
public NesMnemonicGenerator(bool fds = false, bool isFourscore = false)
|
||||
{
|
||||
|
||||
_isFds = fds;
|
||||
_isFourscore = isFourscore;
|
||||
}
|
||||
|
||||
public IEnumerable<IMnemonicGenerator> Generators
|
||||
public bool FourScoreEnabled
|
||||
{
|
||||
get { return _isFourscore; }
|
||||
set { _isFourscore = value; }
|
||||
}
|
||||
|
||||
public bool IsFDS
|
||||
{
|
||||
get { return _isFds; }
|
||||
set { _isFds = value; }
|
||||
}
|
||||
|
||||
#region IMnemonicPorts Implementation
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return _isFourscore ? 4 : 2; }
|
||||
}
|
||||
|
||||
// This is probably not necessary, but let's see how things go
|
||||
public IEnumerable<IMnemonicGenerator> AvailableGenerators
|
||||
{
|
||||
get
|
||||
{
|
||||
return Enumerable.Empty<IMnemonicGenerator>();
|
||||
yield return ConsoleControls;
|
||||
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
yield return _controllerPorts[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IMnemonicGenerator ConsoleControls
|
||||
{
|
||||
get { return _isFds ? _fdsConsoleControls : _nesConsoleControls; }
|
||||
}
|
||||
|
||||
public IMnemonicGenerator this[int portNum]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (portNum < Count)
|
||||
{
|
||||
return _controllerPorts[portNum];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("portNum");
|
||||
}
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (portNum < Count)
|
||||
{
|
||||
// Eventually this will support zappers and FDS controllers, Arkanoid paddle, etc
|
||||
if (value is BooleanControllerMnemonicGenerator)
|
||||
{
|
||||
_controllerPorts[portNum] = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("Invalid Mnemonic Generator for the given port");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("portNum");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Privates
|
||||
|
||||
private bool _isFds;
|
||||
private bool _isFourscore;
|
||||
|
||||
private static readonly Dictionary<string, char> _basicController = new Dictionary<string, char>
|
||||
{
|
||||
{ "Up", 'U' },
|
||||
{ "Down", 'D' },
|
||||
{ "Left", 'L' },
|
||||
{ "Right", 'R' },
|
||||
{ "Select", 's' },
|
||||
{ "Start", 'S' },
|
||||
{ "B", 'B' },
|
||||
{ "A", 'A' }
|
||||
};
|
||||
|
||||
private readonly BooleanControllerMnemonicGenerator _nesConsoleControls = new BooleanControllerMnemonicGenerator(
|
||||
"Console",
|
||||
new Dictionary<string, char>
|
||||
{
|
||||
{ "Reset", 'r' },
|
||||
{ "Power", 'P' },
|
||||
}
|
||||
)
|
||||
{
|
||||
Source = Global.MovieOutputHardpoint,
|
||||
ControllerPrefix = String.Empty
|
||||
};
|
||||
|
||||
private readonly BooleanControllerMnemonicGenerator _fdsConsoleControls = new BooleanControllerMnemonicGenerator(
|
||||
"Console",
|
||||
new Dictionary<string, char>
|
||||
{
|
||||
{ "Reset", 'r' },
|
||||
{ "Power", 'P' },
|
||||
{ "FDS Eject", 'E' },
|
||||
{ "FDS Insert 0", '0' },
|
||||
{ "FDS Insert 1", '1' },
|
||||
}
|
||||
)
|
||||
{
|
||||
Source = Global.MovieOutputHardpoint,
|
||||
ControllerPrefix = String.Empty
|
||||
};
|
||||
|
||||
private readonly List<IMnemonicGenerator> _controllerPorts =
|
||||
new List<IMnemonicGenerator>
|
||||
{
|
||||
new BooleanControllerMnemonicGenerator("Player 1", _basicController)
|
||||
{
|
||||
Source = Global.MovieOutputHardpoint,
|
||||
ControllerPrefix = "P1"
|
||||
},
|
||||
new BooleanControllerMnemonicGenerator("Player 2", _basicController)
|
||||
{
|
||||
Source = Global.MovieOutputHardpoint,
|
||||
ControllerPrefix = "P2"
|
||||
},
|
||||
new BooleanControllerMnemonicGenerator("Player 3", _basicController)
|
||||
{
|
||||
Source = Global.MovieOutputHardpoint,
|
||||
ControllerPrefix = "P3"
|
||||
},
|
||||
new BooleanControllerMnemonicGenerator("Player 4", _basicController)
|
||||
{
|
||||
Source = Global.MovieOutputHardpoint,
|
||||
ControllerPrefix = "P4"
|
||||
}
|
||||
};
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue