From ee24cd310cea9932edee196eec29aa7d40bb63ac Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 8 Nov 2016 18:13:20 -0500 Subject: [PATCH] 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