Inject platform dependency in SpriteFont.

This avoids needing to access the global Game.Renderer.
This commit is contained in:
RoosterDragon
2024-04-05 18:45:59 +01:00
committed by Gustas
parent 377bb4b6cc
commit 2c96f6ec8b
3 changed files with 26 additions and 25 deletions

View File

@@ -134,8 +134,9 @@ namespace OpenRA
fontSheetBuilder?.Dispose();
fontSheetBuilder = new SheetBuilder(SheetType.BGRA, 512);
Fonts = modData.Manifest.Get<Fonts>().FontList.ToDictionary(x => x.Key,
x => new SpriteFont(x.Value.Font, modData.DefaultFileSystem.Open(x.Value.Font).ReadAllBytes(),
x.Value.Size, x.Value.Ascender, Window.EffectiveWindowScale, fontSheetBuilder));
x => new SpriteFont(
platform, x.Value.Font, modData.DefaultFileSystem.Open(x.Value.Font).ReadAllBytes(),
x.Value.Size, x.Value.Ascender, Window.EffectiveWindowScale, fontSheetBuilder));
}
Window.OnWindowScaleChanged += (oldNative, oldEffective, newNative, newEffective) =>
@@ -563,11 +564,6 @@ namespace OpenRA
public string GLVersion => Context.GLVersion;
public IFont CreateFont(byte[] data)
{
return platform.CreateFont(data);
}
public int DisplayCount => Window.DisplayCount;
public int CurrentDisplay => Window.CurrentDisplay;