Pass MessageBox.Show to Virtual Pads schemata as callback

This commit is contained in:
YoshiRulz 2020-12-22 18:18:40 +10:00
parent 0ff60220f7
commit 9124b0f3b5
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
30 changed files with 106 additions and 81 deletions

View File

@ -86,7 +86,7 @@ namespace BizHawk.Client.EmuHawk
if (schemaType == null) return;
var padSchemata = ((IVirtualPadSchema) Activator.CreateInstance(schemaType))
.GetPadSchemas(Emulator)
.GetPadSchemas(Emulator, s => MessageBox.Show(s))
.ToList();
if (VersionInfo.DeveloperBuild)

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
@ -10,7 +11,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class A26Schema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
var ss = ((Atari2600)core).GetSyncSettings().Clone();

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
@ -15,7 +16,7 @@ namespace BizHawk.Client.EmuHawk
private static string ProLineControllerName => typeof(ProLineController).DisplayName();
private static string LightGunControllerName => typeof(LightGunController).DisplayName();
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
var ss = ((A7800Hawk)core).GetSyncSettings().Clone();

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
@ -9,7 +10,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class AppleIISchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
yield return Keyboard();
yield return DiskSelection();

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
@ -9,7 +10,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class C64Schema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
yield return StandardController(1);
yield return StandardController(2);

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using BizHawk.Emulation.Common;
@ -10,7 +11,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class ColecoSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
var deck = ((ColecoVision)core).ControllerDeck;
var ports = new[] { deck.Port1.GetType(), deck.Port2.GetType() };

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
@ -9,7 +10,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class DualGbSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
yield return StandardController(1);
yield return StandardController(2);

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
@ -10,7 +11,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class GbaSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
yield return StandardController();
yield return ConsoleButtons();

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
@ -9,7 +10,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class GbSchema : IVirtualPadSchema
{
public virtual IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public virtual IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
switch (core.ControllerDefinition.Name)
{
@ -113,7 +114,7 @@ namespace BizHawk.Client.EmuHawk
[Schema("GB3x")]
public class Gb3XSchema : GbSchema
{
public override IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public override IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
yield return StandardControllerH(1);
yield return StandardControllerH(2);
@ -125,7 +126,7 @@ namespace BizHawk.Client.EmuHawk
[Schema("GB4x")]
public class Gb4XSchema : GbSchema
{
public override IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public override IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
yield return StandardControllerH(1);
yield return StandardControllerH(2);

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
@ -9,7 +10,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class GGLSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
yield return StandardController(1);
yield return StandardController(2);

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
@ -11,7 +12,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class GenSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
if (core is GPGX gpgx)
{

View File

@ -1,10 +1,11 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
public interface IVirtualPadSchema
{
IEnumerable<PadSchema> GetPadSchemas(IEmulator core);
IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox);
}
}

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
@ -15,7 +16,7 @@ namespace BizHawk.Client.EmuHawk
private string StandardControllerName => typeof(StandardController).DisplayName();
private string AnalogControllerName => typeof(FakeAnalogController).DisplayName();
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
var intvSyncSettings = ((Intellivision)core).GetSyncSettings().Clone();
var port1 = intvSyncSettings.Port1;

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
@ -9,7 +10,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class LynxSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
yield return new PadSchema
{

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Common;
@ -11,7 +12,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class N64Schema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
var ss = ((N64)core).GetSyncSettings();
for (var i = 0; i < 4; i++)

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
@ -8,7 +9,7 @@ namespace BizHawk.Client.EmuHawk.tools.VirtualPads.schema
// ReSharper disable once UnusedMember.Global
public class NdsSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
yield return Controller();
yield return Console();

View File

@ -15,7 +15,7 @@ namespace BizHawk.Client.EmuHawk
public class NesSchema : IVirtualPadSchema
{
/// <exception cref="Exception">found <c>ControllerSNES</c></exception>
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
if (core is NES || core is SubNESHawk)
{

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
@ -9,7 +10,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class NgpSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
yield return Controller();
yield return ConsoleButtons();

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
@ -8,7 +9,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class O2Schema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
yield return StandardController(1);
yield return StandardController(2);

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Common;
@ -11,7 +12,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class PsxSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
var psx = (Octoshock)core;
var settings = psx.GetSyncSettings();

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using BizHawk.Common;
using BizHawk.Emulation.Common;
@ -21,17 +21,17 @@ namespace BizHawk.Client.EmuHawk
[Schema("PCE")]
public class PceSchema : IVirtualPadSchema
{
public virtual IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public virtual IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
return core switch
{
PCEngine pce => PceHawkSchemas(pce),
NymaCore nyma => NymaSchemas(nyma),
PCEngine pce => PceHawkSchemas(pce, showMessageBox),
NymaCore nyma => NymaSchemas(nyma, showMessageBox),
_ => Enumerable.Empty<PadSchema>()
};
}
private static IEnumerable<PadSchema> PceHawkSchemas(PCEngine core)
private static IEnumerable<PadSchema> PceHawkSchemas(PCEngine core, Action<string> showMessageBox)
{
var ss = core.GetSyncSettings();
@ -44,18 +44,18 @@ namespace BizHawk.Client.EmuHawk
ss.Port5
}
.Where(p => p != PceControllerType.Unplugged)
.Select((p, i) => PceHawkGenerateSchemaForPort(p, i + 1))
.Select((p, i) => PceHawkGenerateSchemaForPort(p, i + 1, showMessageBox))
.Where(s => s != null);
return padSchemas;
}
private static PadSchema PceHawkGenerateSchemaForPort(PceControllerType type, int controller)
private static PadSchema PceHawkGenerateSchemaForPort(PceControllerType type, int controller, Action<string> showMessageBox)
{
switch (type)
{
default:
MessageBox.Show($"{type} is not supported yet");
showMessageBox($"{type} is not supported yet");
return null;
case PceControllerType.Unplugged:
return null;
@ -83,7 +83,7 @@ namespace BizHawk.Client.EmuHawk
};
}
private static IEnumerable<PadSchema> NymaSchemas(NymaCore nyma)
private static IEnumerable<PadSchema> NymaSchemas(NymaCore nyma, Action<string> showMessageBox)
{
foreach (NymaCore.PortResult result in nyma.ActualPortData)
{
@ -99,7 +99,7 @@ namespace BizHawk.Client.EmuHawk
}
else if (device != "none")
{
MessageBox.Show($"Controller type {device} not supported yet.");
showMessageBox($"Controller type {device} not supported yet.");
}
}

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using BizHawk.Common;
using BizHawk.Emulation.Common;
@ -13,13 +13,13 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class PcfxSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
var nyma = (NymaCore) core;
return NymaSchemas(nyma);
return NymaSchemas(nyma, showMessageBox);
}
private static IEnumerable<PadSchema> NymaSchemas(NymaCore nyma)
private static IEnumerable<PadSchema> NymaSchemas(NymaCore nyma, Action<string> showMessageBox)
{
foreach (NymaCore.PortResult result in nyma.ActualPortData)
{
@ -35,7 +35,7 @@ namespace BizHawk.Client.EmuHawk
}
else if (device != "none")
{
MessageBox.Show($"Controller type {device} not supported yet.");
showMessageBox($"Controller type {device} not supported yet.");
}
}

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
@ -9,7 +10,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class SgbSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
yield return StandardController(1);
yield return StandardController(2);

View File

@ -1,11 +1,12 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using BizHawk.Common;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Waterbox;
namespace BizHawk.Client.EmuHawk
{
[Schema("SAT")]
@ -14,7 +15,7 @@ namespace BizHawk.Client.EmuHawk
{
private static readonly AxisSpec AxisRange = new AxisSpec(0.RangeTo(0xffff), 0x8000);
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
var nyma = (NymaCore)core;
foreach (var result in nyma.ActualPortData
@ -22,7 +23,7 @@ namespace BizHawk.Client.EmuHawk
{
var num = int.Parse(result.Port.ShortName.Last().ToString());
var device = result.Device.ShortName;
var schema = GenerateSchemaForPort(device, num);
var schema = GenerateSchemaForPort(device, num, showMessageBox);
if (schema != null)
{
yield return schema;
@ -32,12 +33,12 @@ namespace BizHawk.Client.EmuHawk
yield return ConsoleButtons();
}
private static PadSchema GenerateSchemaForPort(string device, int controllerNum)
private static PadSchema GenerateSchemaForPort(string device, int controllerNum, Action<string> showMessageBox)
{
switch (device)
{
default:
MessageBox.Show($"This peripheral `{device}` is not supported yet");
showMessageBox($"This peripheral `{device}` is not supported yet");
return null;
case "none":
return null;

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Sega.MasterSystem;
@ -9,7 +10,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class SmsSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
if (((SMS)core).IsGameGear)
{

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Nintendo.SNES;
using BizHawk.Emulation.Cores.Nintendo.SNES9X;
@ -13,7 +13,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class SnesSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
if (core is LibsnesCore bsnes)
{
@ -22,7 +22,7 @@ namespace BizHawk.Client.EmuHawk
if (core is NymaCore nyma)
{
return GetFaustSchemas(nyma);
return GetFaustSchemas(nyma, showMessageBox);
}
return GetSnes9xPadSchemas((Snes9x)core);
@ -115,7 +115,7 @@ namespace BizHawk.Client.EmuHawk
yield return ConsoleButtons();
}
private static IEnumerable<PadSchema> GetFaustSchemas(NymaCore nyma)
private static IEnumerable<PadSchema> GetFaustSchemas(NymaCore nyma, Action<string> showMessageBox)
{
foreach (NymaCore.PortResult result in nyma.ActualPortData)
{
@ -127,7 +127,7 @@ namespace BizHawk.Client.EmuHawk
}
else if (device != "none")
{
MessageBox.Show($"Controller type {device} not supported yet.");
showMessageBox($"Controller type {device} not supported yet.");
}
}

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
@ -10,7 +11,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class VecSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
var vecSyncSettings = ((VectrexHawk)core).GetSyncSettings().Clone();
var port1 = vecSyncSettings.Port1;

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
@ -9,7 +10,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class VirtualBoySchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
yield return StandardController();
yield return ConsoleButtons();

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
@ -9,7 +10,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
public class WonderSwanSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
yield return StandardController(1);
yield return RotatedController(2);

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
@ -9,7 +10,7 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global
internal class ZxSpectrumSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core, Action<string> showMessageBox)
{
yield return Joystick(1);
yield return Joystick(2);