From 19fd6fe2493cc2fd9ae69a9502dfa00a5073c76a Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 4 Nov 2016 18:06:58 -0400 Subject: [PATCH 01/19] Introduce dependency injection --- osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs | 14 ++++++++------ osu.Game/GameModes/Play/PlaySongSelect.cs | 2 +- osu.Game/GameModes/Play/Player.cs | 3 ++- osu.Game/OsuGame.cs | 3 ++- osu.Game/OsuGameBase.cs | 6 ++++-- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index bbd441d25a..8f604696b5 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -29,7 +29,7 @@ namespace osu.Game.Tests.Beatmaps.IO HeadlessGameHost host = new HeadlessGameHost(); var osu = loadOsu(host); - osu.Beatmaps.Import(osz_path); + osu.Dependencies.Get().Import(osz_path); ensureLoaded(osu); } @@ -60,7 +60,7 @@ namespace osu.Game.Tests.Beatmaps.IO Thread.Sleep(1); //reset beatmap database (sqlite and storage backing) - osu.Beatmaps.Reset(); + osu.Dependencies.Get().Reset(); return osu; } @@ -71,7 +71,8 @@ namespace osu.Game.Tests.Beatmaps.IO Action waitAction = () => { - while ((resultSets = osu.Beatmaps.Query().Where(s => s.BeatmapSetID == 241526)).Count() != 1) + while ((resultSets = osu.Dependencies.Get() + .Query().Where(s => s.BeatmapSetID == 241526)).Count() != 1) Thread.Sleep(1); }; @@ -87,7 +88,8 @@ namespace osu.Game.Tests.Beatmaps.IO //if we don't re-check here, the set will be inserted but the beatmaps won't be present yet. waitAction = () => { - while ((resultBeatmaps = osu.Beatmaps.Query().Where(s => s.BeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12) + while ((resultBeatmaps = osu.Dependencies.Get() + .Query().Where(s => s.BeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12) Thread.Sleep(1); }; @@ -95,7 +97,7 @@ namespace osu.Game.Tests.Beatmaps.IO @"Beatmaps did not import to the database"); //fetch children and check we can load from the post-storage path... - var set = osu.Beatmaps.GetChildren(resultSets.First()); + var set = osu.Dependencies.Get().GetChildren(resultSets.First()); Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count()); @@ -104,7 +106,7 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.IsTrue(set.Beatmaps.Count > 0); - var beatmap = osu.Beatmaps.GetBeatmap(set.Beatmaps.First(b => b.Mode == PlayMode.Osu)); + var beatmap = osu.Dependencies.Get().GetBeatmap(set.Beatmaps.First(b => b.Mode == PlayMode.Osu)); Assert.IsTrue(beatmap.HitObjects.Count > 0); } diff --git a/osu.Game/GameModes/Play/PlaySongSelect.cs b/osu.Game/GameModes/Play/PlaySongSelect.cs index a05e02ae3b..9a62d8f071 100644 --- a/osu.Game/GameModes/Play/PlaySongSelect.cs +++ b/osu.Game/GameModes/Play/PlaySongSelect.cs @@ -137,7 +137,7 @@ namespace osu.Game.GameModes.Play } if (database == null) - database = (game as OsuGameBase).Beatmaps; + database = game.Dependencies.Get(); database.BeatmapSetAdded += s => Schedule(() => addBeatmapSet(s)); diff --git a/osu.Game/GameModes/Play/Player.cs b/osu.Game/GameModes/Play/Player.cs index d48e252fa5..a76f29c49f 100644 --- a/osu.Game/GameModes/Play/Player.cs +++ b/osu.Game/GameModes/Play/Player.cs @@ -37,8 +37,9 @@ namespace osu.Game.GameModes.Play try { + var beatmaps = Game.Dependencies.Get(); if (Beatmap == null) - Beatmap = ((OsuGame)game).Beatmaps.GetWorkingBeatmap(BeatmapInfo); + Beatmap = beatmaps.GetWorkingBeatmap(BeatmapInfo); } catch { diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 1323e65757..65179d5edb 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -19,6 +19,7 @@ using osu.Game.Input; using OpenTK.Input; using osu.Framework.Logging; using osu.Game.Graphics.UserInterface.Volume; +using osu.Game.Database; namespace osu.Game { @@ -61,7 +62,7 @@ namespace osu.Game base.Load(game); if (args?.Length > 0) - Schedule(delegate { Beatmaps.Import(args); }); + Schedule(delegate { Dependencies.Get().Import(args); }); //attach our bindables to the audio subsystem. Audio.Volume.Weld(Config.GetBindable(OsuConfig.VolumeUniversal)); diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 30a109c597..65f8974571 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -23,7 +23,6 @@ namespace osu.Game public class OsuGameBase : BaseGame { internal OsuConfigManager Config; - public BeatmapDatabase Beatmaps { get; private set; } protected override string MainResourceFile => @"osu.Game.Resources.dll"; @@ -57,8 +56,11 @@ namespace osu.Game { base.Load(game); + Dependencies.Cache(this); + Dependencies.Cache(); + Dependencies.Cache(new BeatmapDatabase(Host.Storage, Host)); + OszArchiveReader.Register(); - Beatmaps = new BeatmapDatabase(Host.Storage, Host); //this completely overrides the framework default. will need to change once we make a proper FontStore. Fonts = new TextureStore() { ScaleAdjust = 0.01f }; From dc03f36793265cb52a403f18bd4f9ad817f6f559 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 4 Nov 2016 18:18:08 -0400 Subject: [PATCH 02/19] Use DI for Player --- osu-framework | 2 +- osu.Desktop.VisualTests/Tests/TestCasePlayer.cs | 16 ++++++++++++---- osu.Game/GameModes/Play/PlaySongSelect.cs | 11 +++++++---- osu.Game/GameModes/Play/Player.cs | 7 ++++++- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/osu-framework b/osu-framework index 25b8c3c6cf..eb16219058 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 25b8c3c6cfead49acf5659a750c7e604289d5b81 +Subproject commit eb16219058e87210c9ad90b1e214ccc2c1556058 diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs index bb7b86db43..f46bf5055c 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs @@ -11,6 +11,7 @@ using osu.Game.Beatmaps.Objects; using osu.Game.Beatmaps.Objects.Osu; using osu.Game.GameModes.Play; using OpenTK; +using osu.Framework; namespace osu.Desktop.VisualTests.Tests { @@ -24,6 +25,14 @@ namespace osu.Desktop.VisualTests.Tests protected override IFrameBasedClock Clock => localClock; + private BaseGame game; + + protected override void Load(BaseGame game) + { + base.Load(game); + this.game = game; + } + public override void Reset() { base.Reset(); @@ -55,10 +64,9 @@ namespace osu.Desktop.VisualTests.Tests decoder.Process(b); - Add(new Player - { - Beatmap = new WorkingBeatmap(b) - }); + var player = game.Dependencies.Get(); + player.Beatmap = new WorkingBeatmap(b); + Add(player); } protected override void Update() diff --git a/osu.Game/GameModes/Play/PlaySongSelect.cs b/osu.Game/GameModes/Play/PlaySongSelect.cs index 9a62d8f071..9bb115aba4 100644 --- a/osu.Game/GameModes/Play/PlaySongSelect.cs +++ b/osu.Game/GameModes/Play/PlaySongSelect.cs @@ -113,10 +113,13 @@ namespace osu.Game.GameModes.Play Width = 100, Text = "Play", Colour = new Color4(238, 51, 153, 255), - Action = () => Push(new Player { - BeatmapInfo = selectedBeatmapGroup.SelectedPanel.Beatmap, - PreferredPlayMode = playMode.Value - }), + Action = () => + { + var player = Game.Dependencies.Get(); + player.BeatmapInfo = selectedBeatmapGroup.SelectedPanel.Beatmap; + player.PreferredPlayMode = playMode.Value; + Push(player); + } }, } } diff --git a/osu.Game/GameModes/Play/Player.cs b/osu.Game/GameModes/Play/Player.cs index a76f29c49f..eadb3ae2ae 100644 --- a/osu.Game/GameModes/Play/Player.cs +++ b/osu.Game/GameModes/Play/Player.cs @@ -30,6 +30,12 @@ namespace osu.Game.GameModes.Play private InterpolatingFramedClock playerClock; private IAdjustableClock sourceClock; + private BeatmapDatabase beatmaps; + + public Player(BeatmapDatabase beatmaps) + { + this.beatmaps = beatmaps; + } protected override void Load(BaseGame game) { @@ -37,7 +43,6 @@ namespace osu.Game.GameModes.Play try { - var beatmaps = Game.Dependencies.Get(); if (Beatmap == null) Beatmap = beatmaps.GetWorkingBeatmap(BeatmapInfo); } From ee24cd310cea9932edee196eec29aa7d40bb63ac Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 8 Nov 2016 18:13:20 -0500 Subject: [PATCH 03/19] Convert everything to DI pattern --- .../Tests/TestCaseChatDisplay.cs | 8 ++-- .../Tests/TestCaseHitObjects.cs | 6 +-- .../Tests/TestCasePlayer.cs | 16 ++++---- osu.Desktop.VisualTests/VisualTestGame.cs | 5 ++- osu.Game/Beatmaps/Drawable/BeatmapGroup.cs | 8 ++-- .../Objects/Catch/Drawable/DrawableFruit.cs | 9 +++-- .../Objects/Mania/Drawable/DrawableNote.cs | 8 ++-- .../Objects/Osu/Drawable/DrawableCircle.cs | 37 +++++++++-------- .../Taiko/Drawable/DrawableTaikoHit.cs | 9 +++-- osu.Game/GameModes/BackgroundMode.cs | 5 ++- .../Backgrounds/BackgroundModeCustom.cs | 5 ++- .../Backgrounds/BackgroundModeDefault.cs | 6 +-- osu.Game/GameModes/GameModeWhiteBox.cs | 6 +-- osu.Game/GameModes/Menu/Button.cs | 5 ++- osu.Game/GameModes/Menu/ButtonSystem.cs | 6 +-- osu.Game/GameModes/Menu/Intro.cs | 11 ++--- osu.Game/GameModes/Menu/MainMenu.cs | 11 +++-- osu.Game/GameModes/Menu/OsuLogo.cs | 10 +++-- .../GameModes/Play/Catch/CatchPlayfield.cs | 6 +-- osu.Game/GameModes/Play/ComboCounter.cs | 10 ++--- osu.Game/GameModes/Play/HitRenderer.cs | 6 +-- .../GameModes/Play/Mania/ManiaPlayfield.cs | 8 ++-- .../GameModes/Play/Osu/OsuComboCounter.cs | 10 ++--- osu.Game/GameModes/Play/PlaySongSelect.cs | 14 ++++--- osu.Game/GameModes/Play/Player.cs | 15 +++---- .../GameModes/Play/Taiko/TaikoPlayfield.cs | 9 +++-- osu.Game/Graphics/Background/Background.cs | 9 +++-- .../Graphics/Containers/ParallaxContainer.cs | 17 ++++---- .../Graphics/Cursor/OsuCursorContainer.cs | 9 +++-- osu.Game/Graphics/UserInterface/KeyCounter.cs | 10 +++-- .../Graphics/UserInterface/RollingCounter.cs | 10 ++--- .../Graphics/UserInterface/StarCounter.cs | 6 +-- .../UserInterface/Volume/VolumeControl.cs | 6 +-- .../Online/Chat/Display/ChannelDisplay.cs | 5 ++- osu.Game/Online/Chat/Display/ChatLine.cs | 6 +-- osu.Game/OsuGame.cs | 14 +++---- osu.Game/OsuGameBase.cs | 8 ++-- osu.Game/Overlays/ChatConsole.cs | 5 ++- .../Options/General/LanguageOptions.cs | 40 +++++++++---------- .../Overlays/Options/General/LoginOptions.cs | 12 +++--- .../Overlays/Options/General/UpdateOptions.cs | 33 +++++++-------- osu.Game/Overlays/Toolbar.cs | 7 ++-- osu.Game/Overlays/ToolbarModeButton.cs | 5 ++- osu.Game/Overlays/ToolbarModeSelector.cs | 6 +-- 44 files changed, 233 insertions(+), 224 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs index 98e1c2de08..281b6338a4 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs @@ -16,6 +16,7 @@ using osu.Game.Online.API.Requests; using osu.Game.Online.Chat; using osu.Game.Online.Chat.Display; using OpenTK; +using osu.Framework.Allocation; namespace osu.Desktop.VisualTests.Tests { @@ -34,11 +35,10 @@ namespace osu.Desktop.VisualTests.Tests private ChannelDisplay channelDisplay; - protected override void Load(BaseGame game) + [Initializer] + private void Load(APIAccess api) { - base.Load(game); - - api = ((OsuGameBase)game).API; + this.api = api; } public override void Reset() diff --git a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs index 54d8bbd2e7..0a3700b6bb 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs @@ -9,6 +9,7 @@ using osu.Game.Beatmaps.Objects; using osu.Game.Beatmaps.Objects.Osu; using osu.Game.Beatmaps.Objects.Osu.Drawable; using OpenTK; +using osu.Framework.Allocation; namespace osu.Desktop.VisualTests.Tests { @@ -20,10 +21,9 @@ namespace osu.Desktop.VisualTests.Tests protected override IFrameBasedClock Clock => ourClock; - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); - var swClock = new StopwatchClock(true) { Rate = 1 }; ourClock = new FramedClock(swClock); } diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs index f46bf5055c..80289ae488 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs @@ -12,6 +12,7 @@ using osu.Game.Beatmaps.Objects.Osu; using osu.Game.GameModes.Play; using OpenTK; using osu.Framework; +using osu.Framework.Allocation; namespace osu.Desktop.VisualTests.Tests { @@ -25,12 +26,10 @@ namespace osu.Desktop.VisualTests.Tests protected override IFrameBasedClock Clock => localClock; - private BaseGame game; - - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); - this.game = game; + // TODO: Do we even need this here? } public override void Reset() @@ -64,9 +63,10 @@ namespace osu.Desktop.VisualTests.Tests decoder.Process(b); - var player = game.Dependencies.Get(); - player.Beatmap = new WorkingBeatmap(b); - Add(player); + Add(new Player + { + Beatmap = new WorkingBeatmap(b) + }); } protected override void Update() diff --git a/osu.Desktop.VisualTests/VisualTestGame.cs b/osu.Desktop.VisualTests/VisualTestGame.cs index 5fba0209e2..db273b50af 100644 --- a/osu.Desktop.VisualTests/VisualTestGame.cs +++ b/osu.Desktop.VisualTests/VisualTestGame.cs @@ -13,14 +13,15 @@ using System.Collections.Generic; using osu.Game.GameModes.Play; using SQLiteNetExtensions.Extensions; using osu.Desktop.Platform; +using osu.Framework.Allocation; namespace osu.Desktop.VisualTests { class VisualTestGame : OsuGameBase { - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); Add(new TestBrowser()); } } diff --git a/osu.Game/Beatmaps/Drawable/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawable/BeatmapGroup.cs index 5e10402206..3cd8324346 100644 --- a/osu.Game/Beatmaps/Drawable/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawable/BeatmapGroup.cs @@ -13,7 +13,8 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Game.Database; using OpenTK; - +using osu.Framework.Allocation; + namespace osu.Game.Beatmaps.Drawable { class BeatmapGroup : Container, IStateful @@ -99,10 +100,9 @@ namespace osu.Game.Beatmaps.Drawable }; } - protected override void Load(BaseGame game) + [Initializer] + private void Load(BaseGame game) { - base.Load(game); - BeatmapPanels = beatmapSet.Beatmaps.Select(b => new BeatmapPanel(b) { GainedSelection = panelGainedSelection, diff --git a/osu.Game/Beatmaps/Objects/Catch/Drawable/DrawableFruit.cs b/osu.Game/Beatmaps/Objects/Catch/Drawable/DrawableFruit.cs index ba3c1c90b6..8db412f674 100644 --- a/osu.Game/Beatmaps/Objects/Catch/Drawable/DrawableFruit.cs +++ b/osu.Game/Beatmaps/Objects/Catch/Drawable/DrawableFruit.cs @@ -11,6 +11,8 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using OpenTK; +using osu.Framework.Allocation; +using osu.Framework.Graphics.Textures; namespace osu.Game.Beatmaps.Objects.Catch.Drawable { @@ -28,11 +30,10 @@ namespace osu.Game.Beatmaps.Objects.Catch.Drawable Position = new Vector2(h.Position, -0.1f); } - protected override void Load(BaseGame game) + [Initializer] + private void Load(TextureStore textures) { - base.Load(game); - - Texture = game.Textures.Get(@"Menu/logo"); + Texture = textures.Get(@"Menu/logo"); Transforms.Add(new TransformPosition { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = new Vector2(h.Position, -0.1f), EndValue = new Vector2(h.Position, 0.9f) }); Transforms.Add(new TransformAlpha { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 }); diff --git a/osu.Game/Beatmaps/Objects/Mania/Drawable/DrawableNote.cs b/osu.Game/Beatmaps/Objects/Mania/Drawable/DrawableNote.cs index d4fe46317d..a1e1a8575a 100644 --- a/osu.Game/Beatmaps/Objects/Mania/Drawable/DrawableNote.cs +++ b/osu.Game/Beatmaps/Objects/Mania/Drawable/DrawableNote.cs @@ -6,6 +6,8 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using OpenTK; +using osu.Framework.Allocation; +using osu.Framework.Graphics.Textures; namespace osu.Game.Beatmaps.Objects.Mania.Drawable { @@ -20,10 +22,10 @@ namespace osu.Game.Beatmaps.Objects.Mania.Drawable Scale = new Vector2(0.1f); } - protected override void Load(BaseGame game) + [Initializer] + private void Load(TextureStore textures) { - base.Load(game); - Texture = game.Textures.Get(@"Menu/logo"); + Texture = textures.Get(@"Menu/logo"); Transforms.Add(new TransformPositionY() { StartTime = note.StartTime - 200, EndTime = note.StartTime, StartValue = -0.1f, EndValue = 0.9f }); Transforms.Add(new TransformAlpha() { StartTime = note.StartTime + note.Duration + 200, EndTime = note.StartTime + note.Duration + 400, StartValue = 1, EndValue = 0 }); diff --git a/osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs b/osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs index cf150e7e04..293ecbdd38 100644 --- a/osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs +++ b/osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Transformations; using osu.Framework.Input; using osu.Framework.MathUtils; using OpenTK; +using osu.Framework.Allocation; namespace osu.Game.Beatmaps.Objects.Osu.Drawable { @@ -63,10 +64,9 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable Size = circle.DrawSize; } - protected override void Load(BaseGame game) + [Initializer] + private void Load(BaseGame game) { - base.Load(game); - approachCircle.Texture = game.Textures.Get(@"Play/osu/approachcircle@2x"); } @@ -149,10 +149,10 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable }; } - protected override void Load(BaseGame game) + [Initializer] + private void Load(TextureStore textures) { - base.Load(game); - number.Texture = game.Textures.Get(@"Play/osu/number@2x"); + number.Texture = textures.Get(@"Play/osu/number@2x"); } } @@ -177,10 +177,10 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable }; } - protected override void Load(BaseGame game) + [Initializer] + private void Load(TextureStore textures) { - base.Load(game); - layer.Texture = game.Textures.Get(@"Play/osu/ring-glow@2x"); + layer.Texture = textures.Get(@"Play/osu/ring-glow@2x"); } } @@ -203,10 +203,10 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable }; } - protected override void Load(BaseGame game) + [Initializer] + private void Load(TextureStore textures) { - base.Load(game); - ring.Texture = game.Textures.Get(@"Play/osu/ring@2x"); + ring.Texture = textures.Get(@"Play/osu/ring@2x"); } } @@ -289,10 +289,10 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable }; } - protected override void Load(BaseGame game) + [Initializer] + private void Load(TextureStore textures) { - base.Load(game); - disc.Texture = game.Textures.Get(@"Play/osu/disc@2x"); + disc.Texture = textures.Get(@"Play/osu/disc@2x"); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) @@ -306,11 +306,10 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable { private Texture tex; - protected override void Load(BaseGame game) + [Initializer] + private void Load(TextureStore textures) { - base.Load(game); - - tex = game.Textures.Get(@"Play/osu/triangle@2x"); + tex = textures.Get(@"Play/osu/triangle@2x"); for (int i = 0; i < 10; i++) { diff --git a/osu.Game/Beatmaps/Objects/Taiko/Drawable/DrawableTaikoHit.cs b/osu.Game/Beatmaps/Objects/Taiko/Drawable/DrawableTaikoHit.cs index b2eecb8f05..48116ef75d 100644 --- a/osu.Game/Beatmaps/Objects/Taiko/Drawable/DrawableTaikoHit.cs +++ b/osu.Game/Beatmaps/Objects/Taiko/Drawable/DrawableTaikoHit.cs @@ -6,6 +6,8 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using OpenTK; +using osu.Framework.Allocation; +using osu.Framework.Graphics.Textures; namespace osu.Game.Beatmaps.Objects.Taiko.Drawable { @@ -23,11 +25,10 @@ namespace osu.Game.Beatmaps.Objects.Taiko.Drawable Position = new Vector2(1.1f, 0.5f); } - protected override void Load(BaseGame game) + [Initializer] + private void Load(TextureStore textures) { - base.Load(game); - - Texture = game.Textures.Get(@"Menu/logo"); + Texture = textures.Get(@"Menu/logo"); Transforms.Add(new TransformPositionX { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = 1.1f, EndValue = 0.1f }); Transforms.Add(new TransformAlpha { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 }); diff --git a/osu.Game/GameModes/BackgroundMode.cs b/osu.Game/GameModes/BackgroundMode.cs index 641a95b27f..49a36f7d4a 100644 --- a/osu.Game/GameModes/BackgroundMode.cs +++ b/osu.Game/GameModes/BackgroundMode.cs @@ -13,6 +13,7 @@ using osu.Framework.Graphics; using osu.Framework.Input; using osu.Framework; using System.Threading; +using osu.Framework.Allocation; namespace osu.Game.GameModes { @@ -34,9 +35,9 @@ namespace osu.Game.GameModes BaseGame game; - protected override void Load(BaseGame game) + [Initializer] + private void Load(BaseGame game) { - base.Load(game); this.game = game; } diff --git a/osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs b/osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs index a603b3904e..0eb956eb42 100644 --- a/osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs +++ b/osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs @@ -2,6 +2,7 @@ //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework; +using osu.Framework.Allocation; using osu.Game.Graphics.Background; namespace osu.Game.GameModes.Backgrounds @@ -15,9 +16,9 @@ namespace osu.Game.GameModes.Backgrounds this.textureName = textureName; } - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); Add(new Background(textureName)); } diff --git a/osu.Game/GameModes/Backgrounds/BackgroundModeDefault.cs b/osu.Game/GameModes/Backgrounds/BackgroundModeDefault.cs index bbfa559742..a0a9f62a03 100644 --- a/osu.Game/GameModes/Backgrounds/BackgroundModeDefault.cs +++ b/osu.Game/GameModes/Backgrounds/BackgroundModeDefault.cs @@ -2,16 +2,16 @@ //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework; +using osu.Framework.Allocation; using osu.Game.Graphics.Background; namespace osu.Game.GameModes.Backgrounds { public class BackgroundModeDefault : BackgroundMode { - protected override void Load(BaseGame game) + [Initializer] + private void Load(BaseGame game) { - base.Load(game); - Add(new Background()); } } diff --git a/osu.Game/GameModes/GameModeWhiteBox.cs b/osu.Game/GameModes/GameModeWhiteBox.cs index 3bb8dd4566..4866af1a8f 100644 --- a/osu.Game/GameModes/GameModeWhiteBox.cs +++ b/osu.Game/GameModes/GameModeWhiteBox.cs @@ -13,6 +13,7 @@ using osu.Game.GameModes.Backgrounds; using OpenTK; using OpenTK.Graphics; using osu.Framework; +using osu.Framework.Allocation; namespace osu.Game.GameModes { @@ -77,10 +78,9 @@ namespace osu.Game.GameModes Content.FadeIn(transition_time, EasingTypes.OutExpo); } - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); - Children = new Drawable[] { box = new Box diff --git a/osu.Game/GameModes/Menu/Button.cs b/osu.Game/GameModes/Menu/Button.cs index 07e46ab0f9..b0721ce167 100644 --- a/osu.Game/GameModes/Menu/Button.cs +++ b/osu.Game/GameModes/Menu/Button.cs @@ -10,6 +10,7 @@ using osu.Framework.Graphics.Transformations; using osu.Framework.Input; using osu.Game.Graphics; using System; +using osu.Framework.Allocation; namespace osu.Game.GameModes.Menu { @@ -48,9 +49,9 @@ namespace osu.Game.GameModes.Menu AutoSizeAxes = Axes.Both; } - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); Alpha = 0; Vector2 boxSize = new Vector2(ButtonSystem.button_width + Math.Abs(extraWidth), ButtonSystem.button_area_height); diff --git a/osu.Game/GameModes/Menu/ButtonSystem.cs b/osu.Game/GameModes/Menu/ButtonSystem.cs index 4053935d0f..dcc0854294 100644 --- a/osu.Game/GameModes/Menu/ButtonSystem.cs +++ b/osu.Game/GameModes/Menu/ButtonSystem.cs @@ -14,6 +14,7 @@ using OpenTK; using OpenTK.Graphics; using OpenTK.Input; using osu.Framework; +using osu.Framework.Allocation; namespace osu.Game.GameModes.Menu { @@ -53,10 +54,9 @@ namespace osu.Game.GameModes.Menu RelativeSizeAxes = Axes.Both; } - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); - Children = new Drawable[] { buttonArea = new Container diff --git a/osu.Game/GameModes/Menu/Intro.cs b/osu.Game/GameModes/Menu/Intro.cs index c107fd0c92..e5ffd80fc5 100644 --- a/osu.Game/GameModes/Menu/Intro.cs +++ b/osu.Game/GameModes/Menu/Intro.cs @@ -10,6 +10,8 @@ using osu.Framework.Graphics.Transformations; using osu.Game.GameModes.Backgrounds; using OpenTK.Graphics; using osu.Framework; +using osu.Framework.Allocation; +using osu.Framework.Audio; namespace osu.Game.GameModes.Menu { @@ -43,13 +45,12 @@ namespace osu.Game.GameModes.Menu }; } - protected override void Load(BaseGame game) + [Initializer] + private void Load(AudioManager audio) { - base.Load(game); + welcome = audio.Sample.Get(@"welcome"); - welcome = game.Audio.Sample.Get(@"welcome"); - - bgm = game.Audio.Track.Get(@"circles"); + bgm = audio.Track.Get(@"circles"); bgm.Looping = true; } diff --git a/osu.Game/GameModes/Menu/MainMenu.cs b/osu.Game/GameModes/Menu/MainMenu.cs index f4b9da2bfe..e324ba6e6a 100644 --- a/osu.Game/GameModes/Menu/MainMenu.cs +++ b/osu.Game/GameModes/Menu/MainMenu.cs @@ -17,6 +17,8 @@ using OpenTK; using osu.Framework; using osu.Game.Overlays; using System.Threading.Tasks; +using osu.Game.Configuration; +using osu.Framework.Allocation; namespace osu.Game.GameModes.Menu { @@ -55,14 +57,11 @@ namespace osu.Game.GameModes.Menu }; } - protected override void Load(BaseGame game) + [Initializer] + private void Load(BaseGame game, OptionsOverlay options) { - base.Load(game); - background.Preload(game); - - OsuGame osu = (OsuGame)game; - buttons.OnSettings = osu.Options.ToggleVisibility; + buttons.OnSettings = options.ToggleVisibility; } protected override void LoadComplete() diff --git a/osu.Game/GameModes/Menu/OsuLogo.cs b/osu.Game/GameModes/Menu/OsuLogo.cs index 106df1a1be..b620690610 100644 --- a/osu.Game/GameModes/Menu/OsuLogo.cs +++ b/osu.Game/GameModes/Menu/OsuLogo.cs @@ -9,6 +9,8 @@ using osu.Framework.Graphics.Transformations; using osu.Framework.Input; using osu.Framework; using OpenTK; +using osu.Framework.Allocation; +using osu.Framework.Graphics.Textures; namespace osu.Game.GameModes.Menu { @@ -101,11 +103,11 @@ namespace osu.Game.GameModes.Menu }; } - protected override void Load(BaseGame game) + [Initializer] + private void Load(TextureStore textures) { - base.Load(game); - logo.Texture = game.Textures.Get(@"Menu/logo"); - ripple.Texture = game.Textures.Get(@"Menu/logo"); + logo.Texture = textures.Get(@"Menu/logo"); + ripple.Texture = textures.Get(@"Menu/logo"); } protected override void LoadComplete() diff --git a/osu.Game/GameModes/Play/Catch/CatchPlayfield.cs b/osu.Game/GameModes/Play/Catch/CatchPlayfield.cs index bf1b3f67a2..298d429bcb 100644 --- a/osu.Game/GameModes/Play/Catch/CatchPlayfield.cs +++ b/osu.Game/GameModes/Play/Catch/CatchPlayfield.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; using osu.Framework; +using osu.Framework.Allocation; namespace osu.Game.GameModes.Play.Catch { @@ -20,10 +21,9 @@ namespace osu.Game.GameModes.Play.Catch Origin = Anchor.BottomCentre; } - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); - Add(new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.5f }); } } diff --git a/osu.Game/GameModes/Play/ComboCounter.cs b/osu.Game/GameModes/Play/ComboCounter.cs index ec0d1b45d5..24610e5805 100644 --- a/osu.Game/GameModes/Play/ComboCounter.cs +++ b/osu.Game/GameModes/Play/ComboCounter.cs @@ -14,6 +14,7 @@ using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; +using osu.Framework.Allocation; namespace osu.Game.GameModes.Play { @@ -120,13 +121,12 @@ namespace osu.Game.GameModes.Play TextSize = 80; } - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); - DisplayedCountSpriteText.Text = FormatCount(Count); - DisplayedCountSpriteText.Anchor = this.Anchor; - DisplayedCountSpriteText.Origin = this.Origin; + DisplayedCountSpriteText.Anchor = Anchor; + DisplayedCountSpriteText.Origin = Origin; StopRolling(); } diff --git a/osu.Game/GameModes/Play/HitRenderer.cs b/osu.Game/GameModes/Play/HitRenderer.cs index e693da527d..d489a105fa 100644 --- a/osu.Game/GameModes/Play/HitRenderer.cs +++ b/osu.Game/GameModes/Play/HitRenderer.cs @@ -8,6 +8,7 @@ using osu.Game.Beatmaps.Objects; using osu.Framework; using System; using System.Linq; +using osu.Framework.Allocation; namespace osu.Game.GameModes.Play { @@ -42,10 +43,9 @@ namespace osu.Game.GameModes.Play protected virtual List Convert(List objects) => Converter.Convert(objects); - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); - RelativeSizeAxes = Axes.Both; Children = new Drawable[] diff --git a/osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs b/osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs index 99cd0012cc..dcae3fbff6 100644 --- a/osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs +++ b/osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; using osu.Framework; +using osu.Framework.Allocation; namespace osu.Game.GameModes.Play.Mania { @@ -23,11 +24,10 @@ namespace osu.Game.GameModes.Play.Mania Origin = Anchor.BottomCentre; } - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); - - Add(new Box() { RelativeSizeAxes = Axes.Both, Alpha = 0.5f }); + Add(new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.5f }); for (int i = 0; i < columns; i++) Add(new Box() diff --git a/osu.Game/GameModes/Play/Osu/OsuComboCounter.cs b/osu.Game/GameModes/Play/Osu/OsuComboCounter.cs index f0fc4cf580..c4ceaf3453 100644 --- a/osu.Game/GameModes/Play/Osu/OsuComboCounter.cs +++ b/osu.Game/GameModes/Play/Osu/OsuComboCounter.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using osu.Framework.Allocation; namespace osu.Game.GameModes.Play.Osu { @@ -33,12 +34,11 @@ namespace osu.Game.GameModes.Play.Osu } } - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); - - PopOutSpriteText.Origin = this.Origin; - PopOutSpriteText.Anchor = this.Anchor; + PopOutSpriteText.Origin = Origin; + PopOutSpriteText.Anchor = Anchor; Add(PopOutSpriteText); } diff --git a/osu.Game/GameModes/Play/PlaySongSelect.cs b/osu.Game/GameModes/Play/PlaySongSelect.cs index 9bb115aba4..36342faacd 100644 --- a/osu.Game/GameModes/Play/PlaySongSelect.cs +++ b/osu.Game/GameModes/Play/PlaySongSelect.cs @@ -21,6 +21,8 @@ using osu.Game.Beatmaps.Drawable; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Game.Beatmaps; using osu.Framework.GameModes; +using osu.Framework.Allocation; +using osu.Framework.Audio; namespace osu.Game.GameModes.Play { @@ -126,11 +128,11 @@ namespace osu.Game.GameModes.Play }; } - protected override void Load(BaseGame game) + [Initializer] + private void Load(BeatmapDatabase beatmaps, AudioManager audio, BaseGame game) { - base.Load(game); - - OsuGame osuGame = game as OsuGame; + // TODO: Load(..., [PermitNull] OsuGame osuGame) or some such + var osuGame = game as OsuGame; if (osuGame != null) { playMode = osuGame.PlayMode; @@ -140,11 +142,11 @@ namespace osu.Game.GameModes.Play } if (database == null) - database = game.Dependencies.Get(); + database = beatmaps; database.BeatmapSetAdded += s => Schedule(() => addBeatmapSet(s)); - trackManager = game.Audio.Track; + trackManager = audio.Track; Task.Factory.StartNew(addBeatmapSets); } diff --git a/osu.Game/GameModes/Play/Player.cs b/osu.Game/GameModes/Play/Player.cs index eadb3ae2ae..0236fe7d44 100644 --- a/osu.Game/GameModes/Play/Player.cs +++ b/osu.Game/GameModes/Play/Player.cs @@ -13,6 +13,8 @@ using osu.Game.Database; using osu.Framework.Timing; using osu.Framework.Audio.Track; using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Framework.Allocation; +using osu.Framework.Audio; namespace osu.Game.GameModes.Play { @@ -30,17 +32,10 @@ namespace osu.Game.GameModes.Play private InterpolatingFramedClock playerClock; private IAdjustableClock sourceClock; - private BeatmapDatabase beatmaps; - - public Player(BeatmapDatabase beatmaps) - { - this.beatmaps = beatmaps; - } - protected override void Load(BaseGame game) + [Initializer] + private void Load(AudioManager audio, BeatmapDatabase beatmaps) { - base.Load(game); - try { if (Beatmap == null) @@ -57,7 +52,7 @@ namespace osu.Game.GameModes.Play if (track != null) { - game.Audio.Track.SetExclusive(track); + audio.Track.SetExclusive(track); sourceClock = track; } diff --git a/osu.Game/GameModes/Play/Taiko/TaikoPlayfield.cs b/osu.Game/GameModes/Play/Taiko/TaikoPlayfield.cs index 9d2231667e..19fd1d27f5 100644 --- a/osu.Game/GameModes/Play/Taiko/TaikoPlayfield.cs +++ b/osu.Game/GameModes/Play/Taiko/TaikoPlayfield.cs @@ -7,6 +7,8 @@ using osu.Framework.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; using osu.Framework; +using osu.Framework.Allocation; +using osu.Framework.Graphics.Textures; namespace osu.Game.GameModes.Play.Taiko { @@ -20,15 +22,14 @@ namespace osu.Game.GameModes.Play.Taiko Origin = Anchor.Centre; } - protected override void Load(BaseGame game) + [Initializer] + private void Load(TextureStore textures) { - base.Load(game); - Add(new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.5f }); Add(new Sprite { - Texture = game.Textures.Get(@"Menu/logo"), + Texture = textures.Get(@"Menu/logo"), Origin = Anchor.Centre, Scale = new Vector2(0.2f), RelativePositionAxes = Axes.Both, diff --git a/osu.Game/Graphics/Background/Background.cs b/osu.Game/Graphics/Background/Background.cs index 8d004dcf86..1ef4cc7181 100644 --- a/osu.Game/Graphics/Background/Background.cs +++ b/osu.Game/Graphics/Background/Background.cs @@ -10,6 +10,8 @@ using OpenTK.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework; using System.Threading.Tasks; +using osu.Framework.Graphics.Textures; +using osu.Framework.Allocation; namespace osu.Game.Graphics.Background { @@ -26,13 +28,12 @@ namespace osu.Game.Graphics.Background Depth = float.MinValue; } - protected override void Load(BaseGame game) + [Initializer] + private void Load(TextureStore textures) { - base.Load(game); - Add(BackgroundSprite = new Sprite { - Texture = game.Textures.Get(textureName), + Texture = textures.Get(textureName), Anchor = Anchor.Centre, Origin = Anchor.Centre, Colour = Color4.DarkGray diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 5b28779e47..6a39659afd 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -3,6 +3,7 @@ using osu.Framework.Graphics; using osu.Framework.Input; using OpenTK; using osu.Framework; +using osu.Framework.Allocation; namespace osu.Game.Graphics.Containers { @@ -15,21 +16,21 @@ namespace osu.Game.Graphics.Containers public ParallaxContainer() { RelativeSizeAxes = Axes.Both; - AddInternal(content = new Container() - { - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.Centre, - Origin = Anchor.Centre - }); } private Container content; protected override Container Content => content; - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); + AddInternal(content = new Container() + { + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre + }); } protected override bool OnMouseMove(InputState state) diff --git a/osu.Game/Graphics/Cursor/OsuCursorContainer.cs b/osu.Game/Graphics/Cursor/OsuCursorContainer.cs index 49e6bc84f5..511063bcb0 100644 --- a/osu.Game/Graphics/Cursor/OsuCursorContainer.cs +++ b/osu.Game/Graphics/Cursor/OsuCursorContainer.cs @@ -2,10 +2,12 @@ //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Transformations; using osu.Framework.Input; @@ -37,15 +39,14 @@ namespace osu.Game.Graphics.Cursor AutoSizeAxes = Axes.Both; } - protected override void Load(BaseGame game) + [Initializer] + private void Load(TextureStore textures) { - base.Load(game); - Children = new Drawable[] { new Sprite { - Texture = game.Textures.Get(@"Cursor/cursor") + Texture = textures.Get(@"Cursor/cursor") } }; } diff --git a/osu.Game/Graphics/UserInterface/KeyCounter.cs b/osu.Game/Graphics/UserInterface/KeyCounter.cs index f56a0a3853..4985cc65f9 100644 --- a/osu.Game/Graphics/UserInterface/KeyCounter.cs +++ b/osu.Game/Graphics/UserInterface/KeyCounter.cs @@ -4,9 +4,11 @@ using OpenTK; using OpenTK.Graphics; using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; namespace osu.Game.Graphics.UserInterface { @@ -59,20 +61,20 @@ namespace osu.Game.Graphics.UserInterface Name = name; } - protected override void Load(BaseGame game) + [Initializer] + private void Load(TextureStore textures) { - base.Load(game); Children = new Drawable[] { buttonSprite = new Sprite { - Texture = game.Textures.Get(@"KeyCounter/key-up"), + Texture = textures.Get(@"KeyCounter/key-up"), Anchor = Anchor.Centre, Origin = Anchor.Centre, }, glowSprite = new Sprite { - Texture = game.Textures.Get(@"KeyCounter/key-glow"), + Texture = textures.Get(@"KeyCounter/key-glow"), Anchor = Anchor.Centre, Origin = Anchor.Centre, Alpha = 0 diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index 87403c232a..d4cbfe100f 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -12,6 +12,7 @@ using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; +using osu.Framework.Allocation; namespace osu.Game.Graphics.UserInterface { @@ -119,15 +120,14 @@ namespace osu.Game.Graphics.UserInterface AutoSizeAxes = Axes.Both; } - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); - DisplayedCount = Count; DisplayedCountSpriteText.Text = FormatCount(count); - DisplayedCountSpriteText.Anchor = this.Anchor; - DisplayedCountSpriteText.Origin = this.Origin; + DisplayedCountSpriteText.Anchor = Anchor; + DisplayedCountSpriteText.Origin = Origin; } protected override void LoadComplete() diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index ee6cd137df..e889dee0a8 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -12,6 +12,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using osu.Framework.Allocation; namespace osu.Game.Graphics.UserInterface { @@ -109,10 +110,9 @@ namespace osu.Game.Graphics.UserInterface }; } - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); - starContainer.Width = MaxStars * StarSize + Math.Max(MaxStars - 1, 0) * StarSpacing; starContainer.Height = StarSize; diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs index 0acd330b0e..0d03845062 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs @@ -6,6 +6,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Input; using osu.Framework.Threading; using OpenTK; +using osu.Framework.Allocation; namespace osu.Game.Graphics.UserInterface.Volume { @@ -32,7 +33,8 @@ namespace osu.Game.Graphics.UserInterface.Volume Origin = Anchor.BottomRight; } - protected override void Load(BaseGame game) + [Initializer] + private void Load() { VolumeGlobal.ValueChanged += volumeChanged; VolumeSample.ValueChanged += volumeChanged; @@ -55,8 +57,6 @@ namespace osu.Game.Graphics.UserInterface.Volume } } }; - - base.Load(game); } protected override void Dispose(bool isDisposing) diff --git a/osu.Game/Online/Chat/Display/ChannelDisplay.cs b/osu.Game/Online/Chat/Display/ChannelDisplay.cs index 98fa40679b..d72eaf305a 100644 --- a/osu.Game/Online/Chat/Display/ChannelDisplay.cs +++ b/osu.Game/Online/Chat/Display/ChannelDisplay.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Transformations; using osu.Game.Online.Chat.Display.osu.Online.Social; using OpenTK; using osu.Framework; +using osu.Framework.Allocation; namespace osu.Game.Online.Chat.Display { @@ -59,9 +60,9 @@ namespace osu.Game.Online.Chat.Display channel.NewMessagesArrived -= newMessages; } - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); newMessages(channel.Messages); } diff --git a/osu.Game/Online/Chat/Display/ChatLine.cs b/osu.Game/Online/Chat/Display/ChatLine.cs index 1b827e048e..14cdb6ed11 100644 --- a/osu.Game/Online/Chat/Display/ChatLine.cs +++ b/osu.Game/Online/Chat/Display/ChatLine.cs @@ -10,6 +10,7 @@ using OpenTK; using OpenTK.Graphics; using osu.Framework; using osu.Framework.Graphics.Primitives; +using osu.Framework.Allocation; namespace osu.Game.Online.Chat.Display { @@ -27,10 +28,9 @@ namespace osu.Game.Online.Chat.Display const float padding = 200; const float text_size = 20; - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); - RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 65179d5edb..5b5134cd4f 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -20,6 +20,7 @@ using OpenTK.Input; using osu.Framework.Logging; using osu.Game.Graphics.UserInterface.Volume; using osu.Game.Database; +using osu.Framework.Allocation; namespace osu.Game { @@ -51,7 +52,8 @@ namespace osu.Game host.Size = new Vector2(Config.Get(OsuConfig.Width), Config.Get(OsuConfig.Height)); } - protected override void Load(BaseGame game) + [Initializer] + private void Load() { if (!Host.IsPrimaryInstance) { @@ -59,8 +61,6 @@ namespace osu.Game Environment.Exit(0); } - base.Load(game); - if (args?.Length > 0) Schedule(delegate { Dependencies.Get().Import(args); }); @@ -98,7 +98,7 @@ namespace osu.Game (intro = new Intro { Beatmap = Beatmap - }).Preload(game, d => + }).Preload(this, d => { mainContent.Add(d); @@ -107,8 +107,8 @@ namespace osu.Game intro.DisplayAsRoot(); }); - (Chat = new ChatConsole(API)).Preload(game, Add); - (MusicController = new MusicController()).Preload(game, Add); + (Chat = new ChatConsole(API)).Preload(this, Add); + (MusicController = new MusicController()).Preload(this, Add); (Toolbar = new Toolbar { @@ -116,7 +116,7 @@ namespace osu.Game OnSettings = Options.ToggleVisibility, OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; }, OnMusicController = MusicController.ToggleVisibility - }).Preload(game, t => + }).Preload(this, t => { PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); }; PlayMode.TriggerChange(); diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 65f8974571..2957a375be 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -1,5 +1,6 @@ using System; using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.GameModes; using osu.Framework.Graphics; @@ -52,10 +53,9 @@ namespace osu.Game { } - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); - Dependencies.Cache(this); Dependencies.Cache(); Dependencies.Cache(new BeatmapDatabase(Host.Storage, Host)); @@ -63,7 +63,7 @@ namespace osu.Game OszArchiveReader.Register(); //this completely overrides the framework default. will need to change once we make a proper FontStore. - Fonts = new TextureStore() { ScaleAdjust = 0.01f }; + Fonts = new FontStore { ScaleAdjust = 0.01f }; Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont")); diff --git a/osu.Game/Overlays/ChatConsole.cs b/osu.Game/Overlays/ChatConsole.cs index 2dd6480715..1814130ac0 100644 --- a/osu.Game/Overlays/ChatConsole.cs +++ b/osu.Game/Overlays/ChatConsole.cs @@ -7,6 +7,7 @@ using System.Linq; using OpenTK; using OpenTK.Graphics; using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -55,9 +56,9 @@ namespace osu.Game.Overlays }); } - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); initializeChannels(); } diff --git a/osu.Game/Overlays/Options/General/LanguageOptions.cs b/osu.Game/Overlays/Options/General/LanguageOptions.cs index 594bb9b1ec..f9afe0e94a 100644 --- a/osu.Game/Overlays/Options/General/LanguageOptions.cs +++ b/osu.Game/Overlays/Options/General/LanguageOptions.cs @@ -1,34 +1,32 @@ using osu.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; +using osu.Framework.Allocation; using osu.Game.Configuration; namespace osu.Game.Overlays.Options.General { public class LanguageOptions : OptionsSubsection { - protected override string Header => "Language"; - private CheckBoxOption showUnicode, altChatFont; - - public LanguageOptions() - { - Children = new Drawable[] - { - new SpriteText { Text = "TODO: Dropdown" }, - showUnicode = new CheckBoxOption { LabelText = "Prefer metadata in original language" }, - altChatFont = new CheckBoxOption { LabelText = "Use alternative font for chat display" }, - }; - } - - protected override void Load(BaseGame game) + protected override string Header => "Language"; + + [Initializer] + private void Load(OsuConfigManager config) { - base.Load(game); - var osuGame = game as OsuGameBase; - if (osuGame != null) - { - showUnicode.Bindable = osuGame.Config.GetBindable(OsuConfig.ShowUnicode); - altChatFont.Bindable = osuGame.Config.GetBindable(OsuConfig.AlternativeChatFont); - } + Children = new Drawable[] + { + new SpriteText { Text = "TODO: Dropdown" }, + new CheckBoxOption + { + LabelText = "Prefer metadata in original language", + Bindable = config.GetBindable(OsuConfig.ShowUnicode) + }, + new CheckBoxOption + { + LabelText = "Use alternative font for chat display", + Bindable = config.GetBindable(OsuConfig.AlternativeChatFont) + }, + }; } } } diff --git a/osu.Game/Overlays/Options/General/LoginOptions.cs b/osu.Game/Overlays/Options/General/LoginOptions.cs index f54084b89a..e31a6d29ff 100644 --- a/osu.Game/Overlays/Options/General/LoginOptions.cs +++ b/osu.Game/Overlays/Options/General/LoginOptions.cs @@ -1,5 +1,6 @@ using OpenTK; using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -27,15 +28,14 @@ namespace osu.Game.Overlays.Options.General }; } - protected override void Load(BaseGame game) + [Initializer(permitNulls: true)] + private void Load(APIAccess api) { - base.Load(game); - var osuGame = game as OsuGameBase; - if (osuGame == null) + if (api == null) return; loginForm.Children = new Drawable[] { - new LoginForm(osuGame.API) + new LoginForm(api) }; } @@ -63,4 +63,4 @@ namespace osu.Game.Overlays.Options.General } } } -} \ No newline at end of file +} diff --git a/osu.Game/Overlays/Options/General/UpdateOptions.cs b/osu.Game/Overlays/Options/General/UpdateOptions.cs index 79cd3599ee..0f61f49eb9 100644 --- a/osu.Game/Overlays/Options/General/UpdateOptions.cs +++ b/osu.Game/Overlays/Options/General/UpdateOptions.cs @@ -1,4 +1,5 @@ using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Platform; @@ -8,28 +9,22 @@ namespace osu.Game.Overlays.Options.General { public class UpdateOptions : OptionsSubsection { - private BasicStorage storage; protected override string Header => "Updates"; - public UpdateOptions() - { - Children = new Drawable[] - { - new SpriteText { Text = "TODO: Dropdown" }, - new SpriteText { Text = "Your osu! is up to date" }, // TODO: map this to reality - new OsuButton - { - RelativeSizeAxes = Axes.X, - Text = "Open osu! folder", - Action = () => storage?.OpenInNativeExplorer(), - } - }; - } - - protected override void Load(BaseGame game) + [Initializer] + private void Load(BasicStorage storage) { - base.Load(game); - this.storage = game.Host.Storage; + Children = new Drawable[] + { + new SpriteText { Text = "TODO: Dropdown" }, + new SpriteText { Text = "Your osu! is up to date" }, // TODO: map this to reality + new OsuButton + { + RelativeSizeAxes = Axes.X, + Text = "Open osu! folder", + Action = () => storage.OpenInNativeExplorer(), + } + }; } } } diff --git a/osu.Game/Overlays/Toolbar.cs b/osu.Game/Overlays/Toolbar.cs index f4c5d356dd..25a4c0d4f5 100644 --- a/osu.Game/Overlays/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar.cs @@ -12,6 +12,7 @@ using osu.Game.Configuration; using osu.Game.GameModes.Play; using osu.Game.Graphics; using osu.Framework.Graphics.Sprites; +using osu.Framework.Allocation; namespace osu.Game.Overlays { @@ -111,10 +112,10 @@ namespace osu.Game.Overlays Size = new Vector2(1, height); } - protected override void Load(BaseGame game) + [Initializer] + private void Load(OsuConfigManager config) { - base.Load(game); - userButton.Text = ((OsuGame)game).Config.Get(OsuConfig.Username); + userButton.Text = config.Get(OsuConfig.Username); } public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode); diff --git a/osu.Game/Overlays/ToolbarModeButton.cs b/osu.Game/Overlays/ToolbarModeButton.cs index bd01089a60..f9c0ee7865 100644 --- a/osu.Game/Overlays/ToolbarModeButton.cs +++ b/osu.Game/Overlays/ToolbarModeButton.cs @@ -6,6 +6,7 @@ using osu.Game.GameModes.Play; using osu.Game.Graphics; using OpenTK.Graphics; using osu.Framework; +using osu.Framework.Allocation; namespace osu.Game.Overlays { @@ -43,9 +44,9 @@ namespace osu.Game.Overlays } } - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); DrawableIcon.TextSize *= 1.4f; } } diff --git a/osu.Game/Overlays/ToolbarModeSelector.cs b/osu.Game/Overlays/ToolbarModeSelector.cs index c97b7f9d92..bf72d9f22f 100644 --- a/osu.Game/Overlays/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/ToolbarModeSelector.cs @@ -12,6 +12,7 @@ using OpenTK.Graphics; using osu.Framework; using osu.Framework.Caching; using osu.Framework.Graphics.Sprites; +using osu.Framework.Allocation; namespace osu.Game.Overlays { @@ -30,10 +31,9 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.Y; } - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); - Children = new Drawable[] { new Box From fe9034323b884a0dca913524ad46a517aba1a716 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 8 Nov 2016 18:46:08 -0500 Subject: [PATCH 04/19] Get the game running, though not perfectly --- .../Tests/TestCasePlayer.cs | 6 ---- osu.Game/Beatmaps/Formats/BeatmapDecoder.cs | 2 +- .../Graphics/Containers/ParallaxContainer.cs | 2 +- osu.Game/OsuGameBase.cs | 30 +++++++++---------- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs index 80289ae488..03e382b71e 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs @@ -26,12 +26,6 @@ namespace osu.Desktop.VisualTests.Tests protected override IFrameBasedClock Clock => localClock; - [Initializer] - private void Load() - { - // TODO: Do we even need this here? - } - public override void Reset() { base.Reset(); diff --git a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs index e3d89ac6fc..ca11b97587 100644 --- a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs +++ b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs @@ -52,7 +52,7 @@ namespace osu.Game.Beatmaps.Formats foreach (HitObject h in b.HitObjects) { - if (h.NewCombo) i = (i + 1) % colours.Count; + if (h.NewCombo || i == -1) i = (i + 1) % colours.Count; h.Colour = colours[i]; } } diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 6a39659afd..370f7fbbe9 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -45,4 +45,4 @@ namespace osu.Game.Graphics.Containers content.Scale = new Vector2(1 + ParallaxAmount); } } -} \ No newline at end of file +} diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 2957a375be..a99d0967f1 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -37,18 +37,6 @@ namespace osu.Game public readonly Bindable Beatmap = new Bindable(); - public OsuGameBase() - { - AddInternal(ratioContainer = new RatioAdjust()); - - Children = new Drawable[] - { - Cursor = new OsuCursorContainer { Depth = float.MaxValue } - }; - - Beatmap.ValueChanged += Beatmap_ValueChanged; - } - private void Beatmap_ValueChanged(object sender, EventArgs e) { } @@ -57,8 +45,20 @@ namespace osu.Game private void Load() { Dependencies.Cache(this); - Dependencies.Cache(); + Dependencies.Cache(new OsuConfigManager(Host.Storage)); Dependencies.Cache(new BeatmapDatabase(Host.Storage, Host)); + + AddInternal(ratioContainer = new RatioAdjust()); + + Children = new Drawable[] + { + Options = new OptionsOverlay(), + Cursor = new OsuCursorContainer { Depth = float.MaxValue } + }; + + Dependencies.Cache(Options); + + Beatmap.ValueChanged += Beatmap_ValueChanged; OszArchiveReader.Register(); @@ -80,12 +80,12 @@ namespace osu.Game Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic")); - API = new APIAccess() + Dependencies.Cache(API = new APIAccess { Username = Config.Get(OsuConfig.Username), Password = Config.Get(OsuConfig.Password), Token = Config.Get(OsuConfig.Token) - }; + }); } public override void SetHost(BasicGameHost host) From 2362665b8a3f2f446289dcb612bb10b2aa043132 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 8 Nov 2016 18:51:39 -0500 Subject: [PATCH 05/19] Re-cache the new FontStore when overwritten Fixes issues with font loading --- osu.Game/OsuGameBase.cs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index a99d0967f1..1288473934 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -45,25 +45,11 @@ namespace osu.Game private void Load() { Dependencies.Cache(this); - Dependencies.Cache(new OsuConfigManager(Host.Storage)); + Dependencies.Cache(new OsuConfigManager(Host.Storage)); Dependencies.Cache(new BeatmapDatabase(Host.Storage, Host)); - AddInternal(ratioContainer = new RatioAdjust()); - - Children = new Drawable[] - { - Options = new OptionsOverlay(), - Cursor = new OsuCursorContainer { Depth = float.MaxValue } - }; - - Dependencies.Cache(Options); - - Beatmap.ValueChanged += Beatmap_ValueChanged; - - OszArchiveReader.Register(); - //this completely overrides the framework default. will need to change once we make a proper FontStore. - Fonts = new FontStore { ScaleAdjust = 0.01f }; + Dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 0.01f }); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont")); @@ -79,6 +65,20 @@ namespace osu.Game Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-MediumItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic")); + + AddInternal(ratioContainer = new RatioAdjust()); + + Children = new Drawable[] + { + Options = new OptionsOverlay(), + Cursor = new OsuCursorContainer { Depth = float.MaxValue } + }; + + Dependencies.Cache(Options); + + Beatmap.ValueChanged += Beatmap_ValueChanged; + + OszArchiveReader.Register(); Dependencies.Cache(API = new APIAccess { From 7327db307b2988c0ef1493ccce84887fd6b73696 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 8 Nov 2016 19:02:42 -0500 Subject: [PATCH 06/19] Fix player loading from song select --- osu.Game/GameModes/Play/PlaySongSelect.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/osu.Game/GameModes/Play/PlaySongSelect.cs b/osu.Game/GameModes/Play/PlaySongSelect.cs index 36342faacd..ca43e02b3b 100644 --- a/osu.Game/GameModes/Play/PlaySongSelect.cs +++ b/osu.Game/GameModes/Play/PlaySongSelect.cs @@ -115,13 +115,11 @@ namespace osu.Game.GameModes.Play Width = 100, Text = "Play", Colour = new Color4(238, 51, 153, 255), - Action = () => + Action = () => Push(new Player { - var player = Game.Dependencies.Get(); - player.BeatmapInfo = selectedBeatmapGroup.SelectedPanel.Beatmap; - player.PreferredPlayMode = playMode.Value; - Push(player); - } + BeatmapInfo = selectedBeatmapGroup.SelectedPanel.Beatmap, + PreferredPlayMode = playMode.Value + }) }, } } From 0d4560a054514a652f55cd3680d938aeeb4e944e Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 10 Nov 2016 17:40:42 -0500 Subject: [PATCH 07/19] Update to latest DI stuff --- .vscode/launch.json | 2 +- .vscode/settings.json | 3 + osu-framework | 2 +- .../Tests/TestCaseMusicController.cs | 5 +- osu.Game/GameModes/OsuGameMode.cs | 7 +- .../Graphics/Containers/ParallaxContainer.cs | 15 ++-- osu.Game/OsuGame.cs | 4 +- osu.Game/OsuGameBase.cs | 8 +- osu.Game/Overlays/MusicController.cs | 17 ++-- .../Overlays/Options/Audio/VolumeOptions.cs | 46 +++++----- osu.Game/Overlays/Options/EditorSection.cs | 81 ++++++++++-------- .../Gameplay/GeneralGameplayOptions.cs | 57 +++++++------ .../Options/Graphics/DetailOptions.cs | 83 +++++++++++-------- .../Options/Graphics/LayoutOptions.cs | 43 +++++----- .../Options/Graphics/MainMenuOptions.cs | 66 ++++++++------- .../Options/Graphics/RendererOptions.cs | 44 +++++----- .../Graphics/SongSelectGraphicsOptions.cs | 38 ++++----- .../Overlays/Options/Input/MouseOptions.cs | 72 +++++++++------- .../Options/Input/OtherInputOptions.cs | 49 +++++------ .../Options/Online/InGameChatOptions.cs | 57 +++++++------ .../Options/Online/NotificationsOptions.cs | 58 +++++++------ .../Online/OnlineIntegrationOptions.cs | 59 ++++++------- .../Overlays/Options/Online/PrivacyOptions.cs | 29 +++---- osu.Game/Overlays/Options/SkinSection.cs | 72 ++++++++-------- 24 files changed, 481 insertions(+), 436 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/launch.json b/.vscode/launch.json index d9a6ae12ff..f1682a2ce2 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,7 +5,7 @@ "name": "Launch", "type": "mono", "request": "launch", - "program": "${workspaceRoot}/osu.Desktop/bin/Debug/osu!.exe", + "program": "${workspaceRoot}/osu.Desktop.VisualTests/bin/Debug/osu!.exe", "args": [], "cwd": "${workspaceRoot}", "preLaunchTask": "", diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..20af2f68a6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +// Place your settings in this file to overwrite default and user settings. +{ +} \ No newline at end of file diff --git a/osu-framework b/osu-framework index eb16219058..aa01720fe9 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit eb16219058e87210c9ad90b1e214ccc2c1556058 +Subproject commit aa01720fe9eb6e3b30a4455298a1c6eca7fb7680 diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs b/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs index 070745a49c..36b2c49274 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.GameModes.Testing; using osu.Game.Overlays; @@ -24,9 +25,9 @@ namespace osu.Desktop.Tests protected MusicController mc; - protected override void Load(BaseGame game) + [Initializer] + private void Load() { - base.Load(game); ourClock = new FramedClock(); } diff --git a/osu.Game/GameModes/OsuGameMode.cs b/osu.Game/GameModes/OsuGameMode.cs index 33889e3689..18219b152d 100644 --- a/osu.Game/GameModes/OsuGameMode.cs +++ b/osu.Game/GameModes/OsuGameMode.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.GameModes; using osu.Framework.Graphics.Containers; @@ -69,10 +70,10 @@ namespace osu.Game.GameModes OnBeatmapChanged(beatmap.Value); } - protected override void Load(BaseGame game) + [Initializer(permitNulls: true)] + private void Load(OsuGameBase game) { - base.Load(game); - beatmap = (game as OsuGameBase)?.Beatmap; + beatmap = game?.Beatmap; } public override bool Push(GameMode mode) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 370f7fbbe9..52029dbf8e 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -16,16 +16,7 @@ namespace osu.Game.Graphics.Containers public ParallaxContainer() { RelativeSizeAxes = Axes.Both; - } - - private Container content; - - protected override Container Content => content; - - [Initializer] - private void Load() - { - AddInternal(content = new Container() + AddInternal(content = new Container { RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, @@ -33,6 +24,10 @@ namespace osu.Game.Graphics.Containers }); } + private Container content; + + protected override Container Content => content; + protected override bool OnMouseMove(InputState state) { content.Position = (state.Mouse.Position - DrawSize / 2) * ParallaxAmount; diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 5b5134cd4f..490389237f 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -64,6 +64,8 @@ namespace osu.Game if (args?.Length > 0) Schedule(delegate { Dependencies.Get().Import(args); }); + Dependencies.Cache(this); + //attach our bindables to the audio subsystem. Audio.Volume.Weld(Config.GetBindable(OsuConfig.VolumeUniversal)); Audio.VolumeSample.Weld(Config.GetBindable(OsuConfig.VolumeEffect)); @@ -93,7 +95,7 @@ namespace osu.Game } }); - (Options = new OptionsOverlay { Depth = float.MaxValue / 2 }).Preload(game, Add); + (Options = new OptionsOverlay { Depth = float.MaxValue / 2 }).Preload(this, Add); (intro = new Intro { diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 1288473934..2ca8c452a5 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -67,14 +67,14 @@ namespace osu.Game Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic")); AddInternal(ratioContainer = new RatioAdjust()); - + + var options = new OptionsOverlay(); Children = new Drawable[] { - Options = new OptionsOverlay(), + options, Cursor = new OsuCursorContainer { Depth = float.MaxValue } }; - - Dependencies.Cache(Options); + Dependencies.Cache(options); Beatmap.ValueChanged += Beatmap_ValueChanged; diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 310bae37e4..4043c10327 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -7,6 +7,8 @@ using System.Threading.Tasks; using OpenTK; using OpenTK.Graphics; using osu.Framework; +using osu.Framework.Allocation; +using osu.Framework.Audio; using osu.Framework.Audio.Track; using osu.Framework.Configuration; using osu.Framework.Graphics; @@ -174,21 +176,16 @@ namespace osu.Game.Overlays }; } - protected override void Load(BaseGame game) + [Initializer(permitNulls: true)] + private void Load(OsuGame osuGame, BeatmapDatabase beatmaps, AudioManager audio, TextureStore textures) { - base.Load(game); - var osuGame = game as OsuGameBase; - - if (osuGame != null) - { - if (database == null) database = osuGame.Beatmaps; - trackManager = osuGame.Audio.Track; - } + if (database == null) database = beatmaps; + trackManager = audio.Track; beatmapSource = osuGame?.Beatmap ?? new Bindable(); playList = database.GetAllWithChildren(); - backgroundSprite = getScaledSprite(fallbackTexture = game.Textures.Get(@"Backgrounds/bg4")); + backgroundSprite = getScaledSprite(fallbackTexture = textures.Get(@"Backgrounds/bg4")); AddInternal(backgroundSprite); } diff --git a/osu.Game/Overlays/Options/Audio/VolumeOptions.cs b/osu.Game/Overlays/Options/Audio/VolumeOptions.cs index f9c2326123..adf7e923f7 100644 --- a/osu.Game/Overlays/Options/Audio/VolumeOptions.cs +++ b/osu.Game/Overlays/Options/Audio/VolumeOptions.cs @@ -1,36 +1,36 @@ using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Game.Configuration; -namespace osu.Game.Overlays.Options.Audio -{ - public class VolumeOptions : OptionsSubsection - { +namespace osu.Game.Overlays.Options.Audio +{ + public class VolumeOptions : OptionsSubsection + { protected override string Header => "Volume"; - private CheckBoxOption ignoreHitsounds; - - public VolumeOptions() - { - Children = new Drawable[] - { - new SpriteText { Text = "Master: TODO slider" }, - new SpriteText { Text = "Music: TODO slider" }, - new SpriteText { Text = "Effect: TODO slider" }, - ignoreHitsounds = new CheckBoxOption { LabelText = "Ignore beatmap hitsounds" } - }; + private CheckBoxOption ignoreHitsounds; + + public VolumeOptions() + { } - protected override void Load(BaseGame game) + [Initializer] + private void Load(OsuConfigManager config) { - base.Load(game); - var osuGame = game as OsuGameBase; - if (osuGame != null) + Children = new Drawable[] { - ignoreHitsounds.Bindable = osuGame.Config.GetBindable(OsuConfig.IgnoreBeatmapSamples); - } - } - } + new SpriteText { Text = "Master: TODO slider" }, + new SpriteText { Text = "Music: TODO slider" }, + new SpriteText { Text = "Effect: TODO slider" }, + new CheckBoxOption + { + LabelText = "Ignore beatmap hitsounds", + Bindable = config.GetBindable(OsuConfig.IgnoreBeatmapSamples) + } + }; + } + } } \ No newline at end of file diff --git a/osu.Game/Overlays/Options/EditorSection.cs b/osu.Game/Overlays/Options/EditorSection.cs index be02af7c7b..998f31c77c 100644 --- a/osu.Game/Overlays/Options/EditorSection.cs +++ b/osu.Game/Overlays/Options/EditorSection.cs @@ -1,47 +1,56 @@ using OpenTK; using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.UserInterface; using osu.Game.Configuration; using osu.Game.Graphics; -namespace osu.Game.Overlays.Options -{ - public class EditorSection : OptionsSection - { - protected override string Header => "Editor"; +namespace osu.Game.Overlays.Options +{ + public class EditorSection : OptionsSection + { + protected override string Header => "Editor"; public override FontAwesome Icon => FontAwesome.fa_pencil; - private CheckBoxOption backgroundVideo, defaultSkin, snakingSliders, hitAnimations, followPoints, stacking; - - public EditorSection() - { - content.Spacing = new Vector2(0, 5); - Children = new Drawable[] - { - backgroundVideo = new CheckBoxOption { LabelText = "Background video" }, - defaultSkin = new CheckBoxOption { LabelText = "Always use default skin" }, - snakingSliders = new CheckBoxOption { LabelText = "Snaking sliders" }, - hitAnimations = new CheckBoxOption { LabelText = "Hit animations" }, - followPoints = new CheckBoxOption { LabelText = "Follow points" }, - stacking = new CheckBoxOption { LabelText = "Stacking" }, - }; - } - - protected override void Load(BaseGame game) + [Initializer] + private void Load(OsuConfigManager config) { - base.Load(game); - var osuGame = game as OsuGameBase; - if (osuGame != null) + content.Spacing = new Vector2(0, 5); + Children = new Drawable[] { - backgroundVideo.Bindable = osuGame.Config.GetBindable(OsuConfig.VideoEditor); - defaultSkin.Bindable = osuGame.Config.GetBindable(OsuConfig.EditorDefaultSkin); - snakingSliders.Bindable = osuGame.Config.GetBindable(OsuConfig.EditorSnakingSliders); - hitAnimations.Bindable = osuGame.Config.GetBindable(OsuConfig.EditorHitAnimations); - followPoints.Bindable = osuGame.Config.GetBindable(OsuConfig.EditorFollowPoints); - stacking.Bindable = osuGame.Config.GetBindable(OsuConfig.EditorStacking); - } - } - } -} - + new CheckBoxOption + { + LabelText = "Background video", + Bindable = config.GetBindable(OsuConfig.VideoEditor) + }, + new CheckBoxOption + { + LabelText = "Always use default skin", + Bindable = config.GetBindable(OsuConfig.EditorDefaultSkin) + }, + new CheckBoxOption + { + LabelText = "Snaking sliders", + Bindable = config.GetBindable(OsuConfig.EditorSnakingSliders) + }, + new CheckBoxOption + { + LabelText = "Hit animations", + Bindable = config.GetBindable(OsuConfig.EditorHitAnimations) + }, + new CheckBoxOption + { + LabelText = "Follow points", + Bindable = config.GetBindable(OsuConfig.EditorFollowPoints) + }, + new CheckBoxOption + { + LabelText = "Stacking", + Bindable = config.GetBindable(OsuConfig.EditorStacking) + }, + }; + } + } +} + diff --git a/osu.Game/Overlays/Options/Gameplay/GeneralGameplayOptions.cs b/osu.Game/Overlays/Options/Gameplay/GeneralGameplayOptions.cs index 4c51bddbfa..f2d6f6049d 100644 --- a/osu.Game/Overlays/Options/Gameplay/GeneralGameplayOptions.cs +++ b/osu.Game/Overlays/Options/Gameplay/GeneralGameplayOptions.cs @@ -1,18 +1,18 @@ -using osu.Framework; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.UserInterface; -using osu.Game.Configuration; - +using osu.Framework; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Configuration; + namespace osu.Game.Overlays.Options.Gameplay { public class GeneralGameplayOptions : OptionsSubsection { - protected override string Header => "General"; - - private CheckBoxOption keyOverlay, hiddenApproachCircle, scaleManiaScroll, rememberManiaScroll; + protected override string Header => "General"; - public GeneralGameplayOptions() + [Initializer] + private void Load(OsuConfigManager config) { Children = new Drawable[] { @@ -20,24 +20,27 @@ namespace osu.Game.Overlays.Options.Gameplay new SpriteText { Text = "Progress display: TODO dropdown" }, new SpriteText { Text = "Score meter type: TODO dropdown" }, new SpriteText { Text = "Score meter size: TODO slider" }, - keyOverlay = new CheckBoxOption { LabelText = "Always show key overlay" }, - hiddenApproachCircle = new CheckBoxOption { LabelText = "Show approach circle on first \"Hidden\" object" }, - scaleManiaScroll = new CheckBoxOption { LabelText = "Scale osu!mania scroll speed with BPM" }, - rememberManiaScroll = new CheckBoxOption { LabelText = "Remember osu!mania scroll speed per beatmap" }, + new CheckBoxOption + { + LabelText = "Always show key overlay", + Bindable = config.GetBindable(OsuConfig.KeyOverlay) + }, + new CheckBoxOption + { + LabelText = "Show approach circle on first \"Hidden\" object", + Bindable = config.GetBindable(OsuConfig.HiddenShowFirstApproach) + }, + new CheckBoxOption + { + LabelText = "Scale osu!mania scroll speed with BPM", + Bindable = config.GetBindable(OsuConfig.ManiaSpeedBPMScale) + }, + new CheckBoxOption + { + LabelText = "Remember osu!mania scroll speed per beatmap", + Bindable = config.GetBindable(OsuConfig.UsePerBeatmapManiaSpeed) + }, }; - } - - protected override void Load(BaseGame game) - { - base.Load(game); - var osuGame = game as OsuGameBase; - if (osuGame != null) - { - keyOverlay.Bindable = osuGame.Config.GetBindable(OsuConfig.KeyOverlay); - hiddenApproachCircle.Bindable = osuGame.Config.GetBindable(OsuConfig.HiddenShowFirstApproach); - scaleManiaScroll.Bindable = osuGame.Config.GetBindable(OsuConfig.ManiaSpeedBPMScale); - rememberManiaScroll.Bindable = osuGame.Config.GetBindable(OsuConfig.UsePerBeatmapManiaSpeed); - } } } } \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Graphics/DetailOptions.cs b/osu.Game/Overlays/Options/Graphics/DetailOptions.cs index 14878128e3..f672a353de 100644 --- a/osu.Game/Overlays/Options/Graphics/DetailOptions.cs +++ b/osu.Game/Overlays/Options/Graphics/DetailOptions.cs @@ -1,47 +1,58 @@ using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Game.Configuration; -namespace osu.Game.Overlays.Options.Graphics -{ - public class DetailOptions : OptionsSubsection - { +namespace osu.Game.Overlays.Options.Graphics +{ + public class DetailOptions : OptionsSubsection + { protected override string Header => "Detail Settings"; - private CheckBoxOption snakingSliders, backgroundVideo, storyboards, comboBursts, - hitLighting, shaders, softeningFilter; - - public DetailOptions() - { - Children = new Drawable[] - { - snakingSliders = new CheckBoxOption { LabelText = "Snaking sliders" }, - backgroundVideo = new CheckBoxOption { LabelText = "Background video" }, - storyboards = new CheckBoxOption { LabelText = "Storyboards" }, - comboBursts = new CheckBoxOption { LabelText = "Combo bursts" }, - hitLighting = new CheckBoxOption { LabelText = "Hit lighting" }, - shaders = new CheckBoxOption { LabelText = "Shaders" }, - softeningFilter = new CheckBoxOption { LabelText = "Softening filter" }, - new SpriteText { Text = "Screenshot format TODO: dropdown" } - }; - } - - protected override void Load(BaseGame game) + [Initializer] + private void Load(OsuConfigManager config) { - base.Load(game); - var osuGame = game as OsuGameBase; - if (osuGame != null) + Children = new Drawable[] { - snakingSliders.Bindable = osuGame.Config.GetBindable(OsuConfig.SnakingSliders); - backgroundVideo.Bindable = osuGame.Config.GetBindable(OsuConfig.Video); - storyboards.Bindable = osuGame.Config.GetBindable(OsuConfig.ShowStoryboard); - comboBursts.Bindable = osuGame.Config.GetBindable(OsuConfig.ComboBurst); - hitLighting.Bindable = osuGame.Config.GetBindable(OsuConfig.HitLighting); - shaders.Bindable = osuGame.Config.GetBindable(OsuConfig.Bloom); - softeningFilter.Bindable = osuGame.Config.GetBindable(OsuConfig.BloomSoftening); - } - } - } + new CheckBoxOption + { + LabelText = "Snaking sliders", + Bindable = config.GetBindable(OsuConfig.SnakingSliders) + }, + new CheckBoxOption + { + LabelText = "Background video", + Bindable = config.GetBindable(OsuConfig.Video) + }, + new CheckBoxOption + { + LabelText = "Storyboards", + Bindable = config.GetBindable(OsuConfig.ShowStoryboard) + }, + new CheckBoxOption + { + LabelText = "Combo bursts", + Bindable = config.GetBindable(OsuConfig.ComboBurst) + }, + new CheckBoxOption + { + LabelText = "Hit lighting", + Bindable = config.GetBindable(OsuConfig.HitLighting) + }, + new CheckBoxOption + { + LabelText = "Shaders", + Bindable = config.GetBindable(OsuConfig.Bloom) + }, + new CheckBoxOption + { + LabelText = "Softening filter", + Bindable = config.GetBindable(OsuConfig.BloomSoftening) + }, + new SpriteText { Text = "Screenshot format TODO: dropdown" } + }; + } + } } \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Graphics/LayoutOptions.cs b/osu.Game/Overlays/Options/Graphics/LayoutOptions.cs index 575d290286..3caf598a53 100644 --- a/osu.Game/Overlays/Options/Graphics/LayoutOptions.cs +++ b/osu.Game/Overlays/Options/Graphics/LayoutOptions.cs @@ -1,4 +1,5 @@ using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; @@ -10,31 +11,27 @@ namespace osu.Game.Overlays.Options.Graphics { protected override string Header => "Layout"; - private CheckBoxOption fullscreen, letterboxing; - - public LayoutOptions() - { - Children = new Drawable[] - { - new SpriteText { Text = "Resolution: TODO dropdown" }, - fullscreen = new CheckBoxOption { LabelText = "Fullscreen mode" }, - letterboxing = new CheckBoxOption { LabelText = "Letterboxing" }, - new SpriteText { Text = "Horizontal position" }, - new SpriteText { Text = "TODO: slider" }, - new SpriteText { Text = "Vertical position" }, - new SpriteText { Text = "TODO: slider" }, - }; - } - - protected override void Load(BaseGame game) + [Initializer] + private void Load(OsuConfigManager config) { - base.Load(game); - var osuGame = game as OsuGameBase; - if (osuGame != null) + Children = new Drawable[] { - fullscreen.Bindable = osuGame.Config.GetBindable(OsuConfig.Fullscreen); - letterboxing.Bindable = osuGame.Config.GetBindable(OsuConfig.Letterboxing); - } + new SpriteText { Text = "Resolution: TODO dropdown" }, + new CheckBoxOption + { + LabelText = "Fullscreen mode", + Bindable = config.GetBindable(OsuConfig.Fullscreen), + }, + new CheckBoxOption + { + LabelText = "Letterboxing", + Bindable = config.GetBindable(OsuConfig.Letterboxing), + }, + new SpriteText { Text = "Horizontal position" }, + new SpriteText { Text = "TODO: slider" }, + new SpriteText { Text = "Vertical position" }, + new SpriteText { Text = "TODO: slider" }, + }; } } } \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Graphics/MainMenuOptions.cs b/osu.Game/Overlays/Options/Graphics/MainMenuOptions.cs index 06429f1e61..0944ab401d 100644 --- a/osu.Game/Overlays/Options/Graphics/MainMenuOptions.cs +++ b/osu.Game/Overlays/Options/Graphics/MainMenuOptions.cs @@ -1,39 +1,45 @@ using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics.UserInterface; using osu.Game.Configuration; -namespace osu.Game.Overlays.Options.Graphics -{ - public class MainMenuOptions : OptionsSubsection - { +namespace osu.Game.Overlays.Options.Graphics +{ + public class MainMenuOptions : OptionsSubsection + { protected override string Header => "Main Menu"; - private CheckBoxOption snow, parallax, tips, voices, musicTheme; - - public MainMenuOptions() - { - Children = new[] - { - snow = new CheckBoxOption { LabelText = "Snow" }, - parallax = new CheckBoxOption { LabelText = "Parallax" }, - tips = new CheckBoxOption { LabelText = "Menu tips" }, - voices = new CheckBoxOption { LabelText = "Interface voices" }, - musicTheme = new CheckBoxOption { LabelText = "osu! music theme" }, - }; - } - - protected override void Load(BaseGame game) + [Initializer] + private void Load(OsuConfigManager config) { - base.Load(game); - var osuGame = game as OsuGameBase; - if (osuGame != null) + Children = new[] { - snow.Bindable = osuGame.Config.GetBindable(OsuConfig.MenuSnow); - parallax.Bindable = osuGame.Config.GetBindable(OsuConfig.MenuParallax); - tips.Bindable = osuGame.Config.GetBindable(OsuConfig.ShowMenuTips); - voices.Bindable = osuGame.Config.GetBindable(OsuConfig.MenuVoice); - musicTheme.Bindable = osuGame.Config.GetBindable(OsuConfig.MenuMusic); - } - } - } + new CheckBoxOption + { + LabelText = "Snow", + Bindable = config.GetBindable(OsuConfig.MenuSnow) + }, + new CheckBoxOption + { + LabelText = "Parallax", + Bindable = config.GetBindable(OsuConfig.MenuParallax) + }, + new CheckBoxOption + { + LabelText = "Menu tips", + Bindable = config.GetBindable(OsuConfig.ShowMenuTips) + }, + new CheckBoxOption + { + LabelText = "Interface voices", + Bindable = config.GetBindable(OsuConfig.MenuVoice) + }, + new CheckBoxOption + { + LabelText = "osu! music theme", + Bindable = config.GetBindable(OsuConfig.MenuMusic) + }, + }; + } + } } \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Graphics/RendererOptions.cs b/osu.Game/Overlays/Options/Graphics/RendererOptions.cs index 411bff4a81..ab3fd70d2a 100644 --- a/osu.Game/Overlays/Options/Graphics/RendererOptions.cs +++ b/osu.Game/Overlays/Options/Graphics/RendererOptions.cs @@ -1,4 +1,5 @@ using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; @@ -10,30 +11,29 @@ namespace osu.Game.Overlays.Options.Graphics { protected override string Header => "Renderer"; - private CheckBoxOption fpsCounter, reduceDroppedFrames, detectPerformanceIssues; - - public RendererOptions() - { - // NOTE: Compatability mode omitted - Children = new Drawable[] - { - new SpriteText { Text = "Frame limiter: TODO dropdown" }, - fpsCounter = new CheckBoxOption { LabelText = "Show FPS counter" }, - reduceDroppedFrames = new CheckBoxOption { LabelText = "Reduce dropped frames" }, - detectPerformanceIssues = new CheckBoxOption { LabelText = "Detect performance issues" }, - }; - } - - protected override void Load(BaseGame game) + [Initializer] + private void Load(OsuConfigManager config) { - base.Load(game); - var osuGame = game as OsuGameBase; - if (osuGame != null) + // NOTE: Compatability mode omitted + Children = new Drawable[] { - fpsCounter.Bindable = osuGame.Config.GetBindable(OsuConfig.FpsCounter); - reduceDroppedFrames.Bindable = osuGame.Config.GetBindable(OsuConfig.ForceFrameFlush); - detectPerformanceIssues.Bindable = osuGame.Config.GetBindable(OsuConfig.DetectPerformanceIssues); - } + new SpriteText { Text = "Frame limiter: TODO dropdown" }, + new CheckBoxOption + { + LabelText = "Show FPS counter", + Bindable = config.GetBindable(OsuConfig.FpsCounter), + }, + new CheckBoxOption + { + LabelText = "Reduce dropped frames", + Bindable = config.GetBindable(OsuConfig.ForceFrameFlush), + }, + new CheckBoxOption + { + LabelText = "Detect performance issues", + Bindable = config.GetBindable(OsuConfig.DetectPerformanceIssues), + }, + }; } } } \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Graphics/SongSelectGraphicsOptions.cs b/osu.Game/Overlays/Options/Graphics/SongSelectGraphicsOptions.cs index 044d9bfe96..76037a9d13 100644 --- a/osu.Game/Overlays/Options/Graphics/SongSelectGraphicsOptions.cs +++ b/osu.Game/Overlays/Options/Graphics/SongSelectGraphicsOptions.cs @@ -1,31 +1,25 @@ using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics.UserInterface; using osu.Game.Configuration; -namespace osu.Game.Overlays.Options.Graphics -{ - public class SongSelectGraphicsOptions : OptionsSubsection - { +namespace osu.Game.Overlays.Options.Graphics +{ + public class SongSelectGraphicsOptions : OptionsSubsection + { protected override string Header => "Song Select"; - - private CheckBoxOption showThumbs; - - public SongSelectGraphicsOptions() - { - Children = new[] - { - showThumbs = new CheckBoxOption { LabelText = "Show thumbnails" } - }; - } - protected override void Load(BaseGame game) + [Initializer] + private void Load(OsuConfigManager config) { - base.Load(game); - var osuGame = game as OsuGameBase; - if (osuGame != null) + Children = new[] { - showThumbs.Bindable = osuGame.Config.GetBindable(OsuConfig.SongSelectThumbnails); - } - } - } + new CheckBoxOption + { + LabelText = "Show thumbnails", + Bindable = config.GetBindable(OsuConfig.SongSelectThumbnails) + } + }; + } + } } \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Input/MouseOptions.cs b/osu.Game/Overlays/Options/Input/MouseOptions.cs index 419aecc675..960ef77af8 100644 --- a/osu.Game/Overlays/Options/Input/MouseOptions.cs +++ b/osu.Game/Overlays/Options/Input/MouseOptions.cs @@ -1,43 +1,55 @@ using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Game.Configuration; -namespace osu.Game.Overlays.Options.Input -{ - public class MouseOptions : OptionsSubsection - { +namespace osu.Game.Overlays.Options.Input +{ + public class MouseOptions : OptionsSubsection + { protected override string Header => "Mouse"; - private CheckBoxOption rawInput, mapRawInput, disableWheel, disableButtons, enableRipples; - - public MouseOptions() - { - Children = new Drawable[] - { - new SpriteText { Text = "Sensitivity: TODO slider" }, - rawInput = new CheckBoxOption { LabelText = "Raw input" }, - mapRawInput = new CheckBoxOption { LabelText = "Map absolute raw input to the osu! window" }, - new SpriteText { Text = "Confine mouse cursor: TODO dropdown" }, - disableWheel = new CheckBoxOption { LabelText = "Disable mouse wheel in play mode" }, - disableButtons = new CheckBoxOption { LabelText = "Disable mouse buttons in play mode" }, - enableRipples = new CheckBoxOption { LabelText = "Cursor ripples" }, - }; + private CheckBoxOption rawInput, mapRawInput, disableWheel, disableButtons, enableRipples; + + public MouseOptions() + { } - protected override void Load(BaseGame game) + [Initializer] + private void Load(OsuConfigManager config) { - base.Load(game); - var osuGame = game as OsuGameBase; - if (osuGame != null) + Children = new Drawable[] { - rawInput.Bindable = osuGame.Config.GetBindable(OsuConfig.RawInput); - mapRawInput.Bindable = osuGame.Config.GetBindable(OsuConfig.AbsoluteToOsuWindow); - disableWheel.Bindable = osuGame.Config.GetBindable(OsuConfig.MouseDisableWheel); - disableButtons.Bindable = osuGame.Config.GetBindable(OsuConfig.MouseDisableButtons); - enableRipples.Bindable = osuGame.Config.GetBindable(OsuConfig.CursorRipple); - } - } - } + new SpriteText { Text = "Sensitivity: TODO slider" }, + new CheckBoxOption + { + LabelText = "Raw input", + Bindable = config.GetBindable(OsuConfig.RawInput) + }, + new CheckBoxOption + { + LabelText = "Map absolute raw input to the osu! window", + Bindable = config.GetBindable(OsuConfig.AbsoluteToOsuWindow) + }, + new SpriteText { Text = "Confine mouse cursor: TODO dropdown" }, + new CheckBoxOption + { + LabelText = "Disable mouse wheel in play mode", + Bindable = config.GetBindable(OsuConfig.MouseDisableWheel) + }, + new CheckBoxOption + { + LabelText = "Disable mouse buttons in play mode", + Bindable = config.GetBindable(OsuConfig.MouseDisableButtons) + }, + new CheckBoxOption + { + LabelText = "Cursor ripples", + Bindable = config.GetBindable(OsuConfig.CursorRipple) + }, + }; + } + } } \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Input/OtherInputOptions.cs b/osu.Game/Overlays/Options/Input/OtherInputOptions.cs index a24009454b..64729f7e47 100644 --- a/osu.Game/Overlays/Options/Input/OtherInputOptions.cs +++ b/osu.Game/Overlays/Options/Input/OtherInputOptions.cs @@ -1,35 +1,32 @@ using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.UserInterface; using osu.Game.Configuration; -namespace osu.Game.Overlays.Options.Input -{ - public class OtherInputOptions : OptionsSubsection - { +namespace osu.Game.Overlays.Options.Input +{ + public class OtherInputOptions : OptionsSubsection + { protected override string Header => "Other"; - private CheckBoxOption tabletSupport, wiimoteSupport; - - public OtherInputOptions() - { - Children = new Drawable[] - { - tabletSupport = new CheckBoxOption { LabelText = "OS TabletPC support" }, - wiimoteSupport = new CheckBoxOption { LabelText = "Wiimote/TaTaCon Drum Support" }, - }; - } - - protected override void Load(BaseGame game) + [Initializer] + private void Load(OsuConfigManager config) { - base.Load(game); - var osuGame = game as OsuGameBase; - if (osuGame != null) + Children = new Drawable[] { - tabletSupport.Bindable = osuGame.Config.GetBindable(OsuConfig.Tablet); - wiimoteSupport.Bindable = osuGame.Config.GetBindable(OsuConfig.Wiimote); - } - } - } -} - + new CheckBoxOption + { + LabelText = "OS TabletPC support", + Bindable = config.GetBindable(OsuConfig.Tablet) + }, + new CheckBoxOption + { + LabelText = "Wiimote/TaTaCon Drum Support", + Bindable = config.GetBindable(OsuConfig.Wiimote) + }, + }; + } + } +} + diff --git a/osu.Game/Overlays/Options/Online/InGameChatOptions.cs b/osu.Game/Overlays/Options/Online/InGameChatOptions.cs index 29316b60fc..cca3843278 100644 --- a/osu.Game/Overlays/Options/Online/InGameChatOptions.cs +++ b/osu.Game/Overlays/Options/Online/InGameChatOptions.cs @@ -1,43 +1,46 @@ -using osu.Framework; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.UserInterface; -using osu.Game.Configuration; - +using osu.Framework; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Configuration; + namespace osu.Game.Overlays.Options.Online { public class InGameChatOptions : OptionsSubsection { - protected override string Header => "In-game Chat"; - - private CheckBoxOption filterWords, filterForeign, logPMs, blockPMs; + protected override string Header => "In-game Chat"; - public InGameChatOptions() + [Initializer] + private void Load(OsuConfigManager config) { Children = new Drawable[] { - filterWords = new CheckBoxOption { LabelText = "Filter offensive words" }, - filterForeign = new CheckBoxOption { LabelText = "Filter foreign characters" }, - logPMs = new CheckBoxOption { LabelText = "Log private messages" }, - blockPMs = new CheckBoxOption { LabelText = "Block private messages from non-friends" }, + new CheckBoxOption + { + LabelText = "Filter offensive words", + Bindable = config.GetBindable(OsuConfig.ChatFilter) + }, + new CheckBoxOption + { + LabelText = "Filter foreign characters", + Bindable = config.GetBindable(OsuConfig.ChatRemoveForeign) + }, + new CheckBoxOption + { + LabelText = "Log private messages", + Bindable = config.GetBindable(OsuConfig.LogPrivateMessages) + }, + new CheckBoxOption + { + LabelText = "Block private messages from non-friends", + Bindable = config.GetBindable(OsuConfig.BlockNonFriendPM) + }, new SpriteText { Text = "Chat ignore list (space-seperated list)" }, new TextBox { Height = 20, RelativeSizeAxes = Axes.X }, new SpriteText { Text = "Chat highlight words (space-seperated list)" }, new TextBox { Height = 20, RelativeSizeAxes = Axes.X }, }; - } - - protected override void Load(BaseGame game) - { - base.Load(game); - var osuGame = game as OsuGameBase; - if (osuGame != null) - { - filterWords.Bindable = osuGame.Config.GetBindable(OsuConfig.ChatFilter); - filterForeign.Bindable = osuGame.Config.GetBindable(OsuConfig.ChatRemoveForeign); - logPMs.Bindable = osuGame.Config.GetBindable(OsuConfig.LogPrivateMessages); - blockPMs.Bindable = osuGame.Config.GetBindable(OsuConfig.BlockNonFriendPM); - } } } } \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Online/NotificationsOptions.cs b/osu.Game/Overlays/Options/Online/NotificationsOptions.cs index 0520579f6e..6ed4aed016 100644 --- a/osu.Game/Overlays/Options/Online/NotificationsOptions.cs +++ b/osu.Game/Overlays/Options/Online/NotificationsOptions.cs @@ -1,4 +1,5 @@ using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.UserInterface; using osu.Game.Configuration; @@ -9,35 +10,42 @@ namespace osu.Game.Overlays.Options.Online { protected override string Header => "Notifications"; - private CheckBoxOption chatTicker, notifyMention, notifyChat, audibleNotification, - notificationsDuringGameplay, notifyFriendStatus; - - public NotificationsOptions() + [Initializer] + private void Load(OsuConfigManager config) { Children = new Drawable[] { - chatTicker = new CheckBoxOption { LabelText = "Enable chat ticker" }, - notifyMention = new CheckBoxOption { LabelText = "Show a notification popup when someone says your name" }, - notifyChat = new CheckBoxOption { LabelText = "Show chat message notifications" }, - audibleNotification = new CheckBoxOption { LabelText = "Play a sound when someone says your name" }, - notificationsDuringGameplay = new CheckBoxOption { LabelText = "Show notification popups instantly during gameplay" }, - notifyFriendStatus = new CheckBoxOption { LabelText = "Show notification popups when friends change status" }, + new CheckBoxOption + { + LabelText = "Enable chat ticker", + Bindable = config.GetBindable(OsuConfig.Ticker) + }, + new CheckBoxOption + { + LabelText = "Show a notification popup when someone says your name", + Bindable = config.GetBindable(OsuConfig.ChatHighlightName) + }, + new CheckBoxOption + { + LabelText = "Show chat message notifications", + Bindable = config.GetBindable(OsuConfig.ChatMessageNotification) + }, + new CheckBoxOption + { + LabelText = "Play a sound when someone says your name", + Bindable = config.GetBindable(OsuConfig.ChatAudibleHighlight) + }, + new CheckBoxOption + { + LabelText = "Show notification popups instantly during gameplay", + Bindable = config.GetBindable(OsuConfig.PopupDuringGameplay) + }, + new CheckBoxOption + { + LabelText = "Show notification popups when friends change status", + Bindable = config.GetBindable(OsuConfig.NotifyFriends) + }, }; } - - protected override void Load(BaseGame game) - { - base.Load(game); - var osuGame = game as OsuGameBase; - if (osuGame != null) - { - chatTicker.Bindable = osuGame.Config.GetBindable(OsuConfig.Ticker); - notifyMention.Bindable = osuGame.Config.GetBindable(OsuConfig.ChatHighlightName); - notifyChat.Bindable = osuGame.Config.GetBindable(OsuConfig.ChatMessageNotification); - audibleNotification.Bindable = osuGame.Config.GetBindable(OsuConfig.ChatAudibleHighlight); - notificationsDuringGameplay.Bindable = osuGame.Config.GetBindable(OsuConfig.PopupDuringGameplay); - notifyFriendStatus.Bindable = osuGame.Config.GetBindable(OsuConfig.NotifyFriends); - } - } } } \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Online/OnlineIntegrationOptions.cs b/osu.Game/Overlays/Options/Online/OnlineIntegrationOptions.cs index 4b50914b7e..46f93acd58 100644 --- a/osu.Game/Overlays/Options/Online/OnlineIntegrationOptions.cs +++ b/osu.Game/Overlays/Options/Online/OnlineIntegrationOptions.cs @@ -1,38 +1,41 @@ using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.UserInterface; using osu.Game.Configuration; -namespace osu.Game.Overlays.Options.Online -{ - public class OnlineIntegrationOptions : OptionsSubsection - { +namespace osu.Game.Overlays.Options.Online +{ + public class OnlineIntegrationOptions : OptionsSubsection + { protected override string Header => "Integration"; - private CheckBoxOption yahoo, msn, autoDirect, noVideo; - - public OnlineIntegrationOptions() - { - Children = new Drawable[] - { - yahoo = new CheckBoxOption { LabelText = "Integrate with Yahoo! status display" }, - msn = new CheckBoxOption { LabelText = "Integrate with MSN Live status display" }, - autoDirect = new CheckBoxOption { LabelText = "Automatically start osu!direct downloads" }, - noVideo = new CheckBoxOption { LabelText = "Prefer no-video downloads" }, - }; - } - - protected override void Load(BaseGame game) + [Initializer] + private void Load(OsuConfigManager config) { - base.Load(game); - var osuGame = game as OsuGameBase; - if (osuGame != null) + Children = new Drawable[] { - yahoo.Bindable = osuGame.Config.GetBindable(OsuConfig.YahooIntegration); - msn.Bindable = osuGame.Config.GetBindable(OsuConfig.MsnIntegration); - autoDirect.Bindable = osuGame.Config.GetBindable(OsuConfig.AutomaticDownload); - noVideo.Bindable = osuGame.Config.GetBindable(OsuConfig.AutomaticDownloadNoVideo); - } - } - } + new CheckBoxOption + { + LabelText = "Integrate with Yahoo! status display", + Bindable = config.GetBindable(OsuConfig.YahooIntegration) + }, + new CheckBoxOption + { + LabelText = "Integrate with MSN Live status display", + Bindable = config.GetBindable(OsuConfig.MsnIntegration) + }, + new CheckBoxOption + { + LabelText = "Automatically start osu!direct downloads", + Bindable = config.GetBindable(OsuConfig.AutomaticDownload) + }, + new CheckBoxOption + { + LabelText = "Prefer no-video downloads", + Bindable = config.GetBindable(OsuConfig.AutomaticDownloadNoVideo) + }, + }; + } + } } \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Online/PrivacyOptions.cs b/osu.Game/Overlays/Options/Online/PrivacyOptions.cs index 35880c5627..711272652b 100644 --- a/osu.Game/Overlays/Options/Online/PrivacyOptions.cs +++ b/osu.Game/Overlays/Options/Online/PrivacyOptions.cs @@ -1,4 +1,5 @@ using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.UserInterface; using osu.Game.Configuration; @@ -8,27 +9,23 @@ namespace osu.Game.Overlays.Options.Online public class PrivacyOptions : OptionsSubsection { protected override string Header => "Privacy"; - - private CheckBoxOption shareCity, allowInvites; - public PrivacyOptions() + [Initializer] + private void Load(OsuConfigManager config) { Children = new Drawable[] { - shareCity = new CheckBoxOption { LabelText = "Share your city location with others" }, - allowInvites = new CheckBoxOption { LabelText = "Allow multiplayer game invites from all users" }, + new CheckBoxOption + { + LabelText = "Share your city location with others", + Bindable = config.GetBindable(OsuConfig.DisplayCityLocation) + }, + new CheckBoxOption + { + LabelText = "Allow multiplayer game invites from all users", + Bindable = config.GetBindable(OsuConfig.AllowPublicInvites) + }, }; } - - protected override void Load(BaseGame game) - { - base.Load(game); - var osuGame = game as OsuGameBase; - if (osuGame != null) - { - shareCity.Bindable = osuGame.Config.GetBindable(OsuConfig.DisplayCityLocation); - allowInvites.Bindable = osuGame.Config.GetBindable(OsuConfig.AllowPublicInvites); - } - } } } \ No newline at end of file diff --git a/osu.Game/Overlays/Options/SkinSection.cs b/osu.Game/Overlays/Options/SkinSection.cs index 12f55aafd1..7475ec9e5f 100644 --- a/osu.Game/Overlays/Options/SkinSection.cs +++ b/osu.Game/Overlays/Options/SkinSection.cs @@ -1,22 +1,22 @@ -using OpenTK; -using osu.Framework; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.UserInterface; -using osu.Game.Configuration; -using osu.Game.Graphics; -using osu.Game.Graphics.UserInterface; - +using OpenTK; +using osu.Framework; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Configuration; +using osu.Game.Graphics; +using osu.Game.Graphics.UserInterface; + namespace osu.Game.Overlays.Options { public class SkinSection : OptionsSection { protected override string Header => "Skin"; - public override FontAwesome Icon => FontAwesome.fa_paint_brush; - - private CheckBoxOption ignoreSkins, useSkinSoundSamples, useTaikoSkin, useSkinCursor, autoCursorSize; - - public SkinSection() + public override FontAwesome Icon => FontAwesome.fa_paint_brush; + + [Initializer] + private void Load(OsuConfigManager config) { content.Spacing = new Vector2(0, 5); Children = new Drawable[] @@ -38,27 +38,33 @@ namespace osu.Game.Overlays.Options RelativeSizeAxes = Axes.X, Text = "Export as .osk", }, - ignoreSkins = new CheckBoxOption { LabelText = "Ignore all beatmap skins" }, - useSkinSoundSamples = new CheckBoxOption { LabelText = "Use skin's sound samples" }, - useTaikoSkin = new CheckBoxOption { LabelText = "Use Taiko skin for Taiko mode" }, - useSkinCursor = new CheckBoxOption { LabelText = "Always use skin cursor" }, + new CheckBoxOption + { + LabelText = "Ignore all beatmap skins", + Bindable = config.GetBindable(OsuConfig.IgnoreBeatmapSkins) + }, + new CheckBoxOption + { + LabelText = "Use skin's sound samples", + Bindable = config.GetBindable(OsuConfig.SkinSamples) + }, + new CheckBoxOption + { + LabelText = "Use Taiko skin for Taiko mode", + Bindable = config.GetBindable(OsuConfig.UseTaikoSkin) + }, + new CheckBoxOption + { + LabelText = "Always use skin cursor", + Bindable = config.GetBindable(OsuConfig.UseSkinCursor) + }, new SpriteText { Text = "Cursor size: TODO slider" }, - autoCursorSize = new CheckBoxOption { LabelText = "Automatic cursor size" }, + new CheckBoxOption + { + LabelText = "Automatic cursor size", + Bindable = config.GetBindable(OsuConfig.AutomaticCursorSizing) + }, }; - } - - protected override void Load(BaseGame game) - { - base.Load(game); - var osuGame = game as OsuGameBase; - if (osuGame != null) - { - ignoreSkins.Bindable = osuGame.Config.GetBindable(OsuConfig.IgnoreBeatmapSkins); - useSkinSoundSamples.Bindable = osuGame.Config.GetBindable(OsuConfig.SkinSamples); - useTaikoSkin.Bindable = osuGame.Config.GetBindable(OsuConfig.UseTaikoSkin); - useSkinCursor.Bindable = osuGame.Config.GetBindable(OsuConfig.UseSkinCursor); - autoCursorSize.Bindable = osuGame.Config.GetBindable(OsuConfig.AutomaticCursorSizing); - } } } } \ No newline at end of file From a81f099d403258f494e7e30fe91ecab948916022 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 10 Nov 2016 18:15:30 -0500 Subject: [PATCH 08/19] Add TextBoxOption and wire it up --- .../Options/Online/InGameChatOptions.cs | 9 ++-- osu.Game/Overlays/Options/TextBoxOption.cs | 49 +++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 osu.Game/Overlays/Options/TextBoxOption.cs diff --git a/osu.Game/Overlays/Options/Online/InGameChatOptions.cs b/osu.Game/Overlays/Options/Online/InGameChatOptions.cs index 29316b60fc..ac459f2910 100644 --- a/osu.Game/Overlays/Options/Online/InGameChatOptions.cs +++ b/osu.Game/Overlays/Options/Online/InGameChatOptions.cs @@ -10,7 +10,8 @@ namespace osu.Game.Overlays.Options.Online { protected override string Header => "In-game Chat"; - private CheckBoxOption filterWords, filterForeign, logPMs, blockPMs; + private CheckBoxOption filterWords, filterForeign, logPMs, blockPMs; + private TextBoxOption chatIgnoreList, chatHighlightWords; public InGameChatOptions() { @@ -21,9 +22,9 @@ namespace osu.Game.Overlays.Options.Online logPMs = new CheckBoxOption { LabelText = "Log private messages" }, blockPMs = new CheckBoxOption { LabelText = "Block private messages from non-friends" }, new SpriteText { Text = "Chat ignore list (space-seperated list)" }, - new TextBox { Height = 20, RelativeSizeAxes = Axes.X }, + chatIgnoreList = new TextBoxOption { Height = 20, RelativeSizeAxes = Axes.X }, new SpriteText { Text = "Chat highlight words (space-seperated list)" }, - new TextBox { Height = 20, RelativeSizeAxes = Axes.X }, + chatHighlightWords = new TextBoxOption { Height = 20, RelativeSizeAxes = Axes.X }, }; } @@ -37,6 +38,8 @@ namespace osu.Game.Overlays.Options.Online filterForeign.Bindable = osuGame.Config.GetBindable(OsuConfig.ChatRemoveForeign); logPMs.Bindable = osuGame.Config.GetBindable(OsuConfig.LogPrivateMessages); blockPMs.Bindable = osuGame.Config.GetBindable(OsuConfig.BlockNonFriendPM); + chatIgnoreList.Bindable = osuGame.Config.GetBindable(OsuConfig.IgnoreList); + chatHighlightWords.Bindable = osuGame.Config.GetBindable(OsuConfig.HighlightWords); } } } diff --git a/osu.Game/Overlays/Options/TextBoxOption.cs b/osu.Game/Overlays/Options/TextBoxOption.cs new file mode 100644 index 0000000000..91ec251bac --- /dev/null +++ b/osu.Game/Overlays/Options/TextBoxOption.cs @@ -0,0 +1,49 @@ +using System; +using osu.Framework.Configuration; +using osu.Framework.Graphics.UserInterface; + +namespace osu.Game.Overlays.Options +{ + public class TextBoxOption : TextBox + { + private Bindable bindable; + + public Bindable Bindable + { + set + { + if (bindable != null) + bindable.ValueChanged -= bindableValueChanged; + bindable = value; + if (bindable != null) + { + base.Text = bindable.Value; + bindable.ValueChanged += bindableValueChanged; + } + } + } + + protected override string internalText + { + get { return base.internalText; } + set + { + base.internalText = value; + if (bindable != null) + bindable.Value = value; + } + } + + private void bindableValueChanged(object sender, EventArgs e) + { + Text = bindable.Value; + } + + protected override void Dispose(bool isDisposing) + { + if (bindable != null) + bindable.ValueChanged -= bindableValueChanged; + base.Dispose(isDisposing); + } + } +} \ No newline at end of file diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 3b5ea8de73..4a1b903d08 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -232,6 +232,7 @@ + From e2365cfad283b192a77b6cbaa51420945b1ed7ee Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 10 Nov 2016 18:25:20 -0500 Subject: [PATCH 09/19] s/internalText/InternalText/g --- osu.Game/Overlays/Options/TextBoxOption.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Options/TextBoxOption.cs b/osu.Game/Overlays/Options/TextBoxOption.cs index 91ec251bac..ffd9c86b71 100644 --- a/osu.Game/Overlays/Options/TextBoxOption.cs +++ b/osu.Game/Overlays/Options/TextBoxOption.cs @@ -23,12 +23,12 @@ namespace osu.Game.Overlays.Options } } - protected override string internalText + protected override string InternalText { - get { return base.internalText; } + get { return base.InternalText; } set { - base.internalText = value; + base.InternalText = value; if (bindable != null) bindable.Value = value; } From d49b418449301b90ff4c6effd6a1039c7e83dfe1 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 10 Nov 2016 21:35:58 -0500 Subject: [PATCH 10/19] Implement ShowUnicode option behavior --- .../Beatmaps/Drawable/BeatmapSetHeader.cs | 43 ++++++++++++++++--- osu.Game/Configuration/OsuConfigManager.cs | 3 ++ osu.Game/Overlays/MusicController.cs | 26 +++++++++-- 3 files changed, 63 insertions(+), 9 deletions(-) diff --git a/osu.Game/Beatmaps/Drawable/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawable/BeatmapSetHeader.cs index f8a38931e2..59995d669c 100644 --- a/osu.Game/Beatmaps/Drawable/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawable/BeatmapSetHeader.cs @@ -10,12 +10,19 @@ using osu.Game.Database; using osu.Game.Graphics; using OpenTK; using OpenTK.Graphics; +using osu.Framework; +using osu.Framework.Configuration; +using osu.Game.Configuration; namespace osu.Game.Beatmaps.Drawable { class BeatmapSetHeader : Panel { - public Action GainedSelection; + public Action GainedSelection; + private BeatmapSetInfo beatmapSet; + private SpriteText title, artist; + private OsuConfigManager config; + private Bindable preferUnicode; protected override void Selected() { @@ -30,9 +37,35 @@ namespace osu.Game.Beatmaps.Drawable base.Deselected(); Width = 0.8f; } + + protected override void Load(BaseGame game) + { + base.Load(game); + var osuGame = game as OsuGameBase; + if (osuGame != null) + { + config = osuGame.Config; + preferUnicode = osuGame.Config.GetBindable(OsuConfig.ShowUnicode); + preferUnicode.ValueChanged += preferUnicode_changed; + preferUnicode_changed(preferUnicode, null); + } + } + private void preferUnicode_changed(object sender, EventArgs e) + { + title.Text = config.GetUnicodeString(beatmapSet.Metadata.Title, beatmapSet.Metadata.TitleUnicode); + artist.Text = config.GetUnicodeString(beatmapSet.Metadata.Artist, beatmapSet.Metadata.ArtistUnicode); + } + + protected override void Dispose(bool isDisposing) + { + if (preferUnicode != null) + preferUnicode.ValueChanged -= preferUnicode_changed; + base.Dispose(isDisposing); + } public BeatmapSetHeader(BeatmapSetInfo beatmapSet, WorkingBeatmap working) { + this.beatmapSet = beatmapSet; Children = new Framework.Graphics.Drawable[] { working.Background == null ? new Box{ RelativeSizeAxes = Axes.Both, Colour = new Color4(20, 20, 20, 255) } : new Sprite @@ -51,16 +84,16 @@ namespace osu.Game.Beatmaps.Drawable AutoSizeAxes = Axes.Both, Children = new[] { - new SpriteText + title = new SpriteText { Font = @"Exo2.0-SemiBoldItalic", - Text = beatmapSet.Metadata.Title ?? beatmapSet.Metadata.TitleUnicode, + Text = beatmapSet.Metadata.Title, TextSize = 22 }, - new SpriteText + artist = new SpriteText { Font = @"Exo2.0-MediumItalic", - Text = beatmapSet.Metadata.Artist ?? beatmapSet.Metadata.ArtistUnicode, + Text = beatmapSet.Metadata.Artist, TextSize = 16 }, new FlowContainer diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 6c05603285..c828f2eb40 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -178,6 +178,9 @@ namespace osu.Game.Configuration Set(OsuConfig.CompatibilityContext, false); Set(OsuConfig.CanForceOptimusCompatibility, true); } + + public string GetUnicodeString(string nonunicode, string unicode) + => Get(OsuConfig.ShowUnicode) ? unicode ?? nonunicode : nonunicode ?? unicode; public OsuConfigManager(BasicStorage storage) : base(storage) { diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 310bae37e4..d7f2bfc546 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -17,6 +17,7 @@ using osu.Framework.Graphics.Transformations; using osu.Framework.Input; using osu.Framework.MathUtils; using osu.Game.Beatmaps; +using osu.Game.Configuration; using osu.Game.Database; using osu.Game.Graphics; @@ -38,6 +39,8 @@ namespace osu.Game.Overlays private TrackManager trackManager; private BeatmapDatabase database; private Bindable beatmapSource; + private Bindable preferUnicode; + private OsuConfigManager config; private WorkingBeatmap current; public MusicController(BeatmapDatabase db = null) @@ -183,6 +186,9 @@ namespace osu.Game.Overlays { if (database == null) database = osuGame.Beatmaps; trackManager = osuGame.Audio.Track; + config = osuGame.Config; + preferUnicode = osuGame.Config.GetBindable(OsuConfig.ShowUnicode); + preferUnicode.ValueChanged += preferUnicode_changed; } beatmapSource = osuGame?.Beatmap ?? new Bindable(); @@ -191,7 +197,7 @@ namespace osu.Game.Overlays backgroundSprite = getScaledSprite(fallbackTexture = game.Textures.Get(@"Backgrounds/bg4")); AddInternal(backgroundSprite); } - + protected override void LoadComplete() { beatmapSource.ValueChanged += workingChanged; @@ -210,6 +216,11 @@ namespace osu.Game.Overlays if (current.Track.HasCompleted && !current.Track.Looping) next(); } + void preferUnicode_changed(object sender, EventArgs e) + { + updateDisplay(current, false); + } + private void workingChanged(object sender = null, EventArgs e = null) { if (beatmapSource.Value == current) return; @@ -281,9 +292,9 @@ namespace osu.Game.Overlays private void updateDisplay(WorkingBeatmap beatmap, bool? isNext) { - BeatmapMetadata metadata = beatmap.Beatmap.Metadata; - title.Text = metadata.TitleUnicode ?? metadata.Title; - artist.Text = metadata.ArtistUnicode ?? metadata.Artist; + BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; + title.Text = config.GetUnicodeString(metadata.Title, metadata.TitleUnicode); + artist.Text = config.GetUnicodeString(metadata.Artist, metadata.ArtistUnicode); Sprite newBackground = getScaledSprite(beatmap.Background ?? fallbackTexture); @@ -324,6 +335,13 @@ namespace osu.Game.Overlays current?.Track?.Seek(current.Track.Length * position); current?.Track?.Start(); } + + protected override void Dispose(bool isDisposing) + { + if (preferUnicode != null) + preferUnicode.ValueChanged -= preferUnicode_changed; + base.Dispose(isDisposing); + } protected override bool OnClick(InputState state) => true; From d36c8e9203a0711136f5ce24e22a51aef7d1111a Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 10 Nov 2016 21:54:01 -0500 Subject: [PATCH 11/19] Remove certain options when not running on Windows --- osu.Game/Overlays/Options/Audio/AudioSection.cs | 5 +++-- osu.Game/Overlays/Options/Input/MouseOptions.cs | 12 ++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Options/Audio/AudioSection.cs b/osu.Game/Overlays/Options/Audio/AudioSection.cs index af72974a10..417300abcc 100644 --- a/osu.Game/Overlays/Options/Audio/AudioSection.cs +++ b/osu.Game/Overlays/Options/Audio/AudioSection.cs @@ -1,4 +1,5 @@ -using osu.Framework.Graphics; +using osu.Framework; +using osu.Framework.Graphics; using osu.Game.Graphics; namespace osu.Game.Overlays.Options.Audio @@ -12,7 +13,7 @@ namespace osu.Game.Overlays.Options.Audio { Children = new Drawable[] { - new AudioDevicesOptions(), + new AudioDevicesOptions { Alpha = RuntimeInfo.IsWindows ? 1 : 0 }, new VolumeOptions(), new OffsetAdjustmentOptions(), }; diff --git a/osu.Game/Overlays/Options/Input/MouseOptions.cs b/osu.Game/Overlays/Options/Input/MouseOptions.cs index 419aecc675..c15aff0b90 100644 --- a/osu.Game/Overlays/Options/Input/MouseOptions.cs +++ b/osu.Game/Overlays/Options/Input/MouseOptions.cs @@ -17,8 +17,16 @@ namespace osu.Game.Overlays.Options.Input Children = new Drawable[] { new SpriteText { Text = "Sensitivity: TODO slider" }, - rawInput = new CheckBoxOption { LabelText = "Raw input" }, - mapRawInput = new CheckBoxOption { LabelText = "Map absolute raw input to the osu! window" }, + rawInput = new CheckBoxOption + { + LabelText = "Raw input", + Alpha = RuntimeInfo.IsWindows ? 1 : 0 + }, + mapRawInput = new CheckBoxOption + { + LabelText = "Map absolute raw input to the osu! window", + Alpha = RuntimeInfo.IsWindows ? 1 : 0 + }, new SpriteText { Text = "Confine mouse cursor: TODO dropdown" }, disableWheel = new CheckBoxOption { LabelText = "Disable mouse wheel in play mode" }, disableButtons = new CheckBoxOption { LabelText = "Disable mouse buttons in play mode" }, From e535681bb5c5121e31c7c974869784074bda816e Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 11 Nov 2016 00:21:59 -0500 Subject: [PATCH 12/19] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 25b8c3c6cf..ef57b64639 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 25b8c3c6cfead49acf5659a750c7e604289d5b81 +Subproject commit ef57b64639f53326104707d40536de24226dd63f From b65eb337741d1b0955e99e850389bf126de29901 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 12 Nov 2016 16:44:02 +0900 Subject: [PATCH 13/19] Fix weird artifacting when the MusicController fades in and out by using a buffered container. --- osu.Game/Overlays/MusicController.cs | 69 ++++++++++++++++------------ 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index d7f2bfc546..9885c0cb48 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -25,7 +25,7 @@ namespace osu.Game.Overlays { public class MusicController : OverlayContainer { - private Sprite backgroundSprite; + private MusicControllerBackground backgroundSprite; private DragBar progress; private TextAwesome playButton, listButton; private SpriteText title, artist; @@ -55,11 +55,6 @@ namespace osu.Game.Overlays Position = new Vector2(10, 60); Children = new Drawable[] { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = new Color4(0, 0, 0, 127) - }, title = new SpriteText { Origin = Anchor.BottomCentre, @@ -80,14 +75,6 @@ namespace osu.Game.Overlays Text = @"Nothing to play", Font = @"Exo2.0-BoldItalic" }, - new Box - { - RelativeSizeAxes = Axes.X, - Height = 50, - Origin = Anchor.BottomCentre, - Anchor = Anchor.BottomCentre, - Colour = new Color4(0, 0, 0, 127) - }, new ClickableContainer { AutoSizeAxes = Axes.Both, @@ -194,7 +181,7 @@ namespace osu.Game.Overlays beatmapSource = osuGame?.Beatmap ?? new Bindable(); playList = database.GetAllWithChildren(); - backgroundSprite = getScaledSprite(fallbackTexture = game.Textures.Get(@"Backgrounds/bg4")); + backgroundSprite = new MusicControllerBackground(fallbackTexture = game.Textures.Get(@"Backgrounds/bg4")); AddInternal(backgroundSprite); } @@ -296,7 +283,7 @@ namespace osu.Game.Overlays title.Text = config.GetUnicodeString(metadata.Title, metadata.TitleUnicode); artist.Text = config.GetUnicodeString(metadata.Artist, metadata.ArtistUnicode); - Sprite newBackground = getScaledSprite(beatmap.Background ?? fallbackTexture); + MusicControllerBackground newBackground = new MusicControllerBackground(beatmap.Background ?? fallbackTexture); Add(newBackground); @@ -317,25 +304,12 @@ namespace osu.Game.Overlays backgroundSprite = newBackground; } - private Sprite getScaledSprite(Texture background) - { - Sprite scaledSprite = new Sprite - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Texture = background, - Depth = float.MinValue - }; - scaledSprite.Scale = new Vector2(Math.Max(DrawSize.X / scaledSprite.DrawSize.X, DrawSize.Y / scaledSprite.DrawSize.Y)); - return scaledSprite; - } - private void seek(float position) { current?.Track?.Seek(current.Track.Length * position); current?.Track?.Start(); } - + protected override void Dispose(bool isDisposing) { if (preferUnicode != null) @@ -353,5 +327,40 @@ namespace osu.Game.Overlays protected override void PopIn() => FadeIn(100); protected override void PopOut() => FadeOut(100); + + private class MusicControllerBackground : BufferedContainer + { + private Sprite sprite; + + public MusicControllerBackground(Texture backgroundTexture) + { + CacheDrawnFrameBuffer = true; + RelativeSizeAxes = Axes.Both; + Depth = float.MinValue; + + Children = new Drawable[] + { + sprite = new Sprite + { + Texture = backgroundTexture, + Colour = new Color4(150, 150, 150, 255) + }, + new Box + { + RelativeSizeAxes = Axes.X, + Height = 50, + Origin = Anchor.BottomCentre, + Anchor = Anchor.BottomCentre, + Colour = new Color4(0, 0, 0, 127) + } + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + sprite.Scale = new Vector2(Math.Max(DrawSize.X / sprite.DrawSize.X, DrawSize.Y / sprite.DrawSize.Y)); + } + } } } From 3b99a8fd066d0d907f7eedd96ca41c53432eae32 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 12 Nov 2016 17:09:58 +0900 Subject: [PATCH 14/19] Add a shadow and bit of elasticity to MusicController. --- osu.Game/Overlays/MusicController.cs | 32 +++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 9885c0cb48..9ac6ace0ea 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -25,6 +25,8 @@ namespace osu.Game.Overlays { public class MusicController : OverlayContainer { + private static readonly Vector2 start_position = new Vector2(10, 60); + private MusicControllerBackground backgroundSprite; private DragBar progress; private TextAwesome playButton, listButton; @@ -49,10 +51,17 @@ namespace osu.Game.Overlays Width = 400; Height = 130; CornerRadius = 5; + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Colour = new Color4(0, 0, 0, 40), + Radius = 5, + }; + Masking = true; Anchor = Anchor.TopRight;//placeholder Origin = Anchor.TopRight; - Position = new Vector2(10, 60); + Position = start_position; Children = new Drawable[] { title = new SpriteText @@ -164,6 +173,25 @@ namespace osu.Game.Overlays }; } + protected override bool OnDragStart(InputState state) => true; + + protected override bool OnDrag(InputState state) + { + Vector2 change = (state.Mouse.Position - state.Mouse.PositionMouseDown.Value); + change.X = -change.X; + + change *= (float)Math.Pow(change.Length, 0.7f) / change.Length; + + MoveTo(start_position + change); + return base.OnDrag(state); + } + + protected override bool OnDragEnd(InputState state) + { + MoveTo(start_position, 800, EasingTypes.OutElastic); + return base.OnDragEnd(state); + } + protected override void Load(BaseGame game) { base.Load(game); @@ -321,8 +349,6 @@ namespace osu.Game.Overlays protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; - protected override bool OnDragStart(InputState state) => true; - //placeholder for toggling protected override void PopIn() => FadeIn(100); From 18c0e431c14c7d2a89885d9102a913dcc20adaed Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 9 Nov 2016 15:49:31 +0900 Subject: [PATCH 15/19] Fix some nullrefs. --- osu.Game/Beatmaps/WorkingBeatmap.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 63a33c700e..f2f4a39d91 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -18,7 +18,7 @@ namespace osu.Game.Beatmaps public readonly BeatmapSetInfo BeatmapSetInfo; private readonly BeatmapDatabase database; - private ArchiveReader reader => database.GetReader(BeatmapSetInfo); + private ArchiveReader reader => database?.GetReader(BeatmapSetInfo); private Texture background; private object backgroundLock = new object(); @@ -77,7 +77,7 @@ namespace osu.Game.Beatmaps try { - var trackData = reader.GetStream(BeatmapInfo.Metadata.AudioFile); + var trackData = reader?.GetStream(BeatmapInfo.Metadata.AudioFile); if (trackData != null) track = new AudioTrackBass(trackData); } From 16a0be44df73b7afe69b54e04e9f9f19b3787c3e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 9 Nov 2016 18:50:30 +0900 Subject: [PATCH 16/19] Add local InputManager to Player; handle Z and X. --- osu.Game/GameModes/Play/Player.cs | 49 ++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/osu.Game/GameModes/Play/Player.cs b/osu.Game/GameModes/Play/Player.cs index fecb076e63..145cbd220c 100644 --- a/osu.Game/GameModes/Play/Player.cs +++ b/osu.Game/GameModes/Play/Player.cs @@ -13,6 +13,14 @@ using osu.Game.Database; using osu.Framework.Timing; using osu.Framework.Audio.Track; using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Input; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Platform; +using OpenTK.Input; +using MouseState = osu.Framework.Input.MouseState; +using osu.Framework.Graphics.Primitives; namespace osu.Game.GameModes.Play { @@ -26,6 +34,38 @@ namespace osu.Game.GameModes.Play public BeatmapInfo BeatmapInfo; + PlayerInputManager inputManager; + + class PlayerInputManager : UserInputManager + { + public PlayerInputManager(BasicGameHost host) + : base(host) + { + } + + protected override void UpdateMouseState(InputState state) + { + base.UpdateMouseState(state); + + MouseState mouse = (MouseState)state.Mouse; + + foreach (Key k in state.Keyboard.Keys) + { + switch (k) + { + case Key.Z: + mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = true; + break; + case Key.X: + mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = true; + break; + } + } + + } + } + + public PlayMode PreferredPlayMode; protected override IFrameBasedClock Clock => playerClock; @@ -132,7 +172,14 @@ namespace osu.Game.GameModes.Play Children = new Drawable[] { - hitRenderer, + inputManager = new PlayerInputManager(game.Host) + { + PassThrough = false, + Children = new Drawable[] + { + hitRenderer, + } + }, scoreOverlay, }; } From 099b30964505254a81d675024f057c1e52b3ea69 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 9 Nov 2016 19:49:05 +0900 Subject: [PATCH 17/19] Introduce back the concept of Rulesets. --- osu.Game/GameModes/Play/Catch/CatchRuleset.cs | 20 ++++++++ osu.Game/GameModes/Play/Mania/ManiaRuleset.cs | 20 ++++++++ osu.Game/GameModes/Play/Osu/OsuRuleset.cs | 18 +++++++ osu.Game/GameModes/Play/Player.cs | 47 ++----------------- osu.Game/GameModes/Play/Ruleset.cs | 38 +++++++++++++++ osu.Game/GameModes/Play/Taiko/TaikoRuleset.cs | 20 ++++++++ osu.Game/osu.Game.csproj | 5 ++ 7 files changed, 125 insertions(+), 43 deletions(-) create mode 100644 osu.Game/GameModes/Play/Catch/CatchRuleset.cs create mode 100644 osu.Game/GameModes/Play/Mania/ManiaRuleset.cs create mode 100644 osu.Game/GameModes/Play/Osu/OsuRuleset.cs create mode 100644 osu.Game/GameModes/Play/Ruleset.cs create mode 100644 osu.Game/GameModes/Play/Taiko/TaikoRuleset.cs diff --git a/osu.Game/GameModes/Play/Catch/CatchRuleset.cs b/osu.Game/GameModes/Play/Catch/CatchRuleset.cs new file mode 100644 index 0000000000..5aa77f1f2e --- /dev/null +++ b/osu.Game/GameModes/Play/Catch/CatchRuleset.cs @@ -0,0 +1,20 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Game.Beatmaps.Objects; +using osu.Game.GameModes.Play.Osu; + +namespace osu.Game.GameModes.Play.Catch +{ + class CatchRuleset : Ruleset + { + public override ScoreOverlay CreateScoreOverlay() => new ScoreOverlayOsu(); + + public override HitRenderer CreateHitRendererWith(List objects) => new CatchHitRenderer { Objects = objects }; + } +} diff --git a/osu.Game/GameModes/Play/Mania/ManiaRuleset.cs b/osu.Game/GameModes/Play/Mania/ManiaRuleset.cs new file mode 100644 index 0000000000..3b37082c39 --- /dev/null +++ b/osu.Game/GameModes/Play/Mania/ManiaRuleset.cs @@ -0,0 +1,20 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Game.Beatmaps.Objects; +using osu.Game.GameModes.Play.Osu; + +namespace osu.Game.GameModes.Play.Mania +{ + class ManiaRuleset : Ruleset + { + public override ScoreOverlay CreateScoreOverlay() => new ScoreOverlayOsu(); + + public override HitRenderer CreateHitRendererWith(List objects) => new ManiaHitRenderer { Objects = objects }; + } +} diff --git a/osu.Game/GameModes/Play/Osu/OsuRuleset.cs b/osu.Game/GameModes/Play/Osu/OsuRuleset.cs new file mode 100644 index 0000000000..33eeb72e3f --- /dev/null +++ b/osu.Game/GameModes/Play/Osu/OsuRuleset.cs @@ -0,0 +1,18 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Game.Beatmaps.Objects; + +namespace osu.Game.GameModes.Play.Osu +{ + class OsuRuleset : Ruleset + { + public override ScoreOverlay CreateScoreOverlay() => new ScoreOverlayOsu(); + + public override HitRenderer CreateHitRendererWith(List objects) => new OsuHitRenderer { Objects = objects }; + }} diff --git a/osu.Game/GameModes/Play/Player.cs b/osu.Game/GameModes/Play/Player.cs index 145cbd220c..a0e419acea 100644 --- a/osu.Game/GameModes/Play/Player.cs +++ b/osu.Game/GameModes/Play/Player.cs @@ -15,8 +15,6 @@ using osu.Framework.Audio.Track; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics.Cursor; using osu.Framework.Input; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Cursor; using osu.Framework.Platform; using OpenTK.Input; using MouseState = osu.Framework.Input.MouseState; @@ -72,6 +70,7 @@ namespace osu.Game.GameModes.Play private InterpolatingFramedClock playerClock; private IAdjustableClock sourceClock; + private Ruleset Ruleset; protected override void Load(BaseGame game) { @@ -120,49 +119,11 @@ namespace osu.Game.GameModes.Play PlayMode usablePlayMode = beatmap.BeatmapInfo?.Mode > PlayMode.Osu ? beatmap.BeatmapInfo.Mode : PreferredPlayMode; - switch (usablePlayMode) - { - default: - scoreOverlay = new ScoreOverlayOsu(); + Ruleset = Ruleset.GetRuleset(usablePlayMode); - hitRenderer = new OsuHitRenderer - { - Objects = beatmap.HitObjects, - Anchor = Anchor.Centre, - Origin = Anchor.Centre - }; - break; - case PlayMode.Taiko: - scoreOverlay = new ScoreOverlayOsu(); + scoreOverlay = Ruleset.CreateScoreOverlay(); - hitRenderer = new TaikoHitRenderer - { - Objects = beatmap.HitObjects, - Anchor = Anchor.Centre, - Origin = Anchor.Centre - }; - break; - case PlayMode.Catch: - scoreOverlay = new ScoreOverlayOsu(); - - hitRenderer = new CatchHitRenderer - { - Objects = beatmap.HitObjects, - Anchor = Anchor.Centre, - Origin = Anchor.Centre - }; - break; - case PlayMode.Mania: - scoreOverlay = new ScoreOverlayOsu(); - - hitRenderer = new ManiaHitRenderer - { - Objects = beatmap.HitObjects, - Anchor = Anchor.Centre, - Origin = Anchor.Centre - }; - break; - } + hitRenderer = Ruleset.CreateHitRendererWith(beatmap.HitObjects); hitRenderer.OnHit += delegate (HitObject h) { scoreOverlay.OnHit(h); }; hitRenderer.OnMiss += delegate (HitObject h) { scoreOverlay.OnMiss(h); }; diff --git a/osu.Game/GameModes/Play/Ruleset.cs b/osu.Game/GameModes/Play/Ruleset.cs new file mode 100644 index 0000000000..a5cbc63269 --- /dev/null +++ b/osu.Game/GameModes/Play/Ruleset.cs @@ -0,0 +1,38 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Game.Beatmaps.Objects; +using osu.Game.GameModes.Play.Catch; +using osu.Game.GameModes.Play.Mania; +using osu.Game.GameModes.Play.Osu; +using osu.Game.GameModes.Play.Taiko; + +namespace osu.Game.GameModes.Play +{ + public abstract class Ruleset + { + public abstract ScoreOverlay CreateScoreOverlay(); + + public abstract HitRenderer CreateHitRendererWith(List objects); + + public static Ruleset GetRuleset(PlayMode mode) + { + switch (mode) + { + default: + return new OsuRuleset(); + case PlayMode.Catch: + return new CatchRuleset(); + case PlayMode.Mania: + return new ManiaRuleset(); + case PlayMode.Taiko: + return new TaikoRuleset(); + } + } + } +} diff --git a/osu.Game/GameModes/Play/Taiko/TaikoRuleset.cs b/osu.Game/GameModes/Play/Taiko/TaikoRuleset.cs new file mode 100644 index 0000000000..dacf17df21 --- /dev/null +++ b/osu.Game/GameModes/Play/Taiko/TaikoRuleset.cs @@ -0,0 +1,20 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Game.Beatmaps.Objects; +using osu.Game.GameModes.Play.Osu; + +namespace osu.Game.GameModes.Play.Taiko +{ + class TaikoRuleset : Ruleset + { + public override ScoreOverlay CreateScoreOverlay() => new ScoreOverlayOsu(); + + public override HitRenderer CreateHitRendererWith(List objects) => new TaikoHitRenderer { Objects = objects }; + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 842cb1e546..b8113853d6 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -121,13 +121,18 @@ + + + + + From 80f146e4bd25d0c1de22339ebb9e6f13de633e80 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 12 Nov 2016 18:24:56 +0900 Subject: [PATCH 18/19] Fix a locally set beatmap getting overridden by the game-global one. --- osu.Game/GameModes/OsuGameMode.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/GameModes/OsuGameMode.cs b/osu.Game/GameModes/OsuGameMode.cs index ea9bfcfc1b..82ef2d3240 100644 --- a/osu.Game/GameModes/OsuGameMode.cs +++ b/osu.Game/GameModes/OsuGameMode.cs @@ -78,7 +78,8 @@ namespace osu.Game.GameModes protected override void Load(BaseGame game) { base.Load(game); - beatmap = (game as OsuGameBase)?.Beatmap; + if (beatmap == null) + beatmap = (game as OsuGameBase)?.Beatmap; } public override bool Push(GameMode mode) From f7aabd0ce0e578bacc247670c9b38f4073f65c62 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 12 Nov 2016 18:31:57 +0900 Subject: [PATCH 19/19] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index ef57b64639..cf0de91ecb 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit ef57b64639f53326104707d40536de24226dd63f +Subproject commit cf0de91ecb69569e30d68b06cf709254b204025b