Always initialize MMF LUA functions
This commit is contained in:
parent
308d34890c
commit
457ff87481
|
@ -27,7 +27,15 @@ namespace BizHawk.Client.Common
|
||||||
return Encoding.UTF8.GetString(bytes);
|
return Encoding.UTF8.GetString(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ScreenShotToFile() => WriteToFile(Filename, _takeScreenshotCallback());
|
public int ScreenShotToFile()
|
||||||
|
{
|
||||||
|
if (Filename is null)
|
||||||
|
{
|
||||||
|
Console.WriteLine("MMF screenshot target not set; start EmuHawk with `--mmf=filename`");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return WriteToFile(Filename, _takeScreenshotCallback());
|
||||||
|
}
|
||||||
|
|
||||||
public int WriteToFile(string filename, byte[] outputBytes)
|
public int WriteToFile(string filename, byte[] outputBytes)
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace BizHawk.Client.Common
|
||||||
return APIs.Comm.Sockets.SendString(SendString);
|
return APIs.Comm.Sockets.SendString(SendString);
|
||||||
}
|
}
|
||||||
|
|
||||||
[LuaMethod("socketServerSendBytes", "sends a string to the Socket server")]
|
[LuaMethod("socketServerSendBytes", "sends bytes to the Socket server")]
|
||||||
public int SocketServerSendBytes(LuaTable byteArray)
|
public int SocketServerSendBytes(LuaTable byteArray)
|
||||||
{
|
{
|
||||||
if (!CheckSocketServer()) return -1;
|
if (!CheckSocketServer()) return -1;
|
||||||
|
@ -133,43 +133,30 @@ namespace BizHawk.Client.Common
|
||||||
[LuaMethod("mmfSetFilename", "Sets the filename for the screenshots")]
|
[LuaMethod("mmfSetFilename", "Sets the filename for the screenshots")]
|
||||||
public void MmfSetFilename(string filename)
|
public void MmfSetFilename(string filename)
|
||||||
{
|
{
|
||||||
CheckMmf();
|
|
||||||
APIs.Comm.MMF.Filename = filename;
|
APIs.Comm.MMF.Filename = filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
[LuaMethod("mmfGetFilename", "Gets the filename for the screenshots")]
|
[LuaMethod("mmfGetFilename", "Gets the filename for the screenshots")]
|
||||||
public string MmfGetFilename()
|
public string MmfGetFilename()
|
||||||
{
|
{
|
||||||
CheckMmf();
|
return APIs.Comm.MMF.Filename;
|
||||||
return APIs.Comm.MMF?.Filename;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[LuaMethod("mmfScreenshot", "Saves screenshot to memory mapped file")]
|
[LuaMethod("mmfScreenshot", "Saves screenshot to memory mapped file")]
|
||||||
public int MmfScreenshot()
|
public int MmfScreenshot()
|
||||||
{
|
{
|
||||||
CheckMmf();
|
|
||||||
return APIs.Comm.MMF.ScreenShotToFile();
|
return APIs.Comm.MMF.ScreenShotToFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
[LuaMethod("mmfWrite", "Writes a string to a memory mapped file")]
|
[LuaMethod("mmfWrite", "Writes a string to a memory mapped file")]
|
||||||
public int MmfWrite(string mmf_filename, string outputString)
|
public int MmfWrite(string mmf_filename, string outputString)
|
||||||
{
|
{
|
||||||
CheckMmf();
|
|
||||||
return APIs.Comm.MMF.WriteToFile(mmf_filename, outputString);
|
return APIs.Comm.MMF.WriteToFile(mmf_filename, outputString);
|
||||||
}
|
}
|
||||||
[LuaMethod("mmfRead", "Reads a string from a memory mapped file")]
|
[LuaMethod("mmfRead", "Reads a string from a memory mapped file")]
|
||||||
public string MmfRead(string mmf_filename, int expectedSize)
|
public string MmfRead(string mmf_filename, int expectedSize)
|
||||||
{
|
{
|
||||||
CheckMmf();
|
return APIs.Comm.MMF.ReadFromFile(mmf_filename, expectedSize);
|
||||||
return APIs.Comm.MMF?.ReadFromFile(mmf_filename, expectedSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckMmf()
|
|
||||||
{
|
|
||||||
if (APIs.Comm.MMF == null)
|
|
||||||
{
|
|
||||||
Log("Memory mapped file was not initialized, please initialize it via the command line");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// All HTTP related methods
|
// All HTTP related methods
|
||||||
|
|
|
@ -605,9 +605,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_argParser.HTTPAddresses == null
|
_argParser.HTTPAddresses == null
|
||||||
? null
|
? null
|
||||||
: new HttpCommunication(NetworkingTakeScreenshot, _argParser.HTTPAddresses.Value.UrlGet, _argParser.HTTPAddresses.Value.UrlPost),
|
: new HttpCommunication(NetworkingTakeScreenshot, _argParser.HTTPAddresses.Value.UrlGet, _argParser.HTTPAddresses.Value.UrlPost),
|
||||||
_argParser.MMFFilename == null
|
new MemoryMappedFiles(NetworkingTakeScreenshot, _argParser.MMFFilename),
|
||||||
? null
|
|
||||||
: new MemoryMappedFiles(NetworkingTakeScreenshot, _argParser.MMFFilename),
|
|
||||||
_argParser.SocketAddress == null
|
_argParser.SocketAddress == null
|
||||||
? null
|
? null
|
||||||
: new SocketServer(NetworkingTakeScreenshot, _argParser.SocketAddress.Value.IP, _argParser.SocketAddress.Value.Port)
|
: new SocketServer(NetworkingTakeScreenshot, _argParser.SocketAddress.Value.IP, _argParser.SocketAddress.Value.Port)
|
||||||
|
|
Loading…
Reference in New Issue