Virtualpads - fix up some Readonly logic

This commit is contained in:
adelikat 2014-06-26 20:36:33 +00:00
parent 0e8bf4883f
commit 2a78b5c743
6 changed files with 62 additions and 48 deletions

View File

@ -16,7 +16,7 @@ namespace BizHawk.Client.EmuHawk
{
private PadSchema _schema;
private List<IVirtualPadControl> Pads
private List<IVirtualPadControl> PadControls
{
get
{
@ -26,6 +26,14 @@ namespace BizHawk.Client.EmuHawk
}
}
public bool ReadOnly
{
get
{
return PadControls.First().ReadOnly; // Shortcut logic, assume all controls are in sync
}
}
public VirtualPad(PadSchema schema)
{
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
@ -88,22 +96,22 @@ namespace BizHawk.Client.EmuHawk
public void Clear()
{
Pads.ForEach(p => p.Clear());
PadControls.ForEach(p => p.Clear());
}
public void ToggleReadOnly()
{
Pads.ForEach(p => p.ReadOnly ^= true);
PadControls.ForEach(p => p.ReadOnly ^= true);
}
public void SetReadOnly(bool readOnly)
{
Pads.ForEach(p => p.ReadOnly = readOnly);
PadControls.ForEach(p => p.ReadOnly = readOnly);
}
public void Set(IController controller)
{
Pads.ForEach(c => c.Set(controller));
PadControls.ForEach(c => c.Set(controller));
}
}
}

View File

@ -24,6 +24,14 @@ namespace BizHawk.Client.EmuHawk
}
}
private bool Readonly
{
get
{
return Pads.First().ReadOnly; // Shortcut logic, assume all controls are in sync
}
}
public VirtualpadTool()
{
InitializeComponent();
@ -127,10 +135,10 @@ namespace BizHawk.Client.EmuHawk
}
// TODO
//if (!StickyBox.Checked)
//{
// Pads.ForEach(pad => pad.Clear());
//}
if (!StickyBox.Checked)
{
Pads.ForEach(pad => pad.Clear());
}
}
#endregion

View File

@ -45,15 +45,14 @@ namespace BizHawk.Client.EmuHawk
set
{
var changed = _readonly != value;
AnalogTrackBar.Enabled =
ValueLabel.Enabled =
!value;
_readonly = value;
if (changed)
if (_readonly != value)
{
AnalogTrackBar.Enabled =
ValueLabel.Enabled =
!value;
_readonly = value;
Refresh();
}
}

View File

@ -54,23 +54,21 @@ namespace BizHawk.Client.EmuHawk
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)
if (_readonly != value)
{
XLabel.Enabled =
ManualX.Enabled =
YLabel.Enabled =
ManualY.Enabled =
MaxLabel.Enabled =
MaxXNumeric.Enabled =
MaxYNumeric.Enabled =
!value;
AnalogStick.ReadOnly =
_readonly =
value;
Refresh();
}
}

View File

@ -57,12 +57,15 @@ namespace BizHawk.Client.EmuHawk
set
{
var changed = _readonly != value;
RightClicked = false;
Checked = false;
_readonly = value;
if (changed)
if (_readonly != value)
{
_readonly = value;
RightClicked = false;
if (!value)
{
Checked = false;
}
Refresh();
}
}

View File

@ -64,17 +64,15 @@ namespace BizHawk.Client.EmuHawk
set
{
var changed = _readonly != value;
XNumeric.Enabled =
XLabel.Enabled =
YNumeric.Enabled =
YLabel.Enabled =
!value;
_readonly = value;
if (changed)
if (_readonly != value)
{
XNumeric.Enabled =
XLabel.Enabled =
YNumeric.Enabled =
YLabel.Enabled =
!value;
_readonly = value;
Refresh();
}
}