Skip to content

Commit

Permalink
Add missing params in the Font selector.
Browse files Browse the repository at this point in the history
  • Loading branch information
andy840119 committed Aug 10, 2022
1 parent 1cc313c commit 62fd956
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Rendering;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.IO.Stores;
Expand Down Expand Up @@ -198,12 +199,12 @@ public FontSelector()
}

[BackgroundDependencyLoader]
private void load(FontManager fontManager)
private void load(FontManager fontManager, IRenderer renderer)
{
fonts.BindTo(fontManager.Fonts);

// create local font store and import those files
localFontStore = new KaraokeLocalFontStore(fontManager);
localFontStore = new KaraokeLocalFontStore(fontManager, renderer);
fontStore.AddStore(localFontStore);

Current.BindValueChanged(e =>
Expand Down
8 changes: 4 additions & 4 deletions osu.Game.Rulesets.Karaoke/IO/Stores/KaraokeLocalFontStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#nullable disable

using System.Collections.Generic;
using osu.Framework.Graphics.Rendering;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.IO.Stores;
Expand All @@ -15,19 +16,18 @@ namespace osu.Game.Rulesets.Karaoke.IO.Stores
public class KaraokeLocalFontStore : FontStore
{
private readonly Dictionary<FontInfo, IResourceStore<TextureUpload>> fontInfos = new();
private readonly IResourceStore<TextureUpload> store;
private readonly FontManager fontManager;

/// <summary>
/// Construct a font store to be added to a parent font store via <see cref="AddFont"/>.
/// </summary>
/// <param name="fontManager">font manager.</param>
/// <param name="renderer">The renderer to create textures with.</param>
/// <param name="store">The texture source.</param>
/// <param name="scaleAdjust">The raw pixel height of the font. Can be used to apply a global scale or metric to font usages.</param>
public KaraokeLocalFontStore(FontManager fontManager, IResourceStore<TextureUpload> store = null, float scaleAdjust = 100)
: base(store, scaleAdjust)
public KaraokeLocalFontStore(FontManager fontManager, IRenderer renderer, IResourceStore<TextureUpload> store = null, float scaleAdjust = 100)
: base(renderer, store, scaleAdjust)
{
this.store = store;
this.fontManager = fontManager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Rendering;
using osu.Framework.Graphics.Sprites;
using osu.Framework.IO.Stores;
using osu.Game.Rulesets.Karaoke.Configuration;
Expand Down Expand Up @@ -74,10 +75,10 @@ void addFont(FontUsage fontUsage)
}

[BackgroundDependencyLoader]
private void load(FontManager fontManager, KaraokeRulesetConfigManager config)
private void load(FontManager fontManager, IRenderer renderer, KaraokeRulesetConfigManager config)
{
// create local font store and import those files
localFontStore = new KaraokeLocalFontStore(fontManager);
localFontStore = new KaraokeLocalFontStore(fontManager, renderer);
fontStore.AddStore(localFontStore);

// fonts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Rendering;
using osu.Framework.Graphics.Sprites;
using osu.Framework.IO.Stores;
using osu.Game.Rulesets.Karaoke.Configuration;
Expand All @@ -26,7 +27,7 @@ public class KaraokePlayfieldAdjustmentContainer : PlayfieldAdjustmentContainer
private KaraokeLocalFontStore localFontStore;

[BackgroundDependencyLoader]
private void load(FontManager fontManager, KaraokeRulesetConfigManager manager)
private void load( FontManager fontManager, IRenderer renderer, KaraokeRulesetConfigManager manager)
{
// get all font usage which wants to import.
var targetImportFonts = new[]
Expand All @@ -46,7 +47,7 @@ private void load(FontManager fontManager, KaraokeRulesetConfigManager manager)
return;

// create local font store and import those files
localFontStore = new KaraokeLocalFontStore(fontManager);
localFontStore = new KaraokeLocalFontStore(fontManager, renderer);
fontStore.AddStore(localFontStore);

foreach (var fontInfo in fontInfos)
Expand Down

0 comments on commit 62fd956

Please sign in to comment.