From a350e95e406606931a384a644c037e2452c96b0f Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 30 Nov 2016 09:08:11 -0500 Subject: [PATCH] Add OptionsSlider and wire up volume sliders --- .../Overlays/Options/Audio/VolumeOptions.cs | 17 +++---- osu.Game/Overlays/Options/OptionsSlider.cs | 48 +++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 3 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 osu.Game/Overlays/Options/OptionsSlider.cs diff --git a/osu.Game/Overlays/Options/Audio/VolumeOptions.cs b/osu.Game/Overlays/Options/Audio/VolumeOptions.cs index 2216602a5f..f7d2614a96 100644 --- a/osu.Game/Overlays/Options/Audio/VolumeOptions.cs +++ b/osu.Game/Overlays/Options/Audio/VolumeOptions.cs @@ -3,6 +3,7 @@ using osu.Framework; using osu.Framework.Allocation; +using osu.Framework.Audio; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; @@ -14,21 +15,15 @@ namespace osu.Game.Overlays.Options.Audio { protected override string Header => "Volume"; - private CheckBoxOption ignoreHitsounds; - - public VolumeOptions() - { - } - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) + private void load(OsuConfigManager config, AudioManager audio) { Children = new Drawable[] { - new SpriteText { Text = "Master: TODO slider" }, - new SpriteText { Text = "Music: TODO slider" }, - new SpriteText { Text = "Effect: TODO slider" }, - ignoreHitsounds = new CheckBoxOption + new OptionsSlider { Label = "Master", Bindable = audio.Volume }, + new OptionsSlider { Label = "Effect", Bindable = audio.VolumeSample }, + new OptionsSlider { Label = "Music", Bindable = audio.VolumeTrack }, + new CheckBoxOption { LabelText = "Ignore beatmap hitsounds", Bindable = config.GetBindable(OsuConfig.IgnoreBeatmapSamples) diff --git a/osu.Game/Overlays/Options/OptionsSlider.cs b/osu.Game/Overlays/Options/OptionsSlider.cs new file mode 100644 index 0000000000..a8d0a3da6f --- /dev/null +++ b/osu.Game/Overlays/Options/OptionsSlider.cs @@ -0,0 +1,48 @@ +using System; +using OpenTK.Graphics; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; + +namespace osu.Game.Overlays.Options +{ + public class OptionsSlider : FlowContainer + { + private SliderBar slider; + private SpriteText text; + + public string Label + { + get { return text.Text; } + set { text.Text = value; } + } + + public BindableDouble Bindable + { + get { return slider.Bindable; } + set { slider.Bindable = value; } + } + + public OptionsSlider() + { + Direction = FlowDirection.VerticalOnly; + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Children = new Drawable[] + { + text = new SpriteText(), + slider = new SliderBar + { + Margin = new MarginPadding { Top = 5 }, + Height = 10, + RelativeSizeAxes = Axes.X, + Color = Color4.White, + SelectionColor = new Color4(255, 102, 170, 255), + } + }; + } + } +} \ No newline at end of file diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index c4915b7567..e03f8f3337 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -222,6 +222,7 @@ +