From 2629f78afc2fd04898010f0f5e945ba0f6c106e0 Mon Sep 17 00:00:00 2001 From: Kelvin <2yangk23@gmail.com> Date: Sat, 4 Mar 2017 20:07:47 -0800 Subject: [PATCH 01/37] Add FilterControl and FilterTabControl --- osu-resources | 2 +- .../Tests/TestCasePlaySongSelect.cs | 9 +- .../Graphics/UserInterface/OsuDropDownMenu.cs | 2 +- osu.Game/Screens/Select/CarouselContainer.cs | 11 +- osu.Game/Screens/Select/Filter/GroupMode.cs | 42 ++++ osu.Game/Screens/Select/Filter/SortMode.cs | 28 +++ osu.Game/Screens/Select/FilterControl.cs | 225 +++--------------- .../Screens/Select/Tab/FilterTabControl.cs | 14 ++ .../Select/Tab/FilterTabDropDownHeader.cs | 40 ++++ .../Select/Tab/FilterTabDropDownMenu.cs | 70 ++++++ .../Select/Tab/FilterTabDropDownMenuItem.cs | 39 +++ osu.Game/Screens/Select/Tab/FilterTabItem.cs | 105 ++++++++ osu.Game/osu.Game.csproj | 7 + 13 files changed, 397 insertions(+), 197 deletions(-) create mode 100644 osu.Game/Screens/Select/Filter/GroupMode.cs create mode 100644 osu.Game/Screens/Select/Filter/SortMode.cs create mode 100644 osu.Game/Screens/Select/Tab/FilterTabControl.cs create mode 100644 osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs create mode 100644 osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs create mode 100644 osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs create mode 100644 osu.Game/Screens/Select/Tab/FilterTabItem.cs diff --git a/osu-resources b/osu-resources index 4f9ed4e703..51f2b9b37f 160000 --- a/osu-resources +++ b/osu-resources @@ -1 +1 @@ -Subproject commit 4f9ed4e703777ede98737c7e2af31efa4694c395 +Subproject commit 51f2b9b37f38cd349a3dd728a78f8fffcb3a54f5 diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs index 84bb1cfde6..cb5ff53646 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs @@ -8,6 +8,7 @@ using osu.Framework.MathUtils; using osu.Game.Database; using osu.Game.Modes; using osu.Game.Screens.Select; +using osu.Game.Screens.Select.Filter; namespace osu.Desktop.VisualTests.Tests { @@ -39,10 +40,10 @@ namespace osu.Desktop.VisualTests.Tests Add(songSelect = new PlaySongSelect()); - AddButton(@"Sort by Artist", delegate { songSelect.Filter.Sort = FilterControl.SortMode.Artist; }); - AddButton(@"Sort by Title", delegate { songSelect.Filter.Sort = FilterControl.SortMode.Title; }); - AddButton(@"Sort by Author", delegate { songSelect.Filter.Sort = FilterControl.SortMode.Author; }); - AddButton(@"Sort by Difficulty", delegate { songSelect.Filter.Sort = FilterControl.SortMode.Difficulty; }); + AddButton(@"Sort by Artist", delegate { songSelect.Filter.Sort = SortMode.Artist; }); + AddButton(@"Sort by Title", delegate { songSelect.Filter.Sort = SortMode.Title; }); + AddButton(@"Sort by Author", delegate { songSelect.Filter.Sort = SortMode.Author; }); + AddButton(@"Sort by Difficulty", delegate { songSelect.Filter.Sort = SortMode.Difficulty; }); } protected override void Dispose(bool isDisposing) diff --git a/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs b/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs index 786636ce1a..6ca44034c6 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs @@ -11,7 +11,7 @@ namespace osu.Game.Graphics.UserInterface { public class OsuDropDownMenu : DropDownMenu { - protected override DropDownHeader CreateHeader() => new OsuDropDownHeader(); + protected override BasicDropDownHeader CreateHeader() => new OsuDropDownHeader(); public OsuDropDownMenu() { diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index 6a5bb2dc94..c0340acbd5 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -15,6 +15,7 @@ using OpenTK.Input; using System.Collections; using osu.Framework.MathUtils; using System.Diagnostics; +using osu.Game.Screens.Select.Filter; namespace osu.Game.Screens.Select { @@ -157,21 +158,21 @@ namespace osu.Game.Screens.Select ScrollTo(selectedY, animated); } - public void Sort(FilterControl.SortMode mode) + public void Sort(SortMode mode) { List sortedGroups = new List(groups); switch (mode) { - case FilterControl.SortMode.Artist: + case SortMode.Artist: sortedGroups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Artist, y.BeatmapSet.Metadata.Artist, StringComparison.InvariantCultureIgnoreCase)); break; - case FilterControl.SortMode.Title: + case SortMode.Title: sortedGroups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Title, y.BeatmapSet.Metadata.Title, StringComparison.InvariantCultureIgnoreCase)); break; - case FilterControl.SortMode.Author: + case SortMode.Author: sortedGroups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Author, y.BeatmapSet.Metadata.Author, StringComparison.InvariantCultureIgnoreCase)); break; - case FilterControl.SortMode.Difficulty: + case SortMode.Difficulty: sortedGroups.Sort((x, y) => { float xAverage = 0, yAverage = 0; diff --git a/osu.Game/Screens/Select/Filter/GroupMode.cs b/osu.Game/Screens/Select/Filter/GroupMode.cs new file mode 100644 index 0000000000..a0e343b164 --- /dev/null +++ b/osu.Game/Screens/Select/Filter/GroupMode.cs @@ -0,0 +1,42 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE + +using System.ComponentModel; + +namespace osu.Game.Screens.Select.Filter +{ + public enum GroupMode + { + None = 0, + [Description("All")] + All, + [Description("Artist")] + Artist, + [Description("Author")] + Author, + [Description("BPM")] + BPM, + [Description("Collections")] + Collections, + [Description("Date Added")] + DateAdded, + [Description("Difficulty")] + Difficulty, + [Description("Favorites")] + Favorites, + [Description("Length")] + Length, + [Description("My Maps")] + MyMaps, + [Description("No Grouping")] + NoGrouping, + [Description("Rank Achieved")] + RankAchieved, + [Description("Ranked Status")] + RankedStatus, + [Description("Recently Played")] + RecentlyPlayed, + [Description("Title")] + Title + } +} diff --git a/osu.Game/Screens/Select/Filter/SortMode.cs b/osu.Game/Screens/Select/Filter/SortMode.cs new file mode 100644 index 0000000000..d0b7f3e614 --- /dev/null +++ b/osu.Game/Screens/Select/Filter/SortMode.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE + +using System.ComponentModel; + +namespace osu.Game.Screens.Select.Filter +{ + public enum SortMode + { + None = 0, + [Description("Artist")] + Artist, + [Description("Author")] + Author, + [Description("BPM")] + BPM, + [Description("Date Added")] + DateAdded, + [Description("Difficulty")] + Difficulty, + [Description("Length")] + Length, + [Description("Rank Achieved")] + RankAchieved, + [Description("Title")] + Title + } +} diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index e20c170e3f..2d1ab6cf7b 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -2,16 +2,19 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using osu.Framework.Allocation; using OpenTK; using OpenTK.Graphics; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; -using osu.Framework.Input; +using osu.Framework.Graphics.UserInterface.Tab; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Screens.Select.Filter; +using osu.Game.Screens.Select.Tab; +using Container = osu.Framework.Graphics.Containers.Container; namespace osu.Game.Screens.Select { @@ -23,7 +26,8 @@ namespace osu.Game.Screens.Select private SortMode sort = SortMode.Title; public SortMode Sort { get { return sort; } - set { + set + { if (sort != value) { sort = value; @@ -36,7 +40,7 @@ namespace osu.Game.Screens.Select private SearchTextBox searchTextBox; - public FilterControl() + public FilterControl(float height) { Children = new Drawable[] { @@ -44,7 +48,8 @@ namespace osu.Game.Screens.Select { Colour = Color4.Black, Alpha = 0.8f, - RelativeSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.X, + Height = height }, new FillFlowContainer { @@ -57,7 +62,8 @@ namespace osu.Game.Screens.Select Direction = FillDirection.Vertical, Children = new Drawable[] { - searchTextBox = new SearchTextBox { + searchTextBox = new SearchTextBox + { RelativeSizeAxes = Axes.X, OnChange = (sender, newText) => { @@ -83,97 +89,20 @@ namespace osu.Game.Screens.Select searchTextBox.HoldFocus = true; } - private class TabItem : ClickableContainer + private class GroupSortTabs : Container { - public string Text - { - get { return text.Text; } - set { text.Text = value; } - } + private TabControl groupTabs; + private TabControl sortTabs; - private void fadeActive() + public GroupSortTabs() { - box.FadeIn(300); - text.FadeColour(Color4.White, 300); - } - - private void fadeInactive() - { - box.FadeOut(300); - text.FadeColour(fadeColour, 300); - } - - private bool active; - public bool Active - { - get { return active; } - set - { - active = value; - if (active) - fadeActive(); - else - fadeInactive(); - } - } - - private SpriteText text; - private Box box; - private Color4 fadeColour; - - protected override bool OnHover(InputState state) - { - if (!active) - fadeActive(); - return true; - } - - protected override void OnHoverLost(InputState state) - { - if (!active) - fadeInactive(); - } - - public TabItem() - { - AutoSizeAxes = Axes.Both; - Children = new Drawable[] - { - text = new OsuSpriteText - { - Margin = new MarginPadding(5), - TextSize = 14, - Font = @"Exo2.0-Bold", - }, - box = new Box - { - RelativeSizeAxes = Axes.X, - Height = 1, - Alpha = 0, - Colour = Color4.White, - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - } - }; + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; } [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; - AutoSizeAxes = Axes.Y; Children = new Drawable[] { new Box @@ -181,110 +110,34 @@ namespace osu.Game.Screens.Select RelativeSizeAxes = Axes.X, Height = 1, Colour = OsuColour.Gray(80), - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, + Origin = Anchor.TopLeft, + Anchor = Anchor.TopLeft, + Position = new Vector2(0, 23) }, - new FillFlowContainer + groupTabs = new FilterTabControl { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(10, 0), - Children = new Drawable[] - { - new TabItem - { - Text = "All", - Active = true, - }, - new TabItem - { - Text = "Recently Played", - Active = false, - }, - new TabItem - { - Text = "Collections", - Active = false, - }, - groupsEllipsis = new TextAwesome - { - Icon = FontAwesome.fa_ellipsis_h, - Origin = Anchor.TopLeft, - TextSize = 14, - Margin = new MarginPadding { Top = 5, Bottom = 5 }, - } - } + Width = 210 }, - new FillFlowContainer + sortTabs = new FilterTabControl { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(10, 0), - Origin = Anchor.TopRight, + Width = 180, Anchor = Anchor.TopRight, - Children = new Drawable[] - { - sortLabel = new OsuSpriteText - { - Font = @"Exo2.0-Bold", - Text = "Sort results by", - TextSize = 14, - Margin = new MarginPadding { Top = 5, Bottom = 5 }, - }, - new TabItem - { - Text = "Artist", - Active = true, - }, - sortEllipsis = new TextAwesome - { - Icon = FontAwesome.fa_ellipsis_h, - Origin = Anchor.TopLeft, - TextSize = 14, - Margin = new MarginPadding { Top = 5, Bottom = 5 }, - } - } - }, + Origin = Anchor.TopRight + } }; + sortTabs.Prefix.Children = new Drawable[] + { + new OsuSpriteText + { + Font = @"Exo2.0-Bold", + Text = "Sort results by", + TextSize = 14, + Margin = new MarginPadding { Top = 5, Bottom = 5 }, + } + }; + groupTabs.Pin(GroupMode.All); + groupTabs.Pin(GroupMode.RecentlyPlayed); } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - groupsEllipsis.Colour = colours.Blue; - sortLabel.Colour = colours.GreenLight; - sortEllipsis.Colour = colours.GreenLight; - } - } - - public enum SortMode - { - Artist, - BPM, - Author, - DateAdded, - Difficulty, - Length, - RankAchieved, - Title - } - - public enum GroupMode - { - NoGrouping, - Artist, - BPM, - Author, - DateAdded, - Difficulty, - Length, - RankAchieved, - Title, - Collections, - Favorites, - MyMaps, - RankedStatus, - RecentlyPlayed } } } \ No newline at end of file diff --git a/osu.Game/Screens/Select/Tab/FilterTabControl.cs b/osu.Game/Screens/Select/Tab/FilterTabControl.cs new file mode 100644 index 0000000000..b076f66bde --- /dev/null +++ b/osu.Game/Screens/Select/Tab/FilterTabControl.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics.UserInterface.Tab; + +namespace osu.Game.Screens.Select.Tab +{ + public class FilterTabControl : TabControl + { + protected override TabDropDownMenu CreateDropDownMenu() => new FilterTabDropDownMenu(); + + protected override TabItem CreateTabItem(T value) => new FilterTabItem { Value = value }; + } +} diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs new file mode 100644 index 0000000000..7d90dea594 --- /dev/null +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs @@ -0,0 +1,40 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics; + +namespace osu.Game.Screens.Select.Tab +{ + public class FilterTabDropDownHeader : BasicDropDownHeader + { + protected override string Label { get; set; } + + private TextAwesome ellipses; + + public FilterTabDropDownHeader() + { + AutoSizeAxes = Axes.Both; + Children = new Drawable[] + { + ellipses = new TextAwesome + { + Icon = FontAwesome.fa_ellipsis_h, + TextSize = 14, + Margin = new MarginPadding{ Top = 6, Bottom = 4 }, + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + ellipses.Colour = colours.Blue; + } + } +} diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs new file mode 100644 index 0000000000..7555a59d25 --- /dev/null +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs @@ -0,0 +1,70 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Extensions; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics.Transforms; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Graphics.UserInterface.Tab; +using osu.Game.Graphics; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.Screens.Select.Tab +{ + public class FilterTabDropDownMenu : TabDropDownMenu + { + protected override BasicDropDownHeader CreateHeader() => new FilterTabDropDownHeader(); + + protected override IEnumerable> GetDropDownItems(IEnumerable> values) + => values.Select(v => new FilterTabDropDownMenuItem(v.Key, v.Value)); + + public FilterTabDropDownMenu() + { + ContentContainer.CornerRadius = 4; + MaxDropDownHeight = int.MaxValue; + ContentBackground.Colour = Color4.Black.Opacity(0.5f); + + if (!typeof(T).IsEnum) + throw new InvalidOperationException("TabControl only supports enums as the generic type argument"); + + List> items = new List>(); + foreach (var val in (T[])Enum.GetValues(typeof(T))) + { + if (!val.Equals(default(T))) + items.Add(new KeyValuePair((val as Enum)?.GetDescription(), val)); + } + + Items = items; + // TODO: ValueChanged Handling + } + + protected override void AnimateOpen() + { + ContentContainer.FadeIn(300, EasingTypes.OutQuint); + } + + protected override void AnimateClose() + { + ContentContainer.FadeOut(300, EasingTypes.OutQuint); + } + + protected override void UpdateContentHeight() + { + if (State == DropDownMenuState.Opened) + ContentContainer.ResizeTo(new Vector2(1, ContentHeight), 300, EasingTypes.OutQuint); + else + ContentContainer.ResizeTo(new Vector2(1, 0), 300, EasingTypes.OutQuint); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) { + //Colour = colours.White; + //SelectedItem.Colour = colours.Blue; + } + } +} diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs new file mode 100644 index 0000000000..42ab12e1e4 --- /dev/null +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs @@ -0,0 +1,39 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics; +using OpenTK.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Screens.Select.Tab +{ + public class FilterTabDropDownMenuItem : DropDownMenuItem + { + public FilterTabDropDownMenuItem(string text, T value) : base(text, value) + { + Foreground.Padding = new MarginPadding(5); + Background.Colour = Color4.Red; + Foreground.Margin = new MarginPadding { Left = 7 }; + Foreground.Add(new OsuSpriteText + { + Text = text, + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + }); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + BackgroundColour = Color4.Black.Opacity(0.8f); + BackgroundColourHover = new Color4(124, 200, 253, 255); + BackgroundColourSelected = new Color4(124, 200, 253, 255); + //BackgroundColourSelected = new Color4(163, 196, 36, 255); // Green + } + } +} diff --git a/osu.Game/Screens/Select/Tab/FilterTabItem.cs b/osu.Game/Screens/Select/Tab/FilterTabItem.cs new file mode 100644 index 0000000000..c24dbd7e15 --- /dev/null +++ b/osu.Game/Screens/Select/Tab/FilterTabItem.cs @@ -0,0 +1,105 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using osu.Framework.Allocation; +using osu.Framework.Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface.Tab; +using osu.Framework.Input; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using OpenTK.Graphics; + +namespace osu.Game.Screens.Select.Tab +{ + public class FilterTabItem : TabItem + { + private SpriteText text; + private Box box; + private Color4 fadeColour; + + public new T Value + { + get { return base.Value; } + set + { + base.Value = value; + text.Text = (value as Enum)?.GetDescription(); + } + } + + public override bool Active + { + get { return base.Active; } + set + { + if (value) + fadeActive(); + else + fadeInactive(); + base.Active = value; + } + } + + private void fadeActive() + { + box.FadeIn(300); + text.FadeColour(Color4.White, 300); + } + + private void fadeInactive() + { + box.FadeOut(300); + text.FadeColour(fadeColour, 300); + } + + protected override bool OnHover(InputState state) { + if (!Active) + fadeActive(); + return true; + } + + protected override void OnHoverLost(InputState state) { + if (!Active) + fadeInactive(); + } + + public FilterTabItem() + { + AutoSizeAxes = Axes.Both; + Children = new Drawable[] + { + text = new OsuSpriteText + { + Margin = new MarginPadding(5), + TextSize = 14, + Font = @"Exo2.0-Bold", // Font should only turn bold when active? + }, + box = new Box + { + RelativeSizeAxes = Axes.X, + Height = 1, + Alpha = 0, + Colour = Color4.White, + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + } + }; + } + + // TODO: Remove this (for debugging) + public override string ToString() { + return Value.ToString(); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + fadeColour = colours.Blue; + text.Colour = colours.Blue; + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index b377ba6096..a427a68555 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -84,6 +84,11 @@ + + + + + @@ -175,6 +180,8 @@ + + From 40bcc63a9091aa1878b95ae56310a311a6d1f9eb Mon Sep 17 00:00:00 2001 From: Kelvin <2yangk23@gmail.com> Date: Wed, 8 Mar 2017 01:19:00 -0800 Subject: [PATCH 02/37] Added and styled FilterTabControls --- .../Tests/TestCaseTabControl.cs | 60 +++++++++++++++++++ .../osu.Desktop.VisualTests.csproj | 1 + osu.Game/Screens/Select/FilterControl.cs | 53 +++++++++------- .../Screens/Select/Tab/FilterTabControl.cs | 8 +++ .../Select/Tab/FilterTabDropDownHeader.cs | 7 --- .../Select/Tab/FilterTabDropDownMenu.cs | 20 +++++-- .../Select/Tab/FilterTabDropDownMenuItem.cs | 25 ++++++-- osu.Game/Screens/Select/Tab/FilterTabItem.cs | 22 ++++--- 8 files changed, 148 insertions(+), 48 deletions(-) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs new file mode 100644 index 0000000000..d534acbdc8 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs @@ -0,0 +1,60 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.UserInterface.Tab; +using osu.Framework.Screens.Testing; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Screens.Select.Filter; +using osu.Game.Screens.Select.Tab; + +namespace osu.Desktop.VisualTests.Tests +{ + public class TestCaseTabControl : TestCase + { + public override string Description => @"Filter for song select"; + + public override void Reset() + { + base.Reset(); + + OsuSpriteText text; + FilterTabControl filter; + + Add(new FillFlowContainer + { + Direction = FillDirection.Horizontal, + AutoSizeAxes = Axes.Both, + Children = new Drawable[] + { + filter = new FilterTabControl(GroupMode.All, GroupMode.RecentlyPlayed) + { + Width = 229, + AutoSort = true + }, + text = new OsuSpriteText + { + Text = "None", + Margin = new MarginPadding(4) + } + } + }); + + filter.ValueChanged += (sender, mode) => + { + Debug.WriteLine($"Selected {mode}"); + text.Text = mode.ToString(); + }; + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 81ee7185bb..68aed38b34 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -193,6 +193,7 @@ + diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 2d1ab6cf7b..06e909924a 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -93,16 +93,12 @@ namespace osu.Game.Screens.Select { private TabControl groupTabs; private TabControl sortTabs; + private OsuSpriteText spriteText; public GroupSortTabs() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { Children = new Drawable[] { new Box @@ -114,29 +110,42 @@ namespace osu.Game.Screens.Select Anchor = Anchor.TopLeft, Position = new Vector2(0, 23) }, - groupTabs = new FilterTabControl + groupTabs = new FilterTabControl(GroupMode.All, GroupMode.RecentlyPlayed) { - Width = 210 + Width = 230, + AutoSort = true }, - sortTabs = new FilterTabControl + new Container { - Width = 180, + AutoSizeAxes = Axes.Both, Anchor = Anchor.TopRight, - Origin = Anchor.TopRight + Origin = Anchor.TopRight, + Children = new Drawable[] + { + spriteText = new OsuSpriteText + { + Font = @"Exo2.0-Bold", + Text = "Sort results by", + TextSize = 14, + Margin = new MarginPadding + { + Top = 5, + Bottom = 5 + }, + }, + sortTabs = new FilterTabControl(87) + { + Width = 191, + AutoSort = true + } + } } }; - sortTabs.Prefix.Children = new Drawable[] - { - new OsuSpriteText - { - Font = @"Exo2.0-Bold", - Text = "Sort results by", - TextSize = 14, - Margin = new MarginPadding { Top = 5, Bottom = 5 }, - } - }; - groupTabs.Pin(GroupMode.All); - groupTabs.Pin(GroupMode.RecentlyPlayed); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) { + spriteText.Colour = colours.GreenLight; } } } diff --git a/osu.Game/Screens/Select/Tab/FilterTabControl.cs b/osu.Game/Screens/Select/Tab/FilterTabControl.cs index b076f66bde..f36c088cf3 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabControl.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabControl.cs @@ -10,5 +10,13 @@ namespace osu.Game.Screens.Select.Tab protected override TabDropDownMenu CreateDropDownMenu() => new FilterTabDropDownMenu(); protected override TabItem CreateTabItem(T value) => new FilterTabItem { Value = value }; + + public FilterTabControl(float offset, params T[] pinned) : base(offset, pinned) + { + } + + public FilterTabControl(params T[] pinned) : base(pinned) + { + } } } diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs index 7d90dea594..df4766c3e7 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface; @@ -30,11 +29,5 @@ namespace osu.Game.Screens.Select.Tab } }; } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - ellipses.Colour = colours.Blue; - } } } diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs index 7555a59d25..20f211aaa2 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs @@ -7,10 +7,12 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Extensions; using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Transforms; using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface.Tab; using osu.Game.Graphics; +using osu.Game.Screens.Select.Filter; using OpenTK; using OpenTK.Graphics; @@ -18,6 +20,9 @@ namespace osu.Game.Screens.Select.Tab { public class FilterTabDropDownMenu : TabDropDownMenu { + public override float HeaderWidth => 14; + public override float HeaderHeight => 24; + protected override BasicDropDownHeader CreateHeader() => new FilterTabDropDownHeader(); protected override IEnumerable> GetDropDownItems(IEnumerable> values) @@ -25,9 +30,11 @@ namespace osu.Game.Screens.Select.Tab public FilterTabDropDownMenu() { - ContentContainer.CornerRadius = 4; MaxDropDownHeight = int.MaxValue; - ContentBackground.Colour = Color4.Black.Opacity(0.5f); + ContentContainer.CornerRadius = 4; + ContentBackground.Colour = Color4.Black.Opacity(0.9f); + ScrollContainer.ScrollDraggerVisible = false; + DropDownItemsContainer.Padding = new MarginPadding { Left = 5, Bottom = 7, Right = 5, Top = 7 }; if (!typeof(T).IsEnum) throw new InvalidOperationException("TabControl only supports enums as the generic type argument"); @@ -62,9 +69,12 @@ namespace osu.Game.Screens.Select.Tab } [BackgroundDependencyLoader] - private void load(OsuColour colours) { - //Colour = colours.White; - //SelectedItem.Colour = colours.Blue; + private void load(OsuColour colours) + { + if (typeof(T) == typeof(SortMode)) + Header.Colour = colours.GreenLight; + else + Header.Colour = colours.Blue; } } } diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs index 42ab12e1e4..6747fd3eee 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; using OpenTK.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Screens.Select.Filter; namespace osu.Game.Screens.Select.Tab { @@ -16,9 +17,11 @@ namespace osu.Game.Screens.Select.Tab { public FilterTabDropDownMenuItem(string text, T value) : base(text, value) { - Foreground.Padding = new MarginPadding(5); - Background.Colour = Color4.Red; + Foreground.Padding = new MarginPadding { Top = 4, Bottom = 4 }; Foreground.Margin = new MarginPadding { Left = 7 }; + + Masking = true; + CornerRadius = 6; Foreground.Add(new OsuSpriteText { Text = text, @@ -30,10 +33,20 @@ namespace osu.Game.Screens.Select.Tab [BackgroundDependencyLoader] private void load(OsuColour colours) { - BackgroundColour = Color4.Black.Opacity(0.8f); - BackgroundColourHover = new Color4(124, 200, 253, 255); - BackgroundColourSelected = new Color4(124, 200, 253, 255); - //BackgroundColourSelected = new Color4(163, 196, 36, 255); // Green + BackgroundColour = Color4.Black.Opacity(0f); + ForegroundColourHover = Color4.Black; + ForegroundColourSelected = Color4.Black; + + if (typeof(T) == typeof(SortMode)) + { + BackgroundColourHover = new Color4(163, 196, 36, 255); + BackgroundColourSelected = new Color4(163, 196, 36, 255); + } + else + { + BackgroundColourHover = new Color4(124, 200, 253, 255); + BackgroundColourSelected = new Color4(124, 200, 253, 255); + } } } } diff --git a/osu.Game/Screens/Select/Tab/FilterTabItem.cs b/osu.Game/Screens/Select/Tab/FilterTabItem.cs index c24dbd7e15..3847c84c92 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabItem.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabItem.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Extensions; using osu.Framework.Graphics; @@ -11,7 +12,7 @@ using osu.Framework.Graphics.UserInterface.Tab; using osu.Framework.Input; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using OpenTK.Graphics; +using osu.Game.Screens.Select.Filter; namespace osu.Game.Screens.Select.Tab { @@ -90,16 +91,21 @@ namespace osu.Game.Screens.Select.Tab }; } - // TODO: Remove this (for debugging) - public override string ToString() { - return Value.ToString(); - } - [BackgroundDependencyLoader] private void load(OsuColour colours) { - fadeColour = colours.Blue; - text.Colour = colours.Blue; + if (typeof(T) == typeof(SortMode)) + { + fadeColour = colours.GreenLight; + if (!Active) + text.Colour = colours.GreenLight; + } + else + { + fadeColour = colours.Blue; + if (!Active) + text.Colour = colours.Blue; + } } } } From ee3d3b682f0dfbf2546acad2771afd11b5850856 Mon Sep 17 00:00:00 2001 From: Kelvin <2yangk23@gmail.com> Date: Thu, 9 Mar 2017 02:50:00 -0800 Subject: [PATCH 03/37] Updated usage for DropDownHeader of FilterTabControl --- osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs | 2 +- .../Screens/Select/Tab/FilterTabDropDownHeader.cs | 11 +++++++---- osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs b/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs index 6ca44034c6..786636ce1a 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs @@ -11,7 +11,7 @@ namespace osu.Game.Graphics.UserInterface { public class OsuDropDownMenu : DropDownMenu { - protected override BasicDropDownHeader CreateHeader() => new OsuDropDownHeader(); + protected override DropDownHeader CreateHeader() => new OsuDropDownHeader(); public OsuDropDownMenu() { diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs index df4766c3e7..3c77b12010 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs @@ -8,16 +8,19 @@ using osu.Game.Graphics; namespace osu.Game.Screens.Select.Tab { - public class FilterTabDropDownHeader : BasicDropDownHeader + public class FilterTabDropDownHeader : DropDownHeader { protected override string Label { get; set; } private TextAwesome ellipses; - public FilterTabDropDownHeader() - { + public FilterTabDropDownHeader() { + Background.Hide(); // don't need a background + RelativeSizeAxes = Axes.None; AutoSizeAxes = Axes.Both; - Children = new Drawable[] + Foreground.RelativeSizeAxes = Axes.None; + Foreground.AutoSizeAxes = Axes.Both; + Foreground.Children = new Drawable[] { ellipses = new TextAwesome { diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs index 20f211aaa2..0ac2ff07d3 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs @@ -23,7 +23,7 @@ namespace osu.Game.Screens.Select.Tab public override float HeaderWidth => 14; public override float HeaderHeight => 24; - protected override BasicDropDownHeader CreateHeader() => new FilterTabDropDownHeader(); + protected override DropDownHeader CreateHeader() => new FilterTabDropDownHeader(); protected override IEnumerable> GetDropDownItems(IEnumerable> values) => values.Select(v => new FilterTabDropDownMenuItem(v.Key, v.Value)); From 755fb260dbb93ed31211e2336fb92376e7d118d1 Mon Sep 17 00:00:00 2001 From: Kelvin <2yangk23@gmail.com> Date: Tue, 14 Mar 2017 19:46:13 -0700 Subject: [PATCH 04/37] Updated TabControl Usage --- .../Tests/TestCaseTabControl.cs | 15 +++++---------- .../Graphics/UserInterface/OsuDropDownMenu.cs | 4 ++-- osu.Game/Screens/Select/FilterControl.cs | 4 +++- osu.Game/Screens/Select/SongSelect.cs | 4 ++-- osu.Game/Screens/Select/Tab/FilterTabControl.cs | 6 +----- .../Screens/Select/Tab/FilterTabDropDownHeader.cs | 9 ++------- .../Screens/Select/Tab/FilterTabDropDownMenu.cs | 3 +-- 7 files changed, 16 insertions(+), 29 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs index d534acbdc8..6ea957b5d0 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs @@ -1,19 +1,11 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE -using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.UserInterface.Tab; using osu.Framework.Screens.Testing; -using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Screens.Select.Filter; using osu.Game.Screens.Select.Tab; @@ -37,7 +29,7 @@ namespace osu.Desktop.VisualTests.Tests AutoSizeAxes = Axes.Both, Children = new Drawable[] { - filter = new FilterTabControl(GroupMode.All, GroupMode.RecentlyPlayed) + filter = new FilterTabControl { Width = 229, AutoSort = true @@ -49,7 +41,10 @@ namespace osu.Desktop.VisualTests.Tests } } }); - + + filter.PinTab(GroupMode.All); + filter.PinTab(GroupMode.RecentlyPlayed); + filter.ValueChanged += (sender, mode) => { Debug.WriteLine($"Selected {mode}"); diff --git a/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs b/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs index 786636ce1a..14615417f7 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs @@ -1,11 +1,11 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Graphics.Transforms; -using osu.Framework.Graphics.UserInterface; using OpenTK; using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics.Transforms; +using osu.Framework.Graphics.UserInterface; namespace osu.Game.Graphics.UserInterface { diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 06e909924a..3ab65f3d42 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -110,7 +110,7 @@ namespace osu.Game.Screens.Select Anchor = Anchor.TopLeft, Position = new Vector2(0, 23) }, - groupTabs = new FilterTabControl(GroupMode.All, GroupMode.RecentlyPlayed) + groupTabs = new FilterTabControl { Width = 230, AutoSort = true @@ -141,6 +141,8 @@ namespace osu.Game.Screens.Select } } }; + groupTabs.PinTab(GroupMode.All); + groupTabs.PinTab(GroupMode.RecentlyPlayed); } [BackgroundDependencyLoader] diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index ca8b353c57..132f737d22 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -109,10 +109,10 @@ namespace osu.Game.Screens.Select Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, }); - Add(filter = new FilterControl + Add(filter = new FilterControl(filter_height) { RelativeSizeAxes = Axes.X, - Height = filter_height, + AutoSizeAxes = Axes.Y, FilterChanged = () => filterChanged(), Exit = Exit, }); diff --git a/osu.Game/Screens/Select/Tab/FilterTabControl.cs b/osu.Game/Screens/Select/Tab/FilterTabControl.cs index f36c088cf3..5dd0c24ba1 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabControl.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabControl.cs @@ -11,11 +11,7 @@ namespace osu.Game.Screens.Select.Tab protected override TabItem CreateTabItem(T value) => new FilterTabItem { Value = value }; - public FilterTabControl(float offset, params T[] pinned) : base(offset, pinned) - { - } - - public FilterTabControl(params T[] pinned) : base(pinned) + public FilterTabControl(float offset = 0) : base(offset) { } } diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs index 3c77b12010..8ba4d9c402 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs @@ -3,23 +3,18 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.UserInterface; +using osu.Framework.Graphics.UserInterface.Tab; using osu.Game.Graphics; namespace osu.Game.Screens.Select.Tab { - public class FilterTabDropDownHeader : DropDownHeader + public class FilterTabDropDownHeader : TabDropDownHeader { protected override string Label { get; set; } private TextAwesome ellipses; public FilterTabDropDownHeader() { - Background.Hide(); // don't need a background - RelativeSizeAxes = Axes.None; - AutoSizeAxes = Axes.Both; - Foreground.RelativeSizeAxes = Axes.None; - Foreground.AutoSizeAxes = Axes.Both; Foreground.Children = new Drawable[] { ellipses = new TextAwesome diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs index 0ac2ff07d3..df96711e0c 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs @@ -25,8 +25,7 @@ namespace osu.Game.Screens.Select.Tab protected override DropDownHeader CreateHeader() => new FilterTabDropDownHeader(); - protected override IEnumerable> GetDropDownItems(IEnumerable> values) - => values.Select(v => new FilterTabDropDownMenuItem(v.Key, v.Value)); + protected override DropDownMenuItem CreateDropDownItem(string key, T value) => new FilterTabDropDownMenuItem(key, value); public FilterTabDropDownMenu() { From 20e2e7a8c80d6b68cbba03f6be9b0365e422832e Mon Sep 17 00:00:00 2001 From: Kelvin <2yangk23@gmail.com> Date: Tue, 14 Mar 2017 20:19:41 -0700 Subject: [PATCH 05/37] Sort on SortTabs ValueChanged --- osu.Game/Screens/Select/Filter/GroupMode.cs | 1 - osu.Game/Screens/Select/Filter/SortMode.cs | 1 - osu.Game/Screens/Select/FilterControl.cs | 134 ++++++++++-------- .../Screens/Select/Tab/FilterTabControl.cs | 6 + .../Select/Tab/FilterTabDropDownMenu.cs | 13 -- 5 files changed, 79 insertions(+), 76 deletions(-) diff --git a/osu.Game/Screens/Select/Filter/GroupMode.cs b/osu.Game/Screens/Select/Filter/GroupMode.cs index a0e343b164..5b7a1c332e 100644 --- a/osu.Game/Screens/Select/Filter/GroupMode.cs +++ b/osu.Game/Screens/Select/Filter/GroupMode.cs @@ -7,7 +7,6 @@ namespace osu.Game.Screens.Select.Filter { public enum GroupMode { - None = 0, [Description("All")] All, [Description("Artist")] diff --git a/osu.Game/Screens/Select/Filter/SortMode.cs b/osu.Game/Screens/Select/Filter/SortMode.cs index d0b7f3e614..2a7d62a623 100644 --- a/osu.Game/Screens/Select/Filter/SortMode.cs +++ b/osu.Game/Screens/Select/Filter/SortMode.cs @@ -7,7 +7,6 @@ namespace osu.Game.Screens.Select.Filter { public enum SortMode { - None = 0, [Description("Artist")] Artist, [Description("Author")] diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 3ab65f3d42..c8e85e4992 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -2,9 +2,9 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using osu.Framework.Allocation; using OpenTK; using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; @@ -36,6 +36,23 @@ namespace osu.Game.Screens.Select } } + private GroupMode group = GroupMode.All; + public GroupMode Group { + get { return group; } + set + { + if (group != value) + { + group = value; + FilterChanged?.Invoke(); + } + } + } + + private TabControl groupTabs; + private TabControl sortTabs; + private OsuSpriteText spriteText; + public Action Exit; private SearchTextBox searchTextBox; @@ -72,10 +89,61 @@ namespace osu.Game.Screens.Select }, Exit = () => Exit?.Invoke(), }, - new GroupSortTabs() + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.X, + Height = 1, + Colour = OsuColour.Gray(80), + Origin = Anchor.TopLeft, + Anchor = Anchor.TopLeft, + Position = new Vector2(0, 23) + }, + groupTabs = new FilterTabControl + { + Width = 230, + AutoSort = true + }, + new Container + { + AutoSizeAxes = Axes.Both, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Children = new Drawable[] + { + spriteText = new OsuSpriteText + { + Font = @"Exo2.0-Bold", + Text = "Sort results by", + TextSize = 14, + Margin = new MarginPadding + { + Top = 5, + Bottom = 5 + }, + }, + sortTabs = new FilterTabControl(87) + { + Width = 191, + AutoSort = true + } + } + } + } + } } } }; + + groupTabs.PinTab(GroupMode.All); + groupTabs.PinTab(GroupMode.RecentlyPlayed); + groupTabs.ValueChanged += (sender, value) => Group = value; + sortTabs.ValueChanged += (sender, value) => Sort = value; } public void Deactivate() @@ -89,66 +157,10 @@ namespace osu.Game.Screens.Select searchTextBox.HoldFocus = true; } - private class GroupSortTabs : Container + [BackgroundDependencyLoader] + private void load(OsuColour colours) { - private TabControl groupTabs; - private TabControl sortTabs; - private OsuSpriteText spriteText; - - public GroupSortTabs() - { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.X, - Height = 1, - Colour = OsuColour.Gray(80), - Origin = Anchor.TopLeft, - Anchor = Anchor.TopLeft, - Position = new Vector2(0, 23) - }, - groupTabs = new FilterTabControl - { - Width = 230, - AutoSort = true - }, - new Container - { - AutoSizeAxes = Axes.Both, - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - Children = new Drawable[] - { - spriteText = new OsuSpriteText - { - Font = @"Exo2.0-Bold", - Text = "Sort results by", - TextSize = 14, - Margin = new MarginPadding - { - Top = 5, - Bottom = 5 - }, - }, - sortTabs = new FilterTabControl(87) - { - Width = 191, - AutoSort = true - } - } - } - }; - groupTabs.PinTab(GroupMode.All); - groupTabs.PinTab(GroupMode.RecentlyPlayed); - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) { - spriteText.Colour = colours.GreenLight; - } + spriteText.Colour = colours.GreenLight; } } } \ No newline at end of file diff --git a/osu.Game/Screens/Select/Tab/FilterTabControl.cs b/osu.Game/Screens/Select/Tab/FilterTabControl.cs index 5dd0c24ba1..3f2e0d9a8e 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabControl.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabControl.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Graphics.UserInterface.Tab; namespace osu.Game.Screens.Select.Tab @@ -13,6 +14,11 @@ namespace osu.Game.Screens.Select.Tab public FilterTabControl(float offset = 0) : base(offset) { + if (!typeof(T).IsEnum) + throw new InvalidOperationException("FilterTabControl only supports enums as the generic type argument"); + + foreach (var val in (T[])Enum.GetValues(typeof(T))) + AddTab(val); } } } diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs index df96711e0c..5f56a8aa8b 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs @@ -34,19 +34,6 @@ namespace osu.Game.Screens.Select.Tab ContentBackground.Colour = Color4.Black.Opacity(0.9f); ScrollContainer.ScrollDraggerVisible = false; DropDownItemsContainer.Padding = new MarginPadding { Left = 5, Bottom = 7, Right = 5, Top = 7 }; - - if (!typeof(T).IsEnum) - throw new InvalidOperationException("TabControl only supports enums as the generic type argument"); - - List> items = new List>(); - foreach (var val in (T[])Enum.GetValues(typeof(T))) - { - if (!val.Equals(default(T))) - items.Add(new KeyValuePair((val as Enum)?.GetDescription(), val)); - } - - Items = items; - // TODO: ValueChanged Handling } protected override void AnimateOpen() From 18afd8eabeccf4be2859628cbce374bd57fb8c9e Mon Sep 17 00:00:00 2001 From: Kelvin <2yangk23@gmail.com> Date: Tue, 14 Mar 2017 20:30:42 -0700 Subject: [PATCH 06/37] Fixed license headers --- osu-resources | 2 +- osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs | 2 +- osu.Game/Screens/Select/Filter/GroupMode.cs | 2 +- osu.Game/Screens/Select/Filter/SortMode.cs | 2 +- osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs | 2 +- osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs | 8 ++------ osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs | 2 +- 7 files changed, 8 insertions(+), 12 deletions(-) diff --git a/osu-resources b/osu-resources index 51f2b9b37f..4f9ed4e703 160000 --- a/osu-resources +++ b/osu-resources @@ -1 +1 @@ -Subproject commit 51f2b9b37f38cd349a3dd728a78f8fffcb3a54f5 +Subproject commit 4f9ed4e703777ede98737c7e2af31efa4694c395 diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs index 6ea957b5d0..7fda6a4bbf 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs @@ -1,5 +1,5 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Diagnostics; using osu.Framework.Graphics; diff --git a/osu.Game/Screens/Select/Filter/GroupMode.cs b/osu.Game/Screens/Select/Filter/GroupMode.cs index 5b7a1c332e..b9e0938fcc 100644 --- a/osu.Game/Screens/Select/Filter/GroupMode.cs +++ b/osu.Game/Screens/Select/Filter/GroupMode.cs @@ -1,5 +1,5 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.ComponentModel; diff --git a/osu.Game/Screens/Select/Filter/SortMode.cs b/osu.Game/Screens/Select/Filter/SortMode.cs index 2a7d62a623..4beecb730e 100644 --- a/osu.Game/Screens/Select/Filter/SortMode.cs +++ b/osu.Game/Screens/Select/Filter/SortMode.cs @@ -1,5 +1,5 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.ComponentModel; diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs index 8ba4d9c402..13a3fd836b 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs @@ -1,5 +1,5 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs index 5f56a8aa8b..4acf6d6b1d 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs @@ -1,11 +1,9 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -using System.Collections.Generic; -using System.Linq; +using OpenTK; +using OpenTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Extensions; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Transforms; @@ -13,8 +11,6 @@ using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface.Tab; using osu.Game.Graphics; using osu.Game.Screens.Select.Filter; -using OpenTK; -using OpenTK.Graphics; namespace osu.Game.Screens.Select.Tab { diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs index 6747fd3eee..9a6b575fbc 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs @@ -1,5 +1,5 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; From 4353c9dc3d67f4c73a6339616832663a0cc9fc8a Mon Sep 17 00:00:00 2001 From: Kelvin <2yangk23@gmail.com> Date: Tue, 14 Mar 2017 20:42:02 -0700 Subject: [PATCH 07/37] Fixed Warnings --- osu.Game/Screens/Select/FilterControl.cs | 5 +++-- .../Screens/Select/Tab/FilterTabDropDownHeader.cs | 4 +--- .../Screens/Select/Tab/FilterTabDropDownMenu.cs | 13 +++---------- .../Screens/Select/Tab/FilterTabDropDownMenuItem.cs | 8 ++++---- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index c8e85e4992..a70af1a2b5 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -49,8 +49,6 @@ namespace osu.Game.Screens.Select } } - private TabControl groupTabs; - private TabControl sortTabs; private OsuSpriteText spriteText; public Action Exit; @@ -59,6 +57,9 @@ namespace osu.Game.Screens.Select public FilterControl(float height) { + TabControl sortTabs; + TabControl groupTabs; + Children = new Drawable[] { new Box diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs index 13a3fd836b..6a0ed9044e 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs @@ -12,12 +12,10 @@ namespace osu.Game.Screens.Select.Tab { protected override string Label { get; set; } - private TextAwesome ellipses; - public FilterTabDropDownHeader() { Foreground.Children = new Drawable[] { - ellipses = new TextAwesome + new TextAwesome { Icon = FontAwesome.fa_ellipsis_h, TextSize = 14, diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs index 4acf6d6b1d..b47976446c 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs @@ -44,19 +44,12 @@ namespace osu.Game.Screens.Select.Tab protected override void UpdateContentHeight() { - if (State == DropDownMenuState.Opened) - ContentContainer.ResizeTo(new Vector2(1, ContentHeight), 300, EasingTypes.OutQuint); - else - ContentContainer.ResizeTo(new Vector2(1, 0), 300, EasingTypes.OutQuint); + ContentContainer.ResizeTo(new Vector2(1, State == DropDownMenuState.Opened ? ContentHeight : 0), 300, EasingTypes.OutQuint); } [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - if (typeof(T) == typeof(SortMode)) - Header.Colour = colours.GreenLight; - else - Header.Colour = colours.Blue; + private void load(OsuColour colours) { + Header.Colour = typeof(T) == typeof(SortMode) ? colours.GreenLight : colours.Blue; } } } diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs index 9a6b575fbc..166ce33f05 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs @@ -39,13 +39,13 @@ namespace osu.Game.Screens.Select.Tab if (typeof(T) == typeof(SortMode)) { - BackgroundColourHover = new Color4(163, 196, 36, 255); - BackgroundColourSelected = new Color4(163, 196, 36, 255); + BackgroundColourHover = colours.GreenLight; + BackgroundColourSelected = colours.GreenLight; } else { - BackgroundColourHover = new Color4(124, 200, 253, 255); - BackgroundColourSelected = new Color4(124, 200, 253, 255); + BackgroundColourHover = colours.Blue; + BackgroundColourSelected = colours.Blue; } } } From 3aecbf57395d2b6933e2de0189bfd478dfee42a7 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 15 Mar 2017 20:11:50 -0400 Subject: [PATCH 08/37] Rearrange things somewhat --- .../Tests/TestCaseTabControl.cs | 6 +++--- .../UserInterface/OsuTabControl.cs} | 12 ++++++------ .../UserInterface/OsuTabDropDownHeader.cs} | 7 ++++--- .../UserInterface/OsuTabDropDownMenu.cs} | 13 +++++++------ .../UserInterface/OsuTabDropDownMenuItem.cs} | 6 +++--- .../UserInterface/OsuTabItem.cs} | 6 +++--- osu.Game/Screens/Select/FilterControl.cs | 15 +++++++++------ osu.Game/osu.Game.csproj | 10 +++++----- 8 files changed, 40 insertions(+), 35 deletions(-) rename osu.Game/{Screens/Select/Tab/FilterTabControl.cs => Graphics/UserInterface/OsuTabControl.cs} (57%) rename osu.Game/{Screens/Select/Tab/FilterTabDropDownHeader.cs => Graphics/UserInterface/OsuTabDropDownHeader.cs} (81%) rename osu.Game/{Screens/Select/Tab/FilterTabDropDownMenu.cs => Graphics/UserInterface/OsuTabDropDownMenu.cs} (83%) rename osu.Game/{Screens/Select/Tab/FilterTabDropDownMenuItem.cs => Graphics/UserInterface/OsuTabDropDownMenuItem.cs} (86%) rename osu.Game/{Screens/Select/Tab/FilterTabItem.cs => Graphics/UserInterface/OsuTabItem.cs} (92%) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs index 7fda6a4bbf..a072087956 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs @@ -8,7 +8,7 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Screens.Testing; using osu.Game.Graphics.Sprites; using osu.Game.Screens.Select.Filter; -using osu.Game.Screens.Select.Tab; +using osu.Game.Graphics.UserInterface; namespace osu.Desktop.VisualTests.Tests { @@ -21,7 +21,7 @@ namespace osu.Desktop.VisualTests.Tests base.Reset(); OsuSpriteText text; - FilterTabControl filter; + OsuTabControl filter; Add(new FillFlowContainer { @@ -29,7 +29,7 @@ namespace osu.Desktop.VisualTests.Tests AutoSizeAxes = Axes.Both, Children = new Drawable[] { - filter = new FilterTabControl + filter = new OsuTabControl { Width = 229, AutoSort = true diff --git a/osu.Game/Screens/Select/Tab/FilterTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs similarity index 57% rename from osu.Game/Screens/Select/Tab/FilterTabControl.cs rename to osu.Game/Graphics/UserInterface/OsuTabControl.cs index 3f2e0d9a8e..51df8e7830 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -4,18 +4,18 @@ using System; using osu.Framework.Graphics.UserInterface.Tab; -namespace osu.Game.Screens.Select.Tab +namespace osu.Game.Graphics.UserInterface { - public class FilterTabControl : TabControl + public class OsuTabControl : TabControl { - protected override TabDropDownMenu CreateDropDownMenu() => new FilterTabDropDownMenu(); + protected override TabDropDownMenu CreateDropDownMenu() => new OsuTabDropDownMenu(); - protected override TabItem CreateTabItem(T value) => new FilterTabItem { Value = value }; + protected override TabItem CreateTabItem(T value) => new OsuTabItem { Value = value }; - public FilterTabControl(float offset = 0) : base(offset) + public OsuTabControl(float offset = 0) : base(offset) { if (!typeof(T).IsEnum) - throw new InvalidOperationException("FilterTabControl only supports enums as the generic type argument"); + throw new InvalidOperationException("OsuTabControl only supports enums as the generic type argument"); foreach (var val in (T[])Enum.GetValues(typeof(T))) AddTab(val); diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs b/osu.Game/Graphics/UserInterface/OsuTabDropDownHeader.cs similarity index 81% rename from osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs rename to osu.Game/Graphics/UserInterface/OsuTabDropDownHeader.cs index 6a0ed9044e..5506365aef 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabDropDownHeader.cs @@ -6,13 +6,14 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface.Tab; using osu.Game.Graphics; -namespace osu.Game.Screens.Select.Tab +namespace osu.Game.Graphics.UserInterface { - public class FilterTabDropDownHeader : TabDropDownHeader + public class OsuTabDropDownHeader : TabDropDownHeader { protected override string Label { get; set; } - public FilterTabDropDownHeader() { + public OsuTabDropDownHeader() + { Foreground.Children = new Drawable[] { new TextAwesome diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs similarity index 83% rename from osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs rename to osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs index b47976446c..57f298513a 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs @@ -12,18 +12,18 @@ using osu.Framework.Graphics.UserInterface.Tab; using osu.Game.Graphics; using osu.Game.Screens.Select.Filter; -namespace osu.Game.Screens.Select.Tab +namespace osu.Game.Graphics.UserInterface { - public class FilterTabDropDownMenu : TabDropDownMenu + public class OsuTabDropDownMenu : TabDropDownMenu { public override float HeaderWidth => 14; public override float HeaderHeight => 24; - protected override DropDownHeader CreateHeader() => new FilterTabDropDownHeader(); + protected override DropDownHeader CreateHeader() => new OsuTabDropDownHeader(); - protected override DropDownMenuItem CreateDropDownItem(string key, T value) => new FilterTabDropDownMenuItem(key, value); + protected override DropDownMenuItem CreateDropDownItem(string key, T value) => new OsuTabDropDownMenuItem(key, value); - public FilterTabDropDownMenu() + public OsuTabDropDownMenu() { MaxDropDownHeight = int.MaxValue; ContentContainer.CornerRadius = 4; @@ -48,7 +48,8 @@ namespace osu.Game.Screens.Select.Tab } [BackgroundDependencyLoader] - private void load(OsuColour colours) { + private void load(OsuColour colours) + { Header.Colour = typeof(T) == typeof(SortMode) ? colours.GreenLight : colours.Blue; } } diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs similarity index 86% rename from osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs rename to osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs index 166ce33f05..130e026ab4 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenuItem.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs @@ -11,11 +11,11 @@ using OpenTK.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Screens.Select.Filter; -namespace osu.Game.Screens.Select.Tab +namespace osu.Game.Graphics.UserInterface { - public class FilterTabDropDownMenuItem : DropDownMenuItem + public class OsuTabDropDownMenuItem : DropDownMenuItem { - public FilterTabDropDownMenuItem(string text, T value) : base(text, value) + public OsuTabDropDownMenuItem(string text, T value) : base(text, value) { Foreground.Padding = new MarginPadding { Top = 4, Bottom = 4 }; Foreground.Margin = new MarginPadding { Left = 7 }; diff --git a/osu.Game/Screens/Select/Tab/FilterTabItem.cs b/osu.Game/Graphics/UserInterface/OsuTabItem.cs similarity index 92% rename from osu.Game/Screens/Select/Tab/FilterTabItem.cs rename to osu.Game/Graphics/UserInterface/OsuTabItem.cs index 3847c84c92..8b62829df3 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabItem.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabItem.cs @@ -14,9 +14,9 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Screens.Select.Filter; -namespace osu.Game.Screens.Select.Tab +namespace osu.Game.Graphics.UserInterface { - public class FilterTabItem : TabItem + public class OsuTabItem : TabItem { private SpriteText text; private Box box; @@ -68,7 +68,7 @@ namespace osu.Game.Screens.Select.Tab fadeInactive(); } - public FilterTabItem() + public OsuTabItem() { AutoSizeAxes = Axes.Both; Children = new Drawable[] diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index a70af1a2b5..7bf237d378 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -9,12 +9,12 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.UserInterface.Tab; using osu.Game.Graphics; +using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.Sprites; using osu.Game.Screens.Select.Filter; -using osu.Game.Screens.Select.Tab; using Container = osu.Framework.Graphics.Containers.Container; +using osu.Framework.Graphics.UserInterface.Tab; namespace osu.Game.Screens.Select { @@ -23,8 +23,10 @@ namespace osu.Game.Screens.Select public Action FilterChanged; public string Search => searchTextBox.Text; + private SortMode sort = SortMode.Title; - public SortMode Sort { + public SortMode Sort + { get { return sort; } set { @@ -37,7 +39,8 @@ namespace osu.Game.Screens.Select } private GroupMode group = GroupMode.All; - public GroupMode Group { + public GroupMode Group + { get { return group; } set { @@ -105,7 +108,7 @@ namespace osu.Game.Screens.Select Anchor = Anchor.TopLeft, Position = new Vector2(0, 23) }, - groupTabs = new FilterTabControl + groupTabs = new OsuTabControl { Width = 230, AutoSort = true @@ -128,7 +131,7 @@ namespace osu.Game.Screens.Select Bottom = 5 }, }, - sortTabs = new FilterTabControl(87) + sortTabs = new OsuTabControl(87) { Width = 191, AutoSort = true diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 5368b08260..1b6ea5d84b 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -85,11 +85,6 @@ - - - - - @@ -354,6 +349,11 @@ + + + + + From db5a1e241a23d80399634381f3a813339d47245d Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 15 Mar 2017 20:18:20 -0400 Subject: [PATCH 09/37] Don't crash on unimplemented sorts --- osu.Game/Screens/Select/CarouselContainer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index c0340acbd5..7de7779bd0 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -197,7 +197,8 @@ namespace osu.Game.Screens.Select }); break; default: - throw new NotImplementedException(); + Sort(SortMode.Artist); // Temporary + break; } scrollableContent.Clear(false); From 01cca1a4d217188ee05e0db4b405f683fb5ea827 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 15 Mar 2017 20:52:31 -0400 Subject: [PATCH 10/37] Refactor color handling colour* --- .../Graphics/UserInterface/OsuTabControl.cs | 22 +++++++++++ .../UserInterface/OsuTabDropDownMenu.cs | 26 ++++++++++--- .../UserInterface/OsuTabDropDownMenuItem.cs | 28 +++++++------- osu.Game/Graphics/UserInterface/OsuTabItem.cs | 37 ++++++++++--------- osu.Game/Screens/Select/FilterControl.cs | 7 ++-- 5 files changed, 81 insertions(+), 39 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 51df8e7830..d03fb474b8 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -2,6 +2,8 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Graphics.UserInterface.Tab; namespace osu.Game.Graphics.UserInterface @@ -20,5 +22,25 @@ namespace osu.Game.Graphics.UserInterface foreach (var val in (T[])Enum.GetValues(typeof(T))) AddTab(val); } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + if (accentColour == null) + AccentColour = colours.Blue; + } + + private Color4? accentColour; + public Color4 AccentColour + { + get { return accentColour.GetValueOrDefault(); } + set + { + accentColour = value; + (DropDown as OsuTabDropDownMenu).AccentColour = value; + foreach (OsuTabItem item in TabContainer.Children) + item.AccentColour = value; + } + } } } diff --git a/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs index 57f298513a..51e7009e45 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs @@ -9,8 +9,6 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Transforms; using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface.Tab; -using osu.Game.Graphics; -using osu.Game.Screens.Select.Filter; namespace osu.Game.Graphics.UserInterface { @@ -19,9 +17,26 @@ namespace osu.Game.Graphics.UserInterface public override float HeaderWidth => 14; public override float HeaderHeight => 24; - protected override DropDownHeader CreateHeader() => new OsuTabDropDownHeader(); + private Color4? accentColour; + public Color4 AccentColour + { + get { return accentColour.GetValueOrDefault(); } + set + { + accentColour = value; + Header.Colour = value; + foreach (OsuTabDropDownMenuItem item in ItemList) + item.AccentColour = value; + } + } - protected override DropDownMenuItem CreateDropDownItem(string key, T value) => new OsuTabDropDownMenuItem(key, value); + protected override DropDownHeader CreateHeader() => new OsuTabDropDownHeader + { + Colour = AccentColour + }; + + protected override DropDownMenuItem CreateDropDownItem(string key, T value) => + new OsuTabDropDownMenuItem(key, value) { AccentColour = AccentColour }; public OsuTabDropDownMenu() { @@ -50,7 +65,8 @@ namespace osu.Game.Graphics.UserInterface [BackgroundDependencyLoader] private void load(OsuColour colours) { - Header.Colour = typeof(T) == typeof(SortMode) ? colours.GreenLight : colours.Blue; + if (accentColour == null) + AccentColour = colours.Blue; } } } diff --git a/osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs index 130e026ab4..1df57e3ac6 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs @@ -6,10 +6,8 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface; -using osu.Game.Graphics; using OpenTK.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Screens.Select.Filter; namespace osu.Game.Graphics.UserInterface { @@ -30,23 +28,27 @@ namespace osu.Game.Graphics.UserInterface }); } + private Color4? accentColour; + public Color4 AccentColour + { + get { return accentColour.Value; } + set + { + accentColour = value; + BackgroundColourHover = BackgroundColourSelected = value; + FormatBackground(); + FormatForeground(); + } + } + [BackgroundDependencyLoader] private void load(OsuColour colours) { BackgroundColour = Color4.Black.Opacity(0f); ForegroundColourHover = Color4.Black; ForegroundColourSelected = Color4.Black; - - if (typeof(T) == typeof(SortMode)) - { - BackgroundColourHover = colours.GreenLight; - BackgroundColourSelected = colours.GreenLight; - } - else - { - BackgroundColourHover = colours.Blue; - BackgroundColourSelected = colours.Blue; - } + if (accentColour == null) + AccentColour = colours.Blue; } } } diff --git a/osu.Game/Graphics/UserInterface/OsuTabItem.cs b/osu.Game/Graphics/UserInterface/OsuTabItem.cs index 8b62829df3..ca4b70d5d8 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabItem.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabItem.cs @@ -10,9 +10,7 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface.Tab; using osu.Framework.Input; -using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Screens.Select.Filter; namespace osu.Game.Graphics.UserInterface { @@ -20,7 +18,18 @@ namespace osu.Game.Graphics.UserInterface { private SpriteText text; private Box box; - private Color4 fadeColour; + + private Color4? accentColour; + public Color4 AccentColour + { + get { return accentColour.GetValueOrDefault(); } + set + { + accentColour = value; + if (!Active) + text.Colour = value; + } + } public new T Value { @@ -54,16 +63,18 @@ namespace osu.Game.Graphics.UserInterface private void fadeInactive() { box.FadeOut(300); - text.FadeColour(fadeColour, 300); + text.FadeColour(AccentColour, 300); } - protected override bool OnHover(InputState state) { + protected override bool OnHover(InputState state) + { if (!Active) fadeActive(); return true; } - protected override void OnHoverLost(InputState state) { + protected override void OnHoverLost(InputState state) + { if (!Active) fadeInactive(); } @@ -94,18 +105,8 @@ namespace osu.Game.Graphics.UserInterface [BackgroundDependencyLoader] private void load(OsuColour colours) { - if (typeof(T) == typeof(SortMode)) - { - fadeColour = colours.GreenLight; - if (!Active) - text.Colour = colours.GreenLight; - } - else - { - fadeColour = colours.Blue; - if (!Active) - text.Colour = colours.Blue; - } + if (accentColour == null) + AccentColour = colours.Blue; } } } diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 7bf237d378..a162579b96 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -23,6 +23,8 @@ namespace osu.Game.Screens.Select public Action FilterChanged; public string Search => searchTextBox.Text; + + private OsuTabControl sortTabs; private SortMode sort = SortMode.Title; public SortMode Sort @@ -60,7 +62,6 @@ namespace osu.Game.Screens.Select public FilterControl(float height) { - TabControl sortTabs; TabControl groupTabs; Children = new Drawable[] @@ -134,7 +135,7 @@ namespace osu.Game.Screens.Select sortTabs = new OsuTabControl(87) { Width = 191, - AutoSort = true + AutoSort = true, } } } @@ -164,7 +165,7 @@ namespace osu.Game.Screens.Select [BackgroundDependencyLoader] private void load(OsuColour colours) { - spriteText.Colour = colours.GreenLight; + sortTabs.AccentColour = spriteText.Colour = colours.GreenLight; } } } \ No newline at end of file From 0000cf1bee9ae5e289d1c96dcfd41fac9f18e8f6 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 15 Mar 2017 21:44:27 -0400 Subject: [PATCH 11/37] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 036b124eb2..67dd51e27c 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 036b124eb2387dde29af56e06391c42063ec85e2 +Subproject commit 67dd51e27c1a4cbbc17f29fee5dee3a125eed78e From 360340c61d1038ccffc229e25c6a6449df092ea6 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 15 Mar 2017 22:39:09 -0400 Subject: [PATCH 12/37] Fix linter issues --- osu.Game/Graphics/UserInterface/OsuTabControl.cs | 7 +++++-- osu.Game/Graphics/UserInterface/OsuTabDropDownHeader.cs | 1 - osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs | 3 ++- osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index d03fb474b8..5f467b48ca 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Linq; using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics.UserInterface.Tab; @@ -37,8 +38,10 @@ namespace osu.Game.Graphics.UserInterface set { accentColour = value; - (DropDown as OsuTabDropDownMenu).AccentColour = value; - foreach (OsuTabItem item in TabContainer.Children) + var dropDown = DropDown as OsuTabDropDownMenu; + if (dropDown != null) + dropDown.AccentColour = value; + foreach (var item in TabContainer.Children.OfType>()) item.AccentColour = value; } } diff --git a/osu.Game/Graphics/UserInterface/OsuTabDropDownHeader.cs b/osu.Game/Graphics/UserInterface/OsuTabDropDownHeader.cs index 5506365aef..2b4d68b4b4 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabDropDownHeader.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabDropDownHeader.cs @@ -4,7 +4,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface.Tab; -using osu.Game.Graphics; namespace osu.Game.Graphics.UserInterface { diff --git a/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs index 51e7009e45..f84ab25354 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Linq; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; @@ -25,7 +26,7 @@ namespace osu.Game.Graphics.UserInterface { accentColour = value; Header.Colour = value; - foreach (OsuTabDropDownMenuItem item in ItemList) + foreach (var item in ItemList.OfType>()) item.AccentColour = value; } } diff --git a/osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs index 1df57e3ac6..86d451f7bb 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs @@ -31,7 +31,7 @@ namespace osu.Game.Graphics.UserInterface private Color4? accentColour; public Color4 AccentColour { - get { return accentColour.Value; } + get { return accentColour.GetValueOrDefault(); } set { accentColour = value; From 4d84bf7350f57a01285ac6e452e3d2408cbc6212 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 13:59:23 +0900 Subject: [PATCH 13/37] Change difficulty sort to be based on MaxStarDifficulty. --- osu.Game/Database/BeatmapSetInfo.cs | 3 +++ osu.Game/Screens/Select/CarouselContainer.cs | 23 +------------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/osu.Game/Database/BeatmapSetInfo.cs b/osu.Game/Database/BeatmapSetInfo.cs index 3e05451bed..12247c3997 100644 --- a/osu.Game/Database/BeatmapSetInfo.cs +++ b/osu.Game/Database/BeatmapSetInfo.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; +using System.Linq; using SQLite.Net.Attributes; using SQLiteNetExtensions.Attributes; @@ -23,6 +24,8 @@ namespace osu.Game.Database [OneToMany(CascadeOperations = CascadeOperation.All)] public List Beatmaps { get; set; } + public float MaxStarDifficulty => Beatmaps.Max(b => b.StarDifficulty); + public bool DeletePending { get; set; } public string Hash { get; set; } diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index 7de7779bd0..092e4461e0 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -173,28 +173,7 @@ namespace osu.Game.Screens.Select sortedGroups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Author, y.BeatmapSet.Metadata.Author, StringComparison.InvariantCultureIgnoreCase)); break; case SortMode.Difficulty: - sortedGroups.Sort((x, y) => - { - float xAverage = 0, yAverage = 0; - int counter = 0; - foreach (BeatmapInfo set in x.BeatmapSet.Beatmaps) - { - xAverage += set.StarDifficulty; - counter++; - } - xAverage /= counter; - counter = 0; - foreach (BeatmapInfo set in y.BeatmapSet.Beatmaps) - { - yAverage += set.StarDifficulty; - counter++; - } - yAverage /= counter; - if (xAverage > yAverage) - return 1; - else - return -1; - }); + sortedGroups.Sort((x, y) => x.BeatmapSet.MaxStarDifficulty.CompareTo(y.BeatmapSet.MaxStarDifficulty)); break; default: Sort(SortMode.Artist); // Temporary From 352de2259061cb2cbfb05938fe0e15ebeba1749c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 14:08:05 +0900 Subject: [PATCH 14/37] Filter doesn't need to be public, nor have a property. --- osu.Game/Screens/Select/SongSelect.cs | 31 +++++++-------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 132f737d22..c8dc787eaa 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -65,22 +65,7 @@ namespace osu.Game.Screens.Select /// protected readonly Footer Footer; - private FilterControl filter; - public FilterControl Filter - { - get - { - return filter; - } - private set - { - if (filter != value) - { - filter = value; - filterChanged(); - } - } - } + private FilterControl filterControl; protected SongSelect() { @@ -109,7 +94,7 @@ namespace osu.Game.Screens.Select Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, }); - Add(filter = new FilterControl(filter_height) + Add(filterControl = new FilterControl(filter_height) { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, @@ -198,9 +183,9 @@ namespace osu.Game.Screens.Select filterTask = Scheduler.AddDelayed(() => { filterTask = null; - var search = filter.Search; + var search = filterControl.Search; BeatmapGroup newSelection = null; - carousel.Sort(filter.Sort); + carousel.Sort(filterControl.Sort); foreach (var beatmapGroup in carousel) { var set = beatmapGroup.BeatmapSet; @@ -257,7 +242,7 @@ namespace osu.Game.Screens.Select beatmapInfoWedge.State = Visibility.Visible; - filter.Activate(); + filterControl.Activate(); } protected override void OnResuming(Screen last) @@ -270,7 +255,7 @@ namespace osu.Game.Screens.Select Content.ScaleTo(1, 250, EasingTypes.OutSine); - filter.Activate(); + filterControl.Activate(); } protected override void OnSuspending(Screen next) @@ -279,7 +264,7 @@ namespace osu.Game.Screens.Select Content.FadeOut(250); - filter.Deactivate(); + filterControl.Deactivate(); base.OnSuspending(next); } @@ -289,7 +274,7 @@ namespace osu.Game.Screens.Select Content.FadeOut(100); - filter.Deactivate(); + filterControl.Deactivate(); return base.OnExiting(next); } From 269c1a5e5c49d16b0e7ac38f76b1eb3fbd2c020a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 14:08:37 +0900 Subject: [PATCH 15/37] Reword some comments. --- osu.Game/Screens/Select/SongSelect.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index c8dc787eaa..c6096394ef 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -56,12 +56,12 @@ namespace osu.Game.Screens.Select protected virtual bool ShowFooter => true; /// - /// Can be null if == false + /// Can be null if is false. /// protected readonly BeatmapOptionsOverlay BeatmapOptions; /// - /// Can be null if == false + /// Can be null if is false. /// protected readonly Footer Footer; From da6b98db10233c692cdd5f9de36e832084076532 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 14:23:48 +0900 Subject: [PATCH 16/37] fixup! Filter doesn't need to be public, nor have a property. --- .../Tests/TestCasePlaySongSelect.cs | 8 ++++---- osu.Game/Screens/Select/FilterControl.cs | 6 ++++++ osu.Game/Screens/Select/SongSelect.cs | 16 ++++++++-------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs index cb5ff53646..a4995d2320 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs @@ -40,10 +40,10 @@ namespace osu.Desktop.VisualTests.Tests Add(songSelect = new PlaySongSelect()); - AddButton(@"Sort by Artist", delegate { songSelect.Filter.Sort = SortMode.Artist; }); - AddButton(@"Sort by Title", delegate { songSelect.Filter.Sort = SortMode.Title; }); - AddButton(@"Sort by Author", delegate { songSelect.Filter.Sort = SortMode.Author; }); - AddButton(@"Sort by Difficulty", delegate { songSelect.Filter.Sort = SortMode.Difficulty; }); + AddButton(@"Sort by Artist", delegate { songSelect.FilterControl.Sort = SortMode.Artist; }); + AddButton(@"Sort by Title", delegate { songSelect.FilterControl.Sort = SortMode.Title; }); + AddButton(@"Sort by Author", delegate { songSelect.FilterControl.Sort = SortMode.Author; }); + AddButton(@"Sort by Difficulty", delegate { songSelect.FilterControl.Sort = SortMode.Difficulty; }); } protected override void Dispose(bool isDisposing) diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index a162579b96..c0a2b3703a 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -15,6 +15,7 @@ using osu.Game.Graphics.Sprites; using osu.Game.Screens.Select.Filter; using Container = osu.Framework.Graphics.Containers.Container; using osu.Framework.Graphics.UserInterface.Tab; +using osu.Framework.Input; namespace osu.Game.Screens.Select { @@ -167,5 +168,10 @@ namespace osu.Game.Screens.Select { sortTabs.AccentColour = spriteText.Colour = colours.GreenLight; } + + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) + { + return true; + } } } \ No newline at end of file diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index c6096394ef..507b579669 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -65,7 +65,7 @@ namespace osu.Game.Screens.Select /// protected readonly Footer Footer; - private FilterControl filterControl; + public readonly FilterControl FilterControl; protected SongSelect() { @@ -94,7 +94,7 @@ namespace osu.Game.Screens.Select Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, }); - Add(filterControl = new FilterControl(filter_height) + Add(FilterControl = new FilterControl(filter_height) { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, @@ -183,9 +183,9 @@ namespace osu.Game.Screens.Select filterTask = Scheduler.AddDelayed(() => { filterTask = null; - var search = filterControl.Search; + var search = FilterControl.Search; BeatmapGroup newSelection = null; - carousel.Sort(filterControl.Sort); + carousel.Sort(FilterControl.Sort); foreach (var beatmapGroup in carousel) { var set = beatmapGroup.BeatmapSet; @@ -242,7 +242,7 @@ namespace osu.Game.Screens.Select beatmapInfoWedge.State = Visibility.Visible; - filterControl.Activate(); + FilterControl.Activate(); } protected override void OnResuming(Screen last) @@ -255,7 +255,7 @@ namespace osu.Game.Screens.Select Content.ScaleTo(1, 250, EasingTypes.OutSine); - filterControl.Activate(); + FilterControl.Activate(); } protected override void OnSuspending(Screen next) @@ -264,7 +264,7 @@ namespace osu.Game.Screens.Select Content.FadeOut(250); - filterControl.Deactivate(); + FilterControl.Deactivate(); base.OnSuspending(next); } @@ -274,7 +274,7 @@ namespace osu.Game.Screens.Select Content.FadeOut(100); - filterControl.Deactivate(); + FilterControl.Deactivate(); return base.OnExiting(next); } From 4bedd4d2d72c0dc9ab5bb0bb0f74faf1c03ac0a5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 14:33:31 +0900 Subject: [PATCH 17/37] Block input behind FilterControl. --- osu.Game/Screens/Select/FilterControl.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index c0a2b3703a..f98a4e328c 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -169,9 +169,12 @@ namespace osu.Game.Screens.Select sortTabs.AccentColour = spriteText.Colour = colours.GreenLight; } - protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) - { - return true; - } + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; + + protected override bool OnMouseMove(InputState state) => true; + + protected override bool OnClick(InputState state) => true; + + protected override bool OnDragStart(InputState state) => true; } } \ No newline at end of file From 58fc0a2622b52277fc333cecef99ac4fe2b0b19c Mon Sep 17 00:00:00 2001 From: Kelvin <2yangk23@gmail.com> Date: Wed, 15 Mar 2017 22:49:23 -0700 Subject: [PATCH 18/37] Make TabControl test label more clear --- .../Tests/TestCaseTabControl.cs | 35 +++++++------------ 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs index a072087956..d09a2d5281 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs @@ -1,14 +1,12 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Diagnostics; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; +using OpenTK; using osu.Framework.Graphics.Primitives; using osu.Framework.Screens.Testing; using osu.Game.Graphics.Sprites; -using osu.Game.Screens.Select.Filter; using osu.Game.Graphics.UserInterface; +using osu.Game.Screens.Select.Filter; namespace osu.Desktop.VisualTests.Tests { @@ -22,24 +20,16 @@ namespace osu.Desktop.VisualTests.Tests OsuSpriteText text; OsuTabControl filter; - - Add(new FillFlowContainer + Add(filter = new OsuTabControl { - Direction = FillDirection.Horizontal, - AutoSizeAxes = Axes.Both, - Children = new Drawable[] - { - filter = new OsuTabControl - { - Width = 229, - AutoSort = true - }, - text = new OsuSpriteText - { - Text = "None", - Margin = new MarginPadding(4) - } - } + Width = 229, + AutoSort = true + }); + Add(text = new OsuSpriteText + { + Text = "None", + Margin = new MarginPadding(4), + Position = new Vector2(275, 5) }); filter.PinTab(GroupMode.All); @@ -47,8 +37,7 @@ namespace osu.Desktop.VisualTests.Tests filter.ValueChanged += (sender, mode) => { - Debug.WriteLine($"Selected {mode}"); - text.Text = mode.ToString(); + text.Text = "Currently Selected: " + mode.ToString(); }; } } From 334e38951802af5bb71ac77fe89dc80fa7e73872 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 16:35:44 +0900 Subject: [PATCH 19/37] Tidy up OsuTabControl and FilterControl. --- .../Tests/TestCaseTabControl.cs | 2 +- .../Graphics/UserInterface/OsuTabControl.cs | 9 +- .../UserInterface/OsuTabDropDownHeader.cs | 29 ------ .../UserInterface/OsuTabDropDownMenu.cs | 67 ++++++++++++- osu.Game/Graphics/UserInterface/OsuTabItem.cs | 6 +- osu.Game/Screens/Select/FilterControl.cs | 93 +++++++++---------- osu.Game/Screens/Select/SongSelect.cs | 4 +- osu.Game/osu.Game.csproj | 1 - 8 files changed, 122 insertions(+), 89 deletions(-) delete mode 100644 osu.Game/Graphics/UserInterface/OsuTabDropDownHeader.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs index a072087956..f859038202 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs @@ -26,7 +26,7 @@ namespace osu.Desktop.VisualTests.Tests Add(new FillFlowContainer { Direction = FillDirection.Horizontal, - AutoSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.Both, Children = new Drawable[] { filter = new OsuTabControl diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 5f467b48ca..2fa2db9a99 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -15,7 +15,7 @@ namespace osu.Game.Graphics.UserInterface protected override TabItem CreateTabItem(T value) => new OsuTabItem { Value = value }; - public OsuTabControl(float offset = 0) : base(offset) + public OsuTabControl() { if (!typeof(T).IsEnum) throw new InvalidOperationException("OsuTabControl only supports enums as the generic type argument"); @@ -45,5 +45,12 @@ namespace osu.Game.Graphics.UserInterface item.AccentColour = value; } } + + protected override void Update() + { + base.Update(); + + DropDown.Header.Height = DrawHeight; + } } } diff --git a/osu.Game/Graphics/UserInterface/OsuTabDropDownHeader.cs b/osu.Game/Graphics/UserInterface/OsuTabDropDownHeader.cs deleted file mode 100644 index 2b4d68b4b4..0000000000 --- a/osu.Game/Graphics/UserInterface/OsuTabDropDownHeader.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Graphics; -using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.UserInterface.Tab; - -namespace osu.Game.Graphics.UserInterface -{ - public class OsuTabDropDownHeader : TabDropDownHeader - { - protected override string Label { get; set; } - - public OsuTabDropDownHeader() - { - Foreground.Children = new Drawable[] - { - new TextAwesome - { - Icon = FontAwesome.fa_ellipsis_h, - TextSize = 14, - Margin = new MarginPadding{ Top = 6, Bottom = 4 }, - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - } - }; - } - } -} diff --git a/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs index f84ab25354..1b64056d97 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs @@ -6,18 +6,17 @@ using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Transforms; using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface.Tab; +using osu.Framework.Input; namespace osu.Game.Graphics.UserInterface { public class OsuTabDropDownMenu : TabDropDownMenu { - public override float HeaderWidth => 14; - public override float HeaderHeight => 24; - private Color4? accentColour; public Color4 AccentColour { @@ -25,7 +24,7 @@ namespace osu.Game.Graphics.UserInterface set { accentColour = value; - Header.Colour = value; + ((OsuTabDropDownHeader)Header).AccentColour = value; foreach (var item in ItemList.OfType>()) item.AccentColour = value; } @@ -33,7 +32,7 @@ namespace osu.Game.Graphics.UserInterface protected override DropDownHeader CreateHeader() => new OsuTabDropDownHeader { - Colour = AccentColour + AccentColour = AccentColour }; protected override DropDownMenuItem CreateDropDownItem(string key, T value) => @@ -69,5 +68,63 @@ namespace osu.Game.Graphics.UserInterface if (accentColour == null) AccentColour = colours.Blue; } + + public class OsuTabDropDownHeader : DropDownHeader + { + protected override string Label { get; set; } + + private Color4? accentColour; + public Color4 AccentColour + { + get { return accentColour.GetValueOrDefault(); } + set + { + accentColour = value; + BackgroundColourHover = value; + Foreground.Colour = value; + } + } + + protected override bool OnHover(InputState state) + { + Foreground.Colour = BackgroundColour; + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + Foreground.Colour = BackgroundColourHover; + base.OnHoverLost(state); + } + + public OsuTabDropDownHeader() + { + RelativeSizeAxes = Axes.None; + AutoSizeAxes = Axes.X; + + BackgroundColour = Color4.Black; + + Background.Height = 0.5f; + Background.CornerRadius = 3; + Background.Masking = true; + + Foreground.RelativeSizeAxes = Axes.None; + Foreground.AutoSizeAxes = Axes.X; + Foreground.RelativeSizeAxes = Axes.Y; + Foreground.Margin = new MarginPadding(5); + Foreground.Children = new Drawable[] + { + new TextAwesome + { + Icon = FontAwesome.fa_ellipsis_h, + TextSize = 14, + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + } + }; + + Padding = new MarginPadding { Left = 5, Right = 5 }; + } + } } } diff --git a/osu.Game/Graphics/UserInterface/OsuTabItem.cs b/osu.Game/Graphics/UserInterface/OsuTabItem.cs index ca4b70d5d8..9b8ea58a56 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabItem.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabItem.cs @@ -81,12 +81,16 @@ namespace osu.Game.Graphics.UserInterface public OsuTabItem() { - AutoSizeAxes = Axes.Both; + AutoSizeAxes = Axes.X; + RelativeSizeAxes = Axes.Y; + Children = new Drawable[] { text = new OsuSpriteText { Margin = new MarginPadding(5), + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, TextSize = 14, Font = @"Exo2.0-Bold", // Font should only turn bold when active? }, diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index f98a4e328c..167c12b69e 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -26,7 +26,9 @@ namespace osu.Game.Screens.Select public string Search => searchTextBox.Text; private OsuTabControl sortTabs; - + + TabControl groupTabs; + private SortMode sort = SortMode.Title; public SortMode Sort { @@ -55,34 +57,30 @@ namespace osu.Game.Screens.Select } } - private OsuSpriteText spriteText; - public Action Exit; private SearchTextBox searchTextBox; - public FilterControl(float height) - { - TabControl groupTabs; + public override bool Contains(Vector2 screenSpacePos) => base.Contains(screenSpacePos) || groupTabs.Contains(screenSpacePos) || sortTabs.Contains(screenSpacePos); + public FilterControl() + { Children = new Drawable[] { new Box { Colour = Color4.Black, Alpha = 0.8f, - RelativeSizeAxes = Axes.X, - Height = height + RelativeSizeAxes = Axes.Both, }, - new FillFlowContainer + new Container { Padding = new MarginPadding(20), - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, + BypassContainsCheck = true, + RelativeSizeAxes = Axes.Y, + Width = 500, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, - Width = 0.4f, // TODO: InnerWidth property or something - Direction = FillDirection.Vertical, Children = new Drawable[] { searchTextBox = new SearchTextBox @@ -95,53 +93,50 @@ namespace osu.Game.Screens.Select }, Exit = () => Exit?.Invoke(), }, - new Container + new Box { + RelativeSizeAxes = Axes.X, + Height = 1, + Y = 24, + Colour = OsuColour.Gray(80), + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + }, + new FillFlowContainer + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Direction = FillDirection.Horizontal, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, + BypassContainsCheck = true, Children = new Drawable[] { - new Box - { - RelativeSizeAxes = Axes.X, - Height = 1, - Colour = OsuColour.Gray(80), - Origin = Anchor.TopLeft, - Anchor = Anchor.TopLeft, - Position = new Vector2(0, 23) - }, groupTabs = new OsuTabControl { - Width = 230, + RelativeSizeAxes = Axes.X, + Width = 0.5f, AutoSort = true }, - new Container + //spriteText = new OsuSpriteText + //{ + // Font = @"Exo2.0-Bold", + // Text = "Sort results by", + // TextSize = 14, + // Margin = new MarginPadding + // { + // Top = 5, + // Bottom = 5 + // }, + //}, + sortTabs = new OsuTabControl() { - AutoSizeAxes = Axes.Both, - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - Children = new Drawable[] - { - spriteText = new OsuSpriteText - { - Font = @"Exo2.0-Bold", - Text = "Sort results by", - TextSize = 14, - Margin = new MarginPadding - { - Top = 5, - Bottom = 5 - }, - }, - sortTabs = new OsuTabControl(87) - { - Width = 191, - AutoSort = true, - } - } + RelativeSizeAxes = Axes.X, + Width = 0.5f, + AutoSort = true, } } - } + }, } } }; @@ -166,7 +161,7 @@ namespace osu.Game.Screens.Select [BackgroundDependencyLoader] private void load(OsuColour colours) { - sortTabs.AccentColour = spriteText.Colour = colours.GreenLight; + sortTabs.AccentColour = colours.GreenLight; } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 507b579669..a0f20242c2 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -94,10 +94,10 @@ namespace osu.Game.Screens.Select Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, }); - Add(FilterControl = new FilterControl(filter_height) + Add(FilterControl = new FilterControl { RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, + Height = filter_height, FilterChanged = () => filterChanged(), Exit = Exit, }); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 1b6ea5d84b..1936628ad5 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -350,7 +350,6 @@ - From bd5493fb25f05c85cd5a4c3842be27c05551c715 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 16:43:42 +0900 Subject: [PATCH 20/37] Add back correct defaults. --- osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs | 2 +- osu.Game/Screens/Select/FilterControl.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs index d09a2d5281..ba52a6ce6a 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs @@ -22,7 +22,7 @@ namespace osu.Desktop.VisualTests.Tests OsuTabControl filter; Add(filter = new OsuTabControl { - Width = 229, + Size = new Vector2(229, 24), AutoSort = true }); Add(text = new OsuSpriteText diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 167c12b69e..6cddd7b6d8 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -11,7 +11,6 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; -using osu.Game.Graphics.Sprites; using osu.Game.Screens.Select.Filter; using Container = osu.Framework.Graphics.Containers.Container; using osu.Framework.Graphics.UserInterface.Tab; @@ -97,7 +96,6 @@ namespace osu.Game.Screens.Select { RelativeSizeAxes = Axes.X, Height = 1, - Y = 24, Colour = OsuColour.Gray(80), Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, @@ -115,6 +113,7 @@ namespace osu.Game.Screens.Select groupTabs = new OsuTabControl { RelativeSizeAxes = Axes.X, + Height = 24, Width = 0.5f, AutoSort = true }, @@ -133,6 +132,7 @@ namespace osu.Game.Screens.Select { RelativeSizeAxes = Axes.X, Width = 0.5f, + Height = 24, AutoSort = true, } } From 1156e76c285b3713667e89dedfd235cbf9a7044d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 17:00:49 +0900 Subject: [PATCH 21/37] Don't directly access Header. --- osu.Game/Graphics/UserInterface/OsuTabControl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 2fa2db9a99..067573ace4 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -50,7 +50,7 @@ namespace osu.Game.Graphics.UserInterface { base.Update(); - DropDown.Header.Height = DrawHeight; + DropDown.HeaderHeight = DrawHeight; } } } From 1a7c2eda5ec83f0c9ce49b49d595141790d67ba4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 17:01:02 +0900 Subject: [PATCH 22/37] Size FilterControl relatively now that we can. --- 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 6cddd7b6d8..45b6b56bbb 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -76,8 +76,8 @@ namespace osu.Game.Screens.Select { Padding = new MarginPadding(20), BypassContainsCheck = true, - RelativeSizeAxes = Axes.Y, - Width = 500, + RelativeSizeAxes = Axes.Both, + Width = 0.5f, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Children = new Drawable[] From 93c0fe514080b8266a4a1fa092ef57b913b39993 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 17:02:37 +0900 Subject: [PATCH 23/37] Remove unnecessary set. --- osu.Game/Graphics/UserInterface/OsuTabControl.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 067573ace4..4c2ec902a9 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -45,12 +45,5 @@ namespace osu.Game.Graphics.UserInterface item.AccentColour = value; } } - - protected override void Update() - { - base.Update(); - - DropDown.HeaderHeight = DrawHeight; - } } } From e17f7282826a10f79c6590cf5245cdfce2ea21a6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 17:04:03 +0900 Subject: [PATCH 24/37] Fix CI. --- osu.Game/Screens/Select/FilterControl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 45b6b56bbb..7dd5c397fb 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Select private OsuTabControl sortTabs; - TabControl groupTabs; + private TabControl groupTabs; private SortMode sort = SortMode.Title; public SortMode Sort From 5137338c7c97890d39dcb777ac309e6de83a2b6c Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 16 Mar 2017 17:11:24 +0900 Subject: [PATCH 25/37] Replace List with TimingInfo in Beatmap. --- osu.Game.Modes.Osu/Objects/Slider.cs | 2 +- osu.Game/Beatmaps/Beatmap.cs | 66 +++++------ osu.Game/Beatmaps/Formats/BeatmapDecoder.cs | 2 - osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs | 2 +- osu.Game/Beatmaps/Timing/TimingInfo.cs | 106 ++++++++++++++++++ osu.Game/Screens/Select/BeatmapInfoWedge.cs | 6 +- osu.Game/osu.Game.csproj | 1 + 7 files changed, 140 insertions(+), 45 deletions(-) create mode 100644 osu.Game/Beatmaps/Timing/TimingInfo.cs diff --git a/osu.Game.Modes.Osu/Objects/Slider.cs b/osu.Game.Modes.Osu/Objects/Slider.cs index 83a5a458c7..6c00af89b3 100644 --- a/osu.Game.Modes.Osu/Objects/Slider.cs +++ b/osu.Game.Modes.Osu/Objects/Slider.cs @@ -54,7 +54,7 @@ namespace osu.Game.Modes.Osu.Objects var baseDifficulty = beatmap.BeatmapInfo.BaseDifficulty; ControlPoint overridePoint; - ControlPoint timingPoint = beatmap.TimingPointAt(StartTime, out overridePoint); + ControlPoint timingPoint = beatmap.TimingInfo.TimingPointAt(StartTime, out overridePoint); var velocityAdjustment = overridePoint?.VelocityAdjustment ?? 1; var baseVelocity = 100 * baseDifficulty.SliderMultiplier / velocityAdjustment; diff --git a/osu.Game/Beatmaps/Beatmap.cs b/osu.Game/Beatmaps/Beatmap.cs index 6dbd605359..bf86aeea83 100644 --- a/osu.Game/Beatmaps/Beatmap.cs +++ b/osu.Game/Beatmaps/Beatmap.cs @@ -7,7 +7,6 @@ using osu.Game.Database; using osu.Game.Modes; using osu.Game.Modes.Objects; using System.Collections.Generic; -using System.Linq; namespace osu.Game.Beatmaps { @@ -18,7 +17,7 @@ namespace osu.Game.Beatmaps where T : HitObject { public BeatmapInfo BeatmapInfo; - public List ControlPoints; + public TimingInfo TimingInfo = new TimingInfo(); public readonly List ComboColors = new List { new Color4(17, 136, 170, 255), @@ -41,49 +40,40 @@ namespace osu.Game.Beatmaps public Beatmap(Beatmap original = null) { BeatmapInfo = original?.BeatmapInfo ?? BeatmapInfo; - ControlPoints = original?.ControlPoints ?? ControlPoints; + TimingInfo = original?.TimingInfo ?? TimingInfo; ComboColors = original?.ComboColors ?? ComboColors; } - public double BPMMaximum => 60000 / (ControlPoints?.Where(c => c.BeatLength != 0).OrderBy(c => c.BeatLength).FirstOrDefault() ?? ControlPoint.Default).BeatLength; - public double BPMMinimum => 60000 / (ControlPoints?.Where(c => c.BeatLength != 0).OrderByDescending(c => c.BeatLength).FirstOrDefault() ?? ControlPoint.Default).BeatLength; - public double BPMMode => BPMAt(ControlPoints.Where(c => c.BeatLength != 0).GroupBy(c => c.BeatLength).OrderByDescending(grp => grp.Count()).First().First().Time); - - public double BPMAt(double time) + /// + /// Finds the slider velocity at a time. + /// + /// The time to find the slider velocity at. + /// The slider velocity in positional length units. + public double SliderVelocityAt(double time) { - return 60000 / BeatLengthAt(time); + double scoringDistance = 100 * BeatmapInfo.BaseDifficulty.SliderMultiplier; + double beatDistance = TimingInfo.BeatDistanceAt(time); + + if (beatDistance > 0) + return scoringDistance / beatDistance * 1000; + return scoringDistance; } - public double BeatLengthAt(double time) + /// + /// Maps a difficulty value [0, 10] to a two-piece linear range of values. + /// + /// The difficulty value to be mapped. + /// Minimum of the resulting range which will be achieved by a difficulty value of 0. + /// Midpoint of the resulting range which will be achieved by a difficulty value of 5. + /// Maximum of the resulting range which will be achieved by a difficulty value of 10. + /// Value to which the difficulty value maps in the specified range. + public static double MapDifficultyRange(double difficulty, double min, double mid, double max) { - ControlPoint overridePoint; - ControlPoint timingPoint = TimingPointAt(time, out overridePoint); - return timingPoint.BeatLength; - } - - public ControlPoint TimingPointAt(double time, out ControlPoint overridePoint) - { - overridePoint = null; - - ControlPoint timingPoint = null; - foreach (var controlPoint in ControlPoints) - { - // Some beatmaps have the first timingPoint (accidentally) start after the first HitObject(s). - // This null check makes it so that the first ControlPoint that makes a timing change is used as - // the timingPoint for those HitObject(s). - if (controlPoint.Time <= time || timingPoint == null) - { - if (controlPoint.TimingChange) - { - timingPoint = controlPoint; - overridePoint = null; - } - else overridePoint = controlPoint; - } - else break; - } - - return timingPoint ?? ControlPoint.Default; + if (difficulty > 5) + return mid + (max - mid) * (difficulty - 5) / 5; + if (difficulty < 5) + return mid - (mid - min) * (5 - difficulty) / 5; + return mid; } } diff --git a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs index ba608fb08d..88cc977f1d 100644 --- a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs +++ b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.IO; using osu.Game.Modes.Objects; -using osu.Game.Beatmaps.Timing; using osu.Game.Database; namespace osu.Game.Beatmaps.Formats @@ -43,7 +42,6 @@ namespace osu.Game.Beatmaps.Formats var beatmap = new Beatmap { HitObjects = new List(), - ControlPoints = new List(), BeatmapInfo = new BeatmapInfo { Metadata = new BeatmapMetadata(), diff --git a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs index 71d26b2c51..86f75de794 100644 --- a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs +++ b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs @@ -209,7 +209,7 @@ namespace osu.Game.Beatmaps.Formats } if (cp != null) - beatmap.ControlPoints.Add(cp); + beatmap.TimingInfo.ControlPoints.Add(cp); } private void handleColours(Beatmap beatmap, string key, string val, ref bool hasCustomColours) diff --git a/osu.Game/Beatmaps/Timing/TimingInfo.cs b/osu.Game/Beatmaps/Timing/TimingInfo.cs new file mode 100644 index 0000000000..f245a6b1aa --- /dev/null +++ b/osu.Game/Beatmaps/Timing/TimingInfo.cs @@ -0,0 +1,106 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using System.Linq; + +namespace osu.Game.Beatmaps.Timing +{ + public class TimingInfo + { + public readonly List ControlPoints = new List(); + + public double BPMMaximum => 60000 / (ControlPoints?.Where(c => c.BeatLength != 0).OrderBy(c => c.BeatLength).FirstOrDefault() ?? ControlPoint.Default).BeatLength; + public double BPMMinimum => 60000 / (ControlPoints?.Where(c => c.BeatLength != 0).OrderByDescending(c => c.BeatLength).FirstOrDefault() ?? ControlPoint.Default).BeatLength; + public double BPMMode => BPMAt(ControlPoints.Where(c => c.BeatLength != 0).GroupBy(c => c.BeatLength).OrderByDescending(grp => grp.Count()).First().First().Time); + + public double BPMAt(double time) + { + return 60000 / BeatLengthAt(time); + } + + /// + /// Finds the BPM multiplier at a time. + /// + /// The time to find the BPM multiplier at. + /// The BPM multiplier. + public double BPMMultiplierAt(double time) + { + ControlPoint overridePoint; + ControlPoint timingPoint = TimingPointAt(time, out overridePoint); + + return overridePoint?.VelocityAdjustment ?? timingPoint?.VelocityAdjustment ?? 1; + } + + /// + /// Finds the beat length at a time. + /// + /// The time to find the beat length at. + /// The beat length in milliseconds. + public double BeatLengthAt(double time) + { + ControlPoint overridePoint; + ControlPoint timingPoint = TimingPointAt(time, out overridePoint); + + return timingPoint.BeatLength; + } + + /// + /// Finds the beat velocity at a time. + /// + /// The time to find the velocity at. + /// The velocity. + public double BeatVelocityAt(double time) + { + ControlPoint overridePoint; + ControlPoint timingPoint = TimingPointAt(time, out overridePoint); + + return overridePoint?.VelocityAdjustment ?? timingPoint?.VelocityAdjustment ?? 1; + } + + /// + /// Finds the beat length at a time. + /// + /// The time to find the beat length at. + /// The beat length in positional length units. + public double BeatDistanceAt(double time) + { + ControlPoint overridePoint; + ControlPoint timingPoint = TimingPointAt(time, out overridePoint); + + return (timingPoint?.BeatLength ?? 1) * (overridePoint?.VelocityAdjustment ?? timingPoint?.VelocityAdjustment ?? 1); + } + + /// + /// Finds the timing point at a time. + /// + /// The time to find the timing point at. + /// The timing point containing the velocity change of the returned timing point. + /// The timing point. + public ControlPoint TimingPointAt(double time, out ControlPoint overridePoint) + { + overridePoint = null; + + ControlPoint timingPoint = null; + foreach (var controlPoint in ControlPoints) + { + // Some beatmaps have the first timingPoint (accidentally) start after the first HitObject(s). + // This null check makes it so that the first ControlPoint that makes a timing change is used as + // the timingPoint for those HitObject(s). + if (controlPoint.Time <= time || timingPoint == null) + { + if (controlPoint.TimingChange) + { + timingPoint = controlPoint; + overridePoint = null; + } + else + overridePoint = controlPoint; + } + else break; + } + + return timingPoint ?? ControlPoint.Default; + } + } +} \ No newline at end of file diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index f82c35598a..5285d26264 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -217,12 +217,12 @@ namespace osu.Game.Screens.Select private string getBPMRange(Beatmap beatmap) { - double bpmMax = beatmap.BPMMaximum; - double bpmMin = beatmap.BPMMinimum; + double bpmMax = beatmap.TimingInfo.BPMMaximum; + double bpmMin = beatmap.TimingInfo.BPMMinimum; if (Precision.AlmostEquals(bpmMin, bpmMax)) return Math.Round(bpmMin) + "bpm"; - return Math.Round(bpmMin) + "-" + Math.Round(bpmMax) + "bpm (mostly " + Math.Round(beatmap.BPMMode) + "bpm)"; + return Math.Round(bpmMin) + "-" + Math.Round(bpmMax) + "bpm (mostly " + Math.Round(beatmap.TimingInfo.BPMMode) + "bpm)"; } public class InfoLabel : Container diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 3ec8b535c7..285937003a 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -75,6 +75,7 @@ + From ab8a5afdb91034aa3c2c1e7435be2a6498124666 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 17:38:36 +0900 Subject: [PATCH 26/37] AlwaysReceiveInput and InternalContains. --- .../Objects/Drawables/DrawableSlider.cs | 8 ++++---- .../Objects/Drawables/DrawableSpinner.cs | 4 ++-- .../Objects/Drawables/Pieces/SpinnerDisc.cs | 4 ++-- osu.Game/Graphics/Containers/ParallaxContainer.cs | 4 ++-- osu.Game/Graphics/Cursor/CursorTrail.cs | 2 +- osu.Game/Graphics/Processing/RatioAdjust.cs | 3 +-- osu.Game/Graphics/UserInterface/DialogButton.cs | 2 +- osu.Game/Graphics/UserInterface/TwoLayerButton.cs | 2 +- osu.Game/Modes/UI/Playfield.cs | 13 ++++++++++--- osu.Game/Overlays/Toolbar/Toolbar.cs | 13 ++++--------- osu.Game/Overlays/Toolbar/ToolbarUserArea.cs | 4 ++-- osu.Game/Screens/Menu/Button.cs | 5 +---- osu.Game/Screens/Menu/OsuLogo.cs | 5 +---- osu.Game/Screens/Play/KeyCounterCollection.cs | 7 +++---- osu.Game/Screens/Play/KeyCounterMouse.cs | 3 +-- osu.Game/Screens/Play/PauseOverlay.cs | 2 +- osu.Game/Screens/Select/FilterControl.cs | 6 +++--- osu.Game/Screens/Select/Footer.cs | 4 ++-- .../Screens/Select/Options/BeatmapOptionsButton.cs | 2 +- 19 files changed, 43 insertions(+), 50 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs index 036f12167a..5df2e26bc3 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs @@ -28,6 +28,10 @@ namespace osu.Game.Modes.Osu.Objects.Drawables public DrawableSlider(Slider s) : base(s) { + // Since the DrawableSlider itself is just a container without a size we need to + // pass all input through. + AlwaysReceiveInput = true; + SliderBouncer bouncer1; slider = s; @@ -91,10 +95,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables } } - // Since the DrawableSlider itself is just a container without a size we need to - // pass all input through. - public override bool Contains(Vector2 screenSpacePos) => true; - private int currentRepeat; protected override void Update() diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs index be3048a9ba..97df378f86 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs @@ -24,6 +24,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables public DrawableSpinner(Spinner s) : base(s) { + AlwaysReceiveInput = true; + Origin = Anchor.Centre; Position = s.Position; @@ -69,8 +71,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables disc.Scale = scaleToCircle; } - public override bool Contains(Vector2 screenSpacePos) => true; - protected override void CheckJudgement(bool userTriggered) { if (Time.Current < HitObject.StartTime) return; diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs index 34dec34cb4..906a3cd7c3 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs @@ -19,8 +19,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces { public class SpinnerDisc : CircularContainer { - public override bool Contains(Vector2 screenSpacePos) => true; - protected Sprite Disc; public SRGBColour DiscColour @@ -101,6 +99,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces public SpinnerDisc() { + AlwaysReceiveInput = true; + RelativeSizeAxes = Axes.Both; Children = new Drawable[] diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 88627dbd30..c4cd1777e1 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -18,10 +18,10 @@ namespace osu.Game.Graphics.Containers private Bindable parallaxEnabled; - public override bool Contains(Vector2 screenSpacePos) => true; - public ParallaxContainer() { + AlwaysReceiveInput = true; + RelativeSizeAxes = Axes.Both; AddInternal(content = new Container { diff --git a/osu.Game/Graphics/Cursor/CursorTrail.cs b/osu.Game/Graphics/Cursor/CursorTrail.cs index 09d1193661..ffd96d9622 100644 --- a/osu.Game/Graphics/Cursor/CursorTrail.cs +++ b/osu.Game/Graphics/Cursor/CursorTrail.cs @@ -18,7 +18,6 @@ namespace osu.Game.Graphics.Cursor { internal class CursorTrail : Drawable { - public override bool Contains(Vector2 screenSpacePos) => true; public override bool HandleInput => true; private int currentIndex; @@ -59,6 +58,7 @@ namespace osu.Game.Graphics.Cursor public CursorTrail() { + AlwaysReceiveInput = true; RelativeSizeAxes = Axes.Both; for (int i = 0; i < max_sprites; i++) diff --git a/osu.Game/Graphics/Processing/RatioAdjust.cs b/osu.Game/Graphics/Processing/RatioAdjust.cs index 219d75c675..dd039d5144 100644 --- a/osu.Game/Graphics/Processing/RatioAdjust.cs +++ b/osu.Game/Graphics/Processing/RatioAdjust.cs @@ -10,10 +10,9 @@ namespace osu.Game.Graphics.Processing { internal class RatioAdjust : Container { - public override bool Contains(Vector2 screenSpacePos) => true; - public RatioAdjust() { + AlwaysReceiveInput = true; RelativeSizeAxes = Axes.Both; } diff --git a/osu.Game/Graphics/UserInterface/DialogButton.cs b/osu.Game/Graphics/UserInterface/DialogButton.cs index 590c5bf393..49b5f1e509 100644 --- a/osu.Game/Graphics/UserInterface/DialogButton.cs +++ b/osu.Game/Graphics/UserInterface/DialogButton.cs @@ -88,7 +88,7 @@ namespace osu.Game.Graphics.UserInterface private bool didClick; // Used for making sure that the OnMouseDown animation can call instead of OnHoverLost's when clicking - public override bool Contains(Vector2 screenSpacePos) => backgroundContainer.Contains(screenSpacePos); + protected override bool InternalContains(Vector2 screenSpacePos) => backgroundContainer.Contains(screenSpacePos); protected override bool OnClick(Framework.Input.InputState state) { diff --git a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs index 8221ef952f..0d4e72f92c 100644 --- a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs +++ b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs @@ -158,7 +158,7 @@ namespace osu.Game.Graphics.UserInterface } } - public override bool Contains(Vector2 screenSpacePos) => IconLayer.Contains(screenSpacePos) || TextLayer.Contains(screenSpacePos); + protected override bool InternalContains(Vector2 screenSpacePos) => IconLayer.Contains(screenSpacePos) || TextLayer.Contains(screenSpacePos); protected override bool OnHover(InputState state) { diff --git a/osu.Game/Modes/UI/Playfield.cs b/osu.Game/Modes/UI/Playfield.cs index 288b4bf352..bff461f649 100644 --- a/osu.Game/Modes/UI/Playfield.cs +++ b/osu.Game/Modes/UI/Playfield.cs @@ -18,7 +18,6 @@ namespace osu.Game.Modes.UI /// The HitObjects contained in this Playfield. /// public HitObjectContainer> HitObjects; - public override bool Contains(Vector2 screenSpacePos) => true; internal Container ScaledContent; @@ -31,6 +30,8 @@ namespace osu.Game.Modes.UI /// Whether we want our internal coordinate system to be scaled to a specified width. protected Playfield(float? customWidth = null) { + AlwaysReceiveInput = true; + AddInternal(ScaledContent = new ScaledContainer { CustomWidth = customWidth, @@ -77,12 +78,18 @@ namespace osu.Game.Modes.UI //dividing by the customwidth will effectively scale our content to the required container size. protected override Vector2 DrawScale => CustomWidth.HasValue ? new Vector2(DrawSize.X / CustomWidth.Value) : base.DrawScale; - public override bool Contains(Vector2 screenSpacePos) => true; + public ScaledContainer() + { + AlwaysReceiveInput = true; + } } public class HitObjectContainer : Container where U : Drawable { - public override bool Contains(Vector2 screenSpacePos) => true; + public HitObjectContainer() + { + AlwaysReceiveInput = true; + } } } } diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index 79698a4f3e..657334d1bb 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -35,10 +35,10 @@ namespace osu.Game.Overlays.Toolbar private const float alpha_hovering = 0.8f; private const float alpha_normal = 0.6f; - public override bool Contains(Vector2 screenSpacePos) => true; - public Toolbar() { + AlwaysReceiveInput = true; + Children = new Drawable[] { new ToolbarBackground(), @@ -63,8 +63,9 @@ namespace osu.Game.Overlays.Toolbar } } }, - new PassThroughFlowContainer + new FillFlowContainer { + AlwaysReceiveInput = true, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Direction = FillDirection.Horizontal, @@ -144,11 +145,5 @@ namespace osu.Game.Overlays.Toolbar MoveToY(-DrawSize.Y, transition_time, EasingTypes.OutQuint); FadeOut(transition_time); } - - private class PassThroughFlowContainer : FillFlowContainer - { - //needed to get input to the login overlay. - public override bool Contains(Vector2 screenSpacePos) => true; - } } } diff --git a/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs b/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs index 9de0f290a5..7f28764b17 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs @@ -15,10 +15,10 @@ namespace osu.Game.Overlays.Toolbar public override RectangleF BoundingBox => button.BoundingBox; - public override bool Contains(Vector2 screenSpacePos) => true; - public ToolbarUserArea() { + AlwaysReceiveInput = true; + RelativeSizeAxes = Axes.Y; AutoSizeAxes = Axes.X; diff --git a/osu.Game/Screens/Menu/Button.cs b/osu.Game/Screens/Menu/Button.cs index 7af03d2f11..52872c858b 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -35,10 +35,7 @@ namespace osu.Game.Screens.Menu private Key triggerKey; private SampleChannel sampleClick; - public override bool Contains(Vector2 screenSpacePos) - { - return box.Contains(screenSpacePos); - } + protected override bool InternalContains(Vector2 screenSpacePos) => box.Contains(screenSpacePos); public Button(string text, string internalName, FontAwesome symbol, Color4 colour, Action clickAction = null, float extraWidth = 0, Key triggerKey = Key.Unknown) { diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index 01622fe096..259e98c483 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -50,10 +50,7 @@ namespace osu.Game.Screens.Menu } } - public override bool Contains(Vector2 screenSpacePos) - { - return logoContainer.Contains(screenSpacePos); - } + protected override bool InternalContains(Vector2 screenSpacePos) => logoContainer.Contains(screenSpacePos); public bool Ripple { diff --git a/osu.Game/Screens/Play/KeyCounterCollection.cs b/osu.Game/Screens/Play/KeyCounterCollection.cs index aa2bf47227..bbda7ae318 100644 --- a/osu.Game/Screens/Play/KeyCounterCollection.cs +++ b/osu.Game/Screens/Play/KeyCounterCollection.cs @@ -14,6 +14,8 @@ namespace osu.Game.Screens.Play { public KeyCounterCollection() { + AlwaysReceiveInput = true; + Direction = FillDirection.Horizontal; AutoSizeAxes = Axes.Both; } @@ -33,8 +35,6 @@ namespace osu.Game.Screens.Play counter.ResetCount(); } - public override bool Contains(Vector2 screenSpacePos) => true; - //further: change default values here and in KeyCounter if needed, instead of passing them in every constructor private bool isCounting; public bool IsCounting @@ -111,12 +111,11 @@ namespace osu.Game.Screens.Play public Receptor(KeyCounterCollection target) { + AlwaysReceiveInput = true; RelativeSizeAxes = Axes.Both; this.target = target; } - public override bool Contains(Vector2 screenSpacePos) => true; - public override bool HandleInput => true; protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) => target.Children.Any(c => c.TriggerKeyDown(state, args)); diff --git a/osu.Game/Screens/Play/KeyCounterMouse.cs b/osu.Game/Screens/Play/KeyCounterMouse.cs index 425bcffee5..b0b93e80e7 100644 --- a/osu.Game/Screens/Play/KeyCounterMouse.cs +++ b/osu.Game/Screens/Play/KeyCounterMouse.cs @@ -13,6 +13,7 @@ namespace osu.Game.Screens.Play public KeyCounterMouse(MouseButton button) : base(getStringRepresentation(button)) { + AlwaysReceiveInput = true; Button = button; } @@ -29,8 +30,6 @@ namespace osu.Game.Screens.Play } } - public override bool Contains(Vector2 screenSpacePos) => true; - protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { if (args.Button == Button) IsLit = true; diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index 0f3303fc29..b862adcd53 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -70,7 +70,6 @@ namespace osu.Game.Screens.Play private FillFlowContainer retryCounterContainer; - public override bool Contains(Vector2 screenSpacePos) => true; public override bool HandleInput => State == Visibility.Visible; protected override void PopIn() => FadeIn(transition_duration, EasingTypes.In); @@ -217,6 +216,7 @@ namespace osu.Game.Screens.Play public PauseOverlay() { + AlwaysReceiveInput = true; RelativeSizeAxes = Axes.Both; } } diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 7dd5c397fb..a655d0c4d4 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -60,7 +60,7 @@ namespace osu.Game.Screens.Select private SearchTextBox searchTextBox; - public override bool Contains(Vector2 screenSpacePos) => base.Contains(screenSpacePos) || groupTabs.Contains(screenSpacePos) || sortTabs.Contains(screenSpacePos); + protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || groupTabs.Contains(screenSpacePos) || sortTabs.Contains(screenSpacePos); public FilterControl() { @@ -75,7 +75,7 @@ namespace osu.Game.Screens.Select new Container { Padding = new MarginPadding(20), - BypassContainsCheck = true, + AlwaysReceiveInput = true, RelativeSizeAxes = Axes.Both, Width = 0.5f, Anchor = Anchor.TopRight, @@ -107,7 +107,7 @@ namespace osu.Game.Screens.Select Direction = FillDirection.Horizontal, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - BypassContainsCheck = true, + AlwaysReceiveInput = true, Children = new Drawable[] { groupTabs = new OsuTabControl diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index fae1cb5d4d..0e369c78b9 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -26,8 +26,6 @@ namespace osu.Game.Screens.Select private const float padding = 80; - public override bool Contains(Vector2 screenSpacePos) => true; - public Action OnBack; public Action OnStart; @@ -69,6 +67,8 @@ namespace osu.Game.Screens.Select public Footer() { + AlwaysReceiveInput = true; + const float bottom_tool_height = 50; RelativeSizeAxes = Axes.X; diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs index cfe8eea07f..a0bc702aac 100644 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs +++ b/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs @@ -83,7 +83,7 @@ namespace osu.Game.Screens.Select.Options return false; } - public override bool Contains(Vector2 screenSpacePos) => box.Contains(screenSpacePos); + protected override bool InternalContains(Vector2 screenSpacePos) => box.Contains(screenSpacePos); public BeatmapOptionsButton() { From 3b77fcd5d5fc0e624a77fd9f887f16487c7e45f5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 19:15:18 +0900 Subject: [PATCH 27/37] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 67dd51e27c..4e64545c34 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 67dd51e27c1a4cbbc17f29fee5dee3a125eed78e +Subproject commit 4e64545c34b71ddf6be1ce2c85d0bbb9ff15ef6c From 64825c32c554f50526b620d151bf53ebd18d48be Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 21:16:30 +0900 Subject: [PATCH 28/37] Add margin to testcase to better see edges. --- osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs index ba52a6ce6a..19cc32078c 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs @@ -22,6 +22,7 @@ namespace osu.Desktop.VisualTests.Tests OsuTabControl filter; Add(filter = new OsuTabControl { + Margin = new MarginPadding(4), Size = new Vector2(229, 24), AutoSort = true }); From 110bdbd0c11069fa42a1744272b8e3cbc47a7444 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 21:17:14 +0900 Subject: [PATCH 29/37] Make everything share DropDown implementations again. Remove unnecessary files. --- .../UserInterface/OsuDropDownHeader.cs | 15 +- .../Graphics/UserInterface/OsuDropDownMenu.cs | 46 +++++-- .../UserInterface/OsuDropDownMenuItem.cs | 38 ++++- .../Graphics/UserInterface/OsuTabControl.cs | 93 ++++++++++++- .../UserInterface/OsuTabDropDownMenu.cs | 130 ------------------ .../UserInterface/OsuTabDropDownMenuItem.cs | 54 -------- osu.Game/Graphics/UserInterface/OsuTabItem.cs | 2 +- osu.Game/Screens/Play/KeyCounterCollection.cs | 1 - osu.Game/Screens/Play/KeyCounterMouse.cs | 1 - osu.Game/Screens/Select/FilterControl.cs | 2 +- osu.Game/osu.Game.csproj | 2 - 11 files changed, 173 insertions(+), 211 deletions(-) delete mode 100644 osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs delete mode 100644 osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs diff --git a/osu.Game/Graphics/UserInterface/OsuDropDownHeader.cs b/osu.Game/Graphics/UserInterface/OsuDropDownHeader.cs index 176c066af5..00dc510338 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropDownHeader.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropDownHeader.cs @@ -21,6 +21,17 @@ namespace osu.Game.Graphics.UserInterface set { label.Text = value; } } + private Color4? accentColour; + public virtual Color4 AccentColour + { + get { return accentColour.GetValueOrDefault(); } + set + { + accentColour = value; + BackgroundColourHover = value; + } + } + public OsuDropDownHeader() { Foreground.Padding = new MarginPadding(4); @@ -30,7 +41,7 @@ namespace osu.Game.Graphics.UserInterface CornerRadius = 4; Height = 40; - Children = new[] + Foreground.Children = new Drawable[] { label = new OsuSpriteText { @@ -51,7 +62,7 @@ namespace osu.Game.Graphics.UserInterface private void load(OsuColour colours) { BackgroundColour = Color4.Black.Opacity(0.5f); - BackgroundColourHover = colours.PinkDarker; + BackgroundColourHover = accentColour ?? colours.PinkDarker; } } } \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs b/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs index 14615417f7..5d9e30db8d 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs @@ -1,39 +1,61 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Linq; +using osu.Framework.Allocation; using OpenTK; using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Transforms; using osu.Framework.Graphics.UserInterface; namespace osu.Game.Graphics.UserInterface { - public class OsuDropDownMenu : DropDownMenu + public class OsuDropDownMenu : DropDownMenu { - protected override DropDownHeader CreateHeader() => new OsuDropDownHeader(); + protected override DropDownHeader CreateHeader() => new OsuDropDownHeader { AccentColour = AccentColour }; + + private Color4? accentColour; + public virtual Color4 AccentColour + { + get { return accentColour.GetValueOrDefault(); } + set + { + accentColour = value; + if (Header != null) + ((OsuDropDownHeader)Header).AccentColour = value; + foreach (var item in ItemList.OfType>()) + item.AccentColour = value; + } + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + if (accentColour == null) + AccentColour = colours.PinkDarker; + } public OsuDropDownMenu() { ContentContainer.CornerRadius = 4; ContentBackground.Colour = Color4.Black.Opacity(0.5f); + + DropDownItemsContainer.Padding = new MarginPadding(5); } - protected override void AnimateOpen() - { - ContentContainer.FadeIn(300, EasingTypes.OutQuint); - } + protected override void AnimateOpen() => ContentContainer.FadeIn(300, EasingTypes.OutQuint); - protected override void AnimateClose() - { - ContentContainer.FadeOut(300, EasingTypes.OutQuint); - } + protected override void AnimateClose() => ContentContainer.FadeOut(300, EasingTypes.OutQuint); protected override void UpdateContentHeight() { - ContentContainer.ResizeTo(State == DropDownMenuState.Opened ? new Vector2(1, ContentHeight) : new Vector2(1, 0), 300, EasingTypes.OutQuint); + var actualHeight = (RelativeSizeAxes & Axes.Y) > 0 ? 1 : ContentHeight; + ContentContainer.ResizeTo(new Vector2(1, State == DropDownMenuState.Opened ? actualHeight : 0), 300, EasingTypes.OutQuint); } - protected override DropDownMenuItem CreateDropDownItem(string key, U value) => new OsuDropDownMenuItem(key, value); + protected override DropDownMenuItem CreateDropDownItem(string key, T value) => new OsuDropDownMenuItem(key, value) { AccentColour = AccentColour }; } } \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/OsuDropDownMenuItem.cs b/osu.Game/Graphics/UserInterface/OsuDropDownMenuItem.cs index b06422c302..71650dee52 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropDownMenuItem.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropDownMenuItem.cs @@ -18,6 +18,9 @@ namespace osu.Game.Graphics.UserInterface { Foreground.Padding = new MarginPadding(2); + Masking = true; + CornerRadius = 6; + Children = new[] { new FillFlowContainer @@ -27,12 +30,15 @@ namespace osu.Game.Graphics.UserInterface AutoSizeAxes = Axes.Y, Children = new Drawable[] { - new TextAwesome + chevron = new TextAwesome { + AlwaysPresent = true, Icon = FontAwesome.fa_chevron_right, + UseFullGlyphHeight = false, Colour = Color4.Black, - TextSize = 12, - Margin = new MarginPadding { Right = 3 }, + Alpha = 0.5f, + TextSize = 8, + Margin = new MarginPadding { Left = 3, Right = 3 }, Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, }, @@ -46,11 +52,33 @@ namespace osu.Game.Graphics.UserInterface }; } + private Color4? accentColour; + + private TextAwesome chevron; + + protected override void FormatForeground(bool hover = false) + { + base.FormatForeground(hover); + chevron.Alpha = hover ? 1 : 0; + } + + public Color4 AccentColour + { + get { return accentColour.GetValueOrDefault(); } + set + { + accentColour = value; + BackgroundColourHover = BackgroundColourSelected = value; + FormatBackground(); + FormatForeground(); + } + } + [BackgroundDependencyLoader] private void load(OsuColour colours) { - BackgroundColour = Color4.Black.Opacity(0.5f); - BackgroundColourHover = colours.PinkDarker; + BackgroundColour = Color4.Transparent; + BackgroundColourHover = accentColour ?? colours.PinkDarker; BackgroundColourSelected = Color4.Black.Opacity(0.5f); } } diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 4c2ec902a9..05f154a407 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -5,18 +5,24 @@ using System; using System.Linq; using OpenTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Graphics.UserInterface.Tab; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input; namespace osu.Game.Graphics.UserInterface { public class OsuTabControl : TabControl { - protected override TabDropDownMenu CreateDropDownMenu() => new OsuTabDropDownMenu(); + protected override DropDownMenu CreateDropDownMenu() => new OsuTabDropDownMenu(); protected override TabItem CreateTabItem(T value) => new OsuTabItem { Value = value }; public OsuTabControl() { + AlwaysReceiveInput = true; + if (!typeof(T).IsEnum) throw new InvalidOperationException("OsuTabControl only supports enums as the generic type argument"); @@ -45,5 +51,88 @@ namespace osu.Game.Graphics.UserInterface item.AccentColour = value; } } + + public class OsuTabDropDownMenu : OsuDropDownMenu + { + protected override DropDownHeader CreateHeader() => new OsuTabDropDownHeader + { + AccentColour = AccentColour, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + }; + + protected override DropDownMenuItem CreateDropDownItem(string key, T1 value) + { + var item = base.CreateDropDownItem(key, value); + item.ForegroundColourHover = Color4.Black; + return item; + } + + public OsuTabDropDownMenu() + { + ContentContainer.Anchor = Anchor.TopRight; + ContentContainer.Origin = Anchor.TopRight; + + RelativeSizeAxes = Axes.X; + + ContentBackground.Colour = Color4.Black.Opacity(0.7f); + MaxDropDownHeight = 400; + } + + public class OsuTabDropDownHeader : OsuDropDownHeader + { + public override Color4 AccentColour + { + get { return base.AccentColour; } + set + { + base.AccentColour = value; + Foreground.Colour = value; + } + } + + protected override bool OnHover(InputState state) + { + Foreground.Colour = BackgroundColour; + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + Foreground.Colour = BackgroundColourHover; + base.OnHoverLost(state); + } + + public OsuTabDropDownHeader() + { + RelativeSizeAxes = Axes.None; + AutoSizeAxes = Axes.X; + + BackgroundColour = Color4.Black.Opacity(0.5f); + + Background.Height = 0.5f; + Background.CornerRadius = 5; + Background.Masking = true; + + Foreground.RelativeSizeAxes = Axes.None; + Foreground.AutoSizeAxes = Axes.X; + Foreground.RelativeSizeAxes = Axes.Y; + Foreground.Margin = new MarginPadding(5); + + Foreground.Children = new Drawable[] + { + new TextAwesome + { + Icon = FontAwesome.fa_ellipsis_h, + TextSize = 14, + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + } + }; + + Padding = new MarginPadding { Left = 5, Right = 5 }; + } + } + } } } diff --git a/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs deleted file mode 100644 index 1b64056d97..0000000000 --- a/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System.Linq; -using OpenTK; -using OpenTK.Graphics; -using osu.Framework.Allocation; -using osu.Framework.Extensions.Color4Extensions; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Transforms; -using osu.Framework.Graphics.UserInterface; -using osu.Framework.Graphics.UserInterface.Tab; -using osu.Framework.Input; - -namespace osu.Game.Graphics.UserInterface -{ - public class OsuTabDropDownMenu : TabDropDownMenu - { - private Color4? accentColour; - public Color4 AccentColour - { - get { return accentColour.GetValueOrDefault(); } - set - { - accentColour = value; - ((OsuTabDropDownHeader)Header).AccentColour = value; - foreach (var item in ItemList.OfType>()) - item.AccentColour = value; - } - } - - protected override DropDownHeader CreateHeader() => new OsuTabDropDownHeader - { - AccentColour = AccentColour - }; - - protected override DropDownMenuItem CreateDropDownItem(string key, T value) => - new OsuTabDropDownMenuItem(key, value) { AccentColour = AccentColour }; - - public OsuTabDropDownMenu() - { - MaxDropDownHeight = int.MaxValue; - ContentContainer.CornerRadius = 4; - ContentBackground.Colour = Color4.Black.Opacity(0.9f); - ScrollContainer.ScrollDraggerVisible = false; - DropDownItemsContainer.Padding = new MarginPadding { Left = 5, Bottom = 7, Right = 5, Top = 7 }; - } - - protected override void AnimateOpen() - { - ContentContainer.FadeIn(300, EasingTypes.OutQuint); - } - - protected override void AnimateClose() - { - ContentContainer.FadeOut(300, EasingTypes.OutQuint); - } - - protected override void UpdateContentHeight() - { - ContentContainer.ResizeTo(new Vector2(1, State == DropDownMenuState.Opened ? ContentHeight : 0), 300, EasingTypes.OutQuint); - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - if (accentColour == null) - AccentColour = colours.Blue; - } - - public class OsuTabDropDownHeader : DropDownHeader - { - protected override string Label { get; set; } - - private Color4? accentColour; - public Color4 AccentColour - { - get { return accentColour.GetValueOrDefault(); } - set - { - accentColour = value; - BackgroundColourHover = value; - Foreground.Colour = value; - } - } - - protected override bool OnHover(InputState state) - { - Foreground.Colour = BackgroundColour; - return base.OnHover(state); - } - - protected override void OnHoverLost(InputState state) - { - Foreground.Colour = BackgroundColourHover; - base.OnHoverLost(state); - } - - public OsuTabDropDownHeader() - { - RelativeSizeAxes = Axes.None; - AutoSizeAxes = Axes.X; - - BackgroundColour = Color4.Black; - - Background.Height = 0.5f; - Background.CornerRadius = 3; - Background.Masking = true; - - Foreground.RelativeSizeAxes = Axes.None; - Foreground.AutoSizeAxes = Axes.X; - Foreground.RelativeSizeAxes = Axes.Y; - Foreground.Margin = new MarginPadding(5); - Foreground.Children = new Drawable[] - { - new TextAwesome - { - Icon = FontAwesome.fa_ellipsis_h, - TextSize = 14, - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - } - }; - - Padding = new MarginPadding { Left = 5, Right = 5 }; - } - } - } -} diff --git a/osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs deleted file mode 100644 index 86d451f7bb..0000000000 --- a/osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Allocation; -using osu.Framework.Extensions.Color4Extensions; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.UserInterface; -using OpenTK.Graphics; -using osu.Game.Graphics.Sprites; - -namespace osu.Game.Graphics.UserInterface -{ - public class OsuTabDropDownMenuItem : DropDownMenuItem - { - public OsuTabDropDownMenuItem(string text, T value) : base(text, value) - { - Foreground.Padding = new MarginPadding { Top = 4, Bottom = 4 }; - Foreground.Margin = new MarginPadding { Left = 7 }; - - Masking = true; - CornerRadius = 6; - Foreground.Add(new OsuSpriteText - { - Text = text, - Origin = Anchor.CentreLeft, - Anchor = Anchor.CentreLeft, - }); - } - - private Color4? accentColour; - public Color4 AccentColour - { - get { return accentColour.GetValueOrDefault(); } - set - { - accentColour = value; - BackgroundColourHover = BackgroundColourSelected = value; - FormatBackground(); - FormatForeground(); - } - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - BackgroundColour = Color4.Black.Opacity(0f); - ForegroundColourHover = Color4.Black; - ForegroundColourSelected = Color4.Black; - if (accentColour == null) - AccentColour = colours.Blue; - } - } -} diff --git a/osu.Game/Graphics/UserInterface/OsuTabItem.cs b/osu.Game/Graphics/UserInterface/OsuTabItem.cs index 9b8ea58a56..c394ee31a0 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabItem.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabItem.cs @@ -8,7 +8,7 @@ using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.UserInterface.Tab; +using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; using osu.Game.Graphics.Sprites; diff --git a/osu.Game/Screens/Play/KeyCounterCollection.cs b/osu.Game/Screens/Play/KeyCounterCollection.cs index bbda7ae318..bb6ab34cbb 100644 --- a/osu.Game/Screens/Play/KeyCounterCollection.cs +++ b/osu.Game/Screens/Play/KeyCounterCollection.cs @@ -4,7 +4,6 @@ using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using OpenTK; using OpenTK.Graphics; using osu.Framework.Input; diff --git a/osu.Game/Screens/Play/KeyCounterMouse.cs b/osu.Game/Screens/Play/KeyCounterMouse.cs index b0b93e80e7..744cb905d9 100644 --- a/osu.Game/Screens/Play/KeyCounterMouse.cs +++ b/osu.Game/Screens/Play/KeyCounterMouse.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Input; -using OpenTK; using OpenTK.Input; namespace osu.Game.Screens.Play diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index a655d0c4d4..637b6eafbc 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -9,11 +9,11 @@ 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; using osu.Game.Graphics.UserInterface; using osu.Game.Screens.Select.Filter; using Container = osu.Framework.Graphics.Containers.Container; -using osu.Framework.Graphics.UserInterface.Tab; using osu.Framework.Input; namespace osu.Game.Screens.Select diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 1936628ad5..a947742582 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -350,8 +350,6 @@ - - From 84b080a060eccb397959af51ecff002e9a983f3c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 21:26:03 +0900 Subject: [PATCH 30/37] Make transition logic a bit more sane. --- osu.Game/Graphics/UserInterface/OsuTabItem.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTabItem.cs b/osu.Game/Graphics/UserInterface/OsuTabItem.cs index c394ee31a0..c34ea09e2c 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabItem.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabItem.cs @@ -8,6 +8,7 @@ using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transforms; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; using osu.Game.Graphics.Sprites; @@ -54,16 +55,18 @@ namespace osu.Game.Graphics.UserInterface } } + private const float transition_length = 500; + private void fadeActive() { - box.FadeIn(300); - text.FadeColour(Color4.White, 300); + box.FadeIn(transition_length, EasingTypes.OutQuint); + text.FadeColour(Color4.White, transition_length, EasingTypes.OutQuint); } private void fadeInactive() { - box.FadeOut(300); - text.FadeColour(AccentColour, 300); + box.FadeOut(transition_length, EasingTypes.OutQuint); + text.FadeColour(AccentColour, transition_length, EasingTypes.OutQuint); } protected override bool OnHover(InputState state) From 2cf6ed423e789fe655e41b8d6d1eb058fb94f474 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 21:33:08 +0900 Subject: [PATCH 31/37] Disallow duplicate active changes. --- osu.Game/Graphics/UserInterface/OsuTabItem.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Graphics/UserInterface/OsuTabItem.cs b/osu.Game/Graphics/UserInterface/OsuTabItem.cs index c34ea09e2c..acfca1b67b 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabItem.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabItem.cs @@ -47,6 +47,8 @@ namespace osu.Game.Graphics.UserInterface get { return base.Active; } set { + if (Active == value) return; + if (value) fadeActive(); else From 8cd1353d747b824709c1d3b92611cfc9cb2df81e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 22:09:35 +0900 Subject: [PATCH 32/37] Fix serious input regression. --- osu.Game/Graphics/UserInterface/OsuTabControl.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 05f154a407..02cd5d683a 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -3,6 +3,7 @@ using System; using System.Linq; +using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; @@ -19,10 +20,10 @@ namespace osu.Game.Graphics.UserInterface protected override TabItem CreateTabItem(T value) => new OsuTabItem { Value = value }; + protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || DropDown.Contains(screenSpacePos); + public OsuTabControl() { - AlwaysReceiveInput = true; - if (!typeof(T).IsEnum) throw new InvalidOperationException("OsuTabControl only supports enums as the generic type argument"); From c07cba7f885a6991a872dec829fd7776fc4ae5c7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 22:11:42 +0900 Subject: [PATCH 33/37] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 4e64545c34..53dfe2a110 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 4e64545c34b71ddf6be1ce2c85d0bbb9ff15ef6c +Subproject commit 53dfe2a110d732cca0e7df58c33eca368bc7ff61 From 28e006eeb9f806e8cc41653df295fef4f17ac3ac Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 16 Mar 2017 23:17:27 +0900 Subject: [PATCH 34/37] Move MapDifficultyRange into BaseDifficulty. --- osu.Game/Database/BaseDifficulty.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/osu.Game/Database/BaseDifficulty.cs b/osu.Game/Database/BaseDifficulty.cs index 83f6e2fdd5..ea7511315f 100644 --- a/osu.Game/Database/BaseDifficulty.cs +++ b/osu.Game/Database/BaseDifficulty.cs @@ -15,6 +15,23 @@ namespace osu.Game.Database public float ApproachRate { get; set; } public float SliderMultiplier { get; set; } public float SliderTickRate { get; set; } + + /// + /// Maps a difficulty value [0, 10] to a two-piece linear range of values. + /// + /// The difficulty value to be mapped. + /// Minimum of the resulting range which will be achieved by a difficulty value of 0. + /// Midpoint of the resulting range which will be achieved by a difficulty value of 5. + /// Maximum of the resulting range which will be achieved by a difficulty value of 10. + /// Value to which the difficulty value maps in the specified range. + public static double DifficultyRange(double difficulty, double min, double mid, double max) + { + if (difficulty > 5) + return mid + (max - mid) * (difficulty - 5) / 5; + if (difficulty < 5) + return mid - (mid - min) * (5 - difficulty) / 5; + return mid; + } } } From e0a8c3b1e566e182db06fbd5e7fc78e206f8a492 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 16 Mar 2017 23:18:02 +0900 Subject: [PATCH 35/37] Rename BaseDifficulty -> Difficulty / BeatmapDifficulty. --- .../Tests/TestCaseGamefield.cs | 2 +- .../Tests/TestCasePlaySongSelect.cs | 6 +++--- .../Tests/TestCasePlayer.cs | 2 +- osu.Game.Modes.Osu/Objects/OsuHitObject.cs | 2 +- osu.Game.Modes.Osu/Objects/Slider.cs | 2 +- .../Beatmaps/Formats/OsuLegacyDecoderTest.cs | 2 +- osu.Game/Beatmaps/Beatmap.cs | 19 +------------------ osu.Game/Beatmaps/Formats/BeatmapDecoder.cs | 2 +- osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs | 2 +- osu.Game/Database/BaseDifficulty.cs | 2 +- osu.Game/Database/BeatmapDatabase.cs | 8 ++++---- osu.Game/Database/BeatmapInfo.cs | 6 +++--- 12 files changed, 19 insertions(+), 36 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs index aff2903078..c2e33f7f32 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs @@ -48,7 +48,7 @@ namespace osu.Desktop.VisualTests.Tests HitObjects = objects, BeatmapInfo = new BeatmapInfo { - BaseDifficulty = new BaseDifficulty(), + Difficulty = new BeatmapDifficulty(), Metadata = new BeatmapMetadata { Artist = @"Unknown", diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs index a4995d2320..c97ea929f3 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs @@ -80,7 +80,7 @@ namespace osu.Desktop.VisualTests.Tests Mode = PlayMode.Osu, Path = "normal.osu", Version = "Normal", - BaseDifficulty = new BaseDifficulty + Difficulty = new BeatmapDifficulty { OverallDifficulty = 3.5f, } @@ -91,7 +91,7 @@ namespace osu.Desktop.VisualTests.Tests Mode = PlayMode.Osu, Path = "hard.osu", Version = "Hard", - BaseDifficulty = new BaseDifficulty + Difficulty = new BeatmapDifficulty { OverallDifficulty = 5, } @@ -102,7 +102,7 @@ namespace osu.Desktop.VisualTests.Tests Mode = PlayMode.Osu, Path = "insane.osu", Version = "Insane", - BaseDifficulty = new BaseDifficulty + Difficulty = new BeatmapDifficulty { OverallDifficulty = 7, } diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs index 0d32532f09..41bd24b900 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs @@ -65,7 +65,7 @@ namespace osu.Desktop.VisualTests.Tests HitObjects = objects, BeatmapInfo = new BeatmapInfo { - BaseDifficulty = new BaseDifficulty(), + Difficulty = new BeatmapDifficulty(), Metadata = new BeatmapMetadata { Artist = @"Unknown", diff --git a/osu.Game.Modes.Osu/Objects/OsuHitObject.cs b/osu.Game.Modes.Osu/Objects/OsuHitObject.cs index a3f2222fbb..cee55a281c 100644 --- a/osu.Game.Modes.Osu/Objects/OsuHitObject.cs +++ b/osu.Game.Modes.Osu/Objects/OsuHitObject.cs @@ -69,7 +69,7 @@ namespace osu.Game.Modes.Osu.Objects public virtual void SetDefaultsFromBeatmap(Beatmap beatmap) { - Scale = (1.0f - 0.7f * (beatmap.BeatmapInfo.BaseDifficulty.CircleSize - 5) / 5) / 2; + Scale = (1.0f - 0.7f * (beatmap.BeatmapInfo.Difficulty.CircleSize - 5) / 5) / 2; } } } diff --git a/osu.Game.Modes.Osu/Objects/Slider.cs b/osu.Game.Modes.Osu/Objects/Slider.cs index 6c00af89b3..fdf3658d44 100644 --- a/osu.Game.Modes.Osu/Objects/Slider.cs +++ b/osu.Game.Modes.Osu/Objects/Slider.cs @@ -51,7 +51,7 @@ namespace osu.Game.Modes.Osu.Objects { base.SetDefaultsFromBeatmap(beatmap); - var baseDifficulty = beatmap.BeatmapInfo.BaseDifficulty; + var baseDifficulty = beatmap.BeatmapInfo.Difficulty; ControlPoint overridePoint; ControlPoint timingPoint = beatmap.TimingInfo.TimingPointAt(StartTime, out overridePoint); diff --git a/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs index 61638ef25e..356fa5a6c1 100644 --- a/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs @@ -94,7 +94,7 @@ namespace osu.Game.Tests.Beatmaps.Formats using (var stream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu")) { var beatmap = decoder.Decode(new StreamReader(stream)); - var difficulty = beatmap.BeatmapInfo.BaseDifficulty; + var difficulty = beatmap.BeatmapInfo.Difficulty; Assert.AreEqual(6.5f, difficulty.DrainRate); Assert.AreEqual(4, difficulty.CircleSize); Assert.AreEqual(8, difficulty.OverallDifficulty); diff --git a/osu.Game/Beatmaps/Beatmap.cs b/osu.Game/Beatmaps/Beatmap.cs index bf86aeea83..fc8bb751f9 100644 --- a/osu.Game/Beatmaps/Beatmap.cs +++ b/osu.Game/Beatmaps/Beatmap.cs @@ -51,30 +51,13 @@ namespace osu.Game.Beatmaps /// The slider velocity in positional length units. public double SliderVelocityAt(double time) { - double scoringDistance = 100 * BeatmapInfo.BaseDifficulty.SliderMultiplier; + double scoringDistance = 100 * BeatmapInfo.Difficulty.SliderMultiplier; double beatDistance = TimingInfo.BeatDistanceAt(time); if (beatDistance > 0) return scoringDistance / beatDistance * 1000; return scoringDistance; } - - /// - /// Maps a difficulty value [0, 10] to a two-piece linear range of values. - /// - /// The difficulty value to be mapped. - /// Minimum of the resulting range which will be achieved by a difficulty value of 0. - /// Midpoint of the resulting range which will be achieved by a difficulty value of 5. - /// Maximum of the resulting range which will be achieved by a difficulty value of 10. - /// Value to which the difficulty value maps in the specified range. - public static double MapDifficultyRange(double difficulty, double min, double mid, double max) - { - if (difficulty > 5) - return mid + (max - mid) * (difficulty - 5) / 5; - if (difficulty < 5) - return mid - (mid - min) * (5 - difficulty) / 5; - return mid; - } } /// diff --git a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs index 88cc977f1d..425c6cc5dc 100644 --- a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs +++ b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs @@ -45,7 +45,7 @@ namespace osu.Game.Beatmaps.Formats BeatmapInfo = new BeatmapInfo { Metadata = new BeatmapMetadata(), - BaseDifficulty = new BaseDifficulty(), + Difficulty = new BeatmapDifficulty(), }, }; ParseFile(stream, beatmap); diff --git a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs index 86f75de794..e7ede36b4b 100644 --- a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs +++ b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs @@ -144,7 +144,7 @@ namespace osu.Game.Beatmaps.Formats private void handleDifficulty(Beatmap beatmap, string key, string val) { - var difficulty = beatmap.BeatmapInfo.BaseDifficulty; + var difficulty = beatmap.BeatmapInfo.Difficulty; switch (key) { case @"HPDrainRate": diff --git a/osu.Game/Database/BaseDifficulty.cs b/osu.Game/Database/BaseDifficulty.cs index ea7511315f..3db8b29644 100644 --- a/osu.Game/Database/BaseDifficulty.cs +++ b/osu.Game/Database/BaseDifficulty.cs @@ -5,7 +5,7 @@ using SQLite.Net.Attributes; namespace osu.Game.Database { - public class BaseDifficulty + public class BeatmapDifficulty { [PrimaryKey, AutoIncrement] public int ID { get; set; } diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 871251b882..b3d48c152f 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -64,7 +64,7 @@ namespace osu.Game.Database foreach (var i in b.Beatmaps) { if (i.Metadata != null) connection.Delete(i.Metadata); - if (i.BaseDifficulty != null) connection.Delete(i.BaseDifficulty); + if (i.Difficulty != null) connection.Delete(i.Difficulty); connection.Delete(i); } @@ -90,7 +90,7 @@ namespace osu.Game.Database try { conn.CreateTable(); - conn.CreateTable(); + conn.CreateTable(); conn.CreateTable(); conn.CreateTable(); } @@ -112,7 +112,7 @@ namespace osu.Game.Database } connection.DeleteAll(); - connection.DeleteAll(); + connection.DeleteAll(); connection.DeleteAll(); connection.DeleteAll(); } @@ -329,7 +329,7 @@ namespace osu.Game.Database typeof(BeatmapSetInfo), typeof(BeatmapInfo), typeof(BeatmapMetadata), - typeof(BaseDifficulty), + typeof(BeatmapDifficulty), }; public void Update(T record, bool cascade = true) where T : class diff --git a/osu.Game/Database/BeatmapInfo.cs b/osu.Game/Database/BeatmapInfo.cs index 017f34726b..5f9c0baee8 100644 --- a/osu.Game/Database/BeatmapInfo.cs +++ b/osu.Game/Database/BeatmapInfo.cs @@ -31,11 +31,11 @@ namespace osu.Game.Database [OneToOne(CascadeOperations = CascadeOperation.All)] public BeatmapMetadata Metadata { get; set; } - [ForeignKey(typeof(BaseDifficulty)), NotNull] + [ForeignKey(typeof(BeatmapDifficulty)), NotNull] public int BaseDifficultyID { get; set; } [OneToOne(CascadeOperations = CascadeOperation.All)] - public BaseDifficulty BaseDifficulty { get; set; } + public BeatmapDifficulty Difficulty { get; set; } public string Path { get; set; } @@ -80,7 +80,7 @@ namespace osu.Game.Database { get { - return starDifficulty < 0 ? (BaseDifficulty?.OverallDifficulty ?? 5) : starDifficulty; + return starDifficulty < 0 ? (Difficulty?.OverallDifficulty ?? 5) : starDifficulty; } set { starDifficulty = value; } From b13340c3c8e93b5ce3707e8f7341bb5bf348c9f8 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 17 Mar 2017 00:30:23 +0900 Subject: [PATCH 36/37] Move CheckFailed outside of Schedule(). --- osu.Game/Screens/Play/Player.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 261d279600..ec8cbb1438 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -239,18 +239,18 @@ namespace osu.Game.Screens.Play private void onCompletion() { + // Force a final check to see if the player has failed + // Some game modes (e.g. taiko) fail at the end of the map + if (scoreProcessor.CheckFailed()) + { + // If failed, onFail will be invoked which will push a new screen. + // Let's not push the completion screen in this case + return; + } + Delay(1000); Schedule(delegate { - // Force a final check to see if the player has failed - // Some game modes (e.g. taiko) fail at the end of the map - if (scoreProcessor.CheckFailed()) - { - // If failed, onFail will be called which will push a new screen. - // Let's not push the completion screen in this case - return; - } - ValidForResume = false; Push(new Results { From e78bcf8739a22bfe61e46da0f3abc018dab324a1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 Mar 2017 00:35:27 +0900 Subject: [PATCH 37/37] Update TabControl in line with framework changes. --- osu-framework | 2 +- osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs | 6 +++--- osu.Game/Graphics/UserInterface/OsuTabControl.cs | 2 +- osu.Game/Screens/Select/FilterControl.cs | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/osu-framework b/osu-framework index 53dfe2a110..db310bfc10 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 53dfe2a110d732cca0e7df58c33eca368bc7ff61 +Subproject commit db310bfc10cd1c9ed12c9e19cdc0edfa53117353 diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs index 19cc32078c..da807d5e53 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs @@ -33,10 +33,10 @@ namespace osu.Desktop.VisualTests.Tests Position = new Vector2(275, 5) }); - filter.PinTab(GroupMode.All); - filter.PinTab(GroupMode.RecentlyPlayed); + filter.PinItem(GroupMode.All); + filter.PinItem(GroupMode.RecentlyPlayed); - filter.ValueChanged += (sender, mode) => + filter.ItemChanged += (sender, mode) => { text.Text = "Currently Selected: " + mode.ToString(); }; diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 02cd5d683a..d5699eddaf 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -28,7 +28,7 @@ namespace osu.Game.Graphics.UserInterface throw new InvalidOperationException("OsuTabControl only supports enums as the generic type argument"); foreach (var val in (T[])Enum.GetValues(typeof(T))) - AddTab(val); + AddItem(val); } [BackgroundDependencyLoader] diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 637b6eafbc..2a25928dc7 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -141,10 +141,10 @@ namespace osu.Game.Screens.Select } }; - groupTabs.PinTab(GroupMode.All); - groupTabs.PinTab(GroupMode.RecentlyPlayed); - groupTabs.ValueChanged += (sender, value) => Group = value; - sortTabs.ValueChanged += (sender, value) => Sort = value; + groupTabs.PinItem(GroupMode.All); + groupTabs.PinItem(GroupMode.RecentlyPlayed); + groupTabs.ItemChanged += (sender, value) => Group = value; + sortTabs.ItemChanged += (sender, value) => Sort = value; } public void Deactivate()