lua: add gui.DrawFinish() which will let you choose when to finish drawing; and add optional argument to gui.DrawNew which when set to false lets you keep it from being cleared.

This commit is contained in:
zeromus 2016-04-21 16:43:37 -05:00
parent c069f8fe5c
commit 676b5791f6
2 changed files with 12 additions and 7 deletions

View File

@ -869,7 +869,7 @@ namespace BizHawk.Client.EmuHawk
/// <summary>
/// Locks the requested lua surface name
/// </summary>
public DisplaySurface LockLuaSurface(string name)
public DisplaySurface LockLuaSurface(string name, bool clear=true)
{
if (MapNameToLuaSurface.ContainsKey(name))
throw new InvalidOperationException("Lua surface is already locked: " + name);
@ -898,7 +898,7 @@ namespace BizHawk.Client.EmuHawk
else if(name == "native") { width = currNativeWidth; height = currNativeHeight; }
else throw new InvalidOperationException("Unknown lua surface name: " +name);
DisplaySurface ret = sdss.AllocateSurface(width, height);
DisplaySurface ret = sdss.AllocateSurface(width, height, clear);
MapNameToLuaSurface[name] = ret;
MapLuaSurfaceToName[ret] = name;
return ret;
@ -913,8 +913,9 @@ namespace BizHawk.Client.EmuHawk
var surf = PeekLockedLuaSurface(kvp.Key);
DisplaySurface surfLocked = null;
if (surf == null)
surf = surfLocked = LockLuaSurface(kvp.Key);
surf.Clear();
surf = surfLocked = LockLuaSurface(kvp.Key,true);
//zero 21-apr-2016 - we shouldnt need this
//surf.Clear();
if (surfLocked != null)
UnlockLuaSurface(surfLocked);
LuaSurfaceSets[kvp.Key].SetPending(null);

View File

@ -54,14 +54,14 @@ namespace BizHawk.Client.EmuHawk
[LuaMethodAttributes(
"DrawNew",
"Changes drawing target to the specified lua surface name. This may clobber any previous drawing to this surface."
"Changes drawing target to the specified lua surface name. This may clobber any previous drawing to this surface (pass false if you don't want it to)"
)]
public void DrawNew(string name)
public void DrawNew(string name, bool? clear=true)
{
try
{
DrawFinish();
_luaSurface = GlobalWin.DisplayManager.LockLuaSurface(name);
_luaSurface = GlobalWin.DisplayManager.LockLuaSurface(name,clear??true);
}
catch (InvalidOperationException ex)
{
@ -69,6 +69,10 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"DrawFinish",
"Finishes drawing to the current lua surface and causes it to get displayed."
)]
public void DrawFinish()
{
if(_luaSurface != null)