Shuffle logic between `ScreenshotForm.UpdateValues` and call-site

This commit is contained in:
James Groom 2024-04-04 23:51:09 +00:00 committed by GitHub
parent 3cb7847b35
commit 73c3056bd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 13 deletions

View File

@ -657,20 +657,22 @@ namespace BizHawk.Client.EmuHawk
&& targetRow < Branches.Count)
{
var branch = Branches[targetRow];
var bb = branch.OSDFrameBuffer;
var width = bb.Width;
Point location = PointToScreen(Location);
int width = branch.OSDFrameBuffer.Width;
int height = branch.OSDFrameBuffer.Height;
location.Offset(-width, 0);
if (location.X < 0)
{
location.Offset(width + Width, 0);
}
_screenshot.UpdateValues(branch, location, width, height,
(int)Graphics.FromHwnd(Handle).MeasureString(
branch.UserText, _screenshot.Font, width).Height);
_screenshot.UpdateValues(
bb,
branch.UserText,
location,
width: width,
height: bb.Height,
Graphics.FromHwnd(Handle).MeasureString);
_screenshot.FadeIn();
}
else

View File

@ -1,7 +1,8 @@
using System.Drawing;
using System;
using System.Drawing;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Bizware.BizwareGL;
// We pretend it's a tooltip kind of thing, so show only the actual contents
// and avoid stealing focus, while still being topmost
@ -58,15 +59,20 @@ namespace BizHawk.Client.EmuHawk
};
}
public void UpdateValues(TasBranch branch, Point location , int width, int height, int padding)
public void UpdateValues(
BitmapBuffer bb,
string captionText,
Point location,
int width,
int height,
Func<string, Font, int, SizeF> measureString)
{
var bb = branch.OSDFrameBuffer;
bb.DiscardAlpha();
_bitmap = bb.ToSysdrawingBitmap();
Width = width;
Padding = padding;
Padding = (int) measureString(captionText, Font, width).Height;
_drawingHeight = height;
Text = branch.UserText;
Text = captionText;
Location = location;
if (Padding > 0)