Refactor WaveformOpacityMenuItem to not receive whole config

This commit is contained in:
Dean Herbert
2021-04-21 18:05:26 +09:00
parent cf55383fff
commit c6c91cd9a5
2 changed files with 4 additions and 5 deletions

View File

@ -226,7 +226,7 @@ namespace osu.Game.Screens.Edit
{ {
Items = new[] Items = new[]
{ {
new WaveformOpacityMenu(config) new WaveformOpacityMenuItem(config.GetBindable<float>(OsuSetting.EditorWaveformOpacity)),
} }
} }
} }

View File

@ -4,18 +4,17 @@
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
namespace osu.Game.Screens.Edit namespace osu.Game.Screens.Edit
{ {
internal class WaveformOpacityMenu : MenuItem internal class WaveformOpacityMenuItem : MenuItem
{ {
private readonly Bindable<float> waveformOpacity; private readonly Bindable<float> waveformOpacity;
private readonly Dictionary<float, ToggleMenuItem> menuItemLookup = new Dictionary<float, ToggleMenuItem>(); private readonly Dictionary<float, ToggleMenuItem> menuItemLookup = new Dictionary<float, ToggleMenuItem>();
public WaveformOpacityMenu(OsuConfigManager config) public WaveformOpacityMenuItem(Bindable<float> waveformOpacity)
: base("Waveform opacity") : base("Waveform opacity")
{ {
Items = new[] Items = new[]
@ -26,7 +25,7 @@ namespace osu.Game.Screens.Edit
createMenuItem(1f), createMenuItem(1f),
}; };
waveformOpacity = config.GetBindable<float>(OsuSetting.EditorWaveformOpacity); this.waveformOpacity = waveformOpacity;
waveformOpacity.BindValueChanged(opacity => waveformOpacity.BindValueChanged(opacity =>
{ {
foreach (var kvp in menuItemLookup) foreach (var kvp in menuItemLookup)