Replace IBlitterFont w/ the type wrapped by its sole inheritor

This commit is contained in:
YoshiRulz 2020-12-29 15:32:25 +10:00
parent 47670714b5
commit 23a8387dc1
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 9 additions and 28 deletions

View File

@ -1190,34 +1190,16 @@ namespace BizHawk.Client.EmuHawk
_owner = dispManager;
}
private class FontWrapper : IBlitterFont
{
public FontWrapper(StringRenderer font)
{
Font = font;
}
public StringRenderer GetFontType(string fontType) => _owner._theOneFont;
public readonly StringRenderer Font;
}
IBlitterFont IBlitter.GetFontType(string fontType)
public void DrawString(string s, StringRenderer font, Color color, float x, float y)
{
return new FontWrapper(_owner._theOneFont);
}
void IBlitter.DrawString(string s, IBlitterFont font, Color color, float x, float y)
{
var stringRenderer = ((FontWrapper)font).Font;
_owner._renderer.SetModulateColor(color);
stringRenderer.RenderString(_owner._renderer, x, y, s);
font.RenderString(_owner._renderer, x, y, s);
_owner._renderer.SetModulateColorWhite();
}
SizeF IBlitter.MeasureString(string s, IBlitterFont font)
{
var stringRenderer = ((FontWrapper)font).Font;
return stringRenderer.Measure(s);
}
public SizeF MeasureString(string s, StringRenderer font) => font.Measure(s);
public Rectangle ClipBounds { get; set; }
}

View File

@ -4,6 +4,7 @@ using System.Text;
using System.Drawing;
using System.Collections.Generic;
using BizHawk.Bizware.BizwareGL;
using BizHawk.Emulation.Common;
using BizHawk.Client.Common;
@ -16,9 +17,9 @@ namespace BizHawk.Client.EmuHawk
/// </summary>
public interface IBlitter
{
IBlitterFont GetFontType(string fontType);
void DrawString(string s, IBlitterFont font, Color color, float x, float y);
SizeF MeasureString(string s, IBlitterFont font);
StringRenderer GetFontType(string fontType);
void DrawString(string s, StringRenderer font, Color color, float x, float y);
SizeF MeasureString(string s, StringRenderer font);
Rectangle ClipBounds { get; set; }
}
@ -61,7 +62,7 @@ namespace BizHawk.Client.EmuHawk
}
public string Fps { get; set; }
public IBlitterFont MessageFont;
public StringRenderer MessageFont;
public void Begin(IBlitter blitter)
{

View File

@ -73,6 +73,4 @@ namespace BizHawk.Client.EmuHawk
public Size NativeSize => GraphicsControl.ClientSize;
}
public interface IBlitterFont { }
}