Fix ext. tools in repo, update HelloWorld
This commit is contained in:
parent
d4349aefd4
commit
ce2bd6bb9d
|
@ -5,7 +5,6 @@ using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
using BizHawk.Client.Common;
|
using BizHawk.Client.Common;
|
||||||
using BizHawk.Client.EmuHawk;
|
|
||||||
|
|
||||||
using static BizHawk.Experiment.AutoGenConfig.ConfigEditorUIGenerators;
|
using static BizHawk.Experiment.AutoGenConfig.ConfigEditorUIGenerators;
|
||||||
|
|
||||||
|
@ -14,8 +13,9 @@ namespace BizHawk.Experiment.AutoGenConfig
|
||||||
[ExternalTool("AutoGenConfig")]
|
[ExternalTool("AutoGenConfig")]
|
||||||
public class AutoGenConfigForm : Form, IExternalToolForm
|
public class AutoGenConfigForm : Form, IExternalToolForm
|
||||||
{
|
{
|
||||||
[RequiredApi]
|
public ApiContainer? _apiContainer { get; set; }
|
||||||
private IEmulationApi? _emuAPI { get; set; }
|
|
||||||
|
private ApiContainer APIs => _apiContainer ?? throw new NullReferenceException();
|
||||||
|
|
||||||
private static readonly WeakReference<ConfigEditorCache> _cache = new WeakReference<ConfigEditorCache>(new ConfigEditorCache(typeof(Config)));
|
private static readonly WeakReference<ConfigEditorCache> _cache = new WeakReference<ConfigEditorCache>(new ConfigEditorCache(typeof(Config)));
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ namespace BizHawk.Experiment.AutoGenConfig
|
||||||
Text = fi.Name
|
Text = fi.Name
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var config = (_emuAPI as EmulationApi ?? throw new Exception("required API wasn't fulfilled")).ForbiddenConfigReference;
|
var config = (APIs.Emulation as EmulationApi ?? throw new Exception("required API wasn't fulfilled")).ForbiddenConfigReference;
|
||||||
var groupings = new Dictionary<string, object> { [string.Empty] = config };
|
var groupings = new Dictionary<string, object> { [string.Empty] = config };
|
||||||
void TraverseGroupings(object groupingObj, string parentNesting)
|
void TraverseGroupings(object groupingObj, string parentNesting)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,13 +16,35 @@ namespace HelloWorld
|
||||||
[ExternalToolEmbeddedIcon("HelloWorld.icon_Hello.ico")]
|
[ExternalToolEmbeddedIcon("HelloWorld.icon_Hello.ico")]
|
||||||
public partial class CustomMainForm : Form, IExternalToolForm
|
public partial class CustomMainForm : Form, IExternalToolForm
|
||||||
{
|
{
|
||||||
/// <remarks><see cref="RequiredServiceAttribute">RequiredServices</see> are populated by EmuHawk at runtime.</remarks>
|
/// <remarks>
|
||||||
|
/// <see cref="RequiredServiceAttribute">RequiredServices</see> are populated by EmuHawk at runtime.
|
||||||
|
/// These remain supported, but you should only use them when there is no API that does what you want.
|
||||||
|
/// </remarks>
|
||||||
[RequiredService]
|
[RequiredService]
|
||||||
private IEmulator? _emu { get; set; }
|
private IEmulator? _emu { get; set; }
|
||||||
|
|
||||||
[RequiredService]
|
[RequiredService]
|
||||||
private IMemoryDomains? _memoryDomains { get; set; }
|
private IMemoryDomains? _memoryDomains { get; set; }
|
||||||
|
|
||||||
|
/// <remarks>
|
||||||
|
/// <see cref="RequiredApiAttribute">RequiredApis</see> are populated by EmuHawk at runtime.
|
||||||
|
/// You can have props for any subset of the available APIs, or use an <see cref="ApiContainer"/> to get them all at once.
|
||||||
|
/// </remarks>
|
||||||
|
[RequiredApi]
|
||||||
|
private IEmulationApi? _emuApi { get; set; }
|
||||||
|
|
||||||
|
/// <remarks>
|
||||||
|
/// <see cref="ApiContainer"/> can be used as a shorthand for accessing the various APIs, more like the Lua syntax.
|
||||||
|
/// </remarks>
|
||||||
|
public ApiContainer? _apiContainer { get; set; }
|
||||||
|
|
||||||
|
private ApiContainer APIs => _apiContainer ?? throw new NullReferenceException();
|
||||||
|
|
||||||
|
/// <remarks>
|
||||||
|
/// An example of a hack. Hacks should be your last resort because they're prone to break with new releases.
|
||||||
|
/// </remarks>
|
||||||
|
private Config GlobalConfig => (_emuApi as EmulationApi ?? throw new Exception("required API wasn't fulfilled")).ForbiddenConfigReference;
|
||||||
|
|
||||||
private WatchList? _watches;
|
private WatchList? _watches;
|
||||||
|
|
||||||
private WatchList Watches
|
private WatchList Watches
|
||||||
|
@ -48,11 +70,12 @@ namespace HelloWorld
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
label_GameHash.Click += label_GameHash_Click;
|
label_GameHash.Click += label_GameHash_Click;
|
||||||
|
Closing += (sender, args) => APIs.EmuClient.SetClientExtraPadding(0, 0, 0, 0);
|
||||||
|
|
||||||
ClientApi.BeforeQuickSave += (sender, e) =>
|
ClientApi.BeforeQuickSave += (sender, e) =>
|
||||||
{
|
{
|
||||||
if (e.Slot != 0) return; // only take effect on slot 0
|
if (e.Slot != 0) return; // only take effect on slot 0
|
||||||
var basePath = Path.Combine(GlobalWin.Config.PathEntries.SaveStateAbsolutePath(GlobalWin.Game.System), "Test");
|
var basePath = Path.Combine(GlobalConfig.PathEntries.SaveStateAbsolutePath(APIs.Emulation.GetSystemId()), "Test");
|
||||||
if (!Directory.Exists(basePath)) Directory.CreateDirectory(basePath);
|
if (!Directory.Exists(basePath)) Directory.CreateDirectory(basePath);
|
||||||
ClientApi.SaveState(Path.Combine(basePath, e.Name));
|
ClientApi.SaveState(Path.Combine(basePath, e.Name));
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
|
@ -60,7 +83,7 @@ namespace HelloWorld
|
||||||
ClientApi.BeforeQuickLoad += (sender, e) =>
|
ClientApi.BeforeQuickLoad += (sender, e) =>
|
||||||
{
|
{
|
||||||
if (e.Slot != 0) return; // only take effect on slot 0
|
if (e.Slot != 0) return; // only take effect on slot 0
|
||||||
var basePath = Path.Combine(GlobalWin.Config.PathEntries.SaveStateAbsolutePath(GlobalWin.Game.System), "Test");
|
var basePath = Path.Combine(GlobalConfig.PathEntries.SaveStateAbsolutePath(APIs.Emulation.GetSystemId()), "Test");
|
||||||
ClientApi.LoadState(Path.Combine(basePath, e.Name));
|
ClientApi.LoadState(Path.Combine(basePath, e.Name));
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
|
@ -71,15 +94,13 @@ namespace HelloWorld
|
||||||
/// <remarks>This is called once when the form is opened, and every time a new movie session starts.</remarks>
|
/// <remarks>This is called once when the form is opened, and every time a new movie session starts.</remarks>
|
||||||
public void Restart()
|
public void Restart()
|
||||||
{
|
{
|
||||||
#if false
|
APIs.EmuClient.SetClientExtraPadding(50, 50);
|
||||||
ClientApi.SetExtraPadding(50, 50);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (GlobalWin.Game.Name != "Null")
|
if (APIs.GameInfo.GetRomName() != "Null")
|
||||||
{
|
{
|
||||||
Watches.RefreshDomains(_memoryDomains, GlobalWin.Config.RamWatchDefinePrevious);
|
Watches.RefreshDomains(_memoryDomains, GlobalConfig.RamWatchDefinePrevious);
|
||||||
label_Game.Text = $"You're playing {GlobalWin.Game.Name}";
|
label_Game.Text = $"You're playing {APIs.GameInfo.GetRomName()}";
|
||||||
label_GameHash.Text = $"Hash: {GlobalWin.Game.Hash}";
|
label_GameHash.Text = $"Hash: {APIs.GameInfo.GetRomHash()}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -91,12 +112,12 @@ namespace HelloWorld
|
||||||
public void UpdateValues(ToolFormUpdateType type)
|
public void UpdateValues(ToolFormUpdateType type)
|
||||||
{
|
{
|
||||||
if (!(type == ToolFormUpdateType.PreFrame || type == ToolFormUpdateType.FastPreFrame)
|
if (!(type == ToolFormUpdateType.PreFrame || type == ToolFormUpdateType.FastPreFrame)
|
||||||
|| GlobalWin.Game.Name == "Null"
|
|| APIs.GameInfo.GetRomName() == "Null"
|
||||||
|| Watches.Count < 3)
|
|| Watches.Count < 3)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Watches.UpdateValues(GlobalWin.Config.RamWatchDefinePrevious);
|
Watches.UpdateValues(GlobalConfig.RamWatchDefinePrevious);
|
||||||
label_Watch1.Text = $"First watch ({Watches[0].AddressString}) current value: {Watches[0].ValueString}";
|
label_Watch1.Text = $"First watch ({Watches[0].AddressString}) current value: {Watches[0].ValueString}";
|
||||||
label_Watch2.Text = $"Second watch ({Watches[1].AddressString}) current value: {Watches[1].ValueString}";
|
label_Watch2.Text = $"Second watch ({Watches[1].AddressString}) current value: {Watches[1].ValueString}";
|
||||||
label_Watch3.Text = $"Third watch ({Watches[2].AddressString}) current value: {Watches[2].ValueString}";
|
label_Watch3.Text = $"Third watch ({Watches[2].AddressString}) current value: {Watches[2].ValueString}";
|
||||||
|
@ -129,7 +150,7 @@ namespace HelloWorld
|
||||||
ClientApi.SetInput(1, j);
|
ClientApi.SetInput(1, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void label_GameHash_Click(object sender, EventArgs e) => Clipboard.SetText(GlobalWin.Game.Hash);
|
private void label_GameHash_Click(object sender, EventArgs e) => Clipboard.SetText(APIs.GameInfo.GetRomHash());
|
||||||
|
|
||||||
private void loadstate_Click(object sender, EventArgs e)
|
private void loadstate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue