From 01985936972ab484de543c8a6a0db1d28abbb87f Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 16:29:20 +0800 Subject: [PATCH 01/17] Make BeatmapInfoWedge:OverlayContainer and unify transforms. --- osu.Game/Screens/Select/BeatmapInfoWedge.cs | 33 +++++++++++++------ osu.Game/Screens/Select/PlaySongSelect.cs | 36 ++++++++++----------- 2 files changed, 42 insertions(+), 27 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index eac12f7370..3add709c5f 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -3,27 +3,28 @@ using System; using System.Collections.Generic; -using osu.Framework.Allocation; +using System.Linq; using OpenTK; using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; -using osu.Game.Beatmaps; -using osu.Game.Database; -using osu.Framework.Graphics.Colour; -using osu.Game.Beatmaps.Drawables; -using System.Linq; +using osu.Framework.Graphics.Transforms; using osu.Framework.MathUtils; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Drawables; +using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Modes; namespace osu.Game.Screens.Select { - internal class BeatmapInfoWedge : Container + internal class BeatmapInfoWedge : OverlayContainer { private static readonly Vector2 wedged_container_shear = new Vector2(0.15f, 0); @@ -52,18 +53,32 @@ namespace osu.Game.Screens.Select this.game = game; } + protected override bool HideOnEscape => false; + + protected override void PopIn() + { + MoveToX(0, 800, EasingTypes.OutQuint); + RotateTo(0, 800, EasingTypes.OutQuint); + } + + protected override void PopOut() + { + MoveToX(-100, 800, EasingTypes.InQuint); + RotateTo(10, 800, EasingTypes.InQuint); + } + public void UpdateBeatmap(WorkingBeatmap beatmap) { if (beatmap?.BeatmapInfo == null) { - FadeOut(250); + State = Visibility.Hidden; beatmapInfoContainer?.FadeOut(250); beatmapInfoContainer?.Expire(); beatmapInfoContainer = null; return; } - FadeIn(250); + State = Visibility.Visible; var lastContainer = beatmapInfoContainer; float newDepth = lastContainer?.Depth + 1 ?? 0; diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 09ba794122..6bff6cad00 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -2,33 +2,34 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; +using OpenTK; +using OpenTK.Input; using osu.Framework.Allocation; using osu.Framework.Audio; +using osu.Framework.Audio.Sample; using osu.Framework.Audio.Track; using osu.Framework.Configuration; -using osu.Framework.Screens; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; -using osu.Game.Beatmaps; -using osu.Game.Database; -using osu.Game.Modes; -using osu.Game.Screens.Backgrounds; -using OpenTK; -using osu.Game.Screens.Play; -using osu.Framework.Audio.Sample; using osu.Framework.Graphics.Transforms; -using osu.Game.Beatmaps.Drawables; -using osu.Game.Graphics.Containers; -using osu.Game.Graphics; using osu.Framework.Input; -using OpenTK.Input; -using System.Collections.Generic; +using osu.Framework.Screens; using osu.Framework.Threading; -using osu.Game.Overlays.Mods; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Drawables; +using osu.Game.Database; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Modes; using osu.Game.Overlays; +using osu.Game.Overlays.Mods; +using osu.Game.Screens.Backgrounds; +using osu.Game.Screens.Play; using osu.Game.Screens.Select.Options; namespace osu.Game.Screens.Select @@ -129,6 +130,7 @@ namespace osu.Game.Screens.Select Top = 20, Right = 20, }, + X = -50, }, beatmapOptions = new BeatmapOptionsOverlay { @@ -259,8 +261,7 @@ namespace osu.Game.Screens.Select Content.FadeInFromZero(250); - beatmapInfoWedge.MoveToX(-50); - beatmapInfoWedge.MoveToX(0, 800, EasingTypes.OutQuint); + beatmapInfoWedge.State = Visibility.Visible; filter.Activate(); } @@ -292,8 +293,7 @@ namespace osu.Game.Screens.Select protected override bool OnExiting(Screen next) { - beatmapInfoWedge.MoveToX(-100, 800, EasingTypes.InQuint); - beatmapInfoWedge.RotateTo(10, 800, EasingTypes.InQuint); + beatmapInfoWedge.State = Visibility.Hidden; Content.FadeOut(100); From fae6afa9e3f05762676af0ffc81ee2104b9ba5b7 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 16:44:35 +0800 Subject: [PATCH 02/17] Create basic SongSelect class. --- osu.Game/Screens/Select/{PlaySongSelect.cs => SongSelect.cs} | 2 +- osu.Game/osu.Game.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename osu.Game/Screens/Select/{PlaySongSelect.cs => SongSelect.cs} (96%) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs similarity index 96% rename from osu.Game/Screens/Select/PlaySongSelect.cs rename to osu.Game/Screens/Select/SongSelect.cs index 6bff6cad00..a55d20145e 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -34,7 +34,7 @@ using osu.Game.Screens.Select.Options; namespace osu.Game.Screens.Select { - public class PlaySongSelect : OsuScreen + public class SongSelect : OsuScreen { private Bindable playMode = new Bindable(); private BeatmapDatabase database; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 7fd933c9bc..4161fd4065 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -184,7 +184,7 @@ - + From c3a0549cdd1e953534df5bd2f446d12c39fd63fd Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 16:58:34 +0800 Subject: [PATCH 03/17] Move player specific stuff to derived PlaySongSelect. --- osu.Game/Screens/Select/PlaySongSelect.cs | 30 +++++++++++++++++++++++ osu.Game/Screens/Select/SongSelect.cs | 17 ++++--------- osu.Game/osu.Game.csproj | 1 + 3 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 osu.Game/Screens/Select/PlaySongSelect.cs diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs new file mode 100644 index 0000000000..13395e52c2 --- /dev/null +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -0,0 +1,30 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Screens; +using osu.Game.Beatmaps; +using osu.Game.Screens.Play; + +namespace osu.Game.Screens.Select +{ + public class PlaySongSelect : SongSelect + { + private OsuScreen player; + + protected override void OnResuming(Screen last) + { + player = null; + base.OnResuming(last); + } + + protected override void OnSelected(WorkingBeatmap beatmap) + { + if (player != null) return; + + (player = new PlayerLoader(new Player + { + Beatmap = Beatmap, //eagerly set this so it's present before push. + })).LoadAsync(Game, l => Push(player)); + } + } +} diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index a55d20145e..d289004753 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -34,7 +34,7 @@ using osu.Game.Screens.Select.Options; namespace osu.Game.Screens.Select { - public class SongSelect : OsuScreen + public abstract class SongSelect : OsuScreen { private Bindable playMode = new Bindable(); private BeatmapDatabase database; @@ -60,8 +60,6 @@ namespace osu.Game.Screens.Select private BeatmapOptionsOverlay beatmapOptions; private Footer footer; - private OsuScreen player; - private FilterControl filter; public FilterControl Filter { @@ -158,15 +156,10 @@ namespace osu.Game.Screens.Select OnBack = Exit, OnStart = () => { - if (player != null || Beatmap == null) - return; + if (Beatmap == null) return; Beatmap.PreferredPlayMode = playMode.Value; - - (player = new PlayerLoader(new Player - { - Beatmap = Beatmap, //eagerly set this so it's present before push. - })).LoadAsync(Game, l => Push(player)); + OnSelected(Beatmap); } }, }; @@ -196,6 +189,8 @@ namespace osu.Game.Screens.Select Task.Factory.StartNew(() => addBeatmapSets(game, initialAddSetsTask.Token), initialAddSetsTask.Token); } + protected abstract void OnSelected(WorkingBeatmap beatmap); + private ScheduledDelegate filterTask; private void filterChanged(bool debounce = true, bool eagerSelection = true) @@ -268,8 +263,6 @@ namespace osu.Game.Screens.Select protected override void OnResuming(Screen last) { - player = null; - changeBackground(Beatmap); ensurePlayingSelected(); base.OnResuming(last); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 4161fd4065..402bf45977 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -184,6 +184,7 @@ + From 9a4247f67ee6dc01e48434488643b148a63eb6e9 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 16:58:34 +0800 Subject: [PATCH 04/17] Make Footer handles hotkey. --- osu.Game/Screens/Select/Footer.cs | 18 ++++++++++++-- osu.Game/Screens/Select/FooterButton.cs | 18 +++++++++++--- osu.Game/Screens/Select/SongSelect.cs | 31 +++++-------------------- 3 files changed, 37 insertions(+), 30 deletions(-) diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index 4af72cecd9..b93575ada9 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -4,11 +4,13 @@ using System; using OpenTK; using OpenTK.Graphics; +using OpenTK.Input; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transforms; +using osu.Framework.Input; using osu.Game.Graphics.UserInterface; using osu.Game.Screens.Menu; @@ -34,7 +36,7 @@ namespace osu.Game.Screens.Select public OsuLogo StartButton; - public void AddButton(string text, Color4 colour, Action action) + public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null) { var button = new FooterButton { @@ -43,6 +45,7 @@ namespace osu.Game.Screens.Select Width = play_song_select_button_width, SelectedColour = colour, DeselectedColour = colour.Opacity(0.5f), + Hotkey = hotkey, }; button.Hovered = () => updateModeLight(button); @@ -89,7 +92,7 @@ namespace osu.Game.Screens.Select { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - Action = () => OnBack?.Invoke(), + Action = () => OnBack?.Invoke() }, new FillFlowContainer { @@ -114,5 +117,16 @@ namespace osu.Game.Screens.Select updateModeLight(); } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (!args.Repeat && args.Key == Key.Enter) + { + OnStart?.Invoke(); + return true; + } + + return base.OnKeyDown(state, args); + } } } diff --git a/osu.Game/Screens/Select/FooterButton.cs b/osu.Game/Screens/Select/FooterButton.cs index daa09f03a3..2e245d205f 100644 --- a/osu.Game/Screens/Select/FooterButton.cs +++ b/osu.Game/Screens/Select/FooterButton.cs @@ -1,14 +1,15 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using OpenTK; using OpenTK.Graphics; +using OpenTK.Input; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Input; -using System; using osu.Framework.Graphics.Transforms; +using osu.Framework.Input; using osu.Game.Graphics.Sprites; namespace osu.Game.Screens.Select @@ -34,7 +35,7 @@ namespace osu.Game.Screens.Select set { deselectedColour = value; - if(light.Colour != SelectedColour) + if (light.Colour != SelectedColour) light.Colour = value; } } @@ -83,6 +84,7 @@ namespace osu.Game.Screens.Select public Action Hovered; public Action HoverLost; + public Key? Hotkey; protected override bool OnHover(InputState state) { @@ -119,5 +121,15 @@ namespace osu.Game.Screens.Select return base.OnClick(state); } + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (!args.Repeat && args.Key == Hotkey) + { + OnClick(state); + return true; + } + + return base.OnKeyDown(state, args); + } } } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index d289004753..6bddebbdb2 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -164,9 +164,9 @@ namespace osu.Game.Screens.Select }, }; - footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility); - footer.AddButton(@"random", colours.Green, carousel.SelectRandom); - footer.AddButton(@"options", colours.Blue, beatmapOptions.ToggleVisibility); + footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1); + footer.AddButton(@"random", colours.Green, carousel.SelectRandom, Key.F2); + footer.AddButton(@"options", colours.Blue, beatmapOptions.ToggleVisibility, Key.F3); if (osu != null) playMode.BindTo(osu.PlayMode); @@ -435,29 +435,10 @@ namespace osu.Game.Screens.Select protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { - if (args.Repeat) return false; - - switch (args.Key) + if (!args.Repeat && args.Key == Key.Delete && state.Keyboard.ShiftPressed) { - case Key.F1: - modSelect.ToggleVisibility(); - return true; - case Key.F2: - carousel.SelectRandom(); - return true; - case Key.F3: - beatmapOptions.ToggleVisibility(); - return true; - case Key.Enter: - footer.StartButton.TriggerClick(); - return true; - case Key.Delete: - if (state.Keyboard.ShiftPressed) - { - promptDelete(); - return true; - } - break; + promptDelete(); + return true; } return base.OnKeyDown(state, args); From c4e5eac35ba1ed6454c1755b2ea82b30015c7b53 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 18:38:06 +0800 Subject: [PATCH 05/17] Move footer stuff to derived. --- osu.Game/Screens/Select/PlaySongSelect.cs | 29 +++++++++++++++++++++ osu.Game/Screens/Select/SongSelect.cs | 31 +++++------------------ 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 13395e52c2..ea453a997c 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -1,8 +1,14 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK.Input; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Primitives; using osu.Framework.Screens; using osu.Game.Beatmaps; +using osu.Game.Graphics; +using osu.Game.Overlays.Mods; using osu.Game.Screens.Play; namespace osu.Game.Screens.Select @@ -10,6 +16,29 @@ namespace osu.Game.Screens.Select public class PlaySongSelect : SongSelect { private OsuScreen player; + private ModSelectOverlay modSelect; + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Add(modSelect = new ModSelectOverlay + { + RelativeSizeAxes = Axes.X, + Origin = Anchor.BottomCentre, + Anchor = Anchor.BottomCentre, + Margin = new MarginPadding { Bottom = 50 } + }); + + Footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1); + Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2); + Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3); + } + + protected override void OnBeatmapChanged(WorkingBeatmap beatmap) + { + beatmap?.Mods.BindTo(modSelect.SelectedMods); + base.OnBeatmapChanged(beatmap); + } protected override void OnResuming(Screen last) { diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 6bddebbdb2..e4d2ff9de1 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -27,9 +27,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Modes; using osu.Game.Overlays; -using osu.Game.Overlays.Mods; using osu.Game.Screens.Backgrounds; -using osu.Game.Screens.Play; using osu.Game.Screens.Select.Options; namespace osu.Game.Screens.Select @@ -47,8 +45,6 @@ namespace osu.Game.Screens.Select private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 225); private BeatmapInfoWedge beatmapInfoWedge; - private ModSelectOverlay modSelect; - private static readonly Vector2 background_blur = new Vector2(20); private CancellationTokenSource initialAddSetsTask; @@ -57,8 +53,8 @@ namespace osu.Game.Screens.Select private List beatmapGroups; - private BeatmapOptionsOverlay beatmapOptions; - private Footer footer; + protected BeatmapOptionsOverlay BeatmapOptions { get; private set; } + protected Footer Footer { get; private set; } private FilterControl filter; public FilterControl Filter @@ -130,7 +126,7 @@ namespace osu.Game.Screens.Select }, X = -50, }, - beatmapOptions = new BeatmapOptionsOverlay + BeatmapOptions = new BeatmapOptionsOverlay { OnRemoveFromUnplayed = null, OnClearLocalScores = null, @@ -141,17 +137,7 @@ namespace osu.Game.Screens.Select Bottom = 50, }, }, - modSelect = new ModSelectOverlay - { - RelativeSizeAxes = Axes.X, - Origin = Anchor.BottomCentre, - Anchor = Anchor.BottomCentre, - Margin = new MarginPadding - { - Bottom = 50, - }, - }, - footer = new Footer + Footer = new Footer { OnBack = Exit, OnStart = () => @@ -164,10 +150,6 @@ namespace osu.Game.Screens.Select }, }; - footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1); - footer.AddButton(@"random", colours.Green, carousel.SelectRandom, Key.F2); - footer.AddButton(@"options", colours.Blue, beatmapOptions.ToggleVisibility, Key.F3); - if (osu != null) playMode.BindTo(osu.PlayMode); playMode.ValueChanged += playMode_ValueChanged; @@ -189,6 +171,7 @@ namespace osu.Game.Screens.Select Task.Factory.StartNew(() => addBeatmapSets(game, initialAddSetsTask.Token), initialAddSetsTask.Token); } + public void SelectRandom() => carousel.SelectRandom(); protected abstract void OnSelected(WorkingBeatmap beatmap); private ScheduledDelegate filterTask; @@ -329,8 +312,6 @@ namespace osu.Game.Screens.Select { base.OnBeatmapChanged(beatmap); - beatmap?.Mods.BindTo(modSelect.SelectedMods); - //todo: change background in selectionChanged instead; support per-difficulty backgrounds. changeBackground(beatmap); carousel.SelectBeatmap(beatmap?.BeatmapInfo); @@ -382,7 +363,7 @@ namespace osu.Game.Screens.Select var group = new BeatmapGroup(beatmapSet, database) { SelectionChanged = selectionChanged, - StartRequested = b => footer.StartButton.TriggerClick() + StartRequested = b => Footer.StartButton.TriggerClick() }; //for the time being, let's completely load the difficulty panels in the background. From 3871a350f8477c8061638c2382433b8a805719d2 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 19:38:21 +0800 Subject: [PATCH 06/17] Move BeatmapOptions buttons to derived class and simplify. --- .../Select/Options/BeatmapOptionsButton.cs | 14 +++++ .../BeatmapOptionsClearLocalScoresButton.cs | 24 -------- .../Options/BeatmapOptionsDeleteButton.cs | 24 -------- .../Options/BeatmapOptionsEditButton.cs | 24 -------- .../Select/Options/BeatmapOptionsOverlay.cs | 59 ++++++------------- .../BeatmapOptionsRemoveFromUnplayedButton.cs | 24 -------- osu.Game/Screens/Select/PlaySongSelect.cs | 5 ++ osu.Game/Screens/Select/SongSelect.cs | 8 +-- osu.Game/osu.Game.csproj | 4 -- 9 files changed, 40 insertions(+), 146 deletions(-) delete mode 100644 osu.Game/Screens/Select/Options/BeatmapOptionsClearLocalScoresButton.cs delete mode 100644 osu.Game/Screens/Select/Options/BeatmapOptionsDeleteButton.cs delete mode 100644 osu.Game/Screens/Select/Options/BeatmapOptionsEditButton.cs delete mode 100644 osu.Game/Screens/Select/Options/BeatmapOptionsRemoveFromUnplayedButton.cs diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs index 32901ad919..cfe8eea07f 100644 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs +++ b/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs @@ -3,6 +3,7 @@ using OpenTK; using OpenTK.Graphics; +using OpenTK.Input; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -48,6 +49,8 @@ namespace osu.Game.Screens.Select.Options set { secondLine.Text = value; } } + public Key? HotKey; + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { flash.FadeTo(0.1f, 1000, EasingTypes.OutQuint); @@ -69,6 +72,17 @@ namespace osu.Game.Screens.Select.Options return base.OnClick(state); } + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (!args.Repeat && args.Key == HotKey) + { + OnClick(state); + return true; + } + + return false; + } + public override bool Contains(Vector2 screenSpacePos) => box.Contains(screenSpacePos); public BeatmapOptionsButton() diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsClearLocalScoresButton.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsClearLocalScoresButton.cs deleted file mode 100644 index 66a6dac358..0000000000 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsClearLocalScoresButton.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Allocation; -using osu.Game.Graphics; - -namespace osu.Game.Screens.Select.Options -{ - public class BeatmapOptionsClearLocalScoresButton : BeatmapOptionsButton - { - [BackgroundDependencyLoader] - private void load(OsuColour colour) - { - ButtonColour = colour.Purple; - } - - public BeatmapOptionsClearLocalScoresButton() - { - Icon = FontAwesome.fa_eraser; - FirstLineText = @"Clear"; - SecondLineText = @"local scores"; - } - } -} diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsDeleteButton.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsDeleteButton.cs deleted file mode 100644 index 563cf41a87..0000000000 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsDeleteButton.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Allocation; -using osu.Game.Graphics; - -namespace osu.Game.Screens.Select.Options -{ - public class BeatmapOptionsDeleteButton : BeatmapOptionsButton - { - [BackgroundDependencyLoader] - private void load(OsuColour colour) - { - ButtonColour = colour.Pink; - } - - public BeatmapOptionsDeleteButton() - { - Icon = FontAwesome.fa_trash; - FirstLineText = @"Delete"; - SecondLineText = @"Beatmap"; - } - } -} diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsEditButton.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsEditButton.cs deleted file mode 100644 index f88c0df168..0000000000 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsEditButton.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Allocation; -using osu.Game.Graphics; - -namespace osu.Game.Screens.Select.Options -{ - public class BeatmapOptionsEditButton : BeatmapOptionsButton - { - [BackgroundDependencyLoader] - private void load(OsuColour colour) - { - ButtonColour = colour.Yellow; - } - - public BeatmapOptionsEditButton() - { - Icon = FontAwesome.fa_pencil; - FirstLineText = @"Edit"; - SecondLineText = @"Beatmap"; - } - } -} diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs index 2c327b3658..f23962875f 100644 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs +++ b/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs @@ -6,11 +6,13 @@ using System.Collections.Generic; using System.Linq; using OpenTK; using OpenTK.Graphics; +using OpenTK.Input; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transforms; +using osu.Game.Graphics; namespace osu.Game.Screens.Select.Options { @@ -24,11 +26,6 @@ namespace osu.Game.Screens.Select.Options private Box holder; private FillFlowContainer buttonsContainer; - public Action OnRemoveFromUnplayed; - public Action OnClearLocalScores; - public Action OnEdit; - public Action OnDelete; - protected override void PopIn() { base.PopIn(); @@ -85,45 +82,27 @@ namespace osu.Game.Screens.Select.Options AutoSizeAxes = Axes.X, Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, - Children = new BeatmapOptionsButton[] - { - new BeatmapOptionsRemoveFromUnplayedButton - { - Action = () => - { - Hide(); - OnRemoveFromUnplayed?.Invoke(); - }, - }, - new BeatmapOptionsClearLocalScoresButton - { - Action = () => - { - Hide(); - OnClearLocalScores?.Invoke(); - }, - }, - new BeatmapOptionsEditButton - { - Action = () => - { - Hide(); - OnEdit?.Invoke(); - }, - }, - new BeatmapOptionsDeleteButton - { - Action = () => - { - Hide(); - OnDelete?.Invoke(); - }, - }, - }, }, }; } + public void AddButton(string firstLine, string secongLine, FontAwesome icon, Color4 colour, Action action, Key? hotkey = null) + { + buttonsContainer.Add(new BeatmapOptionsButton + { + FirstLineText = firstLine, + SecondLineText = secongLine, + Icon = icon, + ButtonColour = colour, + Action = () => + { + Hide(); + action?.Invoke(); + }, + HotKey = hotkey + }); + } + private class ButtonFlow : FillFlowContainer { protected override IComparer DepthComparer => new ReverseCreationOrderDepthComparer(); diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsRemoveFromUnplayedButton.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsRemoveFromUnplayedButton.cs deleted file mode 100644 index eeab78ef02..0000000000 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsRemoveFromUnplayedButton.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Allocation; -using osu.Game.Graphics; - -namespace osu.Game.Screens.Select.Options -{ - public class BeatmapOptionsRemoveFromUnplayedButton : BeatmapOptionsButton - { - [BackgroundDependencyLoader] - private void load(OsuColour colour) - { - ButtonColour = colour.Purple; - } - - public BeatmapOptionsRemoveFromUnplayedButton() - { - Icon = FontAwesome.fa_times_circle_o; - FirstLineText = @"Remove"; - SecondLineText = @"from Unplayed"; - } - } -} diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index ea453a997c..5a73acc737 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -32,6 +32,11 @@ namespace osu.Game.Screens.Select Footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1); Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2); Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3); + + BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1); + BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, null, Key.Number2); + BeatmapOptions.AddButton(@"Edit", @"Beatmap", FontAwesome.fa_pencil, colours.Yellow, null, Key.Number3); + BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, PromptDelete, Key.Number4); } protected override void OnBeatmapChanged(WorkingBeatmap beatmap) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index e4d2ff9de1..8150f42e87 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -128,10 +128,6 @@ namespace osu.Game.Screens.Select }, BeatmapOptions = new BeatmapOptionsOverlay { - OnRemoveFromUnplayed = null, - OnClearLocalScores = null, - OnEdit = null, - OnDelete = promptDelete, Margin = new MarginPadding { Bottom = 50, @@ -408,7 +404,7 @@ namespace osu.Game.Screens.Select } } - private void promptDelete() + protected void PromptDelete() { if (Beatmap != null) dialogOverlay?.Push(new BeatmapDeleteDialog(Beatmap)); @@ -418,7 +414,7 @@ namespace osu.Game.Screens.Select { if (!args.Repeat && args.Key == Key.Delete && state.Keyboard.ShiftPressed) { - promptDelete(); + PromptDelete(); return true; } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 402bf45977..1bfe613b81 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -324,11 +324,7 @@ - - - - From 618e8e822b1ce356d57863b3e35f8089faa2b8cf Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 19:53:20 +0800 Subject: [PATCH 07/17] Implement EditSongSelect and MatchSongSelect. --- osu.Game/Screens/Edit/Editor.cs | 11 +++++++++-- osu.Game/Screens/Select/EditSongSelect.cs | 21 +++++++++++++-------- osu.Game/Screens/Select/MatchSongSelect.cs | 17 ++++++++++++++--- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 9d98a0f165..3598a3df45 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -1,14 +1,21 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Screens; -using osu.Game.Screens.Backgrounds; using OpenTK.Graphics; +using osu.Framework.Screens; +using osu.Game.Beatmaps; +using osu.Game.Screens.Backgrounds; namespace osu.Game.Screens.Edit { internal class Editor : ScreenWhiteBox { + private WorkingBeatmap beatmap; + public Editor(WorkingBeatmap wokringBeatmap) + { + beatmap = wokringBeatmap; + } + protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); protected override void OnEntering(Screen last) diff --git a/osu.Game/Screens/Select/EditSongSelect.cs b/osu.Game/Screens/Select/EditSongSelect.cs index 4d07de2de8..7ecb35de03 100644 --- a/osu.Game/Screens/Select/EditSongSelect.cs +++ b/osu.Game/Screens/Select/EditSongSelect.cs @@ -1,19 +1,24 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -using System.Collections.Generic; -using osu.Game.Screens.Backgrounds; +using OpenTK.Input; +using osu.Framework.Allocation; +using osu.Game.Beatmaps; +using osu.Game.Graphics; using osu.Game.Screens.Edit; namespace osu.Game.Screens.Select { - internal class EditSongSelect : ScreenWhiteBox + internal class EditSongSelect : SongSelect { - protected override IEnumerable PossibleChildren => new[] { - typeof(Editor) - }; + protected override void OnSelected(WorkingBeatmap beatmap) => Push(new Editor(beatmap)); + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2); + Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3); - protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); + BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, PromptDelete, Key.Number4); + } } } diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index 5be41edd23..80324d02b0 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -1,12 +1,23 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Game.Screens.Backgrounds; +using OpenTK.Input; +using osu.Framework.Allocation; +using osu.Game.Beatmaps; +using osu.Game.Graphics; namespace osu.Game.Screens.Select { - internal class MatchSongSelect : ScreenWhiteBox + internal class MatchSongSelect : SongSelect { - protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); + protected override void OnSelected(WorkingBeatmap beatmap) => Exit(); + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2); + Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3); + + BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, PromptDelete, Key.Number4); + } } } From 35a60a8f7d9a5822c9b64137fe78ddaac539634d Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 20:18:14 +0800 Subject: [PATCH 08/17] Use depth to arrange buttons. --- osu.Game/Screens/Select/EditSongSelect.cs | 11 ----------- osu.Game/Screens/Select/Footer.cs | 7 ++++++- osu.Game/Screens/Select/MatchSongSelect.cs | 11 ----------- .../Screens/Select/Options/BeatmapOptionsOverlay.cs | 7 ++++++- osu.Game/Screens/Select/PlaySongSelect.cs | 5 +---- osu.Game/Screens/Select/SongSelect.cs | 9 +++++++-- 6 files changed, 20 insertions(+), 30 deletions(-) diff --git a/osu.Game/Screens/Select/EditSongSelect.cs b/osu.Game/Screens/Select/EditSongSelect.cs index 7ecb35de03..3d5b436199 100644 --- a/osu.Game/Screens/Select/EditSongSelect.cs +++ b/osu.Game/Screens/Select/EditSongSelect.cs @@ -1,10 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK.Input; -using osu.Framework.Allocation; using osu.Game.Beatmaps; -using osu.Game.Graphics; using osu.Game.Screens.Edit; namespace osu.Game.Screens.Select @@ -12,13 +9,5 @@ namespace osu.Game.Screens.Select internal class EditSongSelect : SongSelect { protected override void OnSelected(WorkingBeatmap beatmap) => Push(new Editor(beatmap)); - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2); - Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3); - - BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, PromptDelete, Key.Number4); - } } } diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index b93575ada9..18d9516eaa 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -36,13 +36,18 @@ namespace osu.Game.Screens.Select public OsuLogo StartButton; - public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null) + /// + /// Higher depth to be put on the left, and lower to be put on the right. + /// Notice this is different to ! + /// + public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0) { var button = new FooterButton { Text = text, Height = play_song_select_button_height, Width = play_song_select_button_width, + Depth = depth, SelectedColour = colour, DeselectedColour = colour.Opacity(0.5f), Hotkey = hotkey, diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index 80324d02b0..fa13c8b0e9 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -1,23 +1,12 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK.Input; -using osu.Framework.Allocation; using osu.Game.Beatmaps; -using osu.Game.Graphics; namespace osu.Game.Screens.Select { internal class MatchSongSelect : SongSelect { protected override void OnSelected(WorkingBeatmap beatmap) => Exit(); - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2); - Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3); - - BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, PromptDelete, Key.Number4); - } } } diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs index f23962875f..1fb2680b6a 100644 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs +++ b/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs @@ -86,7 +86,11 @@ namespace osu.Game.Screens.Select.Options }; } - public void AddButton(string firstLine, string secongLine, FontAwesome icon, Color4 colour, Action action, Key? hotkey = null) + /// + /// Lower depth to be put on the left, and higher to be put on the right. + /// Notice this is different to ! + /// + public void AddButton(string firstLine, string secongLine, FontAwesome icon, Color4 colour, Action action, Key? hotkey = null, float depth = 0) { buttonsContainer.Add(new BeatmapOptionsButton { @@ -94,6 +98,7 @@ namespace osu.Game.Screens.Select.Options SecondLineText = secongLine, Icon = icon, ButtonColour = colour, + Depth = depth, Action = () => { Hide(); diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 5a73acc737..c3c1d06abd 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -29,14 +29,11 @@ namespace osu.Game.Screens.Select Margin = new MarginPadding { Bottom = 50 } }); - Footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1); - Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2); - Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3); + Footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1, float.MaxValue); BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1); BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, null, Key.Number2); BeatmapOptions.AddButton(@"Edit", @"Beatmap", FontAwesome.fa_pencil, colours.Yellow, null, Key.Number3); - BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, PromptDelete, Key.Number4); } protected override void OnBeatmapChanged(WorkingBeatmap beatmap) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 8150f42e87..41f297a802 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -146,6 +146,11 @@ namespace osu.Game.Screens.Select }, }; + Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2); + Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3); + + BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, promptDelete, Key.Number4, float.MaxValue); + if (osu != null) playMode.BindTo(osu.PlayMode); playMode.ValueChanged += playMode_ValueChanged; @@ -404,7 +409,7 @@ namespace osu.Game.Screens.Select } } - protected void PromptDelete() + private void promptDelete() { if (Beatmap != null) dialogOverlay?.Push(new BeatmapDeleteDialog(Beatmap)); @@ -414,7 +419,7 @@ namespace osu.Game.Screens.Select { if (!args.Repeat && args.Key == Key.Delete && state.Keyboard.ShiftPressed) { - PromptDelete(); + promptDelete(); return true; } From beb0a8ff03553892f947345b2b40fcd15592e922 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 20:36:11 +0800 Subject: [PATCH 09/17] Auto assign hotkeys for BeatmapOptionsButton. --- .../Select/Options/BeatmapOptionsButton.cs | 14 ------------- .../Select/Options/BeatmapOptionsOverlay.cs | 21 +++++++++++++++++-- osu.Game/Screens/Select/PlaySongSelect.cs | 6 +++--- osu.Game/Screens/Select/SongSelect.cs | 2 +- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs index cfe8eea07f..32901ad919 100644 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs +++ b/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs @@ -3,7 +3,6 @@ using OpenTK; using OpenTK.Graphics; -using OpenTK.Input; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -49,8 +48,6 @@ namespace osu.Game.Screens.Select.Options set { secondLine.Text = value; } } - public Key? HotKey; - protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { flash.FadeTo(0.1f, 1000, EasingTypes.OutQuint); @@ -72,17 +69,6 @@ namespace osu.Game.Screens.Select.Options return base.OnClick(state); } - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) - { - if (!args.Repeat && args.Key == HotKey) - { - OnClick(state); - return true; - } - - return false; - } - public override bool Contains(Vector2 screenSpacePos) => box.Contains(screenSpacePos); public BeatmapOptionsButton() diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs index 1fb2680b6a..09991df6f9 100644 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs +++ b/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs @@ -12,6 +12,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transforms; +using osu.Framework.Input; using osu.Game.Graphics; namespace osu.Game.Screens.Select.Options @@ -90,7 +91,7 @@ namespace osu.Game.Screens.Select.Options /// Lower depth to be put on the left, and higher to be put on the right. /// Notice this is different to ! /// - public void AddButton(string firstLine, string secongLine, FontAwesome icon, Color4 colour, Action action, Key? hotkey = null, float depth = 0) + public void AddButton(string firstLine, string secongLine, FontAwesome icon, Color4 colour, Action action, float depth = 0) { buttonsContainer.Add(new BeatmapOptionsButton { @@ -104,10 +105,26 @@ namespace osu.Game.Screens.Select.Options Hide(); action?.Invoke(); }, - HotKey = hotkey }); } + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (args.Repeat) return false; + int index = (int)args.Key - (int)Key.Number1; + if (index >= 0 && index <= 9) + { + // Children of ButtonFlow is reversed. The same reason of depth in AddButton. + var button = buttonsContainer.Children.Reverse().ElementAtOrDefault(index); + if (button != null) + { + button.TriggerClick(); + return true; + } + } + return base.OnKeyDown(state, args); + } + private class ButtonFlow : FillFlowContainer { protected override IComparer DepthComparer => new ReverseCreationOrderDepthComparer(); diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index c3c1d06abd..b403b09536 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -31,9 +31,9 @@ namespace osu.Game.Screens.Select Footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1, float.MaxValue); - BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1); - BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, null, Key.Number2); - BeatmapOptions.AddButton(@"Edit", @"Beatmap", FontAwesome.fa_pencil, colours.Yellow, null, Key.Number3); + BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null); + BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, null); + BeatmapOptions.AddButton(@"Edit", @"Beatmap", FontAwesome.fa_pencil, colours.Yellow, null); } protected override void OnBeatmapChanged(WorkingBeatmap beatmap) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 41f297a802..3c7c568c4d 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -149,7 +149,7 @@ namespace osu.Game.Screens.Select Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2); Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3); - BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, promptDelete, Key.Number4, float.MaxValue); + BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, promptDelete, float.MaxValue); if (osu != null) playMode.BindTo(osu.PlayMode); From c939897a8af0c8ea43ae679d2cdabbb99e0a6213 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 21:13:57 +0800 Subject: [PATCH 10/17] Revert "Auto assign hotkeys for BeatmapOptionsButton." This reverts commit beb0a8ff03553892f947345b2b40fcd15592e922. --- .../Select/Options/BeatmapOptionsButton.cs | 14 +++++++++++++ .../Select/Options/BeatmapOptionsOverlay.cs | 21 ++----------------- osu.Game/Screens/Select/PlaySongSelect.cs | 6 +++--- osu.Game/Screens/Select/SongSelect.cs | 2 +- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs index 32901ad919..cfe8eea07f 100644 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs +++ b/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs @@ -3,6 +3,7 @@ using OpenTK; using OpenTK.Graphics; +using OpenTK.Input; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -48,6 +49,8 @@ namespace osu.Game.Screens.Select.Options set { secondLine.Text = value; } } + public Key? HotKey; + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { flash.FadeTo(0.1f, 1000, EasingTypes.OutQuint); @@ -69,6 +72,17 @@ namespace osu.Game.Screens.Select.Options return base.OnClick(state); } + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (!args.Repeat && args.Key == HotKey) + { + OnClick(state); + return true; + } + + return false; + } + public override bool Contains(Vector2 screenSpacePos) => box.Contains(screenSpacePos); public BeatmapOptionsButton() diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs index 09991df6f9..1fb2680b6a 100644 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs +++ b/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs @@ -12,7 +12,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transforms; -using osu.Framework.Input; using osu.Game.Graphics; namespace osu.Game.Screens.Select.Options @@ -91,7 +90,7 @@ namespace osu.Game.Screens.Select.Options /// Lower depth to be put on the left, and higher to be put on the right. /// Notice this is different to ! /// - public void AddButton(string firstLine, string secongLine, FontAwesome icon, Color4 colour, Action action, float depth = 0) + public void AddButton(string firstLine, string secongLine, FontAwesome icon, Color4 colour, Action action, Key? hotkey = null, float depth = 0) { buttonsContainer.Add(new BeatmapOptionsButton { @@ -105,26 +104,10 @@ namespace osu.Game.Screens.Select.Options Hide(); action?.Invoke(); }, + HotKey = hotkey }); } - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) - { - if (args.Repeat) return false; - int index = (int)args.Key - (int)Key.Number1; - if (index >= 0 && index <= 9) - { - // Children of ButtonFlow is reversed. The same reason of depth in AddButton. - var button = buttonsContainer.Children.Reverse().ElementAtOrDefault(index); - if (button != null) - { - button.TriggerClick(); - return true; - } - } - return base.OnKeyDown(state, args); - } - private class ButtonFlow : FillFlowContainer { protected override IComparer DepthComparer => new ReverseCreationOrderDepthComparer(); diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index b403b09536..c3c1d06abd 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -31,9 +31,9 @@ namespace osu.Game.Screens.Select Footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1, float.MaxValue); - BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null); - BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, null); - BeatmapOptions.AddButton(@"Edit", @"Beatmap", FontAwesome.fa_pencil, colours.Yellow, null); + BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1); + BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, null, Key.Number2); + BeatmapOptions.AddButton(@"Edit", @"Beatmap", FontAwesome.fa_pencil, colours.Yellow, null, Key.Number3); } protected override void OnBeatmapChanged(WorkingBeatmap beatmap) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 3c7c568c4d..41f297a802 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -149,7 +149,7 @@ namespace osu.Game.Screens.Select Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2); Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3); - BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, promptDelete, float.MaxValue); + BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, promptDelete, Key.Number4, float.MaxValue); if (osu != null) playMode.BindTo(osu.PlayMode); From f97e8ae97f2481affbf34e85e3e7f323290fd9d9 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 21:20:38 +0800 Subject: [PATCH 11/17] Fix typo and warnings. --- osu.Game/Screens/Edit/Editor.cs | 6 +++--- osu.Game/Screens/Select/Footer.cs | 4 ++++ .../Screens/Select/Options/BeatmapOptionsOverlay.cs | 10 ++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 3598a3df45..d2bc4a014c 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -10,10 +10,10 @@ namespace osu.Game.Screens.Edit { internal class Editor : ScreenWhiteBox { - private WorkingBeatmap beatmap; - public Editor(WorkingBeatmap wokringBeatmap) + //private WorkingBeatmap beatmap; + public Editor(WorkingBeatmap workingBeatmap) { - beatmap = wokringBeatmap; + //beatmap = workingBeatmap; } protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index 18d9516eaa..a79f518c51 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -36,6 +36,10 @@ namespace osu.Game.Screens.Select public OsuLogo StartButton; + /// Text on the button. + /// Colour of the button. + /// Hotkey of the button. + /// Action the button does. /// /// Higher depth to be put on the left, and lower to be put on the right. /// Notice this is different to ! diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs index 1fb2680b6a..690669ffc1 100644 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs +++ b/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs @@ -86,16 +86,22 @@ namespace osu.Game.Screens.Select.Options }; } + /// Text in the first line. + /// Text in the second line. + /// Colour of the button. + /// Icon of the button. + /// Hotkey of the button. + /// Action the button does. /// /// Lower depth to be put on the left, and higher to be put on the right. /// Notice this is different to ! /// - public void AddButton(string firstLine, string secongLine, FontAwesome icon, Color4 colour, Action action, Key? hotkey = null, float depth = 0) + public void AddButton(string firstLine, string secondLine, FontAwesome icon, Color4 colour, Action action, Key? hotkey = null, float depth = 0) { buttonsContainer.Add(new BeatmapOptionsButton { FirstLineText = firstLine, - SecondLineText = secongLine, + SecondLineText = secondLine, Icon = icon, ButtonColour = colour, Depth = depth, From 259d39c6adf5bb51dc1835c992af62e2e3dac427 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 21:28:33 +0800 Subject: [PATCH 12/17] Stop playing the track in editor to avoid unused member warning --- osu.Game/Screens/Edit/Editor.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index d2bc4a014c..47fc1c9f81 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -10,10 +10,10 @@ namespace osu.Game.Screens.Edit { internal class Editor : ScreenWhiteBox { - //private WorkingBeatmap beatmap; + private WorkingBeatmap beatmap; public Editor(WorkingBeatmap workingBeatmap) { - //beatmap = workingBeatmap; + beatmap = workingBeatmap; } protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); @@ -22,11 +22,13 @@ namespace osu.Game.Screens.Edit { base.OnEntering(last); Background.Schedule(() => Background.FadeColour(Color4.DarkGray, 500)); + beatmap.Track?.Stop(); } protected override bool OnExiting(Screen next) { Background.Schedule(() => Background.FadeColour(Color4.White, 500)); + beatmap.Track?.Start(); return base.OnExiting(next); } } From f068f7c4bda3f1ec1b850d77b2e26979ae839b0b Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 21:51:26 +0800 Subject: [PATCH 13/17] No footer in EditSongSelect. --- osu.Game/Screens/Select/EditSongSelect.cs | 1 + osu.Game/Screens/Select/Footer.cs | 11 -- osu.Game/Screens/Select/MatchSongSelect.cs | 1 + osu.Game/Screens/Select/PlaySongSelect.cs | 7 +- osu.Game/Screens/Select/SongSelect.cs | 143 ++++++++++++--------- 5 files changed, 89 insertions(+), 74 deletions(-) diff --git a/osu.Game/Screens/Select/EditSongSelect.cs b/osu.Game/Screens/Select/EditSongSelect.cs index 3d5b436199..fcea3a006e 100644 --- a/osu.Game/Screens/Select/EditSongSelect.cs +++ b/osu.Game/Screens/Select/EditSongSelect.cs @@ -8,6 +8,7 @@ namespace osu.Game.Screens.Select { internal class EditSongSelect : SongSelect { + public EditSongSelect() : base(false) { } protected override void OnSelected(WorkingBeatmap beatmap) => Push(new Editor(beatmap)); } } diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index a79f518c51..c913085a05 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -126,16 +126,5 @@ namespace osu.Game.Screens.Select updateModeLight(); } - - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) - { - if (!args.Repeat && args.Key == Key.Enter) - { - OnStart?.Invoke(); - return true; - } - - return base.OnKeyDown(state, args); - } } } diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index fa13c8b0e9..d8972a4b2d 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -7,6 +7,7 @@ namespace osu.Game.Screens.Select { internal class MatchSongSelect : SongSelect { + public MatchSongSelect() : base(true) { } protected override void OnSelected(WorkingBeatmap beatmap) => Exit(); } } diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index c3c1d06abd..f4cd432fde 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -18,8 +18,7 @@ namespace osu.Game.Screens.Select private OsuScreen player; private ModSelectOverlay modSelect; - [BackgroundDependencyLoader] - private void load(OsuColour colours) + public PlaySongSelect() : base(true) { Add(modSelect = new ModSelectOverlay { @@ -28,7 +27,11 @@ namespace osu.Game.Screens.Select Anchor = Anchor.BottomCentre, Margin = new MarginPadding { Bottom = 50 } }); + } + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { Footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1, float.MaxValue); BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1); diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 41f297a802..e16f580901 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -53,7 +53,13 @@ namespace osu.Game.Screens.Select private List beatmapGroups; + /// + /// Can be null if hasFooter:false in constructor + /// protected BeatmapOptionsOverlay BeatmapOptions { get; private set; } + /// + /// Can be null if hasFooter:false in constructor + /// protected Footer Footer { get; private set; } private FilterControl filter; @@ -73,83 +79,80 @@ namespace osu.Game.Screens.Select } } - [BackgroundDependencyLoader(permitNulls: true)] - private void load(BeatmapDatabase beatmaps, AudioManager audio, DialogOverlay dialog, Framework.Game game, - OsuGame osu, OsuColour colours) + protected SongSelect(bool hasFooter) { const float carousel_width = 640; const float filter_height = 100; beatmapGroups = new List(); - Children = new Drawable[] + Add(new ParallaxContainer { - new ParallaxContainer + Padding = new MarginPadding { Top = filter_height }, + ParallaxAmount = 0.005f, + RelativeSizeAxes = Axes.Both, + Children = new[] { - Padding = new MarginPadding { Top = filter_height }, - ParallaxAmount = 0.005f, - RelativeSizeAxes = Axes.Both, - Children = new[] + new WedgeBackground { - new WedgeBackground - { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding - { - Right = carousel_width * 0.76f - }, - }, + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Right = carousel_width * 0.76f }, } - }, - carousel = new CarouselContainer + } + }); + Add(carousel = new CarouselContainer + { + RelativeSizeAxes = Axes.Y, + Size = new Vector2(carousel_width, 1), + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + }); + Add(filter = new FilterControl + { + RelativeSizeAxes = Axes.X, + Height = filter_height, + FilterChanged = () => filterChanged(), + Exit = Exit, + }); + Add(beatmapInfoWedge = new BeatmapInfoWedge + { + Alpha = 0, + Size = wedged_container_size, + RelativeSizeAxes = Axes.X, + Margin = new MarginPadding { - RelativeSizeAxes = Axes.Y, - Size = new Vector2(carousel_width, 1), - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, + Top = 20, + Right = 20, }, - filter = new FilterControl - { - RelativeSizeAxes = Axes.X, - Height = filter_height, - FilterChanged = () => filterChanged(), - Exit = Exit, - }, - beatmapInfoWedge = new BeatmapInfoWedge - { - Alpha = 0, - Size = wedged_container_size, - RelativeSizeAxes = Axes.X, - Margin = new MarginPadding - { - Top = 20, - Right = 20, - }, - X = -50, - }, - BeatmapOptions = new BeatmapOptionsOverlay + X = -50, + }); + if (hasFooter) + { + Add(BeatmapOptions = new BeatmapOptionsOverlay { Margin = new MarginPadding { Bottom = 50, }, - }, - Footer = new Footer + }); + Add(Footer = new Footer { OnBack = Exit, - OnStart = () => - { - if (Beatmap == null) return; + OnStart = raiseSelect, + }); + } + } - Beatmap.PreferredPlayMode = playMode.Value; - OnSelected(Beatmap); - } - }, - }; + [BackgroundDependencyLoader(permitNulls: true)] + private void load(BeatmapDatabase beatmaps, AudioManager audio, DialogOverlay dialog, Framework.Game game, + OsuGame osu, OsuColour colours) + { + if (Footer != null) + { + Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2); + Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3); - Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2); - Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3); - - BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, promptDelete, Key.Number4, float.MaxValue); + BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, promptDelete, Key.Number4, float.MaxValue); + } if (osu != null) playMode.BindTo(osu.PlayMode); @@ -172,6 +175,14 @@ namespace osu.Game.Screens.Select Task.Factory.StartNew(() => addBeatmapSets(game, initialAddSetsTask.Token), initialAddSetsTask.Token); } + private void raiseSelect() + { + if (Beatmap == null) return; + + Beatmap.PreferredPlayMode = playMode.Value; + OnSelected(Beatmap); + } + public void SelectRandom() => carousel.SelectRandom(); protected abstract void OnSelected(WorkingBeatmap beatmap); @@ -364,7 +375,7 @@ namespace osu.Game.Screens.Select var group = new BeatmapGroup(beatmapSet, database) { SelectionChanged = selectionChanged, - StartRequested = b => Footer.StartButton.TriggerClick() + StartRequested = b => raiseSelect() }; //for the time being, let's completely load the difficulty panels in the background. @@ -417,10 +428,20 @@ namespace osu.Game.Screens.Select protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { - if (!args.Repeat && args.Key == Key.Delete && state.Keyboard.ShiftPressed) + if (args.Repeat) return false; + + switch (args.Key) { - promptDelete(); - return true; + case Key.Enter: + raiseSelect(); + return true; + case Key.Delete: + if (state.Keyboard.ShiftPressed) + { + promptDelete(); + return true; + } + break; } return base.OnKeyDown(state, args); From b2dd9afcf3cd6c607671a8fed413254e5397bc70 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 22:18:40 +0800 Subject: [PATCH 14/17] Update editor workflow and make edit button works. --- osu.Game/Screens/Edit/Editor.cs | 20 ++++++++++++-------- osu.Game/Screens/Menu/MainMenu.cs | 3 ++- osu.Game/Screens/Select/EditSongSelect.cs | 3 +-- osu.Game/Screens/Select/PlaySongSelect.cs | 7 ++++++- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 47fc1c9f81..3baa79aa1a 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -1,34 +1,38 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; +using System.Collections.Generic; using OpenTK.Graphics; using osu.Framework.Screens; -using osu.Game.Beatmaps; using osu.Game.Screens.Backgrounds; +using osu.Game.Screens.Select; namespace osu.Game.Screens.Edit { internal class Editor : ScreenWhiteBox { - private WorkingBeatmap beatmap; - public Editor(WorkingBeatmap workingBeatmap) - { - beatmap = workingBeatmap; - } + protected override IEnumerable PossibleChildren => new Type[] { typeof(EditSongSelect) }; protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); + protected override void OnResuming(Screen last) + { + Beatmap?.Track?.Stop(); + base.OnResuming(last); + } + protected override void OnEntering(Screen last) { base.OnEntering(last); Background.Schedule(() => Background.FadeColour(Color4.DarkGray, 500)); - beatmap.Track?.Stop(); + Beatmap?.Track?.Stop(); } protected override bool OnExiting(Screen next) { Background.Schedule(() => Background.FadeColour(Color4.White, 500)); - beatmap.Track?.Start(); + Beatmap?.Track?.Start(); return base.OnExiting(next); } } diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 7053face9d..33bffef219 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -10,6 +10,7 @@ using osu.Game.Graphics.Containers; using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Charts; using osu.Game.Screens.Direct; +using osu.Game.Screens.Edit; using osu.Game.Screens.Multiplayer; using OpenTK; using osu.Game.Screens.Select; @@ -44,7 +45,7 @@ namespace osu.Game.Screens.Menu { OnChart = delegate { Push(new ChartListing()); }, OnDirect = delegate { Push(new OnlineListing()); }, - OnEdit = delegate { Push(new EditSongSelect()); }, + OnEdit = delegate { Push(new Editor()); }, OnSolo = delegate { Push(new PlaySongSelect()); }, OnMulti = delegate { Push(new Lobby()); }, OnTest = delegate { Push(new TestBrowser()); }, diff --git a/osu.Game/Screens/Select/EditSongSelect.cs b/osu.Game/Screens/Select/EditSongSelect.cs index fcea3a006e..03ed5a3282 100644 --- a/osu.Game/Screens/Select/EditSongSelect.cs +++ b/osu.Game/Screens/Select/EditSongSelect.cs @@ -2,13 +2,12 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Game.Beatmaps; -using osu.Game.Screens.Edit; namespace osu.Game.Screens.Select { internal class EditSongSelect : SongSelect { public EditSongSelect() : base(false) { } - protected override void OnSelected(WorkingBeatmap beatmap) => Push(new Editor(beatmap)); + protected override void OnSelected(WorkingBeatmap beatmap) => Exit(); } } diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index f4cd432fde..f22ba322e0 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -9,6 +9,7 @@ using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Overlays.Mods; +using osu.Game.Screens.Edit; using osu.Game.Screens.Play; namespace osu.Game.Screens.Select @@ -36,7 +37,11 @@ namespace osu.Game.Screens.Select BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1); BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, null, Key.Number2); - BeatmapOptions.AddButton(@"Edit", @"Beatmap", FontAwesome.fa_pencil, colours.Yellow, null, Key.Number3); + BeatmapOptions.AddButton(@"Edit", @"Beatmap", FontAwesome.fa_pencil, colours.Yellow, () => + { + ValidForResume = false; + Push(new Editor()); + }, Key.Number3); } protected override void OnBeatmapChanged(WorkingBeatmap beatmap) From a8d15e616b40017694d3c9be602481a52b3dcba8 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 22:22:23 +0800 Subject: [PATCH 15/17] Remove parameter of OnSelected. --- osu.Game/Screens/Select/EditSongSelect.cs | 4 +--- osu.Game/Screens/Select/MatchSongSelect.cs | 4 +--- osu.Game/Screens/Select/PlaySongSelect.cs | 2 +- osu.Game/Screens/Select/SongSelect.cs | 4 ++-- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Select/EditSongSelect.cs b/osu.Game/Screens/Select/EditSongSelect.cs index 03ed5a3282..5ad0107d91 100644 --- a/osu.Game/Screens/Select/EditSongSelect.cs +++ b/osu.Game/Screens/Select/EditSongSelect.cs @@ -1,13 +1,11 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Game.Beatmaps; - namespace osu.Game.Screens.Select { internal class EditSongSelect : SongSelect { public EditSongSelect() : base(false) { } - protected override void OnSelected(WorkingBeatmap beatmap) => Exit(); + protected override void OnSelected() => Exit(); } } diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index d8972a4b2d..1fa12f7829 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -1,13 +1,11 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Game.Beatmaps; - namespace osu.Game.Screens.Select { internal class MatchSongSelect : SongSelect { public MatchSongSelect() : base(true) { } - protected override void OnSelected(WorkingBeatmap beatmap) => Exit(); + protected override void OnSelected() => Exit(); } } diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index f22ba322e0..44b672db33 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -56,7 +56,7 @@ namespace osu.Game.Screens.Select base.OnResuming(last); } - protected override void OnSelected(WorkingBeatmap beatmap) + protected override void OnSelected() { if (player != null) return; diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index e16f580901..ee586b74fb 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -180,11 +180,11 @@ namespace osu.Game.Screens.Select if (Beatmap == null) return; Beatmap.PreferredPlayMode = playMode.Value; - OnSelected(Beatmap); + OnSelected(); } public void SelectRandom() => carousel.SelectRandom(); - protected abstract void OnSelected(WorkingBeatmap beatmap); + protected abstract void OnSelected(); private ScheduledDelegate filterTask; From 8c991eae01af96a974e4f7766f56910994670900 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 22:27:24 +0800 Subject: [PATCH 16/17] Fix CI issues. --- osu.Game/Screens/Edit/Editor.cs | 2 +- osu.Game/Screens/Select/Footer.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 3baa79aa1a..850c640770 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -12,7 +12,7 @@ namespace osu.Game.Screens.Edit { internal class Editor : ScreenWhiteBox { - protected override IEnumerable PossibleChildren => new Type[] { typeof(EditSongSelect) }; + protected override IEnumerable PossibleChildren => new[] { typeof(EditSongSelect) }; protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index c913085a05..fae1cb5d4d 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -10,7 +10,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transforms; -using osu.Framework.Input; using osu.Game.Graphics.UserInterface; using osu.Game.Screens.Menu; From 37ff1f39712bb5fd31acbdf12bb731b3a6d03595 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 15 Mar 2017 10:10:59 +0800 Subject: [PATCH 17/17] Control footer by virtual property. --- osu.Game/Screens/Select/EditSongSelect.cs | 5 +++-- osu.Game/Screens/Select/MatchSongSelect.cs | 3 +-- osu.Game/Screens/Select/PlaySongSelect.cs | 2 +- osu.Game/Screens/Select/SongSelect.cs | 16 ++++++++++------ 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/osu.Game/Screens/Select/EditSongSelect.cs b/osu.Game/Screens/Select/EditSongSelect.cs index 5ad0107d91..1a9d37f069 100644 --- a/osu.Game/Screens/Select/EditSongSelect.cs +++ b/osu.Game/Screens/Select/EditSongSelect.cs @@ -3,9 +3,10 @@ namespace osu.Game.Screens.Select { - internal class EditSongSelect : SongSelect + public class EditSongSelect : SongSelect { - public EditSongSelect() : base(false) { } + protected override bool ShowFooter => false; + protected override void OnSelected() => Exit(); } } diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index 1fa12f7829..282cd06126 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -3,9 +3,8 @@ namespace osu.Game.Screens.Select { - internal class MatchSongSelect : SongSelect + public class MatchSongSelect : SongSelect { - public MatchSongSelect() : base(true) { } protected override void OnSelected() => Exit(); } } diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 44b672db33..53f3a3a596 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -19,7 +19,7 @@ namespace osu.Game.Screens.Select private OsuScreen player; private ModSelectOverlay modSelect; - public PlaySongSelect() : base(true) + public PlaySongSelect() { Add(modSelect = new ModSelectOverlay { diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index ee586b74fb..ca8b353c57 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -53,14 +53,17 @@ namespace osu.Game.Screens.Select private List beatmapGroups; + protected virtual bool ShowFooter => true; + /// - /// Can be null if hasFooter:false in constructor + /// Can be null if == false /// - protected BeatmapOptionsOverlay BeatmapOptions { get; private set; } + protected readonly BeatmapOptionsOverlay BeatmapOptions; + /// - /// Can be null if hasFooter:false in constructor + /// Can be null if == false /// - protected Footer Footer { get; private set; } + protected readonly Footer Footer; private FilterControl filter; public FilterControl Filter @@ -79,7 +82,7 @@ namespace osu.Game.Screens.Select } } - protected SongSelect(bool hasFooter) + protected SongSelect() { const float carousel_width = 640; const float filter_height = 100; @@ -125,7 +128,8 @@ namespace osu.Game.Screens.Select }, X = -50, }); - if (hasFooter) + + if (ShowFooter) { Add(BeatmapOptions = new BeatmapOptionsOverlay {