Split TargetedPairSchema.MaxValue to MaxX/MaxY and cleanup

* split TargetedPairSchema ctor and added docs to clarify its behaviour
* renamed VirtualPadTargetScreen.RangeX/RangeY to MaxX/MaxY
* left TODOs in the three places MaxValue was actually used
This commit is contained in:
YoshiRulz 2020-09-01 09:01:18 +10:00
parent 509560fa1a
commit a89b0dfdcd
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
5 changed files with 28 additions and 18 deletions

View File

@ -110,8 +110,8 @@ namespace BizHawk.Client.EmuHawk
_inputManager.StickyXorAdapter, _inputManager.StickyXorAdapter,
targetedPair.Name, targetedPair.Name,
targetedPair.SecondaryName, targetedPair.SecondaryName,
targetedPair.MaxValue, targetedPair.MaxX,
targetedPair.MaxValue // TODO split into MaxX and MaxY, and rename VirtualPadTargetScreen.RangeX/RangeY targetedPair.MaxY
) )
{ {
Location = UIHelper.Scale(targetedPair.Location), Location = UIHelper.Scale(targetedPair.Location),

View File

@ -25,14 +25,14 @@ namespace BizHawk.Client.EmuHawk
StickyXorAdapter stickyXorAdapter, StickyXorAdapter stickyXorAdapter,
string nameX, string nameX,
string nameY, string nameY,
int rangeX, int maxX,
int rangeY) int maxY)
{ {
_stickyXorAdapter = stickyXorAdapter; _stickyXorAdapter = stickyXorAdapter;
Name = XName = nameX; Name = XName = nameX;
YName = nameY; YName = nameY;
RangeX = rangeX; MaxX = maxX;
RangeY = rangeY; MaxY = maxY;
InitializeComponent(); InitializeComponent();
} }
@ -122,16 +122,16 @@ namespace BizHawk.Client.EmuHawk
} }
// These are the value that a maximum x or y actually represent, used to translate from control X,Y to values the core expects // These are the value that a maximum x or y actually represent, used to translate from control X,Y to values the core expects
private readonly int RangeX; private readonly int MaxX;
private readonly int RangeY; private readonly int MaxY;
public float MultiplierX public float MultiplierX
{ {
get get
{ {
if (RangeX > 0) if (MaxX > 0)
{ {
return RangeX / (float)TargetPanel.Width; return MaxX / (float)TargetPanel.Width;
} }
return 1; return 1;
@ -142,9 +142,9 @@ namespace BizHawk.Client.EmuHawk
{ {
get get
{ {
if (RangeY > 0) if (MaxY > 0)
{ {
return RangeY / (float)TargetPanel.Height; return MaxY / (float)TargetPanel.Height;
} }
return 1; return 1;

View File

@ -113,7 +113,7 @@ namespace BizHawk.Client.EmuHawk
Size = new Size(356, 300), Size = new Size(356, 300),
Buttons = new PadSchemaControl[] Buttons = new PadSchemaControl[]
{ {
new TargetedPairSchema(14, 17, $"P{controller} Lightgun X", 10000) new TargetedPairSchema(14, 17, $"P{controller} Lightgun X", 10000, 10000) //TODO (10000, 10000) matches previous behaviour - what was intended here?
{ {
TargetSize = new Size(320, 240) TargetSize = new Size(320, 240)
}, },

View File

@ -106,18 +106,28 @@ namespace BizHawk.Client.EmuHawk
/// <summary>An (X, Y) pair intended to be a screen coordinate (for zappers, mouse, stylus, etc.)</summary> /// <summary>An (X, Y) pair intended to be a screen coordinate (for zappers, mouse, stylus, etc.)</summary>
public sealed class TargetedPairSchema : PadSchemaControl public sealed class TargetedPairSchema : PadSchemaControl
{ {
public int MaxValue { get; } public int MaxX { get; }
public int MaxY { get; }
public string SecondaryName { get; set; } public string SecondaryName { get; set; }
public Size TargetSize { get; set; } public Size TargetSize { get; set; }
public TargetedPairSchema(int x, int y, string nameX, int maxValue = default) /// <remarks>Using this ctor, the valid ranges for the X and Y axes are taken to be <c>(0..TargetSize.Width)</c> and <c>(0..TargetSize.Height)</c>.</remarks>
public TargetedPairSchema(int x, int y, string nameX)
: base(new Point(x, y), nameX) : base(new Point(x, y), nameX)
{ {
MaxValue = maxValue;
SecondaryName = nameX.Replace("X", "Y"); SecondaryName = nameX.Replace("X", "Y");
} }
/// <remarks>Using this ctor, the valid ranges for the X and Y axes are taken to be <c>(0..maxX)</c> and <c>(0..maxY)</c>.</remarks>
public TargetedPairSchema(int x, int y, string nameX, int maxX, int maxY)
: this(x, y, nameX)
{
MaxX = maxX;
MaxY = maxY;
}
} }
public sealed class DiscManagerSchema : PadSchemaControl public sealed class DiscManagerSchema : PadSchemaControl

View File

@ -132,7 +132,7 @@ namespace BizHawk.Client.EmuHawk
Size = new Size(375, 320), Size = new Size(375, 320),
Buttons = new PadSchemaControl[] Buttons = new PadSchemaControl[]
{ {
new TargetedPairSchema(14, 17, $"P{controller} Motion Left / Right", AxisRange.Max) new TargetedPairSchema(14, 17, $"P{controller} Motion Left / Right", AxisRange.Max, AxisRange.Max) //TODO (0xFFFF, 0xFFFF) matches previous behaviour - what was intended here?
{ {
SecondaryName = $"P{controller} Motion Up / Down", SecondaryName = $"P{controller} Motion Up / Down",
TargetSize = new Size(256, 256) TargetSize = new Size(256, 256)
@ -264,7 +264,7 @@ namespace BizHawk.Client.EmuHawk
Size = new Size(375, 320), Size = new Size(375, 320),
Buttons = new PadSchemaControl[] Buttons = new PadSchemaControl[]
{ {
new TargetedPairSchema(14, 17, $"P{controller} X Axis", AxisRange.Max) new TargetedPairSchema(14, 17, $"P{controller} X Axis", AxisRange.Max, AxisRange.Max) //TODO (0xFFFF, 0xFFFF) matches previous behaviour - what was intended here?
{ {
SecondaryName = $"P{controller} Y Axis", SecondaryName = $"P{controller} Y Axis",
TargetSize = new Size(256, 256) TargetSize = new Size(256, 256)