From 73e46ee8c068e209f51d0ba9a55203cca617157b Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 10 Jan 2017 17:43:00 -0500 Subject: [PATCH 01/38] Initial layout of song select filtering UI --- osu.Game/Screens/Select/FilterSongSelect.cs | 218 ++++++++++++++++++++ osu.Game/Screens/Select/PlaySongSelect.cs | 5 + osu.Game/Screens/Select/SearchTextBox.cs | 67 ++++++ osu.Game/osu.Game.csproj | 2 + 4 files changed, 292 insertions(+) create mode 100644 osu.Game/Screens/Select/FilterSongSelect.cs create mode 100644 osu.Game/Screens/Select/SearchTextBox.cs diff --git a/osu.Game/Screens/Select/FilterSongSelect.cs b/osu.Game/Screens/Select/FilterSongSelect.cs new file mode 100644 index 0000000000..a2d2c75d27 --- /dev/null +++ b/osu.Game/Screens/Select/FilterSongSelect.cs @@ -0,0 +1,218 @@ +using System; +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics; + +namespace osu.Game.Screens.Select +{ + public class FilterSongSelect : Container + { + public enum SortMode + { + Arist, + BPM, + Creator, + DateAdded, + Difficulty, + Length, + RankAchieved, + Title + } + + public enum GroupMode + { + NoGrouping, + Arist, + BPM, + Creator, + DateAdded, + Difficulty, + Length, + RankAchieved, + Title, + Collections, + Favorites, + MyMaps, + RankedStatus, + RecentlyPlayed + } + + public Action FilterChanged; + + public string Search { get; private set; } = string.Empty; + public SortMode Sort { get; private set; } = SortMode.Title; + + public FilterSongSelect() + { + AutoSizeAxes = Axes.Y; + + Children = new Drawable[] + { + new Box + { + Colour = Color4.Black, + Alpha = 0.6f, + RelativeSizeAxes = Axes.Both, + }, + new FlowContainer + { + Padding = new MarginPadding(20), + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Width = 0.4f, // TODO: InnerWidth property or something + Direction = FlowDirection.VerticalOnly, + Children = new Drawable[] + { + new SearchTextBox { RelativeSizeAxes = Axes.X }, + new GroupSortTabs() + } + } + }; + } + + private class GroupSortItem : ClickableContainer + { + public string Text + { + get { return text.Text; } + set { text.Text = value; } + } + + public bool Active + { + get { return box.Alpha != 0; } + set + { + if (value) + { + box.FadeIn(300); + text.FadeColour(Color4.White, 300); + } + else + { + box.FadeOut(300); + text.FadeColour(new Color4(102, 204, 255, 255), 300); + } + } + } + + private SpriteText text; + private Box box; + + public GroupSortItem() + { + AutoSizeAxes = Axes.Both; + Children = new Drawable[] + { + text = new SpriteText + { + Colour = new Color4(102, 204, 255, 255), + Margin = new MarginPadding(5), + TextSize = 14, + }, + box = new Box + { + RelativeSizeAxes = Axes.X, + Height = 1, + Alpha = 0, + Colour = Color4.White, + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + } + }; + } + } + + private class GroupSortTabs : Container + { + public GroupSortTabs() + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.X, + Height = 1, + Colour = new Color4(80, 80, 80, 255), + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + }, + new FlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FlowDirection.HorizontalOnly, + Spacing = new Vector2(10, 0), + Children = new Drawable[] + { + new GroupSortItem + { + Text = "All", + Active = true, + }, + new GroupSortItem + { + Text = "Recently Played", + Active = false, + }, + new GroupSortItem + { + Text = "Collections", + Active = false, + }, + new TextAwesome + { + Icon = FontAwesome.fa_ellipsis_h, + Colour = new Color4(102, 204, 255, 255), + TextSize = 14, + Margin = new MarginPadding { Top = 5, Bottom = 5 }, + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + } + } + }, + new FlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FlowDirection.HorizontalOnly, + Spacing = new Vector2(10, 0), + Origin = Anchor.TopRight, + Anchor = Anchor.TopRight, + Children = new Drawable[] + { + new SpriteText + { + Text = "Sort results by", + Colour = new Color4(165, 204, 0, 255), + TextSize = 14, + Margin = new MarginPadding { Top = 5, Bottom = 5 }, + }, + new GroupSortItem + { + Text = "Artist", + Active = true, + }, + new TextAwesome + { + Icon = FontAwesome.fa_ellipsis_h, + Colour = new Color4(165, 204, 0, 255), + TextSize = 14, + Margin = new MarginPadding { Top = 5, Bottom = 5 }, + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + } + } + }, + }; + } + } + } +} \ No newline at end of file diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index e0860fda4c..ca559f1931 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -127,6 +127,11 @@ namespace osu.Game.Screens.Select }, } }, + new FilterSongSelect + { + Position = wedged_container_start_position, + RelativeSizeAxes = Axes.X, + }, carousel = new CarouselContainer { RelativeSizeAxes = Axes.Y, diff --git a/osu.Game/Screens/Select/SearchTextBox.cs b/osu.Game/Screens/Select/SearchTextBox.cs new file mode 100644 index 0000000000..ae8d9e3fde --- /dev/null +++ b/osu.Game/Screens/Select/SearchTextBox.cs @@ -0,0 +1,67 @@ +using System; +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics; + +namespace osu.Game.Screens.Select +{ + public class SearchTextBox : TextBox + { + protected override Color4 BackgroundUnfocused => new Color4(10, 10, 10, 255); + protected override Color4 BackgroundFocused => new Color4(10, 10, 10, 255); + public override bool HasFocus => true; + + private SpriteText placeholder; + + protected override string InternalText + { + get { return base.InternalText; } + set + { + base.InternalText = value; + if (placeholder != null) + { + if (string.IsNullOrEmpty(value)) + placeholder.Text = "type to search"; + else + placeholder.Text = string.Empty; + } + } + } + + public SearchTextBox() + { + Height = 35; + TextContainer.Padding = new MarginPadding(5); + Add(new Drawable[] + { + placeholder = new SpriteText + { + Font = @"Exo2.0-MediumItalic", + Text = "type to search", + Colour = new Color4(180, 180, 180, 255), + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Margin = new MarginPadding { Left = 10 }, + }, + new TextAwesome + { + Icon = FontAwesome.fa_search, + Origin = Anchor.CentreRight, + Anchor = Anchor.CentreRight, + Margin = new MarginPadding { Right = 10 }, + } + }); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + OnFocus(null); + } + } +} \ No newline at end of file diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index a4da659718..2320f16f68 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -232,6 +232,8 @@ + + From 63031fbc3d762416972515423160742317bec2fe Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 10 Jan 2017 17:51:22 -0500 Subject: [PATCH 02/38] Move filter container z depth and add hover fx --- osu.Game/Screens/Select/FilterSongSelect.cs | 46 ++++++++++++++++----- osu.Game/Screens/Select/PlaySongSelect.cs | 10 ++--- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/osu.Game/Screens/Select/FilterSongSelect.cs b/osu.Game/Screens/Select/FilterSongSelect.cs index a2d2c75d27..a08b674d5e 100644 --- a/osu.Game/Screens/Select/FilterSongSelect.cs +++ b/osu.Game/Screens/Select/FilterSongSelect.cs @@ -6,6 +6,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input; using osu.Game.Graphics; namespace osu.Game.Screens.Select @@ -84,27 +85,48 @@ namespace osu.Game.Screens.Select get { return text.Text; } set { text.Text = value; } } - + + private void FadeActive() + { + box.FadeIn(300); + text.FadeColour(Color4.White, 300); + } + + private void FadeInactive() + { + box.FadeOut(300); + text.FadeColour(new Color4(102, 204, 255, 255), 300); + } + + private bool active; public bool Active { - get { return box.Alpha != 0; } + get { return active; } set { - if (value) - { - box.FadeIn(300); - text.FadeColour(Color4.White, 300); - } + active = value; + if (active) + FadeActive(); else - { - box.FadeOut(300); - text.FadeColour(new Color4(102, 204, 255, 255), 300); - } + FadeInactive(); } } private SpriteText text; private Box box; + + protected override bool OnHover(InputState state) + { + if (!active) + FadeActive(); + return true; + } + + protected override void OnHoverLost(InputState state) + { + if (!active) + FadeInactive(); + } public GroupSortItem() { @@ -116,6 +138,7 @@ namespace osu.Game.Screens.Select Colour = new Color4(102, 204, 255, 255), Margin = new MarginPadding(5), TextSize = 14, + Font = @"Exo2.0-Bold", }, box = new Box { @@ -190,6 +213,7 @@ namespace osu.Game.Screens.Select { new SpriteText { + Font = @"Exo2.0-Bold", Text = "Sort results by", Colour = new Color4(165, 204, 0, 255), TextSize = 14, diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index ca559f1931..6e158f67c3 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -127,11 +127,6 @@ namespace osu.Game.Screens.Select }, } }, - new FilterSongSelect - { - Position = wedged_container_start_position, - RelativeSizeAxes = Axes.X, - }, carousel = new CarouselContainer { RelativeSizeAxes = Axes.Y, @@ -139,6 +134,11 @@ namespace osu.Game.Screens.Select Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, }, + new FilterSongSelect + { + Position = wedged_container_start_position, + RelativeSizeAxes = Axes.X, + }, beatmapInfoWedge = new BeatmapInfoWedge { Alpha = 0, From 5eb1cda77b6cc1545cb7e9b3fff74ce633fdde57 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 17 Jan 2017 16:43:40 -0500 Subject: [PATCH 03/38] Rename FilterSongSelect, use OsuColour --- .../{FilterSongSelect.cs => FilterControl.cs} | 46 +++++++++++++------ osu.Game/Screens/Select/PlaySongSelect.cs | 2 +- osu.Game/osu.Game.csproj | 2 +- 3 files changed, 33 insertions(+), 17 deletions(-) rename osu.Game/Screens/Select/{FilterSongSelect.cs => FilterControl.cs} (83%) diff --git a/osu.Game/Screens/Select/FilterSongSelect.cs b/osu.Game/Screens/Select/FilterControl.cs similarity index 83% rename from osu.Game/Screens/Select/FilterSongSelect.cs rename to osu.Game/Screens/Select/FilterControl.cs index a08b674d5e..ad15d75d4d 100644 --- a/osu.Game/Screens/Select/FilterSongSelect.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -1,6 +1,7 @@ using System; using OpenTK; using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; @@ -11,7 +12,7 @@ using osu.Game.Graphics; namespace osu.Game.Screens.Select { - public class FilterSongSelect : Container + public class FilterControl : Container { public enum SortMode { @@ -48,7 +49,7 @@ namespace osu.Game.Screens.Select public string Search { get; private set; } = string.Empty; public SortMode Sort { get; private set; } = SortMode.Title; - public FilterSongSelect() + public FilterControl() { AutoSizeAxes = Axes.Y; @@ -78,7 +79,7 @@ namespace osu.Game.Screens.Select }; } - private class GroupSortItem : ClickableContainer + private class TabItem : ClickableContainer { public string Text { @@ -95,7 +96,7 @@ namespace osu.Game.Screens.Select private void FadeInactive() { box.FadeOut(300); - text.FadeColour(new Color4(102, 204, 255, 255), 300); + text.FadeColour(fadeColour, 300); } private bool active; @@ -114,6 +115,7 @@ namespace osu.Game.Screens.Select private SpriteText text; private Box box; + private Color4 fadeColour; protected override bool OnHover(InputState state) { @@ -128,14 +130,13 @@ namespace osu.Game.Screens.Select FadeInactive(); } - public GroupSortItem() + public TabItem() { AutoSizeAxes = Axes.Both; Children = new Drawable[] { text = new SpriteText { - Colour = new Color4(102, 204, 255, 255), Margin = new MarginPadding(5), TextSize = 14, Font = @"Exo2.0-Bold", @@ -151,10 +152,20 @@ namespace osu.Game.Screens.Select } }; } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + text.Colour = colours.Blue; + fadeColour = colours.Blue; + } } private class GroupSortTabs : Container { + private TextAwesome groupsEllipsis, sortEllipsis; + private SpriteText sortLabel; + public GroupSortTabs() { RelativeSizeAxes = Axes.X; @@ -165,7 +176,7 @@ namespace osu.Game.Screens.Select { RelativeSizeAxes = Axes.X, Height = 1, - Colour = new Color4(80, 80, 80, 255), + Colour = OsuColour.Gray(80), Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, }, @@ -176,25 +187,24 @@ namespace osu.Game.Screens.Select Spacing = new Vector2(10, 0), Children = new Drawable[] { - new GroupSortItem + new TabItem { Text = "All", Active = true, }, - new GroupSortItem + new TabItem { Text = "Recently Played", Active = false, }, - new GroupSortItem + new TabItem { Text = "Collections", Active = false, }, - new TextAwesome + groupsEllipsis = new TextAwesome { Icon = FontAwesome.fa_ellipsis_h, - Colour = new Color4(102, 204, 255, 255), TextSize = 14, Margin = new MarginPadding { Top = 5, Bottom = 5 }, Origin = Anchor.BottomLeft, @@ -211,7 +221,7 @@ namespace osu.Game.Screens.Select Anchor = Anchor.TopRight, Children = new Drawable[] { - new SpriteText + sortLabel = new SpriteText { Font = @"Exo2.0-Bold", Text = "Sort results by", @@ -219,12 +229,12 @@ namespace osu.Game.Screens.Select TextSize = 14, Margin = new MarginPadding { Top = 5, Bottom = 5 }, }, - new GroupSortItem + new TabItem { Text = "Artist", Active = true, }, - new TextAwesome + sortEllipsis = new TextAwesome { Icon = FontAwesome.fa_ellipsis_h, Colour = new Color4(165, 204, 0, 255), @@ -237,6 +247,12 @@ namespace osu.Game.Screens.Select }, }; } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + groupsEllipsis.Colour = colours.Blue; + } } } } \ No newline at end of file diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 6e158f67c3..6fa2337598 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -134,7 +134,7 @@ namespace osu.Game.Screens.Select Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, }, - new FilterSongSelect + new FilterControl { Position = wedged_container_start_position, RelativeSizeAxes = Axes.X, diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 2320f16f68..3f39481f29 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -232,7 +232,7 @@ - + From 7559fc593a94a0bb5bae380fdb94f11667e5ac89 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 17 Jan 2017 16:43:53 -0500 Subject: [PATCH 04/38] Use default background on empty song select screen --- osu.Game/Screens/Backgrounds/BackgroundModeBeatmap.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Backgrounds/BackgroundModeBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundModeBeatmap.cs index 1c25fcfb0e..b5a2332f7f 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundModeBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundModeBeatmap.cs @@ -22,7 +22,6 @@ namespace osu.Game.Screens.Backgrounds { return beatmap; } - set { if (beatmap == value) @@ -56,6 +55,8 @@ namespace osu.Game.Screens.Backgrounds public BackgroundModeBeatmap(WorkingBeatmap beatmap) { Beatmap = beatmap; + if (beatmap == null) + Add(background = new Background(@"Backgrounds/bg1")); } public void BlurTo(Vector2 sigma, double duration) @@ -84,7 +85,6 @@ namespace osu.Game.Screens.Backgrounds { Sprite.Texture = beatmap.Background; } - } } } From 46e7bcef8ca51c2a1e3c2f2b94d8cc68e019e8bc Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 17 Jan 2017 17:05:06 -0500 Subject: [PATCH 05/38] Improve beatmap import --- osu.Desktop/Program.cs | 12 +++++++++--- osu.Game/Screens/Select/PlaySongSelect.cs | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs index d51f898870..db40f31c6f 100644 --- a/osu.Desktop/Program.cs +++ b/osu.Desktop/Program.cs @@ -4,6 +4,7 @@ using System; using System.IO; using System.Linq; +using System.Threading; using osu.Desktop.Beatmaps.IO; using osu.Framework; using osu.Framework.Desktop; @@ -25,17 +26,22 @@ namespace osu.Desktop public static int Main(string[] args) { LegacyFilesystemReader.Register(); + + var cwd = Directory.GetCurrentDirectory(); using (DesktopGameHost host = Host.GetSuitableHost(@"osu", true)) { if (!host.IsPrimaryInstance) { var importer = new BeatmapImporter(host); - + Directory.SetCurrentDirectory(cwd); foreach (var file in args) - if (!importer.Import(file).Wait(1000)) + { + Console.WriteLine(@"Importing {0}", file); + if (!importer.Import(Path.GetFullPath(file)).Wait(3000)) throw new TimeoutException(@"IPC took too long to send"); - Console.WriteLine(@"Sent import requests to running instance"); + Thread.Sleep(500); + } } else { diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 6fa2337598..1688326725 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -205,7 +205,7 @@ namespace osu.Game.Screens.Select private void onDatabaseOnBeatmapSetAdded(BeatmapSetInfo s) { - Schedule(() => addBeatmapSet(s, Game)); + Schedule(() => addBeatmapSet(s, Game, true)); } protected override void OnEntering(GameMode last) @@ -334,7 +334,7 @@ namespace osu.Game.Screens.Select } } - private void addBeatmapSet(BeatmapSetInfo beatmapSet, BaseGame game) + private void addBeatmapSet(BeatmapSetInfo beatmapSet, BaseGame game, bool select = false) { beatmapSet = database.GetWithChildren(beatmapSet.ID); beatmapSet.Beatmaps.ForEach(b => @@ -359,7 +359,7 @@ namespace osu.Game.Screens.Select { carousel.AddGroup(group); - if (Beatmap == null) + if (Beatmap == null || select) carousel.SelectBeatmap(beatmapSet.Beatmaps.First()); else { From 75de03bd88e0ea3f67bb558021ff4fe0c2ca7a41 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 17 Jan 2017 18:26:43 -0500 Subject: [PATCH 06/38] Use OsuColour for green text --- osu.Game/Screens/Select/FilterControl.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index ad15d75d4d..a6fb62945f 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -225,7 +225,6 @@ namespace osu.Game.Screens.Select { Font = @"Exo2.0-Bold", Text = "Sort results by", - Colour = new Color4(165, 204, 0, 255), TextSize = 14, Margin = new MarginPadding { Top = 5, Bottom = 5 }, }, @@ -237,7 +236,6 @@ namespace osu.Game.Screens.Select sortEllipsis = new TextAwesome { Icon = FontAwesome.fa_ellipsis_h, - Colour = new Color4(165, 204, 0, 255), TextSize = 14, Margin = new MarginPadding { Top = 5, Bottom = 5 }, Origin = Anchor.BottomLeft, @@ -252,6 +250,8 @@ namespace osu.Game.Screens.Select private void load(OsuColour colours) { groupsEllipsis.Colour = colours.Blue; + sortLabel.Colour = colours.GreenLight; + sortEllipsis.Colour = colours.GreenLight; } } } From 678f0aaa16e43bf0924d861da25ce5310ea4dce0 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 17 Jan 2017 19:18:15 -0500 Subject: [PATCH 07/38] Implement filtering with strings --- osu.Game/Beatmaps/Drawables/BeatmapGroup.cs | 8 +- osu.Game/Screens/Select/CarouselContainer.cs | 86 ++++++++++++-------- osu.Game/Screens/Select/FilterControl.cs | 10 ++- osu.Game/Screens/Select/PlaySongSelect.cs | 47 ++++++++++- 4 files changed, 113 insertions(+), 38 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index 7799095a77..7470a543f9 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -29,7 +29,9 @@ namespace osu.Game.Beatmaps.Drawables private BeatmapGroupState state; - public List BeatmapPanels; + public List BeatmapPanels; + + public BeatmapSetInfo BeatmapSet; public BeatmapGroupState State { @@ -73,7 +75,9 @@ namespace osu.Game.Beatmaps.Drawables GainedSelection = panelGainedSelection, StartRequested = p => { StartRequested?.Invoke(p.Beatmap); }, RelativeSizeAxes = Axes.X, - }).ToList(); + }).ToList(); + + BeatmapSet = set; } private void headerGainedSelection(BeatmapSetHeader panel) diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index 144e4cabba..715eda58a0 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -16,10 +16,11 @@ using osu.Game.Beatmaps.Drawables; using osu.Framework.Timing; using osu.Framework.Input; using OpenTK.Input; +using System.Collections; namespace osu.Game.Screens.Select { - class CarouselContainer : ScrollContainer + class CarouselContainer : ScrollContainer, IEnumerable { private Container scrollableContent; private List groups = new List(); @@ -27,29 +28,29 @@ namespace osu.Game.Screens.Select public BeatmapGroup SelectedGroup { get; private set; } public BeatmapPanel SelectedPanel { get; private set; } - private List yPositions = new List(); - private CarouselLifetimeList Lifetime; - - public CarouselContainer() - { - DistanceDecayJump = 0.01; - - Add(scrollableContent = new Container(Lifetime = new CarouselLifetimeList(DepthComparer)) - { - RelativeSizeAxes = Axes.X, - }); - } - - internal class CarouselLifetimeList : LifetimeList - { - public CarouselLifetimeList(IComparer comparer) - : base(comparer) - { - } - - public int StartIndex; + private List yPositions = new List(); + private CarouselLifetimeList Lifetime; + + public CarouselContainer() + { + DistanceDecayJump = 0.01; + + Add(scrollableContent = new Container(Lifetime = new CarouselLifetimeList(DepthComparer)) + { + RelativeSizeAxes = Axes.X, + }); + } + + internal class CarouselLifetimeList : LifetimeList + { + public CarouselLifetimeList(IComparer comparer) + : base(comparer) + { + } + + public int StartIndex; public int EndIndex; - + public override bool Update(FrameTimeInfo time) { bool anyAliveChanged = false; @@ -75,9 +76,9 @@ namespace osu.Game.Screens.Select } return anyAliveChanged; - } - } - + } + } + public void AddGroup(BeatmapGroup group) { group.State = BeatmapGroupState.Collapsed; @@ -100,7 +101,7 @@ namespace osu.Game.Screens.Select yPositions.Add(currentY); panel.MoveToY(currentY, 750, EasingTypes.OutExpo); - if (advance) + if (advance && panel.IsVisible) currentY += panel.DrawHeight + 5; } @@ -200,7 +201,9 @@ namespace osu.Game.Screens.Select /// Half the draw height of the carousel container. private void updatePanel(Panel p, float halfHeight) { - float panelDrawY = p.Position.Y - Current + p.DrawHeight / 2; + var height = p.IsVisible ? p.DrawHeight : 0; + + float panelDrawY = p.Position.Y - Current + height / 2; float dist = Math.Abs(1f - panelDrawY / halfHeight); // Setting the origin position serves as an additive position on top of potential @@ -222,11 +225,11 @@ namespace osu.Game.Screens.Select float drawHeight = DrawHeight; float halfHeight = drawHeight / 2; - foreach (Panel p in Lifetime.AliveItems) - { - float panelPosY = p.Position.Y; - p.IsOnScreen = panelPosY >= Current - p.DrawHeight && panelPosY <= Current + drawHeight; - updatePanel(p, halfHeight); + foreach (Panel p in Lifetime.AliveItems) + { + float panelPosY = p.Position.Y; + p.IsOnScreen = panelPosY >= Current - p.DrawHeight && panelPosY <= Current + drawHeight; + updatePanel(p, halfHeight); } // Determine range of indices for items that are now definitely on screen to be added @@ -247,6 +250,13 @@ namespace osu.Game.Screens.Select } } + public void InvalidateVisible() + { + Lifetime.StartIndex = 0; + Lifetime.EndIndex = groups.Count - 1; + computeYPositions(); + } + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { int direction = 0; @@ -288,5 +298,15 @@ namespace osu.Game.Screens.Select return base.OnKeyDown(state, args); } + + public IEnumerator GetEnumerator() + { + return groups.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } } } diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index a6fb62945f..8366da7021 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -49,6 +49,8 @@ namespace osu.Game.Screens.Select public string Search { get; private set; } = string.Empty; public SortMode Sort { get; private set; } = SortMode.Title; + private SearchTextBox searchTextBox; + public FilterControl() { AutoSizeAxes = Axes.Y; @@ -72,11 +74,17 @@ namespace osu.Game.Screens.Select Direction = FlowDirection.VerticalOnly, Children = new Drawable[] { - new SearchTextBox { RelativeSizeAxes = Axes.X }, + searchTextBox = new SearchTextBox { RelativeSizeAxes = Axes.X }, new GroupSortTabs() } } }; + + searchTextBox.OnChange += (sender, text) => + { + Search = searchTextBox.Text; + FilterChanged?.Invoke(); + }; } private class TabItem : ClickableContainer diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 1688326725..6114d5d56a 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -31,6 +31,7 @@ using osu.Game.Graphics.Containers; using osu.Framework.Input; using OpenTK.Input; using osu.Game.Graphics; +using System.Collections.Generic; namespace osu.Game.Screens.Select { @@ -52,6 +53,8 @@ namespace osu.Game.Screens.Select private AudioSample sampleChangeDifficulty; private AudioSample sampleChangeBeatmap; + + private List beatmapGroups; class WedgeBackground : Container { @@ -82,6 +85,7 @@ namespace osu.Game.Screens.Select } Player player; + FilterControl filter; private void start() { @@ -112,6 +116,7 @@ namespace osu.Game.Screens.Select { const float carouselWidth = 640; const float bottomToolHeight = 50; + beatmapGroups = new List(); Children = new Drawable[] { new ParallaxContainer @@ -134,10 +139,11 @@ namespace osu.Game.Screens.Select Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, }, - new FilterControl + filter = new FilterControl { Position = wedged_container_start_position, RelativeSizeAxes = Axes.X, + FilterChanged = filterChanged, }, beatmapInfoWedge = new BeatmapInfoWedge { @@ -203,6 +209,41 @@ namespace osu.Game.Screens.Select Task.Factory.StartNew(() => addBeatmapSets(game, initialAddSetsTask.Token), initialAddSetsTask.Token); } + private void filterChanged() + { + var search = filter.Search; + BeatmapGroup newSelection = null; + bool changed = false; + foreach (var beatmapGroup in carousel) + { + var set = beatmapGroup.BeatmapSet; + if (set == null) + continue; + bool match = string.IsNullOrEmpty(search) + || (set.Metadata.Artist ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 + || (set.Metadata.ArtistUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 + || (set.Metadata.Title ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 + || (set.Metadata.TitleUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1; + if (match) + { + changed = changed && beatmapGroup.Header.Alpha == 1; + beatmapGroup.Header.Alpha = 1; + if (newSelection == null || beatmapGroup.BeatmapSet.OnlineBeatmapSetID == Beatmap.BeatmapSetInfo.OnlineBeatmapSetID) + newSelection = beatmapGroup; + } + else + { + changed = changed && beatmapGroup.Header.Alpha == 0; + beatmapGroup.Header.Alpha = 0; + beatmapGroup.State = BeatmapGroupState.Collapsed; + } + } + if (newSelection != null) + selectBeatmap(newSelection.BeatmapSet.Beatmaps[0]); + if (changed) + carousel.InvalidateVisible(); + } + private void onDatabaseOnBeatmapSetAdded(BeatmapSetInfo s) { Schedule(() => addBeatmapSet(s, Game, true)); @@ -347,7 +388,7 @@ namespace osu.Game.Screens.Select var beatmap = new WorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault(), beatmapSet, database); - var group = new BeatmapGroup(beatmap) + var group = new BeatmapGroup(beatmap, beatmapSet) { SelectionChanged = selectionChanged, StartRequested = b => start() @@ -357,6 +398,8 @@ namespace osu.Game.Screens.Select //this likely won't scale so well, but allows us to completely async the loading flow. Task.WhenAll(group.BeatmapPanels.Select(panel => panel.Preload(game))).ContinueWith(task => Schedule(delegate { + beatmapGroups.Add(group); + carousel.AddGroup(group); if (Beatmap == null || select) From f3c5c1f0b8e731ba00ae9785ddbc6900e7b5a676 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 26 Jan 2017 21:31:28 -0500 Subject: [PATCH 08/38] Fixes following recent updates upstream --- osu.Game/Beatmaps/Drawables/BeatmapGroup.cs | 126 ++++++++++--------- osu.Game/Screens/Menu/ButtonSystem.cs | 2 +- osu.Game/Screens/Select/CarouselContainer.cs | 8 +- osu.Game/Screens/Select/PlaySongSelect.cs | 68 +++++----- 4 files changed, 109 insertions(+), 95 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index 7470a543f9..6155e7779f 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -1,44 +1,46 @@ -//Copyright (c) 2007-2016 ppy Pty Ltd . -//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using System.Collections.Generic; -using System.Linq; -using osu.Framework; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Transformations; -using osu.Game.Database; - -namespace osu.Game.Beatmaps.Drawables -{ - class BeatmapGroup : IStateful - { - public BeatmapPanel SelectedPanel; - - /// - /// Fires when one of our difficulties was selected. Will fire on first expand. - /// - public Action SelectionChanged; - +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using osu.Framework; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Transformations; +using osu.Game.Database; + +namespace osu.Game.Beatmaps.Drawables +{ + class BeatmapGroup : IStateful + { + public BeatmapPanel SelectedPanel; + + /// + /// Fires when one of our difficulties was selected. Will fire on first expand. + /// + public Action SelectionChanged; + /// /// Fires when one of our difficulties is clicked when already selected. Should start playing the map. - /// - public Action StartRequested; - - public BeatmapSetHeader Header; - - private BeatmapGroupState state; + /// + public Action StartRequested; + public BeatmapSetHeader Header; + + private BeatmapGroupState state; + public List BeatmapPanels; - - public BeatmapSetInfo BeatmapSet; - - public BeatmapGroupState State - { - get { return state; } - set - { - state = value; + + public BeatmapSetInfo BeatmapSet; + + public bool Hidden; + + public BeatmapGroupState State + { + get { return state; } + set + { + state = value; switch (state) { case BeatmapGroupState.Expanded: @@ -58,17 +60,17 @@ namespace osu.Game.Beatmaps.Drawables panel.FadeOut(300, EasingTypes.OutQuint); break; } - } - } - - public BeatmapGroup(WorkingBeatmap beatmap, BeatmapSetInfo set = null) - { - Header = new BeatmapSetHeader(beatmap) - { - GainedSelection = headerGainedSelection, - RelativeSizeAxes = Axes.X, - }; - + } + } + + public BeatmapGroup(WorkingBeatmap beatmap, BeatmapSetInfo set = null) + { + Header = new BeatmapSetHeader(beatmap) + { + GainedSelection = headerGainedSelection, + RelativeSizeAxes = Axes.X, + }; + BeatmapPanels = beatmap.BeatmapSetInfo.Beatmaps.Select(b => new BeatmapPanel(b) { Alpha = 0, @@ -76,12 +78,12 @@ namespace osu.Game.Beatmaps.Drawables StartRequested = p => { StartRequested?.Invoke(p.Beatmap); }, RelativeSizeAxes = Axes.X, }).ToList(); - - BeatmapSet = set; + + BeatmapSet = set; } - private void headerGainedSelection(BeatmapSetHeader panel) - { + private void headerGainedSelection(BeatmapSetHeader panel) + { State = BeatmapGroupState.Expanded; //we want to make sure one of our children is selected in the case none have been selected yet. @@ -89,10 +91,10 @@ namespace osu.Game.Beatmaps.Drawables BeatmapPanels.First().State = PanelSelectedState.Selected; else SelectionChanged?.Invoke(this, SelectedPanel.Beatmap); - } - - private void panelGainedSelection(BeatmapPanel panel) - { + } + + private void panelGainedSelection(BeatmapPanel panel) + { try { if (SelectedPanel == panel) return; @@ -100,18 +102,18 @@ namespace osu.Game.Beatmaps.Drawables if (SelectedPanel != null) SelectedPanel.State = PanelSelectedState.NotSelected; SelectedPanel = panel; - } - finally + } + finally { State = BeatmapGroupState.Expanded; SelectionChanged?.Invoke(this, panel.Beatmap); - } - } + } + } } public enum BeatmapGroupState { Collapsed, Expanded, - } -} + } +} diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 8825f9474b..6fbbafff07 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -99,7 +99,7 @@ namespace osu.Game.Screens.Menu { Action = onOsuLogo, Origin = Anchor.Centre, - Anchor = Anchor.Centre + Anchor = Anchor.Centre, } }; diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index 715eda58a0..e1aceb2964 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -101,7 +101,7 @@ namespace osu.Game.Screens.Select yPositions.Add(currentY); panel.MoveToY(currentY, 750, EasingTypes.OutExpo); - if (advance && panel.IsVisible) + if (advance) currentY += panel.DrawHeight + 5; } @@ -118,7 +118,7 @@ namespace osu.Game.Screens.Select foreach (BeatmapGroup group in groups) { - movePanel(group.Header, true, ref currentY); + movePanel(group.Header, !group.Hidden, ref currentY); if (group.State == BeatmapGroupState.Expanded) { @@ -133,10 +133,10 @@ namespace osu.Game.Screens.Select panel.MoveToX(-50, 500, EasingTypes.OutExpo); //on first display we want to begin hidden under our group's header. - if (panel.Alpha == 0) + if (panel.Alpha == 0 && !group.Hidden) panel.MoveToY(headerY); - movePanel(panel, true, ref currentY); + movePanel(panel, !group.Hidden, ref currentY); } } else diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 6114d5d56a..5a54ac07b6 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -32,6 +32,7 @@ using osu.Framework.Input; using OpenTK.Input; using osu.Game.Graphics; using System.Collections.Generic; +using osu.Framework.Threading; namespace osu.Game.Screens.Select { @@ -209,39 +210,50 @@ namespace osu.Game.Screens.Select Task.Factory.StartNew(() => addBeatmapSets(game, initialAddSetsTask.Token), initialAddSetsTask.Token); } + private ScheduledDelegate filterTask; + private void filterChanged() { - var search = filter.Search; - BeatmapGroup newSelection = null; - bool changed = false; - foreach (var beatmapGroup in carousel) + if (filterTask != null) + filterTask.Cancel(); + filterTask = Scheduler.AddDelayed(() => { - var set = beatmapGroup.BeatmapSet; - if (set == null) - continue; - bool match = string.IsNullOrEmpty(search) - || (set.Metadata.Artist ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 - || (set.Metadata.ArtistUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 - || (set.Metadata.Title ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 - || (set.Metadata.TitleUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1; - if (match) + filterTask = null; + var search = filter.Search; + BeatmapGroup newSelection = null; + bool changed = false; + foreach (var beatmapGroup in carousel) { - changed = changed && beatmapGroup.Header.Alpha == 1; - beatmapGroup.Header.Alpha = 1; - if (newSelection == null || beatmapGroup.BeatmapSet.OnlineBeatmapSetID == Beatmap.BeatmapSetInfo.OnlineBeatmapSetID) - newSelection = beatmapGroup; + var set = beatmapGroup.BeatmapSet; + if (set == null) + continue; + bool match = string.IsNullOrEmpty(search) + || (set.Metadata.Artist ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 + || (set.Metadata.ArtistUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 + || (set.Metadata.Title ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 + || (set.Metadata.TitleUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1; + if (match) + { + changed = changed && !beatmapGroup.Hidden; + beatmapGroup.Hidden = false; + beatmapGroup.Header.Alpha = 1; + if (newSelection == null || beatmapGroup.BeatmapSet.OnlineBeatmapSetID == Beatmap.BeatmapSetInfo.OnlineBeatmapSetID) + newSelection = beatmapGroup; + } + else + { + changed = changed && beatmapGroup.Hidden; + beatmapGroup.Hidden = true; + beatmapGroup.Header.Alpha = 0; + beatmapGroup.Header.Masking = false; + beatmapGroup.State = BeatmapGroupState.Collapsed; + } } - else - { - changed = changed && beatmapGroup.Header.Alpha == 0; - beatmapGroup.Header.Alpha = 0; - beatmapGroup.State = BeatmapGroupState.Collapsed; - } - } - if (newSelection != null) - selectBeatmap(newSelection.BeatmapSet.Beatmaps[0]); - if (changed) - carousel.InvalidateVisible(); + if (newSelection != null) + selectBeatmap(newSelection.BeatmapSet.Beatmaps[0]); + if (changed || true) + carousel.InvalidateVisible(); + }, 250); } private void onDatabaseOnBeatmapSetAdded(BeatmapSetInfo s) From 66d104394fc153c931741904e34d6d400d52ae25 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 30 Jan 2017 09:35:59 -0500 Subject: [PATCH 09/38] Add comments around cwd handling --- osu.Desktop/Program.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs index db40f31c6f..b789c31777 100644 --- a/osu.Desktop/Program.cs +++ b/osu.Desktop/Program.cs @@ -26,14 +26,16 @@ namespace osu.Desktop public static int Main(string[] args) { LegacyFilesystemReader.Register(); - - var cwd = Directory.GetCurrentDirectory(); + + // Back up the cwd before DesktopGameHost changes it + var cwd = Environment.CurrentDirectory; using (DesktopGameHost host = Host.GetSuitableHost(@"osu", true)) { if (!host.IsPrimaryInstance) { var importer = new BeatmapImporter(host); + // Restore the cwd so relative paths given at the command line work correctly Directory.SetCurrentDirectory(cwd); foreach (var file in args) { From 0a81fdbd10075f7220a0354c259313e0e5e54f1e Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 30 Jan 2017 09:44:02 -0500 Subject: [PATCH 10/38] Update null background handling --- osu.Game/Screens/Backgrounds/BackgroundModeBeatmap.cs | 11 ++++++----- osu.Game/Screens/Select/PlaySongSelect.cs | 9 +++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/osu.Game/Screens/Backgrounds/BackgroundModeBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundModeBeatmap.cs index b5a2332f7f..250b789511 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundModeBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundModeBeatmap.cs @@ -24,14 +24,17 @@ namespace osu.Game.Screens.Backgrounds } set { - if (beatmap == value) + if (beatmap == value && beatmap != null) return; - beatmap = value; Schedule(() => { - Background newBackground = new BeatmapBackground(beatmap); + Background newBackground; + if (beatmap == null) + newBackground = new Background(@"Backgrounds/bg1"); + else + newBackground = new BeatmapBackground(beatmap); newBackground.Preload(Game, delegate { @@ -55,8 +58,6 @@ namespace osu.Game.Screens.Backgrounds public BackgroundModeBeatmap(WorkingBeatmap beatmap) { Beatmap = beatmap; - if (beatmap == null) - Add(background = new Background(@"Backgrounds/bg1")); } public void BlurTo(Vector2 sigma, double duration) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index ddacf7c4b2..edfe1bc3a5 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -298,18 +298,15 @@ namespace osu.Game.Screens.Select private void changeBackground(WorkingBeatmap beatmap) { - if (beatmap == null) - return; - var backgroundModeBeatmap = Background as BackgroundModeBeatmap; if (backgroundModeBeatmap != null) { backgroundModeBeatmap.Beatmap = beatmap; - // TODO: Remove this once we have non-nullable Beatmap - (Background as BackgroundModeBeatmap)?.BlurTo(BACKGROUND_BLUR, 1000); + backgroundModeBeatmap.BlurTo(BACKGROUND_BLUR, 1000); } - beatmapInfoWedge.UpdateBeatmap(beatmap); + if (beatmap != null) + beatmapInfoWedge.UpdateBeatmap(beatmap); } /// From 42a2285ef3a0b81d7d17efb37fc68b3191f8159a Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 30 Jan 2017 09:47:04 -0500 Subject: [PATCH 11/38] Make BeatmapGroup.Hidden more intelligent --- osu.Game/Beatmaps/Drawables/BeatmapGroup.cs | 13 ++++++++++++- osu.Game/Screens/Select/PlaySongSelect.cs | 4 ---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index 8bacbf4cc9..1994083805 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -33,7 +33,18 @@ namespace osu.Game.Beatmaps.Drawables public BeatmapSetInfo BeatmapSet; - public bool Hidden; + private bool hidden; + public bool Hidden + { + get { return hidden; } + set + { + hidden = value; + Header.Alpha = hidden ? 0 : 1; + if (hidden) + State = BeatmapGroupState.Collapsed; + } + } public BeatmapGroupState State { diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index edfe1bc3a5..3518e94f70 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -213,7 +213,6 @@ namespace osu.Game.Screens.Select { changed = changed && !beatmapGroup.Hidden; beatmapGroup.Hidden = false; - beatmapGroup.Header.Alpha = 1; if (newSelection == null || beatmapGroup.BeatmapSet.OnlineBeatmapSetID == Beatmap.BeatmapSetInfo.OnlineBeatmapSetID) newSelection = beatmapGroup; } @@ -221,9 +220,6 @@ namespace osu.Game.Screens.Select { changed = changed && beatmapGroup.Hidden; beatmapGroup.Hidden = true; - beatmapGroup.Header.Alpha = 0; - beatmapGroup.Header.Masking = false; - beatmapGroup.State = BeatmapGroupState.Collapsed; } } if (newSelection != null) From 7f3cb381a972db745042c2e56c87c811b3bf2afc Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 30 Jan 2017 09:48:12 -0500 Subject: [PATCH 12/38] Refactor FilterControl.Search --- osu.Game/Screens/Select/FilterControl.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 8366da7021..0dfb3ccc06 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -46,7 +46,7 @@ namespace osu.Game.Screens.Select public Action FilterChanged; - public string Search { get; private set; } = string.Empty; + public string Search => searchTextBox.Text; public SortMode Sort { get; private set; } = SortMode.Title; private SearchTextBox searchTextBox; @@ -82,7 +82,6 @@ namespace osu.Game.Screens.Select searchTextBox.OnChange += (sender, text) => { - Search = searchTextBox.Text; FilterChanged?.Invoke(); }; } From 9a2cba852045c66569d7ffca1e4305c504ddaf1f Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 30 Jan 2017 09:48:21 -0500 Subject: [PATCH 13/38] Use null coalesce operator where appropriate --- osu.Game/Screens/Select/PlaySongSelect.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 3518e94f70..6266788141 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -191,8 +191,7 @@ namespace osu.Game.Screens.Select private void filterChanged() { - if (filterTask != null) - filterTask.Cancel(); + filterTask?.Cancel(); filterTask = Scheduler.AddDelayed(() => { filterTask = null; From fb431fd44e3751bc4e79df56db2ed7d708855bbf Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 30 Jan 2017 09:49:58 -0500 Subject: [PATCH 14/38] &&=, unnecessary null check --- osu.Game/Screens/Select/PlaySongSelect.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 6266788141..72ab027fcb 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -201,8 +201,6 @@ namespace osu.Game.Screens.Select foreach (var beatmapGroup in carousel) { var set = beatmapGroup.BeatmapSet; - if (set == null) - continue; bool match = string.IsNullOrEmpty(search) || (set.Metadata.Artist ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 || (set.Metadata.ArtistUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 @@ -210,14 +208,14 @@ namespace osu.Game.Screens.Select || (set.Metadata.TitleUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1; if (match) { - changed = changed && !beatmapGroup.Hidden; + changed &= !beatmapGroup.Hidden; beatmapGroup.Hidden = false; if (newSelection == null || beatmapGroup.BeatmapSet.OnlineBeatmapSetID == Beatmap.BeatmapSetInfo.OnlineBeatmapSetID) newSelection = beatmapGroup; } else { - changed = changed && beatmapGroup.Hidden; + changed &= beatmapGroup.Hidden; beatmapGroup.Hidden = true; } } From b32cbdbec28e164b8b1bf35fefffdfc1cbad120d Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 30 Jan 2017 10:07:11 -0500 Subject: [PATCH 15/38] Relocate enums --- osu.Game/Screens/Select/FilterControl.cs | 60 ++++++++++++------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 0dfb3ccc06..8c9ccc017b 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -14,36 +14,6 @@ namespace osu.Game.Screens.Select { public class FilterControl : Container { - public enum SortMode - { - Arist, - BPM, - Creator, - DateAdded, - Difficulty, - Length, - RankAchieved, - Title - } - - public enum GroupMode - { - NoGrouping, - Arist, - BPM, - Creator, - DateAdded, - Difficulty, - Length, - RankAchieved, - Title, - Collections, - Favorites, - MyMaps, - RankedStatus, - RecentlyPlayed - } - public Action FilterChanged; public string Search => searchTextBox.Text; @@ -261,5 +231,35 @@ namespace osu.Game.Screens.Select sortEllipsis.Colour = colours.GreenLight; } } + + public enum SortMode + { + Arist, + BPM, + Creator, + DateAdded, + Difficulty, + Length, + RankAchieved, + Title + } + + public enum GroupMode + { + NoGrouping, + Arist, + BPM, + Creator, + DateAdded, + Difficulty, + Length, + RankAchieved, + Title, + Collections, + Favorites, + MyMaps, + RankedStatus, + RecentlyPlayed + } } } \ No newline at end of file From 9d07238a7de44a5f8a4f2308684462dc3911772c Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 30 Jan 2017 10:07:40 -0500 Subject: [PATCH 16/38] Update osu-framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 2f03fae533..0ce37fb5f9 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 2f03fae533293bf255a942569c07396f853378f3 +Subproject commit 0ce37fb5f9847b6889ad69c208ae9e561299fb8e From 09680196c937a6ff27edb55d9585edd08bc52313 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 30 Jan 2017 10:16:55 -0500 Subject: [PATCH 17/38] SearchTextBox: Don't handle Key.{Enter,Left,Right} --- osu.Game/Screens/Select/SearchTextBox.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/osu.Game/Screens/Select/SearchTextBox.cs b/osu.Game/Screens/Select/SearchTextBox.cs index ae8d9e3fde..2852565bf2 100644 --- a/osu.Game/Screens/Select/SearchTextBox.cs +++ b/osu.Game/Screens/Select/SearchTextBox.cs @@ -1,10 +1,12 @@ using System; using OpenTK; using OpenTK.Graphics; +using OpenTK.Input; using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input; using osu.Game.Graphics; namespace osu.Game.Screens.Select @@ -63,5 +65,12 @@ namespace osu.Game.Screens.Select base.LoadComplete(); OnFocus(null); } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (args.Key == Key.Left || args.Key == Key.Right || args.Key == Key.Enter) + return false; + return base.OnKeyDown(state, args); + } } } \ No newline at end of file From 144a87a247fb97b50a6b6e872c1548fea844631d Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 30 Jan 2017 13:43:21 -0500 Subject: [PATCH 18/38] Fix focus interactions with search text box --- osu.Game/Screens/Select/FilterControl.cs | 11 +++++++++++ osu.Game/Screens/Select/PlaySongSelect.cs | 8 ++++++++ osu.Game/Screens/Select/SearchTextBox.cs | 13 ++++++++++--- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 8c9ccc017b..9bcf3ad9a2 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -56,6 +56,17 @@ namespace osu.Game.Screens.Select }; } + public void Deactivate() + { + searchTextBox.GrabFocus = false; + searchTextBox.TriggerFocusLost(); + } + + public void Activate() + { + searchTextBox.GrabFocus = true; + } + private class TabItem : ClickableContainer { public string Text diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 72ab027fcb..24ad7974e7 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -242,6 +242,8 @@ namespace osu.Game.Screens.Select beatmapInfoWedge.MoveToX(wedged_container_start_position.X - 50); beatmapInfoWedge.MoveToX(wedged_container_start_position.X, 800, EasingTypes.OutQuint); + + filter.Activate(); } protected override void OnResuming(GameMode last) @@ -255,6 +257,8 @@ namespace osu.Game.Screens.Select Content.FadeIn(250); Content.ScaleTo(1, 250, EasingTypes.OutSine); + + filter.Activate(); } protected override void OnSuspending(GameMode next) @@ -262,6 +266,8 @@ namespace osu.Game.Screens.Select Content.ScaleTo(1.1f, 250, EasingTypes.InSine); Content.FadeOut(250); + + filter.Deactivate(); base.OnSuspending(next); } @@ -271,6 +277,8 @@ namespace osu.Game.Screens.Select beatmapInfoWedge.RotateTo(10, 800, EasingTypes.InQuint); Content.FadeOut(100); + + filter.Deactivate(); return base.OnExiting(next); } diff --git a/osu.Game/Screens/Select/SearchTextBox.cs b/osu.Game/Screens/Select/SearchTextBox.cs index 2852565bf2..8b95d74fb5 100644 --- a/osu.Game/Screens/Select/SearchTextBox.cs +++ b/osu.Game/Screens/Select/SearchTextBox.cs @@ -15,7 +15,7 @@ namespace osu.Game.Screens.Select { protected override Color4 BackgroundUnfocused => new Color4(10, 10, 10, 255); protected override Color4 BackgroundFocused => new Color4(10, 10, 10, 255); - public override bool HasFocus => true; + public bool GrabFocus = false; private SpriteText placeholder; @@ -63,12 +63,19 @@ namespace osu.Game.Screens.Select protected override void LoadComplete() { base.LoadComplete(); - OnFocus(null); + } + + protected override void Update() + { + if (GrabFocus && !HasFocus && IsVisible) + TriggerFocus(); + base.Update(); } protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { - if (args.Key == Key.Left || args.Key == Key.Right || args.Key == Key.Enter) + if (args.Key == Key.Left || args.Key == Key.Right + || args.Key == Key.Enter || args.Key == Key.Escape) return false; return base.OnKeyDown(state, args); } From 8d294a4eca6fefee6f7784a8ac99659d03e38ce2 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 30 Jan 2017 14:03:05 -0500 Subject: [PATCH 19/38] Only grab focus if nothing else has it --- osu.Game/Screens/Select/SearchTextBox.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/SearchTextBox.cs b/osu.Game/Screens/Select/SearchTextBox.cs index 8b95d74fb5..a6790e1130 100644 --- a/osu.Game/Screens/Select/SearchTextBox.cs +++ b/osu.Game/Screens/Select/SearchTextBox.cs @@ -68,7 +68,13 @@ namespace osu.Game.Screens.Select protected override void Update() { if (GrabFocus && !HasFocus && IsVisible) - TriggerFocus(); + { + var inputManager = Parent; + while (inputManager != null && !(inputManager is InputManager)) + inputManager = inputManager.Parent; + if (inputManager != null && (inputManager as InputManager)?.FocusedDrawable == null) + TriggerFocus(); + } base.Update(); } From 5852657205892c393fdb7d08bf4c57eadba97592 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 30 Jan 2017 22:35:09 -0500 Subject: [PATCH 20/38] Refactor out Hidden Also fixes a bug I didn't think about before --- osu.Game/Beatmaps/Drawables/BeatmapGroup.cs | 25 ++++++++------------ osu.Game/Screens/Select/CarouselContainer.cs | 6 ++--- osu.Game/Screens/Select/PlaySongSelect.cs | 8 +++---- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index 1994083805..7bb855eed5 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -33,28 +33,16 @@ namespace osu.Game.Beatmaps.Drawables public BeatmapSetInfo BeatmapSet; - private bool hidden; - public bool Hidden - { - get { return hidden; } - set - { - hidden = value; - Header.Alpha = hidden ? 0 : 1; - if (hidden) - State = BeatmapGroupState.Collapsed; - } - } - public BeatmapGroupState State { get { return state; } set { - state = value; - switch (state) + switch (value) { case BeatmapGroupState.Expanded: + if (state == BeatmapGroupState.Hidden) + Header.Alpha = 1; foreach (BeatmapPanel panel in BeatmapPanels) panel.FadeIn(250); @@ -63,14 +51,20 @@ namespace osu.Game.Beatmaps.Drawables SelectedPanel.State = PanelSelectedState.Selected; break; case BeatmapGroupState.Collapsed: + case BeatmapGroupState.Hidden: + if (state == BeatmapGroupState.Hidden && state != value) + Header.Alpha = 1; Header.State = PanelSelectedState.NotSelected; if (SelectedPanel != null) SelectedPanel.State = PanelSelectedState.NotSelected; foreach (BeatmapPanel panel in BeatmapPanels) panel.FadeOut(300, EasingTypes.OutQuint); + if (value == BeatmapGroupState.Hidden) + Header.Alpha = 0; break; } + state = value; } } @@ -127,5 +121,6 @@ namespace osu.Game.Beatmaps.Drawables { Collapsed, Expanded, + Hidden, } } diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index 5337255bbf..5f431e4a88 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -119,7 +119,7 @@ namespace osu.Game.Screens.Select foreach (BeatmapGroup group in groups) { - movePanel(group.Header, !group.Hidden, ref currentY); + movePanel(group.Header, group.State != BeatmapGroupState.Hidden, ref currentY); if (group.State == BeatmapGroupState.Expanded) { @@ -134,10 +134,10 @@ namespace osu.Game.Screens.Select panel.MoveToX(-50, 500, EasingTypes.OutExpo); //on first display we want to begin hidden under our group's header. - if (panel.Alpha == 0 && !group.Hidden) + if (panel.Alpha == 0 && group.State != BeatmapGroupState.Hidden) panel.MoveToY(headerY); - movePanel(panel, !group.Hidden, ref currentY); + movePanel(panel, group.State != BeatmapGroupState.Hidden, ref currentY); } } else diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 24ad7974e7..5570af73af 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -208,15 +208,15 @@ namespace osu.Game.Screens.Select || (set.Metadata.TitleUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1; if (match) { - changed &= !beatmapGroup.Hidden; - beatmapGroup.Hidden = false; + changed |= beatmapGroup.State != BeatmapGroupState.Hidden; + beatmapGroup.State = BeatmapGroupState.Collapsed; if (newSelection == null || beatmapGroup.BeatmapSet.OnlineBeatmapSetID == Beatmap.BeatmapSetInfo.OnlineBeatmapSetID) newSelection = beatmapGroup; } else { - changed &= beatmapGroup.Hidden; - beatmapGroup.Hidden = true; + changed |= beatmapGroup.State == BeatmapGroupState.Hidden; + beatmapGroup.State = BeatmapGroupState.Hidden; } } if (newSelection != null) From acdf64e1f7f1d0a66bca6a63ba1f997dcd9473d7 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 30 Jan 2017 23:08:24 -0500 Subject: [PATCH 21/38] Remove code to check for other focused controls --- osu.Game/Screens/Select/SearchTextBox.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/osu.Game/Screens/Select/SearchTextBox.cs b/osu.Game/Screens/Select/SearchTextBox.cs index a6790e1130..8b95d74fb5 100644 --- a/osu.Game/Screens/Select/SearchTextBox.cs +++ b/osu.Game/Screens/Select/SearchTextBox.cs @@ -68,13 +68,7 @@ namespace osu.Game.Screens.Select protected override void Update() { if (GrabFocus && !HasFocus && IsVisible) - { - var inputManager = Parent; - while (inputManager != null && !(inputManager is InputManager)) - inputManager = inputManager.Parent; - if (inputManager != null && (inputManager as InputManager)?.FocusedDrawable == null) - TriggerFocus(); - } + TriggerFocus(); base.Update(); } From 4597a765b842bcdd98934f38eb7674ad512a5370 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 31 Jan 2017 19:00:54 -0500 Subject: [PATCH 22/38] Fix escape key to exit PlaySongSelect This is less than ideal but is the least disruptive solution. The InputManager itself holds Escape keypresses from getting to anything else if something is focused. --- osu.Game/Screens/Select/FilterControl.cs | 7 +++---- osu.Game/Screens/Select/PlaySongSelect.cs | 1 + osu.Game/Screens/Select/SearchTextBox.cs | 17 ++++++++++------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 9bcf3ad9a2..fa2aac6fae 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -18,6 +18,7 @@ namespace osu.Game.Screens.Select public string Search => searchTextBox.Text; public SortMode Sort { get; private set; } = SortMode.Title; + public Action Exit; private SearchTextBox searchTextBox; @@ -50,10 +51,8 @@ namespace osu.Game.Screens.Select } }; - searchTextBox.OnChange += (sender, text) => - { - FilterChanged?.Invoke(); - }; + searchTextBox.OnChange += (sender, text) => FilterChanged?.Invoke(); + searchTextBox.Exit = () => Exit?.Invoke(); } public void Deactivate() diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 5570af73af..27d37e7028 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -146,6 +146,7 @@ namespace osu.Game.Screens.Select Position = wedged_container_start_position, RelativeSizeAxes = Axes.X, FilterChanged = filterChanged, + Exit = () => Exit(), }, beatmapInfoWedge = new BeatmapInfoWedge { diff --git a/osu.Game/Screens/Select/SearchTextBox.cs b/osu.Game/Screens/Select/SearchTextBox.cs index 8b95d74fb5..9428fe7f32 100644 --- a/osu.Game/Screens/Select/SearchTextBox.cs +++ b/osu.Game/Screens/Select/SearchTextBox.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using OpenTK; using OpenTK.Graphics; using OpenTK.Input; @@ -15,6 +16,7 @@ namespace osu.Game.Screens.Select { protected override Color4 BackgroundUnfocused => new Color4(10, 10, 10, 255); protected override Color4 BackgroundFocused => new Color4(10, 10, 10, 255); + public Action Exit; public bool GrabFocus = false; private SpriteText placeholder; @@ -60,11 +62,6 @@ namespace osu.Game.Screens.Select }); } - protected override void LoadComplete() - { - base.LoadComplete(); - } - protected override void Update() { if (GrabFocus && !HasFocus && IsVisible) @@ -72,10 +69,16 @@ namespace osu.Game.Screens.Select base.Update(); } + protected override void OnFocusLost(InputState state) + { + if (state.Keyboard.Keys.Any(key => key == Key.Escape)) + Exit?.Invoke(); + base.OnFocusLost(state); + } + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { - if (args.Key == Key.Left || args.Key == Key.Right - || args.Key == Key.Enter || args.Key == Key.Escape) + if (args.Key == Key.Left || args.Key == Key.Right || args.Key == Key.Enter) return false; return base.OnKeyDown(state, args); } From 624d51204f71b1d0eead1caf921151327c98f3a5 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 31 Jan 2017 19:14:42 -0500 Subject: [PATCH 23/38] Fix issue with background on player Not sure why this only happens on my branch, I didn't touch this code. --- osu.Game/Screens/Play/Player.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index d6594dd2be..b7be66f86f 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -167,9 +167,6 @@ namespace osu.Game.Screens.Play { base.OnEntering(last); - (Background as BackgroundModeBeatmap)?.BlurTo(Vector2.Zero, 1000); - Background?.FadeTo((100f- dimLevel)/100, 1000); - Content.Alpha = 0; dimLevel.ValueChanged += dimChanged; } From 35a1479fc14b196c215733490a8ce006154b7c04 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 31 Jan 2017 19:37:00 -0500 Subject: [PATCH 24/38] Fix extra click sound effect --- osu.Game/Screens/Select/PlaySongSelect.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 27d37e7028..8e9248091c 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -189,9 +189,13 @@ namespace osu.Game.Screens.Select } private ScheduledDelegate filterTask; + private string previousFilter = null; private void filterChanged() { + if (previousFilter == filter.Search) + return; + previousFilter = filter.Search; filterTask?.Cancel(); filterTask = Scheduler.AddDelayed(() => { From f7407077128a8ce02e21298cc695feaeb9a592bd Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 31 Jan 2017 19:45:42 -0500 Subject: [PATCH 25/38] Initialize previousFilter to string.Empty --- osu.Game/Screens/Select/PlaySongSelect.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 8e9248091c..75c6d56b0d 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -189,7 +189,7 @@ namespace osu.Game.Screens.Select } private ScheduledDelegate filterTask; - private string previousFilter = null; + private string previousFilter = string.Empty; private void filterChanged() { From b1a55f6b5ee5e759a6dfec9073114fdf102b4273 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 31 Jan 2017 19:48:33 -0500 Subject: [PATCH 26/38] Use OnCommit instead of OnChange simplifies things --- osu.Game/Screens/Select/FilterControl.cs | 6 +++++- osu.Game/Screens/Select/PlaySongSelect.cs | 4 ---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index fa2aac6fae..78dd60d560 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -51,7 +51,11 @@ namespace osu.Game.Screens.Select } }; - searchTextBox.OnChange += (sender, text) => FilterChanged?.Invoke(); + searchTextBox.OnCommit += (sender, newText) => + { + if (newText) + FilterChanged?.Invoke(); + }; searchTextBox.Exit = () => Exit?.Invoke(); } diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 75c6d56b0d..27d37e7028 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -189,13 +189,9 @@ namespace osu.Game.Screens.Select } private ScheduledDelegate filterTask; - private string previousFilter = string.Empty; private void filterChanged() { - if (previousFilter == filter.Search) - return; - previousFilter = filter.Search; filterTask?.Cancel(); filterTask = Scheduler.AddDelayed(() => { From 0861eb79e46f0a92f5fee0d6088b742bffbd9829 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 31 Jan 2017 19:55:36 -0500 Subject: [PATCH 27/38] Minor cleanups --- osu.Desktop/Program.cs | 1 - osu.Game/Beatmaps/Drawables/BeatmapGroup.cs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs index b789c31777..ef2a4b8ba1 100644 --- a/osu.Desktop/Program.cs +++ b/osu.Desktop/Program.cs @@ -42,7 +42,6 @@ namespace osu.Desktop Console.WriteLine(@"Importing {0}", file); if (!importer.Import(Path.GetFullPath(file)).Wait(3000)) throw new TimeoutException(@"IPC took too long to send"); - Thread.Sleep(500); } } else diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index 7bb855eed5..3df0198368 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -28,7 +28,7 @@ namespace osu.Game.Beatmaps.Drawables public BeatmapSetHeader Header; private BeatmapGroupState state; - + public List BeatmapPanels; public BeatmapSetInfo BeatmapSet; From 3143e9d35e757dbec6778dd43fa6c8a7f093043d Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 31 Jan 2017 20:04:17 -0500 Subject: [PATCH 28/38] Fix poorly written BeatmapGroup logic --- osu.Game/Beatmaps/Drawables/BeatmapGroup.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index 3df0198368..e7652405f7 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -38,11 +38,10 @@ namespace osu.Game.Beatmaps.Drawables get { return state; } set { + Header.Alpha = state == BeatmapGroupState.Hidden ? 0 : 1; switch (value) { case BeatmapGroupState.Expanded: - if (state == BeatmapGroupState.Hidden) - Header.Alpha = 1; foreach (BeatmapPanel panel in BeatmapPanels) panel.FadeIn(250); @@ -52,16 +51,12 @@ namespace osu.Game.Beatmaps.Drawables break; case BeatmapGroupState.Collapsed: case BeatmapGroupState.Hidden: - if (state == BeatmapGroupState.Hidden && state != value) - Header.Alpha = 1; Header.State = PanelSelectedState.NotSelected; if (SelectedPanel != null) SelectedPanel.State = PanelSelectedState.NotSelected; foreach (BeatmapPanel panel in BeatmapPanels) panel.FadeOut(300, EasingTypes.OutQuint); - if (value == BeatmapGroupState.Hidden) - Header.Alpha = 0; break; } state = value; From 2d691ca8d5f529bd63de4c3049f271b7e58a55da Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 1 Feb 2017 19:11:24 -0500 Subject: [PATCH 29/38] Use OnChange instead of OnCommit OnCommit only gets fired when focus is lost --- osu.Game/Screens/Select/FilterControl.cs | 2 +- osu.Game/Screens/Select/PlaySongSelect.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 78dd60d560..9050b9b4cb 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -51,7 +51,7 @@ namespace osu.Game.Screens.Select } }; - searchTextBox.OnCommit += (sender, newText) => + searchTextBox.OnChange += (TextBox sender, bool newText) => { if (newText) FilterChanged?.Invoke(); diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 27d37e7028..535ef3a44c 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -222,7 +222,7 @@ namespace osu.Game.Screens.Select } if (newSelection != null) selectBeatmap(newSelection.BeatmapSet.Beatmaps[0]); - if (changed || true) + if (changed) carousel.InvalidateVisible(); }, 250); } From 3c7c3d1cb96021e50eb2b3f66819edaff8eedb9c Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 1 Feb 2017 19:11:58 -0500 Subject: [PATCH 30/38] Tidy up GetEnumerable --- osu.Game/Screens/Select/CarouselContainer.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index 6d43b538a1..101774b4fc 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -311,14 +311,8 @@ namespace osu.Game.Screens.Select SelectGroup(group, panel); } - public IEnumerator GetEnumerator() - { - return groups.GetEnumerator(); - } + public IEnumerator GetEnumerator() => groups.GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } } From 5003b3738ae92b2a4fa602b72adcb222f1f9273e Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 1 Feb 2017 19:15:22 -0500 Subject: [PATCH 31/38] Remove constant boolean expressions --- osu.Game/Screens/Select/CarouselContainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index 101774b4fc..5cd331e44d 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -134,10 +134,10 @@ namespace osu.Game.Screens.Select panel.MoveToX(-50, 500, EasingTypes.OutExpo); //on first display we want to begin hidden under our group's header. - if (panel.Alpha == 0 && group.State != BeatmapGroupState.Hidden) + if (panel.Alpha == 0) panel.MoveToY(headerY); - movePanel(panel, group.State != BeatmapGroupState.Hidden, ref currentY); + movePanel(panel, true, ref currentY); } } else From 9f9245cee39b61a61a27dd94b5027c0796bed6f4 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 1 Feb 2017 19:28:08 -0500 Subject: [PATCH 32/38] Fix use of previous value in Alpha check Frustratingly, this does not fix the problem of ghost groups --- osu.Game/Beatmaps/Drawables/BeatmapGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index e7652405f7..8d3df5afe7 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -38,7 +38,7 @@ namespace osu.Game.Beatmaps.Drawables get { return state; } set { - Header.Alpha = state == BeatmapGroupState.Hidden ? 0 : 1; + Header.Alpha = value == BeatmapGroupState.Hidden ? 0 : 1; switch (value) { case BeatmapGroupState.Expanded: From c88a2fbf8ae8c35fe0dd3c157bfb2b5f160c6b18 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 1 Feb 2017 19:32:30 -0500 Subject: [PATCH 33/38] Replace incorrectly removed background logic I had earlier thought that removing this would solve the weirdness with starting the beatmap on any but the first difficulty, and forgot to replace it when I found the actual cause. --- osu.Game/Screens/Play/Player.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index e59b8c5cf0..b3c0bc118d 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -251,6 +251,9 @@ namespace osu.Game.Screens.Play protected override void OnEntering(GameMode last) { base.OnEntering(last); + + (Background as BackgroundModeBeatmap)?.BlurTo(Vector2.Zero, 1000); + Background?.FadeTo((100f- dimLevel)/100, 1000); Content.Alpha = 0; dimLevel.ValueChanged += dimChanged; From aec84ae725ca37749365875e63cc68fd01f61717 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 2 Feb 2017 17:33:39 +0900 Subject: [PATCH 34/38] Fix laggy animations, incorrect hiding logic. --- osu.Game/Beatmaps/Drawables/BeatmapGroup.cs | 19 +- osu.Game/Beatmaps/Drawables/BeatmapPanel.cs | 5 +- .../Beatmaps/Drawables/BeatmapSetHeader.cs | 6 - osu.Game/Beatmaps/Drawables/Panel.cs | 7 + osu.Game/Overlays/Pause/PauseOverlay.cs | 382 +++++++++--------- osu.Game/Screens/Select/CarouselContainer.cs | 78 ++-- osu.Game/Screens/Select/PlaySongSelect.cs | 15 +- 7 files changed, 247 insertions(+), 265 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index 8d3df5afe7..8e4e37db12 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -38,25 +38,22 @@ namespace osu.Game.Beatmaps.Drawables get { return state; } set { - Header.Alpha = value == BeatmapGroupState.Hidden ? 0 : 1; switch (value) { case BeatmapGroupState.Expanded: - foreach (BeatmapPanel panel in BeatmapPanels) - panel.FadeIn(250); - Header.State = PanelSelectedState.Selected; - if (SelectedPanel != null) - SelectedPanel.State = PanelSelectedState.Selected; + foreach (BeatmapPanel panel in BeatmapPanels) + panel.State = panel == SelectedPanel ? PanelSelectedState.Selected : PanelSelectedState.NotSelected; break; case BeatmapGroupState.Collapsed: - case BeatmapGroupState.Hidden: Header.State = PanelSelectedState.NotSelected; - if (SelectedPanel != null) - SelectedPanel.State = PanelSelectedState.NotSelected; - foreach (BeatmapPanel panel in BeatmapPanels) - panel.FadeOut(300, EasingTypes.OutQuint); + panel.State = PanelSelectedState.Hidden; + break; + case BeatmapGroupState.Hidden: + Header.State = PanelSelectedState.Hidden; + foreach (BeatmapPanel panel in BeatmapPanels) + panel.State = PanelSelectedState.Hidden; break; } state = value; diff --git a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs index fdbf7430fb..9edfd9783a 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs @@ -2,14 +2,11 @@ //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using osu.Framework.Allocation; 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.Framework.Graphics.Textures; -using osu.Framework.MathUtils; using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; @@ -17,7 +14,6 @@ using osu.Game.Graphics.UserInterface; using OpenTK; using OpenTK.Graphics; using osu.Framework.Input; -using osu.Game.Modes; namespace osu.Game.Beatmaps.Drawables { @@ -33,6 +29,7 @@ namespace osu.Game.Beatmaps.Drawables protected override void Selected() { base.Selected(); + GainedSelection?.Invoke(this); background.ColourInfo = ColourInfo.GradientVertical( diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs index b15942c5bb..d961cd067c 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs @@ -68,12 +68,6 @@ namespace osu.Game.Beatmaps.Drawables }; } - protected override void LoadComplete() - { - base.LoadComplete(); - FadeInFromZero(250); - } - protected override void Selected() { base.Selected(); diff --git a/osu.Game/Beatmaps/Drawables/Panel.cs b/osu.Game/Beatmaps/Drawables/Panel.cs index ff89e5882d..22261dd49c 100644 --- a/osu.Game/Beatmaps/Drawables/Panel.cs +++ b/osu.Game/Beatmaps/Drawables/Panel.cs @@ -55,6 +55,7 @@ namespace osu.Game.Beatmaps.Drawables { switch (state) { + case PanelSelectedState.Hidden: case PanelSelectedState.NotSelected: Deselected(); break; @@ -62,6 +63,11 @@ namespace osu.Game.Beatmaps.Drawables Selected(); break; } + + if (state == PanelSelectedState.Hidden) + FadeOut(300, EasingTypes.OutQuint); + else + FadeIn(250); } private PanelSelectedState state = PanelSelectedState.NotSelected; @@ -112,6 +118,7 @@ namespace osu.Game.Beatmaps.Drawables enum PanelSelectedState { + Hidden, NotSelected, Selected } diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index 733133f005..6842e38d3f 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -1,212 +1,212 @@ -using System; -using OpenTK; -using OpenTK.Input; -using OpenTK.Graphics; -using osu.Game.Graphics; -using osu.Framework.Input; -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Containers; +using System; +using OpenTK; +using OpenTK.Input; +using OpenTK.Graphics; +using osu.Game.Graphics; +using osu.Framework.Input; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Transformations; using System.Threading.Tasks; -namespace osu.Game.Overlays.Pause -{ - public class PauseOverlay : OverlayContainer - { - private const int transition_duration = 200; - private const int button_height = 70; - private const float background_alpha = 0.75f; - - public Action OnResume; - public Action OnRetry; - public Action OnQuit; - - public int Retries - { - set - { +namespace osu.Game.Overlays.Pause +{ + public class PauseOverlay : OverlayContainer + { + private const int transition_duration = 200; + private const int button_height = 70; + private const float background_alpha = 0.75f; + + public Action OnResume; + public Action OnRetry; + public Action OnQuit; + + public int Retries + { + set + { if (retryCounterContainer != null) { // "You've retried 1,065 times in this session" - // "You've retried 1 time in this session" + // "You've retried 1 time in this session" retryCounterContainer.Children = new Drawable[] - { - new SpriteText - { - Text = "You've retried ", - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), - TextSize = 18 - }, - new SpriteText - { - Text = String.Format("{0:n0}", value), - Font = @"Exo2.0-Bold", - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), - TextSize = 18 - }, - new SpriteText - { - Text = $" time{((value == 1) ? "" : "s")} in this session", - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), - TextSize = 18 + { + new SpriteText + { + Text = "You've retried ", + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f), + TextSize = 18 + }, + new SpriteText + { + Text = String.Format("{0:n0}", value), + Font = @"Exo2.0-Bold", + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f), + TextSize = 18 + }, + new SpriteText + { + Text = $" time{((value == 1) ? "" : "s")} in this session", + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f), + TextSize = 18 } }; - } - } - } - - private FlowContainer retryCounterContainer; - - public override bool Contains(Vector2 screenSpacePos) => true; - public override bool HandleInput => State == Visibility.Visible; - - protected override void PopIn() => FadeIn(transition_duration, EasingTypes.In); - protected override void PopOut() => FadeOut(transition_duration, EasingTypes.In); - - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) - { - if (args.Key == Key.Escape) - { + } + } + } + + private FlowContainer retryCounterContainer; + + public override bool Contains(Vector2 screenSpacePos) => true; + public override bool HandleInput => State == Visibility.Visible; + + protected override void PopIn() => FadeIn(transition_duration, EasingTypes.In); + protected override void PopOut() => FadeOut(transition_duration, EasingTypes.In); + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (args.Key == Key.Escape) + { if (State == Visibility.Hidden) return false; resume(); - return true; - } - return base.OnKeyDown(state, args); - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) + return true; + } + return base.OnKeyDown(state, args); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) { - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - Alpha = background_alpha, - }, - new FlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FlowDirection.VerticalOnly, - Spacing = new Vector2(0f, 50f), - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Children = new Drawable[] - { - new FlowContainer - { - AutoSizeAxes = Axes.Both, - Direction = FlowDirection.VerticalOnly, - Spacing = new Vector2(0f, 20f), - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - Children = new Drawable[] - { - new SpriteText - { - Text = @"paused", - Font = @"Exo2.0-Medium", - Spacing = new Vector2(5, 0), - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - TextSize = 30, - Colour = colours.Yellow, - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f) - }, - new SpriteText - { - Text = @"you're not going to do what i think you're going to do, are ya?", - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f) - } - } - }, - new FlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Masking = true, - EdgeEffect = new EdgeEffect - { - Type = EdgeEffectType.Shadow, - Colour = Color4.Black.Opacity(0.6f), - Radius = 50 - }, - Children = new Drawable[] - { - new ResumeButton - { - RelativeSizeAxes = Axes.X, - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - Height = button_height, - Action = resume - }, - new RetryButton - { - RelativeSizeAxes = Axes.X, - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - Height = button_height, - Action = delegate - { - Hide(); - OnRetry?.Invoke(); - } - }, - new QuitButton - { - RelativeSizeAxes = Axes.X, - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - Height = button_height, - Action = delegate - { - Hide(); - OnQuit?.Invoke(); - } - } - } - }, - retryCounterContainer = new FlowContainer - { - AutoSizeAxes = Axes.Both, - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre - } - } - }, - new PauseProgressBar - { - Origin = Anchor.BottomCentre, - Anchor = Anchor.BottomCentre, - Width = 1f + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + Alpha = background_alpha, + }, + new FlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FlowDirection.VerticalOnly, + Spacing = new Vector2(0f, 50f), + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Children = new Drawable[] + { + new FlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FlowDirection.VerticalOnly, + Spacing = new Vector2(0f, 20f), + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Children = new Drawable[] + { + new SpriteText + { + Text = @"paused", + Font = @"Exo2.0-Medium", + Spacing = new Vector2(5, 0), + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + TextSize = 30, + Colour = colours.Yellow, + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f) + }, + new SpriteText + { + Text = @"you're not going to do what i think you're going to do, are ya?", + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f) + } + } + }, + new FlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Masking = true, + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(0.6f), + Radius = 50 + }, + Children = new Drawable[] + { + new ResumeButton + { + RelativeSizeAxes = Axes.X, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Height = button_height, + Action = resume + }, + new RetryButton + { + RelativeSizeAxes = Axes.X, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Height = button_height, + Action = delegate + { + Hide(); + OnRetry?.Invoke(); + } + }, + new QuitButton + { + RelativeSizeAxes = Axes.X, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Height = button_height, + Action = delegate + { + Hide(); + OnQuit?.Invoke(); + } + } + } + }, + retryCounterContainer = new FlowContainer + { + AutoSizeAxes = Axes.Both, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre + } + } + }, + new PauseProgressBar + { + Origin = Anchor.BottomCentre, + Anchor = Anchor.BottomCentre, + Width = 1f } - }; - + }; + Retries = 0; - } - - private void resume() - { + } + + private void resume() + { Hide(); - OnResume?.Invoke(); - } + OnResume?.Invoke(); + } public PauseOverlay() { RelativeSizeAxes = Axes.Both; } - } -} + } +} diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index 5cd331e44d..4798e9b491 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -1,23 +1,23 @@ //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; using System.Collections; -using osu.Framework.MathUtils; +using osu.Framework.MathUtils; namespace osu.Game.Screens.Select { @@ -97,10 +97,10 @@ namespace osu.Game.Screens.Select computeYPositions(); } - private void movePanel(Panel panel, bool advance, ref float currentY) + private void movePanel(Panel panel, bool advance, bool animated, ref float currentY) { yPositions.Add(currentY); - panel.MoveToY(currentY, 750, EasingTypes.OutExpo); + panel.MoveToY(currentY, animated && (panel.IsOnScreen || panel.State != PanelSelectedState.Hidden) ? 750 : 0, EasingTypes.OutExpo); if (advance) currentY += panel.DrawHeight + 5; @@ -110,7 +110,7 @@ namespace osu.Game.Screens.Select /// Computes the target Y positions for every panel in the carousel. /// /// The Y position of the currently selected panel. - private float computeYPositions() + private float computeYPositions(bool animated = true) { yPositions.Clear(); @@ -119,7 +119,7 @@ namespace osu.Game.Screens.Select foreach (BeatmapGroup group in groups) { - movePanel(group.Header, group.State != BeatmapGroupState.Hidden, ref currentY); + movePanel(group.Header, group.State != BeatmapGroupState.Hidden, animated, ref currentY); if (group.State == BeatmapGroupState.Expanded) { @@ -137,7 +137,7 @@ namespace osu.Game.Screens.Select if (panel.Alpha == 0) panel.MoveToY(headerY); - movePanel(panel, true, ref currentY); + movePanel(panel, true, animated, ref currentY); } } else @@ -147,7 +147,7 @@ namespace osu.Game.Screens.Select foreach (BeatmapPanel panel in group.BeatmapPanels) { panel.MoveToX(0, 500, EasingTypes.OutExpo); - movePanel(panel, false, ref currentY); + movePanel(panel, false, animated, ref currentY); } } } @@ -158,20 +158,20 @@ namespace osu.Game.Screens.Select return selectedY; } - public void SelectBeatmap(BeatmapInfo beatmap) + public void SelectBeatmap(BeatmapInfo beatmap, bool animated = true) { foreach (BeatmapGroup group in groups) { var panel = group.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(beatmap)); if (panel != null) { - SelectGroup(group, panel); + SelectGroup(group, panel, animated); return; } } } - public void SelectGroup(BeatmapGroup group, BeatmapPanel panel) + public void SelectGroup(BeatmapGroup group, BeatmapPanel panel, bool animated = true) { if (SelectedGroup != null && SelectedGroup != group) SelectedGroup.State = BeatmapGroupState.Collapsed; @@ -180,8 +180,8 @@ namespace osu.Game.Screens.Select panel.State = PanelSelectedState.Selected; SelectedPanel = panel; - float selectedY = computeYPositions(); - ScrollTo(selectedY); + float selectedY = computeYPositions(animated); + ScrollTo(selectedY, animated); } private static float offsetX(float dist, float halfHeight) @@ -246,18 +246,12 @@ namespace osu.Game.Screens.Select for (int i = firstIndex; i < lastIndex; ++i) { Panel p = Lifetime[i]; - p.IsOnScreen = true; + if (p.State != PanelSelectedState.Hidden) + p.IsOnScreen = true; //we don't want to update the on-screen state of hidden pannels as they have incorrect (stacked) y values. updatePanel(p, halfHeight); } } - public void InvalidateVisible() - { - Lifetime.StartIndex = 0; - Lifetime.EndIndex = groups.Count - 1; - computeYPositions(); - } - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { int direction = 0; @@ -298,17 +292,17 @@ namespace osu.Game.Screens.Select } return base.OnKeyDown(state, args); - } - - public void SelectRandom() - { - if (groups.Count < 1) - return; + } + + public void SelectRandom() + { + if (groups.Count < 1) + return; BeatmapGroup group = groups[RNG.Next(groups.Count)]; - BeatmapPanel panel = group?.BeatmapPanels.First(); - if (panel == null) - return; - SelectGroup(group, panel); + BeatmapPanel panel = group?.BeatmapPanels.First(); + if (panel == null) + return; + SelectGroup(group, panel); } public IEnumerator GetEnumerator() => groups.GetEnumerator(); diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 535ef3a44c..3255491ea7 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -146,7 +146,7 @@ namespace osu.Game.Screens.Select Position = wedged_container_start_position, RelativeSizeAxes = Axes.X, FilterChanged = filterChanged, - Exit = () => Exit(), + Exit = Exit, }, beatmapInfoWedge = new BeatmapInfoWedge { @@ -198,7 +198,6 @@ namespace osu.Game.Screens.Select filterTask = null; var search = filter.Search; BeatmapGroup newSelection = null; - bool changed = false; foreach (var beatmapGroup in carousel) { var set = beatmapGroup.BeatmapSet; @@ -209,24 +208,20 @@ namespace osu.Game.Screens.Select || (set.Metadata.TitleUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1; if (match) { - changed |= beatmapGroup.State != BeatmapGroupState.Hidden; beatmapGroup.State = BeatmapGroupState.Collapsed; if (newSelection == null || beatmapGroup.BeatmapSet.OnlineBeatmapSetID == Beatmap.BeatmapSetInfo.OnlineBeatmapSetID) newSelection = beatmapGroup; } else { - changed |= beatmapGroup.State == BeatmapGroupState.Hidden; beatmapGroup.State = BeatmapGroupState.Hidden; } } if (newSelection != null) - selectBeatmap(newSelection.BeatmapSet.Beatmaps[0]); - if (changed) - carousel.InvalidateVisible(); + carousel.SelectBeatmap(newSelection.BeatmapSet.Beatmaps[0], false); }, 250); } - + private void onDatabaseOnBeatmapSetAdded(BeatmapSetInfo s) { Schedule(() => addBeatmapSet(s, Game, true)); @@ -320,11 +315,9 @@ namespace osu.Game.Screens.Select //todo: change background in selectionChanged instead; support per-difficulty backgrounds. changeBackground(beatmap); - selectBeatmap(beatmap.BeatmapInfo); + carousel.SelectBeatmap(beatmap.BeatmapInfo); } - private void selectBeatmap(BeatmapInfo beatmap) => carousel.SelectBeatmap(beatmap); - /// /// selection has been changed as the result of interaction with the carousel. /// From 0c887d3a465a9a4c94055ee78706f7e54c5d0633 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 2 Feb 2017 19:24:43 +0900 Subject: [PATCH 35/38] Fix deselected group remaining visible after search. --- osu.Game/Screens/Select/CarouselContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index 4798e9b491..a0996c3a4b 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -173,7 +173,7 @@ namespace osu.Game.Screens.Select public void SelectGroup(BeatmapGroup group, BeatmapPanel panel, bool animated = true) { - if (SelectedGroup != null && SelectedGroup != group) + if (SelectedGroup != null && SelectedGroup != group && SelectedGroup.State != BeatmapGroupState.Hidden) SelectedGroup.State = BeatmapGroupState.Collapsed; SelectedGroup = group; From 966121a4382cef7a61acb1d3f69eb91ea0a3efb6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 2 Feb 2017 19:37:35 +0900 Subject: [PATCH 36/38] Fix keyboard controls not respecting search filter. --- osu.Game/Screens/Select/CarouselContainer.cs | 36 +++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index a0996c3a4b..017bc6512e 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -203,7 +203,7 @@ namespace osu.Game.Screens.Select private void updatePanel(Panel p, float halfHeight) { var height = p.IsVisible ? p.DrawHeight : 0; - + float panelDrawY = p.Position.Y - Current + height / 2; float dist = Math.Abs(1f - panelDrawY / halfHeight); @@ -275,23 +275,35 @@ namespace osu.Game.Screens.Select break; } - if (direction != 0) + if (direction == 0) + return base.OnKeyDown(state, args); + + if (!skipDifficulties) { - int index = SelectedGroup.BeatmapPanels.IndexOf(SelectedPanel) + direction; + int i = SelectedGroup.BeatmapPanels.IndexOf(SelectedPanel) + direction; - if (!skipDifficulties && index >= 0 && index < SelectedGroup.BeatmapPanels.Count) - //changing difficulty panel, not set. - SelectGroup(SelectedGroup, SelectedGroup.BeatmapPanels[index]); - else + if (i >= 0 && i < SelectedGroup.BeatmapPanels.Count) { - index = (groups.IndexOf(SelectedGroup) + direction + groups.Count) % groups.Count; - SelectBeatmap(groups[index].BeatmapPanels.First().Beatmap); + //changing difficulty panel, not set. + SelectGroup(SelectedGroup, SelectedGroup.BeatmapPanels[i]); + return true; } - - return true; } - return base.OnKeyDown(state, args); + int startIndex = groups.IndexOf(SelectedGroup); + int index = startIndex; + + do + { + index = (index + direction + groups.Count) % groups.Count; + if (groups[index].State != BeatmapGroupState.Hidden) + { + SelectBeatmap(groups[index].BeatmapPanels.First().Beatmap); + return true; + } + } while (index != startIndex); + + return true; } public void SelectRandom() From 7337ac93f4db8037b77665646478585eba4d71af Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 2 Feb 2017 19:38:01 +0900 Subject: [PATCH 37/38] Framework update. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 4880e5425c..16a01c7381 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 4880e5425cfa277be56ef87ec4d79a250ecb6d17 +Subproject commit 16a01c7381e3ee8ef6b4fe863ba9232deba04c29 From 437cc834ebc8586c02d70e8dbff90448e55e7d6a Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 2 Feb 2017 12:21:34 -0500 Subject: [PATCH 38/38] @Tom94 pointed out this problem --- osu.Game/Screens/Select/PlaySongSelect.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 3255491ea7..1fa6d9d3a6 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -91,7 +91,7 @@ namespace osu.Game.Screens.Select private void start() { - if (player != null) + if (player != null || Beatmap == 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