From 1853bbdda8fc855273bac049a1edf6c70a5ca771 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 25 Jan 2017 18:39:41 +0900 Subject: [PATCH 1/3] Move window/volume configuration to framework level. --- osu.Game/Configuration/FrameSync.cs | 12 ------- osu.Game/Configuration/OsuConfigManager.cs | 29 ++--------------- osu.Game/OsuGame.cs | 31 +------------------ osu.Game/OsuGameBase.cs | 24 +++++++------- osu.Game/Overlays/MusicController.cs | 14 +++++---- .../Options/Graphics/LayoutOptions.cs | 10 +++--- .../Options/Graphics/RendererOptions.cs | 1 + osu.Game/Screens/Play/Player.cs | 4 +-- osu.Game/osu.Game.csproj | 1 - 9 files changed, 32 insertions(+), 94 deletions(-) delete mode 100644 osu.Game/Configuration/FrameSync.cs diff --git a/osu.Game/Configuration/FrameSync.cs b/osu.Game/Configuration/FrameSync.cs deleted file mode 100644 index fc8a26db04..0000000000 --- a/osu.Game/Configuration/FrameSync.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -namespace osu.Game.Configuration -{ - public enum FrameSync - { - VSync = 1, - Limit120 = 0, - Unlimited = 2, - CompletelyUnlimited = 4, - Custom = 5 - } -} \ No newline at end of file diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 2c5c53cc3f..b995344db6 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -13,8 +13,7 @@ namespace osu.Game.Configuration protected override void InitialiseDefaults() { #pragma warning disable CS0612 // Type or member is obsolete - Set(OsuConfig.Width, 1366, 640); - Set(OsuConfig.Height, 768, 480); + Set(OsuConfig.MouseSpeed, 1.0); Set(OsuConfig.Username, string.Empty); @@ -24,11 +23,7 @@ namespace osu.Game.Configuration Set(OsuConfig.PlayMode, PlayMode.Osu); Set(OsuConfig.BeatmapDirectory, @"Songs"); // TODO: use this - - Set(OsuConfig.VolumeUniversal, 0.8, 0, 1); - Set(OsuConfig.VolumeMusic, 1.0, 0, 1); - Set(OsuConfig.VolumeEffect, 1.0, 0, 1); - + Set(OsuConfig.AllowPublicInvites, true); Set(OsuConfig.AutoChatHide, true); Set(OsuConfig.AutomaticDownload, true); @@ -56,7 +51,7 @@ namespace osu.Game.Configuration Set(OsuConfig.DisplayCityLocation, false); Set(OsuConfig.DistanceSpacingEnabled, true); Set(OsuConfig.EditorTip, 0); - Set(OsuConfig.VideoEditor, Get(OsuConfig.Fullscreen)); + Set(OsuConfig.VideoEditor, true); Set(OsuConfig.EditorDefaultSkin, false); Set(OsuConfig.EditorSnakingSliders, true); Set(OsuConfig.EditorHitAnimations, false); @@ -104,9 +99,7 @@ namespace osu.Game.Configuration Set(OsuConfig.EditorBeatDivisor, 1, 1, 16); Set(OsuConfig.EditorGridSize, 32, 4, 32); Set(OsuConfig.EditorGridSizeDesign, 32, 4, 32); - Set(OsuConfig.HeightFullscreen, 9999, 240, 9999); Set(OsuConfig.CustomFrameLimit, 240, 240, 999); - Set(OsuConfig.WidthFullscreen, 9999, 320, 9999); Set(OsuConfig.MsnIntegration, false); Set(OsuConfig.MyPcSucks, false); Set(OsuConfig.NotifyFriends, true); @@ -142,7 +135,6 @@ namespace osu.Game.Configuration Set(OsuConfig.YahooIntegration, false); Set(OsuConfig.ForceFrameFlush, false); Set(OsuConfig.DetectPerformanceIssues, true); - Set(OsuConfig.Fullscreen, true); Set(OsuConfig.MenuMusic, true); Set(OsuConfig.MenuVoice, true); Set(OsuConfig.MenuParallax, true); @@ -163,10 +155,6 @@ namespace osu.Game.Configuration Set(OsuConfig.SaveUsername, true); //Set(OsuConfig.TreeSortMode, TreeGroupMode.Show_All); //Set(OsuConfig.TreeSortMode2, TreeSortMode.Title); - Set(OsuConfig.Letterboxing, Get(OsuConfig.Fullscreen)); - Set(OsuConfig.LetterboxPositionX, 0, -100, 100); - Set(OsuConfig.LetterboxPositionY, 0, -100, 100); - Set(OsuConfig.FrameSync, FrameSync.Limit120); bool unicodeDefault = false; switch (Get(OsuConfig.Language)) { @@ -202,9 +190,6 @@ namespace osu.Game.Configuration Token, // Imported from old osu: BeatmapDirectory, - VolumeUniversal, - VolumeEffect, - VolumeMusic, AllowPublicInvites, AutoChatHide, AutomaticDownload, @@ -281,11 +266,7 @@ namespace osu.Game.Configuration EditorBeatDivisor, EditorGridSize, EditorGridSizeDesign, - Height, - Width, - HeightFullscreen, CustomFrameLimit, - WidthFullscreen, MsnIntegration, MyPcSucks, NotifyFriends, @@ -321,7 +302,6 @@ namespace osu.Game.Configuration YahooIntegration, ForceFrameFlush, DetectPerformanceIssues, - Fullscreen, MenuMusic, MenuVoice, MenuParallax, @@ -345,9 +325,6 @@ namespace osu.Game.Configuration SaveUsername, TreeSortMode, TreeSortMode2, - Letterboxing, - LetterboxPositionX, - LetterboxPositionY, FrameSync, ShowUnicode, PermanentSongInfo, diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index c852a41e3b..c4d94b5d65 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -2,16 +2,12 @@ //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Threading; using osu.Framework.Configuration; using osu.Framework.GameModes; using osu.Game.Configuration; -using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Platform; using osu.Game.Overlays; -using osu.Framework; using osu.Framework.Input; using osu.Game.Input; using OpenTK.Input; @@ -25,7 +21,6 @@ using osu.Game.Modes; using osu.Game.Overlays.Toolbar; using osu.Game.Screens; using osu.Game.Screens.Menu; -using osu.Game.Screens.Play; namespace osu.Game { @@ -55,13 +50,6 @@ namespace osu.Game this.args = args; } - public override void SetHost(BasicGameHost host) - { - base.SetHost(host); - - host.Size = new Vector2(Config.Get(OsuConfig.Width), Config.Get(OsuConfig.Height)); - } - public void ToggleOptions() => options.ToggleVisibility(); [BackgroundDependencyLoader] @@ -78,12 +66,7 @@ namespace osu.Game Dependencies.Cache(this); - //attach our bindables to the audio subsystem. - Audio.Volume.Weld(Config.GetBindable(OsuConfig.VolumeUniversal)); - Audio.VolumeSample.Weld(Config.GetBindable(OsuConfig.VolumeEffect)); - Audio.VolumeTrack.Weld(Config.GetBindable(OsuConfig.VolumeMusic)); - - PlayMode = Config.GetBindable(OsuConfig.PlayMode); + PlayMode = LocalConfig.GetBindable(OsuConfig.PlayMode); } protected override void LoadComplete() @@ -239,17 +222,5 @@ namespace osu.Game { modeChanged(newMode); } - - public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true) - { - if (!base.Invalidate(invalidation, source, shallPropagate)) return false; - - if (Parent != null) - { - Config.Set(OsuConfig.Width, DrawSize.X); - Config.Set(OsuConfig.Height, DrawSize.Y); - } - return true; - } } } diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index d29fe0032c..a853e93879 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -22,7 +22,7 @@ namespace osu.Game { public class OsuGameBase : BaseGame, IOnlineComponent { - internal OsuConfigManager Config; + protected OsuConfigManager LocalConfig; protected override string MainResourceFile => @"osu.Game.Resources.dll"; @@ -40,7 +40,7 @@ namespace osu.Game private void load() { Dependencies.Cache(this); - Dependencies.Cache(Config); + Dependencies.Cache(LocalConfig); Dependencies.Cache(new BeatmapDatabase(Host.Storage, Host)); Dependencies.Cache(new OsuColour()); @@ -69,9 +69,9 @@ namespace osu.Game Dependencies.Cache(API = new APIAccess { - Username = Config.Get(OsuConfig.Username), - Password = Config.Get(OsuConfig.Password), - Token = Config.Get(OsuConfig.Token) + Username = LocalConfig.Get(OsuConfig.Username), + Password = LocalConfig.Get(OsuConfig.Password), + Token = LocalConfig.Get(OsuConfig.Token) }); API.Register(this); @@ -82,8 +82,8 @@ namespace osu.Game switch (state) { case APIState.Online: - Config.Set(OsuConfig.Username, Config.Get(OsuConfig.SaveUsername) ? API.Username : string.Empty); - Config.Set(OsuConfig.Password, Config.Get(OsuConfig.SavePassword) ? API.Password : string.Empty); + LocalConfig.Set(OsuConfig.Username, LocalConfig.Get(OsuConfig.SaveUsername) ? API.Username : string.Empty); + LocalConfig.Set(OsuConfig.Password, LocalConfig.Get(OsuConfig.SavePassword) ? API.Password : string.Empty); break; } } @@ -103,8 +103,8 @@ namespace osu.Game public override void SetHost(BasicGameHost host) { - if (Config == null) - Config = new OsuConfigManager(host.Storage); + if (LocalConfig == null) + LocalConfig = new OsuConfigManager(host.Storage); base.SetHost(host); } @@ -117,10 +117,10 @@ namespace osu.Game protected override void Dispose(bool isDisposing) { //refresh token may have changed. - if (Config != null && API != null) + if (LocalConfig != null && API != null) { - Config.Set(OsuConfig.Token, API.Token); - Config.Save(); + LocalConfig.Set(OsuConfig.Token, API.Token); + LocalConfig.Save(); } base.Dispose(isDisposing); diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 5052840848..e480bf3061 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -43,7 +43,6 @@ namespace osu.Game.Overlays private TrackManager trackManager; private Bindable beatmapSource; private Bindable preferUnicode; - private OsuConfigManager config; private WorkingBeatmap current; private BeatmapDatabase beatmaps; private BaseGame game; @@ -87,9 +86,11 @@ namespace osu.Game.Overlays } [BackgroundDependencyLoader] - private void load(OsuGameBase osuGame, BeatmapDatabase beatmaps, AudioManager audio, + private void load(OsuGameBase osuGame, OsuConfigManager config, BeatmapDatabase beatmaps, AudioManager audio, TextureStore textures, OsuColour colours) { + unicodeString = config.GetUnicodeString; + Children = new Drawable[] { title = new SpriteText @@ -202,8 +203,7 @@ namespace osu.Game.Overlays this.beatmaps = beatmaps; trackManager = osuGame.Audio.Track; - config = osuGame.Config; - preferUnicode = osuGame.Config.GetBindable(OsuConfig.ShowUnicode); + preferUnicode = config.GetBindable(OsuConfig.ShowUnicode); preferUnicode.ValueChanged += preferUnicode_changed; beatmapSource = osuGame.Beatmap ?? new Bindable(); @@ -324,8 +324,8 @@ namespace osu.Game.Overlays return; BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; - title.Text = config.GetUnicodeString(metadata.Title, metadata.TitleUnicode); - artist.Text = config.GetUnicodeString(metadata.Artist, metadata.ArtistUnicode); + title.Text = unicodeString(metadata.Title, metadata.TitleUnicode); + artist.Text = unicodeString(metadata.Artist, metadata.ArtistUnicode); }); MusicControllerBackground newBackground; @@ -354,6 +354,8 @@ namespace osu.Game.Overlays }); } + private Func unicodeString; + private void seek(float position) { current?.Track?.Seek(current.Track.Length * position); diff --git a/osu.Game/Overlays/Options/Graphics/LayoutOptions.cs b/osu.Game/Overlays/Options/Graphics/LayoutOptions.cs index e050f7c70c..3235088551 100644 --- a/osu.Game/Overlays/Options/Graphics/LayoutOptions.cs +++ b/osu.Game/Overlays/Options/Graphics/LayoutOptions.cs @@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Options.Graphics protected override string Header => "Layout"; [BackgroundDependencyLoader] - private void load(OsuConfigManager config) + private void load(FrameworkConfigManager config) { Children = new Drawable[] { @@ -24,22 +24,22 @@ namespace osu.Game.Overlays.Options.Graphics new CheckBoxOption { LabelText = "Fullscreen mode", - Bindable = config.GetBindable(OsuConfig.Fullscreen), + Bindable = config.GetBindable(FrameworkConfig.Fullscreen), }, new CheckBoxOption { LabelText = "Letterboxing", - Bindable = config.GetBindable(OsuConfig.Letterboxing), + Bindable = config.GetBindable(FrameworkConfig.Letterboxing), }, new SliderOption { LabelText = "Horizontal position", - Bindable = (BindableInt)config.GetBindable(OsuConfig.LetterboxPositionX) + Bindable = (BindableInt)config.GetBindable(FrameworkConfig.LetterboxPositionX) }, new SliderOption { LabelText = "Vertical position", - Bindable = (BindableInt)config.GetBindable(OsuConfig.LetterboxPositionY) + Bindable = (BindableInt)config.GetBindable(FrameworkConfig.LetterboxPositionY) }, }; } diff --git a/osu.Game/Overlays/Options/Graphics/RendererOptions.cs b/osu.Game/Overlays/Options/Graphics/RendererOptions.cs index 6dce562c4b..895f713346 100644 --- a/osu.Game/Overlays/Options/Graphics/RendererOptions.cs +++ b/osu.Game/Overlays/Options/Graphics/RendererOptions.cs @@ -3,6 +3,7 @@ using osu.Framework; using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index f719d27fc3..fe9345eca8 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -48,9 +48,9 @@ namespace osu.Game.Screens.Play private Bindable dimLevel; [BackgroundDependencyLoader] - private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game) + private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game, OsuConfigManager config) { - dimLevel = game.Config.GetBindable(OsuConfig.DimLevel); + dimLevel = config.GetBindable(OsuConfig.DimLevel); try { if (Beatmap == null) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 8843bcf219..2261605f50 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -230,7 +230,6 @@ - From 25da8a53dcab2edb167dc017ae35ac89d7236582 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 26 Jan 2017 22:15:49 +0900 Subject: [PATCH 2/3] Fix incorrect configuration retrievals. --- osu.Game/Configuration/OsuConfigManager.cs | 1 - osu.Game/Overlays/Options/Graphics/RendererOptions.cs | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index b995344db6..e0134fcf41 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -325,7 +325,6 @@ namespace osu.Game.Configuration SaveUsername, TreeSortMode, TreeSortMode2, - FrameSync, ShowUnicode, PermanentSongInfo, Ticker, diff --git a/osu.Game/Overlays/Options/Graphics/RendererOptions.cs b/osu.Game/Overlays/Options/Graphics/RendererOptions.cs index 895f713346..505881315d 100644 --- a/osu.Game/Overlays/Options/Graphics/RendererOptions.cs +++ b/osu.Game/Overlays/Options/Graphics/RendererOptions.cs @@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Options.Graphics protected override string Header => "Renderer"; [BackgroundDependencyLoader] - private void load(OsuConfigManager config) + private void load(OsuConfigManager osuConfig, FrameworkConfigManager config) { // NOTE: Compatability mode omitted Children = new Drawable[] @@ -25,22 +25,22 @@ namespace osu.Game.Overlays.Options.Graphics new DropdownOption { LabelText = "Frame limiter", - Bindable = config.GetBindable(OsuConfig.FrameSync) + Bindable = config.GetBindable(FrameworkConfig.FrameSync) }, new CheckBoxOption { LabelText = "Show FPS counter", - Bindable = config.GetBindable(OsuConfig.FpsCounter), + Bindable = osuConfig.GetBindable(OsuConfig.FpsCounter), }, new CheckBoxOption { LabelText = "Reduce dropped frames", - Bindable = config.GetBindable(OsuConfig.ForceFrameFlush), + Bindable = osuConfig.GetBindable(OsuConfig.ForceFrameFlush), }, new CheckBoxOption { LabelText = "Detect performance issues", - Bindable = config.GetBindable(OsuConfig.DetectPerformanceIssues), + Bindable = osuConfig.GetBindable(OsuConfig.DetectPerformanceIssues), }, }; } From db37a7e3326ff9240370d3af249f4625cd18596b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 26 Jan 2017 23:36:35 +0900 Subject: [PATCH 3/3] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 29c4a3f29a..2f03fae533 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 29c4a3f29ad06a90da14ddafba1884f8265412d8 +Subproject commit 2f03fae533293bf255a942569c07396f853378f3