From 21f993d1492b18220168a320bab57214f22bcf4d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 15 Dec 2016 22:57:14 +0900 Subject: [PATCH 01/10] Add ability to navigate song select carousel using arrow keys. --- osu.Game/Screens/Select/CarouselContainer.cs | 68 ++++++++++++++++---- 1 file changed, 56 insertions(+), 12 deletions(-) diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index 2c59639ce7..144e4cabba 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -1,19 +1,21 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; -using osu.Framework.Caching; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Transformations; -using osu.Game.Database; -using System; -using System.Collections.Generic; -using System.Linq; -using osu.Framework.Extensions.IEnumerableExtensions; -using osu.Framework.Lists; -using osu.Game.Beatmaps.Drawables; +using OpenTK; +using osu.Framework.Caching; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Transformations; +using osu.Game.Database; +using System; +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Framework.Lists; +using osu.Game.Beatmaps.Drawables; using osu.Framework.Timing; +using osu.Framework.Input; +using OpenTK.Input; namespace osu.Game.Screens.Select { @@ -244,5 +246,47 @@ namespace osu.Game.Screens.Select updatePanel(p, halfHeight); } } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + int direction = 0; + bool skipDifficulties = false; + + switch (args.Key) + { + case Key.Up: + direction = -1; + break; + case Key.Down: + direction = 1; + break; + case Key.Left: + direction = -1; + skipDifficulties = true; + break; + case Key.Right: + direction = 1; + skipDifficulties = true; + break; + } + + if (direction != 0) + { + int index = SelectedGroup.BeatmapPanels.IndexOf(SelectedPanel) + direction; + + if (!skipDifficulties && index >= 0 && index < SelectedGroup.BeatmapPanels.Count) + //changing difficulty panel, not set. + SelectGroup(SelectedGroup, SelectedGroup.BeatmapPanels[index]); + else + { + index = (groups.IndexOf(SelectedGroup) + direction + groups.Count) % groups.Count; + SelectBeatmap(groups[index].BeatmapPanels.First().Beatmap); + } + + return true; + } + + return base.OnKeyDown(state, args); + } } } From 9557821776b5e71084a064b275fb65b567a0f768 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 15 Dec 2016 20:55:37 +0900 Subject: [PATCH 02/10] Start a map using enter key. --- osu.Game/Screens/Select/PlaySongSelect.cs | 29 +++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 9d2debb8aa..e79278a742 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -28,6 +28,8 @@ using osu.Framework.Audio.Sample; using osu.Framework.Graphics.Transformations; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics.Containers; +using osu.Framework.Input; +using OpenTK.Input; namespace osu.Game.Screens.Select { @@ -141,17 +143,22 @@ namespace osu.Game.Screens.Select Width = 100, Text = "Play", Colour = new Color4(238, 51, 153, 255), - Action = () => Push(new Player - { - BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap, - PreferredPlayMode = playMode.Value - }) + Action = start }, } } }; } + private void start() + { + Push(new Player + { + BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap, + PreferredPlayMode = playMode.Value + }); + } + [BackgroundDependencyLoader(permitNulls: true)] private void load(BeatmapDatabase beatmaps, AudioManager audio, BaseGame game, OsuGame osuGame) { @@ -343,5 +350,17 @@ namespace osu.Game.Screens.Select addBeatmapSet(beatmapSet, game); } } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + switch (args.Key) + { + case Key.Enter: + start(); + return true; + } + + return base.OnKeyDown(state, args); + } } } From 8d800dac992d0d941e80164eec78e0fe36a8b1e5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 15 Dec 2016 21:18:30 +0900 Subject: [PATCH 03/10] Make Player load async. --- osu.Game/Screens/Select/PlaySongSelect.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index e79278a742..e9e5144159 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -150,12 +150,26 @@ namespace osu.Game.Screens.Select }; } + Player player; + private void start() { - Push(new Player + if (player != null) + return; + + player = new Player { BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap, PreferredPlayMode = playMode.Value + }; + + player.Preload(Game, delegate + { + if (!Push(player)) + { + player = null; + //error occured? + } }); } @@ -206,6 +220,8 @@ namespace osu.Game.Screens.Select protected override void OnResuming(GameMode last) { + player = null; + changeBackground(Beatmap); ensurePlayingSelected(); base.OnResuming(last); From 08ef8ed8ea22b3266937f0b463da005ef54db6b9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 15 Dec 2016 21:20:27 +0900 Subject: [PATCH 04/10] Add comment about future implementation. --- osu.Game/Screens/Select/PlaySongSelect.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index e9e5144159..6e311d7dd5 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -157,6 +157,8 @@ namespace osu.Game.Screens.Select if (player != null) return; + //in the future we may want to move this logic to a PlayerLoader gamemode or similar, so we can rely on the SongSelect transition + //and provide a better loading experience (at the moment song select is still accepting input during preload). player = new Player { BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap, From 0a9e3ce1b081f053ff3cfecd6836297b657e9a9e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 15 Dec 2016 21:47:32 +0900 Subject: [PATCH 05/10] Don't handle input in triangle particle effect containers. --- osu.Game.Modes.Osu/Objects/Drawables/Pieces/Triangles.cs | 2 ++ osu.Game/Graphics/Backgrounds/Triangles.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/Triangles.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/Triangles.cs index 95f25c43d1..2025934e71 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/Triangles.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/Triangles.cs @@ -13,6 +13,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces { public class Triangles : Container { + public override bool HandleInput => false; + protected override void LoadComplete() { base.LoadComplete(); diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index 34e65f0b2a..b68b5ebc4a 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -15,6 +15,8 @@ namespace osu.Game.Graphics.Backgrounds { public class Triangles : Container { + public override bool HandleInput => false; + public Triangles() { Alpha = 0.3f; From d8e40d4fb160a5b30b3de32e5f9daba07c1d8057 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 15 Dec 2016 21:47:57 +0900 Subject: [PATCH 06/10] Add naive lifetime calculation for drawable HitObjects. --- osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs index 94694b8d5e..d18b3e2cbb 100644 --- a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs @@ -44,6 +44,8 @@ namespace osu.Game.Modes.Objects.Drawables UpdateState(state); + Expire(true); + if (State == ArmedState.Hit) PlaySample(); } @@ -75,6 +77,8 @@ namespace osu.Game.Modes.Objects.Drawables //force application of the state that was set before we loaded. UpdateState(State); + + Expire(true); } /// From cf8283582b6aa877439eb4b942efbf3c12820171 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 15 Dec 2016 22:33:11 +0900 Subject: [PATCH 07/10] Don't update LifetimeStart on HitObject state change. --- osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs index d18b3e2cbb..7ce71acf3e 100644 --- a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs @@ -44,7 +44,7 @@ namespace osu.Game.Modes.Objects.Drawables UpdateState(state); - Expire(true); + Expire(); if (State == ArmedState.Hit) PlaySample(); From ec7bbd231f8ceff76195b19c41daaf3d92c8f3c6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 15 Dec 2016 22:35:12 +0900 Subject: [PATCH 08/10] Make flash animation last slightly longer. --- osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs index ccbfbb1db3..b2179d95d0 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -134,7 +134,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables FadeOut(TIME_FADEOUT / 5); break; case ArmedState.Hit: - const double flash_in = 30; + const double flash_in = 40; flash.FadeTo(0.8f, flash_in); flash.Delay(flash_in); From 8ce18e89869b15af8bb98a8afd35169cc272eea0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 15 Dec 2016 22:48:35 +0900 Subject: [PATCH 09/10] Improve song select startup time via better database querying. Also fix difficulty displays. --- osu.Game/Beatmaps/Drawables/BeatmapGroup.cs | 2 +- osu.Game/Screens/Select/PlaySongSelect.cs | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index 3f5fe58ab5..db769bccc9 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -54,7 +54,7 @@ namespace osu.Game.Beatmaps.Drawables } } - public BeatmapGroup(WorkingBeatmap beatmap) + public BeatmapGroup(WorkingBeatmap beatmap, BeatmapSetInfo set = null) { this.beatmap = beatmap; diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 6e311d7dd5..bf4d2c84f1 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -164,7 +164,7 @@ namespace osu.Game.Screens.Select BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap, PreferredPlayMode = playMode.Value }; - + player.Preload(Game, delegate { if (!Push(player)) @@ -336,10 +336,15 @@ namespace osu.Game.Screens.Select private void addBeatmapSet(BeatmapSetInfo beatmapSet, BaseGame game) { beatmapSet = database.GetWithChildren(beatmapSet.BeatmapSetID); - beatmapSet.Beatmaps.ForEach(b => database.GetChildren(b)); + beatmapSet.Beatmaps.ForEach(b => + { + database.GetChildren(b); + if (b.Metadata == null) b.Metadata = beatmapSet.Metadata; + }); + beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.BaseDifficulty.OverallDifficulty).ToList(); - var beatmap = database.GetWorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault()); + var beatmap = new WorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault(), beatmapSet, database); var group = new BeatmapGroup(beatmap) { SelectionChanged = selectionChanged }; From 20260b43d17d17d77004c9953ac9d4b828988d0b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 15 Dec 2016 22:51:35 +0900 Subject: [PATCH 10/10] Improve star animation. --- osu.Game/Graphics/UserInterface/StarCounter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index 097362bc77..fa8ca7e5a9 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -35,7 +35,7 @@ namespace osu.Game.Graphics.UserInterface protected set; } - private double animationDelay => 150; + private double animationDelay => 80; private double scalingDuration => 500; private EasingTypes scalingEasing => EasingTypes.OutElasticHalf;