Promote IEmuClient to a full-fledged IExternalApi
also remove UnpauseEmulation() (duplicate of Unpause()) and rename SetExtraPadding to SetClientExtraPadding (to match Lua)
This commit is contained in:
parent
9597be621a
commit
a74d657a2a
|
@ -5,7 +5,7 @@ using BizHawk.Emulation.Common;
|
|||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public interface IEmuClient
|
||||
public interface IEmuClientApi : IExternalApi
|
||||
{
|
||||
SystemInfo RunningSystem { get; }
|
||||
|
||||
|
@ -173,7 +173,7 @@ namespace BizHawk.Client.Common
|
|||
/// <param name="top">Top padding</param>
|
||||
/// <param name="right">Right padding</param>
|
||||
/// <param name="bottom">Bottom padding</param>
|
||||
void SetExtraPadding(int left, int top = 0, int right = 0, int bottom = 0);
|
||||
void SetClientExtraPadding(int left, int top = 0, int right = 0, int bottom = 0);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements
|
||||
|
@ -211,11 +211,6 @@ namespace BizHawk.Client.Common
|
|||
|
||||
void UnpauseAv();
|
||||
|
||||
/// <summary>
|
||||
/// Resume the emulation
|
||||
/// </summary>
|
||||
void UnpauseEmulation();
|
||||
|
||||
void UpdateEmulatorAndVP(IEmulator emu = null);
|
||||
|
||||
int Xpos();
|
|
@ -8,6 +8,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public sealed class ApiContainer : ApiSubsetContainer
|
||||
{
|
||||
public ICommApi Comm => (ICommApi) Libraries[typeof(ICommApi)];
|
||||
public IEmuClientApi EmuClient => (IEmuClientApi) Libraries[typeof(IEmuClientApi)];
|
||||
public IGuiApi Gui => (IGuiApi) Libraries[typeof(IGuiApi)];
|
||||
public IInputApi Input => (IInputApi) Libraries[typeof(IInputApi)];
|
||||
public ISaveStateApi SaveState => (ISaveStateApi) Libraries[typeof(ISaveStateApi)];
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private static readonly Type[] CtorParamTypesB = { typeof(Action<string>) };
|
||||
|
||||
private static readonly Type[] CtorParamTypesEmuClientApi = { typeof(Action<string>), typeof(DisplayManager), typeof(InputManager), typeof(MainForm), typeof(Config), typeof(IEmulator), typeof(GameInfo) };
|
||||
|
||||
/// <remarks>TODO do we need to keep references to these because of GC weirdness? --yoshi</remarks>
|
||||
private static ApiContainer? _container;
|
||||
|
||||
|
@ -33,9 +35,19 @@ namespace BizHawk.Client.EmuHawk
|
|||
&& typeof(IExternalApi).IsAssignableFrom(t)
|
||||
&& ServiceInjector.IsAvailable(serviceProvider, t)))
|
||||
{
|
||||
var instance = api.GetConstructor(CtorParamTypesA)?.Invoke(new object[] { logCallback, GlobalWin.DisplayManager, GlobalWin.InputManager, mainForm })
|
||||
?? api.GetConstructor(CtorParamTypesB)?.Invoke(new object[] { logCallback })
|
||||
?? Activator.CreateInstance(api);
|
||||
//TODO if extra params are ignored, we can use the same array for every ConstructorInfo.Invoke call --yoshi
|
||||
object instance;
|
||||
if (typeof(IEmuClientApi).IsAssignableFrom(api))
|
||||
{
|
||||
instance = (api.GetConstructor(CtorParamTypesEmuClientApi) ?? throw new Exception("failed to call EmuClientApi's hack-filled ctor"))
|
||||
.Invoke(new object[] { logCallback, GlobalWin.DisplayManager, GlobalWin.InputManager, mainForm, GlobalWin.Config, GlobalWin.Emulator, GlobalWin.Game });
|
||||
}
|
||||
else
|
||||
{
|
||||
instance = api.GetConstructor(CtorParamTypesA)?.Invoke(new object[] { logCallback, GlobalWin.DisplayManager, GlobalWin.InputManager, mainForm })
|
||||
?? api.GetConstructor(CtorParamTypesB)?.Invoke(new object[] { logCallback })
|
||||
?? Activator.CreateInstance(api);
|
||||
}
|
||||
ServiceInjector.UpdateServices(serviceProvider, instance);
|
||||
libDict.Add(
|
||||
api.GetInterfaces().First(intf => typeof(IExternalApi).IsAssignableFrom(intf) && intf != typeof(IExternalApi)),
|
||||
|
@ -46,7 +58,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
public static IExternalApiProvider Restart(MainForm mainForm, IEmulatorServiceProvider newServiceProvider)
|
||||
=> new BasicApiProvider(_container = Register(mainForm, newServiceProvider, Console.WriteLine));
|
||||
{
|
||||
GlobalWin.ClientApi = null;
|
||||
_container = Register(mainForm, newServiceProvider, Console.WriteLine);
|
||||
GlobalWin.ClientApi = _container.EmuClient as EmuClientApi;
|
||||
return new BasicApiProvider(_container);
|
||||
}
|
||||
|
||||
public static ApiContainer RestartLua(MainForm mainForm, IEmulatorServiceProvider newServiceProvider, Action<string> logCallback)
|
||||
=> _luaContainer = Register(mainForm, newServiceProvider, logCallback);
|
||||
|
|
|
@ -8,204 +8,204 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public static class ClientApi
|
||||
{
|
||||
/// <inheritdoc cref="IEmuClient.DoFrameAdvance"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.DoFrameAdvance"/>
|
||||
public static SystemInfo RunningSystem => GlobalWin.ClientApi.RunningSystem;
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.BeforeQuickLoad"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.BeforeQuickLoad"/>
|
||||
public static event BeforeQuickLoadEventHandler BeforeQuickLoad
|
||||
{
|
||||
add => GlobalWin.ClientApi.BeforeQuickLoad += value;
|
||||
remove => GlobalWin.ClientApi.BeforeQuickLoad -= value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.BeforeQuickSave"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.BeforeQuickSave"/>
|
||||
public static event BeforeQuickSaveEventHandler BeforeQuickSave
|
||||
{
|
||||
add => GlobalWin.ClientApi.BeforeQuickSave += value;
|
||||
remove => GlobalWin.ClientApi.BeforeQuickSave -= value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.RomLoaded"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.RomLoaded"/>
|
||||
public static event EventHandler RomLoaded
|
||||
{
|
||||
add => GlobalWin.ClientApi.RomLoaded += value;
|
||||
remove => GlobalWin.ClientApi.RomLoaded -= value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.StateLoaded"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.StateLoaded"/>
|
||||
public static event StateLoadedEventHandler StateLoaded
|
||||
{
|
||||
add => GlobalWin.ClientApi.StateLoaded += value;
|
||||
remove => GlobalWin.ClientApi.StateLoaded -= value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.StateSaved"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.StateSaved"/>
|
||||
public static event StateSavedEventHandler StateSaved
|
||||
{
|
||||
add => GlobalWin.ClientApi.StateSaved += value;
|
||||
remove => GlobalWin.ClientApi.StateSaved -= value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.BorderHeight"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.BorderHeight"/>
|
||||
public static int BorderHeight() => GlobalWin.ClientApi.BorderHeight();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.BorderWidth"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.BorderWidth"/>
|
||||
public static int BorderWidth() => GlobalWin.ClientApi.BorderWidth();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.BufferHeight"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.BufferHeight"/>
|
||||
public static int BufferHeight() => GlobalWin.ClientApi.BufferHeight();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.BufferWidth"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.BufferWidth"/>
|
||||
public static int BufferWidth() => GlobalWin.ClientApi.BufferWidth();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.ClearAutohold"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.ClearAutohold"/>
|
||||
public static void ClearAutohold() => GlobalWin.ClientApi.ClearAutohold();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.CloseEmulator"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.CloseEmulator"/>
|
||||
public static void CloseEmulator() => GlobalWin.ClientApi.CloseEmulator();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.CloseEmulatorWithCode"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.CloseEmulatorWithCode"/>
|
||||
public static void CloseEmulatorWithCode(int exitCode) => GlobalWin.ClientApi.CloseEmulatorWithCode(exitCode);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.CloseRom"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.CloseRom"/>
|
||||
public static void CloseRom() => GlobalWin.ClientApi.CloseRom();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.DisplayMessages"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.DisplayMessages"/>
|
||||
public static void DisplayMessages(bool value) => GlobalWin.ClientApi.DisplayMessages(value);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.DoFrameAdvance"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.DoFrameAdvance"/>
|
||||
public static void DoFrameAdvance() => GlobalWin.ClientApi.DoFrameAdvance();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.DoFrameAdvanceAndUnpause"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.DoFrameAdvanceAndUnpause"/>
|
||||
public static void DoFrameAdvanceAndUnpause() => GlobalWin.ClientApi.DoFrameAdvanceAndUnpause();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.EnableRewind"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.EnableRewind"/>
|
||||
public static void EnableRewind(bool enabled) => GlobalWin.ClientApi.EnableRewind(enabled);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.FrameSkip"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.FrameSkip"/>
|
||||
public static void FrameSkip(int numFrames) => GlobalWin.ClientApi.FrameSkip(numFrames);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.GetInput"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.GetInput"/>
|
||||
public static Joypad GetInput(int player) => GlobalWin.ClientApi.GetInput(player);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.GetSoundOn"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.GetSoundOn"/>
|
||||
public static bool GetSoundOn() => GlobalWin.ClientApi.GetSoundOn();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.GetTargetScanlineIntensity"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.GetTargetScanlineIntensity"/>
|
||||
public static int GetTargetScanlineIntensity() => GlobalWin.ClientApi.GetTargetScanlineIntensity();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.GetWindowSize"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.GetWindowSize"/>
|
||||
public static int GetWindowSize() => GlobalWin.ClientApi.GetWindowSize();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.InvisibleEmulation"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.InvisibleEmulation"/>
|
||||
public static void InvisibleEmulation(bool invisible) => GlobalWin.ClientApi.InvisibleEmulation(invisible);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.IsPaused"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.IsPaused"/>
|
||||
public static bool IsPaused() => GlobalWin.ClientApi.IsPaused();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.IsSeeking"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.IsSeeking"/>
|
||||
public static bool IsSeeking() => GlobalWin.ClientApi.IsSeeking();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.IsTurbo"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.IsTurbo"/>
|
||||
public static bool IsTurbo() => GlobalWin.ClientApi.IsTurbo();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.LoadState"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.LoadState"/>
|
||||
public static void LoadState(string name) => GlobalWin.ClientApi.LoadState(name);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.OnBeforeQuickLoad"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.OnBeforeQuickLoad"/>
|
||||
public static void OnBeforeQuickLoad(object sender, string quickSaveSlotName, out bool eventHandled) => GlobalWin.ClientApi.OnBeforeQuickLoad(sender, quickSaveSlotName, out eventHandled);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.OnBeforeQuickSave"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.OnBeforeQuickSave"/>
|
||||
public static void OnBeforeQuickSave(object sender, string quickSaveSlotName, out bool eventHandled) => GlobalWin.ClientApi.OnBeforeQuickSave(sender, quickSaveSlotName, out eventHandled);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.OnRomLoaded"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.OnRomLoaded"/>
|
||||
public static void OnRomLoaded(IEmulator emu) => GlobalWin.ClientApi.OnRomLoaded(emu);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.OnStateLoaded"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.OnStateLoaded"/>
|
||||
public static void OnStateLoaded(object sender, string stateName) => GlobalWin.ClientApi.OnStateLoaded(sender, stateName);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.OnStateSaved"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.OnStateSaved"/>
|
||||
public static void OnStateSaved(object sender, string stateName) => GlobalWin.ClientApi.OnStateSaved(sender, stateName);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.OpenRom"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.OpenRom"/>
|
||||
public static void OpenRom(string path) => GlobalWin.ClientApi.OpenRom(path);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.Pause"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.Pause"/>
|
||||
public static void Pause() => GlobalWin.ClientApi.Pause();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.PauseAv"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.PauseAv"/>
|
||||
public static void PauseAv() => GlobalWin.ClientApi.PauseAv();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.RebootCore"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.RebootCore"/>
|
||||
public static void RebootCore() => GlobalWin.ClientApi.RebootCore();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.SaveRam"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.SaveRam"/>
|
||||
public static void SaveRam() => GlobalWin.ClientApi.SaveRam();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.SaveState"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.SaveState"/>
|
||||
public static void SaveState(string name) => GlobalWin.ClientApi.SaveState(name);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.ScreenHeight"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.ScreenHeight"/>
|
||||
public static int ScreenHeight() => GlobalWin.ClientApi.ScreenHeight();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.Screenshot"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.Screenshot"/>
|
||||
public static void Screenshot(string path = null) => GlobalWin.ClientApi.Screenshot(path);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.ScreenshotToClipboard"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.ScreenshotToClipboard"/>
|
||||
public static void ScreenshotToClipboard() => GlobalWin.ClientApi.ScreenshotToClipboard();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.ScreenWidth"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.ScreenWidth"/>
|
||||
public static int ScreenWidth() => GlobalWin.ClientApi.ScreenWidth();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.SeekFrame"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.SeekFrame"/>
|
||||
public static void SeekFrame(int frame) => GlobalWin.ClientApi.SeekFrame(frame);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.SetExtraPadding"/>
|
||||
public static void SetExtraPadding(int left, int top = 0, int right = 0, int bottom = 0) => GlobalWin.ClientApi.SetExtraPadding(left, top, right, bottom);
|
||||
/// <inheritdoc cref="IEmuClientApi.SetClientExtraPadding"/>
|
||||
public static void SetExtraPadding(int left, int top = 0, int right = 0, int bottom = 0) => GlobalWin.ClientApi.SetClientExtraPadding(left, top, right, bottom);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.SetGameExtraPadding"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.SetGameExtraPadding"/>
|
||||
public static void SetGameExtraPadding(int left, int top = 0, int right = 0, int bottom = 0) => GlobalWin.ClientApi.SetGameExtraPadding(left, top, right, bottom);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.SetInput"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.SetInput"/>
|
||||
public static void SetInput(int player, Joypad joypad) => GlobalWin.ClientApi.SetInput(player, joypad);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.SetScreenshotOSD"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.SetScreenshotOSD"/>
|
||||
public static void SetScreenshotOSD(bool value) => GlobalWin.ClientApi.SetScreenshotOSD(value);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.SetSoundOn"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.SetSoundOn"/>
|
||||
public static void SetSoundOn(bool enable) => GlobalWin.ClientApi.SetSoundOn(enable);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.SetTargetScanlineIntensity"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.SetTargetScanlineIntensity"/>
|
||||
public static void SetTargetScanlineIntensity(int val) => GlobalWin.ClientApi.SetTargetScanlineIntensity(val);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.SetWindowSize"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.SetWindowSize"/>
|
||||
public static void SetWindowSize(int size) => GlobalWin.ClientApi.SetWindowSize(size);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.SpeedMode"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.SpeedMode"/>
|
||||
public static void SpeedMode(int percent) => GlobalWin.ClientApi.SpeedMode(percent);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.TogglePause"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.TogglePause"/>
|
||||
public static void TogglePause() => GlobalWin.ClientApi.TogglePause();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.TransformPoint"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.TransformPoint"/>
|
||||
public static Point TransformPoint(Point point) => GlobalWin.ClientApi.TransformPoint(point);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.Unpause"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.Unpause"/>
|
||||
public static void Unpause() => GlobalWin.ClientApi.Unpause();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.UnpauseAv"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.UnpauseAv"/>
|
||||
public static void UnpauseAv() => GlobalWin.ClientApi.UnpauseAv();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.UnpauseEmulation"/>
|
||||
public static void UnpauseEmulation() => GlobalWin.ClientApi.UnpauseEmulation();
|
||||
/// <inheritdoc cref="Unpause"/>
|
||||
public static void UnpauseEmulation() => Unpause();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.UpdateEmulatorAndVP"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.UpdateEmulatorAndVP"/>
|
||||
public static void UpdateEmulatorAndVP(IEmulator emu = null) => GlobalWin.ClientApi.UpdateEmulatorAndVP(emu);
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.Xpos"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.Xpos"/>
|
||||
public static int Xpos() => GlobalWin.ClientApi.Xpos();
|
||||
|
||||
/// <inheritdoc cref="IEmuClient.Ypos"/>
|
||||
/// <inheritdoc cref="IEmuClientApi.Ypos"/>
|
||||
public static int Ypos() => GlobalWin.ClientApi.Ypos();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ using BizHawk.Emulation.Cores.Sega.MasterSystem;
|
|||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public class EmuClientApi : IEmuClient
|
||||
public class EmuClientApi : IEmuClientApi
|
||||
{
|
||||
private List<Joypad> _allJoyPads;
|
||||
|
||||
|
@ -27,6 +27,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private readonly MainForm _mainForm;
|
||||
|
||||
private readonly Action<string> _logCallback;
|
||||
|
||||
private IEmulator _maybeEmulator;
|
||||
|
||||
public IEmulator Emulator;
|
||||
|
@ -83,13 +85,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public event StateSavedEventHandler StateSaved;
|
||||
|
||||
public EmuClientApi(Config config, DisplayManager displayManager, IEmulator emulator, GameInfo game, InputManager inputManager, MainForm mainForm)
|
||||
public EmuClientApi(Action<string> logCallback, DisplayManager displayManager, InputManager inputManager, MainForm mainForm, Config config, IEmulator emulator, GameInfo game)
|
||||
{
|
||||
_config = config;
|
||||
_displayManager = displayManager;
|
||||
Emulator = emulator;
|
||||
Game = game;
|
||||
_inputManager = inputManager;
|
||||
_logCallback = logCallback;
|
||||
_mainForm = mainForm;
|
||||
}
|
||||
|
||||
|
@ -121,7 +124,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public void DoFrameAdvanceAndUnpause()
|
||||
{
|
||||
DoFrameAdvance();
|
||||
UnpauseEmulation();
|
||||
Unpause();
|
||||
}
|
||||
|
||||
public void EnableRewind(bool enabled) => _mainForm.EnableRewind(enabled);
|
||||
|
@ -135,7 +138,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Invalid frame skip value");
|
||||
_logCallback("Invalid frame skip value");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -265,7 +268,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (!wasPaused) _mainForm.UnpauseEmulator();
|
||||
}
|
||||
|
||||
public void SetExtraPadding(int left, int top, int right, int bottom)
|
||||
public void SetClientExtraPadding(int left, int top, int right, int bottom)
|
||||
{
|
||||
_displayManager.ClientExtraPadding = new Padding(left, top, right, bottom);
|
||||
_mainForm.FrameBufferResized();
|
||||
|
@ -329,14 +332,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Invalid window size");
|
||||
_logCallback("Invalid window size");
|
||||
}
|
||||
}
|
||||
|
||||
public void SpeedMode(int percent)
|
||||
{
|
||||
if (percent.StrictlyBoundedBy(0.RangeTo(6400))) _mainForm.ClickSpeedItem(percent);
|
||||
else Console.WriteLine("Invalid speed value");
|
||||
else _logCallback("Invalid speed value");
|
||||
}
|
||||
|
||||
public void TogglePause() => _mainForm.TogglePause();
|
||||
|
@ -347,8 +350,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void UnpauseAv() => _mainForm.PauseAvi = false;
|
||||
|
||||
public void UnpauseEmulation() => _mainForm.UnpauseEmulator();
|
||||
|
||||
public void UpdateEmulatorAndVP(IEmulator emu)
|
||||
{
|
||||
_maybeEmulator = emu;
|
||||
|
|
|
@ -276,8 +276,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public MainForm(string[] args)
|
||||
{
|
||||
GlobalWin.ClientApi = new EmuClientApi(Config, DisplayManager, Emulator, Game, InputManager, this);
|
||||
|
||||
//do this threaded stuff early so it has plenty of time to run in background
|
||||
Database.InitializeDatabase(Path.Combine(PathUtils.ExeDirectoryPath, "gamedb", "gamedb.txt"));
|
||||
BootGodDb.Initialize(Path.Combine(PathUtils.ExeDirectoryPath, "gamedb"));
|
||||
|
@ -295,7 +293,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Icon = Properties.Resources.logo;
|
||||
InitializeComponent();
|
||||
SetImages();
|
||||
Game = GameInfo.NullInstance;
|
||||
GlobalWin.Game = GameInfo.NullInstance;
|
||||
|
||||
_throttle = new Throttle();
|
||||
|
||||
|
@ -829,7 +827,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private set
|
||||
{
|
||||
GlobalWin.ClientApi.Emulator = GlobalWin.Emulator = value;
|
||||
GlobalWin.Emulator = value;
|
||||
if (GlobalWin.ClientApi != null) GlobalWin.ClientApi.Emulator = value; // first call to this setter is in the ctor, before the APIs have been registered by the ToolManager ctor
|
||||
_currentVideoProvider = GlobalWin.Emulator.AsVideoProviderOrDefault();
|
||||
_currentSoundProvider = GlobalWin.Emulator.AsSoundProviderOrDefault();
|
||||
}
|
||||
|
@ -856,11 +855,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private set => GlobalWin.MovieSession = value;
|
||||
}
|
||||
|
||||
private GameInfo Game
|
||||
{
|
||||
get => GlobalWin.Game;
|
||||
set => GlobalWin.ClientApi.Game = GlobalWin.Game = value;
|
||||
}
|
||||
private GameInfo Game => GlobalWin.Game;
|
||||
|
||||
private Sound Sound => GlobalWin.Sound;
|
||||
public CheatCollection CheatList { get; }
|
||||
|
|
Loading…
Reference in New Issue