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 244eaf768e..5c0e4edbbc 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 244eaf768e744fbd05187b30494f3985e7305a58 +Subproject commit 5c0e4edbbcdc26ab56c70676856477cd21e7afdc diff --git a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs index 98e1c2de08..cb412f8c97 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) + [BackgroundDependencyLoader] + 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..c5d4a7069b 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) + [BackgroundDependencyLoader] + private void load() { - base.Load(game); - var swClock = new StopwatchClock(true) { Rate = 1 }; ourClock = new FramedClock(swClock); } diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs b/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs index 070745a49c..578815779d 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) + [BackgroundDependencyLoader] + private void load() { - base.Load(game); ourClock = new FramedClock(); } diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs index bb7b86db43..03e382b71e 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs @@ -11,6 +11,8 @@ using osu.Game.Beatmaps.Objects; 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 { diff --git a/osu.Desktop.VisualTests/VisualTestGame.cs b/osu.Desktop.VisualTests/VisualTestGame.cs index 5fba0209e2..fb05d7baf8 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) + [BackgroundDependencyLoader] + private void load() { - base.Load(game); Add(new TestBrowser()); } } 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/Beatmaps/Drawable/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawable/BeatmapGroup.cs index 5e10402206..1e433922a6 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) + [BackgroundDependencyLoader] + private void load(BaseGame game) { - base.Load(game); - BeatmapPanels = beatmapSet.Beatmaps.Select(b => new BeatmapPanel(b) { GainedSelection = panelGainedSelection, diff --git a/osu.Game/Beatmaps/Drawable/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawable/BeatmapSetHeader.cs index f8a38931e2..38b0e57812 100644 --- a/osu.Game/Beatmaps/Drawable/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawable/BeatmapSetHeader.cs @@ -2,20 +2,28 @@ //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Sprites; -using osu.Game.Database; -using osu.Game.Graphics; -using OpenTK; -using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Game.Database; +using osu.Game.Graphics; +using OpenTK; +using OpenTK.Graphics; +using osu.Framework; +using osu.Framework.Allocation; +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() { @@ -29,10 +37,33 @@ namespace osu.Game.Beatmaps.Drawable { base.Deselected(); Width = 0.8f; + } + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + this.config = config; + + preferUnicode = 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 +82,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/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/Beatmaps/Objects/Catch/Drawable/DrawableFruit.cs b/osu.Game/Beatmaps/Objects/Catch/Drawable/DrawableFruit.cs index ba3c1c90b6..4664bacc30 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) + [BackgroundDependencyLoader] + 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..ed8b42df61 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) + [BackgroundDependencyLoader] + 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..65d93ec651 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) + [BackgroundDependencyLoader] + 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) + [BackgroundDependencyLoader] + 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) + [BackgroundDependencyLoader] + 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) + [BackgroundDependencyLoader] + 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) + [BackgroundDependencyLoader] + 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) + [BackgroundDependencyLoader] + 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..7113016d51 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) + [BackgroundDependencyLoader] + 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/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); } diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 6c05603285..109d3eb527 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -179,6 +179,10 @@ namespace osu.Game.Configuration Set(OsuConfig.CanForceOptimusCompatibility, true); } + //todo: make a UnicodeString class/struct rather than requiring this helper method. + 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/GameModes/BackgroundMode.cs b/osu.Game/GameModes/BackgroundMode.cs index 641a95b27f..b46e7bcc78 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) + [BackgroundDependencyLoader] + 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..4b1a941089 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) + [BackgroundDependencyLoader] + 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..c7fe2139dc 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) + [BackgroundDependencyLoader] + 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..dc96a3c19d 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) + [BackgroundDependencyLoader] + 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..019ade16a0 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) + [BackgroundDependencyLoader] + 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..1253af10c7 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) + [BackgroundDependencyLoader] + 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 57d3f72ea9..92d64f838b 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 { @@ -45,13 +47,12 @@ namespace osu.Game.GameModes.Menu }; } - protected override void Load(BaseGame game) + [BackgroundDependencyLoader] + 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 b9007ab7ab..ed29d5e3db 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 { @@ -57,14 +59,12 @@ namespace osu.Game.GameModes.Menu }; } - protected override void Load(BaseGame game) + [BackgroundDependencyLoader] + private void load(OsuGame game) { - base.Load(game); - background.Preload(game); - OsuGame osu = (OsuGame)game; - buttons.OnSettings = osu.Options.ToggleVisibility; + buttons.OnSettings = game.ToggleOptions; } protected override void LoadComplete() diff --git a/osu.Game/GameModes/Menu/OsuLogo.cs b/osu.Game/GameModes/Menu/OsuLogo.cs index 106df1a1be..0663b79161 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) + [BackgroundDependencyLoader] + 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/OsuGameMode.cs b/osu.Game/GameModes/OsuGameMode.cs index ea9bfcfc1b..0c44a6488a 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; @@ -29,9 +30,9 @@ namespace osu.Game.GameModes internal virtual bool ShowToolbar => true; - protected new OsuGame Game => base.Game as OsuGame; + protected new OsuGameBase Game => base.Game as OsuGameBase; - protected float ToolbarPadding => ShowToolbar ? Game.Toolbar.DrawHeight : 0; + protected float ToolbarPadding => ShowToolbar ? (Game as OsuGame)?.Toolbar.DrawHeight ?? 0 : 0; private bool boundToBeatmap; private Bindable beatmap; @@ -75,10 +76,11 @@ namespace osu.Game.GameModes OnBeatmapChanged(beatmap.Value); } - protected override void Load(BaseGame game) + [BackgroundDependencyLoader(permitNulls: true)] + private void load(OsuGameBase game) { - base.Load(game); - beatmap = (game as OsuGameBase)?.Beatmap; + if (beatmap == null) + beatmap = game?.Beatmap; } public override bool Push(GameMode mode) diff --git a/osu.Game/GameModes/Play/Catch/CatchPlayfield.cs b/osu.Game/GameModes/Play/Catch/CatchPlayfield.cs index bf1b3f67a2..dc351231be 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) + [BackgroundDependencyLoader] + private void load() { - base.Load(game); - Add(new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.5f }); } } 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/ComboCounter.cs b/osu.Game/GameModes/Play/ComboCounter.cs index ec0d1b45d5..ec6d30057f 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) + [BackgroundDependencyLoader] + 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..b2038b88b9 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) + [BackgroundDependencyLoader] + 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..cbd25fd0e9 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) + [BackgroundDependencyLoader] + 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/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/OsuComboCounter.cs b/osu.Game/GameModes/Play/Osu/OsuComboCounter.cs index f0fc4cf580..286e11506e 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) + [BackgroundDependencyLoader] + 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/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/PlaySongSelect.cs b/osu.Game/GameModes/Play/PlaySongSelect.cs index fd22222f48..d083808e5d 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 { @@ -113,35 +115,34 @@ namespace osu.Game.GameModes.Play Width = 100, Text = "Play", Colour = new Color4(238, 51, 153, 255), - Action = () => Push(new Player { + Action = () => Push(new Player + { BeatmapInfo = selectedBeatmapGroup.SelectedPanel.Beatmap, PreferredPlayMode = playMode.Value - }), + }) }, } } }; } - protected override void Load(BaseGame game) + [BackgroundDependencyLoader(permitNulls: true)] + private void load(BeatmapDatabase beatmaps, AudioManager audio, OsuGame game) { - base.Load(game); - - OsuGame osuGame = game as OsuGame; - if (osuGame != null) + if (game != null) { - playMode = osuGame.PlayMode; + playMode = game.PlayMode; playMode.ValueChanged += playMode_ValueChanged; // Temporary: scrollContainer.Padding = new MarginPadding { Top = ToolbarPadding }; } if (database == null) - database = (game as OsuGameBase).Beatmaps; + 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 fecb076e63..a511921c4e 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.Allocation; +using osu.Framework.Audio; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Input; +using osu.Framework.Platform; +using OpenTK.Input; +using MouseState = osu.Framework.Input.MouseState; +using osu.Framework.Graphics.Primitives; namespace osu.Game.GameModes.Play { @@ -26,21 +34,53 @@ 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; private InterpolatingFramedClock playerClock; private IAdjustableClock sourceClock; + private Ruleset Ruleset; - protected override void Load(BaseGame game) + [BackgroundDependencyLoader] + private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game) { - base.Load(game); - try { if (Beatmap == null) - Beatmap = ((OsuGame)game).Beatmaps.GetWorkingBeatmap(BeatmapInfo); + Beatmap = beatmaps.GetWorkingBeatmap(BeatmapInfo); } catch { @@ -53,7 +93,7 @@ namespace osu.Game.GameModes.Play if (track != null) { - game.Audio.Track.SetExclusive(track); + audio.Track.SetExclusive(track); sourceClock = track; } @@ -80,49 +120,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); }; @@ -132,7 +134,14 @@ namespace osu.Game.GameModes.Play Children = new Drawable[] { - hitRenderer, + inputManager = new PlayerInputManager(game.Host) + { + PassThrough = false, + Children = new Drawable[] + { + hitRenderer, + } + }, scoreOverlay, }; } 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/TaikoPlayfield.cs b/osu.Game/GameModes/Play/Taiko/TaikoPlayfield.cs index 9d2231667e..b563cc718a 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) + [BackgroundDependencyLoader] + 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/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/Graphics/Background/Background.cs b/osu.Game/Graphics/Background/Background.cs index 8d004dcf86..d79976a24a 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) + [BackgroundDependencyLoader] + 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..52029dbf8e 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,7 +16,7 @@ namespace osu.Game.Graphics.Containers public ParallaxContainer() { RelativeSizeAxes = Axes.Both; - AddInternal(content = new Container() + AddInternal(content = new Container { RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, @@ -27,11 +28,6 @@ namespace osu.Game.Graphics.Containers protected override Container Content => content; - protected override void Load(BaseGame game) - { - base.Load(game); - } - protected override bool OnMouseMove(InputState state) { content.Position = (state.Mouse.Position - DrawSize / 2) * ParallaxAmount; @@ -44,4 +40,4 @@ namespace osu.Game.Graphics.Containers content.Scale = new Vector2(1 + ParallaxAmount); } } -} \ No newline at end of file +} diff --git a/osu.Game/Graphics/Cursor/OsuCursorContainer.cs b/osu.Game/Graphics/Cursor/OsuCursorContainer.cs index 49e6bc84f5..081919feaf 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) + [BackgroundDependencyLoader] + 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..5a7fe65925 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) + [BackgroundDependencyLoader] + 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..d3374da381 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) + [BackgroundDependencyLoader] + 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..38e3f161ee 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) + [BackgroundDependencyLoader] + 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..7a4a6d92bd 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) + [BackgroundDependencyLoader] + 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..b3a08a1196 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) + [BackgroundDependencyLoader] + 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..175d532f63 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) + [BackgroundDependencyLoader] + 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 a462c4f0fe..a13f772f2d 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -20,6 +20,8 @@ using OpenTK.Input; using osu.Framework.Logging; using osu.Game.GameModes; using osu.Game.Graphics.UserInterface.Volume; +using osu.Game.Database; +using osu.Framework.Allocation; namespace osu.Game { @@ -56,7 +58,10 @@ namespace osu.Game host.Size = new Vector2(Config.Get(OsuConfig.Width), Config.Get(OsuConfig.Height)); } - protected override void Load(BaseGame game) + public void ToggleOptions() => Options.ToggleVisibility(); + + [BackgroundDependencyLoader] + private void load() { if (!Host.IsPrimaryInstance) { @@ -64,10 +69,10 @@ namespace osu.Game Environment.Exit(0); } - base.Load(game); - if (args?.Length > 0) - Schedule(delegate { Beatmaps.Import(args); }); + Schedule(delegate { Dependencies.Get().Import(args); }); + + Dependencies.Cache(this); //attach our bindables to the audio subsystem. Audio.Volume.Weld(Config.GetBindable(OsuConfig.VolumeUniversal)); @@ -76,6 +81,7 @@ namespace osu.Game PlayMode = Config.GetBindable(OsuConfig.PlayMode); + //todo: move to constructor or LoadComplete. Add(new Drawable[] { new VolumeControlReceptor { @@ -102,7 +108,7 @@ namespace osu.Game (modeStack = new Intro { Beatmap = Beatmap - }).Preload(game, d => + }).Preload(this, d => { mainContent.Add(d); @@ -112,9 +118,9 @@ namespace osu.Game }); //overlay elements - (chat = new ChatConsole(API) { Depth = 0 }).Preload(game, overlayContent.Add); - (musicController = new MusicController()).Preload(game, overlayContent.Add); - (Options = new OptionsOverlay { Depth = 1 }).Preload(game, overlayContent.Add); + (chat = new ChatConsole(API) { Depth = 0 }).Preload(this, overlayContent.Add); + (musicController = new MusicController()).Preload(this, overlayContent.Add); + (Options = new OptionsOverlay { Depth = 1 }).Preload(this, overlayContent.Add); (Toolbar = new Toolbar { Depth = 2, @@ -122,7 +128,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 30a109c597..2c0094a384 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; @@ -23,7 +24,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"; @@ -37,31 +37,19 @@ 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) { } - protected override void Load(BaseGame game) + [BackgroundDependencyLoader] + private void load() { - base.Load(game); - - OszArchiveReader.Register(); - Beatmaps = new BeatmapDatabase(Host.Storage, Host); - + Dependencies.Cache(this); + Dependencies.Cache(new OsuConfigManager(Host.Storage)); + Dependencies.Cache(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 }; + Dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 0.01f }); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont")); @@ -77,13 +65,24 @@ 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()); - API = new APIAccess() + Children = new Drawable[] + { + Cursor = new OsuCursorContainer { Depth = float.MaxValue } + }; + + Beatmap.ValueChanged += Beatmap_ValueChanged; + + OszArchiveReader.Register(); + + 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) diff --git a/osu.Game/Overlays/ChatConsole.cs b/osu.Game/Overlays/ChatConsole.cs index 2dd6480715..769c809e7c 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) + [BackgroundDependencyLoader] + private void load() { - base.Load(game); initializeChannels(); } diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 310bae37e4..e1d12fa6dd 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; @@ -17,6 +19,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; @@ -24,7 +27,9 @@ namespace osu.Game.Overlays { public class MusicController : OverlayContainer { - private Sprite backgroundSprite; + private static readonly Vector2 start_position = new Vector2(10, 60); + + private MusicControllerBackground backgroundSprite; private DragBar progress; private TextAwesome playButton, listButton; private SpriteText title, artist; @@ -36,27 +41,30 @@ namespace osu.Game.Overlays private int playHistoryIndex = -1; private TrackManager trackManager; - private BeatmapDatabase database; private Bindable beatmapSource; + private Bindable preferUnicode; + private OsuConfigManager config; private WorkingBeatmap current; + private BeatmapDatabase beatmaps; - public MusicController(BeatmapDatabase db = null) + public MusicController() { - database = db; 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[] { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = new Color4(0, 0, 0, 127) - }, title = new SpriteText { Origin = Anchor.BottomCentre, @@ -77,14 +85,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, @@ -174,21 +174,38 @@ namespace osu.Game.Overlays }; } - protected override void Load(BaseGame game) + protected override bool OnDragStart(InputState state) => true; + + protected override bool OnDrag(InputState state) { - base.Load(game); - var osuGame = game as OsuGameBase; + Vector2 change = (state.Mouse.Position - state.Mouse.PositionMouseDown.Value); + change.X = -change.X; - if (osuGame != null) - { - if (database == null) database = osuGame.Beatmaps; - trackManager = osuGame.Audio.Track; - } + change *= (float)Math.Pow(change.Length, 0.7f) / change.Length; - beatmapSource = osuGame?.Beatmap ?? new Bindable(); - playList = database.GetAllWithChildren(); + MoveTo(start_position + change); + return base.OnDrag(state); + } - backgroundSprite = getScaledSprite(fallbackTexture = game.Textures.Get(@"Backgrounds/bg4")); + protected override bool OnDragEnd(InputState state) + { + MoveTo(start_position, 800, EasingTypes.OutElastic); + return base.OnDragEnd(state); + } + + [BackgroundDependencyLoader] + private void load(OsuGameBase osuGame, BeatmapDatabase beatmaps, AudioManager audio, TextureStore textures) + { + this.beatmaps = beatmaps; + trackManager = osuGame.Audio.Track; + config = osuGame.Config; + preferUnicode = osuGame.Config.GetBindable(OsuConfig.ShowUnicode); + preferUnicode.ValueChanged += preferUnicode_changed; + + beatmapSource = osuGame.Beatmap ?? new Bindable(); + playList = beatmaps.GetAllWithChildren(); + + backgroundSprite = new MusicControllerBackground(fallbackTexture = textures.Get(@"Backgrounds/bg4")); AddInternal(backgroundSprite); } @@ -210,6 +227,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; @@ -269,7 +291,7 @@ namespace osu.Game.Overlays private void play(BeatmapInfo info, bool isNext) { - current = database.GetWorkingBeatmap(info, current); + current = beatmaps.GetWorkingBeatmap(info, current); Task.Run(() => { trackManager.SetExclusive(current.Track); @@ -281,11 +303,15 @@ 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; + if (beatmap.Beatmap == null) + //todo: we may need to display some default text here (currently in the constructor). + return; - Sprite newBackground = getScaledSprite(beatmap.Background ?? fallbackTexture); + BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; + title.Text = config.GetUnicodeString(metadata.Title, metadata.TitleUnicode); + artist.Text = config.GetUnicodeString(metadata.Artist, metadata.ArtistUnicode); + + MusicControllerBackground newBackground = new MusicControllerBackground(beatmap.Background ?? fallbackTexture); Add(newBackground); @@ -306,34 +332,61 @@ 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) + preferUnicode.ValueChanged -= preferUnicode_changed; + base.Dispose(isDisposing); + } + protected override bool OnClick(InputState state) => true; 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); 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)); + } + } } } diff --git a/osu.Game/Overlays/Options/Audio/AudioSection.cs b/osu.Game/Overlays/Options/Audio/AudioSection.cs index 0cb4aa568c..59fbda58c9 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/Audio/VolumeOptions.cs b/osu.Game/Overlays/Options/Audio/VolumeOptions.cs index f9c2326123..e8ec4b7e86 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) + [BackgroundDependencyLoader] + 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 e1868de844..bdd7c87431 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 - { - public override string Header => "Editor"; +namespace osu.Game.Overlays.Options +{ + public class EditorSection : OptionsSection + { + public 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) + [BackgroundDependencyLoader] + 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..fe6f118643 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() + [BackgroundDependencyLoader] + 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/General/LanguageOptions.cs b/osu.Game/Overlays/Options/General/LanguageOptions.cs index 594bb9b1ec..e9009836ab 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 - { +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) + + [BackgroundDependencyLoader] + 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..2dc8bb5976 100644 --- a/osu.Game/Overlays/Options/General/LoginOptions.cs +++ b/osu.Game/Overlays/Options/General/LoginOptions.cs @@ -1,12 +1,13 @@ -using OpenTK; -using osu.Framework; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.UserInterface; -using osu.Game.Graphics.UserInterface; -using osu.Game.Online.API; - +using OpenTK; +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.UserInterface; +using osu.Game.Graphics.UserInterface; +using osu.Game.Online.API; + namespace osu.Game.Overlays.Options.General { public class LoginOptions : OptionsSubsection @@ -27,16 +28,15 @@ namespace osu.Game.Overlays.Options.General }; } - protected override void Load(BaseGame game) - { - base.Load(game); - var osuGame = game as OsuGameBase; - if (osuGame == null) + [BackgroundDependencyLoader(permitNulls: true)] + private void load(APIAccess api) + { + if (api == null) return; loginForm.Children = new Drawable[] { - new LoginForm(osuGame.API) - }; + new LoginForm(api) + }; } class LoginForm : FlowContainer @@ -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..8e68b26c1c 100644 --- a/osu.Game/Overlays/Options/General/UpdateOptions.cs +++ b/osu.Game/Overlays/Options/General/UpdateOptions.cs @@ -1,36 +1,31 @@ using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Platform; using osu.Game.Graphics.UserInterface; -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) +namespace osu.Game.Overlays.Options.General +{ + public class UpdateOptions : OptionsSubsection + { + protected override string Header => "Updates"; + + [BackgroundDependencyLoader] + 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/Options/Graphics/DetailOptions.cs b/osu.Game/Overlays/Options/Graphics/DetailOptions.cs index 14878128e3..12df61f52b 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) + [BackgroundDependencyLoader] + 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..c71c5f8cae 100644 --- a/osu.Game/Overlays/Options/Graphics/LayoutOptions.cs +++ b/osu.Game/Overlays/Options/Graphics/LayoutOptions.cs @@ -1,40 +1,37 @@ 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 LayoutOptions : OptionsSubsection - { +namespace osu.Game.Overlays.Options.Graphics +{ + public class LayoutOptions : OptionsSubsection + { 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) + [BackgroundDependencyLoader] + 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..8b1903e508 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) + [BackgroundDependencyLoader] + 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..bb46718bb6 100644 --- a/osu.Game/Overlays/Options/Graphics/RendererOptions.cs +++ b/osu.Game/Overlays/Options/Graphics/RendererOptions.cs @@ -1,39 +1,39 @@ 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 RendererOptions : OptionsSubsection - { +namespace osu.Game.Overlays.Options.Graphics +{ + public class RendererOptions : OptionsSubsection + { 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) + [BackgroundDependencyLoader] + 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..cda97f6eb3 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) + [BackgroundDependencyLoader] + 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..316354fd4a 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) + [BackgroundDependencyLoader] + 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..d9cb8bb38f 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) + [BackgroundDependencyLoader] + 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..91df397445 100644 --- a/osu.Game/Overlays/Options/Online/InGameChatOptions.cs +++ b/osu.Game/Overlays/Options/Online/InGameChatOptions.cs @@ -1,43 +1,56 @@ -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; + private TextBoxOption chatIgnoreList; + private TextBoxOption chatHighlightWords; + protected override string Header => "In-game Chat"; - public InGameChatOptions() + [BackgroundDependencyLoader] + 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 }, + chatIgnoreList = new TextBoxOption { + Height = 20, + RelativeSizeAxes = Axes.X, + Bindable = config.GetBindable(OsuConfig.IgnoreList) + }, new SpriteText { Text = "Chat highlight words (space-seperated list)" }, - new TextBox { Height = 20, RelativeSizeAxes = Axes.X }, + chatHighlightWords = new TextBoxOption { + Height = 20, + RelativeSizeAxes = Axes.X, + Bindable = config.GetBindable(OsuConfig.HighlightWords) + }, }; } - - 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..dc08277b8e 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() + [BackgroundDependencyLoader] + 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..ea009e81ad 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) + [BackgroundDependencyLoader] + 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..38cfab321d 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() + [BackgroundDependencyLoader] + 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 764ac2f13c..814e0d56c2 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 { public 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; + + [BackgroundDependencyLoader] + 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 diff --git a/osu.Game/Overlays/Options/TextBoxOption.cs b/osu.Game/Overlays/Options/TextBoxOption.cs new file mode 100644 index 0000000000..ffd9c86b71 --- /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/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index ae57ea1119..3ad894e102 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -7,12 +7,14 @@ using OpenTK; using OpenTK.Graphics; using OpenTK.Input; using osu.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using osu.Framework.Input; +using osu.Game.Configuration; using osu.Game.Overlays.Options; using osu.Game.Overlays.Options.Audio; using osu.Game.Overlays.Options.Gameplay; @@ -120,11 +122,10 @@ namespace osu.Game.Overlays }; } - protected override void Load(BaseGame game) + [BackgroundDependencyLoader(permitNulls: true)] + private void load(OsuGame game) { - base.Load(game); - - scrollContainer.Padding = new MarginPadding { Top = (game as OsuGame)?.Toolbar.DrawHeight ?? 0 }; + scrollContainer.Padding = new MarginPadding { Top = game?.Toolbar.DrawHeight ?? 0 }; } protected override void Update() diff --git a/osu.Game/Overlays/Toolbar.cs b/osu.Game/Overlays/Toolbar.cs index f4c5d356dd..4f2513b130 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) + [BackgroundDependencyLoader] + 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..7ae702918e 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) + [BackgroundDependencyLoader] + 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..2a384ea53e 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) + [BackgroundDependencyLoader] + private void load() { - base.Load(game); - Children = new Drawable[] { new Box diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 4ca6c84578..09e19ef4e5 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -121,13 +121,18 @@ + + + + + @@ -235,6 +240,7 @@ +