diff --git a/osu-framework b/osu-framework index aa01720fe9..5c0e4edbbc 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit aa01720fe9eb6e3b30a4455298a1c6eca7fb7680 +Subproject commit 5c0e4edbbcdc26ab56c70676856477cd21e7afdc diff --git a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs index 281b6338a4..cb412f8c97 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs @@ -35,8 +35,8 @@ namespace osu.Desktop.VisualTests.Tests private ChannelDisplay channelDisplay; - [Initializer] - private void Load(APIAccess api) + [BackgroundDependencyLoader] + private void load(APIAccess api) { this.api = api; } diff --git a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs index 0a3700b6bb..c5d4a7069b 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs @@ -21,8 +21,8 @@ namespace osu.Desktop.VisualTests.Tests protected override IFrameBasedClock Clock => ourClock; - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { 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 36b2c49274..578815779d 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs @@ -25,8 +25,8 @@ namespace osu.Desktop.Tests protected MusicController mc; - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { ourClock = new FramedClock(); } diff --git a/osu.Desktop.VisualTests/VisualTestGame.cs b/osu.Desktop.VisualTests/VisualTestGame.cs index db273b50af..fb05d7baf8 100644 --- a/osu.Desktop.VisualTests/VisualTestGame.cs +++ b/osu.Desktop.VisualTests/VisualTestGame.cs @@ -19,8 +19,8 @@ namespace osu.Desktop.VisualTests { class VisualTestGame : OsuGameBase { - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { Add(new TestBrowser()); } diff --git a/osu.Game/Beatmaps/Drawable/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawable/BeatmapGroup.cs index 3cd8324346..1e433922a6 100644 --- a/osu.Game/Beatmaps/Drawable/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawable/BeatmapGroup.cs @@ -100,8 +100,8 @@ namespace osu.Game.Beatmaps.Drawable }; } - [Initializer] - private void Load(BaseGame game) + [BackgroundDependencyLoader] + private void load(BaseGame game) { BeatmapPanels = beatmapSet.Beatmaps.Select(b => new BeatmapPanel(b) { 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/Objects/Catch/Drawable/DrawableFruit.cs b/osu.Game/Beatmaps/Objects/Catch/Drawable/DrawableFruit.cs index 8db412f674..4664bacc30 100644 --- a/osu.Game/Beatmaps/Objects/Catch/Drawable/DrawableFruit.cs +++ b/osu.Game/Beatmaps/Objects/Catch/Drawable/DrawableFruit.cs @@ -30,8 +30,8 @@ namespace osu.Game.Beatmaps.Objects.Catch.Drawable Position = new Vector2(h.Position, -0.1f); } - [Initializer] - private void Load(TextureStore textures) + [BackgroundDependencyLoader] + private void load(TextureStore textures) { Texture = textures.Get(@"Menu/logo"); diff --git a/osu.Game/Beatmaps/Objects/Mania/Drawable/DrawableNote.cs b/osu.Game/Beatmaps/Objects/Mania/Drawable/DrawableNote.cs index a1e1a8575a..ed8b42df61 100644 --- a/osu.Game/Beatmaps/Objects/Mania/Drawable/DrawableNote.cs +++ b/osu.Game/Beatmaps/Objects/Mania/Drawable/DrawableNote.cs @@ -22,8 +22,8 @@ namespace osu.Game.Beatmaps.Objects.Mania.Drawable Scale = new Vector2(0.1f); } - [Initializer] - private void Load(TextureStore textures) + [BackgroundDependencyLoader] + private void load(TextureStore textures) { Texture = textures.Get(@"Menu/logo"); diff --git a/osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs b/osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs index 293ecbdd38..65d93ec651 100644 --- a/osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs +++ b/osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs @@ -64,8 +64,8 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable Size = circle.DrawSize; } - [Initializer] - private void Load(BaseGame game) + [BackgroundDependencyLoader] + private void load(BaseGame game) { approachCircle.Texture = game.Textures.Get(@"Play/osu/approachcircle@2x"); } @@ -149,8 +149,8 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable }; } - [Initializer] - private void Load(TextureStore textures) + [BackgroundDependencyLoader] + private void load(TextureStore textures) { number.Texture = textures.Get(@"Play/osu/number@2x"); } @@ -177,8 +177,8 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable }; } - [Initializer] - private void Load(TextureStore textures) + [BackgroundDependencyLoader] + private void load(TextureStore textures) { layer.Texture = textures.Get(@"Play/osu/ring-glow@2x"); } @@ -203,8 +203,8 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable }; } - [Initializer] - private void Load(TextureStore textures) + [BackgroundDependencyLoader] + private void load(TextureStore textures) { ring.Texture = textures.Get(@"Play/osu/ring@2x"); } @@ -289,8 +289,8 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable }; } - [Initializer] - private void Load(TextureStore textures) + [BackgroundDependencyLoader] + private void load(TextureStore textures) { disc.Texture = textures.Get(@"Play/osu/disc@2x"); } @@ -306,8 +306,8 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable { private Texture tex; - [Initializer] - private void Load(TextureStore textures) + [BackgroundDependencyLoader] + private void load(TextureStore textures) { tex = textures.Get(@"Play/osu/triangle@2x"); diff --git a/osu.Game/Beatmaps/Objects/Taiko/Drawable/DrawableTaikoHit.cs b/osu.Game/Beatmaps/Objects/Taiko/Drawable/DrawableTaikoHit.cs index 48116ef75d..7113016d51 100644 --- a/osu.Game/Beatmaps/Objects/Taiko/Drawable/DrawableTaikoHit.cs +++ b/osu.Game/Beatmaps/Objects/Taiko/Drawable/DrawableTaikoHit.cs @@ -25,8 +25,8 @@ namespace osu.Game.Beatmaps.Objects.Taiko.Drawable Position = new Vector2(1.1f, 0.5f); } - [Initializer] - private void Load(TextureStore textures) + [BackgroundDependencyLoader] + private void load(TextureStore textures) { Texture = textures.Get(@"Menu/logo"); 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 49a36f7d4a..b46e7bcc78 100644 --- a/osu.Game/GameModes/BackgroundMode.cs +++ b/osu.Game/GameModes/BackgroundMode.cs @@ -35,8 +35,8 @@ namespace osu.Game.GameModes BaseGame game; - [Initializer] - private void Load(BaseGame game) + [BackgroundDependencyLoader] + private void load(BaseGame game) { this.game = game; } diff --git a/osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs b/osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs index 0eb956eb42..4b1a941089 100644 --- a/osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs +++ b/osu.Game/GameModes/Backgrounds/BackgroundModeCustom.cs @@ -16,8 +16,8 @@ namespace osu.Game.GameModes.Backgrounds this.textureName = textureName; } - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { Add(new Background(textureName)); } diff --git a/osu.Game/GameModes/Backgrounds/BackgroundModeDefault.cs b/osu.Game/GameModes/Backgrounds/BackgroundModeDefault.cs index a0a9f62a03..c7fe2139dc 100644 --- a/osu.Game/GameModes/Backgrounds/BackgroundModeDefault.cs +++ b/osu.Game/GameModes/Backgrounds/BackgroundModeDefault.cs @@ -9,8 +9,8 @@ namespace osu.Game.GameModes.Backgrounds { public class BackgroundModeDefault : BackgroundMode { - [Initializer] - private void Load(BaseGame game) + [BackgroundDependencyLoader] + private void load(BaseGame game) { Add(new Background()); } diff --git a/osu.Game/GameModes/GameModeWhiteBox.cs b/osu.Game/GameModes/GameModeWhiteBox.cs index 4866af1a8f..dc96a3c19d 100644 --- a/osu.Game/GameModes/GameModeWhiteBox.cs +++ b/osu.Game/GameModes/GameModeWhiteBox.cs @@ -78,8 +78,8 @@ namespace osu.Game.GameModes Content.FadeIn(transition_time, EasingTypes.OutExpo); } - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { Children = new Drawable[] { diff --git a/osu.Game/GameModes/Menu/Button.cs b/osu.Game/GameModes/Menu/Button.cs index b0721ce167..019ade16a0 100644 --- a/osu.Game/GameModes/Menu/Button.cs +++ b/osu.Game/GameModes/Menu/Button.cs @@ -49,8 +49,8 @@ namespace osu.Game.GameModes.Menu AutoSizeAxes = Axes.Both; } - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { Alpha = 0; diff --git a/osu.Game/GameModes/Menu/ButtonSystem.cs b/osu.Game/GameModes/Menu/ButtonSystem.cs index dcc0854294..1253af10c7 100644 --- a/osu.Game/GameModes/Menu/ButtonSystem.cs +++ b/osu.Game/GameModes/Menu/ButtonSystem.cs @@ -54,8 +54,8 @@ namespace osu.Game.GameModes.Menu RelativeSizeAxes = Axes.Both; } - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { Children = new Drawable[] { diff --git a/osu.Game/GameModes/Menu/Intro.cs b/osu.Game/GameModes/Menu/Intro.cs index e5ffd80fc5..92d64f838b 100644 --- a/osu.Game/GameModes/Menu/Intro.cs +++ b/osu.Game/GameModes/Menu/Intro.cs @@ -28,6 +28,8 @@ namespace osu.Game.GameModes.Menu private AudioSample welcome; private AudioTrack bgm; + internal override bool ShowToolbar => (ParentGameMode as OsuGameMode)?.ShowToolbar ?? false; + protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty(); public Intro() @@ -45,8 +47,8 @@ namespace osu.Game.GameModes.Menu }; } - [Initializer] - private void Load(AudioManager audio) + [BackgroundDependencyLoader] + private void load(AudioManager audio) { welcome = audio.Sample.Get(@"welcome"); diff --git a/osu.Game/GameModes/Menu/MainMenu.cs b/osu.Game/GameModes/Menu/MainMenu.cs index e324ba6e6a..ed29d5e3db 100644 --- a/osu.Game/GameModes/Menu/MainMenu.cs +++ b/osu.Game/GameModes/Menu/MainMenu.cs @@ -27,6 +27,8 @@ namespace osu.Game.GameModes.Menu private ButtonSystem buttons; public override string Name => @"Main Menu"; + internal override bool ShowToolbar => true; + private BackgroundMode background; protected override BackgroundMode CreateBackground() => background; @@ -57,11 +59,12 @@ namespace osu.Game.GameModes.Menu }; } - [Initializer] - private void Load(BaseGame game, OptionsOverlay options) + [BackgroundDependencyLoader] + private void load(OsuGame game) { background.Preload(game); - buttons.OnSettings = 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 b620690610..0663b79161 100644 --- a/osu.Game/GameModes/Menu/OsuLogo.cs +++ b/osu.Game/GameModes/Menu/OsuLogo.cs @@ -103,8 +103,8 @@ namespace osu.Game.GameModes.Menu }; } - [Initializer] - private void Load(TextureStore textures) + [BackgroundDependencyLoader] + private void load(TextureStore textures) { logo.Texture = textures.Get(@"Menu/logo"); ripple.Texture = textures.Get(@"Menu/logo"); diff --git a/osu.Game/GameModes/OsuGameMode.cs b/osu.Game/GameModes/OsuGameMode.cs index 18219b152d..0c44a6488a 100644 --- a/osu.Game/GameModes/OsuGameMode.cs +++ b/osu.Game/GameModes/OsuGameMode.cs @@ -28,6 +28,12 @@ namespace osu.Game.GameModes /// protected virtual BackgroundMode CreateBackground() => null; + internal virtual bool ShowToolbar => true; + + protected new OsuGameBase Game => base.Game as OsuGameBase; + + protected float ToolbarPadding => ShowToolbar ? (Game as OsuGame)?.Toolbar.DrawHeight ?? 0 : 0; + private bool boundToBeatmap; private Bindable beatmap; @@ -70,10 +76,11 @@ namespace osu.Game.GameModes OnBeatmapChanged(beatmap.Value); } - [Initializer(permitNulls: true)] - private void Load(OsuGameBase game) + [BackgroundDependencyLoader(permitNulls: true)] + private void load(OsuGameBase game) { - beatmap = game?.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 298d429bcb..dc351231be 100644 --- a/osu.Game/GameModes/Play/Catch/CatchPlayfield.cs +++ b/osu.Game/GameModes/Play/Catch/CatchPlayfield.cs @@ -21,8 +21,8 @@ namespace osu.Game.GameModes.Play.Catch Origin = Anchor.BottomCentre; } - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { 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 24610e5805..ec6d30057f 100644 --- a/osu.Game/GameModes/Play/ComboCounter.cs +++ b/osu.Game/GameModes/Play/ComboCounter.cs @@ -121,8 +121,8 @@ namespace osu.Game.GameModes.Play TextSize = 80; } - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { DisplayedCountSpriteText.Text = FormatCount(Count); DisplayedCountSpriteText.Anchor = Anchor; diff --git a/osu.Game/GameModes/Play/HitRenderer.cs b/osu.Game/GameModes/Play/HitRenderer.cs index d489a105fa..b2038b88b9 100644 --- a/osu.Game/GameModes/Play/HitRenderer.cs +++ b/osu.Game/GameModes/Play/HitRenderer.cs @@ -43,8 +43,8 @@ namespace osu.Game.GameModes.Play protected virtual List Convert(List objects) => Converter.Convert(objects); - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { RelativeSizeAxes = Axes.Both; diff --git a/osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs b/osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs index dcae3fbff6..cbd25fd0e9 100644 --- a/osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs +++ b/osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs @@ -24,8 +24,8 @@ namespace osu.Game.GameModes.Play.Mania Origin = Anchor.BottomCentre; } - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { Add(new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.5f }); 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 c4ceaf3453..286e11506e 100644 --- a/osu.Game/GameModes/Play/Osu/OsuComboCounter.cs +++ b/osu.Game/GameModes/Play/Osu/OsuComboCounter.cs @@ -34,8 +34,8 @@ namespace osu.Game.GameModes.Play.Osu } } - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { PopOutSpriteText.Origin = Origin; PopOutSpriteText.Anchor = Anchor; 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 ca43e02b3b..d083808e5d 100644 --- a/osu.Game/GameModes/Play/PlaySongSelect.cs +++ b/osu.Game/GameModes/Play/PlaySongSelect.cs @@ -126,17 +126,15 @@ namespace osu.Game.GameModes.Play }; } - [Initializer] - private void Load(BeatmapDatabase beatmaps, AudioManager audio, BaseGame game) + [BackgroundDependencyLoader(permitNulls: true)] + private void load(BeatmapDatabase beatmaps, AudioManager audio, OsuGame game) { - // TODO: Load(..., [PermitNull] OsuGame osuGame) or some such - var 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 = osuGame.Toolbar.Height }; + scrollContainer.Padding = new MarginPadding { Top = ToolbarPadding }; } if (database == null) diff --git a/osu.Game/GameModes/Play/Player.cs b/osu.Game/GameModes/Play/Player.cs index 0236fe7d44..a511921c4e 100644 --- a/osu.Game/GameModes/Play/Player.cs +++ b/osu.Game/GameModes/Play/Player.cs @@ -15,6 +15,12 @@ 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 { @@ -24,17 +30,52 @@ namespace osu.Game.GameModes.Play protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4"); + internal override bool ShowToolbar => false; + 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; - [Initializer] - private void Load(AudioManager audio, BeatmapDatabase beatmaps) + [BackgroundDependencyLoader] + private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game) { try { @@ -79,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); }; @@ -131,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 19fd1d27f5..b563cc718a 100644 --- a/osu.Game/GameModes/Play/Taiko/TaikoPlayfield.cs +++ b/osu.Game/GameModes/Play/Taiko/TaikoPlayfield.cs @@ -22,8 +22,8 @@ namespace osu.Game.GameModes.Play.Taiko Origin = Anchor.Centre; } - [Initializer] - private void Load(TextureStore textures) + [BackgroundDependencyLoader] + private void load(TextureStore textures) { Add(new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.5f }); 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 1ef4cc7181..d79976a24a 100644 --- a/osu.Game/Graphics/Background/Background.cs +++ b/osu.Game/Graphics/Background/Background.cs @@ -28,8 +28,8 @@ namespace osu.Game.Graphics.Background Depth = float.MinValue; } - [Initializer] - private void Load(TextureStore textures) + [BackgroundDependencyLoader] + private void load(TextureStore textures) { Add(BackgroundSprite = new Sprite { diff --git a/osu.Game/Graphics/Cursor/OsuCursorContainer.cs b/osu.Game/Graphics/Cursor/OsuCursorContainer.cs index 511063bcb0..081919feaf 100644 --- a/osu.Game/Graphics/Cursor/OsuCursorContainer.cs +++ b/osu.Game/Graphics/Cursor/OsuCursorContainer.cs @@ -39,8 +39,8 @@ namespace osu.Game.Graphics.Cursor AutoSizeAxes = Axes.Both; } - [Initializer] - private void Load(TextureStore textures) + [BackgroundDependencyLoader] + private void load(TextureStore textures) { Children = new Drawable[] { diff --git a/osu.Game/Graphics/UserInterface/KeyCounter.cs b/osu.Game/Graphics/UserInterface/KeyCounter.cs index 4985cc65f9..5a7fe65925 100644 --- a/osu.Game/Graphics/UserInterface/KeyCounter.cs +++ b/osu.Game/Graphics/UserInterface/KeyCounter.cs @@ -61,8 +61,8 @@ namespace osu.Game.Graphics.UserInterface Name = name; } - [Initializer] - private void Load(TextureStore textures) + [BackgroundDependencyLoader] + private void load(TextureStore textures) { Children = new Drawable[] { diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index d4cbfe100f..d3374da381 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -120,8 +120,8 @@ namespace osu.Game.Graphics.UserInterface AutoSizeAxes = Axes.Both; } - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { DisplayedCount = Count; diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index e889dee0a8..38e3f161ee 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -110,8 +110,8 @@ namespace osu.Game.Graphics.UserInterface }; } - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { 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 0d03845062..7a4a6d92bd 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs @@ -33,8 +33,8 @@ namespace osu.Game.Graphics.UserInterface.Volume Origin = Anchor.BottomRight; } - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { VolumeGlobal.ValueChanged += volumeChanged; VolumeSample.ValueChanged += volumeChanged; diff --git a/osu.Game/Online/Chat/Display/ChannelDisplay.cs b/osu.Game/Online/Chat/Display/ChannelDisplay.cs index d72eaf305a..b3a08a1196 100644 --- a/osu.Game/Online/Chat/Display/ChannelDisplay.cs +++ b/osu.Game/Online/Chat/Display/ChannelDisplay.cs @@ -60,8 +60,8 @@ namespace osu.Game.Online.Chat.Display channel.NewMessagesArrived -= newMessages; } - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { newMessages(channel.Messages); } diff --git a/osu.Game/Online/Chat/Display/ChatLine.cs b/osu.Game/Online/Chat/Display/ChatLine.cs index 14cdb6ed11..175d532f63 100644 --- a/osu.Game/Online/Chat/Display/ChatLine.cs +++ b/osu.Game/Online/Chat/Display/ChatLine.cs @@ -28,8 +28,8 @@ namespace osu.Game.Online.Chat.Display const float padding = 200; const float text_size = 20; - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 490389237f..a13f772f2d 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -18,6 +18,7 @@ using osu.Framework.Input; using osu.Game.Input; 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; @@ -27,10 +28,15 @@ namespace osu.Game public class OsuGame : OsuGameBase { public Toolbar Toolbar; - public ChatConsole Chat; - public MusicController MusicController; - public MainMenu MainMenu => intro?.ChildGameMode as MainMenu; - private Intro intro; + + private ChatConsole chat; + + private MusicController musicController; + + private MainMenu mainMenu => modeStack?.ChildGameMode as MainMenu; + private Intro intro => modeStack as Intro; + + private OsuGameMode modeStack; private VolumeControl volume; @@ -52,8 +58,10 @@ namespace osu.Game host.Size = new Vector2(Config.Get(OsuConfig.Width), Config.Get(OsuConfig.Height)); } - [Initializer] - private void Load() + public void ToggleOptions() => Options.ToggleVisibility(); + + [BackgroundDependencyLoader] + private void load() { if (!Host.IsPrimaryInstance) { @@ -73,6 +81,7 @@ namespace osu.Game PlayMode = Config.GetBindable(OsuConfig.PlayMode); + //todo: move to constructor or LoadComplete. Add(new Drawable[] { new VolumeControlReceptor { @@ -89,40 +98,41 @@ namespace osu.Game VolumeSample = Audio.VolumeSample, VolumeTrack = Audio.VolumeTrack }, + overlayContent = new Container{ RelativeSizeAxes = Axes.Both }, new GlobalHotkeys //exists because UserInputManager is at a level below us. { Handler = globalHotkeyPressed } }); - (Options = new OptionsOverlay { Depth = float.MaxValue / 2 }).Preload(this, Add); - - (intro = new Intro + (modeStack = new Intro { Beatmap = Beatmap }).Preload(this, d => { mainContent.Add(d); - intro.ModePushed += modeAdded; - intro.Exited += modeRemoved; - intro.DisplayAsRoot(); + modeStack.ModePushed += modeAdded; + modeStack.Exited += modeRemoved; + modeStack.DisplayAsRoot(); }); - (Chat = new ChatConsole(API)).Preload(this, Add); - (MusicController = new MusicController()).Preload(this, Add); - + //overlay elements + (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 { - OnHome = delegate { MainMenu?.MakeCurrent(); }, + Depth = 2, + OnHome = delegate { mainMenu?.MakeCurrent(); }, OnSettings = Options.ToggleVisibility, OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; }, - OnMusicController = MusicController.ToggleVisibility + OnMusicController = musicController.ToggleVisibility }).Preload(this, t => { PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); }; PlayMode.TriggerChange(); - Add(Toolbar); + overlayContent.Add(Toolbar); }); Cursor.Alpha = 0; @@ -133,7 +143,7 @@ namespace osu.Game switch (args.Key) { case Key.F8: - Chat.ToggleVisibility(); + chat.ToggleVisibility(); return true; } @@ -154,6 +164,8 @@ namespace osu.Game private Container mainContent; + private Container overlayContent; + private void modeChanged(GameMode newMode) { // - Ability to change window size @@ -161,10 +173,10 @@ namespace osu.Game // - Frame limiter changes //central game mode change logic. - if (newMode is Player || newMode is Intro) + if ((newMode as OsuGameMode)?.ShowToolbar != true) { Toolbar.State = Visibility.Hidden; - Chat.State = Visibility.Hidden; + chat.State = Visibility.Hidden; } else { diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 2ca8c452a5..2c0094a384 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -41,8 +41,8 @@ namespace osu.Game { } - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { Dependencies.Cache(this); Dependencies.Cache(new OsuConfigManager(Host.Storage)); @@ -68,13 +68,10 @@ namespace osu.Game AddInternal(ratioContainer = new RatioAdjust()); - var options = new OptionsOverlay(); Children = new Drawable[] { - options, Cursor = new OsuCursorContainer { Depth = float.MaxValue } }; - Dependencies.Cache(options); Beatmap.ValueChanged += Beatmap_ValueChanged; diff --git a/osu.Game/Overlays/ChatConsole.cs b/osu.Game/Overlays/ChatConsole.cs index 1814130ac0..769c809e7c 100644 --- a/osu.Game/Overlays/ChatConsole.cs +++ b/osu.Game/Overlays/ChatConsole.cs @@ -56,8 +56,8 @@ namespace osu.Game.Overlays }); } - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { initializeChannels(); } diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 4043c10327..e1d12fa6dd 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -19,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; @@ -26,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; @@ -38,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, @@ -79,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, @@ -176,16 +174,38 @@ namespace osu.Game.Overlays }; } - [Initializer(permitNulls: true)] - private void Load(OsuGame osuGame, BeatmapDatabase beatmaps, AudioManager audio, TextureStore textures) + protected override bool OnDragStart(InputState state) => true; + + protected override bool OnDrag(InputState state) { - if (database == null) database = beatmaps; - trackManager = audio.Track; + Vector2 change = (state.Mouse.Position - state.Mouse.PositionMouseDown.Value); + change.X = -change.X; - beatmapSource = osuGame?.Beatmap ?? new Bindable(); - playList = database.GetAllWithChildren(); + change *= (float)Math.Pow(change.Length, 0.7f) / change.Length; - backgroundSprite = getScaledSprite(fallbackTexture = textures.Get(@"Backgrounds/bg4")); + MoveTo(start_position + change); + return base.OnDrag(state); + } + + 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); } @@ -207,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; @@ -266,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); @@ -278,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); @@ -303,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 af72974a10..59fbda58c9 100644 --- a/osu.Game/Overlays/Options/Audio/AudioSection.cs +++ b/osu.Game/Overlays/Options/Audio/AudioSection.cs @@ -1,18 +1,19 @@ -using osu.Framework.Graphics; +using osu.Framework; +using osu.Framework.Graphics; using osu.Game.Graphics; namespace osu.Game.Overlays.Options.Audio { public class AudioSection : OptionsSection { - protected override string Header => "Audio"; + public override string Header => "Audio"; public override FontAwesome Icon => FontAwesome.fa_headphones; public AudioSection() { 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 adf7e923f7..e8ec4b7e86 100644 --- a/osu.Game/Overlays/Options/Audio/VolumeOptions.cs +++ b/osu.Game/Overlays/Options/Audio/VolumeOptions.cs @@ -17,8 +17,8 @@ namespace osu.Game.Overlays.Options.Audio { } - [Initializer] - private void Load(OsuConfigManager config) + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) { Children = new Drawable[] { diff --git a/osu.Game/Overlays/Options/EditorSection.cs b/osu.Game/Overlays/Options/EditorSection.cs index 998f31c77c..bdd7c87431 100644 --- a/osu.Game/Overlays/Options/EditorSection.cs +++ b/osu.Game/Overlays/Options/EditorSection.cs @@ -10,11 +10,11 @@ namespace osu.Game.Overlays.Options { public class EditorSection : OptionsSection { - protected override string Header => "Editor"; + public override string Header => "Editor"; public override FontAwesome Icon => FontAwesome.fa_pencil; - [Initializer] - private void Load(OsuConfigManager config) + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) { content.Spacing = new Vector2(0, 5); Children = new Drawable[] diff --git a/osu.Game/Overlays/Options/Gameplay/GameplaySection.cs b/osu.Game/Overlays/Options/Gameplay/GameplaySection.cs index 6ad157bf0b..af4728e0e2 100644 --- a/osu.Game/Overlays/Options/Gameplay/GameplaySection.cs +++ b/osu.Game/Overlays/Options/Gameplay/GameplaySection.cs @@ -5,7 +5,7 @@ namespace osu.Game.Overlays.Options.Gameplay { public class GameplaySection : OptionsSection { - protected override string Header => "Gameplay"; + public override string Header => "Gameplay"; public override FontAwesome Icon => FontAwesome.fa_circle_o; public GameplaySection() diff --git a/osu.Game/Overlays/Options/Gameplay/GeneralGameplayOptions.cs b/osu.Game/Overlays/Options/Gameplay/GeneralGameplayOptions.cs index f2d6f6049d..fe6f118643 100644 --- a/osu.Game/Overlays/Options/Gameplay/GeneralGameplayOptions.cs +++ b/osu.Game/Overlays/Options/Gameplay/GeneralGameplayOptions.cs @@ -11,8 +11,8 @@ namespace osu.Game.Overlays.Options.Gameplay { protected override string Header => "General"; - [Initializer] - private void Load(OsuConfigManager config) + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) { Children = new Drawable[] { diff --git a/osu.Game/Overlays/Options/General/GeneralSection.cs b/osu.Game/Overlays/Options/General/GeneralSection.cs index 29302e530b..a9cea62270 100644 --- a/osu.Game/Overlays/Options/General/GeneralSection.cs +++ b/osu.Game/Overlays/Options/General/GeneralSection.cs @@ -5,7 +5,7 @@ namespace osu.Game.Overlays.Options.General { public class GeneralSection : OptionsSection { - protected override string Header => "General"; + public override string Header => "General"; public override FontAwesome Icon => FontAwesome.fa_gear; public GeneralSection() diff --git a/osu.Game/Overlays/Options/General/LanguageOptions.cs b/osu.Game/Overlays/Options/General/LanguageOptions.cs index f9afe0e94a..e9009836ab 100644 --- a/osu.Game/Overlays/Options/General/LanguageOptions.cs +++ b/osu.Game/Overlays/Options/General/LanguageOptions.cs @@ -1,17 +1,17 @@ using osu.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; -using osu.Framework.Allocation; +using osu.Framework.Allocation; using osu.Game.Configuration; -namespace osu.Game.Overlays.Options.General -{ - public class LanguageOptions : OptionsSubsection - { - protected override string Header => "Language"; - - [Initializer] - private void Load(OsuConfigManager config) +namespace osu.Game.Overlays.Options.General +{ + public class LanguageOptions : OptionsSubsection + { + protected override string Header => "Language"; + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) { Children = new Drawable[] { @@ -27,6 +27,6 @@ namespace osu.Game.Overlays.Options.General Bindable = config.GetBindable(OsuConfig.AlternativeChatFont) }, }; - } - } -} + } + } +} diff --git a/osu.Game/Overlays/Options/General/LoginOptions.cs b/osu.Game/Overlays/Options/General/LoginOptions.cs index e31a6d29ff..2dc8bb5976 100644 --- a/osu.Game/Overlays/Options/General/LoginOptions.cs +++ b/osu.Game/Overlays/Options/General/LoginOptions.cs @@ -1,13 +1,13 @@ -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; - +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 @@ -28,15 +28,15 @@ namespace osu.Game.Overlays.Options.General }; } - [Initializer(permitNulls: true)] - private void Load(APIAccess api) - { - if (api == null) + [BackgroundDependencyLoader(permitNulls: true)] + private void load(APIAccess api) + { + if (api == null) return; loginForm.Children = new Drawable[] { new LoginForm(api) - }; + }; } class LoginForm : FlowContainer diff --git a/osu.Game/Overlays/Options/General/UpdateOptions.cs b/osu.Game/Overlays/Options/General/UpdateOptions.cs index 0f61f49eb9..8e68b26c1c 100644 --- a/osu.Game/Overlays/Options/General/UpdateOptions.cs +++ b/osu.Game/Overlays/Options/General/UpdateOptions.cs @@ -5,14 +5,14 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Platform; using osu.Game.Graphics.UserInterface; -namespace osu.Game.Overlays.Options.General -{ - public class UpdateOptions : OptionsSubsection - { - protected override string Header => "Updates"; - - [Initializer] - private void Load(BasicStorage storage) +namespace osu.Game.Overlays.Options.General +{ + public class UpdateOptions : OptionsSubsection + { + protected override string Header => "Updates"; + + [BackgroundDependencyLoader] + private void load(BasicStorage storage) { Children = new Drawable[] { @@ -25,7 +25,7 @@ namespace osu.Game.Overlays.Options.General Action = () => storage.OpenInNativeExplorer(), } }; - } - } -} - + } + } +} + diff --git a/osu.Game/Overlays/Options/Graphics/DetailOptions.cs b/osu.Game/Overlays/Options/Graphics/DetailOptions.cs index f672a353de..12df61f52b 100644 --- a/osu.Game/Overlays/Options/Graphics/DetailOptions.cs +++ b/osu.Game/Overlays/Options/Graphics/DetailOptions.cs @@ -11,8 +11,8 @@ namespace osu.Game.Overlays.Options.Graphics { protected override string Header => "Detail Settings"; - [Initializer] - private void Load(OsuConfigManager config) + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) { Children = new Drawable[] { diff --git a/osu.Game/Overlays/Options/Graphics/GraphicsSection.cs b/osu.Game/Overlays/Options/Graphics/GraphicsSection.cs index 1e2d8da985..ec0091edde 100644 --- a/osu.Game/Overlays/Options/Graphics/GraphicsSection.cs +++ b/osu.Game/Overlays/Options/Graphics/GraphicsSection.cs @@ -5,7 +5,7 @@ namespace osu.Game.Overlays.Options.Graphics { public class GraphicsSection : OptionsSection { - protected override string Header => "Graphics"; + public override string Header => "Graphics"; public override FontAwesome Icon => FontAwesome.fa_laptop; public GraphicsSection() diff --git a/osu.Game/Overlays/Options/Graphics/LayoutOptions.cs b/osu.Game/Overlays/Options/Graphics/LayoutOptions.cs index 3caf598a53..c71c5f8cae 100644 --- a/osu.Game/Overlays/Options/Graphics/LayoutOptions.cs +++ b/osu.Game/Overlays/Options/Graphics/LayoutOptions.cs @@ -5,14 +5,14 @@ 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"; - [Initializer] - private void Load(OsuConfigManager config) + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) { Children = new Drawable[] { @@ -32,6 +32,6 @@ namespace osu.Game.Overlays.Options.Graphics 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 0944ab401d..8b1903e508 100644 --- a/osu.Game/Overlays/Options/Graphics/MainMenuOptions.cs +++ b/osu.Game/Overlays/Options/Graphics/MainMenuOptions.cs @@ -9,8 +9,8 @@ namespace osu.Game.Overlays.Options.Graphics { protected override string Header => "Main Menu"; - [Initializer] - private void Load(OsuConfigManager config) + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) { Children = new[] { diff --git a/osu.Game/Overlays/Options/Graphics/RendererOptions.cs b/osu.Game/Overlays/Options/Graphics/RendererOptions.cs index ab3fd70d2a..bb46718bb6 100644 --- a/osu.Game/Overlays/Options/Graphics/RendererOptions.cs +++ b/osu.Game/Overlays/Options/Graphics/RendererOptions.cs @@ -5,14 +5,14 @@ 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"; - [Initializer] - private void Load(OsuConfigManager config) + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) { // NOTE: Compatability mode omitted Children = new Drawable[] @@ -34,6 +34,6 @@ namespace osu.Game.Overlays.Options.Graphics 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 76037a9d13..cda97f6eb3 100644 --- a/osu.Game/Overlays/Options/Graphics/SongSelectGraphicsOptions.cs +++ b/osu.Game/Overlays/Options/Graphics/SongSelectGraphicsOptions.cs @@ -9,8 +9,8 @@ namespace osu.Game.Overlays.Options.Graphics { protected override string Header => "Song Select"; - [Initializer] - private void Load(OsuConfigManager config) + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) { Children = new[] { diff --git a/osu.Game/Overlays/Options/Input/InputSection.cs b/osu.Game/Overlays/Options/Input/InputSection.cs index 6e19e8a283..1bbf1ece38 100644 --- a/osu.Game/Overlays/Options/Input/InputSection.cs +++ b/osu.Game/Overlays/Options/Input/InputSection.cs @@ -5,7 +5,7 @@ namespace osu.Game.Overlays.Options.Input { public class InputSection : OptionsSection { - protected override string Header => "Input"; + public override string Header => "Input"; public override FontAwesome Icon => FontAwesome.fa_keyboard_o; public InputSection() diff --git a/osu.Game/Overlays/Options/Input/MouseOptions.cs b/osu.Game/Overlays/Options/Input/MouseOptions.cs index 960ef77af8..316354fd4a 100644 --- a/osu.Game/Overlays/Options/Input/MouseOptions.cs +++ b/osu.Game/Overlays/Options/Input/MouseOptions.cs @@ -17,8 +17,8 @@ namespace osu.Game.Overlays.Options.Input { } - [Initializer] - private void Load(OsuConfigManager config) + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) { Children = new Drawable[] { diff --git a/osu.Game/Overlays/Options/Input/OtherInputOptions.cs b/osu.Game/Overlays/Options/Input/OtherInputOptions.cs index 64729f7e47..d9cb8bb38f 100644 --- a/osu.Game/Overlays/Options/Input/OtherInputOptions.cs +++ b/osu.Game/Overlays/Options/Input/OtherInputOptions.cs @@ -10,8 +10,8 @@ namespace osu.Game.Overlays.Options.Input { protected override string Header => "Other"; - [Initializer] - private void Load(OsuConfigManager config) + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) { Children = new Drawable[] { diff --git a/osu.Game/Overlays/Options/MaintenanceSection.cs b/osu.Game/Overlays/Options/MaintenanceSection.cs index ba9b3b7e56..a76d338592 100644 --- a/osu.Game/Overlays/Options/MaintenanceSection.cs +++ b/osu.Game/Overlays/Options/MaintenanceSection.cs @@ -8,7 +8,7 @@ namespace osu.Game.Overlays.Options { public class MaintenanceSection : OptionsSection { - protected override string Header => "Maintenance"; + public override string Header => "Maintenance"; public override FontAwesome Icon => FontAwesome.fa_wrench; public MaintenanceSection() diff --git a/osu.Game/Overlays/Options/Online/InGameChatOptions.cs b/osu.Game/Overlays/Options/Online/InGameChatOptions.cs index cca3843278..91df397445 100644 --- a/osu.Game/Overlays/Options/Online/InGameChatOptions.cs +++ b/osu.Game/Overlays/Options/Online/InGameChatOptions.cs @@ -9,10 +9,12 @@ namespace osu.Game.Overlays.Options.Online { public class InGameChatOptions : OptionsSubsection { + private TextBoxOption chatIgnoreList; + private TextBoxOption chatHighlightWords; protected override string Header => "In-game Chat"; - [Initializer] - private void Load(OsuConfigManager config) + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) { Children = new Drawable[] { @@ -37,10 +39,18 @@ namespace osu.Game.Overlays.Options.Online 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) + }, }; - } + } } } \ 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 6ed4aed016..dc08277b8e 100644 --- a/osu.Game/Overlays/Options/Online/NotificationsOptions.cs +++ b/osu.Game/Overlays/Options/Online/NotificationsOptions.cs @@ -10,8 +10,8 @@ namespace osu.Game.Overlays.Options.Online { protected override string Header => "Notifications"; - [Initializer] - private void Load(OsuConfigManager config) + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) { Children = new Drawable[] { diff --git a/osu.Game/Overlays/Options/Online/OnlineIntegrationOptions.cs b/osu.Game/Overlays/Options/Online/OnlineIntegrationOptions.cs index 46f93acd58..ea009e81ad 100644 --- a/osu.Game/Overlays/Options/Online/OnlineIntegrationOptions.cs +++ b/osu.Game/Overlays/Options/Online/OnlineIntegrationOptions.cs @@ -10,8 +10,8 @@ namespace osu.Game.Overlays.Options.Online { protected override string Header => "Integration"; - [Initializer] - private void Load(OsuConfigManager config) + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) { Children = new Drawable[] { diff --git a/osu.Game/Overlays/Options/Online/OnlineSection.cs b/osu.Game/Overlays/Options/Online/OnlineSection.cs index 3c6e6b8a67..a29f18d768 100644 --- a/osu.Game/Overlays/Options/Online/OnlineSection.cs +++ b/osu.Game/Overlays/Options/Online/OnlineSection.cs @@ -5,7 +5,7 @@ namespace osu.Game.Overlays.Options.Online { public class OnlineSection : OptionsSection { - protected override string Header => "Online"; + public override string Header => "Online"; public override FontAwesome Icon => FontAwesome.fa_globe; public OnlineSection() diff --git a/osu.Game/Overlays/Options/Online/PrivacyOptions.cs b/osu.Game/Overlays/Options/Online/PrivacyOptions.cs index 711272652b..38cfab321d 100644 --- a/osu.Game/Overlays/Options/Online/PrivacyOptions.cs +++ b/osu.Game/Overlays/Options/Online/PrivacyOptions.cs @@ -10,8 +10,8 @@ namespace osu.Game.Overlays.Options.Online { protected override string Header => "Privacy"; - [Initializer] - private void Load(OsuConfigManager config) + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) { Children = new Drawable[] { diff --git a/osu.Game/Overlays/Options/OptionsSection.cs b/osu.Game/Overlays/Options/OptionsSection.cs index 8dc6d271dd..aa1feddd4f 100644 --- a/osu.Game/Overlays/Options/OptionsSection.cs +++ b/osu.Game/Overlays/Options/OptionsSection.cs @@ -14,7 +14,7 @@ namespace osu.Game.Overlays.Options protected override Container Content => content; public abstract FontAwesome Icon { get; } - protected abstract string Header { get; } + public abstract string Header { get; } public OptionsSection() { diff --git a/osu.Game/Overlays/Options/OptionsSidebar.cs b/osu.Game/Overlays/Options/OptionsSidebar.cs index 60936ea6b0..6f1cb4a48c 100644 --- a/osu.Game/Overlays/Options/OptionsSidebar.cs +++ b/osu.Game/Overlays/Options/OptionsSidebar.cs @@ -4,7 +4,9 @@ using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transformations; using osu.Framework.Input; +using osu.Framework.Threading; using osu.Game.Graphics; namespace osu.Game.Overlays.Options @@ -12,6 +14,7 @@ namespace osu.Game.Overlays.Options public class OptionsSidebar : Container { private FlowContainer content; + internal const int default_width = 60, expanded_width = 200; protected override Container Content => content; public OptionsSidebar() @@ -41,6 +44,25 @@ namespace osu.Game.Overlays.Options }; } + private ScheduledDelegate expandEvent; + + protected override bool OnHover(InputState state) + { + expandEvent = Scheduler.AddDelayed(() => + { + expandEvent = null; + ResizeTo(new Vector2(expanded_width, Height), 150, EasingTypes.OutQuad); + }, 750); + return true; + } + + protected override void OnHoverLost(InputState state) + { + expandEvent?.Cancel(); + ResizeTo(new Vector2(default_width, Height), 150, EasingTypes.OutQuad); + base.OnHoverLost(state); + } + private class SidebarScrollContainer : ScrollContainer { public SidebarScrollContainer() @@ -53,6 +75,7 @@ namespace osu.Game.Overlays.Options public class SidebarButton : Container { private TextAwesome drawableIcon; + private SpriteText headerText; private Box backgroundBox; public Action Action; @@ -61,10 +84,17 @@ namespace osu.Game.Overlays.Options get { return drawableIcon.Icon; } set { drawableIcon.Icon = value; } } + + public string Header + { + get { return headerText.Text; } + set { headerText.Text = value; } + } public SidebarButton() { - Size = new Vector2(60); + Height = default_width; + RelativeSizeAxes = Axes.X; Children = new Drawable[] { backgroundBox = new Box @@ -74,11 +104,25 @@ namespace osu.Game.Overlays.Options Colour = new Color4(60, 60, 60, 255), Alpha = 0, }, - drawableIcon = new TextAwesome + new Container { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, + Width = default_width, + RelativeSizeAxes = Axes.Y, + Children = new[] + { + drawableIcon = new TextAwesome + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, + } }, + headerText = new SpriteText + { + Position = new Vector2(default_width + 10, 0), + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + } }; } @@ -92,12 +136,13 @@ namespace osu.Game.Overlays.Options protected override bool OnHover(InputState state) { backgroundBox.FadeTo(0.4f, 200); - return true; + return base.OnHover(state); } protected override void OnHoverLost(InputState state) { backgroundBox.FadeTo(0, 200); + base.OnHoverLost(state); } } } diff --git a/osu.Game/Overlays/Options/SkinSection.cs b/osu.Game/Overlays/Options/SkinSection.cs index 7475ec9e5f..814e0d56c2 100644 --- a/osu.Game/Overlays/Options/SkinSection.cs +++ b/osu.Game/Overlays/Options/SkinSection.cs @@ -12,11 +12,11 @@ namespace osu.Game.Overlays.Options { public class SkinSection : OptionsSection { - protected override string Header => "Skin"; + public override string Header => "Skin"; public override FontAwesome Icon => FontAwesome.fa_paint_brush; - [Initializer] - private void Load(OsuConfigManager config) + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) { content.Spacing = new Vector2(0, 5); Children = new Drawable[] 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 14219b9841..b2d6aef448 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -6,12 +6,15 @@ using System.Linq; 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; @@ -27,7 +30,8 @@ namespace osu.Game.Overlays internal const float CONTENT_MARGINS = 10; private const float width = 400; - private const float sidebar_width = 60; + private const float sidebar_width = OptionsSidebar.default_width; + private const float sidebar_padding = 10; private ScrollContainer scrollContainer; private OptionsSidebar sidebar; @@ -72,6 +76,7 @@ namespace osu.Game.Overlays AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, Direction = FlowDirection.VerticalOnly, + Children = new Drawable[] { new SpriteText @@ -105,13 +110,20 @@ namespace osu.Game.Overlays new OptionsSidebar.SidebarButton { Icon = section.Icon, - Action = () => scrollContainer.ScrollIntoView(section) + Header = section.Header, + Action = () => scrollContainer.ScrollIntoView(section), } ) } }; } + [BackgroundDependencyLoader(permitNulls: true)] + private void load(OsuGame game) + { + scrollContainer.Padding = new MarginPadding { Top = game?.Toolbar.DrawHeight ?? 0 }; + } + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) diff --git a/osu.Game/Overlays/Toolbar.cs b/osu.Game/Overlays/Toolbar.cs index 25a4c0d4f5..4f2513b130 100644 --- a/osu.Game/Overlays/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar.cs @@ -112,8 +112,8 @@ namespace osu.Game.Overlays Size = new Vector2(1, height); } - [Initializer] - private void Load(OsuConfigManager config) + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) { userButton.Text = config.Get(OsuConfig.Username); } diff --git a/osu.Game/Overlays/ToolbarButton.cs b/osu.Game/Overlays/ToolbarButton.cs index dcf6b19a3d..8fa5ff10b7 100644 --- a/osu.Game/Overlays/ToolbarButton.cs +++ b/osu.Game/Overlays/ToolbarButton.cs @@ -105,10 +105,11 @@ namespace osu.Game.Overlays tooltip1 = new SpriteText { TextSize = 22, + Font = @"Exo2.0-Bold", }, tooltip2 = new SpriteText { - TextSize = 15 + TextSize = 16 } } } diff --git a/osu.Game/Overlays/ToolbarModeButton.cs b/osu.Game/Overlays/ToolbarModeButton.cs index f9c0ee7865..7ae702918e 100644 --- a/osu.Game/Overlays/ToolbarModeButton.cs +++ b/osu.Game/Overlays/ToolbarModeButton.cs @@ -44,8 +44,8 @@ namespace osu.Game.Overlays } } - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { DrawableIcon.TextSize *= 1.4f; } diff --git a/osu.Game/Overlays/ToolbarModeSelector.cs b/osu.Game/Overlays/ToolbarModeSelector.cs index bf72d9f22f..2a384ea53e 100644 --- a/osu.Game/Overlays/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/ToolbarModeSelector.cs @@ -31,8 +31,8 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.Y; } - [Initializer] - private void Load() + [BackgroundDependencyLoader] + private void load() { Children = new Drawable[] { diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 4977317f0c..b8113853d6 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -121,13 +121,18 @@ + + + + + @@ -234,6 +239,7 @@ +