From a3db259071586718122430c1808ddca73d085423 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 23 Nov 2016 06:15:19 -0500 Subject: [PATCH 1/5] Fix VolumeMeter.Bindable --- osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs index f13019e72c..f4083c55b3 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs @@ -13,7 +13,7 @@ namespace osu.Game.Graphics.UserInterface.Volume internal class VolumeMeter : Container { private Box meterFill; - public BindableDouble Bindable; + public BindableDouble Bindable { get; private set; } public VolumeMeter(string meterName) { From 69cb9cf4debf52612815f2547e3e85bd9ec9b2e0 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 23 Nov 2016 06:26:46 -0500 Subject: [PATCH 2/5] Fix up volume encapsulation --- .../UserInterface/Volume/VolumeControl.cs | 35 ++++++++++++------- .../UserInterface/Volume/VolumeMeter.cs | 2 +- osu.Game/OsuGame.cs | 7 +--- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs index 364ef1c7aa..c94eb40c17 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs @@ -6,16 +6,17 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Input; using osu.Framework.Threading; using OpenTK; -using osu.Framework.Allocation; using osu.Framework.Graphics.Primitives; +using osu.Framework.Audio; +using osu.Framework.Allocation; namespace osu.Game.Graphics.UserInterface.Volume { internal class VolumeControl : OverlayContainer { - public BindableDouble VolumeGlobal { get; set; } - public BindableDouble VolumeSample { get; set; } - public BindableDouble VolumeTrack { get; set; } + private BindableDouble volumeGlobal = new BindableDouble(); + private BindableDouble volumeSample = new BindableDouble(); + private BindableDouble volumeTrack = new BindableDouble(); private VolumeMeter volumeMeterMaster; @@ -54,20 +55,20 @@ namespace osu.Game.Graphics.UserInterface.Volume { base.LoadComplete(); - VolumeGlobal.ValueChanged += volumeChanged; - VolumeSample.ValueChanged += volumeChanged; - VolumeTrack.ValueChanged += volumeChanged; + volumeGlobal.ValueChanged += volumeChanged; + volumeSample.ValueChanged += volumeChanged; + volumeTrack.ValueChanged += volumeChanged; - volumeMeterMaster.Bindable = VolumeGlobal; - volumeMeterEffect.Bindable = VolumeSample; - volumeMeterMusic.Bindable = VolumeTrack; + volumeMeterMaster.Bindable.Weld(volumeGlobal); + volumeMeterEffect.Bindable.Weld(volumeSample); + volumeMeterMusic.Bindable.Weld(volumeTrack); } protected override void Dispose(bool isDisposing) { - VolumeGlobal.ValueChanged -= volumeChanged; - VolumeSample.ValueChanged -= volumeChanged; - VolumeTrack.ValueChanged -= volumeChanged; + volumeGlobal.ValueChanged -= volumeChanged; + volumeSample.ValueChanged -= volumeChanged; + volumeTrack.ValueChanged -= volumeChanged; base.Dispose(isDisposing); } @@ -82,6 +83,14 @@ namespace osu.Game.Graphics.UserInterface.Volume volumeMeterMaster.TriggerWheel(state); } + [BackgroundDependencyLoader] + private void load(AudioManager audio) + { + volumeGlobal.Weld(audio.Volume); + volumeSample.Weld(audio.VolumeSample); + volumeTrack.Weld(audio.VolumeTrack); + } + ScheduledDelegate popOutDelegate; private VolumeMeter volumeMeterEffect; diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs index f4083c55b3..230066cf9b 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs @@ -13,7 +13,7 @@ namespace osu.Game.Graphics.UserInterface.Volume internal class VolumeMeter : Container { private Box meterFill; - public BindableDouble Bindable { get; private set; } + public BindableDouble Bindable { get; private set; } = new BindableDouble(); public VolumeMeter(string meterName) { diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 4f40899500..7bf7e4cd2a 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -97,12 +97,7 @@ namespace osu.Game { RelativeSizeAxes = Axes.Both, }, - volume = new VolumeControl - { - VolumeGlobal = Audio.Volume, - VolumeSample = Audio.VolumeSample, - VolumeTrack = Audio.VolumeTrack - }, + volume = new VolumeControl(), overlayContent = new Container{ RelativeSizeAxes = Axes.Both }, new GlobalHotkeys //exists because UserInputManager is at a level below us. { From 89effca12ea9cb414c8fee8e49042f5f3bb48700 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 23 Nov 2016 06:38:33 -0500 Subject: [PATCH 3/5] Remove need for PlaySongSelect ctor to take a db --- osu-framework | 2 +- .../Tests/TestCasePlaySongSelect.cs | 49 ++++++++++--------- osu.Game/OsuGameBase.cs | 2 +- osu.Game/Screens/Select/PlaySongSelect.cs | 5 +- 4 files changed, 28 insertions(+), 30 deletions(-) diff --git a/osu-framework b/osu-framework index 09c18c415d..d9bd79c4c1 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 09c18c415d280448c44cb73f2c4e60e0092b974c +Subproject commit d9bd79c4c15f7e5eb4e69fa7898b7d358e4516e4 diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs index 244982ded3..57dbb2d266 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs @@ -1,31 +1,32 @@ -//Copyright (c) 2007-2016 ppy Pty Ltd . -//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System.Collections.Generic; -using osu.Desktop.VisualTests.Platform; -using osu.Framework.GameModes.Testing; -using osu.Game.Database; -using osu.Game.Modes; -using osu.Game.Screens.Select; - -namespace osu.Desktop.VisualTests.Tests -{ - class TestCasePlaySongSelect : TestCase - { - private BeatmapDatabase db; - private TestStorage storage; - - public override string Name => @"Song Select"; +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using osu.Desktop.VisualTests.Platform; +using osu.Framework.GameModes.Testing; +using osu.Game.Database; +using osu.Game.Modes; +using osu.Game.Screens.Select; + +namespace osu.Desktop.VisualTests.Tests +{ + class TestCasePlaySongSelect : TestCase + { + private BeatmapDatabase db; + private TestStorage storage; + + public override string Name => @"Song Select"; public override string Description => @"with fake data"; - public override void Reset() - { + public override void Reset() + { base.Reset(); if (db == null) { storage = new TestStorage(@"TestCasePlaySongSelect"); db = new BeatmapDatabase(storage); + Dependencies.Cache(db, true); var sets = new List(); @@ -35,7 +36,7 @@ namespace osu.Desktop.VisualTests.Tests db.Import(sets); } - Add(new PlaySongSelect(db)); + Add(new PlaySongSelect()); } private BeatmapSetInfo createTestBeatmapSet(int i) @@ -89,6 +90,6 @@ namespace osu.Desktop.VisualTests.Tests }, }), }; - } - } -} + } + } +} diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 7b05093dde..2f3e5025b7 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -45,7 +45,7 @@ namespace osu.Game Dependencies.Cache(new BeatmapDatabase(Host.Storage, Host)); //this completely overrides the framework default. will need to change once we make a proper FontStore. - Dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 0.01f }); + Dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 0.01f }, true); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont")); diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 76ecdcb64e..371d014659 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -73,11 +73,8 @@ namespace osu.Game.Screens.Select } } - /// Optionally provide a database to use instead of the OsuGame one. - public PlaySongSelect(BeatmapDatabase database = null) + public PlaySongSelect() { - this.database = database; - const float carouselWidth = 640; const float bottomToolHeight = 50; Children = new Drawable[] From 2013f93a968b523da04285965ea99780da4e602d Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 25 Nov 2016 02:31:19 -0500 Subject: [PATCH 4/5] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index d9bd79c4c1..60e210c1aa 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit d9bd79c4c15f7e5eb4e69fa7898b7d358e4516e4 +Subproject commit 60e210c1aa62a114fb08e50797f8f839da326cc3 From c85454d0343fd6c5d1fc71de17c380c41abc0141 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 25 Nov 2016 05:12:01 -0500 Subject: [PATCH 5/5] Reset db on dispose --- .../Tests/TestCasePlaySongSelect.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs index 57dbb2d266..5d85bf0a5d 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs @@ -12,7 +12,7 @@ namespace osu.Desktop.VisualTests.Tests { class TestCasePlaySongSelect : TestCase { - private BeatmapDatabase db; + private BeatmapDatabase db, oldDb; private TestStorage storage; public override string Name => @"Song Select"; @@ -21,7 +21,7 @@ namespace osu.Desktop.VisualTests.Tests public override void Reset() { base.Reset(); - + oldDb = Dependencies.Get(); if (db == null) { storage = new TestStorage(@"TestCasePlaySongSelect"); @@ -35,9 +35,14 @@ namespace osu.Desktop.VisualTests.Tests db.Import(sets); } - Add(new PlaySongSelect()); } + + protected override void Dispose(bool isDisposing) + { + Dependencies.Cache(oldDb, true); + base.Dispose(isDisposing); + } private BeatmapSetInfo createTestBeatmapSet(int i) {