Add overload for `IGuiApi.WithSurface` with stronger encapsulation

This commit is contained in:
YoshiRulz 2024-07-26 16:03:02 +10:00
parent 22e5e035d2
commit 1bc1f1b3d2
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
2 changed files with 16 additions and 0 deletions

View File

@ -65,6 +65,19 @@ namespace BizHawk.Client.Common
{
}
public void WithSurface(DisplaySurfaceID surfaceID, Action<IGuiApi> drawingCallsFunc)
{
_usingSurfaceID = surfaceID;
try
{
drawingCallsFunc(this);
}
finally
{
_usingSurfaceID = null;
}
}
public void WithSurface(DisplaySurfaceID surfaceID, Action drawingCallsFunc)
{
_usingSurfaceID = surfaceID;

View File

@ -12,6 +12,9 @@ namespace BizHawk.Client.Common
[Obsolete("No longer supported, no-op.")]
void SetAttributes(ImageAttributes a);
void WithSurface(DisplaySurfaceID surfaceID, Action<IGuiApi> drawingCallsFunc);
[Obsolete("use the other overload e.g. `APIs.Gui.WithSurface(..., gui => { gui.DrawLine(...); });`")]
void WithSurface(DisplaySurfaceID surfaceID, Action drawingCallsFunc);
[Obsolete("No longer supported, no-op.")]