From 651706b10e4ba85bea3faba3ccf70c2736cbf5aa Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 26 Mar 2019 16:17:20 +0900 Subject: [PATCH 001/120] Account for user/system offsets when deciding on an initial seek time Closes #3043 Remove "AllowLeadIn" flag --- osu.Game/Screens/Play/GameplayClockContainer.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/osu.Game/Screens/Play/GameplayClockContainer.cs b/osu.Game/Screens/Play/GameplayClockContainer.cs index c151e598f7..f6a23575e9 100644 --- a/osu.Game/Screens/Play/GameplayClockContainer.cs +++ b/osu.Game/Screens/Play/GameplayClockContainer.cs @@ -26,6 +26,10 @@ namespace osu.Game.Screens.Play private readonly WorkingBeatmap beatmap; private readonly IReadOnlyList mods; + private readonly bool allowLeadIn; + + private readonly double gameplayStartTime; + /// /// The original source (usually a 's track). /// @@ -60,6 +64,8 @@ namespace osu.Game.Screens.Play private readonly FramedOffsetClock platformOffsetClock; + private double totalOffset => userOffsetClock.Offset + platformOffsetClock.Offset; + public GameplayClockContainer(WorkingBeatmap beatmap, IReadOnlyList mods, double gameplayStartTime) { this.beatmap = beatmap; @@ -93,6 +99,9 @@ namespace osu.Game.Screens.Play userAudioOffset = config.GetBindable(OsuSetting.AudioOffset); userAudioOffset.BindValueChanged(offset => userOffsetClock.Offset = offset.NewValue, true); + adjustableClock.Seek(Math.Min(0, gameplayStartTime - totalOffset - (allowLeadIn ? beatmap.BeatmapInfo.AudioLeadIn : 0))); + adjustableClock.ProcessFrame(); + UserPlaybackRate.ValueChanged += _ => updateRate(); Seek(Math.Min(-beatmap.BeatmapInfo.AudioLeadIn, gameplayStartTime)); From d1d1c4ee7a5df46e20330b28b293dc700c9da7e4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 26 Mar 2019 16:13:58 +0900 Subject: [PATCH 002/120] Add lead-in tests --- .../Visual/Gameplay/TestCaseLeadIn.cs | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs diff --git a/osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs b/osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs new file mode 100644 index 0000000000..0186ba1da1 --- /dev/null +++ b/osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs @@ -0,0 +1,88 @@ +// 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 NUnit.Framework; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Shapes; +using osu.Game.Beatmaps; +using osu.Game.Graphics.Sprites; +using osu.Game.Rulesets; +using osu.Game.Screens.Play; +using osu.Game.Tests.Beatmaps; +using osuTK.Graphics; + +namespace osu.Game.Tests.Visual.Gameplay +{ + public class TestCaseLeadIn : RateAdjustedBeatmapTestCase + { + private Ruleset ruleset; + + private LeadInPlayer player; + + [BackgroundDependencyLoader] + private void load(RulesetStore rulesets) + { + Add(new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + Depth = int.MaxValue + }); + + ruleset = rulesets.AvailableRulesets.First().CreateInstance(); + } + + [Test] + public void TestShortLeadIn() + { + AddStep("create player", () => loadPlayerWithBeatmap(new TestBeatmap(ruleset.RulesetInfo) { BeatmapInfo = { AudioLeadIn = 1000 } })); + AddUntilStep("correct lead-in", () => player.FirstFrameClockTime == 0); + } + + [Test] + public void TestLongLeadIn() + { + AddStep("create player", () => loadPlayerWithBeatmap(new TestBeatmap(ruleset.RulesetInfo) { BeatmapInfo = { AudioLeadIn = 10000 } })); + AddUntilStep("correct lead-in", () => player.FirstFrameClockTime == player.GameplayStartTime - 10000); + } + + private void loadPlayerWithBeatmap(IBeatmap beatmap) + { + Beatmap.Value = new TestWorkingBeatmap(beatmap, Clock); + + LoadScreen(player = new LeadInPlayer + { + AllowPause = false, + AllowResults = false, + }); + } + + private class LeadInPlayer : Player + { + public double? FirstFrameClockTime; + + public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer; + + public double GameplayStartTime => DrawableRuleset.GameplayStartTime; + + public double GameplayClockTime => GameplayClockContainer.GameplayClock.CurrentTime; + + protected override void UpdateAfterChildren() + { + base.UpdateAfterChildren(); + if (!FirstFrameClockTime.HasValue) + { + FirstFrameClockTime = GameplayClockContainer.GameplayClock.CurrentTime; + AddInternal(new OsuSpriteText + { + Text = $"GameplayStartTime: {DrawableRuleset.GameplayStartTime} " + + $"LeadInTime: {Beatmap.Value.BeatmapInfo.AudioLeadIn} " + + $"FirstFrameClockTime: {FirstFrameClockTime}" + }); + } + } + } + } +} From e03a664970e39158396b478dfef1f6aa7e0574b3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 26 Mar 2019 16:18:15 +0900 Subject: [PATCH 003/120] Fix lead-in logic to match stable Also adds storyboard event priority support. --- osu.Game/Screens/Play/GameplayClock.cs | 1 - osu.Game/Screens/Play/GameplayClockContainer.cs | 8 +++++++- osu.Game/Storyboards/Storyboard.cs | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/GameplayClock.cs b/osu.Game/Screens/Play/GameplayClock.cs index b1948d02d5..6c9dacfc39 100644 --- a/osu.Game/Screens/Play/GameplayClock.cs +++ b/osu.Game/Screens/Play/GameplayClock.cs @@ -34,7 +34,6 @@ namespace osu.Game.Screens.Play public void ProcessFrame() { // we do not want to process the underlying clock. - // this is handled by PauseContainer. } public double ElapsedFrameTime => underlyingClock.ElapsedFrameTime; diff --git a/osu.Game/Screens/Play/GameplayClockContainer.cs b/osu.Game/Screens/Play/GameplayClockContainer.cs index f6a23575e9..7abdc8ef66 100644 --- a/osu.Game/Screens/Play/GameplayClockContainer.cs +++ b/osu.Game/Screens/Play/GameplayClockContainer.cs @@ -99,7 +99,13 @@ namespace osu.Game.Screens.Play userAudioOffset = config.GetBindable(OsuSetting.AudioOffset); userAudioOffset.BindValueChanged(offset => userOffsetClock.Offset = offset.NewValue, true); - adjustableClock.Seek(Math.Min(0, gameplayStartTime - totalOffset - (allowLeadIn ? beatmap.BeatmapInfo.AudioLeadIn : 0))); + double startTime = -beatmap.BeatmapInfo.AudioLeadIn; + + startTime = Math.Min(startTime, beatmap.Storyboard.FirstEventTime); + startTime = Math.Min(startTime, gameplayStartTime); + startTime = Math.Min(startTime, 0); + + Seek(startTime); adjustableClock.ProcessFrame(); UserPlaybackRate.ValueChanged += _ => updateRate(); diff --git a/osu.Game/Storyboards/Storyboard.cs b/osu.Game/Storyboards/Storyboard.cs index 3d988c5fe3..401a7ce25a 100644 --- a/osu.Game/Storyboards/Storyboard.cs +++ b/osu.Game/Storyboards/Storyboard.cs @@ -17,6 +17,8 @@ namespace osu.Game.Storyboards public bool HasDrawable => Layers.Any(l => l.Elements.Any(e => e.IsDrawable)); + public double FirstEventTime => Layers.Min(l => l.Elements.FirstOrDefault()?.StartTime ?? 0); + public Storyboard() { layers.Add("Background", new StoryboardLayer("Background", 3)); From a2fbcb2bd39e756503d6e98a9cf25fb57dba021e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 31 May 2019 15:58:46 +0900 Subject: [PATCH 004/120] Fix rebase regressions --- osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs | 14 ++++++++------ osu.Game/Screens/Play/GameplayClockContainer.cs | 6 ------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs b/osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs index 0186ba1da1..33f1e4062f 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs @@ -15,7 +15,7 @@ using osuTK.Graphics; namespace osu.Game.Tests.Visual.Gameplay { - public class TestCaseLeadIn : RateAdjustedBeatmapTestCase + public class TestCaseLeadIn : RateAdjustedBeatmapTestScene { private Ruleset ruleset; @@ -52,15 +52,16 @@ namespace osu.Game.Tests.Visual.Gameplay { Beatmap.Value = new TestWorkingBeatmap(beatmap, Clock); - LoadScreen(player = new LeadInPlayer - { - AllowPause = false, - AllowResults = false, - }); + LoadScreen(player = new LeadInPlayer()); } private class LeadInPlayer : Player { + public LeadInPlayer() + : base(false, false) + { + } + public double? FirstFrameClockTime; public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer; @@ -72,6 +73,7 @@ namespace osu.Game.Tests.Visual.Gameplay protected override void UpdateAfterChildren() { base.UpdateAfterChildren(); + if (!FirstFrameClockTime.HasValue) { FirstFrameClockTime = GameplayClockContainer.GameplayClock.CurrentTime; diff --git a/osu.Game/Screens/Play/GameplayClockContainer.cs b/osu.Game/Screens/Play/GameplayClockContainer.cs index 7abdc8ef66..d718424b29 100644 --- a/osu.Game/Screens/Play/GameplayClockContainer.cs +++ b/osu.Game/Screens/Play/GameplayClockContainer.cs @@ -26,10 +26,6 @@ namespace osu.Game.Screens.Play private readonly WorkingBeatmap beatmap; private readonly IReadOnlyList mods; - private readonly bool allowLeadIn; - - private readonly double gameplayStartTime; - /// /// The original source (usually a 's track). /// @@ -91,8 +87,6 @@ namespace osu.Game.Screens.Play GameplayClock.IsPaused.BindTo(IsPaused); } - private double totalOffset => userOffsetClock.Offset + platformOffsetClock.Offset; - [BackgroundDependencyLoader] private void load(OsuConfigManager config) { From 87974850ddcfdbd55cb332b72016c21f880c91a6 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 7 Aug 2019 08:42:43 +0300 Subject: [PATCH 005/120] Initial implementation --- .../Online/TestSceneLeaderboardModSelector.cs | 63 ++++++++ .../BeatmapSet/LeaderboardModSelector.cs | 136 ++++++++++++++++++ osu.Game/Overlays/Mods/ModButton.cs | 2 +- osu.Game/Rulesets/Mods/ModType.cs | 3 +- osu.Game/Rulesets/UI/ModIcon.cs | 27 ++-- 5 files changed, 213 insertions(+), 18 deletions(-) create mode 100644 osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs create mode 100644 osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs new file mode 100644 index 0000000000..eb7fe5591d --- /dev/null +++ b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs @@ -0,0 +1,63 @@ +// 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.Overlays.BeatmapSet; +using System; +using System.Collections.Generic; +using osu.Framework.Graphics; +using osu.Game.Rulesets.Osu; +using osu.Game.Rulesets.Mania; +using osu.Game.Rulesets.Taiko; +using osu.Game.Rulesets.Catch; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Bindables; +using osu.Game.Rulesets; + +namespace osu.Game.Tests.Visual.Online +{ + public class TestSceneLeaderboardModSelector : OsuTestScene + { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(LeaderboardModSelector), + }; + + public TestSceneLeaderboardModSelector() + { + LeaderboardModSelector modSelector; + FillFlowContainer selectedMods; + Bindable ruleset = new Bindable(); + + Add(selectedMods = new FillFlowContainer + { + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, + }); + + Add(modSelector = new LeaderboardModSelector + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Ruleset = { BindTarget = ruleset } + }); + + modSelector.SelectedMods.BindValueChanged(mods => + { + selectedMods.Clear(); + + foreach (var mod in mods.NewValue) + selectedMods.Add(new SpriteText + { + Text = mod.Acronym, + }); + }); + + AddStep("osu mods", () => ruleset.Value = new OsuRuleset().RulesetInfo); + AddStep("mania mods", () => ruleset.Value = new ManiaRuleset().RulesetInfo); + AddStep("taiko mods", () => ruleset.Value = new TaikoRuleset().RulesetInfo); + AddStep("catch mods", () => ruleset.Value = new CatchRuleset().RulesetInfo); + AddStep("Deselect all", () => modSelector.DeselectAll()); + } + } +} diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs new file mode 100644 index 0000000000..99c51813c5 --- /dev/null +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -0,0 +1,136 @@ +// 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.Graphics.Containers; +using osu.Framework.Graphics; +using osu.Game.Rulesets.Mods; +using osu.Framework.Bindables; +using System.Collections.Generic; +using osu.Game.Rulesets; +using osuTK; +using osu.Game.Rulesets.UI; +using osu.Framework.Input.Events; +using osu.Game.Graphics.UserInterface; +using osuTK.Graphics; +using System; +using System.Linq; +using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Framework.Graphics.Sprites; + +namespace osu.Game.Overlays.BeatmapSet +{ + public class LeaderboardModSelector : Container + { + public readonly Bindable> SelectedMods = new Bindable>(); + public readonly Bindable Ruleset = new Bindable(); + + private readonly FillFlowContainer modsContainer; + + public LeaderboardModSelector() + { + AutoSizeAxes = Axes.Y; + RelativeSizeAxes = Axes.X; + Child = modsContainer = new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Full, + Spacing = new Vector2(4), + }; + + Ruleset.BindValueChanged(onRulesetChanged); + } + + private void onRulesetChanged(ValueChangedEvent ruleset) + { + SelectedMods.Value = new List(); + + modsContainer.Clear(); + + if (ruleset.NewValue == null) + return; + + modsContainer.Add(new ModButton(new NoMod())); + + foreach (var mod in ruleset.NewValue.CreateInstance().GetAllMods()) + if (mod.Ranked) + modsContainer.Add(new ModButton(mod)); + + foreach (var mod in modsContainer) + mod.OnSelectionChanged += selectionChanged; + } + + private void selectionChanged(Mod mod, bool selected) + { + var mods = SelectedMods.Value.ToList(); + + if (selected) + mods.Add(mod); + else + mods.Remove(mod); + + SelectedMods.Value = mods; + } + + public void DeselectAll() => modsContainer.ForEach(mod => mod.Selected.Value = false); + + private class ModButton : ModIcon + { + private const float mod_scale = 0.4f; + private const int duration = 200; + + public readonly BindableBool Selected = new BindableBool(); + public Action OnSelectionChanged; + + public ModButton(Mod mod) + : base(mod) + { + Scale = new Vector2(mod_scale); + Add(new HoverClickSounds()); + + Selected.BindValueChanged(selected => + { + updateState(); + OnSelectionChanged?.Invoke(mod, selected.NewValue); + }, true); + } + + protected override bool OnClick(ClickEvent e) + { + Selected.Value = !Selected.Value; + return base.OnClick(e); + } + + protected override bool OnHover(HoverEvent e) + { + updateState(); + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + base.OnHoverLost(e); + updateState(); + } + + private void updateState() + { + this.FadeColour(IsHovered || Selected.Value ? Color4.White : Color4.Gray, duration, Easing.OutQuint); + } + } + + private class NoMod : Mod + { + public override string Name => "NoMod"; + + public override string Acronym => "NM"; + + public override double ScoreMultiplier => 1; + + public override IconUsage Icon => FontAwesome.Solid.Ban; + + public override ModType Type => ModType.Custom; + } + } +} diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index fa1ee500a8..7b8745cf42 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -96,7 +96,7 @@ namespace osu.Game.Overlays.Mods } } - foregroundIcon.Highlighted = Selected; + foregroundIcon.Highlighted.Value = Selected; SelectionChanged?.Invoke(SelectedMod); return true; diff --git a/osu.Game/Rulesets/Mods/ModType.cs b/osu.Game/Rulesets/Mods/ModType.cs index e3c82e42f5..1cdc4415ac 100644 --- a/osu.Game/Rulesets/Mods/ModType.cs +++ b/osu.Game/Rulesets/Mods/ModType.cs @@ -10,6 +10,7 @@ namespace osu.Game.Rulesets.Mods Conversion, Automation, Fun, - System + System, + Custom } } diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index 86feea09a8..962263adba 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -11,11 +11,14 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Rulesets.Mods; using osuTK; +using osu.Framework.Bindables; namespace osu.Game.Rulesets.UI { public class ModIcon : Container, IHasTooltip { + public readonly BindableBool Highlighted = new BindableBool(); + private readonly SpriteIcon modIcon; private readonly SpriteIcon background; @@ -96,27 +99,19 @@ namespace osu.Game.Rulesets.UI backgroundColour = colours.Pink; highlightedColour = colours.PinkLight; break; - } - applyStyle(); - } - - private bool highlighted; - - public bool Highlighted - { - get => highlighted; - - set - { - highlighted = value; - applyStyle(); + case ModType.Custom: + backgroundColour = colours.Gray6; + highlightedColour = colours.Gray7; + modIcon.Colour = colours.Yellow; + break; } } - private void applyStyle() + protected override void LoadComplete() { - background.Colour = highlighted ? highlightedColour : backgroundColour; + base.LoadComplete(); + Highlighted.BindValueChanged(highlighted => background.Colour = highlighted.NewValue ? highlightedColour : backgroundColour, true); } } } From 0070f6b26072b391e3989eb880261bc632ce41fb Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 12 Aug 2019 14:49:08 +0300 Subject: [PATCH 006/120] Use CompositeDrawable as a parent class --- osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index 99c51813c5..399cd4a49a 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -19,7 +19,7 @@ using osu.Framework.Graphics.Sprites; namespace osu.Game.Overlays.BeatmapSet { - public class LeaderboardModSelector : Container + public class LeaderboardModSelector : CompositeDrawable { public readonly Bindable> SelectedMods = new Bindable>(); public readonly Bindable Ruleset = new Bindable(); @@ -30,7 +30,7 @@ namespace osu.Game.Overlays.BeatmapSet { AutoSizeAxes = Axes.Y; RelativeSizeAxes = Axes.X; - Child = modsContainer = new FillFlowContainer + InternalChild = modsContainer = new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, From 21af39032749fdb8da92fd773a5063f03ab955c6 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 12 Aug 2019 14:57:16 +0300 Subject: [PATCH 007/120] Move binding to LoadComplete --- osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index 399cd4a49a..99c1b54467 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -38,8 +38,12 @@ namespace osu.Game.Overlays.BeatmapSet Direction = FillDirection.Full, Spacing = new Vector2(4), }; + } - Ruleset.BindValueChanged(onRulesetChanged); + protected override void LoadComplete() + { + base.LoadComplete(); + Ruleset.BindValueChanged(onRulesetChanged, true); } private void onRulesetChanged(ValueChangedEvent ruleset) From 62a91e4aaab46c458152233ef4208278dc635e4b Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 12 Aug 2019 15:20:21 +0300 Subject: [PATCH 008/120] Add the ability to override Highlighted action to the ModIcon --- .../Overlays/BeatmapSet/LeaderboardModSelector.cs | 14 ++++++++++++-- osu.Game/Rulesets/UI/ModIcon.cs | 13 +++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index 99c1b54467..03d2e6ce4b 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -92,11 +92,16 @@ namespace osu.Game.Overlays.BeatmapSet { Scale = new Vector2(mod_scale); Add(new HoverClickSounds()); + } + + protected override void LoadComplete() + { + base.LoadComplete(); Selected.BindValueChanged(selected => { updateState(); - OnSelectionChanged?.Invoke(mod, selected.NewValue); + OnSelectionChanged?.Invoke(Mod, selected.NewValue); }, true); } @@ -120,7 +125,12 @@ namespace osu.Game.Overlays.BeatmapSet private void updateState() { - this.FadeColour(IsHovered || Selected.Value ? Color4.White : Color4.Gray, duration, Easing.OutQuint); + Highlighted.Value = (IsHovered || Selected.Value) ? true : false; + } + + protected override void OnHighlightedChange(ValueChangedEvent highlighted) + { + this.FadeColour(highlighted.NewValue ? Color4.White : Color4.Gray, duration, Easing.OutQuint); } } diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index 962263adba..e713216f35 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -34,9 +34,11 @@ namespace osu.Game.Rulesets.UI public virtual string TooltipText { get; } + protected Mod Mod { get; private set; } + public ModIcon(Mod mod) { - if (mod == null) throw new ArgumentNullException(nameof(mod)); + Mod = mod ?? throw new ArgumentNullException(nameof(mod)); type = mod.Type; @@ -106,12 +108,19 @@ namespace osu.Game.Rulesets.UI modIcon.Colour = colours.Yellow; break; } + + background.Colour = backgroundColour; } protected override void LoadComplete() { base.LoadComplete(); - Highlighted.BindValueChanged(highlighted => background.Colour = highlighted.NewValue ? highlightedColour : backgroundColour, true); + Highlighted.BindValueChanged(OnHighlightedChange, true); + } + + protected virtual void OnHighlightedChange(ValueChangedEvent highlighted) + { + background.Colour = highlighted.NewValue ? highlightedColour : backgroundColour; } } } From b71c776e65c291df39a45a175bc8301d6e3661d7 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 12 Aug 2019 16:20:36 +0300 Subject: [PATCH 009/120] Add web-like hover behavior --- .../BeatmapSet/LeaderboardModSelector.cs | 39 +++++++++++++++++-- osu.Game/Rulesets/UI/ModIcon.cs | 2 +- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index 03d2e6ce4b..1e10c41478 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -57,12 +57,13 @@ namespace osu.Game.Overlays.BeatmapSet modsContainer.Add(new ModButton(new NoMod())); - foreach (var mod in ruleset.NewValue.CreateInstance().GetAllMods()) + ruleset.NewValue.CreateInstance().GetAllMods().ForEach(mod => + { if (mod.Ranked) modsContainer.Add(new ModButton(mod)); + }); - foreach (var mod in modsContainer) - mod.OnSelectionChanged += selectionChanged; + modsContainer.ForEach(button => button.OnSelectionChanged += selectionChanged); } private void selectionChanged(Mod mod, bool selected) @@ -74,11 +75,39 @@ namespace osu.Game.Overlays.BeatmapSet else mods.Remove(mod); + if (!mods.Any() && !IsHovered) + modsContainer.ForEach(button => button.Highlighted.Value = true); + SelectedMods.Value = mods; } + protected override bool OnHover(HoverEvent e) + { + if (!SelectedMods.Value.Any()) + dehighlightAll(); + + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + base.OnHoverLost(e); + + if (!SelectedMods.Value.Any()) + modsContainer.ForEach(mod => mod.Highlighted.Value = true); + } + public void DeselectAll() => modsContainer.ForEach(mod => mod.Selected.Value = false); + private void dehighlightAll() + { + modsContainer.ForEach(button => + { + if (!button.IsHovered) + button.Highlighted.Value = false; + }); + } + private class ModButton : ModIcon { private const float mod_scale = 0.4f; @@ -98,11 +127,13 @@ namespace osu.Game.Overlays.BeatmapSet { base.LoadComplete(); + Highlighted.Value = true; + Selected.BindValueChanged(selected => { updateState(); OnSelectionChanged?.Invoke(Mod, selected.NewValue); - }, true); + }); } protected override bool OnClick(ClickEvent e) diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index e713216f35..1bcd2dc780 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -115,7 +115,7 @@ namespace osu.Game.Rulesets.UI protected override void LoadComplete() { base.LoadComplete(); - Highlighted.BindValueChanged(OnHighlightedChange, true); + Highlighted.BindValueChanged(OnHighlightedChange); } protected virtual void OnHighlightedChange(ValueChangedEvent highlighted) From 86c9d5251faea12d24347dc68ae1c94ea3c738db Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 12 Aug 2019 16:28:53 +0300 Subject: [PATCH 010/120] Remove unused function --- .../Overlays/BeatmapSet/LeaderboardModSelector.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index 1e10c41478..fffbc400b1 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -84,7 +84,11 @@ namespace osu.Game.Overlays.BeatmapSet protected override bool OnHover(HoverEvent e) { if (!SelectedMods.Value.Any()) - dehighlightAll(); + modsContainer.ForEach(button => + { + if (!button.IsHovered) + button.Highlighted.Value = false; + }); return base.OnHover(e); } @@ -99,15 +103,6 @@ namespace osu.Game.Overlays.BeatmapSet public void DeselectAll() => modsContainer.ForEach(mod => mod.Selected.Value = false); - private void dehighlightAll() - { - modsContainer.ForEach(button => - { - if (!button.IsHovered) - button.Highlighted.Value = false; - }); - } - private class ModButton : ModIcon { private const float mod_scale = 0.4f; From cf92d6b1b01174666b484580242ad99891a839e0 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 12 Aug 2019 16:32:04 +0300 Subject: [PATCH 011/120] Add highlightAll function to avoid duplication --- osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index fffbc400b1..1489907589 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -76,7 +76,7 @@ namespace osu.Game.Overlays.BeatmapSet mods.Remove(mod); if (!mods.Any() && !IsHovered) - modsContainer.ForEach(button => button.Highlighted.Value = true); + highlightAll(); SelectedMods.Value = mods; } @@ -98,11 +98,13 @@ namespace osu.Game.Overlays.BeatmapSet base.OnHoverLost(e); if (!SelectedMods.Value.Any()) - modsContainer.ForEach(mod => mod.Highlighted.Value = true); + highlightAll(); } public void DeselectAll() => modsContainer.ForEach(mod => mod.Selected.Value = false); + private void highlightAll() => modsContainer.ForEach(mod => mod.Highlighted.Value = true); + private class ModButton : ModIcon { private const float mod_scale = 0.4f; From 1bfb87fcdd01536874269a16ffcf13d6e7ffcc7c Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 12 Aug 2019 16:41:35 +0300 Subject: [PATCH 012/120] Remove redundant conditional ternary expression --- osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index 1489907589..66d78f927a 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -28,8 +28,7 @@ namespace osu.Game.Overlays.BeatmapSet public LeaderboardModSelector() { - AutoSizeAxes = Axes.Y; - RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Both; InternalChild = modsContainer = new FillFlowContainer { Anchor = Anchor.Centre, @@ -151,10 +150,7 @@ namespace osu.Game.Overlays.BeatmapSet updateState(); } - private void updateState() - { - Highlighted.Value = (IsHovered || Selected.Value) ? true : false; - } + private void updateState() => Highlighted.Value = IsHovered || Selected.Value; protected override void OnHighlightedChange(ValueChangedEvent highlighted) { From 0cf4db899ff94292bac6945e8296c93931f64769 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 19 Sep 2019 17:03:52 +0300 Subject: [PATCH 013/120] Few cleanups --- .../Visual/Online/TestSceneLeaderboardModSelector.cs | 9 +++++---- .../Overlays/BeatmapSet/LeaderboardModSelector.cs | 11 ++++------- osu.Game/Rulesets/UI/ModIcon.cs | 4 ++-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs index eb7fe5591d..3a64ac79f6 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs @@ -53,11 +53,12 @@ namespace osu.Game.Tests.Visual.Online }); }); - AddStep("osu mods", () => ruleset.Value = new OsuRuleset().RulesetInfo); - AddStep("mania mods", () => ruleset.Value = new ManiaRuleset().RulesetInfo); - AddStep("taiko mods", () => ruleset.Value = new TaikoRuleset().RulesetInfo); - AddStep("catch mods", () => ruleset.Value = new CatchRuleset().RulesetInfo); + AddStep("osu ruleset", () => ruleset.Value = new OsuRuleset().RulesetInfo); + AddStep("mania ruleset", () => ruleset.Value = new ManiaRuleset().RulesetInfo); + AddStep("taiko ruleset", () => ruleset.Value = new TaikoRuleset().RulesetInfo); + AddStep("catch ruleset", () => ruleset.Value = new CatchRuleset().RulesetInfo); AddStep("Deselect all", () => modSelector.DeselectAll()); + AddStep("null ruleset", () => ruleset.Value = null); } } } diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index 66d78f927a..d09464aba6 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -74,10 +74,10 @@ namespace osu.Game.Overlays.BeatmapSet else mods.Remove(mod); + SelectedMods.Value = mods; + if (!mods.Any() && !IsHovered) highlightAll(); - - SelectedMods.Value = mods; } protected override bool OnHover(HoverEvent e) @@ -116,6 +116,7 @@ namespace osu.Game.Overlays.BeatmapSet : base(mod) { Scale = new Vector2(mod_scale); + Highlighted.Value = true; Add(new HoverClickSounds()); } @@ -123,8 +124,6 @@ namespace osu.Game.Overlays.BeatmapSet { base.LoadComplete(); - Highlighted.Value = true; - Selected.BindValueChanged(selected => { updateState(); @@ -152,10 +151,8 @@ namespace osu.Game.Overlays.BeatmapSet private void updateState() => Highlighted.Value = IsHovered || Selected.Value; - protected override void OnHighlightedChange(ValueChangedEvent highlighted) - { + protected override void OnHighlightedChanged(ValueChangedEvent highlighted) => this.FadeColour(highlighted.NewValue ? Color4.White : Color4.Gray, duration, Easing.OutQuint); - } } private class NoMod : Mod diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index d3607757ab..b54ddf8f12 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -114,10 +114,10 @@ namespace osu.Game.Rulesets.UI protected override void LoadComplete() { base.LoadComplete(); - Highlighted.BindValueChanged(OnHighlightedChange); + Highlighted.BindValueChanged(OnHighlightedChanged, true); } - protected virtual void OnHighlightedChange(ValueChangedEvent highlighted) + protected virtual void OnHighlightedChanged(ValueChangedEvent highlighted) { background.Colour = highlighted.NewValue ? highlightedColour : backgroundColour; } From e7118a9272600b7e4ac2ffddef8bbecab336d12d Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Fri, 20 Sep 2019 23:47:21 +0300 Subject: [PATCH 014/120] Use System mod type for NoMod --- osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs | 2 +- osu.Game/Rulesets/Mods/ModType.cs | 3 +-- osu.Game/Rulesets/UI/ModIcon.cs | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index d09464aba6..4b6fd5bfc2 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -165,7 +165,7 @@ namespace osu.Game.Overlays.BeatmapSet public override IconUsage Icon => FontAwesome.Solid.Ban; - public override ModType Type => ModType.Custom; + public override ModType Type => ModType.System; } } } diff --git a/osu.Game/Rulesets/Mods/ModType.cs b/osu.Game/Rulesets/Mods/ModType.cs index 1cdc4415ac..e3c82e42f5 100644 --- a/osu.Game/Rulesets/Mods/ModType.cs +++ b/osu.Game/Rulesets/Mods/ModType.cs @@ -10,7 +10,6 @@ namespace osu.Game.Rulesets.Mods Conversion, Automation, Fun, - System, - Custom + System } } diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index b54ddf8f12..19211e0c80 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -101,7 +101,7 @@ namespace osu.Game.Rulesets.UI highlightedColour = colours.PinkLight; break; - case ModType.Custom: + case ModType.System: backgroundColour = colours.Gray6; highlightedColour = colours.Gray7; modIcon.Colour = colours.Yellow; From b8d147a3b41586c2e10556145a04aea69193e57a Mon Sep 17 00:00:00 2001 From: LeNitrous Date: Tue, 24 Sep 2019 17:42:06 +0800 Subject: [PATCH 015/120] introduce main menu background modes --- osu.Game/Configuration/BackgroundMode.cs | 12 +++++++ osu.Game/Configuration/OsuConfigManager.cs | 5 ++- .../Graphics/Backgrounds/BeatmapBackground.cs | 28 ++++++++++++++++ .../Sections/Audio/MainMenuSettings.cs | 6 ++++ .../Backgrounds/BackgroundScreenBeatmap.cs | 17 ---------- .../Backgrounds/BackgroundScreenDefault.cs | 33 +++++++++++++++++-- 6 files changed, 80 insertions(+), 21 deletions(-) create mode 100644 osu.Game/Configuration/BackgroundMode.cs create mode 100644 osu.Game/Graphics/Backgrounds/BeatmapBackground.cs diff --git a/osu.Game/Configuration/BackgroundMode.cs b/osu.Game/Configuration/BackgroundMode.cs new file mode 100644 index 0000000000..21554891ca --- /dev/null +++ b/osu.Game/Configuration/BackgroundMode.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.Configuration +{ + public enum BackgroundMode + { + Default, + Seasonal, + Beatmap + } +} diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 64b1f2d7bc..9b964e8893 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -117,6 +117,8 @@ namespace osu.Game.Configuration Set(OsuSetting.UIHoldActivationDelay, 200, 0, 500); Set(OsuSetting.IntroSequence, IntroSequence.Triangles); + + Set(OsuSetting.BackgroundMode, BackgroundMode.Default); } public OsuConfigManager(Storage storage) @@ -186,6 +188,7 @@ namespace osu.Game.Configuration UIScale, IntroSequence, UIHoldActivationDelay, - HitLighting + HitLighting, + BackgroundMode } } diff --git a/osu.Game/Graphics/Backgrounds/BeatmapBackground.cs b/osu.Game/Graphics/Backgrounds/BeatmapBackground.cs new file mode 100644 index 0000000000..40c6dae43c --- /dev/null +++ b/osu.Game/Graphics/Backgrounds/BeatmapBackground.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.Framework.Allocation; +using osu.Framework.Graphics.Textures; +using osu.Game.Beatmaps; + +namespace osu.Game.Graphics.Backgrounds +{ + public class BeatmapBackground : Background + { + public readonly WorkingBeatmap Beatmap; + + private readonly string fallbackTextureName; + + public BeatmapBackground(WorkingBeatmap beatmap, string fallbackTextureName = @"Backgrounds/bg1") + { + Beatmap = beatmap; + this.fallbackTextureName = fallbackTextureName; + } + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + Sprite.Texture = Beatmap?.Background ?? textures.Get(fallbackTextureName); + } + } +} \ No newline at end of file diff --git a/osu.Game/Overlays/Settings/Sections/Audio/MainMenuSettings.cs b/osu.Game/Overlays/Settings/Sections/Audio/MainMenuSettings.cs index 5ccdc952ba..76a6aafe45 100644 --- a/osu.Game/Overlays/Settings/Sections/Audio/MainMenuSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Audio/MainMenuSettings.cs @@ -34,6 +34,12 @@ namespace osu.Game.Overlays.Settings.Sections.Audio Bindable = config.GetBindable(OsuSetting.IntroSequence), Items = Enum.GetValues(typeof(IntroSequence)).Cast() }, + new SettingsDropdown + { + LabelText = "Background", + Bindable = config.GetBindable(OsuSetting.BackgroundMode), + Items = Enum.GetValues(typeof(BackgroundMode)).Cast() + } }; } } diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 2730b0b90d..3de0ab191c 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -6,7 +6,6 @@ using System.Threading; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; -using osu.Framework.Graphics.Textures; using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Graphics.Backgrounds; @@ -107,22 +106,6 @@ namespace osu.Game.Screens.Backgrounds return base.Equals(other) && beatmap == otherBeatmapBackground.Beatmap; } - protected class BeatmapBackground : Background - { - public readonly WorkingBeatmap Beatmap; - - public BeatmapBackground(WorkingBeatmap beatmap) - { - Beatmap = beatmap; - } - - [BackgroundDependencyLoader] - private void load(TextureStore textures) - { - Sprite.Texture = Beatmap?.Background ?? textures.Get(@"Backgrounds/bg1"); - } - } - public class DimmableBackground : UserDimContainer { /// diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs index 2d7fe6a6a3..a8ba17ef49 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs @@ -6,6 +6,8 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.MathUtils; using osu.Framework.Threading; +using osu.Game.Beatmaps; +using osu.Game.Configuration; using osu.Game.Graphics.Backgrounds; using osu.Game.Online.API; using osu.Game.Skinning; @@ -24,6 +26,10 @@ namespace osu.Game.Screens.Backgrounds private Bindable user; private Bindable skin; + private Bindable mode; + + [Resolved] + private IBindable beatmap { get; set; } public BackgroundScreenDefault(bool animateOnEnter = true) : base(animateOnEnter) @@ -31,13 +37,15 @@ namespace osu.Game.Screens.Backgrounds } [BackgroundDependencyLoader] - private void load(IAPIProvider api, SkinManager skinManager) + private void load(IAPIProvider api, SkinManager skinManager, OsuConfigManager config) { user = api.LocalUser.GetBoundCopy(); skin = skinManager.CurrentSkin.GetBoundCopy(); + mode = config.GetBindable(OsuSetting.BackgroundMode); user.ValueChanged += _ => Next(); skin.ValueChanged += _ => Next(); + mode.ValueChanged += _ => Next(); currentDisplay = RNG.Next(0, background_count); @@ -66,9 +74,28 @@ namespace osu.Game.Screens.Backgrounds Background newBackground; if (user.Value?.IsSupporter ?? false) - newBackground = new SkinnedBackground(skin.Value, backgroundName); + { + switch (mode.Value) + { + case BackgroundMode.Beatmap: + newBackground = new BeatmapBackground(beatmap.Value, backgroundName); + break; + + default: + newBackground = new SkinnedBackground(skin.Value, backgroundName); + break; + } + } else - newBackground = new Background(backgroundName); + { + switch (mode.Value) + { + case BackgroundMode.Seasonal: + default: + newBackground = new Background(backgroundName); + break; + } + } newBackground.Depth = currentDisplay; From 03947e5b8532b21f52dcc73f755b2d31c64c000b Mon Sep 17 00:00:00 2001 From: LeNitrous Date: Tue, 24 Sep 2019 19:49:46 +0800 Subject: [PATCH 016/120] change background for ScalingContainer --- osu.Game/Graphics/Containers/ScalingContainer.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/osu.Game/Graphics/Containers/ScalingContainer.cs b/osu.Game/Graphics/Containers/ScalingContainer.cs index 8f07c3a656..84053ee5d9 100644 --- a/osu.Game/Graphics/Containers/ScalingContainer.cs +++ b/osu.Game/Graphics/Containers/ScalingContainer.cs @@ -6,6 +6,7 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Screens; +using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Screens; using osu.Game.Screens.Backgrounds; @@ -154,6 +155,15 @@ namespace osu.Game.Graphics.Containers private class ScalingBackgroundScreen : BackgroundScreenDefault { + private Bindable beatmap; + + [BackgroundDependencyLoader] + private void load(IBindable beatmap) + { + this.beatmap = (Bindable)beatmap; + this.beatmap.ValueChanged += _ => Next(); + } + public override void OnEntering(IScreen last) { this.FadeInFromZero(4000, Easing.OutQuint); From 0bc59e17dc30cfd240407cc3d9fc4928c55b6daa Mon Sep 17 00:00:00 2001 From: LeNitrous Date: Tue, 24 Sep 2019 21:56:32 +0800 Subject: [PATCH 017/120] remove Seasonal and apply suggestions --- osu.Game/Configuration/BackgroundMode.cs | 1 - osu.Game/Graphics/Containers/ScalingContainer.cs | 4 +--- .../Screens/Backgrounds/BackgroundScreenDefault.cs | 10 +--------- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/osu.Game/Configuration/BackgroundMode.cs b/osu.Game/Configuration/BackgroundMode.cs index 21554891ca..50d54f1eb2 100644 --- a/osu.Game/Configuration/BackgroundMode.cs +++ b/osu.Game/Configuration/BackgroundMode.cs @@ -6,7 +6,6 @@ namespace osu.Game.Configuration public enum BackgroundMode { Default, - Seasonal, Beatmap } } diff --git a/osu.Game/Graphics/Containers/ScalingContainer.cs b/osu.Game/Graphics/Containers/ScalingContainer.cs index 84053ee5d9..1701223f44 100644 --- a/osu.Game/Graphics/Containers/ScalingContainer.cs +++ b/osu.Game/Graphics/Containers/ScalingContainer.cs @@ -155,13 +155,11 @@ namespace osu.Game.Graphics.Containers private class ScalingBackgroundScreen : BackgroundScreenDefault { - private Bindable beatmap; [BackgroundDependencyLoader] private void load(IBindable beatmap) { - this.beatmap = (Bindable)beatmap; - this.beatmap.ValueChanged += _ => Next(); + beatmap.ValueChanged += _ => Next(); } public override void OnEntering(IScreen last) diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs index a8ba17ef49..93590b0543 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs @@ -87,15 +87,7 @@ namespace osu.Game.Screens.Backgrounds } } else - { - switch (mode.Value) - { - case BackgroundMode.Seasonal: - default: - newBackground = new Background(backgroundName); - break; - } - } + newBackground = new Background(backgroundName); newBackground.Depth = currentDisplay; From 851e42a444d642ed08e3505f5314398db8401a67 Mon Sep 17 00:00:00 2001 From: LeNitrous Date: Tue, 24 Sep 2019 22:57:29 +0800 Subject: [PATCH 018/120] avoid memory leak --- osu.Game/Graphics/Containers/ScalingContainer.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/ScalingContainer.cs b/osu.Game/Graphics/Containers/ScalingContainer.cs index 1701223f44..023d295b08 100644 --- a/osu.Game/Graphics/Containers/ScalingContainer.cs +++ b/osu.Game/Graphics/Containers/ScalingContainer.cs @@ -155,11 +155,13 @@ namespace osu.Game.Graphics.Containers private class ScalingBackgroundScreen : BackgroundScreenDefault { + private IBindable beatmap; [BackgroundDependencyLoader] private void load(IBindable beatmap) { - beatmap.ValueChanged += _ => Next(); + this.beatmap = beatmap.GetBoundCopy(); + this.beatmap.ValueChanged += _ => Next(); } public override void OnEntering(IScreen last) From 003af19e3f039985ec73565cee3d3ad7345e0e9b Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Wed, 9 Oct 2019 23:04:34 +0300 Subject: [PATCH 019/120] Introduce legacy skin configuration --- osu.Game/Skinning/LegacySkin.cs | 18 ++++++++++++++++-- osu.Game/Skinning/LegacySkinConfiguration.cs | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 osu.Game/Skinning/LegacySkinConfiguration.cs diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index fea15458e4..25703b30dc 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -26,6 +26,8 @@ namespace osu.Game.Skinning [CanBeNull] protected IResourceStore Samples; + protected new LegacySkinConfiguration Configuration => (LegacySkinConfiguration)base.Configuration; + public LegacySkin(SkinInfo skin, IResourceStore storage, AudioManager audioManager) : this(skin, new LegacySkinResourceStore(skin, storage), audioManager, "skin.ini") { @@ -37,9 +39,9 @@ namespace osu.Game.Skinning Stream stream = storage?.GetStream(filename); if (stream != null) using (LineBufferedReader reader = new LineBufferedReader(stream)) - Configuration = new LegacySkinDecoder().Decode(reader); + base.Configuration = new LegacySkinDecoder().Decode(reader); else - Configuration = new DefaultSkinConfiguration(); + base.Configuration = new LegacySkinConfiguration { LegacyVersion = LegacySkinConfiguration.LATEST_VERSION }; if (storage != null) { @@ -71,6 +73,18 @@ namespace osu.Game.Skinning case GlobalSkinColour colour: return SkinUtils.As(getCustomColour(colour.ToString())); + case LegacySkinConfigurations legacy: + switch (legacy) + { + case LegacySkinConfigurations.Version: + if (Configuration.LegacyVersion.HasValue) + return SkinUtils.As(new BindableDouble(Configuration.LegacyVersion.Value)); + + break; + } + + break; + case SkinCustomColourLookup customColour: return SkinUtils.As(getCustomColour(customColour.Lookup.ToString())); diff --git a/osu.Game/Skinning/LegacySkinConfiguration.cs b/osu.Game/Skinning/LegacySkinConfiguration.cs new file mode 100644 index 0000000000..022f613562 --- /dev/null +++ b/osu.Game/Skinning/LegacySkinConfiguration.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. + +namespace osu.Game.Skinning +{ + public class LegacySkinConfiguration : DefaultSkinConfiguration + { + public const double LATEST_VERSION = 2.5; + + /// + /// Legacy version of this skin. + /// + public double? LegacyVersion { get; internal set; } + } + + public enum LegacySkinConfigurations + { + Version, + } +} From 7f6541672c9c3d3e30673e47c7d7a1b0ab630f1b Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Wed, 9 Oct 2019 23:05:50 +0300 Subject: [PATCH 020/120] Parse legacy version of decoded skin to numerical --- osu.Game/Skinning/LegacySkinDecoder.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/osu.Game/Skinning/LegacySkinDecoder.cs b/osu.Game/Skinning/LegacySkinDecoder.cs index e97664e75e..75cd0a666d 100644 --- a/osu.Game/Skinning/LegacySkinDecoder.cs +++ b/osu.Game/Skinning/LegacySkinDecoder.cs @@ -5,14 +5,14 @@ using osu.Game.Beatmaps.Formats; namespace osu.Game.Skinning { - public class LegacySkinDecoder : LegacyDecoder + public class LegacySkinDecoder : LegacyDecoder { public LegacySkinDecoder() : base(1) { } - protected override void ParseLine(DefaultSkinConfiguration skin, Section section, string line) + protected override void ParseLine(LegacySkinConfiguration skin, Section section, string line) { if (section != Section.Colours) { @@ -32,6 +32,14 @@ namespace osu.Game.Skinning case @"Author": skin.SkinInfo.Creator = pair.Value; return; + + case @"Version": + if (pair.Value == "latest" || pair.Value == "User") + skin.LegacyVersion = LegacySkinConfiguration.LATEST_VERSION; + else if (double.TryParse(pair.Value, out var version)) + skin.LegacyVersion = version; + + return; } break; From 01ac19fdbb96cea3f36da3ce4b5ed39d1994658a Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Wed, 9 Oct 2019 23:06:32 +0300 Subject: [PATCH 021/120] Set legacy version of osu!classic skin to 2.0 --- osu.Game/Skinning/DefaultLegacySkin.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Skinning/DefaultLegacySkin.cs b/osu.Game/Skinning/DefaultLegacySkin.cs index 4b6eea6b6e..4c68ee938f 100644 --- a/osu.Game/Skinning/DefaultLegacySkin.cs +++ b/osu.Game/Skinning/DefaultLegacySkin.cs @@ -20,6 +20,8 @@ namespace osu.Game.Skinning new Color4(18, 124, 255, 255), new Color4(242, 24, 57, 255), }); + + Configuration.LegacyVersion = 2.0; } public static SkinInfo Info { get; } = new SkinInfo From d15db378ce2598a66f5bdad3958d964dbd1b869b Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Wed, 9 Oct 2019 23:06:53 +0300 Subject: [PATCH 022/120] Add tests for legacy skin decoding --- osu.Game.Tests/Resources/skin-20.ini | 2 ++ osu.Game.Tests/Resources/skin-latest.ini | 2 ++ osu.Game.Tests/Skins/LegacySkinDecoderTest.cs | 11 +++++++++++ 3 files changed, 15 insertions(+) create mode 100644 osu.Game.Tests/Resources/skin-20.ini create mode 100644 osu.Game.Tests/Resources/skin-latest.ini diff --git a/osu.Game.Tests/Resources/skin-20.ini b/osu.Game.Tests/Resources/skin-20.ini new file mode 100644 index 0000000000..947b56b2f9 --- /dev/null +++ b/osu.Game.Tests/Resources/skin-20.ini @@ -0,0 +1,2 @@ +[General] +Version: 2 \ No newline at end of file diff --git a/osu.Game.Tests/Resources/skin-latest.ini b/osu.Game.Tests/Resources/skin-latest.ini new file mode 100644 index 0000000000..32f500263f --- /dev/null +++ b/osu.Game.Tests/Resources/skin-latest.ini @@ -0,0 +1,2 @@ +[General] +Version: latest \ No newline at end of file diff --git a/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs b/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs index 0d96dd08da..8c85074456 100644 --- a/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs +++ b/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs @@ -56,5 +56,16 @@ namespace osu.Game.Tests.Skins Assert.AreEqual("TestValue", config.ConfigDictionary["TestLookup"]); } } + + [TestCase("skin-20.ini", 2.0)] + [TestCase("skin-latest.ini", LegacySkinConfiguration.LATEST_VERSION)] + [TestCase("skin-empty.ini", null)] + public void TestDecodeVersion(string filename, double? expected) + { + var decoder = new LegacySkinDecoder(); + using (var resStream = TestResources.OpenResource(filename)) + using (var stream = new LineBufferedReader(resStream)) + Assert.AreEqual(expected, decoder.Decode(stream).LegacyVersion); + } } } From 2cf17e0bf38455d465d2f59e7c9552255dde2766 Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Wed, 9 Oct 2019 23:33:25 +0300 Subject: [PATCH 023/120] Use decimal data type instead --- osu.Game.Tests/Skins/LegacySkinDecoderTest.cs | 28 +++++++++++++++---- osu.Game/Skinning/DefaultLegacySkin.cs | 2 +- osu.Game/Skinning/LegacySkin.cs | 2 +- osu.Game/Skinning/LegacySkinConfiguration.cs | 4 +-- osu.Game/Skinning/LegacySkinDecoder.cs | 2 +- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs b/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs index 8c85074456..4fee6942d0 100644 --- a/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs +++ b/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs @@ -57,15 +57,31 @@ namespace osu.Game.Tests.Skins } } - [TestCase("skin-20.ini", 2.0)] - [TestCase("skin-latest.ini", LegacySkinConfiguration.LATEST_VERSION)] - [TestCase("skin-empty.ini", null)] - public void TestDecodeVersion(string filename, double? expected) + [Test] + public void TestDecodeSpecifiedVersion() { var decoder = new LegacySkinDecoder(); - using (var resStream = TestResources.OpenResource(filename)) + using (var resStream = TestResources.OpenResource("skin-20.ini")) using (var stream = new LineBufferedReader(resStream)) - Assert.AreEqual(expected, decoder.Decode(stream).LegacyVersion); + Assert.AreEqual(2.0m, decoder.Decode(stream).LegacyVersion); + } + + [Test] + public void TestDecodeLatestVersion() + { + var decoder = new LegacySkinDecoder(); + using (var resStream = TestResources.OpenResource("skin-latest.ini")) + using (var stream = new LineBufferedReader(resStream)) + Assert.AreEqual(LegacySkinConfiguration.LATEST_VERSION, decoder.Decode(stream).LegacyVersion); + } + + [Test] + public void TestDecodeNoVersion() + { + var decoder = new LegacySkinDecoder(); + using (var resStream = TestResources.OpenResource("skin-empty.ini")) + using (var stream = new LineBufferedReader(resStream)) + Assert.IsNull(decoder.Decode(stream).LegacyVersion); } } } diff --git a/osu.Game/Skinning/DefaultLegacySkin.cs b/osu.Game/Skinning/DefaultLegacySkin.cs index 4c68ee938f..0caf2d19e9 100644 --- a/osu.Game/Skinning/DefaultLegacySkin.cs +++ b/osu.Game/Skinning/DefaultLegacySkin.cs @@ -21,7 +21,7 @@ namespace osu.Game.Skinning new Color4(242, 24, 57, 255), }); - Configuration.LegacyVersion = 2.0; + Configuration.LegacyVersion = 2.0m; } public static SkinInfo Info { get; } = new SkinInfo diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 25703b30dc..f6a366b21d 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -78,7 +78,7 @@ namespace osu.Game.Skinning { case LegacySkinConfigurations.Version: if (Configuration.LegacyVersion.HasValue) - return SkinUtils.As(new BindableDouble(Configuration.LegacyVersion.Value)); + return SkinUtils.As(new Bindable(Configuration.LegacyVersion.Value)); break; } diff --git a/osu.Game/Skinning/LegacySkinConfiguration.cs b/osu.Game/Skinning/LegacySkinConfiguration.cs index 022f613562..051d10747b 100644 --- a/osu.Game/Skinning/LegacySkinConfiguration.cs +++ b/osu.Game/Skinning/LegacySkinConfiguration.cs @@ -5,12 +5,12 @@ namespace osu.Game.Skinning { public class LegacySkinConfiguration : DefaultSkinConfiguration { - public const double LATEST_VERSION = 2.5; + public const decimal LATEST_VERSION = 2.5m; /// /// Legacy version of this skin. /// - public double? LegacyVersion { get; internal set; } + public decimal? LegacyVersion { get; internal set; } } public enum LegacySkinConfigurations diff --git a/osu.Game/Skinning/LegacySkinDecoder.cs b/osu.Game/Skinning/LegacySkinDecoder.cs index 75cd0a666d..ea087353a0 100644 --- a/osu.Game/Skinning/LegacySkinDecoder.cs +++ b/osu.Game/Skinning/LegacySkinDecoder.cs @@ -36,7 +36,7 @@ namespace osu.Game.Skinning case @"Version": if (pair.Value == "latest" || pair.Value == "User") skin.LegacyVersion = LegacySkinConfiguration.LATEST_VERSION; - else if (double.TryParse(pair.Value, out var version)) + else if (decimal.TryParse(pair.Value, out var version)) skin.LegacyVersion = version; return; From 55230a36dd089d49513f074ddcfc8b3070db056e Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Wed, 6 Nov 2019 19:58:07 +0300 Subject: [PATCH 024/120] Set correct legacy version --- osu.Game/Skinning/LegacySkinConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Skinning/LegacySkinConfiguration.cs b/osu.Game/Skinning/LegacySkinConfiguration.cs index 051d10747b..f9bf78b8ad 100644 --- a/osu.Game/Skinning/LegacySkinConfiguration.cs +++ b/osu.Game/Skinning/LegacySkinConfiguration.cs @@ -5,7 +5,7 @@ namespace osu.Game.Skinning { public class LegacySkinConfiguration : DefaultSkinConfiguration { - public const decimal LATEST_VERSION = 2.5m; + public const decimal LATEST_VERSION = 2.7m; /// /// Legacy version of this skin. From 502dcc566978b9bc2420d102e76ecbf51260b875 Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Wed, 6 Nov 2019 20:23:22 +0300 Subject: [PATCH 025/120] Fix incorrect skin version case --- osu.Game/Skinning/LegacySkinDecoder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Skinning/LegacySkinDecoder.cs b/osu.Game/Skinning/LegacySkinDecoder.cs index ea087353a0..7dcb7ea3ac 100644 --- a/osu.Game/Skinning/LegacySkinDecoder.cs +++ b/osu.Game/Skinning/LegacySkinDecoder.cs @@ -34,7 +34,7 @@ namespace osu.Game.Skinning return; case @"Version": - if (pair.Value == "latest" || pair.Value == "User") + if (pair.Value == "latest") skin.LegacyVersion = LegacySkinConfiguration.LATEST_VERSION; else if (decimal.TryParse(pair.Value, out var version)) skin.LegacyVersion = version; From 947602f70afcc6b58d473f0f36ceb28bddfe41b7 Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Wed, 6 Nov 2019 20:24:19 +0300 Subject: [PATCH 026/120] Specify why legacy version is nullable --- osu.Game/Skinning/LegacySkinConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Skinning/LegacySkinConfiguration.cs b/osu.Game/Skinning/LegacySkinConfiguration.cs index f9bf78b8ad..33c29cd47c 100644 --- a/osu.Game/Skinning/LegacySkinConfiguration.cs +++ b/osu.Game/Skinning/LegacySkinConfiguration.cs @@ -8,7 +8,7 @@ namespace osu.Game.Skinning public const decimal LATEST_VERSION = 2.7m; /// - /// Legacy version of this skin. + /// Legacy version of this skin. Null if no version was set to allow fallback to a parent skin version. /// public decimal? LegacyVersion { get; internal set; } } From ba14345107fc46fc1e00656d58a96e89a69d2abd Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Wed, 6 Nov 2019 20:27:55 +0300 Subject: [PATCH 027/120] Specify culture and number style --- osu.Game/Skinning/LegacySkinDecoder.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Skinning/LegacySkinDecoder.cs b/osu.Game/Skinning/LegacySkinDecoder.cs index 7dcb7ea3ac..88ba7b23b7 100644 --- a/osu.Game/Skinning/LegacySkinDecoder.cs +++ b/osu.Game/Skinning/LegacySkinDecoder.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.Globalization; using osu.Game.Beatmaps.Formats; namespace osu.Game.Skinning @@ -36,7 +37,7 @@ namespace osu.Game.Skinning case @"Version": if (pair.Value == "latest") skin.LegacyVersion = LegacySkinConfiguration.LATEST_VERSION; - else if (decimal.TryParse(pair.Value, out var version)) + else if (decimal.TryParse(pair.Value, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var version)) skin.LegacyVersion = version; return; From 69d9a0ae1a0813db3f722df54abdf1fdb53c819d Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Wed, 6 Nov 2019 20:30:26 +0300 Subject: [PATCH 028/120] Use null check and pattern matching --- osu.Game/Skinning/LegacySkin.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index f6a366b21d..c76a61084d 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -77,8 +77,8 @@ namespace osu.Game.Skinning switch (legacy) { case LegacySkinConfigurations.Version: - if (Configuration.LegacyVersion.HasValue) - return SkinUtils.As(new Bindable(Configuration.LegacyVersion.Value)); + if (Configuration.LegacyVersion != null) + return SkinUtils.As(new Bindable((decimal)Configuration.LegacyVersion)); break; } From 198a1750c3db0e2b6a2467478333a08d8a65e6db Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Wed, 6 Nov 2019 20:46:02 +0300 Subject: [PATCH 029/120] Use `is` pattern matching --- osu.Game/Skinning/LegacySkin.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index c76a61084d..1730effc29 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -77,8 +77,8 @@ namespace osu.Game.Skinning switch (legacy) { case LegacySkinConfigurations.Version: - if (Configuration.LegacyVersion != null) - return SkinUtils.As(new Bindable((decimal)Configuration.LegacyVersion)); + if (Configuration.LegacyVersion is decimal version) + return SkinUtils.As(new Bindable(version)); break; } From 93954c8da0996307f277473bf4ac894d97d06395 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 10 Nov 2019 23:58:07 +0300 Subject: [PATCH 030/120] Use BindableList for selected mods --- .../Online/TestSceneLeaderboardModSelector.cs | 31 +++++++++++++------ .../BeatmapSet/LeaderboardModSelector.cs | 20 +++++------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs index 3a64ac79f6..799528220b 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs @@ -13,6 +13,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Bindables; using osu.Game.Rulesets; +using osu.Framework.Extensions.IEnumerableExtensions; namespace osu.Game.Tests.Visual.Online { @@ -26,10 +27,10 @@ namespace osu.Game.Tests.Visual.Online public TestSceneLeaderboardModSelector() { LeaderboardModSelector modSelector; - FillFlowContainer selectedMods; + FillFlowContainer selectedMods; Bindable ruleset = new Bindable(); - Add(selectedMods = new FillFlowContainer + Add(selectedMods = new FillFlowContainer { Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft, @@ -42,16 +43,28 @@ namespace osu.Game.Tests.Visual.Online Ruleset = { BindTarget = ruleset } }); - modSelector.SelectedMods.BindValueChanged(mods => + modSelector.SelectedMods.ItemsAdded += mods => { - selectedMods.Clear(); + mods.ForEach(mod => selectedMods.Add(new SpriteText + { + Text = mod.Acronym, + })); + }; - foreach (var mod in mods.NewValue) - selectedMods.Add(new SpriteText + modSelector.SelectedMods.ItemsRemoved += mods => + { + mods.ForEach(mod => + { + foreach (var selected in selectedMods) { - Text = mod.Acronym, - }); - }); + if (selected.Text == mod.Acronym) + { + selectedMods.Remove(selected); + break; + } + } + }); + }; AddStep("osu ruleset", () => ruleset.Value = new OsuRuleset().RulesetInfo); AddStep("mania ruleset", () => ruleset.Value = new ManiaRuleset().RulesetInfo); diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index 4b6fd5bfc2..75c24cb710 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -5,7 +5,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics; using osu.Game.Rulesets.Mods; using osu.Framework.Bindables; -using System.Collections.Generic; using osu.Game.Rulesets; using osuTK; using osu.Game.Rulesets.UI; @@ -21,7 +20,7 @@ namespace osu.Game.Overlays.BeatmapSet { public class LeaderboardModSelector : CompositeDrawable { - public readonly Bindable> SelectedMods = new Bindable>(); + public readonly BindableList SelectedMods = new BindableList(); public readonly Bindable Ruleset = new Bindable(); private readonly FillFlowContainer modsContainer; @@ -47,8 +46,7 @@ namespace osu.Game.Overlays.BeatmapSet private void onRulesetChanged(ValueChangedEvent ruleset) { - SelectedMods.Value = new List(); - + SelectedMods.Clear(); modsContainer.Clear(); if (ruleset.NewValue == null) @@ -67,22 +65,18 @@ namespace osu.Game.Overlays.BeatmapSet private void selectionChanged(Mod mod, bool selected) { - var mods = SelectedMods.Value.ToList(); - if (selected) - mods.Add(mod); + SelectedMods.Add(mod); else - mods.Remove(mod); + SelectedMods.Remove(mod); - SelectedMods.Value = mods; - - if (!mods.Any() && !IsHovered) + if (!SelectedMods.Any() && !IsHovered) highlightAll(); } protected override bool OnHover(HoverEvent e) { - if (!SelectedMods.Value.Any()) + if (!SelectedMods.Any()) modsContainer.ForEach(button => { if (!button.IsHovered) @@ -96,7 +90,7 @@ namespace osu.Game.Overlays.BeatmapSet { base.OnHoverLost(e); - if (!SelectedMods.Value.Any()) + if (!SelectedMods.Any()) highlightAll(); } From 3655f881806ee7b13cd6e22074439d7d07405885 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 11 Nov 2019 17:56:57 +0300 Subject: [PATCH 031/120] Merge dependency --- .../Online/TestSceneLeaderboardModSelector.cs | 77 ++++++++ .../BeatmapSet/LeaderboardModSelector.cs | 165 ++++++++++++++++++ osu.Game/Rulesets/UI/ModIcon.cs | 19 +- 3 files changed, 259 insertions(+), 2 deletions(-) create mode 100644 osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs create mode 100644 osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs new file mode 100644 index 0000000000..799528220b --- /dev/null +++ b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs @@ -0,0 +1,77 @@ +// 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.Overlays.BeatmapSet; +using System; +using System.Collections.Generic; +using osu.Framework.Graphics; +using osu.Game.Rulesets.Osu; +using osu.Game.Rulesets.Mania; +using osu.Game.Rulesets.Taiko; +using osu.Game.Rulesets.Catch; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Bindables; +using osu.Game.Rulesets; +using osu.Framework.Extensions.IEnumerableExtensions; + +namespace osu.Game.Tests.Visual.Online +{ + public class TestSceneLeaderboardModSelector : OsuTestScene + { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(LeaderboardModSelector), + }; + + public TestSceneLeaderboardModSelector() + { + LeaderboardModSelector modSelector; + FillFlowContainer selectedMods; + Bindable ruleset = new Bindable(); + + Add(selectedMods = new FillFlowContainer + { + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, + }); + + Add(modSelector = new LeaderboardModSelector + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Ruleset = { BindTarget = ruleset } + }); + + modSelector.SelectedMods.ItemsAdded += mods => + { + mods.ForEach(mod => selectedMods.Add(new SpriteText + { + Text = mod.Acronym, + })); + }; + + modSelector.SelectedMods.ItemsRemoved += mods => + { + mods.ForEach(mod => + { + foreach (var selected in selectedMods) + { + if (selected.Text == mod.Acronym) + { + selectedMods.Remove(selected); + break; + } + } + }); + }; + + AddStep("osu ruleset", () => ruleset.Value = new OsuRuleset().RulesetInfo); + AddStep("mania ruleset", () => ruleset.Value = new ManiaRuleset().RulesetInfo); + AddStep("taiko ruleset", () => ruleset.Value = new TaikoRuleset().RulesetInfo); + AddStep("catch ruleset", () => ruleset.Value = new CatchRuleset().RulesetInfo); + AddStep("Deselect all", () => modSelector.DeselectAll()); + AddStep("null ruleset", () => ruleset.Value = null); + } + } +} diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs new file mode 100644 index 0000000000..75c24cb710 --- /dev/null +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -0,0 +1,165 @@ +// 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.Graphics.Containers; +using osu.Framework.Graphics; +using osu.Game.Rulesets.Mods; +using osu.Framework.Bindables; +using osu.Game.Rulesets; +using osuTK; +using osu.Game.Rulesets.UI; +using osu.Framework.Input.Events; +using osu.Game.Graphics.UserInterface; +using osuTK.Graphics; +using System; +using System.Linq; +using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Framework.Graphics.Sprites; + +namespace osu.Game.Overlays.BeatmapSet +{ + public class LeaderboardModSelector : CompositeDrawable + { + public readonly BindableList SelectedMods = new BindableList(); + public readonly Bindable Ruleset = new Bindable(); + + private readonly FillFlowContainer modsContainer; + + public LeaderboardModSelector() + { + AutoSizeAxes = Axes.Both; + InternalChild = modsContainer = new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Full, + Spacing = new Vector2(4), + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + Ruleset.BindValueChanged(onRulesetChanged, true); + } + + private void onRulesetChanged(ValueChangedEvent ruleset) + { + SelectedMods.Clear(); + modsContainer.Clear(); + + if (ruleset.NewValue == null) + return; + + modsContainer.Add(new ModButton(new NoMod())); + + ruleset.NewValue.CreateInstance().GetAllMods().ForEach(mod => + { + if (mod.Ranked) + modsContainer.Add(new ModButton(mod)); + }); + + modsContainer.ForEach(button => button.OnSelectionChanged += selectionChanged); + } + + private void selectionChanged(Mod mod, bool selected) + { + if (selected) + SelectedMods.Add(mod); + else + SelectedMods.Remove(mod); + + if (!SelectedMods.Any() && !IsHovered) + highlightAll(); + } + + protected override bool OnHover(HoverEvent e) + { + if (!SelectedMods.Any()) + modsContainer.ForEach(button => + { + if (!button.IsHovered) + button.Highlighted.Value = false; + }); + + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + base.OnHoverLost(e); + + if (!SelectedMods.Any()) + highlightAll(); + } + + public void DeselectAll() => modsContainer.ForEach(mod => mod.Selected.Value = false); + + private void highlightAll() => modsContainer.ForEach(mod => mod.Highlighted.Value = true); + + private class ModButton : ModIcon + { + private const float mod_scale = 0.4f; + private const int duration = 200; + + public readonly BindableBool Selected = new BindableBool(); + public Action OnSelectionChanged; + + public ModButton(Mod mod) + : base(mod) + { + Scale = new Vector2(mod_scale); + Highlighted.Value = true; + Add(new HoverClickSounds()); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + Selected.BindValueChanged(selected => + { + updateState(); + OnSelectionChanged?.Invoke(Mod, selected.NewValue); + }); + } + + protected override bool OnClick(ClickEvent e) + { + Selected.Value = !Selected.Value; + return base.OnClick(e); + } + + protected override bool OnHover(HoverEvent e) + { + updateState(); + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + base.OnHoverLost(e); + updateState(); + } + + private void updateState() => Highlighted.Value = IsHovered || Selected.Value; + + protected override void OnHighlightedChanged(ValueChangedEvent highlighted) => + this.FadeColour(highlighted.NewValue ? Color4.White : Color4.Gray, duration, Easing.OutQuint); + } + + private class NoMod : Mod + { + public override string Name => "NoMod"; + + public override string Acronym => "NM"; + + public override double ScoreMultiplier => 1; + + public override IconUsage Icon => FontAwesome.Solid.Ban; + + public override ModType Type => ModType.System; + } + } +} diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index 88a2338b94..19211e0c80 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -34,9 +34,11 @@ namespace osu.Game.Rulesets.UI public virtual string TooltipText { get; } + protected Mod Mod { get; private set; } + public ModIcon(Mod mod) { - if (mod == null) throw new ArgumentNullException(nameof(mod)); + Mod = mod ?? throw new ArgumentNullException(nameof(mod)); type = mod.Type; @@ -98,13 +100,26 @@ namespace osu.Game.Rulesets.UI backgroundColour = colours.Pink; highlightedColour = colours.PinkLight; break; + + case ModType.System: + backgroundColour = colours.Gray6; + highlightedColour = colours.Gray7; + modIcon.Colour = colours.Yellow; + break; } + + background.Colour = backgroundColour; } protected override void LoadComplete() { base.LoadComplete(); - Highlighted.BindValueChanged(highlighted => background.Colour = highlighted.NewValue ? highlightedColour : backgroundColour, true); + Highlighted.BindValueChanged(OnHighlightedChanged, true); + } + + protected virtual void OnHighlightedChanged(ValueChangedEvent highlighted) + { + background.Colour = highlighted.NewValue ? highlightedColour : backgroundColour; } } } From 32b2f5e330e70fe7ef910bf28dec1f84255e93c1 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 11 Nov 2019 18:10:25 +0300 Subject: [PATCH 032/120] Use Bindable for ScoresContainer --- .../BeatmapSet/Scores/ScoresContainer.cs | 31 +++++++------------ osu.Game/Overlays/BeatmapSetOverlay.cs | 6 ++-- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 4bbcd8d631..580e863a0c 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -13,6 +13,7 @@ using osu.Game.Online.API.Requests.Responses; using osu.Game.Beatmaps; using osu.Game.Online.API; using osu.Game.Online.API.Requests; +using osu.Framework.Bindables; namespace osu.Game.Overlays.BeatmapSet.Scores { @@ -20,6 +21,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { private const int spacing = 15; + public readonly Bindable Beatmap = new Bindable(); + private readonly Box background; private readonly ScoreTable scoreTable; private readonly FillFlowContainer topScoresContainer; @@ -30,22 +33,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private GetScoresRequest getScoresRequest; - private BeatmapInfo beatmap; - - public BeatmapInfo Beatmap - { - get => beatmap; - set - { - if (beatmap == value) - return; - - beatmap = value; - - getScores(beatmap); - } - } - protected APILegacyScores Scores { set @@ -125,18 +112,24 @@ namespace osu.Game.Overlays.BeatmapSet.Scores background.Colour = colours.Gray2; } - private void getScores(BeatmapInfo beatmap) + protected override void LoadComplete() + { + base.LoadComplete(); + Beatmap.BindValueChanged(getScores, true); + } + + private void getScores(ValueChangedEvent beatmap) { getScoresRequest?.Cancel(); getScoresRequest = null; Scores = null; - if (beatmap?.OnlineBeatmapID.HasValue != true || beatmap.Status <= BeatmapSetOnlineStatus.Pending) + if (beatmap.NewValue?.OnlineBeatmapID.HasValue != true || beatmap.NewValue.Status <= BeatmapSetOnlineStatus.Pending) return; loadingAnimation.Show(); - getScoresRequest = new GetScoresRequest(beatmap, beatmap.Ruleset); + getScoresRequest = new GetScoresRequest(beatmap.NewValue, beatmap.NewValue.Ruleset); getScoresRequest.Success += scores => { loadingAnimation.Hide(); diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index c20e6368d8..65d68e4c8c 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -59,7 +59,10 @@ namespace osu.Game.Overlays { Header = new Header(), info = new Info(), - scoreContainer = new ScoresContainer(), + scoreContainer = new ScoresContainer + { + Beatmap = { BindTarget = Header.Picker.Beatmap } + } }, }, }, @@ -71,7 +74,6 @@ namespace osu.Game.Overlays Header.Picker.Beatmap.ValueChanged += b => { info.Beatmap = b.NewValue; - scoreContainer.Beatmap = b.NewValue; scroll.ScrollToStart(); }; From 00b92297375b3062337d303cdb9f6885e440fc71 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 11 Nov 2019 18:21:07 +0300 Subject: [PATCH 033/120] Add mod filter to beatmap overlay --- .../BeatmapSet/Scores/ScoresContainer.cs | 40 +++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 580e863a0c..acf0f08956 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -14,6 +14,7 @@ using osu.Game.Beatmaps; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Framework.Bindables; +using osu.Game.Rulesets; namespace osu.Game.Overlays.BeatmapSet.Scores { @@ -22,11 +23,14 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private const int spacing = 15; public readonly Bindable Beatmap = new Bindable(); + private readonly Bindable ruleset = new Bindable(); private readonly Box background; private readonly ScoreTable scoreTable; private readonly FillFlowContainer topScoresContainer; private readonly LoadingAnimation loadingAnimation; + private readonly FillFlowContainer modFilter; + private readonly LeaderboardModSelector modSelector; [Resolved] private IAPIProvider api { get; set; } @@ -84,6 +88,22 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Margin = new MarginPadding { Vertical = spacing }, Children = new Drawable[] { + modFilter = new FillFlowContainer + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, spacing), + Children = new Drawable[] + { + new LeaderboardScopeSelector(), + modSelector = new LeaderboardModSelector + { + Ruleset = { BindTarget = ruleset } + } + } + }, topScoresContainer = new FillFlowContainer { RelativeSizeAxes = Axes.X, @@ -115,21 +135,33 @@ namespace osu.Game.Overlays.BeatmapSet.Scores protected override void LoadComplete() { base.LoadComplete(); - Beatmap.BindValueChanged(getScores, true); + Beatmap.BindValueChanged(onBeatmapChanged, true); } - private void getScores(ValueChangedEvent beatmap) + private void onBeatmapChanged(ValueChangedEvent beatmap) + { + var beatmapRuleset = beatmap.NewValue?.Ruleset; + + if (modSelector.Ruleset.Value?.Equals(beatmapRuleset) ?? false) + modSelector.DeselectAll(); + else + ruleset.Value = beatmapRuleset; + + getScores(beatmap.NewValue); + } + + private void getScores(BeatmapInfo beatmap) { getScoresRequest?.Cancel(); getScoresRequest = null; Scores = null; - if (beatmap.NewValue?.OnlineBeatmapID.HasValue != true || beatmap.NewValue.Status <= BeatmapSetOnlineStatus.Pending) + if (beatmap?.OnlineBeatmapID.HasValue != true || beatmap.Status <= BeatmapSetOnlineStatus.Pending) return; loadingAnimation.Show(); - getScoresRequest = new GetScoresRequest(beatmap.NewValue, beatmap.NewValue.Ruleset); + getScoresRequest = new GetScoresRequest(beatmap, beatmap.Ruleset); getScoresRequest.Success += scores => { loadingAnimation.Hide(); From 2cfd54ca0d577da1872f74b92c83596a6001e1d1 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 11 Nov 2019 18:27:48 +0300 Subject: [PATCH 034/120] Handle scope changing --- .../BeatmapSet/Scores/ScoresContainer.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index acf0f08956..8058d0fc0f 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -15,6 +15,7 @@ using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Framework.Bindables; using osu.Game.Rulesets; +using osu.Game.Screens.Select.Leaderboards; namespace osu.Game.Overlays.BeatmapSet.Scores { @@ -24,6 +25,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores public readonly Bindable Beatmap = new Bindable(); private readonly Bindable ruleset = new Bindable(); + private readonly Bindable scope = new Bindable(); private readonly Box background; private readonly ScoreTable scoreTable; @@ -97,7 +99,10 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Spacing = new Vector2(0, spacing), Children = new Drawable[] { - new LeaderboardScopeSelector(), + new LeaderboardScopeSelector + { + Current = { BindTarget = scope } + }, modSelector = new LeaderboardModSelector { Ruleset = { BindTarget = ruleset } @@ -135,6 +140,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores protected override void LoadComplete() { base.LoadComplete(); + scope.BindValueChanged(_ => getScores()); Beatmap.BindValueChanged(onBeatmapChanged, true); } @@ -147,21 +153,21 @@ namespace osu.Game.Overlays.BeatmapSet.Scores else ruleset.Value = beatmapRuleset; - getScores(beatmap.NewValue); + getScores(); } - private void getScores(BeatmapInfo beatmap) + private void getScores() { getScoresRequest?.Cancel(); getScoresRequest = null; Scores = null; - if (beatmap?.OnlineBeatmapID.HasValue != true || beatmap.Status <= BeatmapSetOnlineStatus.Pending) + if (Beatmap.Value?.OnlineBeatmapID.HasValue != true || Beatmap.Value.Status <= BeatmapSetOnlineStatus.Pending) return; loadingAnimation.Show(); - getScoresRequest = new GetScoresRequest(beatmap, beatmap.Ruleset); + getScoresRequest = new GetScoresRequest(Beatmap.Value, Beatmap.Value.Ruleset, scope.Value); getScoresRequest.Success += scores => { loadingAnimation.Hide(); From 31191dadf1c9e487174bbc36a21199f697e721e2 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 11 Nov 2019 18:31:42 +0300 Subject: [PATCH 035/120] Handle mods change --- osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 8058d0fc0f..5c1f1ed7e4 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -141,6 +141,10 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { base.LoadComplete(); scope.BindValueChanged(_ => getScores()); + + modSelector.SelectedMods.ItemsAdded += _ => getScores(); + modSelector.SelectedMods.ItemsRemoved += _ => getScores(); + Beatmap.BindValueChanged(onBeatmapChanged, true); } @@ -167,7 +171,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores return; loadingAnimation.Show(); - getScoresRequest = new GetScoresRequest(Beatmap.Value, Beatmap.Value.Ruleset, scope.Value); + getScoresRequest = new GetScoresRequest(Beatmap.Value, Beatmap.Value.Ruleset, scope.Value, modSelector.SelectedMods); getScoresRequest.Success += scores => { loadingAnimation.Hide(); From 5f5d130d1a7f2d7022424ce771ec1cc59795ed62 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 11 Nov 2019 18:40:57 +0300 Subject: [PATCH 036/120] Update mod filter visibility on user change --- .../BeatmapSet/Scores/ScoresContainer.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 5c1f1ed7e4..1dd224e737 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -16,6 +16,7 @@ using osu.Game.Online.API.Requests; using osu.Framework.Bindables; using osu.Game.Rulesets; using osu.Game.Screens.Select.Leaderboards; +using osu.Game.Users; namespace osu.Game.Overlays.BeatmapSet.Scores { @@ -145,7 +146,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores modSelector.SelectedMods.ItemsAdded += _ => getScores(); modSelector.SelectedMods.ItemsRemoved += _ => getScores(); - Beatmap.BindValueChanged(onBeatmapChanged, true); + Beatmap.BindValueChanged(onBeatmapChanged); + api.LocalUser.BindValueChanged(onUserChanged, true); } private void onBeatmapChanged(ValueChangedEvent beatmap) @@ -160,6 +162,18 @@ namespace osu.Game.Overlays.BeatmapSet.Scores getScores(); } + private void onUserChanged(ValueChangedEvent user) + { + scope.Value = BeatmapLeaderboardScope.Global; + modSelector.DeselectAll(); + updateModFilterVisibility(); + } + + private void updateModFilterVisibility() + { + modFilter.FadeTo(api.IsLoggedIn && api.LocalUser.Value.IsSupporter && !hasNoLeaderboard ? 1 : 0); + } + private void getScores() { getScoresRequest?.Cancel(); @@ -167,7 +181,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Scores = null; - if (Beatmap.Value?.OnlineBeatmapID.HasValue != true || Beatmap.Value.Status <= BeatmapSetOnlineStatus.Pending) + updateModFilterVisibility(); + + if (hasNoLeaderboard) return; loadingAnimation.Show(); @@ -179,5 +195,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores }; api.Queue(getScoresRequest); } + + private bool hasNoLeaderboard => Beatmap.Value?.OnlineBeatmapID.HasValue != true || Beatmap.Value.Status <= BeatmapSetOnlineStatus.Pending; } } From c5b64e26a306885caf7f10f2fdab073aa7cd005c Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 11 Nov 2019 18:51:29 +0300 Subject: [PATCH 037/120] Layout adjustment --- .../BeatmapSet/Scores/ScoresContainer.cs | 47 +++++++++++++------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 1dd224e737..2f30cde5af 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -110,25 +110,44 @@ namespace osu.Game.Overlays.BeatmapSet.Scores } } }, - topScoresContainer = new FillFlowContainer + new Container { - RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Spacing = new Vector2(0, 5), - }, - scoreTable = new ScoreTable - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.X, + Children = new Drawable[] + { + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, spacing), + Children = new Drawable[] + { + topScoresContainer = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 5), + }, + scoreTable = new ScoreTable + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + } + } + }, + loadingAnimation = new LoadingAnimation + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Alpha = 0, + }, + } } } }, - loadingAnimation = new LoadingAnimation - { - Alpha = 0, - Margin = new MarginPadding(20), - }, }; } From 32cc7b3d4d69926c49071c85c1113c6ef1625423 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 11 Nov 2019 19:04:50 +0300 Subject: [PATCH 038/120] CI fix --- osu.Game/Overlays/BeatmapSetOverlay.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index 65d68e4c8c..50fb2782d4 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -37,7 +37,6 @@ namespace osu.Game.Overlays { OsuScrollContainer scroll; Info info; - ScoresContainer scoreContainer; Children = new Drawable[] { @@ -59,7 +58,7 @@ namespace osu.Game.Overlays { Header = new Header(), info = new Info(), - scoreContainer = new ScoresContainer + new ScoresContainer { Beatmap = { BindTarget = Header.Picker.Beatmap } } From 0578f91a764733afafded1fb6b78c1e7990b81b6 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 11 Nov 2019 19:06:46 +0300 Subject: [PATCH 039/120] Small logic adjustments --- osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 2f30cde5af..73253546bb 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -161,6 +161,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { base.LoadComplete(); scope.BindValueChanged(_ => getScores()); + ruleset.BindValueChanged(_ => getScores()); modSelector.SelectedMods.ItemsAdded += _ => getScores(); modSelector.SelectedMods.ItemsRemoved += _ => getScores(); @@ -173,12 +174,12 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { var beatmapRuleset = beatmap.NewValue?.Ruleset; - if (modSelector.Ruleset.Value?.Equals(beatmapRuleset) ?? false) + if (ruleset.Value?.Equals(beatmapRuleset) ?? false) modSelector.DeselectAll(); else ruleset.Value = beatmapRuleset; - getScores(); + scope.Value = BeatmapLeaderboardScope.Global; } private void onUserChanged(ValueChangedEvent user) From a69a4643c950526a0683120799c06f7051f478ba Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 12 Nov 2019 08:45:21 +0300 Subject: [PATCH 040/120] Simplify LINQ expressions --- .../Overlays/BeatmapSet/LeaderboardModSelector.cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index 75c24cb710..a7128ca157 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -53,12 +53,7 @@ namespace osu.Game.Overlays.BeatmapSet return; modsContainer.Add(new ModButton(new NoMod())); - - ruleset.NewValue.CreateInstance().GetAllMods().ForEach(mod => - { - if (mod.Ranked) - modsContainer.Add(new ModButton(mod)); - }); + modsContainer.AddRange(ruleset.NewValue.CreateInstance().GetAllMods().Where(m => m.Ranked).Select(m => new ModButton(m))); modsContainer.ForEach(button => button.OnSelectionChanged += selectionChanged); } @@ -77,11 +72,7 @@ namespace osu.Game.Overlays.BeatmapSet protected override bool OnHover(HoverEvent e) { if (!SelectedMods.Any()) - modsContainer.ForEach(button => - { - if (!button.IsHovered) - button.Highlighted.Value = false; - }); + modsContainer.Children.Where(button => !button.IsHovered).ForEach(button => button.Highlighted.Value = false); return base.OnHover(e); } From 27f721eec232a056e208d9ffcbbac1b8459db063 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 13 Nov 2019 00:24:13 +0300 Subject: [PATCH 041/120] Use = instead of += for OnSelectionChanged Action --- osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index a7128ca157..09c388a3b0 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -55,7 +55,7 @@ namespace osu.Game.Overlays.BeatmapSet modsContainer.Add(new ModButton(new NoMod())); modsContainer.AddRange(ruleset.NewValue.CreateInstance().GetAllMods().Where(m => m.Ranked).Select(m => new ModButton(m))); - modsContainer.ForEach(button => button.OnSelectionChanged += selectionChanged); + modsContainer.ForEach(button => button.OnSelectionChanged = selectionChanged); } private void selectionChanged(Mod mod, bool selected) From 99ec84ed38643c504378ede2a10894cd0ae5f350 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 13 Nov 2019 00:26:19 +0300 Subject: [PATCH 042/120] Update dependency --- .../Overlays/BeatmapSet/LeaderboardModSelector.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index 75c24cb710..bd639881e7 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -54,13 +54,9 @@ namespace osu.Game.Overlays.BeatmapSet modsContainer.Add(new ModButton(new NoMod())); - ruleset.NewValue.CreateInstance().GetAllMods().ForEach(mod => - { - if (mod.Ranked) - modsContainer.Add(new ModButton(mod)); - }); + modsContainer.AddRange(ruleset.NewValue.CreateInstance().GetAllMods().Where(m => m.Ranked).Select(m => new ModButton(m))); - modsContainer.ForEach(button => button.OnSelectionChanged += selectionChanged); + modsContainer.ForEach(button => button.OnSelectionChanged = selectionChanged); } private void selectionChanged(Mod mod, bool selected) @@ -77,11 +73,7 @@ namespace osu.Game.Overlays.BeatmapSet protected override bool OnHover(HoverEvent e) { if (!SelectedMods.Any()) - modsContainer.ForEach(button => - { - if (!button.IsHovered) - button.Highlighted.Value = false; - }); + modsContainer.Children.Where(button => !button.IsHovered).ForEach(button => button.Highlighted.Value = false); return base.OnHover(e); } From 5f609b48da9619025998a867882527b273e19905 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 13 Nov 2019 00:29:28 +0300 Subject: [PATCH 043/120] Use local bindable for api.LocalUser --- osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 73253546bb..bc5daa39a0 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -27,6 +27,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores public readonly Bindable Beatmap = new Bindable(); private readonly Bindable ruleset = new Bindable(); private readonly Bindable scope = new Bindable(); + private readonly Bindable user = new Bindable(); private readonly Box background; private readonly ScoreTable scoreTable; @@ -155,6 +156,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private void load(OsuColour colours) { background.Colour = colours.Gray2; + + user.BindTo(api.LocalUser); } protected override void LoadComplete() @@ -167,7 +170,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores modSelector.SelectedMods.ItemsRemoved += _ => getScores(); Beatmap.BindValueChanged(onBeatmapChanged); - api.LocalUser.BindValueChanged(onUserChanged, true); + user.BindValueChanged(onUserChanged, true); } private void onBeatmapChanged(ValueChangedEvent beatmap) From 6715b25ddd767c1a1d2b8891033b827765ce2ac7 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 13 Nov 2019 16:04:15 +0300 Subject: [PATCH 044/120] Apply suggestions --- osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index 09c388a3b0..b400141abf 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -118,14 +118,14 @@ namespace osu.Game.Overlays.BeatmapSet protected override bool OnClick(ClickEvent e) { - Selected.Value = !Selected.Value; - return base.OnClick(e); + Selected.Toggle(); + return true; } protected override bool OnHover(HoverEvent e) { updateState(); - return base.OnHover(e); + return false; } protected override void OnHoverLost(HoverLostEvent e) From 2dbee5da79e027b3903acb8fd280b6fa9aa85333 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 13 Nov 2019 16:06:37 +0300 Subject: [PATCH 045/120] Update dependency --- osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index bd639881e7..b400141abf 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -53,7 +53,6 @@ namespace osu.Game.Overlays.BeatmapSet return; modsContainer.Add(new ModButton(new NoMod())); - modsContainer.AddRange(ruleset.NewValue.CreateInstance().GetAllMods().Where(m => m.Ranked).Select(m => new ModButton(m))); modsContainer.ForEach(button => button.OnSelectionChanged = selectionChanged); @@ -119,14 +118,14 @@ namespace osu.Game.Overlays.BeatmapSet protected override bool OnClick(ClickEvent e) { - Selected.Value = !Selected.Value; - return base.OnClick(e); + Selected.Toggle(); + return true; } protected override bool OnHover(HoverEvent e) { updateState(); - return base.OnHover(e); + return false; } protected override void OnHoverLost(HoverLostEvent e) From 4e90daf212d718d3a64611d1e153bcca292fce53 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 13 Nov 2019 16:39:33 +0300 Subject: [PATCH 046/120] Implement NoScoresPlaceholder --- .../BeatmapSet/Scores/NoScoresPlaceholder.cs | 50 +++++++++++++++++++ .../BeatmapSet/Scores/ScoresContainer.cs | 13 +++++ 2 files changed, 63 insertions(+) create mode 100644 osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs diff --git a/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs b/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs new file mode 100644 index 0000000000..b34e54b301 --- /dev/null +++ b/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs @@ -0,0 +1,50 @@ +// 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.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; +using osu.Framework.Bindables; +using osu.Game.Screens.Select.Leaderboards; +using osu.Framework.Graphics.Sprites; + +namespace osu.Game.Overlays.BeatmapSet.Scores +{ + public class NoScoresPlaceholder : Container + { + public readonly Bindable Scope = new Bindable(); + + private readonly SpriteText text; + + public NoScoresPlaceholder() + { + AutoSizeAxes = Axes.Both; + Child = text = new SpriteText + { + Font = OsuFont.GetFont(), + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + Scope.BindValueChanged(scope => text.Text = getText(scope.NewValue), true); + } + + private string getText(BeatmapLeaderboardScope scope) + { + switch (scope) + { + default: + case BeatmapLeaderboardScope.Global: + return @"No scores yet. Maybe should try setting some?"; + + case BeatmapLeaderboardScope.Friend: + return @"None of your friends has set a score on this map yet!"; + + case BeatmapLeaderboardScope.Country: + return @"No one from your country has set a score on this map yet!"; + } + } + } +} diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index bc5daa39a0..62ec9ca609 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -35,6 +35,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly LoadingAnimation loadingAnimation; private readonly FillFlowContainer modFilter; private readonly LeaderboardModSelector modSelector; + private readonly NoScoresPlaceholder noScoresPlaceholder; [Resolved] private IAPIProvider api { get; set; } @@ -125,6 +126,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Spacing = new Vector2(0, spacing), Children = new Drawable[] { + noScoresPlaceholder = new NoScoresPlaceholder + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Alpha = 0, + Scope = { BindTarget = scope } + }, topScoresContainer = new FillFlowContainer { RelativeSizeAxes = Axes.X, @@ -204,6 +212,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Scores = null; + noScoresPlaceholder.Hide(); + updateModFilterVisibility(); if (hasNoLeaderboard) @@ -215,6 +225,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { loadingAnimation.Hide(); Scores = scores; + + if (!scores.Scores.Any()) + noScoresPlaceholder.Show(); }; api.Queue(getScoresRequest); } From 3f6140db6dbe88f0412ca7e08c8206a1657c2b1f Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 13 Nov 2019 17:18:58 +0300 Subject: [PATCH 047/120] Improve loading animation --- .../BeatmapSet/Scores/NoScoresPlaceholder.cs | 20 +++----- .../BeatmapSet/Scores/ScoresContainer.cs | 50 +++++++++++-------- 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs b/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs index b34e54b301..4241ea3e54 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs @@ -4,7 +4,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; -using osu.Framework.Bindables; using osu.Game.Screens.Select.Leaderboards; using osu.Framework.Graphics.Sprites; @@ -12,8 +11,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { public class NoScoresPlaceholder : Container { - public readonly Bindable Scope = new Bindable(); - private readonly SpriteText text; public NoScoresPlaceholder() @@ -25,25 +22,22 @@ namespace osu.Game.Overlays.BeatmapSet.Scores }; } - protected override void LoadComplete() - { - base.LoadComplete(); - Scope.BindValueChanged(scope => text.Text = getText(scope.NewValue), true); - } - - private string getText(BeatmapLeaderboardScope scope) + public void UpdateText(BeatmapLeaderboardScope scope) { switch (scope) { default: case BeatmapLeaderboardScope.Global: - return @"No scores yet. Maybe should try setting some?"; + text.Text = @"No scores yet. Maybe should try setting some?"; + return; case BeatmapLeaderboardScope.Friend: - return @"None of your friends has set a score on this map yet!"; + text.Text = @"None of your friends has set a score on this map yet!"; + return; case BeatmapLeaderboardScope.Country: - return @"No one from your country has set a score on this map yet!"; + text.Text = @"No one from your country has set a score on this map yet!"; + return; } } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 62ec9ca609..c74c4e3df0 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -23,6 +23,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores public class ScoresContainer : CompositeDrawable { private const int spacing = 15; + private const int duration = 200; public readonly Bindable Beatmap = new Bindable(); private readonly Bindable ruleset = new Bindable(); @@ -32,7 +33,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly Box background; private readonly ScoreTable scoreTable; private readonly FillFlowContainer topScoresContainer; - private readonly LoadingAnimation loadingAnimation; + private readonly DimmedLoadingLayer loading; private readonly FillFlowContainer modFilter; private readonly LeaderboardModSelector modSelector; private readonly NoScoresPlaceholder noScoresPlaceholder; @@ -89,7 +90,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores AutoSizeAxes = Axes.Y, Width = 0.95f, Direction = FillDirection.Vertical, - Spacing = new Vector2(0, spacing), Margin = new MarginPadding { Vertical = spacing }, Children = new Drawable[] { @@ -116,8 +116,17 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, + Margin = new MarginPadding { Vertical = spacing }, Children = new Drawable[] { + noScoresPlaceholder = new NoScoresPlaceholder + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Alpha = 0, + AlwaysPresent = true, + Margin = new MarginPadding { Vertical = 10 } + }, new FillFlowContainer { RelativeSizeAxes = Axes.X, @@ -126,13 +135,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Spacing = new Vector2(0, spacing), Children = new Drawable[] { - noScoresPlaceholder = new NoScoresPlaceholder - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Alpha = 0, - Scope = { BindTarget = scope } - }, topScoresContainer = new FillFlowContainer { RelativeSizeAxes = Axes.X, @@ -147,12 +149,16 @@ namespace osu.Game.Overlays.BeatmapSet.Scores } } }, - loadingAnimation = new LoadingAnimation + new Container { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Alpha = 0, - }, + RelativeSizeAxes = Axes.Both, + Masking = true, + CornerRadius = 10, + Child = loading = new DimmedLoadingLayer(iconScale: 0.8f) + { + Alpha = 0, + }, + } } } } @@ -210,24 +216,28 @@ namespace osu.Game.Overlays.BeatmapSet.Scores getScoresRequest?.Cancel(); getScoresRequest = null; - Scores = null; - - noScoresPlaceholder.Hide(); + noScoresPlaceholder.FadeOut(duration, Easing.OutQuint); updateModFilterVisibility(); if (hasNoLeaderboard) + { + Scores = null; return; + } - loadingAnimation.Show(); + loading.Show(); getScoresRequest = new GetScoresRequest(Beatmap.Value, Beatmap.Value.Ruleset, scope.Value, modSelector.SelectedMods); getScoresRequest.Success += scores => { - loadingAnimation.Hide(); + loading.Hide(); Scores = scores; if (!scores.Scores.Any()) - noScoresPlaceholder.Show(); + { + noScoresPlaceholder.UpdateText(scope.Value); + noScoresPlaceholder.FadeIn(duration, Easing.OutQuint); + } }; api.Queue(getScoresRequest); } From 8005ee73af2f77b9cb12f00cdeb07e40b05c9e77 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 13 Nov 2019 17:23:46 +0300 Subject: [PATCH 048/120] Trim whitespace --- osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index c74c4e3df0..bc950a0c0c 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -116,7 +116,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, - Margin = new MarginPadding { Vertical = spacing }, + Margin = new MarginPadding { Vertical = spacing }, Children = new Drawable[] { noScoresPlaceholder = new NoScoresPlaceholder From d1853ea55bfc0ddd04c7785ebb246a9865877389 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 13 Nov 2019 17:29:50 +0300 Subject: [PATCH 049/120] Fix incorrect formatting for switch/case --- .../BeatmapSet/Scores/NoScoresPlaceholder.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs b/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs index 4241ea3e54..aefff5d567 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs @@ -28,16 +28,16 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { default: case BeatmapLeaderboardScope.Global: - text.Text = @"No scores yet. Maybe should try setting some?"; - return; + text.Text = @"No scores yet. Maybe should try setting some?"; + return; case BeatmapLeaderboardScope.Friend: - text.Text = @"None of your friends has set a score on this map yet!"; - return; + text.Text = @"None of your friends has set a score on this map yet!"; + return; case BeatmapLeaderboardScope.Country: - text.Text = @"No one from your country has set a score on this map yet!"; - return; + text.Text = @"No one from your country has set a score on this map yet!"; + return; } } } From 633c497602db249d5113eb2e35a725f1a53fff3d Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 13 Nov 2019 17:36:08 +0300 Subject: [PATCH 050/120] Hide content if beatmap has no leaderboard --- osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index bc950a0c0c..32e5314fba 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -37,6 +37,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly FillFlowContainer modFilter; private readonly LeaderboardModSelector modSelector; private readonly NoScoresPlaceholder noScoresPlaceholder; + private readonly FillFlowContainer content; [Resolved] private IAPIProvider api { get; set; } @@ -82,7 +83,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { RelativeSizeAxes = Axes.Both, }, - new FillFlowContainer + content = new FillFlowContainer { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, @@ -223,9 +224,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores if (hasNoLeaderboard) { Scores = null; + content.Hide(); return; } + content.Show(); loading.Show(); getScoresRequest = new GetScoresRequest(Beatmap.Value, Beatmap.Value.Ruleset, scope.Value, modSelector.SelectedMods); getScoresRequest.Success += scores => From 2d3fadc1a8d21ed1895db93542bec2b597a50645 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 14 Nov 2019 00:38:37 +0300 Subject: [PATCH 051/120] Don't update mod filter visibility on every beatmap change --- .../Overlays/BeatmapSet/Scores/ScoresContainer.cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 32e5314fba..3e3f823368 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -204,12 +204,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { scope.Value = BeatmapLeaderboardScope.Global; modSelector.DeselectAll(); - updateModFilterVisibility(); - } - - private void updateModFilterVisibility() - { - modFilter.FadeTo(api.IsLoggedIn && api.LocalUser.Value.IsSupporter && !hasNoLeaderboard ? 1 : 0); + modFilter.FadeTo(api.IsLoggedIn && api.LocalUser.Value.IsSupporter ? 1 : 0); } private void getScores() @@ -219,9 +214,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores noScoresPlaceholder.FadeOut(duration, Easing.OutQuint); - updateModFilterVisibility(); - - if (hasNoLeaderboard) + if (Beatmap.Value?.OnlineBeatmapID.HasValue != true || Beatmap.Value.Status <= BeatmapSetOnlineStatus.Pending) { Scores = null; content.Hide(); @@ -244,7 +237,5 @@ namespace osu.Game.Overlays.BeatmapSet.Scores }; api.Queue(getScoresRequest); } - - private bool hasNoLeaderboard => Beatmap.Value?.OnlineBeatmapID.HasValue != true || Beatmap.Value.Status <= BeatmapSetOnlineStatus.Pending; } } From c7d0b88854a66cfacab8ac91c2e885088a606ca3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 15 Nov 2019 14:15:09 +0900 Subject: [PATCH 052/120] Update test scene --- .../Visual/Gameplay/{TestCaseLeadIn.cs => TestSceneLeadIn.cs} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename osu.Game.Tests/Visual/Gameplay/{TestCaseLeadIn.cs => TestSceneLeadIn.cs} (97%) diff --git a/osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs similarity index 97% rename from osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs rename to osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs index 41cd80ed8c..3522c2265a 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs @@ -15,7 +15,7 @@ using osuTK.Graphics; namespace osu.Game.Tests.Visual.Gameplay { - public class TestCaseLeadIn : RateAdjustedBeatmapTestScene + public class TestSceneLeadIn : RateAdjustedBeatmapTestScene { private Ruleset ruleset; From dbfec215e7acdf716f4c11c42f3ab8bd6c7711d6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 15 Nov 2019 14:47:28 +0900 Subject: [PATCH 053/120] Improve test quality --- .../Visual/Gameplay/TestSceneLeadIn.cs | 50 ++++++++----------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs index 3522c2265a..addf7c3b28 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs @@ -1,61 +1,55 @@ // 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 NUnit.Framework; -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Graphics.Sprites; -using osu.Game.Rulesets; +using osu.Game.Rulesets.Osu; using osu.Game.Screens.Play; using osu.Game.Tests.Beatmaps; -using osuTK.Graphics; namespace osu.Game.Tests.Visual.Gameplay { public class TestSceneLeadIn : RateAdjustedBeatmapTestScene { - private Ruleset ruleset; - private LeadInPlayer player; - [BackgroundDependencyLoader] - private void load(RulesetStore rulesets) - { - Add(new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - Depth = int.MaxValue - }); - - ruleset = rulesets.AvailableRulesets.First().CreateInstance(); - } - [Test] public void TestShortLeadIn() { - AddStep("create player", () => loadPlayerWithBeatmap(new TestBeatmap(ruleset.RulesetInfo) { BeatmapInfo = { AudioLeadIn = 1000 } })); - AddUntilStep("correct lead-in", () => player.FirstFrameClockTime == 0); + loadPlayerWithBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo) + { + BeatmapInfo = { AudioLeadIn = 1000 } + }); + + AddUntilStep("player loaded", () => player.IsLoaded && player.Alpha == 1); + + AddAssert("correct lead-in", () => player.FirstFrameClockTime == 0); } [Test] public void TestLongLeadIn() { - AddStep("create player", () => loadPlayerWithBeatmap(new TestBeatmap(ruleset.RulesetInfo) { BeatmapInfo = { AudioLeadIn = 10000 } })); - AddUntilStep("correct lead-in", () => player.FirstFrameClockTime == player.GameplayStartTime - 10000); + loadPlayerWithBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo) + { + BeatmapInfo = { AudioLeadIn = 10000 } + }); + + AddAssert("correct lead-in", () => player.FirstFrameClockTime == player.GameplayStartTime - 10000); } private void loadPlayerWithBeatmap(IBeatmap beatmap) { - Beatmap.Value = new TestWorkingBeatmap(beatmap); + AddStep("create player", () => + { + Beatmap.Value = CreateWorkingBeatmap(beatmap); + LoadScreen(player = new LeadInPlayer()); + }); - LoadScreen(player = new LeadInPlayer()); + AddUntilStep("player loaded", () => player.IsLoaded && player.Alpha == 1); } - private class LeadInPlayer : Player + private class LeadInPlayer : TestPlayer { public LeadInPlayer() : base(false, false) From 1218d41b50ee6d1e52552c533c110448b312e63d Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Fri, 15 Nov 2019 11:52:49 +0300 Subject: [PATCH 054/120] Make Ruleset a property --- .../BeatmapSet/LeaderboardModSelector.cs | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index b400141abf..660d957e1a 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -21,7 +21,34 @@ namespace osu.Game.Overlays.BeatmapSet public class LeaderboardModSelector : CompositeDrawable { public readonly BindableList SelectedMods = new BindableList(); - public readonly Bindable Ruleset = new Bindable(); + + private RulesetInfo ruleset; + + public RulesetInfo Ruleset + { + get => ruleset; + set + { + if (ruleset == value) + { + DeselectAll(); + return; + } + + ruleset = value; + + SelectedMods.Clear(); + modsContainer.Clear(); + + if (ruleset == null) + return; + + modsContainer.Add(new ModButton(new NoMod())); + modsContainer.AddRange(ruleset.CreateInstance().GetAllMods().Where(m => m.Ranked).Select(m => new ModButton(m))); + + modsContainer.ForEach(button => button.OnSelectionChanged = selectionChanged); + } + } private readonly FillFlowContainer modsContainer; @@ -38,26 +65,6 @@ namespace osu.Game.Overlays.BeatmapSet }; } - protected override void LoadComplete() - { - base.LoadComplete(); - Ruleset.BindValueChanged(onRulesetChanged, true); - } - - private void onRulesetChanged(ValueChangedEvent ruleset) - { - SelectedMods.Clear(); - modsContainer.Clear(); - - if (ruleset.NewValue == null) - return; - - modsContainer.Add(new ModButton(new NoMod())); - modsContainer.AddRange(ruleset.NewValue.CreateInstance().GetAllMods().Where(m => m.Ranked).Select(m => new ModButton(m))); - - modsContainer.ForEach(button => button.OnSelectionChanged = selectionChanged); - } - private void selectionChanged(Mod mod, bool selected) { if (selected) From 2592a0489b05fb4a7d5dfe112adc1802e5c27694 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Fri, 15 Nov 2019 11:57:40 +0300 Subject: [PATCH 055/120] Use existing ModNoMod --- .../Online/TestSceneLeaderboardModSelector.cs | 12 +++++------- .../BeatmapSet/LeaderboardModSelector.cs | 16 +--------------- osu.Game/Rulesets/Mods/ModNoMod.cs | 4 ++++ 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs index 799528220b..94540eeb5b 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs @@ -28,7 +28,6 @@ namespace osu.Game.Tests.Visual.Online { LeaderboardModSelector modSelector; FillFlowContainer selectedMods; - Bindable ruleset = new Bindable(); Add(selectedMods = new FillFlowContainer { @@ -40,7 +39,6 @@ namespace osu.Game.Tests.Visual.Online { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Ruleset = { BindTarget = ruleset } }); modSelector.SelectedMods.ItemsAdded += mods => @@ -66,12 +64,12 @@ namespace osu.Game.Tests.Visual.Online }); }; - AddStep("osu ruleset", () => ruleset.Value = new OsuRuleset().RulesetInfo); - AddStep("mania ruleset", () => ruleset.Value = new ManiaRuleset().RulesetInfo); - AddStep("taiko ruleset", () => ruleset.Value = new TaikoRuleset().RulesetInfo); - AddStep("catch ruleset", () => ruleset.Value = new CatchRuleset().RulesetInfo); + AddStep("osu ruleset", () => modSelector.Ruleset = new OsuRuleset().RulesetInfo); + AddStep("mania ruleset", () => modSelector.Ruleset = new ManiaRuleset().RulesetInfo); + AddStep("taiko ruleset", () => modSelector.Ruleset = new TaikoRuleset().RulesetInfo); + AddStep("catch ruleset", () => modSelector.Ruleset = new CatchRuleset().RulesetInfo); AddStep("Deselect all", () => modSelector.DeselectAll()); - AddStep("null ruleset", () => ruleset.Value = null); + AddStep("null ruleset", () => modSelector.Ruleset = null); } } } diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index 660d957e1a..c96840c959 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -14,7 +14,6 @@ using osuTK.Graphics; using System; using System.Linq; using osu.Framework.Extensions.IEnumerableExtensions; -using osu.Framework.Graphics.Sprites; namespace osu.Game.Overlays.BeatmapSet { @@ -43,7 +42,7 @@ namespace osu.Game.Overlays.BeatmapSet if (ruleset == null) return; - modsContainer.Add(new ModButton(new NoMod())); + modsContainer.Add(new ModButton(new ModNoMod())); modsContainer.AddRange(ruleset.CreateInstance().GetAllMods().Where(m => m.Ranked).Select(m => new ModButton(m))); modsContainer.ForEach(button => button.OnSelectionChanged = selectionChanged); @@ -146,18 +145,5 @@ namespace osu.Game.Overlays.BeatmapSet protected override void OnHighlightedChanged(ValueChangedEvent highlighted) => this.FadeColour(highlighted.NewValue ? Color4.White : Color4.Gray, duration, Easing.OutQuint); } - - private class NoMod : Mod - { - public override string Name => "NoMod"; - - public override string Acronym => "NM"; - - public override double ScoreMultiplier => 1; - - public override IconUsage Icon => FontAwesome.Solid.Ban; - - public override ModType Type => ModType.System; - } } } diff --git a/osu.Game/Rulesets/Mods/ModNoMod.cs b/osu.Game/Rulesets/Mods/ModNoMod.cs index 0ddbd2a8cb..487985b2b3 100644 --- a/osu.Game/Rulesets/Mods/ModNoMod.cs +++ b/osu.Game/Rulesets/Mods/ModNoMod.cs @@ -1,6 +1,8 @@ // 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.Graphics.Sprites; + namespace osu.Game.Rulesets.Mods { /// @@ -11,5 +13,7 @@ namespace osu.Game.Rulesets.Mods public override string Name => "No Mod"; public override string Acronym => "NM"; public override double ScoreMultiplier => 1; + public override IconUsage Icon => FontAwesome.Solid.Ban; + public override ModType Type => ModType.System; } } From 18f77008dbcafb9c69d1b09a25bf31fdb95c67b0 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Fri, 15 Nov 2019 12:04:01 +0300 Subject: [PATCH 056/120] Update dependency --- .../Online/TestSceneLeaderboardModSelector.cs | 14 ++--- .../BeatmapSet/LeaderboardModSelector.cs | 63 +++++++++---------- .../BeatmapSet/Scores/ScoresContainer.cs | 13 +--- osu.Game/Rulesets/Mods/ModNoMod.cs | 4 ++ 4 files changed, 39 insertions(+), 55 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs index 799528220b..c0c18c2583 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs @@ -11,8 +11,6 @@ using osu.Game.Rulesets.Taiko; using osu.Game.Rulesets.Catch; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Bindables; -using osu.Game.Rulesets; using osu.Framework.Extensions.IEnumerableExtensions; namespace osu.Game.Tests.Visual.Online @@ -28,7 +26,6 @@ namespace osu.Game.Tests.Visual.Online { LeaderboardModSelector modSelector; FillFlowContainer selectedMods; - Bindable ruleset = new Bindable(); Add(selectedMods = new FillFlowContainer { @@ -40,7 +37,6 @@ namespace osu.Game.Tests.Visual.Online { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Ruleset = { BindTarget = ruleset } }); modSelector.SelectedMods.ItemsAdded += mods => @@ -66,12 +62,12 @@ namespace osu.Game.Tests.Visual.Online }); }; - AddStep("osu ruleset", () => ruleset.Value = new OsuRuleset().RulesetInfo); - AddStep("mania ruleset", () => ruleset.Value = new ManiaRuleset().RulesetInfo); - AddStep("taiko ruleset", () => ruleset.Value = new TaikoRuleset().RulesetInfo); - AddStep("catch ruleset", () => ruleset.Value = new CatchRuleset().RulesetInfo); + AddStep("osu ruleset", () => modSelector.Ruleset = new OsuRuleset().RulesetInfo); + AddStep("mania ruleset", () => modSelector.Ruleset = new ManiaRuleset().RulesetInfo); + AddStep("taiko ruleset", () => modSelector.Ruleset = new TaikoRuleset().RulesetInfo); + AddStep("catch ruleset", () => modSelector.Ruleset = new CatchRuleset().RulesetInfo); AddStep("Deselect all", () => modSelector.DeselectAll()); - AddStep("null ruleset", () => ruleset.Value = null); + AddStep("null ruleset", () => modSelector.Ruleset = null); } } } diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index b400141abf..c96840c959 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -14,14 +14,40 @@ using osuTK.Graphics; using System; using System.Linq; using osu.Framework.Extensions.IEnumerableExtensions; -using osu.Framework.Graphics.Sprites; namespace osu.Game.Overlays.BeatmapSet { public class LeaderboardModSelector : CompositeDrawable { public readonly BindableList SelectedMods = new BindableList(); - public readonly Bindable Ruleset = new Bindable(); + + private RulesetInfo ruleset; + + public RulesetInfo Ruleset + { + get => ruleset; + set + { + if (ruleset == value) + { + DeselectAll(); + return; + } + + ruleset = value; + + SelectedMods.Clear(); + modsContainer.Clear(); + + if (ruleset == null) + return; + + modsContainer.Add(new ModButton(new ModNoMod())); + modsContainer.AddRange(ruleset.CreateInstance().GetAllMods().Where(m => m.Ranked).Select(m => new ModButton(m))); + + modsContainer.ForEach(button => button.OnSelectionChanged = selectionChanged); + } + } private readonly FillFlowContainer modsContainer; @@ -38,26 +64,6 @@ namespace osu.Game.Overlays.BeatmapSet }; } - protected override void LoadComplete() - { - base.LoadComplete(); - Ruleset.BindValueChanged(onRulesetChanged, true); - } - - private void onRulesetChanged(ValueChangedEvent ruleset) - { - SelectedMods.Clear(); - modsContainer.Clear(); - - if (ruleset.NewValue == null) - return; - - modsContainer.Add(new ModButton(new NoMod())); - modsContainer.AddRange(ruleset.NewValue.CreateInstance().GetAllMods().Where(m => m.Ranked).Select(m => new ModButton(m))); - - modsContainer.ForEach(button => button.OnSelectionChanged = selectionChanged); - } - private void selectionChanged(Mod mod, bool selected) { if (selected) @@ -139,18 +145,5 @@ namespace osu.Game.Overlays.BeatmapSet protected override void OnHighlightedChanged(ValueChangedEvent highlighted) => this.FadeColour(highlighted.NewValue ? Color4.White : Color4.Gray, duration, Easing.OutQuint); } - - private class NoMod : Mod - { - public override string Name => "NoMod"; - - public override string Acronym => "NM"; - - public override double ScoreMultiplier => 1; - - public override IconUsage Icon => FontAwesome.Solid.Ban; - - public override ModType Type => ModType.System; - } } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 3e3f823368..bdcf536e39 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -107,10 +107,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { Current = { BindTarget = scope } }, - modSelector = new LeaderboardModSelector - { - Ruleset = { BindTarget = ruleset } - } + modSelector = new LeaderboardModSelector() } }, new Container @@ -190,13 +187,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private void onBeatmapChanged(ValueChangedEvent beatmap) { - var beatmapRuleset = beatmap.NewValue?.Ruleset; - - if (ruleset.Value?.Equals(beatmapRuleset) ?? false) - modSelector.DeselectAll(); - else - ruleset.Value = beatmapRuleset; - + ruleset.Value = modSelector.Ruleset = beatmap.NewValue?.Ruleset; scope.Value = BeatmapLeaderboardScope.Global; } diff --git a/osu.Game/Rulesets/Mods/ModNoMod.cs b/osu.Game/Rulesets/Mods/ModNoMod.cs index 0ddbd2a8cb..487985b2b3 100644 --- a/osu.Game/Rulesets/Mods/ModNoMod.cs +++ b/osu.Game/Rulesets/Mods/ModNoMod.cs @@ -1,6 +1,8 @@ // 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.Graphics.Sprites; + namespace osu.Game.Rulesets.Mods { /// @@ -11,5 +13,7 @@ namespace osu.Game.Rulesets.Mods public override string Name => "No Mod"; public override string Acronym => "NM"; public override double ScoreMultiplier => 1; + public override IconUsage Icon => FontAwesome.Solid.Ban; + public override ModType Type => ModType.System; } } From e51fd00d588cd2b7488995b15f15b5533a8d759d Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Fri, 15 Nov 2019 12:09:31 +0300 Subject: [PATCH 057/120] CI fix --- osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs | 2 -- osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs index 94540eeb5b..c0c18c2583 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs @@ -11,8 +11,6 @@ using osu.Game.Rulesets.Taiko; using osu.Game.Rulesets.Catch; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Bindables; -using osu.Game.Rulesets; using osu.Framework.Extensions.IEnumerableExtensions; namespace osu.Game.Tests.Visual.Online diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index c96840c959..e62a754e92 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -28,7 +28,7 @@ namespace osu.Game.Overlays.BeatmapSet get => ruleset; set { - if (ruleset == value) + if (ruleset?.Equals(value) ?? false) { DeselectAll(); return; From f2862e95e0be0544027118cbf47cac3f00b99fa9 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Fri, 15 Nov 2019 12:15:51 +0300 Subject: [PATCH 058/120] CI fix --- osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index c96840c959..e62a754e92 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -28,7 +28,7 @@ namespace osu.Game.Overlays.BeatmapSet get => ruleset; set { - if (ruleset == value) + if (ruleset?.Equals(value) ?? false) { DeselectAll(); return; From 08b8cedfdf4766b4d29c2e36bd4ed33277c3cd33 Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Wed, 20 Nov 2019 01:15:40 +0300 Subject: [PATCH 059/120] Add setter to legacy skin configuration access --- osu.Game/Skinning/LegacySkin.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 35aca3aa7b..0ee41e654e 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -26,7 +26,11 @@ namespace osu.Game.Skinning [CanBeNull] protected IResourceStore Samples; - protected new LegacySkinConfiguration Configuration => (LegacySkinConfiguration)base.Configuration; + protected new LegacySkinConfiguration Configuration + { + get => base.Configuration as LegacySkinConfiguration; + set => base.Configuration = value; + } public LegacySkin(SkinInfo skin, IResourceStore storage, AudioManager audioManager) : this(skin, new LegacySkinResourceStore(skin, storage), audioManager, "skin.ini") @@ -41,10 +45,10 @@ namespace osu.Game.Skinning if (stream != null) { using (LineBufferedReader reader = new LineBufferedReader(stream)) - base.Configuration = new LegacySkinDecoder().Decode(reader); + Configuration = new LegacySkinDecoder().Decode(reader); } else - base.Configuration = new LegacySkinConfiguration { LegacyVersion = LegacySkinConfiguration.LATEST_VERSION }; + Configuration = new LegacySkinConfiguration { LegacyVersion = LegacySkinConfiguration.LATEST_VERSION }; if (storage != null) { From bcb1504110f732679752f43254f2bdf1f9b0fd0b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 20 Nov 2019 15:40:35 +0900 Subject: [PATCH 060/120] Fix naming --- osu.Game/Skinning/LegacySkin.cs | 4 ++-- osu.Game/Skinning/LegacySkinConfiguration.cs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 0ee41e654e..7ffed18d7b 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -80,10 +80,10 @@ namespace osu.Game.Skinning case GlobalSkinColour colour: return SkinUtils.As(getCustomColour(colour.ToString())); - case LegacySkinConfigurations legacy: + case LegacySkinConfiguration.LegacySetting legacy: switch (legacy) { - case LegacySkinConfigurations.Version: + case LegacySkinConfiguration.LegacySetting.Version: if (Configuration.LegacyVersion is decimal version) return SkinUtils.As(new Bindable(version)); diff --git a/osu.Game/Skinning/LegacySkinConfiguration.cs b/osu.Game/Skinning/LegacySkinConfiguration.cs index 33c29cd47c..6a667e69f4 100644 --- a/osu.Game/Skinning/LegacySkinConfiguration.cs +++ b/osu.Game/Skinning/LegacySkinConfiguration.cs @@ -11,10 +11,10 @@ namespace osu.Game.Skinning /// Legacy version of this skin. Null if no version was set to allow fallback to a parent skin version. /// public decimal? LegacyVersion { get; internal set; } - } - public enum LegacySkinConfigurations - { - Version, + public enum LegacySetting + { + Version, + } } } From 8369be90f20842c6b9a6aaf4eba5a4671c0c2915 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Nov 2019 15:19:06 +0900 Subject: [PATCH 061/120] Allow skip button to actuate more than once --- .../Visual/Gameplay/TestSceneSkipOverlay.cs | 13 +--------- .../Screens/Play/GameplayClockContainer.cs | 26 ++++++++++++++++--- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Play/SkipOverlay.cs | 20 +++----------- 4 files changed, 29 insertions(+), 32 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs index b152c21454..0d62d9a520 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs @@ -33,7 +33,7 @@ namespace osu.Game.Tests.Visual.Gameplay { skip = new SkipOverlay(6000) { - RequestSeek = _ => requestCount++ + RequestSkip = () => requestCount++ } }, }; @@ -60,17 +60,6 @@ namespace osu.Game.Tests.Visual.Gameplay checkRequestCount(1); } - [Test] - public void TestClickOnlyActuatesOnce() - { - AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre)); - AddStep("click", () => InputManager.Click(MouseButton.Left)); - AddStep("click", () => InputManager.Click(MouseButton.Left)); - AddStep("click", () => InputManager.Click(MouseButton.Left)); - AddStep("click", () => InputManager.Click(MouseButton.Left)); - checkRequestCount(1); - } - [Test] public void TestDoesntFadeOnMouseDown() { diff --git a/osu.Game/Screens/Play/GameplayClockContainer.cs b/osu.Game/Screens/Play/GameplayClockContainer.cs index 671711f5a4..e1f4d8fa94 100644 --- a/osu.Game/Screens/Play/GameplayClockContainer.cs +++ b/osu.Game/Screens/Play/GameplayClockContainer.cs @@ -89,6 +89,11 @@ namespace osu.Game.Screens.Play private double totalOffset => userOffsetClock.Offset + platformOffsetClock.Offset; + /// + /// Duration before gameplay start time required before skip button displays. + /// + public const double MINIMUM_SKIP_TIME = 1000; + private readonly BindableDouble pauseFreqAdjust = new BindableDouble(1); [BackgroundDependencyLoader] @@ -104,11 +109,9 @@ namespace osu.Game.Screens.Play startTime = Math.Min(startTime, 0); Seek(startTime); + adjustableClock.ProcessFrame(); - UserPlaybackRate.ValueChanged += _ => updateRate(); - - Seek(Math.Min(-beatmap.BeatmapInfo.AudioLeadIn, gameplayStartTime)); } public void Restart() @@ -139,6 +142,23 @@ namespace osu.Game.Screens.Play this.TransformBindableTo(pauseFreqAdjust, 1, 200, Easing.In); } + /// + /// Skip forwardto the next valid skip point. + /// + public void Skip() + { + if (GameplayClock.CurrentTime > gameplayStartTime - MINIMUM_SKIP_TIME) + return; + + double skipTarget = gameplayStartTime - MINIMUM_SKIP_TIME; + + if (GameplayClock.CurrentTime < 0 && skipTarget > 6000) + // double skip exception for storyboards with very long intros + skipTarget = 0; + + Seek(skipTarget); + } + /// /// Seek to a specific time in gameplay. /// diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index a9b0649fab..d6488dc209 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -203,7 +203,7 @@ namespace osu.Game.Screens.Play }, new SkipOverlay(DrawableRuleset.GameplayStartTime) { - RequestSeek = GameplayClockContainer.Seek + RequestSkip = GameplayClockContainer.Skip }, FailOverlay = new FailOverlay { diff --git a/osu.Game/Screens/Play/SkipOverlay.cs b/osu.Game/Screens/Play/SkipOverlay.cs index 835867fe62..3abe61d1a9 100644 --- a/osu.Game/Screens/Play/SkipOverlay.cs +++ b/osu.Game/Screens/Play/SkipOverlay.cs @@ -27,7 +27,7 @@ namespace osu.Game.Screens.Play { private readonly double startTime; - public Action RequestSeek; + public Action RequestSkip; private Button button; private Box remainingTimeBox; @@ -90,11 +90,6 @@ namespace osu.Game.Screens.Play }; } - /// - /// Duration before gameplay start time required before skip button displays. - /// - private const double skip_buffer = 1000; - private const double fade_time = 300; private double beginFadeTime => startTime - fade_time; @@ -104,7 +99,7 @@ namespace osu.Game.Screens.Play base.LoadComplete(); // skip is not required if there is no extra "empty" time to skip. - if (Clock.CurrentTime > beginFadeTime - skip_buffer) + if (Clock.CurrentTime > beginFadeTime - GameplayClockContainer.MINIMUM_SKIP_TIME) { Alpha = 0; Expire(); @@ -115,10 +110,9 @@ namespace osu.Game.Screens.Play using (BeginAbsoluteSequence(beginFadeTime)) this.FadeOut(fade_time); - button.Action = () => RequestSeek?.Invoke(beginFadeTime); + button.Action = () => RequestSkip?.Invoke(); displayTime = Time.Current; - Expire(); } @@ -335,13 +329,7 @@ namespace osu.Game.Screens.Play box.FlashColour(Color4.White, 500, Easing.OutQuint); aspect.ScaleTo(1.2f, 2000, Easing.OutQuint); - bool result = base.OnClick(e); - - // for now, let's disable the skip button after the first press. - // this will likely need to be contextual in the future (bound from external components). - Enabled.Value = false; - - return result; + return base.OnClick(e); } } } From 586e31efc256964b722de2112d55d367ee88ea56 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Nov 2019 15:56:08 +0900 Subject: [PATCH 062/120] Update tests --- osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs index addf7c3b28..9275dc636c 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using NUnit.Framework; +using osu.Framework.MathUtils; using osu.Game.Beatmaps; using osu.Game.Graphics.Sprites; using osu.Game.Rulesets.Osu; @@ -22,9 +23,7 @@ namespace osu.Game.Tests.Visual.Gameplay BeatmapInfo = { AudioLeadIn = 1000 } }); - AddUntilStep("player loaded", () => player.IsLoaded && player.Alpha == 1); - - AddAssert("correct lead-in", () => player.FirstFrameClockTime == 0); + AddAssert("correct lead-in", () => Precision.AlmostEquals(player.FirstFrameClockTime.Value, 0, 100)); } [Test] @@ -35,7 +34,7 @@ namespace osu.Game.Tests.Visual.Gameplay BeatmapInfo = { AudioLeadIn = 10000 } }); - AddAssert("correct lead-in", () => player.FirstFrameClockTime == player.GameplayStartTime - 10000); + AddAssert("correct lead-in", () => Precision.AlmostEquals(player.FirstFrameClockTime.Value, player.GameplayStartTime - 10000, 100)); } private void loadPlayerWithBeatmap(IBeatmap beatmap) From 2dd2e3d861706d22991174ed0e068f7f3c738ae9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Nov 2019 16:55:18 +0900 Subject: [PATCH 063/120] Add correct AudioLeadIn support --- osu.Game/Screens/Play/GameplayClockContainer.cs | 17 +++++++++++++---- osu.Game/Screens/Play/Player.cs | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Play/GameplayClockContainer.cs b/osu.Game/Screens/Play/GameplayClockContainer.cs index e1f4d8fa94..bc6f649492 100644 --- a/osu.Game/Screens/Play/GameplayClockContainer.cs +++ b/osu.Game/Screens/Play/GameplayClockContainer.cs @@ -41,6 +41,8 @@ namespace osu.Game.Screens.Play private readonly double gameplayStartTime; + private readonly double firstHitObjectTime; + public readonly Bindable UserPlaybackRate = new BindableDouble(1) { Default = 1, @@ -61,11 +63,12 @@ namespace osu.Game.Screens.Play private readonly FramedOffsetClock platformOffsetClock; - public GameplayClockContainer(WorkingBeatmap beatmap, IReadOnlyList mods, double gameplayStartTime) + public GameplayClockContainer(WorkingBeatmap beatmap, IReadOnlyList mods, double gameplayStartTime, double firstHitObjectTime) { this.beatmap = beatmap; this.mods = mods; this.gameplayStartTime = gameplayStartTime; + this.firstHitObjectTime = firstHitObjectTime; RelativeSizeAxes = Axes.Both; @@ -102,11 +105,17 @@ namespace osu.Game.Screens.Play userAudioOffset = config.GetBindable(OsuSetting.AudioOffset); userAudioOffset.BindValueChanged(offset => userOffsetClock.Offset = offset.NewValue, true); - double startTime = -beatmap.BeatmapInfo.AudioLeadIn; + // sane default provided by ruleset. + double startTime = Math.Min(0, gameplayStartTime); + // if a storyboard is present, it may dictate the appropriate start time by having events in negative time space. + // this is commonly used to display an intro before the audio track start. startTime = Math.Min(startTime, beatmap.Storyboard.FirstEventTime); - startTime = Math.Min(startTime, gameplayStartTime); - startTime = Math.Min(startTime, 0); + + // some beatmaps specify a current lead-in time which should be used instead of the ruleset-provided value when available. + // this is not available as an option in the live editor but can still be applied via .osu editing. + if (beatmap.BeatmapInfo.AudioLeadIn > 0) + startTime = Math.Min(startTime, firstHitObjectTime - beatmap.BeatmapInfo.AudioLeadIn); Seek(startTime); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index d6488dc209..cb71693312 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -129,7 +129,7 @@ namespace osu.Game.Screens.Play if (!ScoreProcessor.Mode.Disabled) config.BindWith(OsuSetting.ScoreDisplayMode, ScoreProcessor.Mode); - InternalChild = GameplayClockContainer = new GameplayClockContainer(working, Mods.Value, DrawableRuleset.GameplayStartTime); + InternalChild = GameplayClockContainer = new GameplayClockContainer(working, Mods.Value, DrawableRuleset.GameplayStartTime, DrawableRuleset.Objects.First().StartTime); addUnderlayComponents(GameplayClockContainer); addGameplayComponents(GameplayClockContainer, working); From 29d23749285dfc0773a152ee81536a061cc0c9ee Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Nov 2019 17:12:29 +0900 Subject: [PATCH 064/120] Add back skip button actuation count tests --- .../Visual/Gameplay/TestSceneSkipOverlay.cs | 51 +++++++++++++++++-- osu.Game/Screens/Play/SkipOverlay.cs | 2 + 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs index 0d62d9a520..1b4b0b4dcc 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs @@ -18,27 +18,41 @@ namespace osu.Game.Tests.Visual.Gameplay private SkipOverlay skip; private int requestCount; + private FramedOffsetClock offsetClock; + private StopwatchClock stopwatchClock; + + private double increment; + [SetUp] public void SetUp() => Schedule(() => { requestCount = 0; + increment = 6000; + Child = new Container { RelativeSizeAxes = Axes.Both, - Clock = new FramedOffsetClock(Clock) - { - Offset = -Clock.CurrentTime, - }, + Clock = offsetClock = new FramedOffsetClock(stopwatchClock = new StopwatchClock(true)), Children = new Drawable[] { skip = new SkipOverlay(6000) { - RequestSkip = () => requestCount++ + RequestSkip = () => + { + requestCount++; + offsetClock.Offset += increment; + } } }, }; }); + protected override void Update() + { + if (stopwatchClock != null) + stopwatchClock.Rate = Clock.Rate; + } + [Test] public void TestFadeOnIdle() { @@ -60,6 +74,33 @@ namespace osu.Game.Tests.Visual.Gameplay checkRequestCount(1); } + [Test] + public void TestClickOnlyActuatesOnce() + { + AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre)); + AddStep("click", () => + { + increment = 6000 - offsetClock.CurrentTime - GameplayClockContainer.MINIMUM_SKIP_TIME / 2; + InputManager.Click(MouseButton.Left); + }); + AddStep("click", () => InputManager.Click(MouseButton.Left)); + AddStep("click", () => InputManager.Click(MouseButton.Left)); + AddStep("click", () => InputManager.Click(MouseButton.Left)); + checkRequestCount(1); + } + + [Test] + public void TestClickOnlyActuatesMultipleTimes() + { + AddStep("set increment lower", () => increment = 3000); + AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre)); + AddStep("click", () => InputManager.Click(MouseButton.Left)); + AddStep("click", () => InputManager.Click(MouseButton.Left)); + AddStep("click", () => InputManager.Click(MouseButton.Left)); + AddStep("click", () => InputManager.Click(MouseButton.Left)); + checkRequestCount(2); + } + [Test] public void TestDoesntFadeOnMouseDown() { diff --git a/osu.Game/Screens/Play/SkipOverlay.cs b/osu.Game/Screens/Play/SkipOverlay.cs index 3abe61d1a9..2c6b33be39 100644 --- a/osu.Game/Screens/Play/SkipOverlay.cs +++ b/osu.Game/Screens/Play/SkipOverlay.cs @@ -124,6 +124,8 @@ namespace osu.Game.Screens.Play { base.Update(); remainingTimeBox.ResizeWidthTo((float)Math.Max(0, 1 - (Time.Current - displayTime) / (beginFadeTime - displayTime)), 120, Easing.OutQuint); + + button.Enabled.Value = Time.Current < startTime - GameplayClockContainer.MINIMUM_SKIP_TIME; } protected override bool OnMouseMove(MouseMoveEvent e) From 4e53bca8dd1e8ad8392a13010af04a9e42b69e50 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Nov 2019 18:21:49 +0900 Subject: [PATCH 065/120] Simplify tests --- .../Visual/Gameplay/TestSceneLeadIn.cs | 31 +++++++++++-------- osu.Game/Beatmaps/BeatmapInfo.cs | 2 +- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs index 9275dc636c..6434387f51 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs @@ -1,6 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Diagnostics; +using System.Linq; using NUnit.Framework; using osu.Framework.MathUtils; using osu.Game.Beatmaps; @@ -15,26 +17,26 @@ namespace osu.Game.Tests.Visual.Gameplay { private LeadInPlayer player; - [Test] - public void TestShortLeadIn() + private const double lenience_ms = 10; + + private const double first_hit_object = 2170; + + [TestCase(1000, 0)] + [TestCase(2000, 0)] + [TestCase(3000, first_hit_object - 3000)] + [TestCase(10000, first_hit_object - 10000)] + public void TestLeadInProducesCorrectStartTime(double leadIn, double expectedStartTime) { loadPlayerWithBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo) { - BeatmapInfo = { AudioLeadIn = 1000 } + BeatmapInfo = { AudioLeadIn = leadIn } }); - AddAssert("correct lead-in", () => Precision.AlmostEquals(player.FirstFrameClockTime.Value, 0, 100)); - } - - [Test] - public void TestLongLeadIn() - { - loadPlayerWithBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo) + AddAssert($"first frame is {expectedStartTime}", () => { - BeatmapInfo = { AudioLeadIn = 10000 } + Debug.Assert(player.FirstFrameClockTime != null); + return Precision.AlmostEquals(player.FirstFrameClockTime.Value, expectedStartTime, lenience_ms); }); - - AddAssert("correct lead-in", () => Precision.AlmostEquals(player.FirstFrameClockTime.Value, player.GameplayStartTime - 10000, 100)); } private void loadPlayerWithBeatmap(IBeatmap beatmap) @@ -61,6 +63,8 @@ namespace osu.Game.Tests.Visual.Gameplay public double GameplayStartTime => DrawableRuleset.GameplayStartTime; + public double FirstHitObjectTime => DrawableRuleset.Objects.First().StartTime; + public double GameplayClockTime => GameplayClockContainer.GameplayClock.CurrentTime; protected override void UpdateAfterChildren() @@ -73,6 +77,7 @@ namespace osu.Game.Tests.Visual.Gameplay AddInternal(new OsuSpriteText { Text = $"GameplayStartTime: {DrawableRuleset.GameplayStartTime} " + + $"FirstHitObjectTime: {FirstHitObjectTime} " + $"LeadInTime: {Beatmap.Value.BeatmapInfo.AudioLeadIn} " + $"FirstFrameClockTime: {FirstFrameClockTime}" }); diff --git a/osu.Game/Beatmaps/BeatmapInfo.cs b/osu.Game/Beatmaps/BeatmapInfo.cs index 198046df4f..6e82c465dc 100644 --- a/osu.Game/Beatmaps/BeatmapInfo.cs +++ b/osu.Game/Beatmaps/BeatmapInfo.cs @@ -76,7 +76,7 @@ namespace osu.Game.Beatmaps public string MD5Hash { get; set; } // General - public int AudioLeadIn { get; set; } + public double AudioLeadIn { get; set; } public bool Countdown { get; set; } = true; public float StackLeniency { get; set; } = 0.7f; public bool SpecialStyle { get; set; } From 8d1b11d4bd86b644c683bd74eac0dc893f61823a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Nov 2019 18:50:54 +0900 Subject: [PATCH 066/120] Add storyboard lead-in tests --- .../TestSceneSkinFallbacks.cs | 7 +++-- .../TestSceneSpinnerRotation.cs | 5 ++-- .../Visual/Gameplay/TestSceneAutoplay.cs | 5 ++-- .../Gameplay/TestSceneGameplayRewinding.cs | 5 ++-- .../Visual/Gameplay/TestSceneLeadIn.cs | 29 +++++++++++++++++-- .../TestScenePlayerReferenceLeaking.cs | 5 ++-- .../Drawables/DrawableStoryboardSprite.cs | 2 +- osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs | 10 +++++-- osu.Game/Tests/Visual/OsuTestScene.cs | 14 +++++---- 9 files changed, 60 insertions(+), 22 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs index 02c65db6ad..7ca311118e 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs @@ -19,6 +19,7 @@ using osu.Game.Graphics; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Screens.Play; using osu.Game.Skinning; +using osu.Game.Storyboards; using osu.Game.Tests.Visual; namespace osu.Game.Rulesets.Osu.Tests @@ -75,14 +76,14 @@ namespace osu.Game.Rulesets.Osu.Tests protected override Player CreatePlayer(Ruleset ruleset) => new SkinProvidingPlayer(testUserSkin); - protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap) => new CustomSkinWorkingBeatmap(beatmap, Clock, audio, testBeatmapSkin); + protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) => new CustomSkinWorkingBeatmap(beatmap, storyboard, Clock, audio, testBeatmapSkin); public class CustomSkinWorkingBeatmap : ClockBackedTestWorkingBeatmap { private readonly ISkinSource skin; - public CustomSkinWorkingBeatmap(IBeatmap beatmap, IFrameBasedClock frameBasedClock, AudioManager audio, ISkinSource skin) - : base(beatmap, frameBasedClock, audio) + public CustomSkinWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock frameBasedClock, AudioManager audio, ISkinSource skin) + : base(beatmap, storyboard, frameBasedClock, audio) { this.skin = skin; } diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerRotation.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerRotation.cs index cded7f0e95..d0ce0c33c2 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerRotation.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerRotation.cs @@ -15,6 +15,7 @@ using osu.Game.Tests.Visual; using osuTK; using System.Collections.Generic; using System.Linq; +using osu.Game.Storyboards; using static osu.Game.Tests.Visual.OsuTestScene.ClockBackedTestWorkingBeatmap; namespace osu.Game.Rulesets.Osu.Tests @@ -28,9 +29,9 @@ namespace osu.Game.Rulesets.Osu.Tests protected override bool Autoplay => true; - protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap) + protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) { - var working = new ClockBackedTestWorkingBeatmap(beatmap, new FramedClock(new ManualClock { Rate = 1 }), audioManager); + var working = new ClockBackedTestWorkingBeatmap(beatmap, storyboard, new FramedClock(new ManualClock { Rate = 1 }), audioManager); track = (TrackVirtualManual)working.Track; return working; } diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneAutoplay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneAutoplay.cs index f94071a7a9..5ee109e3dd 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneAutoplay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneAutoplay.cs @@ -7,6 +7,7 @@ using osu.Game.Beatmaps; using osu.Game.Rulesets; using osu.Game.Rulesets.Scoring; using osu.Game.Screens.Play; +using osu.Game.Storyboards; namespace osu.Game.Tests.Visual.Gameplay { @@ -29,9 +30,9 @@ namespace osu.Game.Tests.Visual.Gameplay AddUntilStep("key counter reset", () => ((ScoreAccessiblePlayer)Player).HUDOverlay.KeyCounter.Children.All(kc => kc.CountPresses == 0)); } - protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap) + protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) { - var working = base.CreateWorkingBeatmap(beatmap); + var working = base.CreateWorkingBeatmap(beatmap, storyboard); track = (ClockBackedTestWorkingBeatmap.TrackVirtualManual)working.Track; diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayRewinding.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayRewinding.cs index ffc025a942..b2b58a63fb 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayRewinding.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayRewinding.cs @@ -17,6 +17,7 @@ using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; using osu.Game.Screens.Play; +using osu.Game.Storyboards; using osuTK; namespace osu.Game.Tests.Visual.Gameplay @@ -35,9 +36,9 @@ namespace osu.Game.Tests.Visual.Gameplay private Track track; - protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap) + protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) { - var working = new ClockBackedTestWorkingBeatmap(beatmap, new FramedClock(new ManualClock { Rate = 1 }), audioManager); + var working = new ClockBackedTestWorkingBeatmap(beatmap, storyboard, new FramedClock(new ManualClock { Rate = 1 }), audioManager); track = working.Track; return working; } diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs index 6434387f51..0150c6ea74 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs @@ -4,12 +4,15 @@ using System.Diagnostics; using System.Linq; using NUnit.Framework; +using osu.Framework.Graphics; using osu.Framework.MathUtils; using osu.Game.Beatmaps; using osu.Game.Graphics.Sprites; using osu.Game.Rulesets.Osu; using osu.Game.Screens.Play; +using osu.Game.Storyboards; using osu.Game.Tests.Beatmaps; +using osuTK; namespace osu.Game.Tests.Visual.Gameplay { @@ -39,11 +42,33 @@ namespace osu.Game.Tests.Visual.Gameplay }); } - private void loadPlayerWithBeatmap(IBeatmap beatmap) + [TestCase(1000, 0)] + [TestCase(0, 0)] + [TestCase(-1000, -1000)] + [TestCase(-10000, -10000)] + public void TestStoryboardProducesCorrectStartTime(double firstStoryboardEvent, double expectedStartTime) + { + var storyboard = new Storyboard(); + + var sprite = new StoryboardSprite("unknown", Anchor.TopLeft, Vector2.Zero); + sprite.TimelineGroup.Alpha.Add(Easing.None, firstStoryboardEvent, firstStoryboardEvent + 500, 0, 1); + + storyboard.GetLayer("Background").Add(sprite); + + loadPlayerWithBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo), storyboard); + + AddAssert($"first frame is {expectedStartTime}", () => + { + Debug.Assert(player.FirstFrameClockTime != null); + return Precision.AlmostEquals(player.FirstFrameClockTime.Value, expectedStartTime, lenience_ms); + }); + } + + private void loadPlayerWithBeatmap(IBeatmap beatmap, Storyboard storyboard = null) { AddStep("create player", () => { - Beatmap.Value = CreateWorkingBeatmap(beatmap); + Beatmap.Value = CreateWorkingBeatmap(beatmap, storyboard); LoadScreen(player = new LeadInPlayer()); }); diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerReferenceLeaking.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerReferenceLeaking.cs index 65b56319e8..4d701f56a9 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerReferenceLeaking.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerReferenceLeaking.cs @@ -6,6 +6,7 @@ using osu.Framework.Lists; using osu.Game.Beatmaps; using osu.Game.Rulesets; using osu.Game.Screens.Play; +using osu.Game.Storyboards; namespace osu.Game.Tests.Visual.Gameplay { @@ -42,9 +43,9 @@ namespace osu.Game.Tests.Visual.Gameplay }); } - protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap) + protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) { - var working = base.CreateWorkingBeatmap(beatmap); + var working = base.CreateWorkingBeatmap(beatmap, storyboard); workingWeakReferences.Add(working); return working; } diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs index 5f1f5ddacb..3a117d1713 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs @@ -66,7 +66,7 @@ namespace osu.Game.Storyboards.Drawables [BackgroundDependencyLoader] private void load(IBindable beatmap, TextureStore textureStore) { - var path = beatmap.Value.BeatmapSetInfo.Files.Find(f => f.Filename.Equals(Sprite.Path, StringComparison.InvariantCultureIgnoreCase))?.FileInfo.StoragePath; + var path = beatmap.Value.BeatmapSetInfo?.Files?.Find(f => f.Filename.Equals(Sprite.Path, StringComparison.InvariantCultureIgnoreCase))?.FileInfo.StoragePath; if (path == null) return; diff --git a/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs b/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs index 0d9f4f51be..871d8ee3f1 100644 --- a/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs +++ b/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs @@ -5,25 +5,31 @@ using osu.Framework.Audio.Track; using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Video; using osu.Game.Beatmaps; +using osu.Game.Storyboards; namespace osu.Game.Tests.Beatmaps { public class TestWorkingBeatmap : WorkingBeatmap { private readonly IBeatmap beatmap; + private readonly Storyboard storyboard; /// /// Create an instance which provides the when requested. /// - /// The beatmap - public TestWorkingBeatmap(IBeatmap beatmap) + /// The beatmap. + /// An optional storyboard. + public TestWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) : base(beatmap.BeatmapInfo, null) { this.beatmap = beatmap; + this.storyboard = storyboard; } protected override IBeatmap GetBeatmap() => beatmap; + protected override Storyboard GetStoryboard() => storyboard ?? base.GetStoryboard(); + protected override Texture GetBackground() => null; protected override VideoSprite GetVideo() => null; diff --git a/osu.Game/Tests/Visual/OsuTestScene.cs b/osu.Game/Tests/Visual/OsuTestScene.cs index 13e08c7d22..be67c2fe23 100644 --- a/osu.Game/Tests/Visual/OsuTestScene.cs +++ b/osu.Game/Tests/Visual/OsuTestScene.cs @@ -21,6 +21,7 @@ using osu.Game.Database; using osu.Game.Online.API; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; +using osu.Game.Storyboards; using osu.Game.Tests.Beatmaps; namespace osu.Game.Tests.Visual @@ -119,10 +120,10 @@ namespace osu.Game.Tests.Visual protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset); protected WorkingBeatmap CreateWorkingBeatmap(RulesetInfo ruleset) => - CreateWorkingBeatmap(CreateBeatmap(ruleset)); + CreateWorkingBeatmap(CreateBeatmap(ruleset), null); - protected virtual WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap) => - new ClockBackedTestWorkingBeatmap(beatmap, Clock, audio); + protected virtual WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) => + new ClockBackedTestWorkingBeatmap(beatmap, storyboard, Clock, audio); [BackgroundDependencyLoader] private void load(RulesetStore rulesets) @@ -168,7 +169,7 @@ namespace osu.Game.Tests.Visual /// A clock which should be used instead of a stopwatch for virtual time progression. /// Audio manager. Required if a reference clock isn't provided. public ClockBackedTestWorkingBeatmap(RulesetInfo ruleset, IFrameBasedClock referenceClock, AudioManager audio) - : this(new TestBeatmap(ruleset), referenceClock, audio) + : this(new TestBeatmap(ruleset), null, referenceClock, audio) { } @@ -176,11 +177,12 @@ namespace osu.Game.Tests.Visual /// Create an instance which provides the when requested. /// /// The beatmap + /// The storyboard. /// An optional clock which should be used instead of a stopwatch for virtual time progression. /// Audio manager. Required if a reference clock isn't provided. /// The length of the returned virtual track. - public ClockBackedTestWorkingBeatmap(IBeatmap beatmap, IFrameBasedClock referenceClock, AudioManager audio, double length = 60000) - : base(beatmap) + public ClockBackedTestWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock referenceClock, AudioManager audio, double length = 60000) + : base(beatmap, storyboard) { if (referenceClock != null) { From 46a94821d44129975336136556b2b18e9e791e1b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Nov 2019 18:57:19 +0900 Subject: [PATCH 067/120] Add support for consecutive skips --- .../Visual/Gameplay/TestSceneSkipOverlay.cs | 42 ++++++++++++++++--- .../Screens/Play/GameplayClockContainer.cs | 22 ++++++++++ osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Play/SkipOverlay.cs | 22 +++------- 4 files changed, 65 insertions(+), 23 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs index b152c21454..1b4b0b4dcc 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs @@ -18,27 +18,41 @@ namespace osu.Game.Tests.Visual.Gameplay private SkipOverlay skip; private int requestCount; + private FramedOffsetClock offsetClock; + private StopwatchClock stopwatchClock; + + private double increment; + [SetUp] public void SetUp() => Schedule(() => { requestCount = 0; + increment = 6000; + Child = new Container { RelativeSizeAxes = Axes.Both, - Clock = new FramedOffsetClock(Clock) - { - Offset = -Clock.CurrentTime, - }, + Clock = offsetClock = new FramedOffsetClock(stopwatchClock = new StopwatchClock(true)), Children = new Drawable[] { skip = new SkipOverlay(6000) { - RequestSeek = _ => requestCount++ + RequestSkip = () => + { + requestCount++; + offsetClock.Offset += increment; + } } }, }; }); + protected override void Update() + { + if (stopwatchClock != null) + stopwatchClock.Rate = Clock.Rate; + } + [Test] public void TestFadeOnIdle() { @@ -64,13 +78,29 @@ namespace osu.Game.Tests.Visual.Gameplay public void TestClickOnlyActuatesOnce() { AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre)); - AddStep("click", () => InputManager.Click(MouseButton.Left)); + AddStep("click", () => + { + increment = 6000 - offsetClock.CurrentTime - GameplayClockContainer.MINIMUM_SKIP_TIME / 2; + InputManager.Click(MouseButton.Left); + }); AddStep("click", () => InputManager.Click(MouseButton.Left)); AddStep("click", () => InputManager.Click(MouseButton.Left)); AddStep("click", () => InputManager.Click(MouseButton.Left)); checkRequestCount(1); } + [Test] + public void TestClickOnlyActuatesMultipleTimes() + { + AddStep("set increment lower", () => increment = 3000); + AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre)); + AddStep("click", () => InputManager.Click(MouseButton.Left)); + AddStep("click", () => InputManager.Click(MouseButton.Left)); + AddStep("click", () => InputManager.Click(MouseButton.Left)); + AddStep("click", () => InputManager.Click(MouseButton.Left)); + checkRequestCount(2); + } + [Test] public void TestDoesntFadeOnMouseDown() { diff --git a/osu.Game/Screens/Play/GameplayClockContainer.cs b/osu.Game/Screens/Play/GameplayClockContainer.cs index 2f2028ff53..6903ccf06d 100644 --- a/osu.Game/Screens/Play/GameplayClockContainer.cs +++ b/osu.Game/Screens/Play/GameplayClockContainer.cs @@ -89,6 +89,11 @@ namespace osu.Game.Screens.Play private double totalOffset => userOffsetClock.Offset + platformOffsetClock.Offset; + /// + /// Duration before gameplay start time required before skip button displays. + /// + public const double MINIMUM_SKIP_TIME = 1000; + private readonly BindableDouble pauseFreqAdjust = new BindableDouble(1); [BackgroundDependencyLoader] @@ -130,6 +135,23 @@ namespace osu.Game.Screens.Play this.TransformBindableTo(pauseFreqAdjust, 1, 200, Easing.In); } + /// + /// Skip forward to the next valid skip point. + /// + public void Skip() + { + if (GameplayClock.CurrentTime > gameplayStartTime - MINIMUM_SKIP_TIME) + return; + + double skipTarget = gameplayStartTime - MINIMUM_SKIP_TIME; + + if (GameplayClock.CurrentTime < 0 && skipTarget > 6000) + // double skip exception for storyboards with very long intros + skipTarget = 0; + + Seek(skipTarget); + } + /// /// Seek to a specific time in gameplay. /// diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index a9b0649fab..d6488dc209 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -203,7 +203,7 @@ namespace osu.Game.Screens.Play }, new SkipOverlay(DrawableRuleset.GameplayStartTime) { - RequestSeek = GameplayClockContainer.Seek + RequestSkip = GameplayClockContainer.Skip }, FailOverlay = new FailOverlay { diff --git a/osu.Game/Screens/Play/SkipOverlay.cs b/osu.Game/Screens/Play/SkipOverlay.cs index 835867fe62..2c6b33be39 100644 --- a/osu.Game/Screens/Play/SkipOverlay.cs +++ b/osu.Game/Screens/Play/SkipOverlay.cs @@ -27,7 +27,7 @@ namespace osu.Game.Screens.Play { private readonly double startTime; - public Action RequestSeek; + public Action RequestSkip; private Button button; private Box remainingTimeBox; @@ -90,11 +90,6 @@ namespace osu.Game.Screens.Play }; } - /// - /// Duration before gameplay start time required before skip button displays. - /// - private const double skip_buffer = 1000; - private const double fade_time = 300; private double beginFadeTime => startTime - fade_time; @@ -104,7 +99,7 @@ namespace osu.Game.Screens.Play base.LoadComplete(); // skip is not required if there is no extra "empty" time to skip. - if (Clock.CurrentTime > beginFadeTime - skip_buffer) + if (Clock.CurrentTime > beginFadeTime - GameplayClockContainer.MINIMUM_SKIP_TIME) { Alpha = 0; Expire(); @@ -115,10 +110,9 @@ namespace osu.Game.Screens.Play using (BeginAbsoluteSequence(beginFadeTime)) this.FadeOut(fade_time); - button.Action = () => RequestSeek?.Invoke(beginFadeTime); + button.Action = () => RequestSkip?.Invoke(); displayTime = Time.Current; - Expire(); } @@ -130,6 +124,8 @@ namespace osu.Game.Screens.Play { base.Update(); remainingTimeBox.ResizeWidthTo((float)Math.Max(0, 1 - (Time.Current - displayTime) / (beginFadeTime - displayTime)), 120, Easing.OutQuint); + + button.Enabled.Value = Time.Current < startTime - GameplayClockContainer.MINIMUM_SKIP_TIME; } protected override bool OnMouseMove(MouseMoveEvent e) @@ -335,13 +331,7 @@ namespace osu.Game.Screens.Play box.FlashColour(Color4.White, 500, Easing.OutQuint); aspect.ScaleTo(1.2f, 2000, Easing.OutQuint); - bool result = base.OnClick(e); - - // for now, let's disable the skip button after the first press. - // this will likely need to be contextual in the future (bound from external components). - Enabled.Value = false; - - return result; + return base.OnClick(e); } } } From bd6831624a58802f022eccc616d90f977c9155e3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Nov 2019 19:51:22 +0900 Subject: [PATCH 068/120] Decouple skip button animations from gameplay clock --- .../Visual/Gameplay/TestSceneSkipOverlay.cs | 32 +++++++-------- osu.Game/Screens/Play/SkipOverlay.cs | 40 +++++++++---------- 2 files changed, 33 insertions(+), 39 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs index 1b4b0b4dcc..a21f55e361 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs @@ -4,8 +4,8 @@ using System.Linq; using NUnit.Framework; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Timing; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Osu; using osu.Game.Screens.Play; using osuTK; using osuTK.Input; @@ -18,40 +18,38 @@ namespace osu.Game.Tests.Visual.Gameplay private SkipOverlay skip; private int requestCount; - private FramedOffsetClock offsetClock; - private StopwatchClock stopwatchClock; - private double increment; + private GameplayClockContainer gameplayClockContainer; + private GameplayClock gameplayClock; + + private const double skip_time = 6000; + [SetUp] public void SetUp() => Schedule(() => { requestCount = 0; - increment = 6000; + increment = skip_time; - Child = new Container + Child = gameplayClockContainer = new GameplayClockContainer(CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)), new Mod[] { }, 0) { RelativeSizeAxes = Axes.Both, - Clock = offsetClock = new FramedOffsetClock(stopwatchClock = new StopwatchClock(true)), Children = new Drawable[] { - skip = new SkipOverlay(6000) + skip = new SkipOverlay(skip_time) { RequestSkip = () => { requestCount++; - offsetClock.Offset += increment; + gameplayClockContainer.Seek(gameplayClock.CurrentTime + increment); } } }, }; - }); - protected override void Update() - { - if (stopwatchClock != null) - stopwatchClock.Rate = Clock.Rate; - } + gameplayClockContainer.Start(); + gameplayClock = gameplayClockContainer.GameplayClock; + }); [Test] public void TestFadeOnIdle() @@ -80,7 +78,7 @@ namespace osu.Game.Tests.Visual.Gameplay AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre)); AddStep("click", () => { - increment = 6000 - offsetClock.CurrentTime - GameplayClockContainer.MINIMUM_SKIP_TIME / 2; + increment = skip_time - gameplayClock.CurrentTime - GameplayClockContainer.MINIMUM_SKIP_TIME / 2; InputManager.Click(MouseButton.Left); }); AddStep("click", () => InputManager.Click(MouseButton.Left)); diff --git a/osu.Game/Screens/Play/SkipOverlay.cs b/osu.Game/Screens/Play/SkipOverlay.cs index 2c6b33be39..1a5ed20953 100644 --- a/osu.Game/Screens/Play/SkipOverlay.cs +++ b/osu.Game/Screens/Play/SkipOverlay.cs @@ -19,6 +19,7 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Graphics.Containers; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; +using osu.Framework.MathUtils; using osu.Game.Input.Bindings; namespace osu.Game.Screens.Play @@ -35,6 +36,9 @@ namespace osu.Game.Screens.Play private FadeContainer fadeContainer; private double displayTime; + [Resolved] + private GameplayClock gameplayClock { get; set; } + public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; /// @@ -45,8 +49,6 @@ namespace osu.Game.Screens.Play { this.startTime = startTime; - Show(); - RelativePositionAxes = Axes.Both; RelativeSizeAxes = Axes.X; @@ -57,13 +59,8 @@ namespace osu.Game.Screens.Play } [BackgroundDependencyLoader(true)] - private void load(OsuColour colours, GameplayClock clock) + private void load(OsuColour colours) { - var baseClock = Clock; - - if (clock != null) - Clock = clock; - Children = new Drawable[] { fadeContainer = new FadeContainer @@ -73,7 +70,6 @@ namespace osu.Game.Screens.Play { button = new Button { - Clock = baseClock, Anchor = Anchor.Centre, Origin = Anchor.Centre, }, @@ -92,40 +88,40 @@ namespace osu.Game.Screens.Play private const double fade_time = 300; - private double beginFadeTime => startTime - fade_time; + private double fadeOutBeginTime => startTime - GameplayClockContainer.MINIMUM_SKIP_TIME; protected override void LoadComplete() { base.LoadComplete(); // skip is not required if there is no extra "empty" time to skip. - if (Clock.CurrentTime > beginFadeTime - GameplayClockContainer.MINIMUM_SKIP_TIME) + // we may need to remove this if rewinding before the initial player load position becomes a thing. + if (fadeOutBeginTime < gameplayClock.CurrentTime) { - Alpha = 0; Expire(); return; } - this.FadeInFromZero(fade_time); - using (BeginAbsoluteSequence(beginFadeTime)) - this.FadeOut(fade_time); - button.Action = () => RequestSkip?.Invoke(); + displayTime = gameplayClock.CurrentTime; - displayTime = Time.Current; - Expire(); + Show(); } - protected override void PopIn() => this.FadeIn(); + protected override void PopIn() => this.FadeIn(fade_time); - protected override void PopOut() => this.FadeOut(); + protected override void PopOut() => this.FadeOut(fade_time); protected override void Update() { base.Update(); - remainingTimeBox.ResizeWidthTo((float)Math.Max(0, 1 - (Time.Current - displayTime) / (beginFadeTime - displayTime)), 120, Easing.OutQuint); - button.Enabled.Value = Time.Current < startTime - GameplayClockContainer.MINIMUM_SKIP_TIME; + var progress = Math.Max(0, 1 - (gameplayClock.CurrentTime - displayTime) / (fadeOutBeginTime - displayTime)); + + remainingTimeBox.Width = (float)Interpolation.Lerp(remainingTimeBox.Width, progress, Math.Clamp(Time.Elapsed / 40, 0, 1)); + + button.Enabled.Value = progress > 0; + State.Value = progress > 0 ? Visibility.Visible : Visibility.Hidden; } protected override bool OnMouseMove(MouseMoveEvent e) From 71a64da566a685cce2ad929d989afab589c2b60e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Nov 2019 22:07:37 +0900 Subject: [PATCH 069/120] Fix test regressions --- osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs index a21f55e361..875e7b9758 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs @@ -104,7 +104,7 @@ namespace osu.Game.Tests.Visual.Gameplay { AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre)); AddStep("button down", () => InputManager.PressButton(MouseButton.Left)); - AddUntilStep("wait for overlay disapper", () => !skip.IsAlive); + AddUntilStep("wait for overlay disappear", () => !skip.IsPresent); AddAssert("ensure button didn't disappear", () => skip.Children.First().Alpha > 0); AddStep("button up", () => InputManager.ReleaseButton(MouseButton.Left)); checkRequestCount(0); From 737c2bd1c8fa1a66bcf47160cc675fe082985941 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 21 Nov 2019 18:50:29 +0300 Subject: [PATCH 070/120] Remove pointless const --- osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index e62a754e92..ac8952bebb 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -97,7 +97,6 @@ namespace osu.Game.Overlays.BeatmapSet private class ModButton : ModIcon { - private const float mod_scale = 0.4f; private const int duration = 200; public readonly BindableBool Selected = new BindableBool(); @@ -106,7 +105,7 @@ namespace osu.Game.Overlays.BeatmapSet public ModButton(Mod mod) : base(mod) { - Scale = new Vector2(mod_scale); + Scale = new Vector2(0.4f); Highlighted.Value = true; Add(new HoverClickSounds()); } From 984ec11a78ca071e70d04cd5899ee7b07cfad140 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 21 Nov 2019 18:56:48 +0300 Subject: [PATCH 071/120] Make Ruleset a bindable --- .../Online/TestSceneLeaderboardModSelector.cs | 14 ++++-- .../BeatmapSet/LeaderboardModSelector.cs | 49 ++++++++----------- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs index c0c18c2583..ebe233a5f4 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs @@ -12,6 +12,8 @@ using osu.Game.Rulesets.Catch; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Framework.Bindables; +using osu.Game.Rulesets; namespace osu.Game.Tests.Visual.Online { @@ -26,6 +28,7 @@ namespace osu.Game.Tests.Visual.Online { LeaderboardModSelector modSelector; FillFlowContainer selectedMods; + var ruleset = new Bindable(); Add(selectedMods = new FillFlowContainer { @@ -37,6 +40,7 @@ namespace osu.Game.Tests.Visual.Online { Anchor = Anchor.Centre, Origin = Anchor.Centre, + Ruleset = { BindTarget = ruleset } }); modSelector.SelectedMods.ItemsAdded += mods => @@ -62,12 +66,12 @@ namespace osu.Game.Tests.Visual.Online }); }; - AddStep("osu ruleset", () => modSelector.Ruleset = new OsuRuleset().RulesetInfo); - AddStep("mania ruleset", () => modSelector.Ruleset = new ManiaRuleset().RulesetInfo); - AddStep("taiko ruleset", () => modSelector.Ruleset = new TaikoRuleset().RulesetInfo); - AddStep("catch ruleset", () => modSelector.Ruleset = new CatchRuleset().RulesetInfo); + AddStep("osu ruleset", () => ruleset.Value = new OsuRuleset().RulesetInfo); + AddStep("mania ruleset", () => ruleset.Value = new ManiaRuleset().RulesetInfo); + AddStep("taiko ruleset", () => ruleset.Value = new TaikoRuleset().RulesetInfo); + AddStep("catch ruleset", () => ruleset.Value = new CatchRuleset().RulesetInfo); AddStep("Deselect all", () => modSelector.DeselectAll()); - AddStep("null ruleset", () => modSelector.Ruleset = null); + AddStep("null ruleset", () => ruleset.Value = null); } } } diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index ac8952bebb..ba42e8c310 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -20,34 +20,7 @@ namespace osu.Game.Overlays.BeatmapSet public class LeaderboardModSelector : CompositeDrawable { public readonly BindableList SelectedMods = new BindableList(); - - private RulesetInfo ruleset; - - public RulesetInfo Ruleset - { - get => ruleset; - set - { - if (ruleset?.Equals(value) ?? false) - { - DeselectAll(); - return; - } - - ruleset = value; - - SelectedMods.Clear(); - modsContainer.Clear(); - - if (ruleset == null) - return; - - modsContainer.Add(new ModButton(new ModNoMod())); - modsContainer.AddRange(ruleset.CreateInstance().GetAllMods().Where(m => m.Ranked).Select(m => new ModButton(m))); - - modsContainer.ForEach(button => button.OnSelectionChanged = selectionChanged); - } - } + public readonly Bindable Ruleset = new Bindable(); private readonly FillFlowContainer modsContainer; @@ -64,6 +37,26 @@ namespace osu.Game.Overlays.BeatmapSet }; } + protected override void LoadComplete() + { + base.LoadComplete(); + Ruleset.BindValueChanged(onRulesetChanged, true); + } + + private void onRulesetChanged(ValueChangedEvent ruleset) + { + SelectedMods.Clear(); + modsContainer.Clear(); + + if (ruleset.NewValue == null) + return; + + modsContainer.Add(new ModButton(new ModNoMod())); + modsContainer.AddRange(ruleset.NewValue.CreateInstance().GetAllMods().Where(m => m.Ranked).Select(m => new ModButton(m))); + + modsContainer.ForEach(button => button.OnSelectionChanged = selectionChanged); + } + private void selectionChanged(Mod mod, bool selected) { if (selected) From 23fc7b198782d79333edfa849a29bfe27f9805cd Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 21 Nov 2019 19:02:24 +0300 Subject: [PATCH 072/120] Implement updateHighlighted method --- .../BeatmapSet/LeaderboardModSelector.cs | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index ba42e8c310..0a053c98db 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -64,24 +64,34 @@ namespace osu.Game.Overlays.BeatmapSet else SelectedMods.Remove(mod); - if (!SelectedMods.Any() && !IsHovered) + updateHighlighted(); + } + + private void updateHighlighted() + { + if (SelectedMods.Any()) + return; + + if (IsHovered) + { + modsContainer.Children.Where(button => !button.IsHovered).ForEach(button => button.Highlighted.Value = false); + } + else + { highlightAll(); + } } protected override bool OnHover(HoverEvent e) { - if (!SelectedMods.Any()) - modsContainer.Children.Where(button => !button.IsHovered).ForEach(button => button.Highlighted.Value = false); - + updateHighlighted(); return base.OnHover(e); } protected override void OnHoverLost(HoverLostEvent e) { base.OnHoverLost(e); - - if (!SelectedMods.Any()) - highlightAll(); + updateHighlighted(); } public void DeselectAll() => modsContainer.ForEach(mod => mod.Selected.Value = false); From e22a71c6b80125e63660b3a0799b7325bce50348 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 21 Nov 2019 19:42:07 +0300 Subject: [PATCH 073/120] Add visual difference between hovered and selected states --- .../BeatmapSet/LeaderboardModSelector.cs | 44 ++++++++----------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index 0a053c98db..0e9e848e7a 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -72,14 +72,7 @@ namespace osu.Game.Overlays.BeatmapSet if (SelectedMods.Any()) return; - if (IsHovered) - { - modsContainer.Children.Where(button => !button.IsHovered).ForEach(button => button.Highlighted.Value = false); - } - else - { - highlightAll(); - } + modsContainer.Children.Where(button => !button.IsHovered).ForEach(button => button.IsActive.Value = !IsHovered); } protected override bool OnHover(HoverEvent e) @@ -94,22 +87,19 @@ namespace osu.Game.Overlays.BeatmapSet updateHighlighted(); } - public void DeselectAll() => modsContainer.ForEach(mod => mod.Selected.Value = false); - - private void highlightAll() => modsContainer.ForEach(mod => mod.Highlighted.Value = true); + public void DeselectAll() => modsContainer.ForEach(mod => mod.Highlighted.Value = false); private class ModButton : ModIcon { private const int duration = 200; - public readonly BindableBool Selected = new BindableBool(); + public readonly BindableBool IsActive = new BindableBool(); public Action OnSelectionChanged; public ModButton(Mod mod) : base(mod) { Scale = new Vector2(0.4f); - Highlighted.Value = true; Add(new HoverClickSounds()); } @@ -117,35 +107,39 @@ namespace osu.Game.Overlays.BeatmapSet { base.LoadComplete(); - Selected.BindValueChanged(selected => + IsActive.BindValueChanged(hovered => { - updateState(); - OnSelectionChanged?.Invoke(Mod, selected.NewValue); - }); + if (Highlighted.Value) + return; + + this.FadeColour(hovered.NewValue ? Color4.White : Color4.DimGray, duration, Easing.OutQuint); + }, true); + } + + protected override void OnHighlightedChanged(ValueChangedEvent highlighted) + { + base.OnHighlightedChanged(highlighted); + OnSelectionChanged?.Invoke(Mod, highlighted.NewValue); + IsActive.TriggerChange(); } protected override bool OnClick(ClickEvent e) { - Selected.Toggle(); + Highlighted.Toggle(); return true; } protected override bool OnHover(HoverEvent e) { - updateState(); + IsActive.Value = true; return false; } protected override void OnHoverLost(HoverLostEvent e) { base.OnHoverLost(e); - updateState(); + IsActive.Value = false; } - - private void updateState() => Highlighted.Value = IsHovered || Selected.Value; - - protected override void OnHighlightedChanged(ValueChangedEvent highlighted) => - this.FadeColour(highlighted.NewValue ? Color4.White : Color4.Gray, duration, Easing.OutQuint); } } } From c7c8527f5ff780ccf012b41720545084757486b8 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 21 Nov 2019 20:22:15 +0300 Subject: [PATCH 074/120] Remove OnHighlightedChanged function --- .../Overlays/BeatmapSet/LeaderboardModSelector.cs | 11 +++++------ osu.Game/Rulesets/UI/ModIcon.cs | 9 +-------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index 0e9e848e7a..bb6f889c40 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -114,13 +114,12 @@ namespace osu.Game.Overlays.BeatmapSet this.FadeColour(hovered.NewValue ? Color4.White : Color4.DimGray, duration, Easing.OutQuint); }, true); - } - protected override void OnHighlightedChanged(ValueChangedEvent highlighted) - { - base.OnHighlightedChanged(highlighted); - OnSelectionChanged?.Invoke(Mod, highlighted.NewValue); - IsActive.TriggerChange(); + Highlighted.BindValueChanged(highlighted => + { + OnSelectionChanged?.Invoke(Mod, highlighted.NewValue); + IsActive.TriggerChange(); + }, true); } protected override bool OnClick(ClickEvent e) diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index 19211e0c80..cf1bbadb57 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -107,19 +107,12 @@ namespace osu.Game.Rulesets.UI modIcon.Colour = colours.Yellow; break; } - - background.Colour = backgroundColour; } protected override void LoadComplete() { base.LoadComplete(); - Highlighted.BindValueChanged(OnHighlightedChanged, true); - } - - protected virtual void OnHighlightedChanged(ValueChangedEvent highlighted) - { - background.Colour = highlighted.NewValue ? highlightedColour : backgroundColour; + Highlighted.BindValueChanged(highlighted => background.Colour = highlighted.NewValue ? highlightedColour : backgroundColour, true); } } } From f390e558c76532b4ac2d784a9cc02af0058122bd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 22 Nov 2019 02:32:02 +0900 Subject: [PATCH 075/120] Combine and simplify beatmap change logic --- osu.Game/Graphics/Containers/ScalingContainer.cs | 10 ---------- .../Screens/Backgrounds/BackgroundScreenDefault.cs | 1 + osu.Game/Screens/Menu/MainMenu.cs | 11 ----------- 3 files changed, 1 insertion(+), 21 deletions(-) diff --git a/osu.Game/Graphics/Containers/ScalingContainer.cs b/osu.Game/Graphics/Containers/ScalingContainer.cs index 023d295b08..8f07c3a656 100644 --- a/osu.Game/Graphics/Containers/ScalingContainer.cs +++ b/osu.Game/Graphics/Containers/ScalingContainer.cs @@ -6,7 +6,6 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Screens; -using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Screens; using osu.Game.Screens.Backgrounds; @@ -155,15 +154,6 @@ namespace osu.Game.Graphics.Containers private class ScalingBackgroundScreen : BackgroundScreenDefault { - private IBindable beatmap; - - [BackgroundDependencyLoader] - private void load(IBindable beatmap) - { - this.beatmap = beatmap.GetBoundCopy(); - this.beatmap.ValueChanged += _ => Next(); - } - public override void OnEntering(IScreen last) { this.FadeInFromZero(4000, Easing.OutQuint); diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs index 93590b0543..d49751f511 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs @@ -46,6 +46,7 @@ namespace osu.Game.Screens.Backgrounds user.ValueChanged += _ => Next(); skin.ValueChanged += _ => Next(); mode.ValueChanged += _ => Next(); + beatmap.ValueChanged += _ => Next(); currentDisplay = RNG.Next(0, background_count); diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 08338845e6..231115d1e1 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -10,7 +10,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Platform; using osu.Framework.Screens; -using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Graphics.Containers; @@ -170,8 +169,6 @@ namespace osu.Game.Screens.Menu track.Start(); } } - - Beatmap.ValueChanged += beatmap_ValueChanged; } private bool exitConfirmed; @@ -220,14 +217,6 @@ namespace osu.Game.Screens.Menu seq.OnAbort(_ => buttons.SetOsuLogo(null)); } - private void beatmap_ValueChanged(ValueChangedEvent e) - { - if (!this.IsCurrentScreen()) - return; - - ((BackgroundScreenDefault)Background).Next(); - } - public override void OnSuspending(IScreen next) { base.OnSuspending(next); From 0f1a3d97c8d5c7a6daf9330663e3d81677d6d3f6 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 21 Nov 2019 20:34:19 +0300 Subject: [PATCH 076/120] Naming adjustments --- .../BeatmapSet/LeaderboardModSelector.cs | 32 +++++++++---------- osu.Game/Overlays/Mods/ModButton.cs | 2 +- osu.Game/Rulesets/UI/ModIcon.cs | 4 +-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index bb6f889c40..a6f69617d0 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -72,7 +72,7 @@ namespace osu.Game.Overlays.BeatmapSet if (SelectedMods.Any()) return; - modsContainer.Children.Where(button => !button.IsHovered).ForEach(button => button.IsActive.Value = !IsHovered); + modsContainer.Children.Where(button => !button.IsHovered).ForEach(button => button.Highlighted.Value = !IsHovered); } protected override bool OnHover(HoverEvent e) @@ -87,13 +87,13 @@ namespace osu.Game.Overlays.BeatmapSet updateHighlighted(); } - public void DeselectAll() => modsContainer.ForEach(mod => mod.Highlighted.Value = false); + public void DeselectAll() => modsContainer.ForEach(mod => mod.Selected.Value = false); private class ModButton : ModIcon { private const int duration = 200; - public readonly BindableBool IsActive = new BindableBool(); + public readonly BindableBool Highlighted = new BindableBool(); public Action OnSelectionChanged; public ModButton(Mod mod) @@ -107,37 +107,37 @@ namespace osu.Game.Overlays.BeatmapSet { base.LoadComplete(); - IsActive.BindValueChanged(hovered => - { - if (Highlighted.Value) - return; - - this.FadeColour(hovered.NewValue ? Color4.White : Color4.DimGray, duration, Easing.OutQuint); - }, true); - Highlighted.BindValueChanged(highlighted => { - OnSelectionChanged?.Invoke(Mod, highlighted.NewValue); - IsActive.TriggerChange(); + if (Selected.Value) + return; + + this.FadeColour(highlighted.NewValue ? Color4.White : Color4.DimGray, duration, Easing.OutQuint); + }, true); + + Selected.BindValueChanged(selected => + { + OnSelectionChanged?.Invoke(Mod, selected.NewValue); + Highlighted.TriggerChange(); }, true); } protected override bool OnClick(ClickEvent e) { - Highlighted.Toggle(); + Selected.Toggle(); return true; } protected override bool OnHover(HoverEvent e) { - IsActive.Value = true; + Highlighted.Value = true; return false; } protected override void OnHoverLost(HoverLostEvent e) { base.OnHoverLost(e); - IsActive.Value = false; + Highlighted.Value = false; } } } diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 8252020e9b..c6b4787ff1 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -96,7 +96,7 @@ namespace osu.Game.Overlays.Mods } } - foregroundIcon.Highlighted.Value = Selected; + foregroundIcon.Selected.Value = Selected; SelectionChanged?.Invoke(SelectedMod); return true; diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index cf1bbadb57..1be70ff48f 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.UI { public class ModIcon : Container, IHasTooltip { - public readonly BindableBool Highlighted = new BindableBool(); + public readonly BindableBool Selected = new BindableBool(); private readonly SpriteIcon modIcon; private readonly SpriteIcon background; @@ -112,7 +112,7 @@ namespace osu.Game.Rulesets.UI protected override void LoadComplete() { base.LoadComplete(); - Highlighted.BindValueChanged(highlighted => background.Colour = highlighted.NewValue ? highlightedColour : backgroundColour, true); + Selected.BindValueChanged(highlighted => background.Colour = highlighted.NewValue ? highlightedColour : backgroundColour, true); } } } From eb2f7c1d0a63f2bd0aa21cc56eeb61f58a066d5a Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 21 Nov 2019 20:37:02 +0300 Subject: [PATCH 077/120] Rename forgotten variable --- osu.Game/Rulesets/UI/ModIcon.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index 1be70ff48f..945dbe4cc9 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -112,7 +112,7 @@ namespace osu.Game.Rulesets.UI protected override void LoadComplete() { base.LoadComplete(); - Selected.BindValueChanged(highlighted => background.Colour = highlighted.NewValue ? highlightedColour : backgroundColour, true); + Selected.BindValueChanged(selected => background.Colour = selected.NewValue ? highlightedColour : backgroundColour, true); } } } From ab42fac43abe3250ece9eb306e07ad2a49db94cb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 22 Nov 2019 02:38:31 +0900 Subject: [PATCH 078/120] Improve naming --- .../{BackgroundMode.cs => BackgroundSource.cs} | 4 ++-- osu.Game/Configuration/OsuConfigManager.cs | 4 ++-- .../Overlays/Settings/Sections/Audio/MainMenuSettings.cs | 8 ++++---- osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) rename osu.Game/Configuration/{BackgroundMode.cs => BackgroundSource.cs} (81%) diff --git a/osu.Game/Configuration/BackgroundMode.cs b/osu.Game/Configuration/BackgroundSource.cs similarity index 81% rename from osu.Game/Configuration/BackgroundMode.cs rename to osu.Game/Configuration/BackgroundSource.cs index 50d54f1eb2..5726e96eb1 100644 --- a/osu.Game/Configuration/BackgroundMode.cs +++ b/osu.Game/Configuration/BackgroundSource.cs @@ -3,9 +3,9 @@ namespace osu.Game.Configuration { - public enum BackgroundMode + public enum BackgroundSource { - Default, + Skin, Beatmap } } diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index b847f96a1f..b71463841a 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -118,7 +118,7 @@ namespace osu.Game.Configuration Set(OsuSetting.IntroSequence, IntroSequence.Triangles); - Set(OsuSetting.BackgroundMode, BackgroundMode.Default); + Set(OsuSetting.MenuBackgroundSource, BackgroundSource.Skin); } public OsuConfigManager(Storage storage) @@ -189,6 +189,6 @@ namespace osu.Game.Configuration IntroSequence, UIHoldActivationDelay, HitLighting, - BackgroundMode + MenuBackgroundSource } } diff --git a/osu.Game/Overlays/Settings/Sections/Audio/MainMenuSettings.cs b/osu.Game/Overlays/Settings/Sections/Audio/MainMenuSettings.cs index 76a6aafe45..a303f93b34 100644 --- a/osu.Game/Overlays/Settings/Sections/Audio/MainMenuSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Audio/MainMenuSettings.cs @@ -34,11 +34,11 @@ namespace osu.Game.Overlays.Settings.Sections.Audio Bindable = config.GetBindable(OsuSetting.IntroSequence), Items = Enum.GetValues(typeof(IntroSequence)).Cast() }, - new SettingsDropdown + new SettingsDropdown { - LabelText = "Background", - Bindable = config.GetBindable(OsuSetting.BackgroundMode), - Items = Enum.GetValues(typeof(BackgroundMode)).Cast() + LabelText = "Background source", + Bindable = config.GetBindable(OsuSetting.MenuBackgroundSource), + Items = Enum.GetValues(typeof(BackgroundSource)).Cast() } }; } diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs index d49751f511..095985e9d1 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Backgrounds private Bindable user; private Bindable skin; - private Bindable mode; + private Bindable mode; [Resolved] private IBindable beatmap { get; set; } @@ -41,7 +41,7 @@ namespace osu.Game.Screens.Backgrounds { user = api.LocalUser.GetBoundCopy(); skin = skinManager.CurrentSkin.GetBoundCopy(); - mode = config.GetBindable(OsuSetting.BackgroundMode); + mode = config.GetBindable(OsuSetting.MenuBackgroundSource); user.ValueChanged += _ => Next(); skin.ValueChanged += _ => Next(); @@ -78,7 +78,7 @@ namespace osu.Game.Screens.Backgrounds { switch (mode.Value) { - case BackgroundMode.Beatmap: + case BackgroundSource.Beatmap: newBackground = new BeatmapBackground(beatmap.Value, backgroundName); break; From 57d38c5c74c956e36920f43de95a4af9c11a0f9d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 22 Nov 2019 02:39:54 +0900 Subject: [PATCH 079/120] Add final newline --- osu.Game/Graphics/Backgrounds/BeatmapBackground.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Backgrounds/BeatmapBackground.cs b/osu.Game/Graphics/Backgrounds/BeatmapBackground.cs index 40c6dae43c..387e189dc4 100644 --- a/osu.Game/Graphics/Backgrounds/BeatmapBackground.cs +++ b/osu.Game/Graphics/Backgrounds/BeatmapBackground.cs @@ -25,4 +25,4 @@ namespace osu.Game.Graphics.Backgrounds Sprite.Texture = Beatmap?.Background ?? textures.Get(fallbackTextureName); } } -} \ No newline at end of file +} From e170cd289269f9a028fb699953f2a28551a3e570 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 22 Nov 2019 10:29:16 +0900 Subject: [PATCH 080/120] Move private methods below --- .../BeatmapSet/LeaderboardModSelector.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index a6f69617d0..60fd520681 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -57,6 +57,18 @@ namespace osu.Game.Overlays.BeatmapSet modsContainer.ForEach(button => button.OnSelectionChanged = selectionChanged); } + protected override bool OnHover(HoverEvent e) + { + updateHighlighted(); + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + base.OnHoverLost(e); + updateHighlighted(); + } + private void selectionChanged(Mod mod, bool selected) { if (selected) @@ -75,18 +87,6 @@ namespace osu.Game.Overlays.BeatmapSet modsContainer.Children.Where(button => !button.IsHovered).ForEach(button => button.Highlighted.Value = !IsHovered); } - protected override bool OnHover(HoverEvent e) - { - updateHighlighted(); - return base.OnHover(e); - } - - protected override void OnHoverLost(HoverLostEvent e) - { - base.OnHoverLost(e); - updateHighlighted(); - } - public void DeselectAll() => modsContainer.ForEach(mod => mod.Selected.Value = false); private class ModButton : ModIcon From d8260f4a6511ce6118507f114e06eed4cd0bc229 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 22 Nov 2019 10:51:49 +0900 Subject: [PATCH 081/120] Reduce carousel scroll motion on initial display --- osu.Game/Screens/Select/BeatmapCarousel.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 538656a5fa..17736e7819 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -640,10 +640,19 @@ namespace osu.Game.Screens.Select itemsCache.Validate(); } + private bool firstScroll = true; + private void updateScrollPosition() { if (scrollTarget != null) { + if (firstScroll) + { + // reduce movement when first displaying the carousel. + scroll.ScrollTo(scrollTarget.Value - 200, false); + firstScroll = false; + } + scroll.ScrollTo(scrollTarget.Value); scrollPositionCache.Validate(); } From da425c93fac6a629490690a3555d8d84e64e4118 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Fri, 22 Nov 2019 05:08:50 +0300 Subject: [PATCH 082/120] Fix beatmap switch doesn't trigger scores update --- osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 3e3f823368..b33b5feb4d 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -193,7 +193,10 @@ namespace osu.Game.Overlays.BeatmapSet.Scores var beatmapRuleset = beatmap.NewValue?.Ruleset; if (ruleset.Value?.Equals(beatmapRuleset) ?? false) + { modSelector.DeselectAll(); + ruleset.TriggerChange(); + } else ruleset.Value = beatmapRuleset; From 745047fd193ce406f4c6d2896429279918536d67 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Fri, 22 Nov 2019 05:10:47 +0300 Subject: [PATCH 083/120] Remove useless line from ModIcon --- osu.Game/Rulesets/UI/ModIcon.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index c22120d6e0..945dbe4cc9 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -107,8 +107,6 @@ namespace osu.Game.Rulesets.UI modIcon.Colour = colours.Yellow; break; } - - background.Colour = backgroundColour; } protected override void LoadComplete() From f079ebe857ebf708c5aae6ee0a7c102ea4c9c5f5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 22 Nov 2019 16:13:48 +0900 Subject: [PATCH 084/120] Simplify beatmap lookup to use a single endpoint --- osu.Game/Online/API/Requests/GetBeatmapRequest.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Game/Online/API/Requests/GetBeatmapRequest.cs b/osu.Game/Online/API/Requests/GetBeatmapRequest.cs index b37a6804fe..8e92cf0611 100644 --- a/osu.Game/Online/API/Requests/GetBeatmapRequest.cs +++ b/osu.Game/Online/API/Requests/GetBeatmapRequest.cs @@ -10,13 +10,11 @@ namespace osu.Game.Online.API.Requests { private readonly BeatmapInfo beatmap; - private string lookupString => beatmap.OnlineBeatmapID > 0 ? beatmap.OnlineBeatmapID.ToString() : $@"lookup?checksum={beatmap.MD5Hash}&filename={System.Uri.EscapeUriString(beatmap.Path)}"; - public GetBeatmapRequest(BeatmapInfo beatmap) { this.beatmap = beatmap; } - protected override string Target => $@"beatmaps/{lookupString}"; + protected override string Target => $@"beatmaps/lookup?id={beatmap.OnlineBeatmapID}&checksum={beatmap.MD5Hash}&filename={System.Uri.EscapeUriString(beatmap.Path)}"; } } From 0cc1698b6d1764b183e663db9d27f7d3e2b5ee0e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 22 Nov 2019 18:05:12 +0900 Subject: [PATCH 085/120] Rename incorrectly named container --- osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index b33b5feb4d..ac39671f56 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -34,7 +34,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly ScoreTable scoreTable; private readonly FillFlowContainer topScoresContainer; private readonly DimmedLoadingLayer loading; - private readonly FillFlowContainer modFilter; + private readonly FillFlowContainer filterControls; private readonly LeaderboardModSelector modSelector; private readonly NoScoresPlaceholder noScoresPlaceholder; private readonly FillFlowContainer content; @@ -94,7 +94,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Margin = new MarginPadding { Vertical = spacing }, Children = new Drawable[] { - modFilter = new FillFlowContainer + filterControls = new FillFlowContainer { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, @@ -207,7 +207,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { scope.Value = BeatmapLeaderboardScope.Global; modSelector.DeselectAll(); - modFilter.FadeTo(api.IsLoggedIn && api.LocalUser.Value.IsSupporter ? 1 : 0); + filterControls.FadeTo(api.IsLoggedIn && api.LocalUser.Value.IsSupporter ? 1 : 0); } private void getScores() From 16bdf4e6bd250ac5dd9cb6fa497d80e984002af1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 22 Nov 2019 18:07:56 +0900 Subject: [PATCH 086/120] Update english to be more readable --- osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs b/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs index aefff5d567..9cfce4ef5b 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs @@ -27,16 +27,15 @@ namespace osu.Game.Overlays.BeatmapSet.Scores switch (scope) { default: - case BeatmapLeaderboardScope.Global: - text.Text = @"No scores yet. Maybe should try setting some?"; + text.Text = @"No scores have been set yet. Maybe you can be the first!"; return; case BeatmapLeaderboardScope.Friend: - text.Text = @"None of your friends has set a score on this map yet!"; + text.Text = @"None of your friends have set a score on this map yet."; return; case BeatmapLeaderboardScope.Country: - text.Text = @"No one from your country has set a score on this map yet!"; + text.Text = @"No one from your country has set a score on this map yet."; return; } } From dad2e5c678dc6f781ea46d4e6acf82411da46bd0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 22 Nov 2019 18:10:44 +0900 Subject: [PATCH 087/120] Improve legibility of NoScroesPlaceholder --- .../BeatmapSet/Scores/NoScoresPlaceholder.cs | 21 +++++++++++-------- .../BeatmapSet/Scores/ScoresContainer.cs | 8 ++----- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs b/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs index 9cfce4ef5b..391ba93a4b 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/NoScoresPlaceholder.cs @@ -3,9 +3,9 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Graphics; using osu.Game.Screens.Select.Leaderboards; using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.BeatmapSet.Scores { @@ -16,27 +16,30 @@ namespace osu.Game.Overlays.BeatmapSet.Scores public NoScoresPlaceholder() { AutoSizeAxes = Axes.Both; - Child = text = new SpriteText - { - Font = OsuFont.GetFont(), - }; + Child = text = new OsuSpriteText(); } - public void UpdateText(BeatmapLeaderboardScope scope) + public override void Show() => this.FadeIn(200, Easing.OutQuint); + + public override void Hide() => this.FadeOut(200, Easing.OutQuint); + + public void ShowWithScope(BeatmapLeaderboardScope scope) { + Show(); + switch (scope) { default: text.Text = @"No scores have been set yet. Maybe you can be the first!"; - return; + break; case BeatmapLeaderboardScope.Friend: text.Text = @"None of your friends have set a score on this map yet."; - return; + break; case BeatmapLeaderboardScope.Country: text.Text = @"No one from your country has set a score on this map yet."; - return; + break; } } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index ac39671f56..86fb455eb8 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -23,7 +23,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores public class ScoresContainer : CompositeDrawable { private const int spacing = 15; - private const int duration = 200; public readonly Bindable Beatmap = new Bindable(); private readonly Bindable ruleset = new Bindable(); @@ -215,7 +214,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores getScoresRequest?.Cancel(); getScoresRequest = null; - noScoresPlaceholder.FadeOut(duration, Easing.OutQuint); + noScoresPlaceholder.Hide(); if (Beatmap.Value?.OnlineBeatmapID.HasValue != true || Beatmap.Value.Status <= BeatmapSetOnlineStatus.Pending) { @@ -233,10 +232,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Scores = scores; if (!scores.Scores.Any()) - { - noScoresPlaceholder.UpdateText(scope.Value); - noScoresPlaceholder.FadeIn(duration, Easing.OutQuint); - } + noScoresPlaceholder.ShowWithScope(scope.Value); }; api.Queue(getScoresRequest); } From 66e2a259f0fcdcf7e349816f8f83a918edd7fcea Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 22 Nov 2019 18:21:40 +0900 Subject: [PATCH 088/120] Fix usage of SpriteText instead of OsuSpriteText --- CodeAnalysis/BannedSymbols.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CodeAnalysis/BannedSymbols.txt b/CodeAnalysis/BannedSymbols.txt index 9fb86485d2..3ad8d5db5b 100644 --- a/CodeAnalysis/BannedSymbols.txt +++ b/CodeAnalysis/BannedSymbols.txt @@ -2,3 +2,4 @@ M:System.Object.Equals(System.Object,System.Object)~System.Boolean;Don't use obj M:System.Object.Equals(System.Object)~System.Boolean;Don't use object.Equals. Use IEquatable or EqualityComparer.Default instead. M:System.ValueType.Equals(System.Object)~System.Boolean;Don't use object.Equals(Fallbacks to ValueType). Use IEquatable or EqualityComparer.Default instead. T:System.IComparable;Don't use non-generic IComparable. Use generic version instead. +T:osu.Framework.Graphics.Sprites.SpriteText;Use OsuSpriteText. From b026197859bd0fb362f80323621f7a53576d3fbd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 22 Nov 2019 18:23:48 +0900 Subject: [PATCH 089/120] Add spacing --- osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 86fb455eb8..f6f4b39c14 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -225,6 +225,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores content.Show(); loading.Show(); + getScoresRequest = new GetScoresRequest(Beatmap.Value, Beatmap.Value.Ruleset, scope.Value, modSelector.SelectedMods); getScoresRequest.Success += scores => { @@ -234,6 +235,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores if (!scores.Scores.Any()) noScoresPlaceholder.ShowWithScope(scope.Value); }; + api.Queue(getScoresRequest); } } From 6469199f0dd594049208f1634d127d4d04a4b5ee Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 22 Nov 2019 19:47:21 +0900 Subject: [PATCH 090/120] Update framework --- osu.Android.props | 2 +- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Android.props b/osu.Android.props index 0f0e82d56a..0da3e66236 100644 --- a/osu.Android.props +++ b/osu.Android.props @@ -55,6 +55,6 @@ - + diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 28ef7d3d92..449b4dc4e3 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -21,7 +21,7 @@ - + diff --git a/osu.iOS.props b/osu.iOS.props index 364b0b2c78..871a9238e3 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -73,7 +73,7 @@ - + @@ -81,7 +81,7 @@ - + From c2e85a205733bfad5d8433d5688dd94dd81f0012 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 22 Nov 2019 19:49:20 +0900 Subject: [PATCH 091/120] Apply CornerExponent fixes --- .../Edit/Blueprints/HitCircles/Components/HitCirclePiece.cs | 2 ++ .../Objects/Drawables/Connections/FollowPoint.cs | 3 +-- .../Objects/Drawables/Pieces/CirclePiece.cs | 2 ++ osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/RingPiece.cs | 3 +-- osu.Game.Tournament/Components/SongBar.cs | 2 ++ osu.Game.Tournament/Components/TournamentBeatmapPanel.cs | 1 + osu.Game/Overlays/Comments/DrawableComment.cs | 1 + osu.Game/Overlays/Volume/MuteButton.cs | 1 + osu.Game/Screens/Edit/Components/CircularButton.cs | 1 + osu.Game/Users/Drawables/UpdateableAvatar.cs | 6 ++++++ 10 files changed, 18 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/Components/HitCirclePiece.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/Components/HitCirclePiece.cs index 2b6b93a590..2868ddeaa4 100644 --- a/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/Components/HitCirclePiece.cs +++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/Components/HitCirclePiece.cs @@ -17,7 +17,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components Origin = Anchor.Centre; Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2); + CornerRadius = Size.X / 2; + CornerExponent = 2; InternalChild = new RingPiece(); } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/FollowPoint.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/FollowPoint.cs index db34ae1d87..7e530ca047 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/FollowPoint.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/FollowPoint.cs @@ -25,11 +25,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections { Origin = Anchor.Centre; - Child = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.FollowPoint), _ => new Container + Child = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.FollowPoint), _ => new CircularContainer { Masking = true, AutoSizeAxes = Axes.Both, - CornerRadius = width / 2, EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Glow, diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/CirclePiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/CirclePiece.cs index 210d5ff839..aab01f45d4 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/CirclePiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/CirclePiece.cs @@ -16,7 +16,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2); Masking = true; + CornerRadius = Size.X / 2; + CornerExponent = 2; Anchor = Anchor.Centre; Origin = Anchor.Centre; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/RingPiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/RingPiece.cs index c97b74756a..82e4383143 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/RingPiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/RingPiece.cs @@ -18,10 +18,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces Anchor = Anchor.Centre; Origin = Anchor.Centre; - InternalChild = new Container + InternalChild = new CircularContainer { Masking = true, - CornerRadius = Size.X / 2, BorderThickness = 10, BorderColour = Color4.White, RelativeSizeAxes = Axes.Both, diff --git a/osu.Game.Tournament/Components/SongBar.cs b/osu.Game.Tournament/Components/SongBar.cs index 7005c068ae..43958aca7a 100644 --- a/osu.Game.Tournament/Components/SongBar.cs +++ b/osu.Game.Tournament/Components/SongBar.cs @@ -106,6 +106,7 @@ namespace osu.Game.Tournament.Components Width = main_width, Height = TournamentBeatmapPanel.HEIGHT, CornerRadius = TournamentBeatmapPanel.HEIGHT / 2, + CornerExponent = 2, Children = new Drawable[] { new Box @@ -126,6 +127,7 @@ namespace osu.Game.Tournament.Components { Masking = true, CornerRadius = TournamentBeatmapPanel.HEIGHT / 2, + CornerExponent = 2, Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, diff --git a/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs b/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs index 0908814537..51483a0964 100644 --- a/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs +++ b/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs @@ -52,6 +52,7 @@ namespace osu.Game.Tournament.Components currentMatch.BindTo(ladder.CurrentMatch); CornerRadius = HEIGHT / 2; + CornerExponent = 2; Masking = true; AddRangeInternal(new Drawable[] diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs index 3fb9867f0e..0d00f7c63b 100644 --- a/osu.Game/Overlays/Comments/DrawableComment.cs +++ b/osu.Game/Overlays/Comments/DrawableComment.cs @@ -100,6 +100,7 @@ namespace osu.Game.Overlays.Comments Size = new Vector2(avatar_size), Masking = true, CornerRadius = avatar_size / 2f, + CornerExponent = 2, }, } }, diff --git a/osu.Game/Overlays/Volume/MuteButton.cs b/osu.Game/Overlays/Volume/MuteButton.cs index 6d876a77b1..bcc9394aba 100644 --- a/osu.Game/Overlays/Volume/MuteButton.cs +++ b/osu.Game/Overlays/Volume/MuteButton.cs @@ -43,6 +43,7 @@ namespace osu.Game.Overlays.Volume { Content.BorderThickness = 3; Content.CornerRadius = HEIGHT / 2; + Content.CornerExponent = 2; Size = new Vector2(width, HEIGHT); diff --git a/osu.Game/Screens/Edit/Components/CircularButton.cs b/osu.Game/Screens/Edit/Components/CircularButton.cs index 931c7d03a0..40b5ac663a 100644 --- a/osu.Game/Screens/Edit/Components/CircularButton.cs +++ b/osu.Game/Screens/Edit/Components/CircularButton.cs @@ -20,6 +20,7 @@ namespace osu.Game.Screens.Edit.Components { base.Update(); Content.CornerRadius = DrawHeight / 2f; + Content.CornerExponent = 2; } } } diff --git a/osu.Game/Users/Drawables/UpdateableAvatar.cs b/osu.Game/Users/Drawables/UpdateableAvatar.cs index 795b90ba11..59fbb5f910 100644 --- a/osu.Game/Users/Drawables/UpdateableAvatar.cs +++ b/osu.Game/Users/Drawables/UpdateableAvatar.cs @@ -31,6 +31,12 @@ namespace osu.Game.Users.Drawables set => base.CornerRadius = value; } + public new float CornerExponent + { + get => base.CornerExponent; + set => base.CornerExponent = value; + } + public new EdgeEffectParameters EdgeEffect { get => base.EdgeEffect; From d0002cc1c25e9da8ede3277257c588b884a28c65 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 22 Nov 2019 19:50:30 +0900 Subject: [PATCH 092/120] Update performance logging setting --- osu.Game/Overlays/Settings/Sections/Debug/GeneralSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/Sections/Debug/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Debug/GeneralSettings.cs index 7eec971b62..457f064f89 100644 --- a/osu.Game/Overlays/Settings/Sections/Debug/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Debug/GeneralSettings.cs @@ -24,7 +24,7 @@ namespace osu.Game.Overlays.Settings.Sections.Debug new SettingsCheckbox { LabelText = "Performance logging", - Bindable = frameworkConfig.GetBindable(FrameworkSetting.PerformanceLogging) + Bindable = config.GetBindable(DebugSetting.PerformanceLogging) }, new SettingsCheckbox { From 4063135a3a894e262f880cca2b91904c51fb33c2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 22 Nov 2019 20:45:05 +0900 Subject: [PATCH 093/120] Fix result mode button's corner exponent --- osu.Game/Screens/Ranking/ResultModeButton.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Screens/Ranking/ResultModeButton.cs b/osu.Game/Screens/Ranking/ResultModeButton.cs index 1383511241..38636b0c3b 100644 --- a/osu.Game/Screens/Ranking/ResultModeButton.cs +++ b/osu.Game/Screens/Ranking/ResultModeButton.cs @@ -36,7 +36,9 @@ namespace osu.Game.Screens.Ranking Size = new Vector2(50); Masking = true; + CornerRadius = 25; + CornerExponent = 2; activeColour = colours.PinkDarker; inactiveColour = OsuColour.Gray(0.8f); From 4cb09df754aa0b03e145936660cd518117b1959d Mon Sep 17 00:00:00 2001 From: Albie Spriddell Date: Fri, 22 Nov 2019 18:23:48 +0000 Subject: [PATCH 094/120] increase padding --- osu.Game/Overlays/Mods/ModSection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Mods/ModSection.cs b/osu.Game/Overlays/Mods/ModSection.cs index 3b16189e73..9c0a164ad6 100644 --- a/osu.Game/Overlays/Mods/ModSection.cs +++ b/osu.Game/Overlays/Mods/ModSection.cs @@ -167,7 +167,7 @@ namespace osu.Game.Overlays.Mods Spacing = new Vector2(50f, 0f), Margin = new MarginPadding { - Top = 6, + Top = 20, }, AlwaysPresent = true }, From d6c9387bebcc44dafc92693e6e6d6ceb3f46117e Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Fri, 22 Nov 2019 21:55:21 +0300 Subject: [PATCH 095/120] Implement NotSupporterPlaceholder --- .../Online/TestSceneBeatmapSetOverlay.cs | 1 + .../Scores/NotSupporterPlaceholder.cs | 51 +++++++++++++++++++ .../BeatmapSet/Scores/ScoresContainer.cs | 1 + 3 files changed, 53 insertions(+) create mode 100644 osu.Game/Overlays/BeatmapSet/Scores/NotSupporterPlaceholder.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs index 286971bc90..5ca2c9868f 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs @@ -42,6 +42,7 @@ namespace osu.Game.Tests.Visual.Online typeof(BeatmapAvailability), typeof(BeatmapRulesetSelector), typeof(BeatmapRulesetTabItem), + typeof(NotSupporterPlaceholder) }; protected override bool UseOnlineAPI => true; diff --git a/osu.Game/Overlays/BeatmapSet/Scores/NotSupporterPlaceholder.cs b/osu.Game/Overlays/BeatmapSet/Scores/NotSupporterPlaceholder.cs new file mode 100644 index 0000000000..86b02c0cff --- /dev/null +++ b/osu.Game/Overlays/BeatmapSet/Scores/NotSupporterPlaceholder.cs @@ -0,0 +1,51 @@ +// 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.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osuTK; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; + +namespace osu.Game.Overlays.BeatmapSet.Scores +{ + public class NotSupporterPlaceholder : Container + { + public NotSupporterPlaceholder() + { + LinkFlowContainer text; + + AutoSizeAxes = Axes.Both; + Anchor = Anchor.TopCentre; + Origin = Anchor.TopCentre; + Child = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 10), + Children = new Drawable[] + { + new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Text = @"You need to be an osu!supporter to access the friend and country rankings!", + Font = OsuFont.GetFont(weight: FontWeight.Bold), + }, + text = new LinkFlowContainer(t => t.Font = t.Font.With(size: 12)) + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Direction = FillDirection.Horizontal, + AutoSizeAxes = Axes.Both, + } + } + }; + + text.AddText("Click "); + text.AddLink("here", "/home/support"); + text.AddText(" to see all the fancy features that you can get!"); + } + } +} diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index f6f4b39c14..fe42ef2975 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -106,6 +106,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { Current = { BindTarget = scope } }, + new NotSupporterPlaceholder(), modSelector = new LeaderboardModSelector { Ruleset = { BindTarget = ruleset } From aede1b183a597b0a354f2919e7787928eb409445 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Fri, 22 Nov 2019 22:04:58 +0300 Subject: [PATCH 096/120] Make ScopeSelector always visible --- .../Scores/NotSupporterPlaceholder.cs | 2 -- .../BeatmapSet/Scores/ScoresContainer.cs | 22 +++++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/NotSupporterPlaceholder.cs b/osu.Game/Overlays/BeatmapSet/Scores/NotSupporterPlaceholder.cs index 86b02c0cff..ba08a78a61 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/NotSupporterPlaceholder.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/NotSupporterPlaceholder.cs @@ -17,8 +17,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores LinkFlowContainer text; AutoSizeAxes = Axes.Both; - Anchor = Anchor.TopCentre; - Origin = Anchor.TopCentre; Child = new FillFlowContainer { AutoSizeAxes = Axes.Both, diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index fe42ef2975..0389d4cf25 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -33,10 +33,10 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly ScoreTable scoreTable; private readonly FillFlowContainer topScoresContainer; private readonly DimmedLoadingLayer loading; - private readonly FillFlowContainer filterControls; private readonly LeaderboardModSelector modSelector; private readonly NoScoresPlaceholder noScoresPlaceholder; private readonly FillFlowContainer content; + private readonly NotSupporterPlaceholder notSupporterPlaceholder; [Resolved] private IAPIProvider api { get; set; } @@ -93,22 +93,30 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Margin = new MarginPadding { Vertical = spacing }, Children = new Drawable[] { - filterControls = new FillFlowContainer + new FillFlowContainer { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - AutoSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Spacing = new Vector2(0, spacing), Children = new Drawable[] { new LeaderboardScopeSelector { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, Current = { BindTarget = scope } }, - new NotSupporterPlaceholder(), + notSupporterPlaceholder = new NotSupporterPlaceholder + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Alpha = 0, + }, modSelector = new LeaderboardModSelector { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, Ruleset = { BindTarget = ruleset } } } @@ -207,7 +215,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { scope.Value = BeatmapLeaderboardScope.Global; modSelector.DeselectAll(); - filterControls.FadeTo(api.IsLoggedIn && api.LocalUser.Value.IsSupporter ? 1 : 0); + modSelector.FadeTo(api.IsLoggedIn && api.LocalUser.Value.IsSupporter ? 1 : 0); } private void getScores() From 2e161f7e997538dea478ca788a895473006ebd27 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Fri, 22 Nov 2019 22:25:58 +0300 Subject: [PATCH 097/120] Hook up the rest of the logic --- .../BeatmapSet/Scores/ScoresContainer.cs | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 0389d4cf25..e91d12b9fc 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -26,7 +26,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores public readonly Bindable Beatmap = new Bindable(); private readonly Bindable ruleset = new Bindable(); - private readonly Bindable scope = new Bindable(); + private readonly Bindable scope = new Bindable(BeatmapLeaderboardScope.Global); private readonly Bindable user = new Bindable(); private readonly Box background; @@ -107,12 +107,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Origin = Anchor.TopCentre, Current = { BindTarget = scope } }, - notSupporterPlaceholder = new NotSupporterPlaceholder - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Alpha = 0, - }, modSelector = new LeaderboardModSelector { Anchor = Anchor.TopCentre, @@ -136,6 +130,12 @@ namespace osu.Game.Overlays.BeatmapSet.Scores AlwaysPresent = true, Margin = new MarginPadding { Vertical = 10 } }, + notSupporterPlaceholder = new NotSupporterPlaceholder + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Alpha = 0, + }, new FillFlowContainer { RelativeSizeAxes = Axes.X, @@ -213,9 +213,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private void onUserChanged(ValueChangedEvent user) { - scope.Value = BeatmapLeaderboardScope.Global; modSelector.DeselectAll(); - modSelector.FadeTo(api.IsLoggedIn && api.LocalUser.Value.IsSupporter ? 1 : 0); + modSelector.FadeTo(userIsSupporter ? 1 : 0); + getScores(); } private void getScores() @@ -232,6 +232,18 @@ namespace osu.Game.Overlays.BeatmapSet.Scores return; } + if (scope.Value != BeatmapLeaderboardScope.Global && !userIsSupporter) + { + Scores = null; + notSupporterPlaceholder.Show(); + loading.Hide(); + return; + } + else + { + notSupporterPlaceholder.Hide(); + } + content.Show(); loading.Show(); @@ -247,5 +259,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores api.Queue(getScoresRequest); } + + private bool userIsSupporter => api.IsLoggedIn && api.LocalUser.Value.IsSupporter; } } From e3f3b1ab1a1101f86e7b9cdfe6c3d1af7c3c5226 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 23 Nov 2019 20:52:41 +0900 Subject: [PATCH 098/120] Display useful statistics on song bar depending on current ruleset --- osu.Game.Tournament/Components/SongBar.cs | 48 +++++++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/osu.Game.Tournament/Components/SongBar.cs b/osu.Game.Tournament/Components/SongBar.cs index 43958aca7a..4a738ae36b 100644 --- a/osu.Game.Tournament/Components/SongBar.cs +++ b/osu.Game.Tournament/Components/SongBar.cs @@ -3,6 +3,7 @@ using System; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -13,6 +14,7 @@ using osu.Game.Beatmaps; using osu.Game.Beatmaps.Legacy; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Rulesets; using osu.Game.Screens.Menu; using osuTK; using osuTK.Graphics; @@ -23,6 +25,9 @@ namespace osu.Game.Tournament.Components { private BeatmapInfo beatmap; + [Resolved] + private IBindable ruleset { get; set; } + public BeatmapInfo Beatmap { get => beatmap; @@ -165,7 +170,8 @@ namespace osu.Game.Tournament.Components string hardRockExtra = ""; string srExtra = ""; - //var ar = beatmap.BaseDifficulty.ApproachRate; + var ar = beatmap.BaseDifficulty.ApproachRate; + if ((mods & LegacyMods.HardRock) > 0) { hardRockExtra = "*"; @@ -174,12 +180,43 @@ namespace osu.Game.Tournament.Components if ((mods & LegacyMods.DoubleTime) > 0) { - //ar *= 1.5f; + ar *= 1.5f; bpm *= 1.5f; length /= 1.5f; srExtra = "*"; } + (string heading, string content)[] stats; + + switch (ruleset.Value.ID) + { + default: + stats = new (string heading, string content)[] + { + ("CS", $"{beatmap.BaseDifficulty.CircleSize:0.#}{hardRockExtra}"), + ("AR", $"{ar:0.#}{srExtra}"), + ("OD", $"{beatmap.BaseDifficulty.OverallDifficulty:0.#}{hardRockExtra}"), + }; + break; + + case 1: + case 3: + stats = new (string heading, string content)[] + { + ("OD", $"{beatmap.BaseDifficulty.OverallDifficulty:0.#}{hardRockExtra}"), + ("HP", $"{beatmap.BaseDifficulty.DrainRate:0.#}{hardRockExtra}") + }; + break; + + case 2: + stats = new (string heading, string content)[] + { + ("CS", $"{beatmap.BaseDifficulty.CircleSize:0.#}{hardRockExtra}"), + ("AR", $"{ar:0.#}{srExtra}"), + }; + break; + } + panelContents.Children = new Drawable[] { new DiffPiece(("Length", TimeSpan.FromMilliseconds(length).ToString(@"mm\:ss"))) @@ -192,12 +229,7 @@ namespace osu.Game.Tournament.Components Anchor = Anchor.CentreLeft, Origin = Anchor.TopLeft }, - new DiffPiece( - //("CS", $"{beatmap.BaseDifficulty.CircleSize:0.#}{hardRockExtra}"), - //("AR", $"{ar:0.#}{srExtra}"), - ("OD", $"{beatmap.BaseDifficulty.OverallDifficulty:0.#}{hardRockExtra}"), - ("HP", $"{beatmap.BaseDifficulty.DrainRate:0.#}{hardRockExtra}") - ) + new DiffPiece(stats) { Anchor = Anchor.CentreRight, Origin = Anchor.BottomRight From eb81d15463721c4e3abaf9a89fbef8a9a5eca562 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 23 Nov 2019 20:52:55 +0900 Subject: [PATCH 099/120] Don't attempt to repopulate already populated users on startup --- osu.Game.Tournament/TournamentGameBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tournament/TournamentGameBase.cs b/osu.Game.Tournament/TournamentGameBase.cs index f2a158971b..ec696c818d 100644 --- a/osu.Game.Tournament/TournamentGameBase.cs +++ b/osu.Game.Tournament/TournamentGameBase.cs @@ -202,7 +202,8 @@ namespace osu.Game.Tournament { foreach (var p in t.Players) { - PopulateUser(p); + if (p.Username == null || p.Statistics == null) + PopulateUser(p); addedInfo = true; } } @@ -243,7 +244,6 @@ namespace osu.Game.Tournament { user.Username = res.Username; user.Statistics = res.Statistics; - user.Username = res.Username; user.Country = res.Country; user.Cover = res.Cover; From 65d71b94424ab46a3fa307784a8637334d75f172 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 23 Nov 2019 20:54:01 +0900 Subject: [PATCH 100/120] Fix beatmap lookups failing for beatmaps with no local path Turns out the underlying EscapeUriString doesn't like nulls --- osu.Game/Online/API/Requests/GetBeatmapRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/API/Requests/GetBeatmapRequest.cs b/osu.Game/Online/API/Requests/GetBeatmapRequest.cs index 8e92cf0611..87925b94c6 100644 --- a/osu.Game/Online/API/Requests/GetBeatmapRequest.cs +++ b/osu.Game/Online/API/Requests/GetBeatmapRequest.cs @@ -15,6 +15,6 @@ namespace osu.Game.Online.API.Requests this.beatmap = beatmap; } - protected override string Target => $@"beatmaps/lookup?id={beatmap.OnlineBeatmapID}&checksum={beatmap.MD5Hash}&filename={System.Uri.EscapeUriString(beatmap.Path)}"; + protected override string Target => $@"beatmaps/lookup?id={beatmap.OnlineBeatmapID}&checksum={beatmap.MD5Hash}&filename={System.Uri.EscapeUriString(beatmap.Path ?? string.Empty)}"; } } From 1bd9fa413e76c4f65300cf1005ba8231e9548be3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 23 Nov 2019 23:29:34 +0900 Subject: [PATCH 101/120] Fix incorrect NativeLibs version reference --- osu.iOS.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.iOS.props b/osu.iOS.props index 871a9238e3..ff6839f5ca 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -86,6 +86,6 @@ - + From 326a8f62eb49da63a172a4a6eb8aadbfeb35570a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 24 Nov 2019 00:21:34 +0900 Subject: [PATCH 102/120] Calculate more correct AR locally for now --- osu.Game.Tournament/Components/SongBar.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tournament/Components/SongBar.cs b/osu.Game.Tournament/Components/SongBar.cs index 4a738ae36b..23dc4bb22c 100644 --- a/osu.Game.Tournament/Components/SongBar.cs +++ b/osu.Game.Tournament/Components/SongBar.cs @@ -180,7 +180,10 @@ namespace osu.Game.Tournament.Components if ((mods & LegacyMods.DoubleTime) > 0) { - ar *= 1.5f; + // temporary local calculation (taken from OsuDifficultyCalculator) + double preempt = (int)BeatmapDifficulty.DifficultyRange(ar, 1800, 1200, 450) / 1.5; + ar = (float)(preempt > 1200 ? (1800 - preempt) / 120 : (1200 - preempt) / 150 + 5); + bpm *= 1.5f; length /= 1.5f; srExtra = "*"; From 244177880e3ce004a11942e469cbdbe91f2eca1a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 24 Nov 2019 01:45:21 +0900 Subject: [PATCH 103/120] Only show star on HR --- osu.Game.Tournament/Components/SongBar.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tournament/Components/SongBar.cs b/osu.Game.Tournament/Components/SongBar.cs index 23dc4bb22c..727dddeb7b 100644 --- a/osu.Game.Tournament/Components/SongBar.cs +++ b/osu.Game.Tournament/Components/SongBar.cs @@ -197,7 +197,7 @@ namespace osu.Game.Tournament.Components stats = new (string heading, string content)[] { ("CS", $"{beatmap.BaseDifficulty.CircleSize:0.#}{hardRockExtra}"), - ("AR", $"{ar:0.#}{srExtra}"), + ("AR", $"{ar:0.#}{hardRockExtra}"), ("OD", $"{beatmap.BaseDifficulty.OverallDifficulty:0.#}{hardRockExtra}"), }; break; @@ -215,7 +215,7 @@ namespace osu.Game.Tournament.Components stats = new (string heading, string content)[] { ("CS", $"{beatmap.BaseDifficulty.CircleSize:0.#}{hardRockExtra}"), - ("AR", $"{ar:0.#}{srExtra}"), + ("AR", $"{ar:0.#}"), }; break; } From 29b05e293913c75490242416786c9a537b307041 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 24 Nov 2019 00:01:49 +0300 Subject: [PATCH 104/120] Fix getScores can be fired twice on user change --- osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index e91d12b9fc..d65a03acad 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -213,9 +213,12 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private void onUserChanged(ValueChangedEvent user) { - modSelector.DeselectAll(); + if (modSelector.SelectedMods.Any()) + modSelector.DeselectAll(); + else + getScores(); + modSelector.FadeTo(userIsSupporter ? 1 : 0); - getScores(); } private void getScores() From 96533631fc546046a2b75f94d10324a0145aa446 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 24 Nov 2019 01:29:11 +0300 Subject: [PATCH 105/120] Simplify if/else statement --- osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index d65a03acad..112903b0f3 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -242,10 +242,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores loading.Hide(); return; } - else - { - notSupporterPlaceholder.Hide(); - } + + notSupporterPlaceholder.Hide(); content.Show(); loading.Show(); From 20a8a653c2f7f9fd8e64e6ef30c5116bb4c4be50 Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Sun, 24 Nov 2019 04:10:04 +0300 Subject: [PATCH 106/120] Change LegacySkin.Configuration accessibility --- osu.Game/Skinning/LegacySkin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 7ffed18d7b..868e3921bb 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -26,7 +26,7 @@ namespace osu.Game.Skinning [CanBeNull] protected IResourceStore Samples; - protected new LegacySkinConfiguration Configuration + public new LegacySkinConfiguration Configuration { get => base.Configuration as LegacySkinConfiguration; set => base.Configuration = value; From 2437cfd28c008e9f9af01c7ca10ebca41246971d Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Sun, 24 Nov 2019 04:36:16 +0300 Subject: [PATCH 107/120] Add test ensuring correct version lookup --- osu.Game.Tests/Skins/TestSceneSkinConfigurationLookup.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/osu.Game.Tests/Skins/TestSceneSkinConfigurationLookup.cs b/osu.Game.Tests/Skins/TestSceneSkinConfigurationLookup.cs index 578030748b..8b9c648442 100644 --- a/osu.Game.Tests/Skins/TestSceneSkinConfigurationLookup.cs +++ b/osu.Game.Tests/Skins/TestSceneSkinConfigurationLookup.cs @@ -116,6 +116,14 @@ namespace osu.Game.Tests.Skins }); } + [Test] + public void TestLegacyVersionLookup() + { + AddStep("Set source1 version 2.3", () => source1.Configuration.LegacyVersion = 2.3m); + AddStep("Set source2 version null", () => source2.Configuration.LegacyVersion = null); + AddAssert("Check legacy version lookup", () => requester.GetConfig(LegacySkinConfiguration.LegacySetting.Version)?.Value == 2.3m); + } + public enum LookupType { Test From b58afa3eb693c29d74d5aac93f7160f5f35dc639 Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Sun, 24 Nov 2019 04:36:34 +0300 Subject: [PATCH 108/120] Remove unnecessary mentioning in xmldoc --- osu.Game/Skinning/LegacySkinConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Skinning/LegacySkinConfiguration.cs b/osu.Game/Skinning/LegacySkinConfiguration.cs index 6a667e69f4..b1679bd464 100644 --- a/osu.Game/Skinning/LegacySkinConfiguration.cs +++ b/osu.Game/Skinning/LegacySkinConfiguration.cs @@ -8,7 +8,7 @@ namespace osu.Game.Skinning public const decimal LATEST_VERSION = 2.7m; /// - /// Legacy version of this skin. Null if no version was set to allow fallback to a parent skin version. + /// Legacy version of this skin. /// public decimal? LegacyVersion { get; internal set; } From 6126fd9a6b573a422aae719d240b31f80fea4950 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 24 Nov 2019 10:42:05 +0900 Subject: [PATCH 109/120] ApplyToDrawableHitObjects should be able to get all the hitobject in nasted Playfield --- osu.Game/Rulesets/UI/DrawableRuleset.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/UI/DrawableRuleset.cs b/osu.Game/Rulesets/UI/DrawableRuleset.cs index e0aeff8330..5ed1e5a368 100644 --- a/osu.Game/Rulesets/UI/DrawableRuleset.cs +++ b/osu.Game/Rulesets/UI/DrawableRuleset.cs @@ -224,7 +224,7 @@ namespace osu.Game.Rulesets.UI Playfield.PostProcess(); foreach (var mod in mods.OfType()) - mod.ApplyToDrawableHitObjects(Playfield.HitObjectContainer.Objects); + mod.ApplyToDrawableHitObjects(Playfield.AllHitObjects); } public override void RequestResume(Action continueResume) From fccdbffa9370d23cc606d4d3ced16a702801ca07 Mon Sep 17 00:00:00 2001 From: Berkan Diler Date: Mon, 25 Nov 2019 00:45:42 +0100 Subject: [PATCH 110/120] Use MathF instead of Math- functions when possible MathF-functions are faster than the Math-counterpart and it looks cleaner, so use MathF when we cast to float or int anyway. --- .../Difficulty/CatchPerformanceCalculator.cs | 2 +- .../Objects/Drawable/DrawableFruit.cs | 4 ++-- .../Beatmaps/ManiaBeatmapConverter.cs | 2 +- .../Beatmaps/Patterns/Legacy/PatternGenerator.cs | 4 ++-- osu.Game.Rulesets.Osu/Mods/OsuModTransform.cs | 2 +- .../Objects/Drawables/DrawableRepeatPoint.cs | 2 +- .../Objects/Drawables/Pieces/SpinnerTicks.cs | 10 +++++----- osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs | 10 +++++----- .../Screens/Drawings/Components/GroupContainer.cs | 2 +- .../Screens/Gameplay/Components/MatchScoreDisplay.cs | 2 +- osu.Game/Graphics/Backgrounds/Triangles.cs | 2 +- osu.Game/Overlays/NowPlayingOverlay.cs | 2 +- .../Overlays/Profile/Header/Components/RankGraph.cs | 4 ++-- .../Edit/Compose/Components/BeatDivisorControl.cs | 2 +- .../Compose/Components/CircularDistanceSnapGrid.cs | 2 +- osu.Game/Screens/Menu/LogoVisualisation.cs | 4 ++-- osu.Game/Screens/Select/BeatmapCarousel.cs | 4 ++-- osu.Game/Screens/Select/Details/AdvancedStats.cs | 2 +- 18 files changed, 31 insertions(+), 31 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchPerformanceCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchPerformanceCalculator.cs index a7f0d358ed..b876c774b2 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchPerformanceCalculator.cs @@ -55,7 +55,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty // Longer maps are worth more float lengthBonus = 0.95f + 0.4f * Math.Min(1.0f, numTotalHits / 3000.0f) + - (numTotalHits > 3000 ? (float)Math.Log10(numTotalHits / 3000.0f) * 0.5f : 0.0f); + (numTotalHits > 3000 ? MathF.Log10(numTotalHits / 3000.0f) * 0.5f : 0.0f); // Longer maps are worth more value *= lengthBonus; diff --git a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableFruit.cs b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableFruit.cs index eae652573b..2c97e5083d 100644 --- a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableFruit.cs +++ b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableFruit.cs @@ -99,8 +99,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable const float small_pulp = large_pulp_3 / 2; Vector2 positionAt(float angle, float distance) => new Vector2( - distance * (float)Math.Sin(angle * Math.PI / 180), - distance * (float)Math.Cos(angle * Math.PI / 180)); + distance * MathF.Sin(angle * MathF.PI / 180), + distance * MathF.Cos(angle * MathF.PI / 180)); switch (representation) { diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index 6c5bb304bf..5fa1e31c78 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -73,7 +73,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps { BeatmapDifficulty difficulty = original.BeatmapInfo.BaseDifficulty; - int seed = (int)Math.Round(difficulty.DrainRate + difficulty.CircleSize) * 20 + (int)(difficulty.OverallDifficulty * 41.2) + (int)Math.Round(difficulty.ApproachRate); + int seed = (int)MathF.Round(difficulty.DrainRate + difficulty.CircleSize) * 20 + (int)(difficulty.OverallDifficulty * 41.2) + (int)MathF.Round(difficulty.ApproachRate); Random = new FastRandom(seed); return base.ConvertBeatmap(original); diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs index b9984a8b90..a249c6f0f3 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs @@ -53,11 +53,11 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy if (allowSpecial && TotalColumns == 8) { const float local_x_divisor = 512f / 7; - return Math.Clamp((int)Math.Floor(position / local_x_divisor), 0, 6) + 1; + return Math.Clamp((int)MathF.Floor(position / local_x_divisor), 0, 6) + 1; } float localXDivisor = 512f / TotalColumns; - return Math.Clamp((int)Math.Floor(position / localXDivisor), 0, TotalColumns - 1); + return Math.Clamp((int)MathF.Floor(position / localXDivisor), 0, TotalColumns - 1); } /// diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModTransform.cs b/osu.Game.Rulesets.Osu/Mods/OsuModTransform.cs index 9b079895fa..a9475af638 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModTransform.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModTransform.cs @@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Osu.Mods float appearDistance = (float)(hitObject.TimePreempt - hitObject.TimeFadeIn) / 2; Vector2 originalPosition = drawable.Position; - Vector2 appearOffset = new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta)) * appearDistance; + Vector2 appearOffset = new Vector2(MathF.Cos(theta), MathF.Sin(theta)) * appearDistance; //the - 1 and + 1 prevents the hit objects to appear in the wrong position. double appearTime = hitObject.StartTime - hitObject.TimePreempt - 1; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs index 122975d55e..71cb9a9691 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs @@ -120,7 +120,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables break; } - float aimRotation = MathHelper.RadiansToDegrees((float)Math.Atan2(aimRotationVector.Y - Position.Y, aimRotationVector.X - Position.X)); + float aimRotation = MathHelper.RadiansToDegrees(MathF.Atan2(aimRotationVector.Y - Position.Y, aimRotationVector.X - Position.X)); while (Math.Abs(aimRotation - Rotation) > 180) aimRotation += aimRotation < Rotation ? 360 : -360; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerTicks.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerTicks.cs index 9219fab830..676cefb236 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerTicks.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerTicks.cs @@ -20,9 +20,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces Anchor = Anchor.Centre; RelativeSizeAxes = Axes.Both; - const int count = 18; + const float count = 18; - for (int i = 0; i < count; i++) + for (float i = 0; i < count; i++) { Add(new Container { @@ -40,10 +40,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces Size = new Vector2(60, 10), Origin = Anchor.Centre, Position = new Vector2( - 0.5f + (float)Math.Sin((float)i / count * 2 * MathHelper.Pi) / 2 * 0.86f, - 0.5f + (float)Math.Cos((float)i / count * 2 * MathHelper.Pi) / 2 * 0.86f + 0.5f + MathF.Sin(i / count * 2 * MathF.PI) / 2 * 0.86f, + 0.5f + MathF.Cos(i / count * 2 * MathF.PI) / 2 * 0.86f ), - Rotation = -(float)i / count * 360 + 90, + Rotation = -i / count * 360 + 90, Children = new[] { new Box diff --git a/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs b/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs index 24320b6579..d50b2098d6 100644 --- a/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs +++ b/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs @@ -185,14 +185,14 @@ namespace osu.Game.Rulesets.Osu.Replays { Vector2 spinCentreOffset = SPINNER_CENTRE - prevPos; float distFromCentre = spinCentreOffset.Length; - float distToTangentPoint = (float)Math.Sqrt(distFromCentre * distFromCentre - SPIN_RADIUS * SPIN_RADIUS); + float distToTangentPoint = MathF.Sqrt(distFromCentre * distFromCentre - SPIN_RADIUS * SPIN_RADIUS); if (distFromCentre > SPIN_RADIUS) { // Previous cursor position was outside spin circle, set startPosition to the tangent point. // Angle between centre offset and tangent point offset. - float angle = (float)Math.Asin(SPIN_RADIUS / distFromCentre); + float angle = MathF.Asin(SPIN_RADIUS / distFromCentre); if (angle > 0) { @@ -204,8 +204,8 @@ namespace osu.Game.Rulesets.Osu.Replays } // Rotate by angle so it's parallel to tangent line - spinCentreOffset.X = spinCentreOffset.X * (float)Math.Cos(angle) - spinCentreOffset.Y * (float)Math.Sin(angle); - spinCentreOffset.Y = spinCentreOffset.X * (float)Math.Sin(angle) + spinCentreOffset.Y * (float)Math.Cos(angle); + spinCentreOffset.X = spinCentreOffset.X * MathF.Cos(angle) - spinCentreOffset.Y * MathF.Sin(angle); + spinCentreOffset.Y = spinCentreOffset.X * MathF.Sin(angle) + spinCentreOffset.Y * MathF.Cos(angle); // Set length to distToTangentPoint spinCentreOffset.Normalize(); @@ -331,7 +331,7 @@ namespace osu.Game.Rulesets.Osu.Replays Vector2 difference = startPosition - SPINNER_CENTRE; float radius = difference.Length; - float angle = radius == 0 ? 0 : (float)Math.Atan2(difference.Y, difference.X); + float angle = radius == 0 ? 0 : MathF.Atan2(difference.Y, difference.X); double t; diff --git a/osu.Game.Tournament/Screens/Drawings/Components/GroupContainer.cs b/osu.Game.Tournament/Screens/Drawings/Components/GroupContainer.cs index 8a66ca7bf6..b9a19090df 100644 --- a/osu.Game.Tournament/Screens/Drawings/Components/GroupContainer.cs +++ b/osu.Game.Tournament/Screens/Drawings/Components/GroupContainer.cs @@ -57,7 +57,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components groups.Add(g); nextGroupName++; - if (i < (int)Math.Ceiling(numGroups / 2f)) + if (i < (int)MathF.Ceiling(numGroups / 2f)) topGroups.Add(g); else bottomGroups.Add(g); diff --git a/osu.Game.Tournament/Screens/Gameplay/Components/MatchScoreDisplay.cs b/osu.Game.Tournament/Screens/Gameplay/Components/MatchScoreDisplay.cs index 78455c8bb7..cc7903f2fa 100644 --- a/osu.Game.Tournament/Screens/Gameplay/Components/MatchScoreDisplay.cs +++ b/osu.Game.Tournament/Screens/Gameplay/Components/MatchScoreDisplay.cs @@ -100,7 +100,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components var diff = Math.Max(score1.Value, score2.Value) - Math.Min(score1.Value, score2.Value); losingBar.ResizeWidthTo(0, 400, Easing.OutQuint); - winningBar.ResizeWidthTo(Math.Min(0.4f, (float)Math.Pow(diff / 1500000f, 0.5) / 2), 400, Easing.OutQuint); + winningBar.ResizeWidthTo(Math.Min(0.4f, MathF.Pow(diff / 1500000f, 0.5f) / 2), 400, Easing.OutQuint); } protected override void Update() diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index dffa0c4fd5..6d88808150 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -111,7 +111,7 @@ namespace osu.Game.Graphics.Backgrounds float adjustedAlpha = HideAlphaDiscrepancies // Cubically scale alpha to make it drop off more sharply. - ? (float)Math.Pow(DrawColourInfo.Colour.AverageColour.Linear.A, 3) + ? MathF.Pow(DrawColourInfo.Colour.AverageColour.Linear.A, 3) : 1; float elapsedSeconds = (float)Time.Elapsed / 1000; diff --git a/osu.Game/Overlays/NowPlayingOverlay.cs b/osu.Game/Overlays/NowPlayingOverlay.cs index 4f73cbfacd..de30e1a754 100644 --- a/osu.Game/Overlays/NowPlayingOverlay.cs +++ b/osu.Game/Overlays/NowPlayingOverlay.cs @@ -390,7 +390,7 @@ namespace osu.Game.Overlays Vector2 change = e.MousePosition - e.MouseDownPosition; // Diminish the drag distance as we go further to simulate "rubber band" feeling. - change *= change.Length <= 0 ? 0 : (float)Math.Pow(change.Length, 0.7f) / change.Length; + change *= change.Length <= 0 ? 0 : MathF.Pow(change.Length, 0.7f) / change.Length; this.MoveTo(change); return true; diff --git a/osu.Game/Overlays/Profile/Header/Components/RankGraph.cs b/osu.Game/Overlays/Profile/Header/Components/RankGraph.cs index c6d96c5917..250b345db7 100644 --- a/osu.Game/Overlays/Profile/Header/Components/RankGraph.cs +++ b/osu.Game/Overlays/Profile/Header/Components/RankGraph.cs @@ -90,7 +90,7 @@ namespace osu.Game.Overlays.Profile.Header.Components placeholder.FadeOut(fade_duration, Easing.Out); graph.DefaultValueCount = ranks.Length; - graph.Values = ranks.Select(x => -(float)Math.Log(x.Value)); + graph.Values = ranks.Select(x => -MathF.Log(x.Value)); } graph.FadeTo(ranks.Length > 1 ? 1 : 0, fade_duration, Easing.Out); @@ -187,7 +187,7 @@ namespace osu.Game.Overlays.Profile.Header.Components public void HideBar() => bar.FadeOut(fade_duration); - private int calculateIndex(float mouseXPosition) => (int)Math.Round(mouseXPosition / DrawWidth * (DefaultValueCount - 1)); + private int calculateIndex(float mouseXPosition) => (int)MathF.Round(mouseXPosition / DrawWidth * (DefaultValueCount - 1)); private Vector2 calculateBallPosition(int index) { diff --git a/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs b/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs index 9e4691e4dd..42773ef687 100644 --- a/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs +++ b/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs @@ -289,7 +289,7 @@ namespace osu.Game.Screens.Edit.Compose.Components OnUserChange(Current.Value); } - private float getMappedPosition(float divisor) => (float)Math.Pow((divisor - 1) / (availableDivisors.Last() - 1), 0.90f); + private float getMappedPosition(float divisor) => MathF.Pow((divisor - 1) / (availableDivisors.Last() - 1), 0.90f); private class Tick : CompositeDrawable { diff --git a/osu.Game/Screens/Edit/Compose/Components/CircularDistanceSnapGrid.cs b/osu.Game/Screens/Edit/Compose/Components/CircularDistanceSnapGrid.cs index fc7d51db4b..91e19f9cc0 100644 --- a/osu.Game/Screens/Edit/Compose/Components/CircularDistanceSnapGrid.cs +++ b/osu.Game/Screens/Edit/Compose/Components/CircularDistanceSnapGrid.cs @@ -75,7 +75,7 @@ namespace osu.Game.Screens.Edit.Compose.Components float distance = direction.Length; float radius = DistanceSpacing; - int radialCount = Math.Clamp((int)Math.Round(distance / radius), 1, MaxIntervals); + int radialCount = Math.Clamp((int)MathF.Round(distance / radius), 1, MaxIntervals); Vector2 normalisedDirection = direction * new Vector2(1f / distance); Vector2 snappedPosition = CentrePosition + normalisedDirection * radialCount * radius; diff --git a/osu.Game/Screens/Menu/LogoVisualisation.cs b/osu.Game/Screens/Menu/LogoVisualisation.cs index 59ab6ad265..1a625f8d83 100644 --- a/osu.Game/Screens/Menu/LogoVisualisation.cs +++ b/osu.Game/Screens/Menu/LogoVisualisation.cs @@ -206,8 +206,8 @@ namespace osu.Game.Screens.Menu continue; float rotation = MathHelper.DegreesToRadians(i / (float)bars_per_visualiser * 360 + j * 360 / visualiser_rounds); - float rotationCos = (float)Math.Cos(rotation); - float rotationSin = (float)Math.Sin(rotation); + float rotationCos = MathF.Cos(rotation); + float rotationSin = MathF.Sin(rotation); //taking the cos and sin to the 0..1 range var barPosition = new Vector2(rotationCos / 2 + 0.5f, rotationSin / 2 + 0.5f) * size; diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 17736e7819..838ca5322c 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -670,8 +670,8 @@ namespace osu.Game.Screens.Select { // The radius of the circle the carousel moves on. const float circle_radius = 3; - double discriminant = Math.Max(0, circle_radius * circle_radius - dist * dist); - float x = (circle_radius - (float)Math.Sqrt(discriminant)) * halfHeight; + float discriminant = MathF.Max(0, circle_radius * circle_radius - dist * dist); + float x = (circle_radius - MathF.Sqrt(discriminant)) * halfHeight; return 125 + x; } diff --git a/osu.Game/Screens/Select/Details/AdvancedStats.cs b/osu.Game/Screens/Select/Details/AdvancedStats.cs index 52a57dd506..c5bdc230d0 100644 --- a/osu.Game/Screens/Select/Details/AdvancedStats.cs +++ b/osu.Game/Screens/Select/Details/AdvancedStats.cs @@ -34,7 +34,7 @@ namespace osu.Game.Screens.Select.Details if ((Beatmap?.Ruleset?.ID ?? 0) == 3) { firstValue.Title = "Key Amount"; - firstValue.Value = (int)Math.Round(Beatmap?.BaseDifficulty?.CircleSize ?? 0); + firstValue.Value = (int)MathF.Round(Beatmap?.BaseDifficulty?.CircleSize ?? 0); } else { From 45514ff660a403a41e2c284c6e6be5ef81406331 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Nov 2019 11:30:55 +0900 Subject: [PATCH 111/120] Apply fixes --- osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs | 4 ++-- osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs | 3 ++- .../Visual/Gameplay/TestSceneBarHitErrorMeter.cs | 8 ++++---- .../Visual/Online/TestSceneLeaderboardModSelector.cs | 3 ++- .../Visual/Online/TestSceneRankingsDismissableFlag.cs | 3 ++- osu.Game.Tests/Visual/Online/TestSceneUserRequest.cs | 6 +++--- osu.Game.Tournament/TournamentGameBase.cs | 4 ++-- osu.Game/Online/API/APIRequest.cs | 2 +- osu.Game/Overlays/Chat/DrawableChannel.cs | 3 ++- osu.Game/Overlays/Comments/CommentsHeader.cs | 5 +++-- .../Overlays/Comments/DeletedChildrenPlaceholder.cs | 3 ++- osu.Game/Overlays/Comments/DrawableComment.cs | 11 ++++++----- osu.Game/Overlays/Comments/SortTabControl.cs | 3 ++- osu.Game/Overlays/Comments/TotalCommentsCounter.cs | 5 +++-- osu.Game/Overlays/Comments/VotePill.cs | 2 +- .../Profile/Header/Components/PreviousUsernames.cs | 3 ++- osu.Game/Overlays/Rankings/HeaderTitle.cs | 5 +++-- 17 files changed, 42 insertions(+), 31 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs index 720ef1db42..9b529a2e4c 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs @@ -11,12 +11,12 @@ using System; using System.Collections.Generic; using osu.Game.Skinning; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; using osuTK.Graphics; using osu.Framework.Audio.Sample; using osu.Framework.Bindables; using osu.Framework.Graphics.Textures; using osu.Game.Audio; +using osu.Game.Graphics.Sprites; namespace osu.Game.Rulesets.Catch.Tests { @@ -66,7 +66,7 @@ namespace osu.Game.Rulesets.Catch.Tests RelativeSizeAxes = Axes.Both, Colour = Color4.Blue }, - new SpriteText + new OsuSpriteText { Text = "custom" } diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs index 7ca311118e..4da1b1dae0 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs @@ -16,6 +16,7 @@ using osu.Game.Audio; using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Screens.Play; using osu.Game.Skinning; @@ -125,7 +126,7 @@ namespace osu.Game.Rulesets.Osu.Tests { if (!enabled) return null; - return new SpriteText + return new OsuSpriteText { Text = identifier, Font = OsuFont.Default.With(size: 30), diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneBarHitErrorMeter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneBarHitErrorMeter.cs index a934d22b5d..e3688c276f 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneBarHitErrorMeter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneBarHitErrorMeter.cs @@ -9,7 +9,7 @@ using osu.Game.Rulesets.Judgements; using osu.Framework.MathUtils; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics.Sprites; using osu.Game.Rulesets.Catch.Scoring; using osu.Game.Rulesets.Mania.Scoring; using osu.Game.Rulesets.Osu.Scoring; @@ -85,9 +85,9 @@ namespace osu.Game.Tests.Visual.Gameplay AutoSizeAxes = Axes.Both, Children = new[] { - new SpriteText { Text = $@"Great: {hitWindows?.WindowFor(HitResult.Great)}" }, - new SpriteText { Text = $@"Good: {hitWindows?.WindowFor(HitResult.Good)}" }, - new SpriteText { Text = $@"Meh: {hitWindows?.WindowFor(HitResult.Meh)}" }, + new OsuSpriteText { Text = $@"Great: {hitWindows?.WindowFor(HitResult.Great)}" }, + new OsuSpriteText { Text = $@"Good: {hitWindows?.WindowFor(HitResult.Good)}" }, + new OsuSpriteText { Text = $@"Meh: {hitWindows?.WindowFor(HitResult.Meh)}" }, } }); diff --git a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs index ebe233a5f4..e0e5a088ce 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs @@ -13,6 +13,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Bindables; +using osu.Game.Graphics.Sprites; using osu.Game.Rulesets; namespace osu.Game.Tests.Visual.Online @@ -45,7 +46,7 @@ namespace osu.Game.Tests.Visual.Online modSelector.SelectedMods.ItemsAdded += mods => { - mods.ForEach(mod => selectedMods.Add(new SpriteText + mods.ForEach(mod => selectedMods.Add(new OsuSpriteText { Text = mod.Acronym, })); diff --git a/osu.Game.Tests/Visual/Online/TestSceneRankingsDismissableFlag.cs b/osu.Game.Tests/Visual/Online/TestSceneRankingsDismissableFlag.cs index db6afa9bf3..cd954cd6bd 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneRankingsDismissableFlag.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneRankingsDismissableFlag.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Rankings; using osu.Game.Users; using osuTK; @@ -45,7 +46,7 @@ namespace osu.Game.Tests.Visual.Online Size = new Vector2(30, 20), Country = countryA, }, - text = new SpriteText + text = new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserRequest.cs b/osu.Game.Tests/Visual/Online/TestSceneUserRequest.cs index 18d6028cb8..0f41247571 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserRequest.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserRequest.cs @@ -11,7 +11,7 @@ using osu.Game.Rulesets; using osu.Game.Rulesets.Mania; using osu.Game.Users; using osu.Framework.Graphics; -using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics.Sprites; using osu.Game.Rulesets.Taiko; using osu.Game.Graphics.UserInterface; @@ -94,11 +94,11 @@ namespace osu.Game.Tests.Visual.Online AddRange(new Drawable[] { - new SpriteText + new OsuSpriteText { Text = $@"Username: {user.NewValue?.Username}" }, - new SpriteText + new OsuSpriteText { Text = $@"RankedScore: {user.NewValue?.Statistics.RankedScore}" }, diff --git a/osu.Game.Tournament/TournamentGameBase.cs b/osu.Game.Tournament/TournamentGameBase.cs index f2a158971b..9e3dfa3ea6 100644 --- a/osu.Game.Tournament/TournamentGameBase.cs +++ b/osu.Game.Tournament/TournamentGameBase.cs @@ -12,13 +12,13 @@ using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Framework.Input; using osu.Framework.IO.Stores; using osu.Framework.Platform; using osu.Game.Beatmaps; using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; using osu.Game.Online.API.Requests; using osu.Game.Tournament.IPC; using osu.Game.Tournament.Models; @@ -104,7 +104,7 @@ namespace osu.Game.Tournament Colour = Color4.Red, RelativeSizeAxes = Axes.Both, }, - new SpriteText + new OsuSpriteText { Text = "Please make the window wider", Font = OsuFont.Default.With(weight: "bold"), diff --git a/osu.Game/Online/API/APIRequest.cs b/osu.Game/Online/API/APIRequest.cs index 53b23f5922..b424e0f086 100644 --- a/osu.Game/Online/API/APIRequest.cs +++ b/osu.Game/Online/API/APIRequest.cs @@ -150,7 +150,7 @@ namespace osu.Game.Online.API private class DisplayableError { [JsonProperty("error")] - public string ErrorMessage; + public string ErrorMessage { get; set; } } } diff --git a/osu.Game/Overlays/Chat/DrawableChannel.cs b/osu.Game/Overlays/Chat/DrawableChannel.cs index 427bd8dcde..443f2b7bf7 100644 --- a/osu.Game/Overlays/Chat/DrawableChannel.cs +++ b/osu.Game/Overlays/Chat/DrawableChannel.cs @@ -16,6 +16,7 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.Chat { @@ -202,7 +203,7 @@ namespace osu.Game.Overlays.Chat RelativeSizeAxes = Axes.X, Height = lineHeight, }, - text = new SpriteText + text = new OsuSpriteText { Margin = new MarginPadding { Horizontal = 10 }, Text = time.ToLocalTime().ToString("dd MMM yyyy"), diff --git a/osu.Game/Overlays/Comments/CommentsHeader.cs b/osu.Game/Overlays/Comments/CommentsHeader.cs index 66fe7ff3fa..6a7a678cc7 100644 --- a/osu.Game/Overlays/Comments/CommentsHeader.cs +++ b/osu.Game/Overlays/Comments/CommentsHeader.cs @@ -10,6 +10,7 @@ using osu.Game.Graphics; using osu.Framework.Graphics.Sprites; using osuTK; using osu.Framework.Input.Events; +using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.Comments { @@ -48,7 +49,7 @@ namespace osu.Game.Overlays.Comments Origin = Anchor.CentreLeft, Children = new Drawable[] { - new SpriteText + new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, @@ -101,7 +102,7 @@ namespace osu.Game.Overlays.Comments Origin = Anchor.CentreLeft, Size = new Vector2(10), }, - new SpriteText + new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, diff --git a/osu.Game/Overlays/Comments/DeletedChildrenPlaceholder.cs b/osu.Game/Overlays/Comments/DeletedChildrenPlaceholder.cs index e849691597..6b41453b91 100644 --- a/osu.Game/Overlays/Comments/DeletedChildrenPlaceholder.cs +++ b/osu.Game/Overlays/Comments/DeletedChildrenPlaceholder.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Sprites; using osuTK; using osu.Framework.Bindables; using Humanizer; +using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.Comments { @@ -31,7 +32,7 @@ namespace osu.Game.Overlays.Comments Icon = FontAwesome.Solid.Trash, Size = new Vector2(14), }, - countText = new SpriteText + countText = new OsuSpriteText { Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true), } diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs index 3fb9867f0e..9a11e85a7b 100644 --- a/osu.Game/Overlays/Comments/DrawableComment.cs +++ b/osu.Game/Overlays/Comments/DrawableComment.cs @@ -14,6 +14,7 @@ using osu.Framework.Graphics.Cursor; using osu.Framework.Bindables; using osu.Framework.Graphics.Shapes; using System.Linq; +using osu.Game.Graphics.Sprites; using osu.Game.Online.Chat; namespace osu.Game.Overlays.Comments @@ -122,7 +123,7 @@ namespace osu.Game.Overlays.Comments AutoSizeAxes = Axes.Both, }, new ParentUsername(comment), - new SpriteText + new OsuSpriteText { Alpha = comment.IsDeleted ? 1 : 0, Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true), @@ -144,7 +145,7 @@ namespace osu.Game.Overlays.Comments Colour = OsuColour.Gray(0.7f), Children = new Drawable[] { - new SpriteText + new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, @@ -195,7 +196,7 @@ namespace osu.Game.Overlays.Comments if (comment.EditedAt.HasValue) { - info.Add(new SpriteText + info.Add(new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, @@ -290,7 +291,7 @@ namespace osu.Game.Overlays.Comments this.count = count; Alpha = count == 0 ? 0 : 1; - Child = text = new SpriteText + Child = text = new OsuSpriteText { Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), }; @@ -323,7 +324,7 @@ namespace osu.Game.Overlays.Comments Icon = FontAwesome.Solid.Reply, Size = new Vector2(14), }, - new SpriteText + new OsuSpriteText { Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true), Text = parentComment?.User?.Username ?? parentComment?.LegacyName diff --git a/osu.Game/Overlays/Comments/SortTabControl.cs b/osu.Game/Overlays/Comments/SortTabControl.cs index f5423e692f..a114197b8d 100644 --- a/osu.Game/Overlays/Comments/SortTabControl.cs +++ b/osu.Game/Overlays/Comments/SortTabControl.cs @@ -11,6 +11,7 @@ using osu.Game.Graphics.UserInterface; using osu.Framework.Input.Events; using osu.Framework.Bindables; using osu.Framework.Allocation; +using osu.Game.Graphics.Sprites; using osuTK.Graphics; namespace osu.Game.Overlays.Comments @@ -61,7 +62,7 @@ namespace osu.Game.Overlays.Comments public TabButton(CommentsSortCriteria value) { - Add(text = new SpriteText + Add(text = new OsuSpriteText { Font = OsuFont.GetFont(size: 14), Text = value.ToString() diff --git a/osu.Game/Overlays/Comments/TotalCommentsCounter.cs b/osu.Game/Overlays/Comments/TotalCommentsCounter.cs index c71ca762e1..376853c1de 100644 --- a/osu.Game/Overlays/Comments/TotalCommentsCounter.cs +++ b/osu.Game/Overlays/Comments/TotalCommentsCounter.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics.Sprites; using osuTK; using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.Comments { @@ -32,7 +33,7 @@ namespace osu.Game.Overlays.Comments Spacing = new Vector2(5, 0), Children = new Drawable[] { - new SpriteText + new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, @@ -52,7 +53,7 @@ namespace osu.Game.Overlays.Comments RelativeSizeAxes = Axes.Both, Colour = OsuColour.Gray(0.05f) }, - counter = new SpriteText + counter = new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Overlays/Comments/VotePill.cs b/osu.Game/Overlays/Comments/VotePill.cs index ab35a477aa..978846549e 100644 --- a/osu.Game/Overlays/Comments/VotePill.cs +++ b/osu.Game/Overlays/Comments/VotePill.cs @@ -110,7 +110,7 @@ namespace osu.Game.Overlays.Comments } } }, - sideNumber = new SpriteText + sideNumber = new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreRight, diff --git a/osu.Game/Overlays/Profile/Header/Components/PreviousUsernames.cs b/osu.Game/Overlays/Profile/Header/Components/PreviousUsernames.cs index f18f319e27..e4c0fe3a5a 100644 --- a/osu.Game/Overlays/Profile/Header/Components/PreviousUsernames.cs +++ b/osu.Game/Overlays/Profile/Header/Components/PreviousUsernames.cs @@ -11,6 +11,7 @@ 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.Users; using osuTK; @@ -63,7 +64,7 @@ namespace osu.Game.Overlays.Profile.Header.Components new Drawable[] { hoverIcon = new HoverIconContainer(), - header = new SpriteText + header = new OsuSpriteText { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, diff --git a/osu.Game/Overlays/Rankings/HeaderTitle.cs b/osu.Game/Overlays/Rankings/HeaderTitle.cs index cba407ecf7..a1a893fa6b 100644 --- a/osu.Game/Overlays/Rankings/HeaderTitle.cs +++ b/osu.Game/Overlays/Rankings/HeaderTitle.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics; using osuTK; using osu.Game.Graphics; using osu.Framework.Allocation; +using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.Rankings { @@ -41,13 +42,13 @@ namespace osu.Game.Overlays.Rankings Margin = new MarginPadding { Bottom = flag_margin }, Size = new Vector2(30, 20), }, - scopeText = new SpriteText + scopeText = new OsuSpriteText { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Light) }, - new SpriteText + new OsuSpriteText { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, From 4904346814feeb39dd95a5879abd6eb0120be701 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Nov 2019 11:31:03 +0900 Subject: [PATCH 112/120] Fix false warnings --- CodeAnalysis/BannedSymbols.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CodeAnalysis/BannedSymbols.txt b/CodeAnalysis/BannedSymbols.txt index 3ad8d5db5b..c54c639b4f 100644 --- a/CodeAnalysis/BannedSymbols.txt +++ b/CodeAnalysis/BannedSymbols.txt @@ -2,4 +2,4 @@ M:System.Object.Equals(System.Object,System.Object)~System.Boolean;Don't use obj M:System.Object.Equals(System.Object)~System.Boolean;Don't use object.Equals. Use IEquatable or EqualityComparer.Default instead. M:System.ValueType.Equals(System.Object)~System.Boolean;Don't use object.Equals(Fallbacks to ValueType). Use IEquatable or EqualityComparer.Default instead. T:System.IComparable;Don't use non-generic IComparable. Use generic version instead. -T:osu.Framework.Graphics.Sprites.SpriteText;Use OsuSpriteText. +T:osu.Framework.Graphics.Sprites.SpriteText.#ctor;Use OsuSpriteText. From 36cabe72cf854cbfd05f01fb0d03dc91e9717078 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Nov 2019 11:49:54 +0900 Subject: [PATCH 113/120] Make DimmedLoadingLayer block input when active --- osu.Game/Graphics/UserInterface/DimmedLoadingLayer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/DimmedLoadingLayer.cs b/osu.Game/Graphics/UserInterface/DimmedLoadingLayer.cs index f7138827cc..f2f6dd429b 100644 --- a/osu.Game/Graphics/UserInterface/DimmedLoadingLayer.cs +++ b/osu.Game/Graphics/UserInterface/DimmedLoadingLayer.cs @@ -10,7 +10,7 @@ using osuTK; namespace osu.Game.Graphics.UserInterface { - public class DimmedLoadingLayer : VisibilityContainer + public class DimmedLoadingLayer : OverlayContainer { private const float transition_duration = 250; From 94e6bfeed33e9c3f1f3acf2ce0fc256d7fca30eb Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2019 07:30:17 +0000 Subject: [PATCH 114/120] Bump Microsoft.Build.Traversal from 2.0.19 to 2.0.24 Bumps [Microsoft.Build.Traversal](https://github.com/Microsoft/MSBuildSdks) from 2.0.19 to 2.0.24. - [Release notes](https://github.com/Microsoft/MSBuildSdks/releases) - [Changelog](https://github.com/microsoft/MSBuildSdks/blob/master/RELEASE.md) - [Commits](https://github.com/Microsoft/MSBuildSdks/compare/Microsoft.Build.Traversal.2.0.19...Microsoft.Build.Traversal.2.0.24) Signed-off-by: dependabot-preview[bot] --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index d8b8d14c36..43bb34912a 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "msbuild-sdks": { - "Microsoft.Build.Traversal": "2.0.19" + "Microsoft.Build.Traversal": "2.0.24" } } \ No newline at end of file From 719f0d5947e4d92db11682259a8033c361a6d2b7 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 25 Nov 2019 18:28:43 +0900 Subject: [PATCH 115/120] Fix stutters when changing beatmap difficulties --- osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 3de0ab191c..7b68460e6b 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -73,7 +73,7 @@ namespace osu.Game.Screens.Backgrounds Schedule(() => { - if ((Background as BeatmapBackground)?.Beatmap == beatmap) + if ((Background as BeatmapBackground)?.Beatmap.BeatmapInfo.BackgroundEquals(beatmap?.BeatmapInfo) ?? false) return; cancellationSource?.Cancel(); From 709ec1404f650cb368a56f88593ceed9f265f303 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Nov 2019 19:01:24 +0900 Subject: [PATCH 116/120] Centralise End/StartTime retrieval to extension method --- .../Objects/Drawable/DrawableCatchHitObject.cs | 4 ++-- .../ManiaBeatmapConversionTest.cs | 3 +-- .../Legacy/DistanceObjectPatternGenerator.cs | 2 +- .../Replays/ManiaAutoGenerator.cs | 3 +-- .../OsuBeatmapConversionTest.cs | 3 +-- .../Beatmaps/OsuBeatmapProcessor.cs | 12 ++++++------ osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs | 4 ++-- .../Drawables/Connections/FollowPointConnection.cs | 4 ++-- osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs | 6 +++--- .../TaikoBeatmapConversionTest.cs | 3 +-- osu.Game/Beatmaps/BeatmapManager.cs | 5 +++-- osu.Game/Rulesets/Mods/ModTimeRamp.cs | 3 +-- osu.Game/Rulesets/Objects/BarLineGenerator.cs | 3 +-- .../Rulesets/Objects/Drawables/DrawableHitObject.cs | 6 +++--- osu.Game/Rulesets/Objects/HitObject.cs | 13 +++++++++++++ .../UI/Scrolling/DrawableScrollingRuleset.cs | 3 +-- .../Edit/Compose/Components/DistanceSnapGrid.cs | 3 +-- osu.Game/Screens/Play/SongProgress.cs | 4 ++-- osu.Game/Screens/Play/SongProgressGraph.cs | 5 ++--- 19 files changed, 47 insertions(+), 42 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableCatchHitObject.cs b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableCatchHitObject.cs index dd4a58a5ef..b7c05392f3 100644 --- a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableCatchHitObject.cs +++ b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableCatchHitObject.cs @@ -4,8 +4,8 @@ using System; using osuTK; using osu.Framework.Graphics; +using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; -using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Scoring; namespace osu.Game.Rulesets.Catch.Objects.Drawable @@ -68,7 +68,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable protected override void UpdateStateTransforms(ArmedState state) { - var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime; + var endTime = HitObject.GetEndTime(); using (BeginAbsoluteSequence(endTime, true)) { diff --git a/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapConversionTest.cs b/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapConversionTest.cs index 6f10540973..12865385b6 100644 --- a/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapConversionTest.cs +++ b/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapConversionTest.cs @@ -9,7 +9,6 @@ using osu.Game.Beatmaps; using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Objects; -using osu.Game.Rulesets.Objects.Types; using osu.Game.Tests.Beatmaps; namespace osu.Game.Rulesets.Mania.Tests @@ -27,7 +26,7 @@ namespace osu.Game.Rulesets.Mania.Tests yield return new ConvertValue { StartTime = hitObject.StartTime, - EndTime = (hitObject as IHasEndTime)?.EndTime ?? hitObject.StartTime, + EndTime = hitObject.GetEndTime(), Column = ((ManiaHitObject)hitObject).Column }; } diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index 6297a68e08..5404cf2d23 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -77,7 +77,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy foreach (var obj in originalPattern.HitObjects) { - if (!Precision.AlmostEquals(EndTime, (obj as IHasEndTime)?.EndTime ?? obj.StartTime)) + if (!Precision.AlmostEquals(EndTime, obj.GetEndTime())) intermediatePattern.Add(obj); else endTimePattern.Add(obj); diff --git a/osu.Game.Rulesets.Mania/Replays/ManiaAutoGenerator.cs b/osu.Game.Rulesets.Mania/Replays/ManiaAutoGenerator.cs index 2b336ca16d..483327d5b3 100644 --- a/osu.Game.Rulesets.Mania/Replays/ManiaAutoGenerator.cs +++ b/osu.Game.Rulesets.Mania/Replays/ManiaAutoGenerator.cs @@ -6,7 +6,6 @@ using System.Linq; using osu.Game.Replays; using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Objects; -using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Replays; namespace osu.Game.Rulesets.Mania.Replays @@ -84,7 +83,7 @@ namespace osu.Game.Rulesets.Mania.Replays var currentObject = Beatmap.HitObjects[i]; var nextObjectInColumn = GetNextObject(i); // Get the next object that requires pressing the same button - double endTime = (currentObject as IHasEndTime)?.EndTime ?? currentObject.StartTime; + double endTime = currentObject.GetEndTime(); bool canDelayKeyUp = nextObjectInColumn == null || nextObjectInColumn.StartTime > endTime + RELEASE_DELAY; diff --git a/osu.Game.Rulesets.Osu.Tests/OsuBeatmapConversionTest.cs b/osu.Game.Rulesets.Osu.Tests/OsuBeatmapConversionTest.cs index e9fdf924c3..1a36bb37d5 100644 --- a/osu.Game.Rulesets.Osu.Tests/OsuBeatmapConversionTest.cs +++ b/osu.Game.Rulesets.Osu.Tests/OsuBeatmapConversionTest.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using NUnit.Framework; using osu.Framework.MathUtils; using osu.Game.Rulesets.Objects; -using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Tests.Beatmaps; @@ -44,7 +43,7 @@ namespace osu.Game.Rulesets.Osu.Tests ConvertValue createConvertValue(OsuHitObject obj) => new ConvertValue { StartTime = obj.StartTime, - EndTime = (obj as IHasEndTime)?.EndTime ?? obj.StartTime, + EndTime = obj.GetEndTime(), X = obj.StackedPosition.X, Y = obj.StackedPosition.Y }; diff --git a/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs b/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs index bb19b783aa..3a829f72fa 100644 --- a/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs +++ b/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs @@ -4,7 +4,7 @@ using System; using osu.Framework.Graphics; using osu.Game.Beatmaps; -using osu.Game.Rulesets.Objects.Types; +using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Osu.Objects; using osuTK; @@ -62,7 +62,7 @@ namespace osu.Game.Rulesets.Osu.Beatmaps if (objectN is Spinner) continue; - double endTime = (stackBaseObject as IHasEndTime)?.EndTime ?? stackBaseObject.StartTime; + double endTime = stackBaseObject.GetEndTime(); double stackThreshold = objectN.TimePreempt * beatmap.BeatmapInfo.StackLeniency; if (objectN.StartTime - endTime > stackThreshold) @@ -121,7 +121,7 @@ namespace osu.Game.Rulesets.Osu.Beatmaps OsuHitObject objectN = beatmap.HitObjects[n]; if (objectN is Spinner) continue; - double endTime = (objectN as IHasEndTime)?.EndTime ?? objectN.StartTime; + double endTime = objectN.GetEndTime(); if (objectI.StartTime - endTime > stackThreshold) //We are no longer within stacking range of the previous object. @@ -199,7 +199,7 @@ namespace osu.Game.Rulesets.Osu.Beatmaps if (currHitObject.StackHeight != 0 && !(currHitObject is Slider)) continue; - double startTime = (currHitObject as IHasEndTime)?.EndTime ?? currHitObject.StartTime; + double startTime = currHitObject.GetEndTime(); int sliderStack = 0; for (int j = i + 1; j < beatmap.HitObjects.Count; j++) @@ -217,14 +217,14 @@ namespace osu.Game.Rulesets.Osu.Beatmaps if (Vector2Extensions.Distance(beatmap.HitObjects[j].Position, currHitObject.Position) < stack_distance) { currHitObject.StackHeight++; - startTime = (beatmap.HitObjects[j] as IHasEndTime)?.EndTime ?? beatmap.HitObjects[j].StartTime; + startTime = beatmap.HitObjects[j].GetEndTime(); } else if (Vector2Extensions.Distance(beatmap.HitObjects[j].Position, position2) < stack_distance) { //Case for sliders - bump notes down and right, rather than up and left. sliderStack++; beatmap.HitObjects[j].StackHeight -= sliderStack; - startTime = (beatmap.HitObjects[j] as IHasEndTime)?.EndTime ?? beatmap.HitObjects[j].StartTime; + startTime = beatmap.HitObjects[j].GetEndTime(); } } } diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs index 32c9e913c6..9f384ea2e8 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs @@ -6,9 +6,9 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Graphics; using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables; -using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Osu.Objects; namespace osu.Game.Rulesets.Osu.Mods @@ -48,7 +48,7 @@ namespace osu.Game.Rulesets.Osu.Mods var fadeOutDuration = h.TimePreempt * fade_out_duration_multiplier; // new duration from completed fade in to end (before fading out) - var longFadeDuration = ((h as IHasEndTime)?.EndTime ?? h.StartTime) - fadeOutStartTime; + var longFadeDuration = h.GetEndTime() - fadeOutStartTime; switch (drawable) { diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/FollowPointConnection.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/FollowPointConnection.cs index 1e032eb977..6c4fbbac17 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/FollowPointConnection.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/FollowPointConnection.cs @@ -6,7 +6,7 @@ using JetBrains.Annotations; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Rulesets.Objects.Types; +using osu.Game.Rulesets.Objects; using osuTK; namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections @@ -99,7 +99,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections Vector2 startPosition = osuStart.EndPosition; Vector2 endPosition = osuEnd.Position; - double startTime = (osuStart as IHasEndTime)?.EndTime ?? osuStart.StartTime; + double startTime = osuStart.GetEndTime(); double endTime = osuEnd.StartTime; Vector2 distanceVector = endPosition - startPosition; diff --git a/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs b/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs index d50b2098d6..bd59e8a03f 100644 --- a/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs +++ b/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs @@ -10,7 +10,7 @@ using System.Diagnostics; using System.Linq; using osu.Framework.Graphics; using osu.Game.Replays; -using osu.Game.Rulesets.Objects.Types; +using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Osu.Beatmaps; using osu.Game.Rulesets.Osu.Scoring; using osu.Game.Rulesets.Scoring; @@ -96,7 +96,7 @@ namespace osu.Game.Rulesets.Osu.Replays private void addDelayedMovements(OsuHitObject h, OsuHitObject prev) { - double endTime = (prev as IHasEndTime)?.EndTime ?? prev.StartTime; + double endTime = prev.GetEndTime(); HitWindows hitWindows = null; @@ -275,7 +275,7 @@ namespace osu.Game.Rulesets.Osu.Replays var startFrame = new OsuReplayFrame(h.StartTime, new Vector2(startPosition.X, startPosition.Y), action); // TODO: Why do we delay 1 ms if the object is a spinner? There already is KEY_UP_DELAY from hEndTime. - double hEndTime = ((h as IHasEndTime)?.EndTime ?? h.StartTime) + KEY_UP_DELAY; + double hEndTime = h.GetEndTime() + KEY_UP_DELAY; int endDelay = h is Spinner ? 1 : 0; var endFrame = new OsuReplayFrame(hEndTime + endDelay, new Vector2(h.StackedEndPosition.X, h.StackedEndPosition.Y)); diff --git a/osu.Game.Rulesets.Taiko.Tests/TaikoBeatmapConversionTest.cs b/osu.Game.Rulesets.Taiko.Tests/TaikoBeatmapConversionTest.cs index 6c1882b4e2..28f5d4d301 100644 --- a/osu.Game.Rulesets.Taiko.Tests/TaikoBeatmapConversionTest.cs +++ b/osu.Game.Rulesets.Taiko.Tests/TaikoBeatmapConversionTest.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using NUnit.Framework; using osu.Framework.MathUtils; using osu.Game.Rulesets.Objects; -using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Taiko.Objects; using osu.Game.Tests.Beatmaps; @@ -27,7 +26,7 @@ namespace osu.Game.Rulesets.Taiko.Tests yield return new ConvertValue { StartTime = hitObject.StartTime, - EndTime = (hitObject as IHasEndTime)?.EndTime ?? hitObject.StartTime, + EndTime = hitObject.GetEndTime(), IsRim = hitObject is RimHit, IsCentre = hitObject is CentreHit, IsDrumRoll = hitObject is DrumRoll, diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index e6783ec828..bc78e50f5d 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -25,7 +25,7 @@ using osu.Game.IO.Archives; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Rulesets; -using osu.Game.Rulesets.Objects.Types; +using osu.Game.Rulesets.Objects; namespace osu.Game.Beatmaps { @@ -334,7 +334,8 @@ namespace osu.Game.Beatmaps var lastObject = b.HitObjects.Last(); - double endTime = (lastObject as IHasEndTime)?.EndTime ?? lastObject.StartTime; + //TODO: this isn't always correct (consider mania where a non-last object may last for longer than the last in the list). + double endTime = lastObject.GetEndTime(); double startTime = b.HitObjects.First().StartTime; return endTime - startTime; diff --git a/osu.Game/Rulesets/Mods/ModTimeRamp.cs b/osu.Game/Rulesets/Mods/ModTimeRamp.cs index f217512965..e231225e3c 100644 --- a/osu.Game/Rulesets/Mods/ModTimeRamp.cs +++ b/osu.Game/Rulesets/Mods/ModTimeRamp.cs @@ -8,7 +8,6 @@ using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Rulesets.UI; using osu.Game.Rulesets.Objects; -using osu.Game.Rulesets.Objects.Types; namespace osu.Game.Rulesets.Mods { @@ -42,7 +41,7 @@ namespace osu.Game.Rulesets.Mods HitObject lastObject = beatmap.HitObjects.LastOrDefault(); beginRampTime = beatmap.HitObjects.FirstOrDefault()?.StartTime ?? 0; - finalRateTime = final_rate_progress * ((lastObject as IHasEndTime)?.EndTime ?? lastObject?.StartTime ?? 0); + finalRateTime = final_rate_progress * (lastObject?.GetEndTime() ?? 0); } public virtual void Update(Playfield playfield) diff --git a/osu.Game/Rulesets/Objects/BarLineGenerator.cs b/osu.Game/Rulesets/Objects/BarLineGenerator.cs index 4f9395435e..07f0595015 100644 --- a/osu.Game/Rulesets/Objects/BarLineGenerator.cs +++ b/osu.Game/Rulesets/Objects/BarLineGenerator.cs @@ -6,7 +6,6 @@ using System.Linq; using osu.Framework.MathUtils; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; -using osu.Game.Rulesets.Objects.Types; namespace osu.Game.Rulesets.Objects { @@ -28,7 +27,7 @@ namespace osu.Game.Rulesets.Objects return; HitObject lastObject = beatmap.HitObjects.Last(); - double lastHitTime = 1 + ((lastObject as IHasEndTime)?.EndTime ?? lastObject.StartTime); + double lastHitTime = 1 + (lastObject.GetEndTime()); var timingPoints = beatmap.ControlPointInfo.TimingPoints; diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 35228e9ad1..ed48ddbc2f 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -382,7 +382,7 @@ namespace osu.Game.Rulesets.Objects.Drawables if (Result != null && Result.HasResult) { - var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime; + var endTime = HitObject.GetEndTime(); if (Result.TimeOffset + endTime > Time.Current) { @@ -460,7 +460,7 @@ namespace osu.Game.Rulesets.Objects.Drawables throw new InvalidOperationException($"{GetType().ReadableName()} applied a {nameof(JudgementResult)} but did not update {nameof(JudgementResult.Type)}."); // Ensure that the judgement is given a valid time offset, because this may not get set by the caller - var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime; + var endTime = HitObject.GetEndTime(); Result.TimeOffset = Math.Min(HitObject.HitWindows.WindowFor(HitResult.Miss), Time.Current - endTime); @@ -495,7 +495,7 @@ namespace osu.Game.Rulesets.Objects.Drawables if (Judged) return false; - var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime; + var endTime = HitObject.GetEndTime(); CheckForResult(userTriggered, Time.Current - endTime); return Judged; diff --git a/osu.Game/Rulesets/Objects/HitObject.cs b/osu.Game/Rulesets/Objects/HitObject.cs index ee0705ec5a..1179efaa6e 100644 --- a/osu.Game/Rulesets/Objects/HitObject.cs +++ b/osu.Game/Rulesets/Objects/HitObject.cs @@ -158,4 +158,17 @@ namespace osu.Game.Rulesets.Objects [NotNull] protected virtual HitWindows CreateHitWindows() => new HitWindows(); } + + public static class HitObjectExtensions + { + /// + /// Returns the end time of this object. + /// + /// + /// This returns the where available, falling back to otherwise. + /// + /// The object. + /// The end time of this object. + public static double GetEndTime(this HitObject hitObject) => (hitObject as IHasEndTime)?.EndTime ?? hitObject.StartTime; + } } diff --git a/osu.Game/Rulesets/UI/Scrolling/DrawableScrollingRuleset.cs b/osu.Game/Rulesets/UI/Scrolling/DrawableScrollingRuleset.cs index f178c01fd6..cfec5d3f49 100644 --- a/osu.Game/Rulesets/UI/Scrolling/DrawableScrollingRuleset.cs +++ b/osu.Game/Rulesets/UI/Scrolling/DrawableScrollingRuleset.cs @@ -15,7 +15,6 @@ using osu.Game.Configuration; using osu.Game.Input.Bindings; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects; -using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Timing; using osu.Game.Rulesets.UI.Scrolling.Algorithms; @@ -112,7 +111,7 @@ namespace osu.Game.Rulesets.UI.Scrolling [BackgroundDependencyLoader] private void load() { - double lastObjectTime = (Objects.LastOrDefault() as IHasEndTime)?.EndTime ?? Objects.LastOrDefault()?.StartTime ?? double.MaxValue; + double lastObjectTime = Objects.LastOrDefault()?.GetEndTime() ?? double.MaxValue; double baseBeatLength = TimingControlPoint.DEFAULT_BEAT_LENGTH; if (RelativeScaleBeatLengths) diff --git a/osu.Game/Screens/Edit/Compose/Components/DistanceSnapGrid.cs b/osu.Game/Screens/Edit/Compose/Components/DistanceSnapGrid.cs index 475b6e7274..9508a2cdf0 100644 --- a/osu.Game/Screens/Edit/Compose/Components/DistanceSnapGrid.cs +++ b/osu.Game/Screens/Edit/Compose/Components/DistanceSnapGrid.cs @@ -10,7 +10,6 @@ using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Objects; -using osu.Game.Rulesets.Objects.Types; using osuTK; namespace osu.Game.Screens.Edit.Compose.Components @@ -70,7 +69,7 @@ namespace osu.Game.Screens.Edit.Compose.Components [BackgroundDependencyLoader] private void load() { - StartTime = (hitObject as IHasEndTime)?.EndTime ?? hitObject.StartTime; + StartTime = hitObject.GetEndTime(); } protected override void LoadComplete() diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 3df06ebfa8..713d27bd16 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -12,7 +12,6 @@ using System.Linq; using osu.Framework.Bindables; using osu.Framework.Timing; using osu.Game.Rulesets.Objects; -using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.UI; namespace osu.Game.Screens.Play @@ -34,7 +33,8 @@ namespace osu.Game.Screens.Play public override bool HandleNonPositionalInput => AllowSeeking; public override bool HandlePositionalInput => AllowSeeking; - private double lastHitTime => ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1; + //TODO: this isn't always correct (consider mania where a non-last object may last for longer than the last in the list). + private double lastHitTime => objects.Last().GetEndTime() + 1; private double firstHitTime => objects.First().StartTime; diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index e480c5b502..e182a1a53d 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Collections.Generic; using System.Diagnostics; -using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects; namespace osu.Game.Screens.Play @@ -26,7 +25,7 @@ namespace osu.Game.Screens.Play return; var firstHit = objects.First().StartTime; - var lastHit = objects.Max(o => (o as IHasEndTime)?.EndTime ?? o.StartTime); + var lastHit = objects.Max(o => (o.GetEndTime())); if (lastHit == 0) lastHit = objects.Last().StartTime; @@ -35,7 +34,7 @@ namespace osu.Game.Screens.Play foreach (var h in objects) { - var endTime = (h as IHasEndTime)?.EndTime ?? h.StartTime; + var endTime = h.GetEndTime(); Debug.Assert(endTime >= h.StartTime); From 1fd5ed3c0f88f284a2155a379fff07275d9e6a7c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Nov 2019 21:35:25 +0900 Subject: [PATCH 117/120] Change login placeholder text to ask for username --- osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index a8bbccb168..d8833ee2f4 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -225,7 +225,7 @@ namespace osu.Game.Overlays.Settings.Sections.General { username = new OsuTextBox { - PlaceholderText = "email address", + PlaceholderText = "username", RelativeSizeAxes = Axes.X, Text = api?.ProvidedUsername ?? string.Empty, TabbableContentContainer = this @@ -239,7 +239,7 @@ namespace osu.Game.Overlays.Settings.Sections.General }, new SettingsCheckbox { - LabelText = "Remember email address", + LabelText = "Remember username", Bindable = config.GetBindable(OsuSetting.SaveUsername), }, new SettingsCheckbox From fbebbab5dbb4db0faaf633accc82e99f29982c5a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Nov 2019 22:37:07 +0900 Subject: [PATCH 118/120] Remove excess parenthesis --- osu.Game/Rulesets/Objects/BarLineGenerator.cs | 2 +- osu.Game/Screens/Play/SongProgressGraph.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/Objects/BarLineGenerator.cs b/osu.Game/Rulesets/Objects/BarLineGenerator.cs index 07f0595015..99672240e2 100644 --- a/osu.Game/Rulesets/Objects/BarLineGenerator.cs +++ b/osu.Game/Rulesets/Objects/BarLineGenerator.cs @@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Objects return; HitObject lastObject = beatmap.HitObjects.Last(); - double lastHitTime = 1 + (lastObject.GetEndTime()); + double lastHitTime = 1 + lastObject.GetEndTime(); var timingPoints = beatmap.ControlPointInfo.TimingPoints; diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index e182a1a53d..78eb456bb5 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -25,7 +25,7 @@ namespace osu.Game.Screens.Play return; var firstHit = objects.First().StartTime; - var lastHit = objects.Max(o => (o.GetEndTime())); + var lastHit = objects.Max(o => o.GetEndTime()); if (lastHit == 0) lastHit = objects.Last().StartTime; From 41fd3f67494c1131affda5c9e9c62da994e4cde1 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 25 Nov 2019 23:42:59 +0800 Subject: [PATCH 119/120] Correct BannedSymbols.txt. --- CodeAnalysis/BannedSymbols.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CodeAnalysis/BannedSymbols.txt b/CodeAnalysis/BannedSymbols.txt index c54c639b4f..5d86b99fd7 100644 --- a/CodeAnalysis/BannedSymbols.txt +++ b/CodeAnalysis/BannedSymbols.txt @@ -2,4 +2,4 @@ M:System.Object.Equals(System.Object,System.Object)~System.Boolean;Don't use obj M:System.Object.Equals(System.Object)~System.Boolean;Don't use object.Equals. Use IEquatable or EqualityComparer.Default instead. M:System.ValueType.Equals(System.Object)~System.Boolean;Don't use object.Equals(Fallbacks to ValueType). Use IEquatable or EqualityComparer.Default instead. T:System.IComparable;Don't use non-generic IComparable. Use generic version instead. -T:osu.Framework.Graphics.Sprites.SpriteText.#ctor;Use OsuSpriteText. +M:osu.Framework.Graphics.Sprites.SpriteText.#ctor;Use OsuSpriteText. From 8e25214eeea21dca5ea24727a968ba6b91223e9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 25 Nov 2019 21:21:56 +0100 Subject: [PATCH 120/120] Revert Android to using native network components This reverts commit 9acfc2587aa6a8dcd34a2535f3fc4bcf928bac1b ("Switch android to using managed network components") due to it causing crashes on every online call. The managed legacy TLS provider is slated for removal in later mono releases as it stands anyway. --- osu.Android.props | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Android.props b/osu.Android.props index 0da3e66236..f2d2af5678 100644 --- a/osu.Android.props +++ b/osu.Android.props @@ -16,8 +16,6 @@ armeabi-v7a;x86;arm64-v8a true cjk,mideast,other,rare,west - System.Net.Http.HttpClientHandler - legacy SdkOnly prompt