From 35a60a8f7d9a5822c9b64137fe78ddaac539634d Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 20:18:14 +0800 Subject: [PATCH] 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; }