From 11dad7bf746820b56fa426f63f8582062de52a6d Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 10 Oct 2018 16:46:02 +0200 Subject: [PATCH 001/203] filter beatmaps by star range --- .../Visual/TestCaseBeatmapCarousel.cs | 49 +++++++++++++++++++ .../Select/Carousel/CarouselBeatmap.cs | 6 +++ osu.Game/Screens/Select/FilterControl.cs | 40 +++++++++------ osu.Game/Screens/Select/FilterCriteria.cs | 2 + 4 files changed, 81 insertions(+), 16 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs b/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs index db66c01814..df42ba9d16 100644 --- a/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs @@ -77,6 +77,7 @@ namespace osu.Game.Tests.Visual testEmptyTraversal(); testHiding(); testSelectingFilteredRuleset(); + testFilterByStarRange(); testCarouselRootIsRandom(); } @@ -245,6 +246,54 @@ namespace osu.Game.Tests.Visual AddAssert("Selection is non-null", () => currentSelection != null); } + /// + /// Test filtering by restricting the desired star range + /// + private void testFilterByStarRange() + { + var manyStarDiffs = createTestBeatmapSet(set_count + 1); + manyStarDiffs.Beatmaps.Clear(); + + for (int i = 0; i < 12; i++) + { + manyStarDiffs.Beatmaps.Add(new BeatmapInfo + { + OnlineBeatmapID = manyStarDiffs.ID * 10 + i, + Path = $"randomDiff{i}.osu", + Version = $"Totally Normal {i}", + StarDifficulty = i, + BaseDifficulty = new BeatmapDifficulty + { + OverallDifficulty = 5, + } + }); + } + + AddStep("add set with many stars", () => carousel.UpdateBeatmapSet(manyStarDiffs)); + + AddStep("select added set", () => carousel.SelectBeatmap(manyStarDiffs.Beatmaps[0], false)); + + AddStep("Filter to 1-3 stars", () => carousel.Filter(new FilterCriteria { DisplayStarsMinimum = 1, DisplayStarsMaximum = 3 }, false)); + checkVisibleItemCount(diff: false, count: 1); + checkVisibleItemCount(diff: true, count: 3); + + AddStep("Filter to 3-3 stars", () => carousel.Filter(new FilterCriteria { DisplayStarsMinimum = 3, DisplayStarsMaximum = 3 }, false)); + checkVisibleItemCount(diff: false, count: 1); + checkVisibleItemCount(diff: true, count: 1); + + AddStep("Filter to 4-2 stars", () => carousel.Filter(new FilterCriteria { DisplayStarsMinimum = 4, DisplayStarsMaximum = 2 }, false)); + checkVisibleItemCount(diff: false, count: 0); + checkVisibleItemCount(diff: true, count: 0); + + AddStep("remove added set", () => + { + carousel.RemoveBeatmapSet(manyStarDiffs); + manyStarDiffs = null; + }); + + AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false)); + } + /// /// Test random non-repeating algorithm /// diff --git a/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs b/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs index 272332f1ce..c9ed2f3573 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs @@ -26,6 +26,12 @@ namespace osu.Game.Screens.Select.Carousel bool match = criteria.Ruleset == null || Beatmap.RulesetID == criteria.Ruleset.ID || Beatmap.RulesetID == 0 && criteria.Ruleset.ID > 0 && criteria.AllowConvertedBeatmaps; + if(criteria.DisplayStarsMinimum.HasValue) + match &= Beatmap.StarDifficulty >= criteria.DisplayStarsMinimum; + + if (criteria.DisplayStarsMaximum.HasValue) + match &= Beatmap.StarDifficulty <= criteria.DisplayStarsMaximum; + if (!string.IsNullOrEmpty(criteria.SearchText)) match &= Beatmap.Metadata.SearchableTerms.Any(term => term.IndexOf(criteria.SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0) || diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index fce7af1400..78b452b6f5 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -32,14 +32,13 @@ namespace osu.Game.Screens.Select public SortMode Sort { - get { return sort; } + get => sort; set { - if (sort != value) - { - sort = value; - FilterChanged?.Invoke(CreateCriteria()); - } + if (sort == value) return; + + sort = value; + FilterChanged?.Invoke(CreateCriteria()); } } @@ -47,14 +46,13 @@ namespace osu.Game.Screens.Select public GroupMode Group { - get { return group; } + get => group; set { - if (group != value) - { - group = value; - FilterChanged?.Invoke(CreateCriteria()); - } + if (group == value) return; + + group = value; + FilterChanged?.Invoke(CreateCriteria()); } } @@ -64,7 +62,9 @@ namespace osu.Game.Screens.Select Sort = sort, SearchText = searchTextBox.Text, AllowConvertedBeatmaps = showConverted, - Ruleset = ruleset.Value + Ruleset = ruleset.Value, + DisplayStarsMinimum = minimumStars, + DisplayStarsMaximum = maximumStars, }; public Action Exit; @@ -168,7 +168,9 @@ namespace osu.Game.Screens.Select private readonly IBindable ruleset = new Bindable(); - private Bindable showConverted; + private readonly Bindable showConverted = new Bindable(); + private readonly Bindable minimumStars = new Bindable(); + private readonly Bindable maximumStars = new Bindable(); public readonly Box Background; @@ -177,8 +179,14 @@ namespace osu.Game.Screens.Select { sortTabs.AccentColour = colours.GreenLight; - showConverted = config.GetBindable(OsuSetting.ShowConvertedBeatmaps); - showConverted.ValueChanged += val => updateCriteria(); + config.BindWith(OsuSetting.ShowConvertedBeatmaps, showConverted); + showConverted.ValueChanged += _ => updateCriteria(); + + config.BindWith(OsuSetting.DisplayStarsMinimum, minimumStars); + minimumStars.ValueChanged += _ => updateCriteria(); + + config.BindWith(OsuSetting.DisplayStarsMaximum, maximumStars); + maximumStars.ValueChanged += _ => updateCriteria(); ruleset.BindTo(parentRuleset); ruleset.BindValueChanged(_ => updateCriteria(), true); diff --git a/osu.Game/Screens/Select/FilterCriteria.cs b/osu.Game/Screens/Select/FilterCriteria.cs index bea806f00f..f97eb1bea1 100644 --- a/osu.Game/Screens/Select/FilterCriteria.cs +++ b/osu.Game/Screens/Select/FilterCriteria.cs @@ -13,5 +13,7 @@ namespace osu.Game.Screens.Select public string SearchText; public RulesetInfo Ruleset; public bool AllowConvertedBeatmaps; + public double? DisplayStarsMinimum; + public double? DisplayStarsMaximum; } } From d83ce7e4bb35b352f112d1353c4766b4006281be Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 19 Oct 2018 12:22:05 +0200 Subject: [PATCH 002/203] don't allow null values in FilterCriteria, ensure values in test instead --- .../Visual/TestCaseBeatmapCarousel.cs | 51 +++++++++++-------- .../Select/Carousel/CarouselBeatmap.cs | 7 +-- osu.Game/Screens/Select/FilterCriteria.cs | 4 +- 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs b/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs index df42ba9d16..a57ef21dd9 100644 --- a/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs @@ -65,6 +65,10 @@ namespace osu.Game.Tests.Visual carousel.SelectionChanged = s => currentSelection = s; + // not being hooked up to the config leads to the SR filter only showing 0 to 0 SR maps + // thus "filter" once to assume a 0 to 10 range + carousel.Filter(new TestCriteria()); + loadBeatmaps(beatmapSets); testTraversal(); @@ -150,9 +154,7 @@ namespace osu.Game.Tests.Visual private bool selectedBeatmapVisible() { var currentlySelected = carousel.Items.FirstOrDefault(s => s.Item is CarouselBeatmap && s.Item.State == CarouselItemState.Selected); - if (currentlySelected == null) - return true; - return currentlySelected.Item.Visible; + return currentlySelected?.Item.Visible ?? true; } private void checkInvisibleDifficultiesUnselectable() @@ -165,8 +167,8 @@ namespace osu.Game.Tests.Visual { AddStep("Toggle non-matching filter", () => { - carousel.Filter(new FilterCriteria { SearchText = "Dingo" }, false); - carousel.Filter(new FilterCriteria(), false); + carousel.Filter(new TestCriteria { SearchText = "Dingo" }, false); + carousel.Filter(new TestCriteria(), false); eagerSelectedIDs.Add(carousel.SelectedBeatmapSet.ID); } ); @@ -207,7 +209,7 @@ namespace osu.Game.Tests.Visual setSelected(1, 1); - AddStep("Filter", () => carousel.Filter(new FilterCriteria { SearchText = "set #3!" }, false)); + AddStep("Filter", () => carousel.Filter(new TestCriteria { SearchText = "set #3!" }, false)); checkVisibleItemCount(diff: false, count: 1); checkVisibleItemCount(diff: true, count: 3); checkSelected(3, 1); @@ -215,7 +217,7 @@ namespace osu.Game.Tests.Visual advanceSelection(diff: true, count: 4); checkSelected(3, 2); - AddStep("Un-filter (debounce)", () => carousel.Filter(new FilterCriteria())); + AddStep("Un-filter (debounce)", () => carousel.Filter(new TestCriteria())); AddUntilStep(() => !carousel.PendingFilterTask, "Wait for debounce"); checkVisibleItemCount(diff: false, count: set_count); checkVisibleItemCount(diff: true, count: 3); @@ -223,13 +225,13 @@ namespace osu.Game.Tests.Visual // test filtering some difficulties (and keeping current beatmap set selected). setSelected(1, 2); - AddStep("Filter some difficulties", () => carousel.Filter(new FilterCriteria { SearchText = "Normal" }, false)); + AddStep("Filter some difficulties", () => carousel.Filter(new TestCriteria { SearchText = "Normal" }, false)); checkSelected(1, 1); - AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false)); + AddStep("Un-filter", () => carousel.Filter(new TestCriteria(), false)); checkSelected(1, 1); - AddStep("Filter all", () => carousel.Filter(new FilterCriteria { SearchText = "Dingo" }, false)); + AddStep("Filter all", () => carousel.Filter(new TestCriteria { SearchText = "Dingo" }, false)); checkVisibleItemCount(false, 0); checkVisibleItemCount(true, 0); @@ -241,7 +243,7 @@ namespace osu.Game.Tests.Visual advanceSelection(false); AddAssert("Selection is null", () => currentSelection == null); - AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false)); + AddStep("Un-filter", () => carousel.Filter(new TestCriteria(), false)); AddAssert("Selection is non-null", () => currentSelection != null); } @@ -273,15 +275,15 @@ namespace osu.Game.Tests.Visual AddStep("select added set", () => carousel.SelectBeatmap(manyStarDiffs.Beatmaps[0], false)); - AddStep("Filter to 1-3 stars", () => carousel.Filter(new FilterCriteria { DisplayStarsMinimum = 1, DisplayStarsMaximum = 3 }, false)); + AddStep("Filter to 1-3 stars", () => carousel.Filter(new TestCriteria { DisplayStarsMinimum = 1, DisplayStarsMaximum = 3 }, false)); checkVisibleItemCount(diff: false, count: 1); checkVisibleItemCount(diff: true, count: 3); - AddStep("Filter to 3-3 stars", () => carousel.Filter(new FilterCriteria { DisplayStarsMinimum = 3, DisplayStarsMaximum = 3 }, false)); + AddStep("Filter to 3-3 stars", () => carousel.Filter(new TestCriteria { DisplayStarsMinimum = 3, DisplayStarsMaximum = 3 }, false)); checkVisibleItemCount(diff: false, count: 1); checkVisibleItemCount(diff: true, count: 1); - AddStep("Filter to 4-2 stars", () => carousel.Filter(new FilterCriteria { DisplayStarsMinimum = 4, DisplayStarsMaximum = 2 }, false)); + AddStep("Filter to 4-2 stars", () => carousel.Filter(new TestCriteria { DisplayStarsMinimum = 4, DisplayStarsMaximum = 2 }, false)); checkVisibleItemCount(diff: false, count: 0); checkVisibleItemCount(diff: true, count: 0); @@ -291,7 +293,7 @@ namespace osu.Game.Tests.Visual manyStarDiffs = null; }); - AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false)); + AddStep("Un-filter", () => carousel.Filter(new TestCriteria(), false)); } /// @@ -322,13 +324,13 @@ namespace osu.Game.Tests.Visual AddAssert("ensure repeat", () => selectedSets.Contains(carousel.SelectedBeatmapSet)); AddStep("Add set with 100 difficulties", () => carousel.UpdateBeatmapSet(createTestBeatmapSetWithManyDifficulties(set_count + 1))); - AddStep("Filter Extra", () => carousel.Filter(new FilterCriteria { SearchText = "Extra 10" }, false)); + AddStep("Filter Extra", () => carousel.Filter(new TestCriteria { SearchText = "Extra 10" }, false)); checkInvisibleDifficultiesUnselectable(); checkInvisibleDifficultiesUnselectable(); checkInvisibleDifficultiesUnselectable(); checkInvisibleDifficultiesUnselectable(); checkInvisibleDifficultiesUnselectable(); - AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false)); + AddStep("Un-filter", () => carousel.Filter(new TestCriteria(), false)); } /// @@ -359,9 +361,9 @@ namespace osu.Game.Tests.Visual /// private void testSorting() { - AddStep("Sort by author", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Author }, false)); + AddStep("Sort by author", () => carousel.Filter(new TestCriteria { Sort = SortMode.Author }, false)); AddAssert("Check zzzzz is at bottom", () => carousel.BeatmapSets.Last().Metadata.AuthorString == "zzzzz"); - AddStep("Sort by artist", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Artist }, false)); + AddStep("Sort by artist", () => carousel.Filter(new TestCriteria { Sort = SortMode.Artist }, false)); AddAssert($"Check #{set_count} is at bottom", () => carousel.BeatmapSets.Last().Metadata.Title.EndsWith($"#{set_count}!")); } @@ -451,7 +453,7 @@ namespace osu.Game.Tests.Visual carousel.UpdateBeatmapSet(testMixed); }); AddStep("filter to ruleset 0", () => - carousel.Filter(new FilterCriteria { Ruleset = rulesets.AvailableRulesets.ElementAt(0) }, false)); + carousel.Filter(new TestCriteria { Ruleset = rulesets.AvailableRulesets.ElementAt(0) }, false)); AddStep("select filtered map skipping filtered", () => carousel.SelectBeatmap(testMixed.Beatmaps[1], false)); AddAssert("unfiltered beatmap selected", () => carousel.SelectedBeatmap.Equals(testMixed.Beatmaps[0])); @@ -581,5 +583,14 @@ namespace osu.Game.Tests.Visual public bool PendingFilterTask => PendingFilter != null; } + + private class TestCriteria : FilterCriteria + { + public TestCriteria() + { + DisplayStarsMinimum = 0; + DisplayStarsMaximum = 10; + } + } } } diff --git a/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs b/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs index c9ed2f3573..2e1adaf66f 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs @@ -25,12 +25,7 @@ namespace osu.Game.Screens.Select.Carousel base.Filter(criteria); bool match = criteria.Ruleset == null || Beatmap.RulesetID == criteria.Ruleset.ID || Beatmap.RulesetID == 0 && criteria.Ruleset.ID > 0 && criteria.AllowConvertedBeatmaps; - - if(criteria.DisplayStarsMinimum.HasValue) - match &= Beatmap.StarDifficulty >= criteria.DisplayStarsMinimum; - - if (criteria.DisplayStarsMaximum.HasValue) - match &= Beatmap.StarDifficulty <= criteria.DisplayStarsMaximum; + match &= Beatmap.StarDifficulty >= criteria.DisplayStarsMinimum && Beatmap.StarDifficulty <= criteria.DisplayStarsMaximum; if (!string.IsNullOrEmpty(criteria.SearchText)) match &= diff --git a/osu.Game/Screens/Select/FilterCriteria.cs b/osu.Game/Screens/Select/FilterCriteria.cs index f97eb1bea1..bd8bb22e1c 100644 --- a/osu.Game/Screens/Select/FilterCriteria.cs +++ b/osu.Game/Screens/Select/FilterCriteria.cs @@ -13,7 +13,7 @@ namespace osu.Game.Screens.Select public string SearchText; public RulesetInfo Ruleset; public bool AllowConvertedBeatmaps; - public double? DisplayStarsMinimum; - public double? DisplayStarsMaximum; + public double DisplayStarsMinimum; + public double DisplayStarsMaximum; } } From 608223cbb408d33b27c45c8183c13c0d49172c4f Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 4 Jul 2019 11:59:38 +0200 Subject: [PATCH 003/203] Add setting to collapse the song progress graph --- .../Visual/Gameplay/TestSceneSongProgress.cs | 16 +++- osu.Game/Configuration/OsuConfigManager.cs | 2 + .../Sections/Gameplay/GeneralSettings.cs | 5 + osu.Game/Screens/Play/SongProgress.cs | 93 +++++++++++-------- osu.Game/Screens/Play/SongProgressBar.cs | 5 +- 5 files changed, 77 insertions(+), 44 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs index af21007efe..eef7a25c7a 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Collections.Generic; using NUnit.Framework; using osu.Framework.Allocation; @@ -15,6 +16,11 @@ namespace osu.Game.Tests.Visual.Gameplay [TestFixture] public class TestSceneSongProgress : OsuTestScene { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(SongProgressBar), + }; + private readonly SongProgress progress; private readonly TestSongProgressGraph graph; @@ -46,24 +52,26 @@ namespace osu.Game.Tests.Visual.Gameplay Origin = Anchor.TopLeft, }); - AddWaitStep("wait some", 5); AddAssert("ensure not created", () => graph.CreationCount == 0); AddStep("display values", displayNewValues); - AddWaitStep("wait some", 5); AddUntilStep("wait for creation count", () => graph.CreationCount == 1); AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking); - AddWaitStep("wait some", 5); AddUntilStep("wait for creation count", () => graph.CreationCount == 1); AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking); - AddWaitStep("wait some", 5); AddUntilStep("wait for creation count", () => graph.CreationCount == 1); AddRepeatStep("New Values", displayNewValues, 5); AddWaitStep("wait some", 5); AddAssert("ensure debounced", () => graph.CreationCount == 2); + + AddStep("hide graph", () => progress.CollapseGraph.Value = true); + AddStep("show graph", () => progress.CollapseGraph.Value = false); + + AddStep("start", clock.Start); + AddStep("pause", clock.Stop); } private void displayNewValues() diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 795f0b43f7..f3792fcb7f 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -77,6 +77,7 @@ namespace osu.Game.Configuration Set(OsuSetting.BlurLevel, 0, 0, 1, 0.01); Set(OsuSetting.ShowInterface, true); + Set(OsuSetting.CollapseProgressGraph, false); Set(OsuSetting.KeyOverlay, false); Set(OsuSetting.FloatingComments, false); @@ -131,6 +132,7 @@ namespace osu.Game.Configuration KeyOverlay, FloatingComments, ShowInterface, + CollapseProgressGraph, MouseDisableButtons, MouseDisableWheel, AudioOffset, diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs index 997d1354b3..e365973c4b 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs @@ -35,6 +35,11 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay Bindable = config.GetBindable(OsuSetting.ShowInterface) }, new SettingsCheckbox + { + LabelText = "Collapse song progress graph", + Bindable = config.GetBindable(OsuSetting.CollapseProgressGraph) + }, + new SettingsCheckbox { LabelText = "Always show key overlay", Bindable = config.GetBindable(OsuSetting.KeyOverlay) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 6642efdf8b..a535dc3333 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -11,6 +11,7 @@ using osu.Framework.Allocation; using System.Linq; using osu.Framework.Bindables; using osu.Framework.Timing; +using osu.Game.Configuration; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.UI; @@ -20,7 +21,7 @@ namespace osu.Game.Screens.Play public class SongProgress : OverlayContainer { private const int bottom_bar_height = 5; - + private const float graph_height = SquareGraph.Column.WIDTH * 6; private static readonly Vector2 handle_size = new Vector2(10, 18); private const float transition_duration = 200; @@ -30,13 +31,13 @@ namespace osu.Game.Screens.Play private readonly SongProgressInfo info; public Action RequestSeek; + public readonly Bindable CollapseGraph = new Bindable(); public override bool HandleNonPositionalInput => AllowSeeking; public override bool HandlePositionalInput => AllowSeeking; - private double lastHitTime => ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1; - private double firstHitTime => objects.First().StartTime; + private double lastHitTime => ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1; private IEnumerable objects; @@ -54,25 +55,28 @@ namespace osu.Game.Screens.Play } } + private bool allowSeeking; + + public bool AllowSeeking + { + get => allowSeeking; + set + { + if (allowSeeking == value) return; + + allowSeeking = value; + updateBarVisibility(); + } + } + private readonly BindableBool replayLoaded = new BindableBool(); public IClock ReferenceClock; private IClock gameplayClock; - [BackgroundDependencyLoader(true)] - private void load(OsuColour colours, GameplayClock clock) - { - if (clock != null) - gameplayClock = clock; - - graph.FillColour = bar.FillColour = colours.BlueLighter; - } - public SongProgress() { - const float graph_height = SquareGraph.Column.WIDTH * 6; - Height = bottom_bar_height + graph_height + handle_size.Y; Y = bottom_bar_height; @@ -104,12 +108,23 @@ namespace osu.Game.Screens.Play }; } + [BackgroundDependencyLoader(true)] + private void load(OsuColour colours, GameplayClock clock, OsuConfigManager config) + { + if (clock != null) + gameplayClock = clock; + + config.BindWith(OsuSetting.CollapseProgressGraph, CollapseGraph); + + graph.FillColour = bar.FillColour = colours.BlueLighter; + } + protected override void LoadComplete() { Show(); - replayLoaded.ValueChanged += loaded => AllowSeeking = loaded.NewValue; - replayLoaded.TriggerChange(); + replayLoaded.BindValueChanged(loaded => AllowSeeking = loaded.NewValue, true); + CollapseGraph.BindValueChanged(_ => updateGraphVisibility(), true); } public void BindDrawableRuleset(DrawableRuleset drawableRuleset) @@ -117,28 +132,6 @@ namespace osu.Game.Screens.Play replayLoaded.BindTo(drawableRuleset.HasReplayLoaded); } - private bool allowSeeking; - - public bool AllowSeeking - { - get => allowSeeking; - set - { - if (allowSeeking == value) return; - - allowSeeking = value; - updateBarVisibility(); - } - } - - private void updateBarVisibility() - { - bar.FadeTo(allowSeeking ? 1 : 0, transition_duration, Easing.In); - this.MoveTo(new Vector2(0, allowSeeking ? 0 : bottom_bar_height), transition_duration, Easing.In); - - info.Margin = new MarginPadding { Bottom = Height - (allowSeeking ? 0 : handle_size.Y) }; - } - protected override void PopIn() { updateBarVisibility(); @@ -165,5 +158,29 @@ namespace osu.Game.Screens.Play bar.CurrentTime = gameplayTime; graph.Progress = (int)(graph.ColumnCount * progress); } + + private void updateBarVisibility() + { + bar.FadeTo(allowSeeking ? 1 : 0, transition_duration, Easing.In); + this.MoveTo(new Vector2(0, allowSeeking ? 0 : bottom_bar_height), transition_duration, Easing.In); + + updateInfoMargin(); + } + + private void updateGraphVisibility() + { + float barHeight = bottom_bar_height + handle_size.Y; + + bar.ResizeHeightTo(CollapseGraph.Value ? barHeight : barHeight + graph_height, transition_duration, Easing.In); + graph.MoveToY(CollapseGraph.Value ? graph_height : 0, transition_duration, Easing.In); + + updateInfoMargin(); + } + + private void updateInfoMargin() + { + float finalMargin = bottom_bar_height + (allowSeeking ? handle_size.Y : 0) + (CollapseGraph.Value ? 0 : graph_height); + info.TransformTo(nameof(info.Margin), new MarginPadding { Bottom = finalMargin }, transition_duration, Easing.In); + } } } diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs index dd7b5826d5..0a906845fc 100644 --- a/osu.Game/Screens/Play/SongProgressBar.cs +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -18,6 +18,7 @@ namespace osu.Game.Screens.Play private readonly Box fill; private readonly Container handleBase; + private readonly Container handleContainer; public Color4 FillColour { @@ -73,7 +74,6 @@ namespace osu.Game.Screens.Play Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, Width = 2, - Height = barHeight + handleBarHeight, Colour = Color4.White, Position = new Vector2(2, 0), Children = new Drawable[] @@ -83,7 +83,7 @@ namespace osu.Game.Screens.Play Name = "HandleBar box", RelativeSizeAxes = Axes.Both, }, - new Container + handleContainer = new Container { Name = "Handle container", Origin = Anchor.BottomCentre, @@ -115,6 +115,7 @@ namespace osu.Game.Screens.Play { base.Update(); + handleBase.Height = Height - handleContainer.Height; float newX = (float)Interpolation.Lerp(handleBase.X, NormalizedValue * UsableWidth, MathHelper.Clamp(Time.Elapsed / 40, 0, 1)); fill.Width = newX; From e69160a0ce1f80bee073cc618c7205106ac5a206 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 5 Jul 2019 08:05:18 +0200 Subject: [PATCH 004/203] fix graph not completely hiding --- osu.Game/Screens/Play/SongProgress.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index a535dc3333..a201b04864 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -172,7 +172,7 @@ namespace osu.Game.Screens.Play float barHeight = bottom_bar_height + handle_size.Y; bar.ResizeHeightTo(CollapseGraph.Value ? barHeight : barHeight + graph_height, transition_duration, Easing.In); - graph.MoveToY(CollapseGraph.Value ? graph_height : 0, transition_duration, Easing.In); + graph.MoveToY(CollapseGraph.Value ? bottom_bar_height + graph_height : 0, transition_duration, Easing.In); updateInfoMargin(); } From c22667bdf79eed3048331c1350526041553761f5 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 5 Jul 2019 08:05:23 +0200 Subject: [PATCH 005/203] reorganise tests --- .../Visual/Gameplay/TestSceneSongProgress.cs | 128 ++++++++++++------ 1 file changed, 84 insertions(+), 44 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs index eef7a25c7a..810659233b 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs @@ -7,6 +7,7 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.MathUtils; +using osu.Framework.Testing; using osu.Framework.Timing; using osu.Game.Rulesets.Objects; using osu.Game.Screens.Play; @@ -21,65 +22,104 @@ namespace osu.Game.Tests.Visual.Gameplay typeof(SongProgressBar), }; - private readonly SongProgress progress; - private readonly TestSongProgressGraph graph; + private SongProgress progress; + private TestSongProgressGraph graph; private readonly StopwatchClock clock; + private readonly FramedClock framedClock; [Cached] private readonly GameplayClock gameplayClock; - private readonly FramedClock framedClock; - public TestSceneSongProgress() { - clock = new StopwatchClock(true); - + clock = new StopwatchClock(); gameplayClock = new GameplayClock(framedClock = new FramedClock(clock)); - - Add(progress = new SongProgress - { - RelativeSizeAxes = Axes.X, - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - }); - - Add(graph = new TestSongProgressGraph - { - RelativeSizeAxes = Axes.X, - Height = 200, - Anchor = Anchor.TopLeft, - Origin = Anchor.TopLeft, - }); - - AddAssert("ensure not created", () => graph.CreationCount == 0); - - AddStep("display values", displayNewValues); - AddUntilStep("wait for creation count", () => graph.CreationCount == 1); - - AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking); - AddUntilStep("wait for creation count", () => graph.CreationCount == 1); - - AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking); - AddUntilStep("wait for creation count", () => graph.CreationCount == 1); - AddRepeatStep("New Values", displayNewValues, 5); - - AddWaitStep("wait some", 5); - AddAssert("ensure debounced", () => graph.CreationCount == 2); - - AddStep("hide graph", () => progress.CollapseGraph.Value = true); - AddStep("show graph", () => progress.CollapseGraph.Value = false); - - AddStep("start", clock.Start); - AddStep("pause", clock.Stop); } - private void displayNewValues() + [SetUpSteps] + public void SetupSteps() { - List objects = new List(); + AddStep("add new song progress", () => + { + if (progress != null) + { + progress.Expire(); + progress = null; + } + + Add(progress = new SongProgress + { + RelativeSizeAxes = Axes.X, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + }); + }); + + AddStep("add new big graph", () => + { + if (graph != null) + { + graph.Expire(); + graph = null; + } + + Add(graph = new TestSongProgressGraph + { + RelativeSizeAxes = Axes.X, + Height = 200, + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, + }); + }); + + AddStep("reset clock", clock.Reset); + } + + [Test] + public void TestGraphRecreation() + { + AddAssert("ensure not created", () => graph.CreationCount == 0); + AddStep("display values", displayRandomValues); + AddUntilStep("wait for creation count", () => graph.CreationCount == 1); + AddRepeatStep("new values", displayRandomValues, 5); + AddWaitStep("wait some", 5); + AddAssert("ensure recreation debounced", () => graph.CreationCount == 2); + } + + [Test] + public void TestDisplay() + { + AddStep("display max values", displayMaxValues); + AddStep("start", clock.Start); + AddStep("show bar", () => progress.AllowSeeking = true); + AddStep("hide graph", () => progress.CollapseGraph.Value = true); + AddStep("hide Bar", () => progress.AllowSeeking = false); + AddStep("show bar", () => progress.AllowSeeking = true); + AddStep("show graph", () => progress.CollapseGraph.Value = false); + AddStep("stop", clock.Stop); + } + + private void displayRandomValues() + { + var objects = new List(); for (double i = 0; i < 5000; i += RNG.NextDouble() * 10 + i / 1000) objects.Add(new HitObject { StartTime = i }); + replaceObjects(objects); + } + + private void displayMaxValues() + { + var objects = new List(); + for (double i = 0; i < 5000; i++) + objects.Add(new HitObject { StartTime = i }); + + replaceObjects(objects); + } + + private void replaceObjects(List objects) + { progress.Objects = objects; graph.Objects = objects; From 1cb7a9617be89f5f01f6b21bc6ce280fdf8e2c95 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 5 Jul 2019 08:29:57 +0200 Subject: [PATCH 006/203] move songprogress up to be able to see below for masking --- .../Visual/Gameplay/TestSceneSongProgress.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs index 810659233b..550115846b 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs @@ -6,9 +6,12 @@ using System.Collections.Generic; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; using osu.Framework.MathUtils; using osu.Framework.Testing; using osu.Framework.Timing; +using osu.Game.Graphics; using osu.Game.Rulesets.Objects; using osu.Game.Screens.Play; @@ -24,6 +27,7 @@ namespace osu.Game.Tests.Visual.Gameplay private SongProgress progress; private TestSongProgressGraph graph; + private readonly Container progressContainer; private readonly StopwatchClock clock; private readonly FramedClock framedClock; @@ -35,6 +39,20 @@ namespace osu.Game.Tests.Visual.Gameplay { clock = new StopwatchClock(); gameplayClock = new GameplayClock(framedClock = new FramedClock(clock)); + + Add(progressContainer = new Container + { + RelativeSizeAxes = Axes.X, + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + Height = 100, + Y = -100, + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.Gray(1), + } + }); } [SetUpSteps] @@ -48,7 +66,7 @@ namespace osu.Game.Tests.Visual.Gameplay progress = null; } - Add(progress = new SongProgress + progressContainer.Add(progress = new SongProgress { RelativeSizeAxes = Axes.X, Anchor = Anchor.BottomLeft, @@ -91,6 +109,7 @@ namespace osu.Game.Tests.Visual.Gameplay public void TestDisplay() { AddStep("display max values", displayMaxValues); + AddUntilStep("wait for graph", () => graph.CreationCount == 1); AddStep("start", clock.Start); AddStep("show bar", () => progress.AllowSeeking = true); AddStep("hide graph", () => progress.CollapseGraph.Value = true); From ed22c23f37bf57a9d1de77db3a905a718a5394db Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 5 Jul 2019 08:30:32 +0200 Subject: [PATCH 007/203] mask SongProgress --- osu.Game/Screens/Play/SongProgress.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index a201b04864..9ebfeb5c82 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -77,8 +77,8 @@ namespace osu.Game.Screens.Play public SongProgress() { - Height = bottom_bar_height + graph_height + handle_size.Y; - Y = bottom_bar_height; + Masking = true; + Height = bottom_bar_height + graph_height + handle_size.Y + OsuFont.Numeric.Size; Children = new Drawable[] { @@ -88,7 +88,6 @@ namespace osu.Game.Screens.Play Anchor = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Bottom = bottom_bar_height + graph_height }, }, graph = new SongProgressGraph { From b425df6c75afa792aa97165a798d3a884c6a8c04 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 5 Jul 2019 08:48:40 +0200 Subject: [PATCH 008/203] various fixes - make AllowSeeking a Bindable which fixes incorrect initial position and removes unnecessary variables - make SongProgressInfo fixed height --- .../Visual/Gameplay/TestSceneSongProgress.cs | 6 +-- osu.Game/Screens/Play/SongProgress.cs | 45 ++++++++----------- 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs index 550115846b..e16ad42558 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs @@ -111,10 +111,10 @@ namespace osu.Game.Tests.Visual.Gameplay AddStep("display max values", displayMaxValues); AddUntilStep("wait for graph", () => graph.CreationCount == 1); AddStep("start", clock.Start); - AddStep("show bar", () => progress.AllowSeeking = true); + AddStep("show bar", () => progress.AllowSeeking.Value = true); AddStep("hide graph", () => progress.CollapseGraph.Value = true); - AddStep("hide Bar", () => progress.AllowSeeking = false); - AddStep("show bar", () => progress.AllowSeeking = true); + AddStep("hide Bar", () => progress.AllowSeeking.Value = false); + AddStep("show bar", () => progress.AllowSeeking.Value = true); AddStep("show graph", () => progress.CollapseGraph.Value = false); AddStep("stop", clock.Stop); } diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 9ebfeb5c82..9d1978e4cd 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -20,6 +20,7 @@ namespace osu.Game.Screens.Play { public class SongProgress : OverlayContainer { + private const int info_height = 20; private const int bottom_bar_height = 5; private const float graph_height = SquareGraph.Column.WIDTH * 6; private static readonly Vector2 handle_size = new Vector2(10, 18); @@ -31,10 +32,19 @@ namespace osu.Game.Screens.Play private readonly SongProgressInfo info; public Action RequestSeek; + + /// + /// Whether seeking is allowed and the progress bar should be shown. + /// + public readonly Bindable AllowSeeking = new Bindable(); + + /// + /// Whether the difficulty graph should be shown. + /// public readonly Bindable CollapseGraph = new Bindable(); - public override bool HandleNonPositionalInput => AllowSeeking; - public override bool HandlePositionalInput => AllowSeeking; + public override bool HandleNonPositionalInput => AllowSeeking.Value; + public override bool HandlePositionalInput => AllowSeeking.Value; private double firstHitTime => objects.First().StartTime; private double lastHitTime => ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1; @@ -55,22 +65,6 @@ namespace osu.Game.Screens.Play } } - private bool allowSeeking; - - public bool AllowSeeking - { - get => allowSeeking; - set - { - if (allowSeeking == value) return; - - allowSeeking = value; - updateBarVisibility(); - } - } - - private readonly BindableBool replayLoaded = new BindableBool(); - public IClock ReferenceClock; private IClock gameplayClock; @@ -78,7 +72,7 @@ namespace osu.Game.Screens.Play public SongProgress() { Masking = true; - Height = bottom_bar_height + graph_height + handle_size.Y + OsuFont.Numeric.Size; + Height = bottom_bar_height + graph_height + handle_size.Y + info_height; Children = new Drawable[] { @@ -87,7 +81,7 @@ namespace osu.Game.Screens.Play Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, + Height = info_height, }, graph = new SongProgressGraph { @@ -122,18 +116,17 @@ namespace osu.Game.Screens.Play { Show(); - replayLoaded.BindValueChanged(loaded => AllowSeeking = loaded.NewValue, true); + AllowSeeking.BindValueChanged(_ => updateBarVisibility(), true); CollapseGraph.BindValueChanged(_ => updateGraphVisibility(), true); } public void BindDrawableRuleset(DrawableRuleset drawableRuleset) { - replayLoaded.BindTo(drawableRuleset.HasReplayLoaded); + AllowSeeking.BindTo(drawableRuleset.HasReplayLoaded); } protected override void PopIn() { - updateBarVisibility(); this.FadeIn(500, Easing.OutQuint); } @@ -160,8 +153,8 @@ namespace osu.Game.Screens.Play private void updateBarVisibility() { - bar.FadeTo(allowSeeking ? 1 : 0, transition_duration, Easing.In); - this.MoveTo(new Vector2(0, allowSeeking ? 0 : bottom_bar_height), transition_duration, Easing.In); + bar.FadeTo(AllowSeeking.Value ? 1 : 0, transition_duration, Easing.In); + this.MoveTo(new Vector2(0, AllowSeeking.Value ? 0 : bottom_bar_height), transition_duration, Easing.In); updateInfoMargin(); } @@ -178,7 +171,7 @@ namespace osu.Game.Screens.Play private void updateInfoMargin() { - float finalMargin = bottom_bar_height + (allowSeeking ? handle_size.Y : 0) + (CollapseGraph.Value ? 0 : graph_height); + float finalMargin = bottom_bar_height + (AllowSeeking.Value ? handle_size.Y : 0) + (CollapseGraph.Value ? 0 : graph_height); info.TransformTo(nameof(info.Margin), new MarginPadding { Bottom = finalMargin }, transition_duration, Easing.In); } } From 2d5fd7f1c4fc789daabbebd0dad891ed3033a8f2 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 5 Jul 2019 08:49:56 +0200 Subject: [PATCH 009/203] remove unnecessarily setting value of bindable that was already bound to --- osu.Game/Screens/Play/HUDOverlay.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index 017bf70133..e0036cdeb9 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -106,7 +106,6 @@ namespace osu.Game.Screens.Play BindDrawableRuleset(drawableRuleset); Progress.Objects = drawableRuleset.Objects; - Progress.AllowSeeking = drawableRuleset.HasReplayLoaded.Value; Progress.RequestSeek = time => RequestSeek(time); Progress.ReferenceClock = drawableRuleset.FrameStableClock; From ee44caf964c59439449e8d65dfa4bf73ea9fb887 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 5 Jul 2019 08:52:44 +0200 Subject: [PATCH 010/203] better setting description --- osu.Game/Configuration/OsuConfigManager.cs | 4 ++-- .../Overlays/Settings/Sections/Gameplay/GeneralSettings.cs | 4 ++-- osu.Game/Screens/Play/SongProgress.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index f3792fcb7f..c055d7d321 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -77,7 +77,7 @@ namespace osu.Game.Configuration Set(OsuSetting.BlurLevel, 0, 0, 1, 0.01); Set(OsuSetting.ShowInterface, true); - Set(OsuSetting.CollapseProgressGraph, false); + Set(OsuSetting.ShowProgressGraph, true); Set(OsuSetting.KeyOverlay, false); Set(OsuSetting.FloatingComments, false); @@ -132,7 +132,7 @@ namespace osu.Game.Configuration KeyOverlay, FloatingComments, ShowInterface, - CollapseProgressGraph, + ShowProgressGraph, MouseDisableButtons, MouseDisableWheel, AudioOffset, diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs index e365973c4b..2169fc69cc 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs @@ -36,8 +36,8 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay }, new SettingsCheckbox { - LabelText = "Collapse song progress graph", - Bindable = config.GetBindable(OsuSetting.CollapseProgressGraph) + LabelText = "Show difficulty graph on progress bar", + Bindable = config.GetBindable(OsuSetting.ShowProgressGraph) }, new SettingsCheckbox { diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 9d1978e4cd..7411afb688 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -107,7 +107,7 @@ namespace osu.Game.Screens.Play if (clock != null) gameplayClock = clock; - config.BindWith(OsuSetting.CollapseProgressGraph, CollapseGraph); + config.BindWith(OsuSetting.ShowProgressGraph, CollapseGraph); graph.FillColour = bar.FillColour = colours.BlueLighter; } From d05512a12a3d7c41f8276473d0fb08c31e2ba092 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 5 Jul 2019 09:16:50 +0200 Subject: [PATCH 011/203] invert usage corresponding to previous description change --- .../Visual/Gameplay/TestSceneSongProgress.cs | 4 ++-- osu.Game/Screens/Play/SongProgress.cs | 15 ++++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs index e16ad42558..15bf907b4f 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSongProgress.cs @@ -112,10 +112,10 @@ namespace osu.Game.Tests.Visual.Gameplay AddUntilStep("wait for graph", () => graph.CreationCount == 1); AddStep("start", clock.Start); AddStep("show bar", () => progress.AllowSeeking.Value = true); - AddStep("hide graph", () => progress.CollapseGraph.Value = true); + AddStep("hide graph", () => progress.ShowGraph.Value = false); AddStep("hide Bar", () => progress.AllowSeeking.Value = false); AddStep("show bar", () => progress.AllowSeeking.Value = true); - AddStep("show graph", () => progress.CollapseGraph.Value = false); + AddStep("show graph", () => progress.ShowGraph.Value = true); AddStep("stop", clock.Stop); } diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 7411afb688..727fad84c9 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -38,10 +38,7 @@ namespace osu.Game.Screens.Play /// public readonly Bindable AllowSeeking = new Bindable(); - /// - /// Whether the difficulty graph should be shown. - /// - public readonly Bindable CollapseGraph = new Bindable(); + public readonly Bindable ShowGraph = new Bindable(); public override bool HandleNonPositionalInput => AllowSeeking.Value; public override bool HandlePositionalInput => AllowSeeking.Value; @@ -107,7 +104,7 @@ namespace osu.Game.Screens.Play if (clock != null) gameplayClock = clock; - config.BindWith(OsuSetting.ShowProgressGraph, CollapseGraph); + config.BindWith(OsuSetting.ShowProgressGraph, ShowGraph); graph.FillColour = bar.FillColour = colours.BlueLighter; } @@ -117,7 +114,7 @@ namespace osu.Game.Screens.Play Show(); AllowSeeking.BindValueChanged(_ => updateBarVisibility(), true); - CollapseGraph.BindValueChanged(_ => updateGraphVisibility(), true); + ShowGraph.BindValueChanged(_ => updateGraphVisibility(), true); } public void BindDrawableRuleset(DrawableRuleset drawableRuleset) @@ -163,15 +160,15 @@ namespace osu.Game.Screens.Play { float barHeight = bottom_bar_height + handle_size.Y; - bar.ResizeHeightTo(CollapseGraph.Value ? barHeight : barHeight + graph_height, transition_duration, Easing.In); - graph.MoveToY(CollapseGraph.Value ? bottom_bar_height + graph_height : 0, transition_duration, Easing.In); + bar.ResizeHeightTo(ShowGraph.Value ? barHeight + graph_height : barHeight, transition_duration, Easing.In); + graph.MoveToY(ShowGraph.Value ? 0 : bottom_bar_height + graph_height, transition_duration, Easing.In); updateInfoMargin(); } private void updateInfoMargin() { - float finalMargin = bottom_bar_height + (AllowSeeking.Value ? handle_size.Y : 0) + (CollapseGraph.Value ? 0 : graph_height); + float finalMargin = bottom_bar_height + (AllowSeeking.Value ? handle_size.Y : 0) + (ShowGraph.Value ? graph_height : 0); info.TransformTo(nameof(info.Margin), new MarginPadding { Bottom = finalMargin }, transition_duration, Easing.In); } } From 54a8c00bb854c8bf70cd077302cd6fbba240504a Mon Sep 17 00:00:00 2001 From: Shane Woolcock Date: Thu, 28 Nov 2019 17:09:54 +1030 Subject: [PATCH 012/203] Add support for --sdl command line arg --- .../.idea/runConfigurations/osu_SDL.xml | 20 +++++++++++++++++++ osu.Desktop/Program.cs | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 .idea/.idea.osu.Desktop/.idea/runConfigurations/osu_SDL.xml diff --git a/.idea/.idea.osu.Desktop/.idea/runConfigurations/osu_SDL.xml b/.idea/.idea.osu.Desktop/.idea/runConfigurations/osu_SDL.xml new file mode 100644 index 0000000000..1fd10e0e1a --- /dev/null +++ b/.idea/.idea.osu.Desktop/.idea/runConfigurations/osu_SDL.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs index 141b2cdbbc..bd91bcc933 100644 --- a/osu.Desktop/Program.cs +++ b/osu.Desktop/Program.cs @@ -22,8 +22,9 @@ namespace osu.Desktop { // Back up the cwd before DesktopGameHost changes it var cwd = Environment.CurrentDirectory; + bool useSdl = args.Contains("--sdl"); - using (DesktopGameHost host = Host.GetSuitableHost(@"osu", true)) + using (DesktopGameHost host = Host.GetSuitableHost(@"osu", true, useSdl: useSdl)) { host.ExceptionThrown += handleException; From c69e88eb97b90c73b3e2dcd2bebe18c8aa4b8540 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 21 Dec 2019 13:32:25 +0300 Subject: [PATCH 013/203] Add more types to dropdown --- osu.Game/Configuration/ScoreMeterType.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/osu.Game/Configuration/ScoreMeterType.cs b/osu.Game/Configuration/ScoreMeterType.cs index b85ef9309d..156c4b1377 100644 --- a/osu.Game/Configuration/ScoreMeterType.cs +++ b/osu.Game/Configuration/ScoreMeterType.cs @@ -18,5 +18,14 @@ namespace osu.Game.Configuration [Description("Hit Error (both)")] HitErrorBoth, + + [Description("Colour (left)")] + ColourLeft, + + [Description("Colour (right)")] + ColourRight, + + [Description("Colour (both)")] + ColourBoth, } } From 5b115d8d8a94fff0f265d8a5aba113c0c1b1ad53 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 21 Dec 2019 13:41:50 +0300 Subject: [PATCH 014/203] Implement basic logic --- osu.Game/Screens/Play/HUD/HitErrorDisplay.cs | 31 +++++++++++++++++ .../HUD/HitErrorMeters/ColourHitErrorMeter.cs | 33 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs diff --git a/osu.Game/Screens/Play/HUD/HitErrorDisplay.cs b/osu.Game/Screens/Play/HUD/HitErrorDisplay.cs index 6196ce4026..4d28f00f39 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorDisplay.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorDisplay.cs @@ -77,6 +77,19 @@ namespace osu.Game.Screens.Play.HUD case ScoreMeterType.HitErrorRight: createBar(true); break; + + case ScoreMeterType.ColourBoth: + createColour(false); + createColour(true); + break; + + case ScoreMeterType.ColourLeft: + createColour(false); + break; + + case ScoreMeterType.ColourRight: + createColour(true); + break; } } @@ -90,6 +103,24 @@ namespace osu.Game.Screens.Play.HUD Alpha = 0, }; + completeDisplayLoading(display); + } + + private void createColour(bool rightAligned) + { + var display = new ColourHitErrorMeter(hitWindows) + { + Margin = new MarginPadding(margin), + Anchor = rightAligned ? Anchor.CentreRight : Anchor.CentreLeft, + Origin = rightAligned ? Anchor.CentreRight : Anchor.CentreLeft, + Alpha = 0, + }; + + completeDisplayLoading(display); + } + + private void completeDisplayLoading(HitErrorMeter display) + { Add(display); display.FadeInFromZero(fade_duration, Easing.OutQuint); } diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs new file mode 100644 index 0000000000..95d4940b17 --- /dev/null +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -0,0 +1,33 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Scoring; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Screens.Play.HUD.HitErrorMeters +{ + public class ColourHitErrorMeter : HitErrorMeter + { + public ColourHitErrorMeter(HitWindows hitWindows) + : base(hitWindows) + { + + } + + public override void OnNewJudgement(JudgementResult judgement) + { + throw new System.NotImplementedException(); + } + } +} From 5e3c3f2a90190b9a785800627b44e4af136d6dba Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 21 Dec 2019 14:30:41 +0300 Subject: [PATCH 015/203] Make judgements work --- .../HUD/HitErrorMeters/ColourHitErrorMeter.cs | 70 +++++++++++++++++-- 1 file changed, 63 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs index 95d4940b17..41401a0048 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -1,33 +1,89 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Scoring; using osuTK; -using osuTK.Graphics; namespace osu.Game.Screens.Play.HUD.HitErrorMeters { public class ColourHitErrorMeter : HitErrorMeter { + private const int bar_height = 200; + + private readonly FillFlowContainer judgementsFlow; + public ColourHitErrorMeter(HitWindows hitWindows) : base(hitWindows) { - + AutoSizeAxes = Axes.Both; + InternalChild = judgementsFlow = new FillFlowContainer + { + AutoSizeAxes = Axes.X, + Height = bar_height, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 2), + Masking = true, + }; } public override void OnNewJudgement(JudgementResult judgement) { - throw new System.NotImplementedException(); + judgementsFlow.Add(new DrawableJudgement(HitWindows.ResultFor(judgement.TimeOffset))); + } + + private class DrawableJudgement : CircularContainer + { + private readonly Box background; + private readonly HitResult result; + + public DrawableJudgement(HitResult result) + { + this.result = result; + + Masking = true; + Size = new Vector2(8); + Child = background = new Box + { + RelativeSizeAxes = Axes.Both, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + switch (result) + { + case HitResult.Miss: + background.Colour = colours.Red; + break; + + case HitResult.Meh: + background.Colour = colours.Yellow; + break; + + case HitResult.Ok: + background.Colour = colours.Green; + break; + + case HitResult.Good: + background.Colour = colours.GreenLight; + break; + + case HitResult.Great: + background.Colour = colours.Blue; + break; + + default: + background.Colour = colours.BlueLight; + break; + } + } } } } From 5af126009488554a4322fa292c24e39f8ef0f898 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 21 Dec 2019 14:30:49 +0300 Subject: [PATCH 016/203] Improve testing --- ...rrorMeter.cs => TestSceneHitErrorMeter.cs} | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) rename osu.Game.Tests/Visual/Gameplay/{TestSceneBarHitErrorMeter.cs => TestSceneHitErrorMeter.cs} (75%) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneBarHitErrorMeter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs similarity index 75% rename from osu.Game.Tests/Visual/Gameplay/TestSceneBarHitErrorMeter.cs rename to osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs index e3688c276f..b208a2e0e7 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneBarHitErrorMeter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs @@ -19,18 +19,22 @@ using osu.Game.Screens.Play.HUD.HitErrorMeters; namespace osu.Game.Tests.Visual.Gameplay { - public class TestSceneBarHitErrorMeter : OsuTestScene + public class TestSceneHitErrorMeter : OsuTestScene { public override IReadOnlyList RequiredTypes => new[] { typeof(HitErrorMeter), + typeof(BarHitErrorMeter), + typeof(ColourHitErrorMeter) }; - private HitErrorMeter meter; - private HitErrorMeter meter2; + private BarHitErrorMeter barMeter; + private BarHitErrorMeter barMeter2; + private ColourHitErrorMeter colourMeter; + private ColourHitErrorMeter colourMeter2; private HitWindows hitWindows; - public TestSceneBarHitErrorMeter() + public TestSceneHitErrorMeter() { recreateDisplay(new OsuHitWindows(), 5); @@ -91,17 +95,31 @@ namespace osu.Game.Tests.Visual.Gameplay } }); - Add(meter = new BarHitErrorMeter(hitWindows, true) + Add(barMeter = new BarHitErrorMeter(hitWindows, true) { Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, }); - Add(meter2 = new BarHitErrorMeter(hitWindows, false) + Add(barMeter2 = new BarHitErrorMeter(hitWindows, false) { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, }); + + Add(colourMeter = new ColourHitErrorMeter(hitWindows) + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Margin = new MarginPadding { Right = 50 } + }); + + Add(colourMeter2 = new ColourHitErrorMeter(hitWindows) + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Margin = new MarginPadding { Left = 50 } + }); } private void newJudgement(double offset = 0) @@ -112,8 +130,10 @@ namespace osu.Game.Tests.Visual.Gameplay Type = HitResult.Perfect, }; - meter.OnNewJudgement(judgement); - meter2.OnNewJudgement(judgement); + barMeter.OnNewJudgement(judgement); + barMeter2.OnNewJudgement(judgement); + colourMeter.OnNewJudgement(judgement); + colourMeter2.OnNewJudgement(judgement); } } } From b61aa660c63f0e126f32643ef17e7bb458d2a1ae Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 21 Dec 2019 14:52:53 +0300 Subject: [PATCH 017/203] Move colours to HitErrorMeter class --- .../HUD/HitErrorMeters/BarHitErrorMeter.cs | 25 +--------- .../HUD/HitErrorMeters/ColourHitErrorMeter.cs | 46 ++----------------- .../Play/HUD/HitErrorMeters/HitErrorMeter.cs | 30 ++++++++++++ 3 files changed, 37 insertions(+), 64 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/BarHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/BarHitErrorMeter.cs index 03a0f23fb6..208bdd17ad 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/BarHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/BarHitErrorMeter.cs @@ -163,30 +163,9 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters centre.Width = 2.5f; colourBars.Add(centre); - Color4 getColour(HitResult result) - { - switch (result) - { - case HitResult.Meh: - return colours.Yellow; - - case HitResult.Ok: - return colours.Green; - - case HitResult.Good: - return colours.GreenLight; - - case HitResult.Great: - return colours.Blue; - - default: - return colours.BlueLight; - } - } - Drawable createColourBar(HitResult result, float height, bool first = false) { - var colour = getColour(result); + var colour = GetColourForHitResult(result); if (first) { @@ -201,7 +180,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters new Box { RelativeSizeAxes = Axes.Both, - Colour = getColour(result), + Colour = colour, Height = height * gradient_start }, new Box diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs index 41401a0048..6775b98f84 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -1,14 +1,13 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Scoring; using osuTK; +using osuTK.Graphics; namespace osu.Game.Screens.Play.HUD.HitErrorMeters { @@ -34,56 +33,21 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters public override void OnNewJudgement(JudgementResult judgement) { - judgementsFlow.Add(new DrawableJudgement(HitWindows.ResultFor(judgement.TimeOffset))); + judgementsFlow.Add(new DrawableJudgement(GetColourForHitResult(HitWindows.ResultFor(judgement.TimeOffset)))); } private class DrawableJudgement : CircularContainer { - private readonly Box background; - private readonly HitResult result; - - public DrawableJudgement(HitResult result) + public DrawableJudgement(Color4 colour) { - this.result = result; - Masking = true; Size = new Vector2(8); - Child = background = new Box + Child = new Box { RelativeSizeAxes = Axes.Both, + Colour = colour }; } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - switch (result) - { - case HitResult.Miss: - background.Colour = colours.Red; - break; - - case HitResult.Meh: - background.Colour = colours.Yellow; - break; - - case HitResult.Ok: - background.Colour = colours.Green; - break; - - case HitResult.Good: - background.Colour = colours.GreenLight; - break; - - case HitResult.Great: - background.Colour = colours.Blue; - break; - - default: - background.Colour = colours.BlueLight; - break; - } - } } } } diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs index dee25048ed..b3edfdedec 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs @@ -1,9 +1,12 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Allocation; using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Scoring; +using osuTK.Graphics; namespace osu.Game.Screens.Play.HUD.HitErrorMeters { @@ -11,11 +14,38 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters { protected readonly HitWindows HitWindows; + [Resolved] + private OsuColour colours { get; set; } + protected HitErrorMeter(HitWindows hitWindows) { HitWindows = hitWindows; } public abstract void OnNewJudgement(JudgementResult judgement); + + protected Color4 GetColourForHitResult(HitResult result) + { + switch (result) + { + case HitResult.Miss: + return colours.Red; + + case HitResult.Meh: + return colours.Yellow; + + case HitResult.Ok: + return colours.Green; + + case HitResult.Good: + return colours.GreenLight; + + case HitResult.Great: + return colours.Blue; + + default: + return colours.BlueLight; + } + } } } From 14a77a8f16d849483a59c68cf726e7784966052a Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 21 Dec 2019 16:08:28 +0300 Subject: [PATCH 018/203] Improve animations --- .../HUD/HitErrorMeters/ColourHitErrorMeter.cs | 83 +++++++++++++++---- 1 file changed, 69 insertions(+), 14 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs index 6775b98f84..649f29810e 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -1,6 +1,10 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Bindables; +using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -13,35 +17,86 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters { public class ColourHitErrorMeter : HitErrorMeter { - private const int bar_height = 200; + private const int max_available_judgements = 20; - private readonly FillFlowContainer judgementsFlow; + private readonly JudgementFlow judgementsFlow; + private readonly BindableList<(Color4 colour, JudgementResult result)> judgements = new BindableList<(Color4 colour, JudgementResult result)>(); public ColourHitErrorMeter(HitWindows hitWindows) : base(hitWindows) { AutoSizeAxes = Axes.Both; - InternalChild = judgementsFlow = new FillFlowContainer - { - AutoSizeAxes = Axes.X, - Height = bar_height, - Direction = FillDirection.Vertical, - Spacing = new Vector2(0, 2), - Masking = true, - }; + InternalChild = judgementsFlow = new JudgementFlow(); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + judgementsFlow.Judgements.BindTo(judgements); } public override void OnNewJudgement(JudgementResult judgement) { - judgementsFlow.Add(new DrawableJudgement(GetColourForHitResult(HitWindows.ResultFor(judgement.TimeOffset)))); + judgements.Add((GetColourForHitResult(HitWindows.ResultFor(judgement.TimeOffset)), judgement)); + + if (judgements.Count > max_available_judgements) + judgements.RemoveAt(0); } - private class DrawableJudgement : CircularContainer + private class JudgementFlow : Container { - public DrawableJudgement(Color4 colour) + private const int drawable_judgement_size = 8; + private const int spacing = 2; + private const int animation_duration = 200; + + public readonly BindableList<(Color4 colour, JudgementResult result)> Judgements = new BindableList<(Color4 colour, JudgementResult result)>(); + + public JudgementFlow() { + AutoSizeAxes = Axes.X; + Height = max_available_judgements * (drawable_judgement_size + spacing); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + Judgements.ItemsAdded += push; + Judgements.ItemsRemoved += pop; + } + + private void push(IEnumerable<(Color4 colour, JudgementResult result)> judgements) + { + Children.ForEach(c => c.FinishTransforms()); + + var (colour, result) = judgements.Single(); + var drawableJudgement = new DrawableResult(colour, result, drawable_judgement_size) + { + Alpha = 0, + Y = -(drawable_judgement_size + spacing) + }; + + Add(drawableJudgement); + drawableJudgement.FadeInFromZero(animation_duration, Easing.OutQuint); + + Children.ForEach(c => c.MoveToOffset(new Vector2(0, drawable_judgement_size + spacing), animation_duration, Easing.OutQuint)); + } + + private void pop(IEnumerable<(Color4 colour, JudgementResult result)> judgements) + { + Children.FirstOrDefault(c => c.Result == judgements.Single().result).FadeOut(animation_duration, Easing.OutQuint).Expire(); + } + } + + private class DrawableResult : CircularContainer + { + public JudgementResult Result { get; private set; } + + public DrawableResult(Color4 colour, JudgementResult result, int size) + { + Result = result; + Masking = true; - Size = new Vector2(8); + Size = new Vector2(size); Child = new Box { RelativeSizeAxes = Axes.Both, From 46501cf0ac2984537d8a96b885fc87804d4ece15 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 22 Dec 2019 03:06:57 +0300 Subject: [PATCH 019/203] Use FillFlowContainer --- .../HUD/HitErrorMeters/ColourHitErrorMeter.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs index 649f29810e..d730a8d321 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Bindables; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -43,7 +42,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters judgements.RemoveAt(0); } - private class JudgementFlow : Container + private class JudgementFlow : FillFlowContainer { private const int drawable_judgement_size = 8; private const int spacing = 2; @@ -51,10 +50,16 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters public readonly BindableList<(Color4 colour, JudgementResult result)> Judgements = new BindableList<(Color4 colour, JudgementResult result)>(); + private int runningDepth; + public JudgementFlow() { AutoSizeAxes = Axes.X; Height = max_available_judgements * (drawable_judgement_size + spacing); + Spacing = new Vector2(0, spacing); + Direction = FillDirection.Vertical; + LayoutDuration = animation_duration; + LayoutEasing = Easing.OutQuint; } protected override void LoadComplete() @@ -66,24 +71,20 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters private void push(IEnumerable<(Color4 colour, JudgementResult result)> judgements) { - Children.ForEach(c => c.FinishTransforms()); - var (colour, result) = judgements.Single(); var drawableJudgement = new DrawableResult(colour, result, drawable_judgement_size) { Alpha = 0, - Y = -(drawable_judgement_size + spacing) }; - Add(drawableJudgement); + Insert(runningDepth--, drawableJudgement); drawableJudgement.FadeInFromZero(animation_duration, Easing.OutQuint); - - Children.ForEach(c => c.MoveToOffset(new Vector2(0, drawable_judgement_size + spacing), animation_duration, Easing.OutQuint)); } private void pop(IEnumerable<(Color4 colour, JudgementResult result)> judgements) { - Children.FirstOrDefault(c => c.Result == judgements.Single().result).FadeOut(animation_duration, Easing.OutQuint).Expire(); + var (colour, result) = judgements.Single(); + Children.FirstOrDefault(c => c.Result == result).FadeOut(animation_duration, Easing.OutQuint).Expire(); } } From eb75c6c70f342ff84d50b038af92e6873f1d080c Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 22 Dec 2019 03:17:56 +0300 Subject: [PATCH 020/203] Update FadeIn animation for new judgement --- .../HUD/HitErrorMeters/ColourHitErrorMeter.cs | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs index d730a8d321..b76f2c7817 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -17,6 +17,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters public class ColourHitErrorMeter : HitErrorMeter { private const int max_available_judgements = 20; + private const int animation_duration = 200; private readonly JudgementFlow judgementsFlow; private readonly BindableList<(Color4 colour, JudgementResult result)> judgements = new BindableList<(Color4 colour, JudgementResult result)>(); @@ -46,7 +47,6 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters { private const int drawable_judgement_size = 8; private const int spacing = 2; - private const int animation_duration = 200; public readonly BindableList<(Color4 colour, JudgementResult result)> Judgements = new BindableList<(Color4 colour, JudgementResult result)>(); @@ -72,13 +72,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters private void push(IEnumerable<(Color4 colour, JudgementResult result)> judgements) { var (colour, result) = judgements.Single(); - var drawableJudgement = new DrawableResult(colour, result, drawable_judgement_size) - { - Alpha = 0, - }; - - Insert(runningDepth--, drawableJudgement); - drawableJudgement.FadeInFromZero(animation_duration, Easing.OutQuint); + Insert(runningDepth--, new DrawableResult(colour, result, drawable_judgement_size)); } private void pop(IEnumerable<(Color4 colour, JudgementResult result)> judgements) @@ -88,22 +82,37 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters } } - private class DrawableResult : CircularContainer + private class DrawableResult : Container { public JudgementResult Result { get; private set; } + private readonly CircularContainer content; + public DrawableResult(Color4 colour, JudgementResult result, int size) { Result = result; - Masking = true; Size = new Vector2(size); - Child = new Box + Child = content = new CircularContainer { RelativeSizeAxes = Axes.Both, - Colour = colour + Masking = true, + Alpha = 0, + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colour + }, }; } + + protected override void LoadComplete() + { + base.LoadComplete(); + content.FadeInFromZero(animation_duration, Easing.OutQuint); + content.MoveToY(-DrawSize.Y); + content.MoveToY(0, animation_duration, Easing.OutQuint); + } } } } From aded12af9e157ea0535dfbf8da48ed7fe3a8c2f0 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 22 Dec 2019 03:30:17 +0300 Subject: [PATCH 021/203] Refactoor to avoid bindable usage --- .../HUD/HitErrorMeters/ColourHitErrorMeter.cs | 54 ++++++------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs index b76f2c7817..196eb23da6 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -1,9 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Collections.Generic; using System.Linq; -using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -16,11 +14,9 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters { public class ColourHitErrorMeter : HitErrorMeter { - private const int max_available_judgements = 20; private const int animation_duration = 200; private readonly JudgementFlow judgementsFlow; - private readonly BindableList<(Color4 colour, JudgementResult result)> judgements = new BindableList<(Color4 colour, JudgementResult result)>(); public ColourHitErrorMeter(HitWindows hitWindows) : base(hitWindows) @@ -29,69 +25,43 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters InternalChild = judgementsFlow = new JudgementFlow(); } - protected override void LoadComplete() - { - base.LoadComplete(); - judgementsFlow.Judgements.BindTo(judgements); - } - - public override void OnNewJudgement(JudgementResult judgement) - { - judgements.Add((GetColourForHitResult(HitWindows.ResultFor(judgement.TimeOffset)), judgement)); - - if (judgements.Count > max_available_judgements) - judgements.RemoveAt(0); - } + public override void OnNewJudgement(JudgementResult judgement) => judgementsFlow.Push(GetColourForHitResult(HitWindows.ResultFor(judgement.TimeOffset))); private class JudgementFlow : FillFlowContainer { + private const int max_available_judgements = 20; private const int drawable_judgement_size = 8; private const int spacing = 2; - public readonly BindableList<(Color4 colour, JudgementResult result)> Judgements = new BindableList<(Color4 colour, JudgementResult result)>(); - private int runningDepth; public JudgementFlow() { AutoSizeAxes = Axes.X; - Height = max_available_judgements * (drawable_judgement_size + spacing); + Height = max_available_judgements * (drawable_judgement_size + spacing) - spacing; Spacing = new Vector2(0, spacing); Direction = FillDirection.Vertical; LayoutDuration = animation_duration; LayoutEasing = Easing.OutQuint; } - protected override void LoadComplete() + public void Push(Color4 colour) { - base.LoadComplete(); - Judgements.ItemsAdded += push; - Judgements.ItemsRemoved += pop; - } + Insert(runningDepth--, new DrawableResult(colour, drawable_judgement_size)); - private void push(IEnumerable<(Color4 colour, JudgementResult result)> judgements) - { - var (colour, result) = judgements.Single(); - Insert(runningDepth--, new DrawableResult(colour, result, drawable_judgement_size)); - } - - private void pop(IEnumerable<(Color4 colour, JudgementResult result)> judgements) - { - var (colour, result) = judgements.Single(); - Children.FirstOrDefault(c => c.Result == result).FadeOut(animation_duration, Easing.OutQuint).Expire(); + if (Children.Count > max_available_judgements) + Children.FirstOrDefault(c => !c.IsRemoved).Remove(); } } private class DrawableResult : Container { - public JudgementResult Result { get; private set; } + public bool IsRemoved { get; private set; } private readonly CircularContainer content; - public DrawableResult(Color4 colour, JudgementResult result, int size) + public DrawableResult(Color4 colour, int size) { - Result = result; - Size = new Vector2(size); Child = content = new CircularContainer { @@ -113,6 +83,12 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters content.MoveToY(-DrawSize.Y); content.MoveToY(0, animation_duration, Easing.OutQuint); } + + public void Remove() + { + IsRemoved = true; + this.FadeOut(animation_duration, Easing.OutQuint).Expire(); + } } } } From 7a0d76ae77e5b830f158dcde6bfdb80797165e70 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 22 Dec 2019 03:41:19 +0300 Subject: [PATCH 022/203] Fix nullref --- osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs index 196eb23da6..d18f6f3743 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -50,7 +50,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters Insert(runningDepth--, new DrawableResult(colour, drawable_judgement_size)); if (Children.Count > max_available_judgements) - Children.FirstOrDefault(c => !c.IsRemoved).Remove(); + Children.FirstOrDefault(c => !c.IsRemoved)?.Remove(); } } From 2c1a65d90acfa70f206cf46a00b26da5d93111c8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 26 Dec 2019 19:37:55 +0900 Subject: [PATCH 023/203] Add simple test --- .../Editor/TestSceneBlueprintContainer.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 osu.Game.Tests/Editor/TestSceneBlueprintContainer.cs diff --git a/osu.Game.Tests/Editor/TestSceneBlueprintContainer.cs b/osu.Game.Tests/Editor/TestSceneBlueprintContainer.cs new file mode 100644 index 0000000000..5ccce5b3c6 --- /dev/null +++ b/osu.Game.Tests/Editor/TestSceneBlueprintContainer.cs @@ -0,0 +1,20 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; +using osu.Game.Screens.Edit.Compose.Components; +using osu.Game.Tests.Visual; + +namespace osu.Game.Tests.Editor +{ + public class TestSceneBlueprintContainer : EditorClockTestScene + { + private BlueprintContainer blueprintContainer; + + [SetUp] + public void Setup() => Schedule(() => + { + Child = blueprintContainer = new BlueprintContainer(); + }); + } +} From ee332e0d424b0a8a76efc28b413208e14f8b1f6e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 2 Jan 2020 11:46:18 +0900 Subject: [PATCH 024/203] Split out BlueprintContainer functionality further --- .../Edit/ManiaBlueprintContainer.cs | 28 +++++++++++++++ .../Edit/ManiaHitObjectComposer.cs | 21 ++--------- .../Edit/OsuBlueprintContainer.cs | 35 +++++++++++++++++++ .../Edit/OsuHitObjectComposer.cs | 24 +------------ .../Editor/TestSceneBlueprintContainer.cs | 4 +-- osu.Game/Rulesets/Edit/HitObjectComposer.cs | 15 ++------ .../Compose/Components/BlueprintContainer.cs | 23 +++++++++--- .../Components/ComposeBlueprintContainer.cs | 12 +++++++ 8 files changed, 101 insertions(+), 61 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/Edit/ManiaBlueprintContainer.cs create mode 100644 osu.Game.Rulesets.Osu/Edit/OsuBlueprintContainer.cs create mode 100644 osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs diff --git a/osu.Game.Rulesets.Mania/Edit/ManiaBlueprintContainer.cs b/osu.Game.Rulesets.Mania/Edit/ManiaBlueprintContainer.cs new file mode 100644 index 0000000000..9cb4e54234 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Edit/ManiaBlueprintContainer.cs @@ -0,0 +1,28 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Mania.Edit.Blueprints; +using osu.Game.Rulesets.Mania.Objects.Drawables; +using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Screens.Edit.Compose.Components; + +namespace osu.Game.Rulesets.Mania.Edit +{ + public class ManiaBlueprintContainer : ComposeBlueprintContainer + { + public override SelectionBlueprint CreateBlueprintFor(DrawableHitObject hitObject) + { + switch (hitObject) + { + case DrawableNote note: + return new NoteSelectionBlueprint(note); + + case DrawableHoldNote holdNote: + return new HoldNoteSelectionBlueprint(holdNote); + } + + return base.CreateBlueprintFor(hitObject); + } + } +} diff --git a/osu.Game.Rulesets.Mania/Edit/ManiaHitObjectComposer.cs b/osu.Game.Rulesets.Mania/Edit/ManiaHitObjectComposer.cs index 1632b6a583..824c92184a 100644 --- a/osu.Game.Rulesets.Mania/Edit/ManiaHitObjectComposer.cs +++ b/osu.Game.Rulesets.Mania/Edit/ManiaHitObjectComposer.cs @@ -5,11 +5,8 @@ using osu.Game.Beatmaps; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.Mania.Objects; -using osu.Game.Rulesets.Mania.Objects.Drawables; -using osu.Game.Rulesets.Objects.Drawables; using System.Collections.Generic; using osu.Framework.Allocation; -using osu.Game.Rulesets.Mania.Edit.Blueprints; using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.UI; @@ -52,26 +49,12 @@ namespace osu.Game.Rulesets.Mania.Edit return drawableRuleset; } + protected override ComposeBlueprintContainer CreateBlueprintContainer() => new ManiaBlueprintContainer(); + protected override IReadOnlyList CompositionTools => new HitObjectCompositionTool[] { new NoteCompositionTool(), new HoldNoteCompositionTool() }; - - public override SelectionHandler CreateSelectionHandler() => new ManiaSelectionHandler(); - - public override SelectionBlueprint CreateBlueprintFor(DrawableHitObject hitObject) - { - switch (hitObject) - { - case DrawableNote note: - return new NoteSelectionBlueprint(note); - - case DrawableHoldNote holdNote: - return new HoldNoteSelectionBlueprint(holdNote); - } - - return base.CreateBlueprintFor(hitObject); - } } } diff --git a/osu.Game.Rulesets.Osu/Edit/OsuBlueprintContainer.cs b/osu.Game.Rulesets.Osu/Edit/OsuBlueprintContainer.cs new file mode 100644 index 0000000000..a6a7d9bcc0 --- /dev/null +++ b/osu.Game.Rulesets.Osu/Edit/OsuBlueprintContainer.cs @@ -0,0 +1,35 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles; +using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders; +using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners; +using osu.Game.Rulesets.Osu.Objects.Drawables; +using osu.Game.Screens.Edit.Compose.Components; + +namespace osu.Game.Rulesets.Osu.Edit +{ + public class OsuBlueprintContainer : ComposeBlueprintContainer + { + public override SelectionHandler CreateSelectionHandler() => new OsuSelectionHandler(); + + public override SelectionBlueprint CreateBlueprintFor(DrawableHitObject hitObject) + { + switch (hitObject) + { + case DrawableHitCircle circle: + return new HitCircleSelectionBlueprint(circle); + + case DrawableSlider slider: + return new SliderSelectionBlueprint(slider); + + case DrawableSpinner spinner: + return new SpinnerSelectionBlueprint(spinner); + } + + return base.CreateBlueprintFor(hitObject); + } + } +} diff --git a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs index 49624ea733..28f7768aac 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs @@ -9,12 +9,7 @@ using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects; -using osu.Game.Rulesets.Objects.Drawables; -using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles; -using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders; -using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners; using osu.Game.Rulesets.Osu.Objects; -using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.UI; using osu.Game.Screens.Edit.Compose.Components; @@ -37,24 +32,7 @@ namespace osu.Game.Rulesets.Osu.Edit new SpinnerCompositionTool() }; - public override SelectionHandler CreateSelectionHandler() => new OsuSelectionHandler(); - - public override SelectionBlueprint CreateBlueprintFor(DrawableHitObject hitObject) - { - switch (hitObject) - { - case DrawableHitCircle circle: - return new HitCircleSelectionBlueprint(circle); - - case DrawableSlider slider: - return new SliderSelectionBlueprint(slider); - - case DrawableSpinner spinner: - return new SpinnerSelectionBlueprint(spinner); - } - - return base.CreateBlueprintFor(hitObject); - } + protected override ComposeBlueprintContainer CreateBlueprintContainer() => new OsuBlueprintContainer(); protected override DistanceSnapGrid CreateDistanceSnapGrid(IEnumerable selectedHitObjects) { diff --git a/osu.Game.Tests/Editor/TestSceneBlueprintContainer.cs b/osu.Game.Tests/Editor/TestSceneBlueprintContainer.cs index 5ccce5b3c6..67b0b61545 100644 --- a/osu.Game.Tests/Editor/TestSceneBlueprintContainer.cs +++ b/osu.Game.Tests/Editor/TestSceneBlueprintContainer.cs @@ -9,12 +9,10 @@ namespace osu.Game.Tests.Editor { public class TestSceneBlueprintContainer : EditorClockTestScene { - private BlueprintContainer blueprintContainer; - [SetUp] public void Setup() => Schedule(() => { - Child = blueprintContainer = new BlueprintContainer(); + Child = new ComposeBlueprintContainer(); }); } } diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index bfaa7e8872..536c7767b7 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -95,7 +95,7 @@ namespace osu.Game.Rulesets.Edit new EditorPlayfieldBorder { RelativeSizeAxes = Axes.Both } }); - var layerAboveRuleset = drawableRulesetWrapper.CreatePlayfieldAdjustmentContainer().WithChild(blueprintContainer = new BlueprintContainer()); + var layerAboveRuleset = drawableRulesetWrapper.CreatePlayfieldAdjustmentContainer().WithChild(blueprintContainer = CreateBlueprintContainer()); layerContainers.Add(layerBelowRuleset); layerContainers.Add(layerAboveRuleset); @@ -147,6 +147,8 @@ namespace osu.Game.Rulesets.Edit blueprintContainer.SelectionChanged += selectionChanged; } + protected abstract ComposeBlueprintContainer CreateBlueprintContainer(); + protected override void LoadComplete() { base.LoadComplete(); @@ -323,17 +325,6 @@ namespace osu.Game.Rulesets.Edit /// public abstract bool CursorInPlacementArea { get; } - /// - /// Creates a for a specific . - /// - /// The to create the overlay for. - public virtual SelectionBlueprint CreateBlueprintFor(DrawableHitObject hitObject) => null; - - /// - /// Creates a which outlines s and handles movement of selections. - /// - public virtual SelectionHandler CreateSelectionHandler() => new SelectionHandler(); - /// /// Creates the applicable for a selection. /// diff --git a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs index cafaddc39e..39ec42ba96 100644 --- a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs @@ -22,7 +22,11 @@ using osuTK.Input; namespace osu.Game.Screens.Edit.Compose.Components { - public class BlueprintContainer : CompositeDrawable, IKeyBindingHandler + /// + /// A container which provides a "blueprint" display of hitobjects. + /// Includes selection and manipulation support via a . + /// + public abstract class BlueprintContainer : CompositeDrawable, IKeyBindingHandler { public event Action> SelectionChanged; @@ -42,15 +46,26 @@ namespace osu.Game.Screens.Edit.Compose.Components [Resolved] private EditorBeatmap beatmap { get; set; } - public BlueprintContainer() + protected BlueprintContainer() { RelativeSizeAxes = Axes.Both; } + /// + /// Creates a which outlines s and handles movement of selections. + /// + public virtual SelectionHandler CreateSelectionHandler() => new SelectionHandler(); + + /// + /// Creates a for a specific . + /// + /// The to create the overlay for. + public virtual SelectionBlueprint CreateBlueprintFor(DrawableHitObject hitObject) => null; + [BackgroundDependencyLoader] private void load() { - selectionHandler = composer.CreateSelectionHandler(); + selectionHandler = CreateSelectionHandler(); selectionHandler.DeselectAll = deselectAll; InternalChildren = new[] @@ -259,7 +274,7 @@ namespace osu.Game.Screens.Edit.Compose.Components { refreshTool(); - var blueprint = composer.CreateBlueprintFor(hitObject); + var blueprint = CreateBlueprintFor(hitObject); if (blueprint == null) return; diff --git a/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs new file mode 100644 index 0000000000..9267006e4c --- /dev/null +++ b/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs @@ -0,0 +1,12 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +namespace osu.Game.Screens.Edit.Compose.Components +{ + /// + /// A blueprint container generally displayed as an overlay to a ruleset's playfield. + /// + public class ComposeBlueprintContainer : BlueprintContainer + { + } +} From d8d12cbbddfe864f96467e22a8b672f8ef4d22c6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 2 Jan 2020 19:09:37 +0900 Subject: [PATCH 025/203] wip: Move more functionality into ComposeBlueprintContainer --- .../Timelines/Summary/Parts/TimelinePart.cs | 4 ++-- .../Edit/Compose/Components/BlueprintContainer.cs | 5 +---- .../Components/Timeline/TimelineHitObjectDisplay.cs | 12 ++++++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs b/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs index 7706e33179..119635ccd5 100644 --- a/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs +++ b/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs @@ -14,7 +14,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts /// /// Represents a part of the summary timeline.. /// - public abstract class TimelinePart : Container + public class TimelinePart : Container { protected readonly IBindable Beatmap = new Bindable(); @@ -22,7 +22,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts protected override Container Content => timeline; - protected TimelinePart() + public TimelinePart() { AddInternal(timeline = new Container { RelativeSizeAxes = Axes.Both }); diff --git a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs index 39ec42ba96..a8fb87c1b0 100644 --- a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs @@ -40,9 +40,6 @@ namespace osu.Game.Screens.Edit.Compose.Components [Resolved] private IAdjustableClock adjustableClock { get; set; } - [Resolved] - private HitObjectComposer composer { get; set; } - [Resolved] private EditorBeatmap beatmap { get; set; } @@ -77,7 +74,7 @@ namespace osu.Game.Screens.Edit.Compose.Components dragBox.CreateProxy() }; - foreach (var obj in composer.HitObjects) + foreach (var obj in beatmap.HitObjects) addBlueprintFor(obj); } diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectDisplay.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectDisplay.cs index b20f2fa11d..12909f257d 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectDisplay.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectDisplay.cs @@ -14,15 +14,19 @@ using osuTK.Graphics; namespace osu.Game.Screens.Edit.Compose.Components.Timeline { - internal class TimelineHitObjectDisplay : TimelinePart + internal class TimelineHitObjectDisplay : BlueprintContainer { private EditorBeatmap beatmap { get; } + private readonly TimelinePart content; + public TimelineHitObjectDisplay(EditorBeatmap beatmap) { RelativeSizeAxes = Axes.Both; this.beatmap = beatmap; + + AddInternal(content = new TimelinePart()); } [BackgroundDependencyLoader] @@ -42,15 +46,15 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline private void remove(HitObject h) { - foreach (var d in Children.OfType().Where(c => c.HitObject == h)) + foreach (var d in content.OfType().Where(c => c.HitObject == h)) d.Expire(); } private void add(HitObject h) { - var yOffset = Children.Count(d => d.X == h.StartTime); + var yOffset = content.Count(d => d.X == h.StartTime); - Add(new TimelineHitObjectRepresentation(h) { Y = -yOffset * TimelineHitObjectRepresentation.THICKNESS }); + content.Add(new TimelineHitObjectRepresentation(h) { Y = -yOffset * TimelineHitObjectRepresentation.THICKNESS }); } private class TimelineHitObjectRepresentation : CompositeDrawable From 9da7eec0d91f4779c98ec094c321eba952440884 Mon Sep 17 00:00:00 2001 From: Sebastian Krajewski Date: Sat, 4 Jan 2020 08:21:48 +0100 Subject: [PATCH 026/203] Add pulse to slider reverse arrows --- .../Objects/Drawables/DrawableRepeatPoint.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs index b81d94a673..db8ad98f8a 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs @@ -65,12 +65,18 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables protected override void UpdateInitialTransforms() { - animDuration = Math.Min(150, repeatPoint.SpanDuration / 2); + animDuration = Math.Min(300, repeatPoint.SpanDuration); - this.Animate( - d => d.FadeIn(animDuration), - d => d.ScaleTo(0.5f).ScaleTo(1f, animDuration * 4, Easing.OutElasticHalf) - ); + this.FadeIn(animDuration); + + double fadeInStart = repeatPoint.StartTime - 2 * repeatPoint.SpanDuration; + + // We want first repeat arrow to start pulsing during snake in + if (repeatPoint.RepeatIndex == 0) + fadeInStart -= repeatPoint.TimePreempt; + + for (double pulseStartTime = fadeInStart; pulseStartTime < repeatPoint.StartTime; pulseStartTime += 300) + this.Delay(pulseStartTime - LifetimeStart).ScaleTo(1.3f).ScaleTo(1f, Math.Min(300, repeatPoint.StartTime - pulseStartTime)); } protected override void UpdateStateTransforms(ArmedState state) @@ -88,7 +94,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables break; case ArmedState.Hit: - this.FadeOut(animDuration, Easing.OutQuint) + this.FadeOut(animDuration, Easing.Out) .ScaleTo(Scale * 1.5f, animDuration, Easing.Out); break; } From fc0b622a69dc20e0104536d58b15f5a5f67cf45d Mon Sep 17 00:00:00 2001 From: Sebastian Krajewski Date: Sat, 4 Jan 2020 10:35:10 +0100 Subject: [PATCH 027/203] Change reverse arrow pulse easing to OutQuad --- .../Objects/Drawables/DrawableRepeatPoint.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs index db8ad98f8a..e1cacfaaff 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; @@ -76,7 +76,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables fadeInStart -= repeatPoint.TimePreempt; for (double pulseStartTime = fadeInStart; pulseStartTime < repeatPoint.StartTime; pulseStartTime += 300) - this.Delay(pulseStartTime - LifetimeStart).ScaleTo(1.3f).ScaleTo(1f, Math.Min(300, repeatPoint.StartTime - pulseStartTime)); + this.Delay(pulseStartTime - LifetimeStart).ScaleTo(1.3f).ScaleTo(1f, Math.Min(300, repeatPoint.StartTime - pulseStartTime), Easing.Out); } protected override void UpdateStateTransforms(ArmedState state) From 46271ccbc89e2a55059cda1070d1599321427bca Mon Sep 17 00:00:00 2001 From: Sebastian Krajewski Date: Sat, 4 Jan 2020 13:01:42 +0100 Subject: [PATCH 028/203] Add slider reverse arrow pulse settings --- .../Configuration/OsuRulesetConfigManager.cs | 5 +- .../Objects/Drawables/DrawableRepeatPoint.cs | 43 +++++++------- .../Drawables/Pieces/ReverseArrowPiece.cs | 58 +++++++++++++++++++ .../UI/OsuSettingsSubsection.cs | 5 ++ .../UI/ReverseArrowPulseMode.cs | 18 ++++++ 5 files changed, 108 insertions(+), 21 deletions(-) create mode 100644 osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs create mode 100644 osu.Game.Rulesets.Osu/UI/ReverseArrowPulseMode.cs diff --git a/osu.Game.Rulesets.Osu/Configuration/OsuRulesetConfigManager.cs b/osu.Game.Rulesets.Osu/Configuration/OsuRulesetConfigManager.cs index f76635a932..77b0c728b0 100644 --- a/osu.Game.Rulesets.Osu/Configuration/OsuRulesetConfigManager.cs +++ b/osu.Game.Rulesets.Osu/Configuration/OsuRulesetConfigManager.cs @@ -3,6 +3,7 @@ using osu.Game.Configuration; using osu.Game.Rulesets.Configuration; +using osu.Game.Rulesets.Osu.UI; namespace osu.Game.Rulesets.Osu.Configuration { @@ -19,6 +20,7 @@ namespace osu.Game.Rulesets.Osu.Configuration Set(OsuRulesetSetting.SnakingInSliders, true); Set(OsuRulesetSetting.SnakingOutSliders, true); Set(OsuRulesetSetting.ShowCursorTrail, true); + Set(OsuRulesetSetting.ReverseArrowPulse, ReverseArrowPulseMode.Synced); } } @@ -26,6 +28,7 @@ namespace osu.Game.Rulesets.Osu.Configuration { SnakingInSliders, SnakingOutSliders, - ShowCursorTrail + ShowCursorTrail, + ReverseArrowPulse, } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs index e1cacfaaff..1f3c5d54bc 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; @@ -6,13 +6,13 @@ using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; -using osu.Framework.Graphics.Sprites; using osu.Framework.MathUtils; using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Osu.Configuration; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; +using osu.Game.Rulesets.Osu.UI; using osu.Game.Rulesets.Scoring; using osuTK; -using osu.Game.Skinning; namespace osu.Game.Rulesets.Osu.Objects.Drawables { @@ -21,9 +21,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables private readonly RepeatPoint repeatPoint; private readonly DrawableSlider drawableSlider; + public readonly Bindable PulseMode = new Bindable(ReverseArrowPulseMode.Synced); + private double animDuration; - private readonly SkinnableDrawable scaleContainer; + private readonly Drawable scaleContainer; + + [Resolved(CanBeNull = true)] + private OsuRulesetConfigManager config { get; set; } public DrawableRepeatPoint(RepeatPoint repeatPoint, DrawableSlider drawableSlider) : base(repeatPoint) @@ -36,16 +41,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables Blending = BlendingParameters.Additive; Origin = Anchor.Centre; - InternalChild = scaleContainer = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.ReverseArrow), _ => new SpriteIcon - { - RelativeSizeAxes = Axes.Both, - Icon = FontAwesome.Solid.ChevronRight, - Size = new Vector2(0.35f) - }, confineMode: ConfineMode.NoScaling) - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }; + InternalChild = scaleContainer = new ReverseArrowPiece(); } private readonly IBindable scaleBindable = new Bindable(); @@ -55,6 +51,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { scaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue), true); scaleBindable.BindTo(HitObject.ScaleBindable); + + config?.BindWith(OsuRulesetSetting.ReverseArrowPulse, PulseMode); } protected override void CheckForResult(bool userTriggered, double timeOffset) @@ -69,14 +67,19 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables this.FadeIn(animDuration); - double fadeInStart = repeatPoint.StartTime - 2 * repeatPoint.SpanDuration; + if (PulseMode.Value == ReverseArrowPulseMode.Stable) + { + double fadeInStart = repeatPoint.StartTime - 2 * repeatPoint.SpanDuration; - // We want first repeat arrow to start pulsing during snake in - if (repeatPoint.RepeatIndex == 0) - fadeInStart -= repeatPoint.TimePreempt; + // We want first repeat arrow to start pulsing during snake in + if (repeatPoint.RepeatIndex == 0) + fadeInStart -= repeatPoint.TimePreempt; - for (double pulseStartTime = fadeInStart; pulseStartTime < repeatPoint.StartTime; pulseStartTime += 300) - this.Delay(pulseStartTime - LifetimeStart).ScaleTo(1.3f).ScaleTo(1f, Math.Min(300, repeatPoint.StartTime - pulseStartTime), Easing.Out); + for (double pulseStartTime = fadeInStart; pulseStartTime < repeatPoint.StartTime; pulseStartTime += 300) + this.Delay(pulseStartTime - LifetimeStart).ScaleTo(1.3f).ScaleTo(1f, Math.Min(300, repeatPoint.StartTime - pulseStartTime), Easing.Out); + } + else if (PulseMode.Value == ReverseArrowPulseMode.Off) + this.ScaleTo(0.5f).ScaleTo(1f, animDuration * 2, Easing.OutElasticHalf); } protected override void UpdateStateTransforms(ArmedState state) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs new file mode 100644 index 0000000000..1ec175274e --- /dev/null +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs @@ -0,0 +1,58 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Audio.Track; +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osuTK; +using osu.Framework.Graphics.Sprites; +using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Graphics.Containers; +using osu.Game.Rulesets.Osu.Configuration; +using osu.Game.Rulesets.Osu.UI; +using osu.Game.Skinning; + +namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces +{ + public class ReverseArrowPiece : BeatSyncedContainer + { + public readonly Bindable PulseMode = new Bindable(ReverseArrowPulseMode.Synced); + + [Resolved(CanBeNull = true)] + private OsuRulesetConfigManager config { get; set; } + + public ReverseArrowPiece() + { + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + + Blending = BlendingParameters.Additive; + + Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2); + + InternalChild = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.ReverseArrow), _ => new SpriteIcon + { + RelativeSizeAxes = Axes.Both, + Icon = FontAwesome.Solid.ChevronRight, + Size = new Vector2(0.35f) + }, confineMode: ConfineMode.NoScaling) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }; + } + + protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) + { + if (PulseMode.Value == ReverseArrowPulseMode.Synced) + InternalChild.ScaleTo(1.3f).ScaleTo(1f, timingPoint.BeatLength, Easing.Out); + } + + [BackgroundDependencyLoader] + private void load() + { + config?.BindWith(OsuRulesetSetting.ReverseArrowPulse, PulseMode); + } + } +} diff --git a/osu.Game.Rulesets.Osu/UI/OsuSettingsSubsection.cs b/osu.Game.Rulesets.Osu/UI/OsuSettingsSubsection.cs index 88adf72551..afde693316 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuSettingsSubsection.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuSettingsSubsection.cs @@ -39,6 +39,11 @@ namespace osu.Game.Rulesets.Osu.UI LabelText = "Cursor trail", Bindable = config.GetBindable(OsuRulesetSetting.ShowCursorTrail) }, + new SettingsEnumDropdown + { + LabelText = "Slider reverse arrow pulse", + Bindable = config.GetBindable(OsuRulesetSetting.ReverseArrowPulse) + }, }; } } diff --git a/osu.Game.Rulesets.Osu/UI/ReverseArrowPulseMode.cs b/osu.Game.Rulesets.Osu/UI/ReverseArrowPulseMode.cs new file mode 100644 index 0000000000..d3261e71db --- /dev/null +++ b/osu.Game.Rulesets.Osu/UI/ReverseArrowPulseMode.cs @@ -0,0 +1,18 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.ComponentModel; + +namespace osu.Game.Rulesets.Osu.UI +{ + public enum ReverseArrowPulseMode + { + Off, + + [Description("Match osu!stable")] + Stable, + + [Description("Sync to beatmap")] + Synced + } +} From 319465899824dfde4a6ef3150c86651c3afc98f9 Mon Sep 17 00:00:00 2001 From: Sebastian Krajewski Date: Sat, 4 Jan 2020 13:12:37 +0100 Subject: [PATCH 029/203] Fix repeat point pulsing when it is in fade out state --- .../Objects/Drawables/DrawableRepeatPoint.cs | 2 +- .../Objects/Drawables/Pieces/ReverseArrowPiece.cs | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs index 1f3c5d54bc..6bf2f95f41 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs @@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables Blending = BlendingParameters.Additive; Origin = Anchor.Centre; - InternalChild = scaleContainer = new ReverseArrowPiece(); + InternalChild = scaleContainer = new ReverseArrowPiece(repeatPoint); } private readonly IBindable scaleBindable = new Bindable(); diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs index 1ec175274e..114cf9d27e 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osu.Framework.Allocation; using osu.Framework.Audio.Track; using osu.Framework.Bindables; @@ -22,8 +23,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces [Resolved(CanBeNull = true)] private OsuRulesetConfigManager config { get; set; } - public ReverseArrowPiece() + private readonly RepeatPoint repeatPoint; + + public ReverseArrowPiece(RepeatPoint repeatPoint) { + this.repeatPoint = repeatPoint; + Anchor = Anchor.Centre; Origin = Anchor.Centre; @@ -45,8 +50,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) { - if (PulseMode.Value == ReverseArrowPulseMode.Synced) - InternalChild.ScaleTo(1.3f).ScaleTo(1f, timingPoint.BeatLength, Easing.Out); + if (PulseMode.Value == ReverseArrowPulseMode.Synced && Clock.CurrentTime < repeatPoint.StartTime) + InternalChild.ScaleTo(1.3f).ScaleTo(1f, Math.Min(timingPoint.BeatLength, repeatPoint.StartTime - Clock.CurrentTime), Easing.Out); } [BackgroundDependencyLoader] From e0f66928e6e76dfeef068327a4296d1482baff97 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 7 Jan 2020 01:07:50 +0300 Subject: [PATCH 030/203] Allow CommentsContainer refetch comments using a method --- .../Online/TestSceneCommentsContainer.cs | 28 +++++++---------- .../Overlays/Comments/CommentsContainer.cs | 30 ++++++++++++------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs index 86bd0ddd11..8134c10750 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs @@ -30,29 +30,23 @@ namespace osu.Game.Tests.Visual.Online public TestSceneCommentsContainer() { - BasicScrollContainer scrollFlow; + BasicScrollContainer scroll; + CommentsContainer comments; - Add(scrollFlow = new BasicScrollContainer + Add(scroll = new BasicScrollContainer { RelativeSizeAxes = Axes.Both, + Child = comments = new CommentsContainer() }); - AddStep("Big Black comments", () => + AddStep("Big Black comments", () => comments.ShowComments(CommentableType.Beatmapset, 41823)); + AddStep("Airman comments", () => comments.ShowComments(CommentableType.Beatmapset, 24313)); + AddStep("Lazer build comments", () => comments.ShowComments(CommentableType.Build, 4772)); + AddStep("News comments", () => comments.ShowComments(CommentableType.NewsPost, 715)); + AddStep("Idle state", () => { - scrollFlow.Clear(); - scrollFlow.Add(new CommentsContainer(CommentableType.Beatmapset, 41823)); - }); - - AddStep("Airman comments", () => - { - scrollFlow.Clear(); - scrollFlow.Add(new CommentsContainer(CommentableType.Beatmapset, 24313)); - }); - - AddStep("lazer build comments", () => - { - scrollFlow.Clear(); - scrollFlow.Add(new CommentsContainer(CommentableType.Build, 4772)); + scroll.Clear(); + scroll.Add(comments = new CommentsContainer()); }); } } diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs index 560123eb55..584f658673 100644 --- a/osu.Game/Overlays/Comments/CommentsContainer.cs +++ b/osu.Game/Overlays/Comments/CommentsContainer.cs @@ -18,8 +18,8 @@ namespace osu.Game.Overlays.Comments { public class CommentsContainer : CompositeDrawable { - private readonly CommentableType type; - private readonly long id; + private CommentableType type; + private long id; public readonly Bindable Sort = new Bindable(); public readonly BindableBool ShowDeleted = new BindableBool(); @@ -39,11 +39,8 @@ namespace osu.Game.Overlays.Comments private readonly DeletedChildrenPlaceholder deletedChildrenPlaceholder; private readonly CommentsShowMoreButton moreButton; - public CommentsContainer(CommentableType type, long id) + public CommentsContainer() { - this.type = type; - this.id = id; - RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; AddRangeInternal(new Drawable[] @@ -101,7 +98,8 @@ namespace osu.Game.Overlays.Comments Anchor = Anchor.Centre, Origin = Anchor.Centre, Margin = new MarginPadding(5), - Action = getComments + Action = getComments, + IsLoading = true, } } } @@ -121,12 +119,24 @@ namespace osu.Game.Overlays.Comments protected override void LoadComplete() { - Sort.BindValueChanged(onSortChanged, true); + Sort.BindValueChanged(_ => resetComments()); base.LoadComplete(); } - private void onSortChanged(ValueChangedEvent sort) + /// The type of resource to get comments for. + /// The id of the resource to get comments for. + public void ShowComments(CommentableType type, long id) { + this.type = type; + this.id = id; + Sort.TriggerChange(); + } + + private void resetComments() + { + if (id == default) + return; + clearComments(); getComments(); } @@ -152,7 +162,7 @@ namespace osu.Game.Overlays.Comments { loadCancellation = new CancellationTokenSource(); - FillFlowContainer page = new FillFlowContainer + var page = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, From 21468eb07011c8774f9de838a5a19d602fe01fc6 Mon Sep 17 00:00:00 2001 From: Sebastian Krajewski Date: Tue, 7 Jan 2020 04:55:05 +0100 Subject: [PATCH 031/203] Remove settings related to reverse arrow --- .../Configuration/OsuRulesetConfigManager.cs | 5 +--- .../Objects/Drawables/DrawableRepeatPoint.cs | 28 +++---------------- .../Drawables/Pieces/ReverseArrowPiece.cs | 17 +---------- .../UI/OsuSettingsSubsection.cs | 5 ---- .../UI/ReverseArrowPulseMode.cs | 18 ------------ 5 files changed, 6 insertions(+), 67 deletions(-) delete mode 100644 osu.Game.Rulesets.Osu/UI/ReverseArrowPulseMode.cs diff --git a/osu.Game.Rulesets.Osu/Configuration/OsuRulesetConfigManager.cs b/osu.Game.Rulesets.Osu/Configuration/OsuRulesetConfigManager.cs index 77b0c728b0..f76635a932 100644 --- a/osu.Game.Rulesets.Osu/Configuration/OsuRulesetConfigManager.cs +++ b/osu.Game.Rulesets.Osu/Configuration/OsuRulesetConfigManager.cs @@ -3,7 +3,6 @@ using osu.Game.Configuration; using osu.Game.Rulesets.Configuration; -using osu.Game.Rulesets.Osu.UI; namespace osu.Game.Rulesets.Osu.Configuration { @@ -20,7 +19,6 @@ namespace osu.Game.Rulesets.Osu.Configuration Set(OsuRulesetSetting.SnakingInSliders, true); Set(OsuRulesetSetting.SnakingOutSliders, true); Set(OsuRulesetSetting.ShowCursorTrail, true); - Set(OsuRulesetSetting.ReverseArrowPulse, ReverseArrowPulseMode.Synced); } } @@ -28,7 +26,6 @@ namespace osu.Game.Rulesets.Osu.Configuration { SnakingInSliders, SnakingOutSliders, - ShowCursorTrail, - ReverseArrowPulse, + ShowCursorTrail } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs index 6bf2f95f41..4873160af0 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs @@ -8,9 +8,7 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.MathUtils; using osu.Game.Rulesets.Objects.Drawables; -using osu.Game.Rulesets.Osu.Configuration; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; -using osu.Game.Rulesets.Osu.UI; using osu.Game.Rulesets.Scoring; using osuTK; @@ -21,15 +19,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables private readonly RepeatPoint repeatPoint; private readonly DrawableSlider drawableSlider; - public readonly Bindable PulseMode = new Bindable(ReverseArrowPulseMode.Synced); - private double animDuration; private readonly Drawable scaleContainer; - [Resolved(CanBeNull = true)] - private OsuRulesetConfigManager config { get; set; } - public DrawableRepeatPoint(RepeatPoint repeatPoint, DrawableSlider drawableSlider) : base(repeatPoint) { @@ -51,8 +44,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { scaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue), true); scaleBindable.BindTo(HitObject.ScaleBindable); - - config?.BindWith(OsuRulesetSetting.ReverseArrowPulse, PulseMode); } protected override void CheckForResult(bool userTriggered, double timeOffset) @@ -65,21 +56,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { animDuration = Math.Min(300, repeatPoint.SpanDuration); - this.FadeIn(animDuration); - - if (PulseMode.Value == ReverseArrowPulseMode.Stable) - { - double fadeInStart = repeatPoint.StartTime - 2 * repeatPoint.SpanDuration; - - // We want first repeat arrow to start pulsing during snake in - if (repeatPoint.RepeatIndex == 0) - fadeInStart -= repeatPoint.TimePreempt; - - for (double pulseStartTime = fadeInStart; pulseStartTime < repeatPoint.StartTime; pulseStartTime += 300) - this.Delay(pulseStartTime - LifetimeStart).ScaleTo(1.3f).ScaleTo(1f, Math.Min(300, repeatPoint.StartTime - pulseStartTime), Easing.Out); - } - else if (PulseMode.Value == ReverseArrowPulseMode.Off) - this.ScaleTo(0.5f).ScaleTo(1f, animDuration * 2, Easing.OutElasticHalf); + this.Animate( + d => d.FadeIn(animDuration), + d => d.ScaleTo(0.5f).ScaleTo(1f, animDuration * 2, Easing.OutElasticHalf) + ); } protected override void UpdateStateTransforms(ArmedState state) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs index 114cf9d27e..2b9a3aa197 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs @@ -2,27 +2,18 @@ // See the LICENCE file in the repository root for full licence text. using System; -using osu.Framework.Allocation; using osu.Framework.Audio.Track; -using osu.Framework.Bindables; using osu.Framework.Graphics; using osuTK; using osu.Framework.Graphics.Sprites; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Graphics.Containers; -using osu.Game.Rulesets.Osu.Configuration; -using osu.Game.Rulesets.Osu.UI; using osu.Game.Skinning; namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { public class ReverseArrowPiece : BeatSyncedContainer { - public readonly Bindable PulseMode = new Bindable(ReverseArrowPulseMode.Synced); - - [Resolved(CanBeNull = true)] - private OsuRulesetConfigManager config { get; set; } - private readonly RepeatPoint repeatPoint; public ReverseArrowPiece(RepeatPoint repeatPoint) @@ -50,14 +41,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) { - if (PulseMode.Value == ReverseArrowPulseMode.Synced && Clock.CurrentTime < repeatPoint.StartTime) + if (Clock.CurrentTime < repeatPoint.StartTime) InternalChild.ScaleTo(1.3f).ScaleTo(1f, Math.Min(timingPoint.BeatLength, repeatPoint.StartTime - Clock.CurrentTime), Easing.Out); } - - [BackgroundDependencyLoader] - private void load() - { - config?.BindWith(OsuRulesetSetting.ReverseArrowPulse, PulseMode); - } } } diff --git a/osu.Game.Rulesets.Osu/UI/OsuSettingsSubsection.cs b/osu.Game.Rulesets.Osu/UI/OsuSettingsSubsection.cs index afde693316..88adf72551 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuSettingsSubsection.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuSettingsSubsection.cs @@ -39,11 +39,6 @@ namespace osu.Game.Rulesets.Osu.UI LabelText = "Cursor trail", Bindable = config.GetBindable(OsuRulesetSetting.ShowCursorTrail) }, - new SettingsEnumDropdown - { - LabelText = "Slider reverse arrow pulse", - Bindable = config.GetBindable(OsuRulesetSetting.ReverseArrowPulse) - }, }; } } diff --git a/osu.Game.Rulesets.Osu/UI/ReverseArrowPulseMode.cs b/osu.Game.Rulesets.Osu/UI/ReverseArrowPulseMode.cs deleted file mode 100644 index d3261e71db..0000000000 --- a/osu.Game.Rulesets.Osu/UI/ReverseArrowPulseMode.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System.ComponentModel; - -namespace osu.Game.Rulesets.Osu.UI -{ - public enum ReverseArrowPulseMode - { - Off, - - [Description("Match osu!stable")] - Stable, - - [Description("Sync to beatmap")] - Synced - } -} From 6adf5ba3813482e40cf3e0c391d136e7e9c596e9 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 7 Jan 2020 12:29:21 +0300 Subject: [PATCH 032/203] Use nullable long type for id value --- osu.Game/Overlays/Comments/CommentsContainer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs index 584f658673..97bd0a75e9 100644 --- a/osu.Game/Overlays/Comments/CommentsContainer.cs +++ b/osu.Game/Overlays/Comments/CommentsContainer.cs @@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Comments public class CommentsContainer : CompositeDrawable { private CommentableType type; - private long id; + private long? id; public readonly Bindable Sort = new Bindable(); public readonly BindableBool ShowDeleted = new BindableBool(); @@ -134,18 +134,18 @@ namespace osu.Game.Overlays.Comments private void resetComments() { - if (id == default) - return; - clearComments(); getComments(); } private void getComments() { + if (!id.HasValue) + return; + request?.Cancel(); loadCancellation?.Cancel(); - request = new GetCommentsRequest(type, id, Sort.Value, currentPage++); + request = new GetCommentsRequest(type, id.Value, Sort.Value, currentPage++); request.Success += onSuccess; api.Queue(request); } From 7dc03a1335f860ea0e190901bdc27827352e7286 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 7 Jan 2020 12:30:06 +0300 Subject: [PATCH 033/203] resetComments -> refetchComments --- osu.Game/Overlays/Comments/CommentsContainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs index 97bd0a75e9..99f79cd940 100644 --- a/osu.Game/Overlays/Comments/CommentsContainer.cs +++ b/osu.Game/Overlays/Comments/CommentsContainer.cs @@ -119,7 +119,7 @@ namespace osu.Game.Overlays.Comments protected override void LoadComplete() { - Sort.BindValueChanged(_ => resetComments()); + Sort.BindValueChanged(_ => refetchComments()); base.LoadComplete(); } @@ -132,7 +132,7 @@ namespace osu.Game.Overlays.Comments Sort.TriggerChange(); } - private void resetComments() + private void refetchComments() { clearComments(); getComments(); From 14289523777302fbcb3aa3c524964f9d43a365af Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 8 Jan 2020 18:59:13 +0300 Subject: [PATCH 034/203] Implement CountryFilter component for RankingsOverlay --- .../Online/TestSceneRankingsCountryFilter.cs | 45 ++++ osu.Game/Overlays/Rankings/CountryFilter.cs | 231 ++++++++++++++++++ 2 files changed, 276 insertions(+) create mode 100644 osu.Game.Tests/Visual/Online/TestSceneRankingsCountryFilter.cs create mode 100644 osu.Game/Overlays/Rankings/CountryFilter.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneRankingsCountryFilter.cs b/osu.Game.Tests/Visual/Online/TestSceneRankingsCountryFilter.cs new file mode 100644 index 0000000000..968be62a7c --- /dev/null +++ b/osu.Game.Tests/Visual/Online/TestSceneRankingsCountryFilter.cs @@ -0,0 +1,45 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Collections.Generic; +using osu.Framework.Bindables; +using osu.Game.Overlays.Rankings; +using osu.Game.Users; + +namespace osu.Game.Tests.Visual.Online +{ + public class TestSceneRankingsCountryFilter : OsuTestScene + { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(CountryFilter), + }; + + public TestSceneRankingsCountryFilter() + { + var countryBindable = new Bindable(); + CountryFilter filter; + + Add(filter = new CountryFilter + { + Country = { BindTarget = countryBindable } + }); + + var country = new Country + { + FlagName = "BY", + FullName = "Belarus" + }; + var unknownCountry = new Country + { + FlagName = "CK", + FullName = "Cook Islands" + }; + + AddStep("Set country", () => countryBindable.Value = country); + AddStep("Set null country", () => countryBindable.Value = null); + AddStep("Set country with no flag", () => countryBindable.Value = unknownCountry); + } + } +} diff --git a/osu.Game/Overlays/Rankings/CountryFilter.cs b/osu.Game/Overlays/Rankings/CountryFilter.cs new file mode 100644 index 0000000000..4a24a440cc --- /dev/null +++ b/osu.Game/Overlays/Rankings/CountryFilter.cs @@ -0,0 +1,231 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input.Events; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; +using osu.Game.Users; +using osu.Game.Users.Drawables; +using osuTK; + +namespace osu.Game.Overlays.Rankings +{ + public class CountryFilter : Container + { + private const int duration = 200; + private const int height = 50; + + public readonly Bindable Country = new Bindable(); + + private readonly Box background; + private readonly CountryPill countryPill; + private readonly Container content; + + public CountryFilter() + { + RelativeSizeAxes = Axes.X; + Child = content = new Container + { + RelativeSizeAxes = Axes.X, + Height = height, + Alpha = 0, + Children = new Drawable[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both + }, + new FillFlowContainer + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(10, 0), + Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN }, + Children = new Drawable[] + { + new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Text = @"filtered by country:", + Font = OsuFont.GetFont(size: 14) + }, + countryPill = new CountryPill + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Alpha = 0, + Country = { BindTarget = Country } + } + } + } + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + background.Colour = colours.GreySeafoam; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + Country.BindValueChanged(onCountryChanged, true); + } + + private void onCountryChanged(ValueChangedEvent country) + { + countryPill.ClearTransforms(); + + if (country.NewValue == null) + { + countryPill.Collapse(); + this.ResizeHeightTo(0, duration, Easing.OutQuint); + content.FadeOut(duration, Easing.OutQuint); + return; + } + + this.ResizeHeightTo(height, duration, Easing.OutQuint); + content.FadeIn(duration, Easing.OutQuint).Finally(_ => countryPill.Expand()); + } + + private class CountryPill : CircularContainer + { + private readonly Box background; + private readonly UpdateableFlag flag; + private readonly OsuSpriteText countryName; + + public readonly Bindable Country = new Bindable(); + + public CountryPill() + { + AutoSizeDuration = duration; + AutoSizeEasing = Easing.OutQuint; + Height = 25; + Masking = true; + Children = new Drawable[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both + }, + new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Margin = new MarginPadding { Horizontal = 10 }, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(8, 0), + Children = new Drawable[] + { + new FillFlowContainer + { + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(3, 0), + Children = new Drawable[] + { + flag = new UpdateableFlag + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(22, 15) + }, + countryName = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.GetFont(size: 14) + } + } + }, + new CloseButton + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + ClickAction = () => Country.Value = null + } + } + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + background.Colour = colours.GreySeafoamDarker; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + Country.BindValueChanged(onCountryChanged, true); + } + + public void Expand() + { + AutoSizeAxes = Axes.X; + this.FadeIn(duration, Easing.OutQuint); + } + + public void Collapse() + { + AutoSizeAxes = Axes.None; + this.ResizeWidthTo(0, duration, Easing.OutQuint); + this.FadeOut(duration, Easing.OutQuint); + } + + private void onCountryChanged(ValueChangedEvent country) + { + if (country.NewValue == null) + return; + + flag.Country = country.NewValue; + countryName.Text = country.NewValue.FullName; + } + + private class CloseButton : Container + { + public Action ClickAction; + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + AutoSizeAxes = Axes.Both; + Children = new Drawable[] + { + new SpriteIcon + { + Size = new Vector2(8), + Icon = FontAwesome.Solid.Times, + Colour = colours.GreySeafoamLighter, + }, + new HoverClickSounds(), + }; + } + + protected override bool OnClick(ClickEvent e) + { + ClickAction?.Invoke(); + return base.OnClick(e); + } + } + } + } +} From dc64ba8ed81d21aef0c4368f53c5fcfda795161a Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 8 Jan 2020 19:22:07 +0300 Subject: [PATCH 035/203] Remove unused variable --- osu.Game.Tests/Visual/Online/TestSceneRankingsCountryFilter.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneRankingsCountryFilter.cs b/osu.Game.Tests/Visual/Online/TestSceneRankingsCountryFilter.cs index 968be62a7c..9a8ddf9cad 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneRankingsCountryFilter.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneRankingsCountryFilter.cs @@ -19,9 +19,8 @@ namespace osu.Game.Tests.Visual.Online public TestSceneRankingsCountryFilter() { var countryBindable = new Bindable(); - CountryFilter filter; - Add(filter = new CountryFilter + Add(new CountryFilter { Country = { BindTarget = countryBindable } }); From 1dbae21f981852f878154d73af241d7e44e0073a Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 8 Jan 2020 19:40:28 +0300 Subject: [PATCH 036/203] Fix crashing test --- osu.Game/Overlays/Rankings/CountryFilter.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Overlays/Rankings/CountryFilter.cs b/osu.Game/Overlays/Rankings/CountryFilter.cs index 4a24a440cc..008214a9a4 100644 --- a/osu.Game/Overlays/Rankings/CountryFilter.cs +++ b/osu.Game/Overlays/Rankings/CountryFilter.cs @@ -86,6 +86,7 @@ namespace osu.Game.Overlays.Rankings private void onCountryChanged(ValueChangedEvent country) { + content.ClearTransforms(); countryPill.ClearTransforms(); if (country.NewValue == null) From 6cb763a019b3ecc34d47d683390a5b476ee94334 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 9 Jan 2020 00:06:28 +0300 Subject: [PATCH 037/203] Improve animations --- osu.Game/Overlays/Rankings/CountryFilter.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Rankings/CountryFilter.cs b/osu.Game/Overlays/Rankings/CountryFilter.cs index 008214a9a4..5452bc9327 100644 --- a/osu.Game/Overlays/Rankings/CountryFilter.cs +++ b/osu.Game/Overlays/Rankings/CountryFilter.cs @@ -86,9 +86,6 @@ namespace osu.Game.Overlays.Rankings private void onCountryChanged(ValueChangedEvent country) { - content.ClearTransforms(); - countryPill.ClearTransforms(); - if (country.NewValue == null) { countryPill.Collapse(); @@ -98,7 +95,8 @@ namespace osu.Game.Overlays.Rankings } this.ResizeHeightTo(height, duration, Easing.OutQuint); - content.FadeIn(duration, Easing.OutQuint).Finally(_ => countryPill.Expand()); + content.FadeIn(duration, Easing.OutQuint); + countryPill.Expand(); } private class CountryPill : CircularContainer @@ -181,12 +179,14 @@ namespace osu.Game.Overlays.Rankings public void Expand() { + ClearTransforms(); AutoSizeAxes = Axes.X; this.FadeIn(duration, Easing.OutQuint); } public void Collapse() { + ClearTransforms(); AutoSizeAxes = Axes.None; this.ResizeWidthTo(0, duration, Easing.OutQuint); this.FadeOut(duration, Easing.OutQuint); From 29c4ae68d91e8bb06f6197eb7da2ee24dc2725bb Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 9 Jan 2020 00:14:29 +0300 Subject: [PATCH 038/203] Add some content to test scene for better visual representation --- .../Online/TestSceneRankingsCountryFilter.cs | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneRankingsCountryFilter.cs b/osu.Game.Tests/Visual/Online/TestSceneRankingsCountryFilter.cs index 9a8ddf9cad..360bb81715 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneRankingsCountryFilter.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneRankingsCountryFilter.cs @@ -4,8 +4,13 @@ using System; using System.Collections.Generic; using osu.Framework.Bindables; +using osu.Framework.Graphics.Containers; using osu.Game.Overlays.Rankings; using osu.Game.Users; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Shapes; +using osuTK.Graphics; +using osu.Game.Graphics.Sprites; namespace osu.Game.Tests.Visual.Online { @@ -20,9 +25,35 @@ namespace osu.Game.Tests.Visual.Online { var countryBindable = new Bindable(); - Add(new CountryFilter + AddRange(new Drawable[] { - Country = { BindTarget = countryBindable } + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Gray, + }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + new CountryFilter + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Country = { BindTarget = countryBindable } + }, + new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Text = "Some content", + Margin = new MarginPadding { Vertical = 20 } + } + } + } }); var country = new Country From 0d9fb065da462b36074c9b292cc50c001b39236a Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 9 Jan 2020 00:27:22 +0300 Subject: [PATCH 039/203] Move CountryPill to it's own class --- .../Online/TestSceneRankingsCountryFilter.cs | 1 + osu.Game/Overlays/Rankings/CountryFilter.cs | 135 ---------------- osu.Game/Overlays/Rankings/CountryPill.cs | 149 ++++++++++++++++++ 3 files changed, 150 insertions(+), 135 deletions(-) create mode 100644 osu.Game/Overlays/Rankings/CountryPill.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneRankingsCountryFilter.cs b/osu.Game.Tests/Visual/Online/TestSceneRankingsCountryFilter.cs index 360bb81715..3d38710b59 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneRankingsCountryFilter.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneRankingsCountryFilter.cs @@ -19,6 +19,7 @@ namespace osu.Game.Tests.Visual.Online public override IReadOnlyList RequiredTypes => new[] { typeof(CountryFilter), + typeof(CountryPill) }; public TestSceneRankingsCountryFilter() diff --git a/osu.Game/Overlays/Rankings/CountryFilter.cs b/osu.Game/Overlays/Rankings/CountryFilter.cs index 5452bc9327..7cd56100db 100644 --- a/osu.Game/Overlays/Rankings/CountryFilter.cs +++ b/osu.Game/Overlays/Rankings/CountryFilter.cs @@ -1,19 +1,14 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Graphics.UserInterface; using osu.Game.Users; -using osu.Game.Users.Drawables; using osuTK; namespace osu.Game.Overlays.Rankings @@ -98,135 +93,5 @@ namespace osu.Game.Overlays.Rankings content.FadeIn(duration, Easing.OutQuint); countryPill.Expand(); } - - private class CountryPill : CircularContainer - { - private readonly Box background; - private readonly UpdateableFlag flag; - private readonly OsuSpriteText countryName; - - public readonly Bindable Country = new Bindable(); - - public CountryPill() - { - AutoSizeDuration = duration; - AutoSizeEasing = Easing.OutQuint; - Height = 25; - Masking = true; - Children = new Drawable[] - { - background = new Box - { - RelativeSizeAxes = Axes.Both - }, - new FillFlowContainer - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Y, - AutoSizeAxes = Axes.X, - Margin = new MarginPadding { Horizontal = 10 }, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(8, 0), - Children = new Drawable[] - { - new FillFlowContainer - { - RelativeSizeAxes = Axes.Y, - AutoSizeAxes = Axes.X, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(3, 0), - Children = new Drawable[] - { - flag = new UpdateableFlag - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(22, 15) - }, - countryName = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 14) - } - } - }, - new CloseButton - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - ClickAction = () => Country.Value = null - } - } - } - }; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - background.Colour = colours.GreySeafoamDarker; - } - - protected override void LoadComplete() - { - base.LoadComplete(); - Country.BindValueChanged(onCountryChanged, true); - } - - public void Expand() - { - ClearTransforms(); - AutoSizeAxes = Axes.X; - this.FadeIn(duration, Easing.OutQuint); - } - - public void Collapse() - { - ClearTransforms(); - AutoSizeAxes = Axes.None; - this.ResizeWidthTo(0, duration, Easing.OutQuint); - this.FadeOut(duration, Easing.OutQuint); - } - - private void onCountryChanged(ValueChangedEvent country) - { - if (country.NewValue == null) - return; - - flag.Country = country.NewValue; - countryName.Text = country.NewValue.FullName; - } - - private class CloseButton : Container - { - public Action ClickAction; - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - AutoSizeAxes = Axes.Both; - Children = new Drawable[] - { - new SpriteIcon - { - Size = new Vector2(8), - Icon = FontAwesome.Solid.Times, - Colour = colours.GreySeafoamLighter, - }, - new HoverClickSounds(), - }; - } - - protected override bool OnClick(ClickEvent e) - { - ClickAction?.Invoke(); - return base.OnClick(e); - } - } - } } } diff --git a/osu.Game/Overlays/Rankings/CountryPill.cs b/osu.Game/Overlays/Rankings/CountryPill.cs new file mode 100644 index 0000000000..65fce3b909 --- /dev/null +++ b/osu.Game/Overlays/Rankings/CountryPill.cs @@ -0,0 +1,149 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osu.Game.Users; +using osu.Game.Users.Drawables; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Overlays.Rankings +{ + public class CountryPill : CircularContainer + { + private const int duration = 200; + + private readonly Box background; + private readonly UpdateableFlag flag; + private readonly OsuSpriteText countryName; + + public readonly Bindable Country = new Bindable(); + + public CountryPill() + { + AutoSizeDuration = duration; + AutoSizeEasing = Easing.OutQuint; + Height = 25; + Masking = true; + Children = new Drawable[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both + }, + new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Margin = new MarginPadding { Horizontal = 10 }, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(8, 0), + Children = new Drawable[] + { + new FillFlowContainer + { + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(3, 0), + Children = new Drawable[] + { + flag = new UpdateableFlag + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(22, 15) + }, + countryName = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.GetFont(size: 14) + } + } + }, + new CloseButton + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Action = () => Country.Value = null + } + } + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + background.Colour = colours.GreySeafoamDarker; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + Country.BindValueChanged(onCountryChanged, true); + } + + public void Expand() + { + ClearTransforms(); + AutoSizeAxes = Axes.X; + this.FadeIn(duration, Easing.OutQuint); + } + + public void Collapse() + { + ClearTransforms(); + AutoSizeAxes = Axes.None; + this.ResizeWidthTo(0, duration, Easing.OutQuint); + this.FadeOut(duration, Easing.OutQuint); + } + + private void onCountryChanged(ValueChangedEvent country) + { + if (country.NewValue == null) + return; + + flag.Country = country.NewValue; + countryName.Text = country.NewValue.FullName; + } + + private class CloseButton : OsuHoverContainer + { + private readonly SpriteIcon icon; + + protected override IEnumerable EffectTargets => new[] { icon }; + + public CloseButton() + { + AutoSizeAxes = Axes.Both; + Add(icon = new SpriteIcon + { + Size = new Vector2(8), + Icon = FontAwesome.Solid.Times + }); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + IdleColour = colours.GreySeafoamLighter; + HoverColour = Color4.White; + } + } + } +} From 6500cc967fff845a8e65cd3fc1a7a666be43669e Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 11 Jan 2020 06:58:35 +0300 Subject: [PATCH 040/203] Implement SongTicker component --- osu.Game/Screens/Menu/MainMenu.cs | 7 +++ osu.Game/Screens/Menu/SongTicker.cs | 66 +++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 osu.Game/Screens/Menu/SongTicker.cs diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index b28d572b5c..47c86fc1ae 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -75,6 +75,13 @@ namespace osu.Game.Screens.Menu holdDelay = config.GetBindable(OsuSetting.UIHoldActivationDelay); loginDisplayed = statics.GetBindable(Static.LoginOverlayDisplayed); + AddInternal(new SongTicker + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Margin = new MarginPadding { Right = 15 } + }); + if (host.CanExit) { AddInternal(exitConfirmOverlay = new ExitConfirmOverlay diff --git a/osu.Game/Screens/Menu/SongTicker.cs b/osu.Game/Screens/Menu/SongTicker.cs new file mode 100644 index 0000000000..504b016019 --- /dev/null +++ b/osu.Game/Screens/Menu/SongTicker.cs @@ -0,0 +1,66 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osuTK; +using osu.Game.Graphics; +using osu.Framework.Bindables; +using osu.Game.Beatmaps; + +namespace osu.Game.Screens.Menu +{ + public class SongTicker : Container + { + private const int duration = 500; + + [Resolved] + private Bindable beatmap { get; set; } + + private readonly Bindable workingBeatmap = new Bindable(); + private readonly OsuSpriteText title, artist; + + public SongTicker() + { + AutoSizeAxes = Axes.Both; + Child = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 3), + Children = new Drawable[] + { + title = new OsuSpriteText + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Font = OsuFont.GetFont(size: 24, weight: FontWeight.Light, italics: true) + }, + artist = new OsuSpriteText + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Font = OsuFont.GetFont(size: 16) + } + } + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + workingBeatmap.BindTo(beatmap); + workingBeatmap.BindValueChanged(onBeatmapChanged); + } + + private void onBeatmapChanged(ValueChangedEvent working) + { + title.Text = working.NewValue?.Metadata?.Title; + artist.Text = working.NewValue?.Metadata?.Artist; + + this.FadeIn(duration, Easing.OutQuint).Delay(4000).Then().FadeOut(duration, Easing.OutQuint); + } + } +} From 7716a555ecb71fd5d3ad290bc22d89daf4a281c1 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 11 Jan 2020 07:08:00 +0300 Subject: [PATCH 041/203] Move only ButtonSystem on screen changes rather than everything --- osu.Game/Screens/Menu/MainMenu.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 47c86fc1ae..c4465dce17 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -69,6 +69,8 @@ namespace osu.Game.Screens.Menu private ExitConfirmOverlay exitConfirmOverlay; + private ParallaxContainer buttonsContainer; + [BackgroundDependencyLoader(true)] private void load(DirectOverlay direct, SettingsOverlay settings, OsuConfigManager config, SessionStatics statics) { @@ -79,7 +81,7 @@ namespace osu.Game.Screens.Menu { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, - Margin = new MarginPadding { Right = 15 } + Margin = new MarginPadding { Right = 15, Top = 5 } }); if (host.CanExit) @@ -98,7 +100,7 @@ namespace osu.Game.Screens.Menu AddRangeInternal(new Drawable[] { - new ParallaxContainer + buttonsContainer = new ParallaxContainer { ParallaxAmount = 0.01f, Children = new Drawable[] @@ -197,7 +199,7 @@ namespace osu.Game.Screens.Menu buttons.State = ButtonSystemState.TopLevel; this.FadeIn(FADE_IN_DURATION, Easing.OutQuint); - this.MoveTo(new Vector2(0, 0), FADE_IN_DURATION, Easing.OutQuint); + buttonsContainer.MoveTo(new Vector2(0, 0), FADE_IN_DURATION, Easing.OutQuint); sideFlashes.Delay(FADE_IN_DURATION).FadeIn(64, Easing.InQuint); } @@ -234,7 +236,7 @@ namespace osu.Game.Screens.Menu buttons.State = ButtonSystemState.EnteringMode; this.FadeOut(FADE_OUT_DURATION, Easing.InSine); - this.MoveTo(new Vector2(-800, 0), FADE_OUT_DURATION, Easing.InSine); + buttonsContainer.MoveTo(new Vector2(-800, 0), FADE_OUT_DURATION, Easing.InSine); sideFlashes.FadeOut(64, Easing.OutQuint); } From d59cae33d3f0ff67fc5f6a38a7a2c02449bcb110 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 11 Jan 2020 07:17:13 +0300 Subject: [PATCH 042/203] Some animation adjustments --- osu.Game/Screens/Menu/MainMenu.cs | 6 +++++- osu.Game/Screens/Menu/SongTicker.cs | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index c4465dce17..0b267731d8 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -70,6 +70,7 @@ namespace osu.Game.Screens.Menu private ExitConfirmOverlay exitConfirmOverlay; private ParallaxContainer buttonsContainer; + private SongTicker songTicker; [BackgroundDependencyLoader(true)] private void load(DirectOverlay direct, SettingsOverlay settings, OsuConfigManager config, SessionStatics statics) @@ -77,7 +78,7 @@ namespace osu.Game.Screens.Menu holdDelay = config.GetBindable(OsuSetting.UIHoldActivationDelay); loginDisplayed = statics.GetBindable(Static.LoginOverlayDisplayed); - AddInternal(new SongTicker + AddInternal(songTicker = new SongTicker { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -235,6 +236,7 @@ namespace osu.Game.Screens.Menu buttons.State = ButtonSystemState.EnteringMode; + songTicker.Hide(); this.FadeOut(FADE_OUT_DURATION, Easing.InSine); buttonsContainer.MoveTo(new Vector2(-800, 0), FADE_OUT_DURATION, Easing.InSine); @@ -244,6 +246,7 @@ namespace osu.Game.Screens.Menu public override void OnResuming(IScreen last) { base.OnResuming(last); + songTicker.Hide(); (Background as BackgroundScreenDefault)?.Next(); @@ -272,6 +275,7 @@ namespace osu.Game.Screens.Menu buttons.State = ButtonSystemState.Exit; this.FadeOut(3000); + songTicker.Hide(); return base.OnExiting(next); } diff --git a/osu.Game/Screens/Menu/SongTicker.cs b/osu.Game/Screens/Menu/SongTicker.cs index 504b016019..eb7012a150 100644 --- a/osu.Game/Screens/Menu/SongTicker.cs +++ b/osu.Game/Screens/Menu/SongTicker.cs @@ -14,7 +14,7 @@ namespace osu.Game.Screens.Menu { public class SongTicker : Container { - private const int duration = 500; + private const int fade_duration = 800; [Resolved] private Bindable beatmap { get; set; } @@ -60,7 +60,7 @@ namespace osu.Game.Screens.Menu title.Text = working.NewValue?.Metadata?.Title; artist.Text = working.NewValue?.Metadata?.Artist; - this.FadeIn(duration, Easing.OutQuint).Delay(4000).Then().FadeOut(duration, Easing.OutQuint); + this.FadeIn(fade_duration, Easing.OutQuint).Delay(4000).Then().FadeOut(fade_duration, Easing.OutQuint); } } } From e6210f10b7de81a12ef03148202ae14933a77fb7 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 11 Jan 2020 07:32:40 +0300 Subject: [PATCH 043/203] Add unicode metadata support --- osu.Game/Screens/Menu/SongTicker.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Menu/SongTicker.cs b/osu.Game/Screens/Menu/SongTicker.cs index eb7012a150..d9b66d06e9 100644 --- a/osu.Game/Screens/Menu/SongTicker.cs +++ b/osu.Game/Screens/Menu/SongTicker.cs @@ -9,6 +9,7 @@ using osuTK; using osu.Game.Graphics; using osu.Framework.Bindables; using osu.Game.Beatmaps; +using osu.Framework.Localisation; namespace osu.Game.Screens.Menu { @@ -57,8 +58,13 @@ namespace osu.Game.Screens.Menu private void onBeatmapChanged(ValueChangedEvent working) { - title.Text = working.NewValue?.Metadata?.Title; - artist.Text = working.NewValue?.Metadata?.Artist; + if (working.NewValue?.Beatmap == null) + return; + + var metadata = working.NewValue?.Metadata; + + title.Text = new LocalisedString((metadata.TitleUnicode, metadata.Title)); + artist.Text = new LocalisedString((metadata.ArtistUnicode, metadata.Artist)); this.FadeIn(fade_duration, Easing.OutQuint).Delay(4000).Then().FadeOut(fade_duration, Easing.OutQuint); } From d25ef1966d32bda80e258da550a6c87768ca0eeb Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 11 Jan 2020 17:48:09 +0300 Subject: [PATCH 044/203] Remove unnecessary local bindable --- osu.Game/Screens/Menu/SongTicker.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Game/Screens/Menu/SongTicker.cs b/osu.Game/Screens/Menu/SongTicker.cs index d9b66d06e9..f2c861a296 100644 --- a/osu.Game/Screens/Menu/SongTicker.cs +++ b/osu.Game/Screens/Menu/SongTicker.cs @@ -20,7 +20,6 @@ namespace osu.Game.Screens.Menu [Resolved] private Bindable beatmap { get; set; } - private readonly Bindable workingBeatmap = new Bindable(); private readonly OsuSpriteText title, artist; public SongTicker() @@ -52,8 +51,7 @@ namespace osu.Game.Screens.Menu protected override void LoadComplete() { base.LoadComplete(); - workingBeatmap.BindTo(beatmap); - workingBeatmap.BindValueChanged(onBeatmapChanged); + beatmap.BindValueChanged(onBeatmapChanged); } private void onBeatmapChanged(ValueChangedEvent working) From 81948744d056acd6ca24d0f6875236fcef3f034a Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 11 Jan 2020 17:50:13 +0300 Subject: [PATCH 045/203] remove unnecessary null checks --- osu.Game/Screens/Menu/SongTicker.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/osu.Game/Screens/Menu/SongTicker.cs b/osu.Game/Screens/Menu/SongTicker.cs index f2c861a296..8eae94ae1d 100644 --- a/osu.Game/Screens/Menu/SongTicker.cs +++ b/osu.Game/Screens/Menu/SongTicker.cs @@ -56,10 +56,7 @@ namespace osu.Game.Screens.Menu private void onBeatmapChanged(ValueChangedEvent working) { - if (working.NewValue?.Beatmap == null) - return; - - var metadata = working.NewValue?.Metadata; + var metadata = working.NewValue.Metadata; title.Text = new LocalisedString((metadata.TitleUnicode, metadata.Title)); artist.Text = new LocalisedString((metadata.ArtistUnicode, metadata.Artist)); From bd33687f533a969d7bd855054b50f840614ef754 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 11 Jan 2020 18:27:22 +0300 Subject: [PATCH 046/203] Add AllowUpdates flag to SongTicker --- osu.Game/Screens/Menu/MainMenu.cs | 5 ++++- osu.Game/Screens/Menu/SongTicker.cs | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 0b267731d8..72b61eb05c 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -237,6 +237,8 @@ namespace osu.Game.Screens.Menu buttons.State = ButtonSystemState.EnteringMode; songTicker.Hide(); + songTicker.AllowUpdates = false; + this.FadeOut(FADE_OUT_DURATION, Easing.InSine); buttonsContainer.MoveTo(new Vector2(-800, 0), FADE_OUT_DURATION, Easing.InSine); @@ -246,7 +248,8 @@ namespace osu.Game.Screens.Menu public override void OnResuming(IScreen last) { base.OnResuming(last); - songTicker.Hide(); + + songTicker.AllowUpdates = true; (Background as BackgroundScreenDefault)?.Next(); diff --git a/osu.Game/Screens/Menu/SongTicker.cs b/osu.Game/Screens/Menu/SongTicker.cs index 8eae94ae1d..f858d162d2 100644 --- a/osu.Game/Screens/Menu/SongTicker.cs +++ b/osu.Game/Screens/Menu/SongTicker.cs @@ -17,6 +17,8 @@ namespace osu.Game.Screens.Menu { private const int fade_duration = 800; + public bool AllowUpdates { get; set; } = true; + [Resolved] private Bindable beatmap { get; set; } @@ -56,6 +58,9 @@ namespace osu.Game.Screens.Menu private void onBeatmapChanged(ValueChangedEvent working) { + if (!AllowUpdates) + return; + var metadata = working.NewValue.Metadata; title.Text = new LocalisedString((metadata.TitleUnicode, metadata.Title)); From 730cc92bf36ddf5c7a2eb53d5c7042b422708de5 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 11 Jan 2020 22:43:07 +0300 Subject: [PATCH 047/203] Fade out instead of insta hiding on menu suspending --- osu.Game/Screens/Menu/MainMenu.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 72b61eb05c..2de31cf399 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -236,7 +236,7 @@ namespace osu.Game.Screens.Menu buttons.State = ButtonSystemState.EnteringMode; - songTicker.Hide(); + songTicker.FadeOut(100, Easing.OutQuint); songTicker.AllowUpdates = false; this.FadeOut(FADE_OUT_DURATION, Easing.InSine); From af167eb719964794663983e32f2fbac80ba4f693 Mon Sep 17 00:00:00 2001 From: recapitalverb <41869184+recapitalverb@users.noreply.github.com> Date: Mon, 13 Jan 2020 23:28:26 +0700 Subject: [PATCH 048/203] Remove duplicate condition in TournamentFont --- osu.Game.Tournament/TournamentFont.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tournament/TournamentFont.cs b/osu.Game.Tournament/TournamentFont.cs index f9e60ff2bc..32f0264562 100644 --- a/osu.Game.Tournament/TournamentFont.cs +++ b/osu.Game.Tournament/TournamentFont.cs @@ -61,7 +61,7 @@ namespace osu.Game.Tournament string weightString = weight.ToString(); // Only exo has an explicit "regular" weight, other fonts do not - if (weight == FontWeight.Regular && family != GetFamilyString(TournamentTypeface.Aquatico) && family != GetFamilyString(TournamentTypeface.Aquatico)) + if (weight == FontWeight.Regular && family != GetFamilyString(TournamentTypeface.Aquatico)) weightString = string.Empty; return weightString; From 619fe29871b7e2797b9e0c15003842bb70e4059f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 14 Jan 2020 01:39:45 +0900 Subject: [PATCH 049/203] Make reverse arrow animate faster via divisor specification Adds MinimumBeatLength to BeatSyncedContainer to make sure things don't get out of hand. --- .../Objects/Drawables/Pieces/ReverseArrowPiece.cs | 3 +++ osu.Game/Graphics/Containers/BeatSyncedContainer.cs | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs index 2b9a3aa197..2c6e5b7c18 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs @@ -20,6 +20,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { this.repeatPoint = repeatPoint; + Divisor = 2; + MinimumBeatLength = 200; + Anchor = Anchor.Centre; Origin = Anchor.Centre; diff --git a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs index b9ef279f5c..be9aefa359 100644 --- a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs +++ b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs @@ -38,6 +38,11 @@ namespace osu.Game.Graphics.Containers /// public int Divisor { get; set; } = 1; + /// + /// An optional minimum beat length. Any beat length below this will be multiplied by two until valid. + /// + public double MinimumBeatLength { get; set; } + /// /// Default length of a beat in milliseconds. Used whenever there is no beatmap or track playing. /// @@ -89,6 +94,9 @@ namespace osu.Game.Graphics.Containers double beatLength = timingPoint.BeatLength / Divisor; + while (beatLength < MinimumBeatLength) + beatLength *= 2; + int beatIndex = (int)((currentTrackTime - timingPoint.Time) / beatLength) - (effectPoint.OmitFirstBarLine ? 1 : 0); // The beats before the start of the first control point are off by 1, this should do the trick From c5085aea24ae4b08890baac8e894ce208d71af7e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 14 Jan 2020 01:45:10 +0900 Subject: [PATCH 050/203] Use Child, not InternalChild --- .../Objects/Drawables/Pieces/ReverseArrowPiece.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs index 2c6e5b7c18..ee7cdefa13 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs @@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2); - InternalChild = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.ReverseArrow), _ => new SpriteIcon + Child = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.ReverseArrow), _ => new SpriteIcon { RelativeSizeAxes = Axes.Both, Icon = FontAwesome.Solid.ChevronRight, @@ -45,7 +45,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) { if (Clock.CurrentTime < repeatPoint.StartTime) - InternalChild.ScaleTo(1.3f).ScaleTo(1f, Math.Min(timingPoint.BeatLength, repeatPoint.StartTime - Clock.CurrentTime), Easing.Out); + Child.ScaleTo(1.3f).ScaleTo(1f, Math.Min(timingPoint.BeatLength, repeatPoint.StartTime - Clock.CurrentTime), Easing.Out); } } } From 210d06b75ed27209d6d8721a8d3b131004a57bb5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 14 Jan 2020 01:45:32 +0900 Subject: [PATCH 051/203] Remove default value --- .../Objects/Drawables/Pieces/ReverseArrowPiece.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs index ee7cdefa13..37bbfbe806 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs @@ -35,7 +35,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces RelativeSizeAxes = Axes.Both, Icon = FontAwesome.Solid.ChevronRight, Size = new Vector2(0.35f) - }, confineMode: ConfineMode.NoScaling) + }) { Anchor = Anchor.Centre, Origin = Anchor.Centre, From ab4f31639d9e2ccfd8ac4cc61091c024aa0c6827 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 14 Jan 2020 01:47:44 +0900 Subject: [PATCH 052/203] Remove weird time clause --- .../Objects/Drawables/Pieces/ReverseArrowPiece.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs index 37bbfbe806..0403fe8196 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs @@ -45,7 +45,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) { if (Clock.CurrentTime < repeatPoint.StartTime) - Child.ScaleTo(1.3f).ScaleTo(1f, Math.Min(timingPoint.BeatLength, repeatPoint.StartTime - Clock.CurrentTime), Easing.Out); + Child.ScaleTo(1.3f).ScaleTo(1f, timingPoint.BeatLength, Easing.Out); } } } From fe09e34f1bf8a9ed9d7479c0792ac871ae3b5020 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 14 Jan 2020 01:48:20 +0900 Subject: [PATCH 053/203] Remove limiting clause --- .../Objects/Drawables/Pieces/ReverseArrowPiece.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs index 0403fe8196..08dd97b0d8 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ReverseArrowPiece.cs @@ -42,10 +42,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces }; } - protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) - { - if (Clock.CurrentTime < repeatPoint.StartTime) - Child.ScaleTo(1.3f).ScaleTo(1f, timingPoint.BeatLength, Easing.Out); - } + protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) => + Child.ScaleTo(1.3f).ScaleTo(1f, timingPoint.BeatLength, Easing.Out); } } From c196e83e75f495f533f82e867d7d8cd3e9165738 Mon Sep 17 00:00:00 2001 From: Joehu Date: Mon, 13 Jan 2020 20:48:39 -0800 Subject: [PATCH 054/203] Allow changing volume in song select with arrow keys when pressing alt --- osu.Game/Screens/Select/BeatmapCarousel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index bf2382c4ae..da01ac5f95 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -436,7 +436,7 @@ namespace osu.Game.Screens.Select break; } - if (direction == 0) + if (direction == 0 || e.AltPressed) return base.OnKeyDown(e); SelectNext(direction, skipDifficulties); From 20466d79df37e8671badf7bd12f7dc66b0bcea10 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 14 Jan 2020 14:18:28 +0900 Subject: [PATCH 055/203] Update netcore version --- .idea/.idea.osu.Desktop/.idea/runConfigurations/osu_SDL.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.idea/.idea.osu.Desktop/.idea/runConfigurations/osu_SDL.xml b/.idea/.idea.osu.Desktop/.idea/runConfigurations/osu_SDL.xml index 1fd10e0e1a..d85a0ae44c 100644 --- a/.idea/.idea.osu.Desktop/.idea/runConfigurations/osu_SDL.xml +++ b/.idea/.idea.osu.Desktop/.idea/runConfigurations/osu_SDL.xml @@ -1,6 +1,6 @@ -