Add editor waveform opacity selection to menu

This commit is contained in:
Dean Herbert
2020-11-03 16:01:14 +09:00
parent 6bf35d5767
commit 7e4314684b
3 changed files with 59 additions and 2 deletions

View File

@ -132,6 +132,8 @@ namespace osu.Game.Configuration
Set(OsuSetting.MenuBackgroundSource, BackgroundSource.Skin);
Set(OsuSetting.SeasonalBackgroundMode, SeasonalBackgroundMode.Sometimes);
Set(OsuSetting.EditorWaveformOpacity, 1f);
}
public OsuConfigManager(Storage storage)
@ -241,6 +243,7 @@ namespace osu.Game.Configuration
HitLighting,
MenuBackgroundSource,
GameplayDisableWinKey,
SeasonalBackgroundMode
SeasonalBackgroundMode,
EditorWaveformOpacity,
}
}

View File

@ -20,6 +20,7 @@ using osu.Framework.Platform;
using osu.Framework.Screens;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface;
@ -103,7 +104,7 @@ namespace osu.Game.Screens.Edit
private MusicController music { get; set; }
[BackgroundDependencyLoader]
private void load(OsuColour colours, GameHost host)
private void load(OsuColour colours, GameHost host, OsuConfigManager config)
{
beatDivisor.Value = Beatmap.Value.BeatmapInfo.BeatDivisor;
beatDivisor.BindValueChanged(divisor => Beatmap.Value.BeatmapInfo.BeatDivisor = divisor.NewValue);
@ -208,6 +209,13 @@ namespace osu.Game.Screens.Edit
copyMenuItem = new EditorMenuItem("Copy", MenuItemType.Standard, Copy),
pasteMenuItem = new EditorMenuItem("Paste", MenuItemType.Standard, Paste),
}
},
new MenuItem("View")
{
Items = new[]
{
new WaveformOpacityMenu(config)
}
}
}
}

View File

@ -0,0 +1,46 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using osu.Framework.Bindables;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Screens.Edit
{
internal class WaveformOpacityMenu : MenuItem
{
private readonly Bindable<float> waveformOpacity;
private readonly Dictionary<float, ToggleMenuItem> menuItemLookup = new Dictionary<float, ToggleMenuItem>();
public WaveformOpacityMenu(OsuConfigManager config)
: base("Waveform opacity")
{
Items = new[]
{
createMenuItem(0.25f),
createMenuItem(0.5f),
createMenuItem(0.75f),
createMenuItem(1f),
};
waveformOpacity = config.GetBindable<float>(OsuSetting.EditorWaveformOpacity);
waveformOpacity.BindValueChanged(opacity =>
{
foreach (var kvp in menuItemLookup)
kvp.Value.State.Value = kvp.Key == opacity.NewValue;
}, true);
}
private ToggleMenuItem createMenuItem(float opacity)
{
var item = new ToggleMenuItem($"{opacity * 100}%", MenuItemType.Standard, _ => updateOpacity(opacity));
menuItemLookup[opacity] = item;
return item;
}
private void updateOpacity(float opacity) => waveformOpacity.Value = opacity;
}
}