Virtual Pad - ability to toggle between single player and multiplayer and remember the setting in the config
This commit is contained in:
parent
abac70d592
commit
1e48111092
|
@ -489,6 +489,7 @@ namespace BizHawk.Client.Common
|
|||
public bool VirtualPadsUpdatePads = true;
|
||||
public bool AutoloadVirtualPad = false;
|
||||
public bool VirtualPadSticky = true;
|
||||
public bool VirtualPadMultiplayerMode = false;
|
||||
|
||||
// NES Game Genie Encoder/Decoder
|
||||
public ToolDialogSettings NesGGSettings = new ToolDialogSettings();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
{
|
||||
public interface IVirtualPad
|
||||
{
|
||||
string Controller { get; set; }
|
||||
string GetMnemonic();
|
||||
void Clear();
|
||||
void SetButtons(string buttons);
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public CheckBox B6;
|
||||
public CheckBox B7;
|
||||
public CheckBox B8;
|
||||
public string Controller;
|
||||
public string Controller { get; set; }
|
||||
|
||||
public VirtualPad()
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class VirtualPadA78 : UserControl, IVirtualPad
|
||||
{
|
||||
public string Controller = "P1";
|
||||
public string Controller { get; set; }
|
||||
|
||||
public VirtualPadA78()
|
||||
{
|
||||
|
@ -17,6 +17,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
SetStyle(ControlStyles.DoubleBuffer, true);
|
||||
BorderStyle = BorderStyle.Fixed3D;
|
||||
InitializeComponent();
|
||||
|
||||
Controller = "P1";
|
||||
}
|
||||
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class VirtualPadA78Control : UserControl, IVirtualPad
|
||||
{
|
||||
public string Controller { get; set; }
|
||||
public VirtualPadA78Control()
|
||||
{
|
||||
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
|
@ -16,6 +17,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
BorderStyle = BorderStyle.Fixed3D;
|
||||
Paint += VirtualPad_Paint;
|
||||
InitializeComponent();
|
||||
|
||||
Controller = string.Empty;
|
||||
}
|
||||
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||
|
|
|
@ -8,9 +8,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class VirtualPadC64Keyboard : UserControl , IVirtualPad
|
||||
{
|
||||
public string Controller { get; set; }
|
||||
public VirtualPadC64Keyboard()
|
||||
{
|
||||
InitializeComponent();
|
||||
Controller = string.Empty;
|
||||
}
|
||||
|
||||
private void Buttons_CheckedChanged(object sender, EventArgs e)
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class VirtualPadColeco : UserControl , IVirtualPad
|
||||
{
|
||||
public string Controller = "P1";
|
||||
public string Controller { get; set; }
|
||||
public VirtualPadColeco()
|
||||
{
|
||||
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
|
@ -17,6 +17,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
BorderStyle = BorderStyle.Fixed3D;
|
||||
Paint += VirtualPad_Paint;
|
||||
InitializeComponent();
|
||||
|
||||
Controller = "P1";
|
||||
}
|
||||
|
||||
private void VirtualPadColeco_Load(object sender, EventArgs e)
|
||||
|
|
|
@ -36,8 +36,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
private int _defaultWidth;
|
||||
private int _defaultHeight;
|
||||
|
||||
private bool _multiplayerMode;
|
||||
|
||||
#region Public API
|
||||
|
||||
public bool AskSave() { return true; }
|
||||
|
@ -95,6 +93,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
LoadConfigSettings();
|
||||
LoadStartingPads();
|
||||
if (Global.Config.VirtualPadMultiplayerMode)
|
||||
{
|
||||
SwitchToMultiplayer();
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadConfigSettings()
|
||||
|
@ -196,7 +198,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
private void LoadExtraPads()
|
||||
private void SwitchToMultiplayer()
|
||||
{
|
||||
switch (Global.Emulator.SystemId)
|
||||
{
|
||||
|
@ -254,7 +256,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
break;
|
||||
}
|
||||
|
||||
_multiplayerMode = true;
|
||||
Global.Config.VirtualPadMultiplayerMode = true;
|
||||
}
|
||||
|
||||
public void BumpAnalogValue(int? dx, int? dy) // TODO: multi-player
|
||||
|
@ -314,6 +316,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
Global.Config.VirtualPadSettings.SaveWindowPosition = true;
|
||||
Global.Config.VirtualPadSettings.TopMost = TopMost = false;
|
||||
Global.Config.VirtualPadSettings.FloatingWindow = false;
|
||||
Global.Config.VirtualPadMultiplayerMode = false;
|
||||
SwitchToSinglePlayer();
|
||||
}
|
||||
|
||||
private void ExitMenuItem_Click(object sender, EventArgs e)
|
||||
|
@ -347,18 +351,39 @@ namespace BizHawk.Client.EmuHawk
|
|||
base.OnShown(e);
|
||||
}
|
||||
|
||||
private void SwitchToSinglePlayer()
|
||||
{
|
||||
var toRemove = Pads
|
||||
.Where(pad => !string.IsNullOrEmpty(pad.Controller) && pad.Controller != "P1")
|
||||
.ToList();
|
||||
|
||||
foreach (var pad in toRemove)
|
||||
{
|
||||
ControllerBox.Controls.Remove(pad as Control);
|
||||
}
|
||||
|
||||
Global.Config.VirtualPadMultiplayerMode = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
private void MultiplayerModeMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadExtraPads();
|
||||
if (Global.Config.VirtualPadMultiplayerMode)
|
||||
{
|
||||
SwitchToSinglePlayer();
|
||||
}
|
||||
else
|
||||
{
|
||||
SwitchToMultiplayer();
|
||||
}
|
||||
}
|
||||
|
||||
private void PadsSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
MultiplayerModeMenuItem.Enabled = !_multiplayerMode;
|
||||
MultiplayerModeMenuItem.Checked = Global.Config.VirtualPadMultiplayerMode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class VirtualPadGen6Button : UserControl, IVirtualPad
|
||||
{
|
||||
public string Controller = "P1";
|
||||
public string Controller { get; set; }
|
||||
|
||||
public VirtualPadGen6Button()
|
||||
{
|
||||
|
@ -17,6 +17,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
SetStyle(ControlStyles.DoubleBuffer, true);
|
||||
BorderStyle = BorderStyle.Fixed3D;
|
||||
InitializeComponent();
|
||||
|
||||
Controller = "P1";
|
||||
}
|
||||
|
||||
private void VirtualPadGen6Button_Load(object sender, EventArgs e)
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class VirtualPadN64 : UserControl, IVirtualPad
|
||||
{
|
||||
public string Controller = "P1";
|
||||
public string Controller { get; set; }
|
||||
|
||||
private int old_X = 0;
|
||||
private int old_Y = 0;
|
||||
|
@ -22,15 +22,19 @@ namespace BizHawk.Client.EmuHawk
|
|||
SetStyle(ControlStyles.DoubleBuffer, true);
|
||||
BorderStyle = BorderStyle.Fixed3D;
|
||||
InitializeComponent();
|
||||
|
||||
Controller = "P1";
|
||||
}
|
||||
|
||||
private void UserControl1_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (Controller == "P1")
|
||||
{
|
||||
numericUpDown1.Visible = true;
|
||||
numericUpDown2.Visible = true;
|
||||
}
|
||||
{
|
||||
// adelikat: What's wrong with having this on players 2 - 4?
|
||||
if (Controller == "P1")
|
||||
{
|
||||
numericUpDown1.Visible = true;
|
||||
numericUpDown2.Visible = true;
|
||||
}
|
||||
|
||||
PU.ControllerButton = Controller + " Up";
|
||||
PD.ControllerButton = Controller + " Down";
|
||||
PL.ControllerButton = Controller + " Left";
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class VirtualPadSaturn : UserControl, IVirtualPad
|
||||
{
|
||||
public string Controller = "P1";
|
||||
public string Controller { get; set; }
|
||||
|
||||
public VirtualPadSaturn()
|
||||
{
|
||||
|
@ -18,6 +18,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
BorderStyle = BorderStyle.Fixed3D;
|
||||
Paint += VirtualPad_Paint;
|
||||
InitializeComponent();
|
||||
|
||||
Controller = "P1";
|
||||
}
|
||||
|
||||
private void VirtualPadSaturn_Load(object sender, EventArgs e)
|
||||
|
|
|
@ -8,6 +8,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class VirtualPadSaturnControl : UserControl, IVirtualPad
|
||||
{
|
||||
public string Controller { get; set; }
|
||||
|
||||
public VirtualPadSaturnControl()
|
||||
{
|
||||
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
|
@ -16,6 +18,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
BorderStyle = BorderStyle.Fixed3D;
|
||||
Paint += VirtualPad_Paint;
|
||||
InitializeComponent();
|
||||
|
||||
Controller = string.Empty;
|
||||
}
|
||||
|
||||
private void VirtualPadSaturnControl_Load(object sender, EventArgs e)
|
||||
|
|
Loading…
Reference in New Issue