Add command-line switch --open-ext-tool-dll

takes an absolute path; or a relative path with or without `.dll` (relative to
ExternalTools)
This commit is contained in:
YoshiRulz 2020-08-28 04:38:38 +10:00
parent 0109386049
commit e128cb82f2
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
2 changed files with 30 additions and 0 deletions

View File

@ -39,6 +39,7 @@ namespace BizHawk.Client.EmuHawk
public HttpCommunication httpCommunication = null;
public SocketServer socketServer = null;
public MemoryMappedFiles memoryMappedFiles = null;
public string openExtToolDll;
/// <exception cref="ArgParserException"><c>--socket_ip</c> passed without specifying <c>--socket_port</c> or vice-versa</exception>
public void ParseArguments(string[] args, Func<byte[]> takeScreenshotCallback)
@ -146,6 +147,13 @@ namespace BizHawk.Client.EmuHawk
{
audiosync = arg.Substring(arg.IndexOf('=') + 1) == "true";
}
else if (arg.StartsWith("--open-ext-tool-dll="))
{
// the first ext. tool from ExternalToolManager.ToolStripMenu which satisfies both of these will be opened:
// - available (no load errors, correct system/rom, etc.)
// - dll path matches given string; or dll filename matches given string with or without `.dll`
openExtToolDll = args[i].Substring(20);
}
else
{
cmdRom = args[i];

View File

@ -153,6 +153,26 @@ namespace BizHawk.Client.EmuHawk
};
UpdateChecker.GlobalConfig = Config;
UpdateChecker.BeginCheck(); // Won't actually check unless enabled by user
// open requested ext. tool
var requestedExtToolDll = _argParser.openExtToolDll;
if (requestedExtToolDll != null)
{
var enabled = ExternalToolManager.ToolStripMenu.Where(item => item.Enabled)
.Select(item => (ValueTuple<string, string>) item.Tag)
.ToList();
try
{
var found = enabled.First(tuple => tuple.Item1 == requestedExtToolDll
|| Path.GetFileName(tuple.Item1) == requestedExtToolDll
|| Path.GetFileNameWithoutExtension(tuple.Item1) == requestedExtToolDll);
Tools.LoadExternalToolForm(found.Item1, found.Item2);
}
catch (Exception)
{
Console.WriteLine($"requested ext. tool dll {requestedExtToolDll} could not be loaded");
}
}
}
static MainForm()
@ -1552,6 +1572,8 @@ namespace BizHawk.Client.EmuHawk
// input state which has been destined for client hotkey consumption are colesced here
private readonly InputCoalescer _hotkeyCoalescer = new InputCoalescer();
private readonly (string, string)? _loadExtToolForm;
private readonly PresentationPanel PresentationPanel;
// countdown for saveram autoflushing