VirtualPads - progres on ReadOnly for AnalogStick

This commit is contained in:
adelikat 2014-06-26 03:30:56 +00:00
parent c21ab3e22d
commit 39e7039341
3 changed files with 91 additions and 50 deletions

View File

@ -28,9 +28,9 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.label1 = new System.Windows.Forms.Label(); this.XLabel = new System.Windows.Forms.Label();
this.ManualX = new System.Windows.Forms.NumericUpDown(); this.ManualX = new System.Windows.Forms.NumericUpDown();
this.label2 = new System.Windows.Forms.Label(); this.YLabel = new System.Windows.Forms.Label();
this.ManualY = new System.Windows.Forms.NumericUpDown(); this.ManualY = new System.Windows.Forms.NumericUpDown();
this.MaxLabel = new System.Windows.Forms.Label(); this.MaxLabel = new System.Windows.Forms.Label();
this.MaxXNumeric = new System.Windows.Forms.NumericUpDown(); this.MaxXNumeric = new System.Windows.Forms.NumericUpDown();
@ -42,14 +42,14 @@
((System.ComponentModel.ISupportInitialize)(this.MaxYNumeric)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.MaxYNumeric)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// label1 // XLabel
// //
this.label1.AutoSize = true; this.XLabel.AutoSize = true;
this.label1.Location = new System.Drawing.Point(138, 7); this.XLabel.Location = new System.Drawing.Point(138, 7);
this.label1.Name = "label1"; this.XLabel.Name = "XLabel";
this.label1.Size = new System.Drawing.Size(14, 13); this.XLabel.Size = new System.Drawing.Size(14, 13);
this.label1.TabIndex = 23; this.XLabel.TabIndex = 23;
this.label1.Text = "X"; this.XLabel.Text = "X";
// //
// ManualX // ManualX
// //
@ -70,14 +70,14 @@
this.ManualX.ValueChanged += new System.EventHandler(this.ManualX_ValueChanged); this.ManualX.ValueChanged += new System.EventHandler(this.ManualX_ValueChanged);
this.ManualX.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ManualX_KeyUp); this.ManualX.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ManualX_KeyUp);
// //
// label2 // YLabel
// //
this.label2.AutoSize = true; this.YLabel.AutoSize = true;
this.label2.Location = new System.Drawing.Point(138, 33); this.YLabel.Location = new System.Drawing.Point(138, 33);
this.label2.Name = "label2"; this.YLabel.Name = "YLabel";
this.label2.Size = new System.Drawing.Size(14, 13); this.YLabel.Size = new System.Drawing.Size(14, 13);
this.label2.TabIndex = 26; this.YLabel.TabIndex = 26;
this.label2.Text = "Y"; this.YLabel.Text = "Y";
// //
// ManualY // ManualY
// //
@ -152,6 +152,8 @@
this.AnalogStick.BackColor = System.Drawing.Color.Gray; this.AnalogStick.BackColor = System.Drawing.Color.Gray;
this.AnalogStick.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.AnalogStick.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.AnalogStick.Location = new System.Drawing.Point(3, 3); this.AnalogStick.Location = new System.Drawing.Point(3, 3);
this.AnalogStick.MaxX = 127;
this.AnalogStick.MaxY = 127;
this.AnalogStick.Name = "AnalogStick"; this.AnalogStick.Name = "AnalogStick";
this.AnalogStick.Size = new System.Drawing.Size(129, 129); this.AnalogStick.Size = new System.Drawing.Size(129, 129);
this.AnalogStick.TabIndex = 0; this.AnalogStick.TabIndex = 0;
@ -165,10 +167,10 @@
this.Controls.Add(this.MaxYNumeric); this.Controls.Add(this.MaxYNumeric);
this.Controls.Add(this.MaxXNumeric); this.Controls.Add(this.MaxXNumeric);
this.Controls.Add(this.MaxLabel); this.Controls.Add(this.MaxLabel);
this.Controls.Add(this.label2); this.Controls.Add(this.YLabel);
this.Controls.Add(this.ManualY); this.Controls.Add(this.ManualY);
this.Controls.Add(this.ManualX); this.Controls.Add(this.ManualX);
this.Controls.Add(this.label1); this.Controls.Add(this.XLabel);
this.Controls.Add(this.AnalogStick); this.Controls.Add(this.AnalogStick);
this.Name = "VirtualPadAnalogStick"; this.Name = "VirtualPadAnalogStick";
this.Size = new System.Drawing.Size(204, 136); this.Size = new System.Drawing.Size(204, 136);
@ -185,9 +187,9 @@
#endregion #endregion
private AnalogStickPanel AnalogStick; private AnalogStickPanel AnalogStick;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label XLabel;
private System.Windows.Forms.NumericUpDown ManualX; private System.Windows.Forms.NumericUpDown ManualX;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label YLabel;
private System.Windows.Forms.NumericUpDown ManualY; private System.Windows.Forms.NumericUpDown ManualY;
private System.Windows.Forms.Label MaxLabel; private System.Windows.Forms.Label MaxLabel;
private System.Windows.Forms.NumericUpDown MaxXNumeric; private System.Windows.Forms.NumericUpDown MaxXNumeric;

View File

@ -14,6 +14,7 @@ namespace BizHawk.Client.EmuHawk
public partial class VirtualPadAnalogStick : UserControl, IVirtualPadControl public partial class VirtualPadAnalogStick : UserControl, IVirtualPadControl
{ {
private bool _programmaticallyUpdatingNumerics = false; private bool _programmaticallyUpdatingNumerics = false;
private bool _readonly = false;
public VirtualPadAnalogStick() public VirtualPadAnalogStick()
{ {
@ -46,8 +47,33 @@ namespace BizHawk.Client.EmuHawk
public bool ReadOnly public bool ReadOnly
{ {
get; get
set; // TODO {
return _readonly;
}
set
{
var changed = _readonly != value;
XLabel.Enabled =
ManualX.Enabled =
YLabel.Enabled =
ManualY.Enabled =
MaxLabel.Enabled =
MaxXNumeric.Enabled =
MaxYNumeric.Enabled =
!value;
AnalogStick.Readonly =
_readonly =
value;
if (changed)
{
Refresh();
}
}
} }
#endregion #endregion
@ -94,16 +120,22 @@ namespace BizHawk.Client.EmuHawk
private void AnalogStick_MouseDown(object sender, MouseEventArgs e) private void AnalogStick_MouseDown(object sender, MouseEventArgs e)
{ {
_programmaticallyUpdatingNumerics = true; if (!ReadOnly)
SetNumericsFromAnalog(); {
_programmaticallyUpdatingNumerics = false; _programmaticallyUpdatingNumerics = true;
SetNumericsFromAnalog();
_programmaticallyUpdatingNumerics = false;
}
} }
private void AnalogStick_MouseMove(object sender, MouseEventArgs e) private void AnalogStick_MouseMove(object sender, MouseEventArgs e)
{ {
_programmaticallyUpdatingNumerics = true; if (!ReadOnly)
SetNumericsFromAnalog(); {
_programmaticallyUpdatingNumerics = false; _programmaticallyUpdatingNumerics = true;
SetNumericsFromAnalog();
_programmaticallyUpdatingNumerics = false;
}
} }
private void MaxXNumeric_ValueChanged(object sender, EventArgs e) private void MaxXNumeric_ValueChanged(object sender, EventArgs e)

View File

@ -11,6 +11,7 @@ namespace BizHawk.Client.EmuHawk
public int X = 0; public int X = 0;
public int Y = 0; public int Y = 0;
public bool HasValue = false; public bool HasValue = false;
public bool Readonly { get; set; }
public string XName = string.Empty; public string XName = string.Empty;
public string YName = string.Empty; public string YName = string.Empty;
@ -153,20 +154,23 @@ namespace BizHawk.Client.EmuHawk
protected override void OnMouseMove(MouseEventArgs e) protected override void OnMouseMove(MouseEventArgs e)
{ {
if (e.Button == MouseButtons.Left) if (!Readonly)
{ {
X = GFXToReal(e.X - 64, true); if (e.Button == MouseButtons.Left)
Y = GFXToReal(-(e.Y - 63), false); {
HasValue = true; X = GFXToReal(e.X - 64, true);
SetAnalog(); Y = GFXToReal(-(e.Y - 63), false);
} HasValue = true;
else if (e.Button == MouseButtons.Right) SetAnalog();
{ }
Clear(); else if (e.Button == MouseButtons.Right)
} {
Clear();
}
Refresh(); Refresh();
base.OnMouseMove(e); base.OnMouseMove(e);
}
} }
protected override void OnMouseUp(MouseEventArgs e) protected override void OnMouseUp(MouseEventArgs e)
@ -188,18 +192,21 @@ namespace BizHawk.Client.EmuHawk
protected override void OnMouseDown(MouseEventArgs e) protected override void OnMouseDown(MouseEventArgs e)
{ {
if (e.Button == MouseButtons.Left) if (!Readonly)
{ {
X = GFXToReal(e.X - 64, true); if (e.Button == MouseButtons.Left)
Y = GFXToReal(-(e.Y - 63), false); {
HasValue = true; X = GFXToReal(e.X - 64, true);
} Y = GFXToReal(-(e.Y - 63), false);
if (e.Button == MouseButtons.Right) HasValue = true;
{ }
Clear(); if (e.Button == MouseButtons.Right)
} {
Clear();
}
Refresh(); Refresh();
}
} }