From 22f9339b01ff091b1e538050912c85377fbe38bf Mon Sep 17 00:00:00 2001 From: LeNitrous Date: Wed, 10 Apr 2019 21:53:13 +0800 Subject: [PATCH 01/34] let mods button have selected mod icons --- osu.Game/Screens/Select/Footer.cs | 31 ++++++------- osu.Game/Screens/Select/FooterButton.cs | 16 ++++--- osu.Game/Screens/Select/FooterButtonMods.cs | 48 +++++++++++++++++++++ osu.Game/Screens/Select/SongSelect.cs | 6 +-- 4 files changed, 74 insertions(+), 27 deletions(-) create mode 100644 osu.Game/Screens/Select/FooterButtonMods.cs diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index 03b9826e9b..c991e5c350 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -20,9 +20,6 @@ namespace osu.Game.Screens.Select { private readonly Box modeLight; - private const float play_song_select_button_width = 100; - private const float play_song_select_button_height = 50; - public const float HEIGHT = 50; public const int TRANSITION_LENGTH = 300; @@ -33,6 +30,7 @@ namespace osu.Game.Screens.Select private readonly FillFlowContainer buttons; + /// Button to be added. /// Text on the button. /// Colour of the button. /// Hotkey of the button. @@ -41,21 +39,16 @@ namespace osu.Game.Screens.Select /// Higher depth to be put on the left, and lower to be put on the right. /// Notice this is different to ! /// - public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0) + public void AddButton(FooterButton button, string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0) { - var button = new FooterButton - { - Text = text, - Height = play_song_select_button_height, - Width = play_song_select_button_width, - Depth = depth, - SelectedColour = colour, - DeselectedColour = colour.Opacity(0.5f), - Hotkey = hotkey, - Hovered = updateModeLight, - HoverLost = updateModeLight, - Action = action, - }; + button.Text = text; + button.Depth = depth; + button.SelectedColour = colour; + button.DeselectedColour = colour.Opacity(0.5f); + button.Hotkey = hotkey; + button.Hovered = updateModeLight; + button.HoverLost = updateModeLight; + button.Action = action; buttons.Add(button); buttons.SetLayoutPosition(button, -depth); @@ -71,10 +64,10 @@ namespace osu.Game.Screens.Select /// Higher depth to be put on the left, and lower to be put on the right. /// Notice this is different to ! /// - public void AddButton(string text, Color4 colour, OverlayContainer overlay, Key? hotkey = null, float depth = 0) + public void AddButton(FooterButton button, string text, Color4 colour, OverlayContainer overlay, Key? hotkey = null, float depth = 0) { overlays.Add(overlay); - AddButton(text, colour, () => + AddButton(button, text, colour, () => { foreach (var o in overlays) { diff --git a/osu.Game/Screens/Select/FooterButton.cs b/osu.Game/Screens/Select/FooterButton.cs index 9b98e344ce..0000bb95dd 100644 --- a/osu.Game/Screens/Select/FooterButton.cs +++ b/osu.Game/Screens/Select/FooterButton.cs @@ -6,6 +6,7 @@ using osuTK; using osuTK.Graphics; using osuTK.Input; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; @@ -61,8 +62,18 @@ namespace osu.Game.Screens.Select public FooterButton() { + AutoSizeAxes = Axes.Both; Children = new Drawable[] { + new Container + { + Size = new Vector2(100, 50), + Child = spriteText = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + } + }, box = new Box { RelativeSizeAxes = Axes.Both, @@ -78,11 +89,6 @@ namespace osu.Game.Screens.Select EdgeSmoothness = new Vector2(2, 0), RelativeSizeAxes = Axes.X, }, - spriteText = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - } }; } diff --git a/osu.Game/Screens/Select/FooterButtonMods.cs b/osu.Game/Screens/Select/FooterButtonMods.cs new file mode 100644 index 0000000000..a08870ba03 --- /dev/null +++ b/osu.Game/Screens/Select/FooterButtonMods.cs @@ -0,0 +1,48 @@ +// 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.Bindables; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.UI; +using System; +using System.Collections.Generic; +using osuTK; + +namespace osu.Game.Screens.Select +{ + public class FooterButtonMods : FooterButton + { + private readonly Bindable> selectedMods = new Bindable>(); + + private readonly FillFlowContainer modIcons; + + public FooterButtonMods(Bindable> mods) : base() + { + Add(modIcons = new FillFlowContainer + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Direction = FillDirection.Horizontal, + AutoSizeAxes = Axes.Both, + Margin = new MarginPadding {Left = 80, Right = 20} + }); + + if (mods != null) + { + selectedMods.BindTo(mods); + selectedMods.ValueChanged += updateModIcons; + } + } + + private void updateModIcons(ValueChangedEvent> mods) + { + modIcons.Clear(); + foreach (Mod mod in mods.NewValue) + { + modIcons.Add(new ModIcon(mod) { Scale = new Vector2(0.4f) }); + } + } + } +} diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index b60e693cbf..6fc95ea2e1 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -224,9 +224,9 @@ namespace osu.Game.Screens.Select if (Footer != null) { - Footer.AddButton(@"mods", colours.Yellow, ModSelect, Key.F1); - Footer.AddButton(@"random", colours.Green, triggerRandom, Key.F2); - Footer.AddButton(@"options", colours.Blue, BeatmapOptions, Key.F3); + Footer.AddButton(new FooterButtonMods(selectedMods), @"mods", colours.Yellow, ModSelect, Key.F1); + Footer.AddButton(new FooterButton(), @"random", colours.Green, triggerRandom, Key.F2); + Footer.AddButton(new FooterButton(), @"options", colours.Blue, BeatmapOptions, Key.F3); BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue); BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.Regular.TimesCircle, colours.Purple, null, Key.Number1); From b4d07558186a9d8dc3627ac1af564e375cab2f95 Mon Sep 17 00:00:00 2001 From: LeNitrous Date: Wed, 10 Apr 2019 22:10:09 +0800 Subject: [PATCH 02/34] please appveyor --- osu.Game/Screens/Select/FooterButtonMods.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Select/FooterButtonMods.cs b/osu.Game/Screens/Select/FooterButtonMods.cs index a08870ba03..51973b1e3d 100644 --- a/osu.Game/Screens/Select/FooterButtonMods.cs +++ b/osu.Game/Screens/Select/FooterButtonMods.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.UI; -using System; using System.Collections.Generic; using osuTK; @@ -18,7 +17,7 @@ namespace osu.Game.Screens.Select private readonly FillFlowContainer modIcons; - public FooterButtonMods(Bindable> mods) : base() + public FooterButtonMods(Bindable> mods) { Add(modIcons = new FillFlowContainer { @@ -26,7 +25,7 @@ namespace osu.Game.Screens.Select Origin = Anchor.CentreLeft, Direction = FillDirection.Horizontal, AutoSizeAxes = Axes.Both, - Margin = new MarginPadding {Left = 80, Right = 20} + Margin = new MarginPadding { Left = 80, Right = 20 } }); if (mods != null) From 01cc78108c1bd0d2fa3a21d6327e85354ccc6e8b Mon Sep 17 00:00:00 2001 From: LeNitrous Date: Thu, 11 Apr 2019 05:47:32 +0800 Subject: [PATCH 03/34] add random button --- osu.Game/Screens/Select/FooterButton.cs | 5 +- osu.Game/Screens/Select/FooterButtonRandom.cs | 56 +++++++++++++++++++ osu.Game/Screens/Select/SongSelect.cs | 2 +- 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 osu.Game/Screens/Select/FooterButtonRandom.cs diff --git a/osu.Game/Screens/Select/FooterButton.cs b/osu.Game/Screens/Select/FooterButton.cs index 0000bb95dd..aa547c658f 100644 --- a/osu.Game/Screens/Select/FooterButton.cs +++ b/osu.Game/Screens/Select/FooterButton.cs @@ -54,7 +54,8 @@ namespace osu.Game.Screens.Select } } - private readonly SpriteText spriteText; + protected readonly Container textContainer; + protected readonly SpriteText spriteText; private readonly Box box; private readonly Box light; @@ -65,7 +66,7 @@ namespace osu.Game.Screens.Select AutoSizeAxes = Axes.Both; Children = new Drawable[] { - new Container + textContainer = new Container { Size = new Vector2(100, 50), Child = spriteText = new OsuSpriteText diff --git a/osu.Game/Screens/Select/FooterButtonRandom.cs b/osu.Game/Screens/Select/FooterButtonRandom.cs new file mode 100644 index 0000000000..7466e1f243 --- /dev/null +++ b/osu.Game/Screens/Select/FooterButtonRandom.cs @@ -0,0 +1,56 @@ +// 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.Sprites; +using osu.Framework.Input.Events; +using osu.Game.Graphics.Sprites; +using System; + +namespace osu.Game.Screens.Select +{ + public class FooterButtonRandom : FooterButton + { + private readonly SpriteText secondaryText; + private bool secondaryActive; + + public FooterButtonRandom() + { + textContainer.Add(secondaryText = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Text = @"rewind", + Alpha = 0 + }); + } + + protected override bool OnKeyDown(KeyDownEvent e) + { + secondaryActive = e.ShiftPressed; + updateText(); + return base.OnKeyDown(e); + } + + protected override bool OnKeyUp(KeyUpEvent e) + { + secondaryActive = e.ShiftPressed; + updateText(); + return base.OnKeyUp(e); + } + + private void updateText() + { + if (secondaryActive) + { + spriteText.FadeOut(120, Easing.InQuad); + secondaryText.FadeIn(120, Easing.InQuad); + } + else + { + spriteText.FadeIn(120, Easing.InQuad); + secondaryText.FadeOut(120, Easing.InQuad); + } + } + } +} diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 6fc95ea2e1..7fb49e6dc6 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -225,7 +225,7 @@ namespace osu.Game.Screens.Select if (Footer != null) { Footer.AddButton(new FooterButtonMods(selectedMods), @"mods", colours.Yellow, ModSelect, Key.F1); - Footer.AddButton(new FooterButton(), @"random", colours.Green, triggerRandom, Key.F2); + Footer.AddButton(new FooterButtonRandom(), @"random", colours.Green, triggerRandom, Key.F2); Footer.AddButton(new FooterButton(), @"options", colours.Blue, BeatmapOptions, Key.F3); BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue); From 91c327a90f14b151ff3a62710559ab3f96153aa5 Mon Sep 17 00:00:00 2001 From: LeNitrous Date: Sun, 14 Apr 2019 07:22:31 +0800 Subject: [PATCH 04/34] use ModDisplay --- osu.Game/Screens/Select/FooterButtonMods.cs | 28 +++++++++------------ 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/osu.Game/Screens/Select/FooterButtonMods.cs b/osu.Game/Screens/Select/FooterButtonMods.cs index 51973b1e3d..d4bb7d3f21 100644 --- a/osu.Game/Screens/Select/FooterButtonMods.cs +++ b/osu.Game/Screens/Select/FooterButtonMods.cs @@ -4,44 +4,40 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Screens.Play.HUD; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.UI; using System.Collections.Generic; using osuTK; +using osu.Framework.Input.Events; namespace osu.Game.Screens.Select { public class FooterButtonMods : FooterButton { - private readonly Bindable> selectedMods = new Bindable>(); - - private readonly FillFlowContainer modIcons; + private readonly FooterModDisplay modDisplay; public FooterButtonMods(Bindable> mods) { - Add(modIcons = new FillFlowContainer + Add(new Container { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - Direction = FillDirection.Horizontal, + Child = modDisplay = new FooterModDisplay { + DisplayUnrankedText = false, + Scale = new Vector2(0.8f) + }, AutoSizeAxes = Axes.Both, - Margin = new MarginPadding { Left = 80, Right = 20 } + Margin = new MarginPadding { Left = 70 } }); if (mods != null) - { - selectedMods.BindTo(mods); - selectedMods.ValueChanged += updateModIcons; - } + modDisplay.Current = mods; } - private void updateModIcons(ValueChangedEvent> mods) + private class FooterModDisplay : ModDisplay { - modIcons.Clear(); - foreach (Mod mod in mods.NewValue) - { - modIcons.Add(new ModIcon(mod) { Scale = new Vector2(0.4f) }); - } + public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent?.Parent?.ReceivePositionalInputAt(screenSpacePos) ?? false; } } } From 2d227d25ccf45132e813e5293cd165fa30a6606f Mon Sep 17 00:00:00 2001 From: LeNitrous Date: Sun, 14 Apr 2019 07:55:15 +0800 Subject: [PATCH 05/34] fix appveyor warnings --- osu.Game/Screens/Select/FooterButton.cs | 14 +++++++------- osu.Game/Screens/Select/FooterButtonMods.cs | 6 ++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/osu.Game/Screens/Select/FooterButton.cs b/osu.Game/Screens/Select/FooterButton.cs index aa547c658f..e18a086a10 100644 --- a/osu.Game/Screens/Select/FooterButton.cs +++ b/osu.Game/Screens/Select/FooterButton.cs @@ -21,11 +21,11 @@ namespace osu.Game.Screens.Select public string Text { - get => spriteText?.Text; + get => SpriteText?.Text; set { - if (spriteText != null) - spriteText.Text = value; + if (SpriteText != null) + SpriteText.Text = value; } } @@ -54,8 +54,8 @@ namespace osu.Game.Screens.Select } } - protected readonly Container textContainer; - protected readonly SpriteText spriteText; + protected readonly Container TextContainer; + protected readonly SpriteText SpriteText; private readonly Box box; private readonly Box light; @@ -66,10 +66,10 @@ namespace osu.Game.Screens.Select AutoSizeAxes = Axes.Both; Children = new Drawable[] { - textContainer = new Container + TextContainer = new Container { Size = new Vector2(100, 50), - Child = spriteText = new OsuSpriteText + Child = SpriteText = new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Screens/Select/FooterButtonMods.cs b/osu.Game/Screens/Select/FooterButtonMods.cs index d4bb7d3f21..0a5b8c0929 100644 --- a/osu.Game/Screens/Select/FooterButtonMods.cs +++ b/osu.Game/Screens/Select/FooterButtonMods.cs @@ -6,19 +6,17 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Screens.Play.HUD; using osu.Game.Rulesets.Mods; -using osu.Game.Rulesets.UI; using System.Collections.Generic; using osuTK; -using osu.Framework.Input.Events; namespace osu.Game.Screens.Select { public class FooterButtonMods : FooterButton { - private readonly FooterModDisplay modDisplay; - public FooterButtonMods(Bindable> mods) { + FooterModDisplay modDisplay; + Add(new Container { Anchor = Anchor.CentreLeft, From 009eaa647a6acb5bf2d6b34bc02ce8223df891e3 Mon Sep 17 00:00:00 2001 From: LeNitrous Date: Fri, 3 May 2019 16:38:15 +0800 Subject: [PATCH 06/34] fixes to FooterButtonRandom --- osu.Game/Screens/Select/FooterButtonRandom.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Select/FooterButtonRandom.cs b/osu.Game/Screens/Select/FooterButtonRandom.cs index 7466e1f243..61e95de7fa 100644 --- a/osu.Game/Screens/Select/FooterButtonRandom.cs +++ b/osu.Game/Screens/Select/FooterButtonRandom.cs @@ -16,7 +16,7 @@ namespace osu.Game.Screens.Select public FooterButtonRandom() { - textContainer.Add(secondaryText = new OsuSpriteText + TextContainer.Add(secondaryText = new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -43,12 +43,12 @@ namespace osu.Game.Screens.Select { if (secondaryActive) { - spriteText.FadeOut(120, Easing.InQuad); + SpriteText.FadeOut(120, Easing.InQuad); secondaryText.FadeIn(120, Easing.InQuad); } else { - spriteText.FadeIn(120, Easing.InQuad); + SpriteText.FadeIn(120, Easing.InQuad); secondaryText.FadeOut(120, Easing.InQuad); } } From 31341bfeb181a5f2c3a71db7ae7010ed6115f839 Mon Sep 17 00:00:00 2001 From: LeNitrous Date: Fri, 3 May 2019 16:51:33 +0800 Subject: [PATCH 07/34] use SongSelect's SelectedMods property to ensure it exists --- osu.Game/Screens/Select/SongSelect.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 7fb49e6dc6..db77323b3d 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -224,7 +224,7 @@ namespace osu.Game.Screens.Select if (Footer != null) { - Footer.AddButton(new FooterButtonMods(selectedMods), @"mods", colours.Yellow, ModSelect, Key.F1); + Footer.AddButton(new FooterButtonMods(SelectedMods), @"mods", colours.Yellow, ModSelect, Key.F1); Footer.AddButton(new FooterButtonRandom(), @"random", colours.Green, triggerRandom, Key.F2); Footer.AddButton(new FooterButton(), @"options", colours.Blue, BeatmapOptions, Key.F3); From ff3c2265967ef633bdf91ba616d95f5bd9f3a60e Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 8 May 2019 13:37:03 +0900 Subject: [PATCH 08/34] Give ZoomableScrollContainer an initial width --- .../Editor/TestCaseZoomableScrollContainer.cs | 60 +++++++++++-------- .../Timeline/ZoomableScrollContainer.cs | 8 +++ 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/osu.Game.Tests/Visual/Editor/TestCaseZoomableScrollContainer.cs b/osu.Game.Tests/Visual/Editor/TestCaseZoomableScrollContainer.cs index e2cf1ef28a..55c978ae06 100644 --- a/osu.Game.Tests/Visual/Editor/TestCaseZoomableScrollContainer.cs +++ b/osu.Game.Tests/Visual/Editor/TestCaseZoomableScrollContainer.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Shapes; using osu.Framework.MathUtils; +using osu.Framework.Testing; using osu.Game.Graphics; using osu.Game.Graphics.Cursor; using osu.Game.Screens.Edit.Compose.Components.Timeline; @@ -18,38 +19,49 @@ namespace osu.Game.Tests.Visual.Editor { public class TestCaseZoomableScrollContainer : ManualInputManagerTestCase { - private readonly ZoomableScrollContainer scrollContainer; - private readonly Drawable innerBox; + private ZoomableScrollContainer scrollContainer; + private Drawable innerBox; - public TestCaseZoomableScrollContainer() + [SetUpSteps] + public void SetUpSteps() { - Children = new Drawable[] + AddStep("Add new scroll container", () => { - new Container + Children = new Drawable[] { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.X, - Height = 250, - Width = 0.75f, - Children = new Drawable[] + new Container { - new Box + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.X, + Height = 250, + Width = 0.75f, + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.Gray(30) - }, - scrollContainer = new ZoomableScrollContainer { RelativeSizeAxes = Axes.Both } - } - }, - new MenuCursor() - }; + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.Gray(30) + }, + scrollContainer = new ZoomableScrollContainer { RelativeSizeAxes = Axes.Both } + } + }, + new MenuCursor() + }; - scrollContainer.Add(innerBox = new Box - { - RelativeSizeAxes = Axes.Both, - Colour = ColourInfo.GradientHorizontal(new Color4(0.8f, 0.6f, 0.4f, 1f), new Color4(0.4f, 0.6f, 0.8f, 1f)) + scrollContainer.Add(innerBox = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = ColourInfo.GradientHorizontal(new Color4(0.8f, 0.6f, 0.4f, 1f), new Color4(0.4f, 0.6f, 0.8f, 1f)) + }); }); + AddUntilStep("Scroll container is loaded", () => scrollContainer.LoadState >= LoadState.Loaded); + } + + [Test] + public void TestWidthInitialization() + { + AddAssert("Inner container width was initialized", () => innerBox.DrawWidth > 0); } [Test] diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs index 9b00a3998d..ee6e29c92e 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs @@ -102,6 +102,14 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline return true; } + protected override void LoadComplete() + { + base.LoadComplete(); + + // This width only gets updated on the application of a transform, so this needs to be initialized here. + zoomedContent.Width = DrawWidth * currentZoom; + } + private float zoomTarget = 1; private void setZoomTarget(float newZoom, float focusPoint) From bace8296297851ed337ab71afeec50f7350a0169 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 8 May 2019 18:42:26 +0900 Subject: [PATCH 09/34] Add ability to avoid expand animation in ModDisplay --- osu.Game/Screens/Play/HUD/ModDisplay.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/ModDisplay.cs b/osu.Game/Screens/Play/HUD/ModDisplay.cs index 878d2b7c38..eeed74ae94 100644 --- a/osu.Game/Screens/Play/HUD/ModDisplay.cs +++ b/osu.Game/Screens/Play/HUD/ModDisplay.cs @@ -24,6 +24,8 @@ namespace osu.Game.Screens.Play.HUD public bool DisplayUnrankedText = true; + public bool AllowExpand = true; + private readonly Bindable> current = new Bindable>(); public Bindable> Current @@ -87,7 +89,9 @@ namespace osu.Game.Screens.Play.HUD protected override void LoadComplete() { base.LoadComplete(); + appearTransform(); + iconsContainer.FadeInFromZero(fade_duration, Easing.OutQuint); } private void appearTransform() @@ -97,14 +101,17 @@ namespace osu.Game.Screens.Play.HUD else unrankedText.Hide(); - iconsContainer.FinishTransforms(); - iconsContainer.FadeInFromZero(fade_duration, Easing.OutQuint); expand(); + using (iconsContainer.BeginDelayedSequence(1200)) contract(); } - private void expand() => iconsContainer.TransformSpacingTo(new Vector2(5, 0), 500, Easing.OutQuint); + private void expand() + { + if (AllowExpand) + iconsContainer.TransformSpacingTo(new Vector2(5, 0), 500, Easing.OutQuint); + } private void contract() => iconsContainer.TransformSpacingTo(new Vector2(-25, 0), 500, Easing.OutQuint); From 9a9ac05cd915c74b909bd3ad5372fa8a354db953 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 8 May 2019 18:42:54 +0900 Subject: [PATCH 10/34] Fix post-merge issues --- osu.Game/Screens/Select/SongSelect.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index ae1343099c..d43ca33ee3 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -223,7 +223,7 @@ namespace osu.Game.Screens.Select if (Footer != null) { - Footer.AddButton(new FooterButtonMods(SelectedMods), @"mods", colours.Yellow, ModSelect, Key.F1); + Footer.AddButton(new FooterButtonMods(mods), @"mods", colours.Yellow, ModSelect, Key.F1); Footer.AddButton(new FooterButtonRandom(), @"random", colours.Green, triggerRandom, Key.F2); Footer.AddButton(new FooterButton(), @"options", colours.Blue, BeatmapOptions, Key.F3); From 8906eb874ae7a015a5932b858b6ee586a9bd8267 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 8 May 2019 18:43:06 +0900 Subject: [PATCH 11/34] Fix CI issues --- osu.Game/Screens/Select/Footer.cs | 1 + osu.Game/Screens/Select/FooterButtonMods.cs | 7 ++++--- osu.Game/Screens/Select/FooterButtonRandom.cs | 1 - 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index c991e5c350..4466fb418c 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -56,6 +56,7 @@ namespace osu.Game.Screens.Select private readonly List overlays = new List(); + /// THe button to be added. /// Text on the button. /// Colour of the button. /// Hotkey of the button. diff --git a/osu.Game/Screens/Select/FooterButtonMods.cs b/osu.Game/Screens/Select/FooterButtonMods.cs index 0a5b8c0929..639804b3bd 100644 --- a/osu.Game/Screens/Select/FooterButtonMods.cs +++ b/osu.Game/Screens/Select/FooterButtonMods.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osu.Framework.Bindables; @@ -13,7 +13,7 @@ namespace osu.Game.Screens.Select { public class FooterButtonMods : FooterButton { - public FooterButtonMods(Bindable> mods) + public FooterButtonMods(Bindable> mods) { FooterModDisplay modDisplay; @@ -21,7 +21,8 @@ namespace osu.Game.Screens.Select { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - Child = modDisplay = new FooterModDisplay { + Child = modDisplay = new FooterModDisplay + { DisplayUnrankedText = false, Scale = new Vector2(0.8f) }, diff --git a/osu.Game/Screens/Select/FooterButtonRandom.cs b/osu.Game/Screens/Select/FooterButtonRandom.cs index 61e95de7fa..a725bfc103 100644 --- a/osu.Game/Screens/Select/FooterButtonRandom.cs +++ b/osu.Game/Screens/Select/FooterButtonRandom.cs @@ -5,7 +5,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; using osu.Game.Graphics.Sprites; -using System; namespace osu.Game.Screens.Select { From b33372ca629e46f4d399c9d35fe360bb9090843c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 8 May 2019 18:43:15 +0900 Subject: [PATCH 12/34] Don't expand mods in button on hover --- osu.Game/Screens/Select/FooterButtonMods.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/FooterButtonMods.cs b/osu.Game/Screens/Select/FooterButtonMods.cs index 639804b3bd..3de668bbf0 100644 --- a/osu.Game/Screens/Select/FooterButtonMods.cs +++ b/osu.Game/Screens/Select/FooterButtonMods.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osu.Framework.Bindables; @@ -37,6 +37,11 @@ namespace osu.Game.Screens.Select private class FooterModDisplay : ModDisplay { public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent?.Parent?.ReceivePositionalInputAt(screenSpacePos) ?? false; + + public FooterModDisplay() + { + AllowExpand = false; + } } } } From 772eb460fbd477fac46d5948bc133e0bc947b433 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 8 May 2019 19:03:26 +0900 Subject: [PATCH 13/34] Move button definitions to their respective classes --- osu.Game/Screens/Select/Footer.cs | 57 +++++++------------ osu.Game/Screens/Select/FooterButtonMods.cs | 11 ++++ osu.Game/Screens/Select/FooterButtonRandom.cs | 11 ++++ osu.Game/Screens/Select/SongSelect.cs | 6 +- 4 files changed, 46 insertions(+), 39 deletions(-) diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index 4466fb418c..b5afc7b0ff 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -30,54 +30,39 @@ namespace osu.Game.Screens.Select private readonly FillFlowContainer buttons; - /// Button to be added. - /// Text on the button. - /// Colour of the button. + private readonly List overlays = new List(); + + /// THe button to be added. + /// The to be toggled by this button. /// Hotkey of the button. - /// Action the button does. - /// - /// Higher depth to be put on the left, and lower to be put on the right. - /// Notice this is different to ! - /// - public void AddButton(FooterButton button, string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0) + public void AddButton(FooterButton button, OverlayContainer overlay, Key? hotkey = null) + { + overlays.Add(overlay); + AddButton(button, () => showOverlay(overlay), hotkey); + } + + /// Button to be added. + /// Action the button does. + /// Hotkey of the button. + public void AddButton(FooterButton button, Action action, Key? hotkey = null) { - button.Text = text; - button.Depth = depth; - button.SelectedColour = colour; - button.DeselectedColour = colour.Opacity(0.5f); button.Hotkey = hotkey; button.Hovered = updateModeLight; button.HoverLost = updateModeLight; button.Action = action; buttons.Add(button); - buttons.SetLayoutPosition(button, -depth); } - private readonly List overlays = new List(); - - /// THe button to be added. - /// Text on the button. - /// Colour of the button. - /// Hotkey of the button. - /// The to be toggled by this button. - /// - /// Higher depth to be put on the left, and lower to be put on the right. - /// Notice this is different to ! - /// - public void AddButton(FooterButton button, string text, Color4 colour, OverlayContainer overlay, Key? hotkey = null, float depth = 0) + private void showOverlay(OverlayContainer overlay) { - overlays.Add(overlay); - AddButton(button, text, colour, () => + foreach (var o in overlays) { - foreach (var o in overlays) - { - if (o == overlay) - o.ToggleVisibility(); - else - o.Hide(); - } - }, hotkey, depth); + if (o == overlay) + o.ToggleVisibility(); + else + o.Hide(); + } } private void updateModeLight() => modeLight.FadeColour(buttons.FirstOrDefault(b => b.IsHovered)?.SelectedColour ?? Color4.Transparent, TRANSITION_LENGTH, Easing.OutQuint); diff --git a/osu.Game/Screens/Select/FooterButtonMods.cs b/osu.Game/Screens/Select/FooterButtonMods.cs index 3de668bbf0..4343ee6cdb 100644 --- a/osu.Game/Screens/Select/FooterButtonMods.cs +++ b/osu.Game/Screens/Select/FooterButtonMods.cs @@ -7,6 +7,9 @@ using osu.Framework.Graphics.Containers; using osu.Game.Screens.Play.HUD; using osu.Game.Rulesets.Mods; using System.Collections.Generic; +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; +using osu.Game.Graphics; using osuTK; namespace osu.Game.Screens.Select @@ -34,6 +37,14 @@ namespace osu.Game.Screens.Select modDisplay.Current = mods; } + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + SelectedColour = colours.Yellow; + DeselectedColour = SelectedColour.Opacity(0.5f); + Text = @"mods"; + } + private class FooterModDisplay : ModDisplay { public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent?.Parent?.ReceivePositionalInputAt(screenSpacePos) ?? false; diff --git a/osu.Game/Screens/Select/FooterButtonRandom.cs b/osu.Game/Screens/Select/FooterButtonRandom.cs index a725bfc103..06f2e1ee43 100644 --- a/osu.Game/Screens/Select/FooterButtonRandom.cs +++ b/osu.Game/Screens/Select/FooterButtonRandom.cs @@ -1,9 +1,12 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; +using osu.Game.Graphics; using osu.Game.Graphics.Sprites; namespace osu.Game.Screens.Select @@ -24,6 +27,14 @@ namespace osu.Game.Screens.Select }); } + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + SelectedColour = colours.Green; + DeselectedColour = SelectedColour.Opacity(0.5f); + Text = @"random"; + } + protected override bool OnKeyDown(KeyDownEvent e) { secondaryActive = e.ShiftPressed; diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index d43ca33ee3..c747fdee60 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -223,9 +223,9 @@ namespace osu.Game.Screens.Select if (Footer != null) { - Footer.AddButton(new FooterButtonMods(mods), @"mods", colours.Yellow, ModSelect, Key.F1); - Footer.AddButton(new FooterButtonRandom(), @"random", colours.Green, triggerRandom, Key.F2); - Footer.AddButton(new FooterButton(), @"options", colours.Blue, BeatmapOptions, Key.F3); + Footer.AddButton(new FooterButtonMods(mods), ModSelect, Key.F1); + Footer.AddButton(new FooterButtonRandom(), triggerRandom, Key.F2); + Footer.AddButton(new FooterButtonOptions(), BeatmapOptions, Key.F3); BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue); BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.Regular.TimesCircle, colours.Purple, null, Key.Number1); From 39efa2d173de774cf130dded0bf4f5febdbb4666 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 8 May 2019 19:05:00 +0900 Subject: [PATCH 14/34] Fix possible cross-thread config cache access --- osu.Game/Rulesets/RulesetConfigCache.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/osu.Game/Rulesets/RulesetConfigCache.cs b/osu.Game/Rulesets/RulesetConfigCache.cs index 4ac866fc90..9a5a4d4acd 100644 --- a/osu.Game/Rulesets/RulesetConfigCache.cs +++ b/osu.Game/Rulesets/RulesetConfigCache.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; -using System.Collections.Generic; +using System.Collections.Concurrent; using osu.Framework.Graphics; using osu.Game.Configuration; using osu.Game.Rulesets.Configuration; @@ -15,7 +15,7 @@ namespace osu.Game.Rulesets /// public class RulesetConfigCache : Component { - private readonly Dictionary configCache = new Dictionary(); + private readonly ConcurrentDictionary configCache = new ConcurrentDictionary(); private readonly SettingsStore settingsStore; public RulesetConfigCache(SettingsStore settingsStore) @@ -34,10 +34,7 @@ namespace osu.Game.Rulesets if (ruleset.RulesetInfo.ID == null) throw new InvalidOperationException("The provided ruleset doesn't have a valid id."); - if (configCache.TryGetValue(ruleset.RulesetInfo.ID.Value, out var existing)) - return existing; - - return configCache[ruleset.RulesetInfo.ID.Value] = ruleset.CreateConfig(settingsStore); + return configCache.GetOrAdd(ruleset.RulesetInfo.ID.Value, _ => ruleset.CreateConfig(settingsStore)); } } } From c91b9c60322f2c580c2378e4ad5afbf9c539f967 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 8 May 2019 19:27:53 +0900 Subject: [PATCH 15/34] Add missing button --- osu.Game/Screens/Select/FooterButtonOptions.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 osu.Game/Screens/Select/FooterButtonOptions.cs diff --git a/osu.Game/Screens/Select/FooterButtonOptions.cs b/osu.Game/Screens/Select/FooterButtonOptions.cs new file mode 100644 index 0000000000..1fbe03216d --- /dev/null +++ b/osu.Game/Screens/Select/FooterButtonOptions.cs @@ -0,0 +1,17 @@ +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; +using osu.Game.Graphics; + +namespace osu.Game.Screens.Select +{ + public class FooterButtonOptions : FooterButton + { + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + SelectedColour = colours.Blue; + DeselectedColour = SelectedColour.Opacity(0.5f); + Text = @"options"; + } + } +} \ No newline at end of file From 6dea16f36543f640901652e2f2e69020d14c321e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 8 May 2019 19:29:43 +0900 Subject: [PATCH 16/34] Move action and hotkey specification local --- osu.Game/Screens/Select/Footer.cs | 14 +++++--------- osu.Game/Screens/Select/FooterButtonMods.cs | 2 ++ osu.Game/Screens/Select/FooterButtonOptions.cs | 4 +++- osu.Game/Screens/Select/FooterButtonRandom.cs | 2 ++ osu.Game/Screens/Select/SongSelect.cs | 6 +++--- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index b5afc7b0ff..6ba29751b0 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Linq; using osuTK; using osuTK.Graphics; -using osuTK.Input; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -34,22 +33,19 @@ namespace osu.Game.Screens.Select /// THe button to be added. /// The to be toggled by this button. - /// Hotkey of the button. - public void AddButton(FooterButton button, OverlayContainer overlay, Key? hotkey = null) + public void AddButton(FooterButton button, OverlayContainer overlay) { overlays.Add(overlay); - AddButton(button, () => showOverlay(overlay), hotkey); + button.Action = () => showOverlay(overlay); + + AddButton(button); } /// Button to be added. - /// Action the button does. - /// Hotkey of the button. - public void AddButton(FooterButton button, Action action, Key? hotkey = null) + public void AddButton(FooterButton button) { - button.Hotkey = hotkey; button.Hovered = updateModeLight; button.HoverLost = updateModeLight; - button.Action = action; buttons.Add(button); } diff --git a/osu.Game/Screens/Select/FooterButtonMods.cs b/osu.Game/Screens/Select/FooterButtonMods.cs index 4343ee6cdb..c96c5022c0 100644 --- a/osu.Game/Screens/Select/FooterButtonMods.cs +++ b/osu.Game/Screens/Select/FooterButtonMods.cs @@ -11,6 +11,7 @@ using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Game.Graphics; using osuTK; +using osuTK.Input; namespace osu.Game.Screens.Select { @@ -43,6 +44,7 @@ namespace osu.Game.Screens.Select SelectedColour = colours.Yellow; DeselectedColour = SelectedColour.Opacity(0.5f); Text = @"mods"; + Hotkey = Key.F1; } private class FooterModDisplay : ModDisplay diff --git a/osu.Game/Screens/Select/FooterButtonOptions.cs b/osu.Game/Screens/Select/FooterButtonOptions.cs index 1fbe03216d..0e4a32299d 100644 --- a/osu.Game/Screens/Select/FooterButtonOptions.cs +++ b/osu.Game/Screens/Select/FooterButtonOptions.cs @@ -1,6 +1,7 @@ using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Game.Graphics; +using osuTK.Input; namespace osu.Game.Screens.Select { @@ -12,6 +13,7 @@ namespace osu.Game.Screens.Select SelectedColour = colours.Blue; DeselectedColour = SelectedColour.Opacity(0.5f); Text = @"options"; + Hotkey = Key.F3; } } -} \ No newline at end of file +} diff --git a/osu.Game/Screens/Select/FooterButtonRandom.cs b/osu.Game/Screens/Select/FooterButtonRandom.cs index 06f2e1ee43..14c9eb2035 100644 --- a/osu.Game/Screens/Select/FooterButtonRandom.cs +++ b/osu.Game/Screens/Select/FooterButtonRandom.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osuTK.Input; namespace osu.Game.Screens.Select { @@ -33,6 +34,7 @@ namespace osu.Game.Screens.Select SelectedColour = colours.Green; DeselectedColour = SelectedColour.Opacity(0.5f); Text = @"random"; + Hotkey = Key.F2; } protected override bool OnKeyDown(KeyDownEvent e) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index c747fdee60..d5301116a9 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -223,9 +223,9 @@ namespace osu.Game.Screens.Select if (Footer != null) { - Footer.AddButton(new FooterButtonMods(mods), ModSelect, Key.F1); - Footer.AddButton(new FooterButtonRandom(), triggerRandom, Key.F2); - Footer.AddButton(new FooterButtonOptions(), BeatmapOptions, Key.F3); + Footer.AddButton(new FooterButtonMods(mods), ModSelect); + Footer.AddButton(new FooterButtonRandom { Action = triggerRandom }); + Footer.AddButton(new FooterButtonOptions(), BeatmapOptions); BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue); BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.Regular.TimesCircle, colours.Purple, null, Key.Number1); From 4f697e2bd58c4e238c03918c0a2c4eedb9152174 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 8 May 2019 19:35:20 +0900 Subject: [PATCH 17/34] Add licence header --- osu.Game/Screens/Select/FooterButtonOptions.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Screens/Select/FooterButtonOptions.cs b/osu.Game/Screens/Select/FooterButtonOptions.cs index 0e4a32299d..c000d8a8c8 100644 --- a/osu.Game/Screens/Select/FooterButtonOptions.cs +++ b/osu.Game/Screens/Select/FooterButtonOptions.cs @@ -1,3 +1,6 @@ +// 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.Extensions.Color4Extensions; using osu.Game.Graphics; From 83663467ce4ea861622b9a7ad86be18904f03783 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 8 May 2019 21:08:46 +0900 Subject: [PATCH 18/34] Update dependencies --- osu.Desktop/osu.Desktop.csproj | 6 +++--- osu.Game/osu.Game.csproj | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index 66db439c82..aa8848c55f 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -26,9 +26,9 @@ - - - + + + diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index b6b4896658..8f733a5c55 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -11,11 +11,11 @@ - - - - - + + + + + From 17a9f191cd70dde920ee52ba58ada1e81d38127d Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 8 May 2019 23:08:08 +0900 Subject: [PATCH 19/34] Fix incorrect texture name usage for some rank icons --- .../Profile/Header/DetailHeaderContainer.cs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs b/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs index de710c5fcd..f9ee67002a 100644 --- a/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs +++ b/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs @@ -4,14 +4,12 @@ using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Extensions; 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.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Online.Leaderboards; using osu.Game.Overlays.Profile.Header.Components; using osu.Game.Scoring; using osu.Game.Users; @@ -185,8 +183,6 @@ namespace osu.Game.Overlays.Profile.Header private class ScoreRankInfo : CompositeDrawable { - private readonly ScoreRank rank; - private readonly Sprite rankSprite; private readonly OsuSpriteText rankCount; public int RankCount @@ -196,8 +192,6 @@ namespace osu.Game.Overlays.Profile.Header public ScoreRankInfo(ScoreRank rank) { - this.rank = rank; - AutoSizeAxes = Axes.Both; InternalChild = new FillFlowContainer { @@ -206,9 +200,10 @@ namespace osu.Game.Overlays.Profile.Header Direction = FillDirection.Vertical, Children = new Drawable[] { - rankSprite = new Sprite + new DrawableRank(rank) { - RelativeSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.X, + Height = 30, FillMode = FillMode.Fit }, rankCount = new OsuSpriteText @@ -220,12 +215,6 @@ namespace osu.Game.Overlays.Profile.Header } }; } - - [BackgroundDependencyLoader] - private void load(TextureStore textures) - { - rankSprite.Texture = textures.Get($"Grades/{rank.GetDescription()}"); - } } } } From 5128dc32e440d7c3925d1440ef5961d0782c00a4 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 8 May 2019 23:13:09 +0900 Subject: [PATCH 20/34] Remove unnecessary fillmode --- osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs b/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs index f9ee67002a..e41c90be45 100644 --- a/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs +++ b/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs @@ -204,7 +204,6 @@ namespace osu.Game.Overlays.Profile.Header { RelativeSizeAxes = Axes.X, Height = 30, - FillMode = FillMode.Fit }, rankCount = new OsuSpriteText { From 9b279f324f35c367edf0ad12cb1b22dfe0fef797 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 8 May 2019 23:38:57 +0900 Subject: [PATCH 21/34] Adjust testcase to avoid random failures --- .../TestCaseUpdateableBeatmapBackgroundSprite.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestCaseUpdateableBeatmapBackgroundSprite.cs b/osu.Game.Tests/Visual/UserInterface/TestCaseUpdateableBeatmapBackgroundSprite.cs index a4dd7b83e2..e9c5bc929d 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestCaseUpdateableBeatmapBackgroundSprite.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestCaseUpdateableBeatmapBackgroundSprite.cs @@ -107,7 +107,7 @@ namespace osu.Game.Tests.Visual.UserInterface AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Spacing = new Vector2(10), - Padding = new MarginPadding { Bottom = 250 } + Padding = new MarginPadding { Bottom = 550 } } }; @@ -136,7 +136,7 @@ namespace osu.Game.Tests.Visual.UserInterface AddUntilStep("some loaded", () => (initialLoadCount = loadedBackgrounds.Count()) > 0); AddStep("scroll to bottom", () => scrollContainer.ScrollToEnd()); - AddUntilStep("some unloaded", () => loadedBackgrounds.Count() < initialLoadCount); + AddUntilStep("all unloaded", () => !loadedBackgrounds.Any()); } private class TestUpdateableBeatmapBackgroundSprite : UpdateableBeatmapBackgroundSprite From 9c01f6793ecb7341d8c3fe42ac20f0ab140e6822 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 8 May 2019 23:52:44 +0900 Subject: [PATCH 22/34] Remove unused variable --- .../UserInterface/TestCaseUpdateableBeatmapBackgroundSprite.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestCaseUpdateableBeatmapBackgroundSprite.cs b/osu.Game.Tests/Visual/UserInterface/TestCaseUpdateableBeatmapBackgroundSprite.cs index e9c5bc929d..f57464e7c3 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestCaseUpdateableBeatmapBackgroundSprite.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestCaseUpdateableBeatmapBackgroundSprite.cs @@ -132,8 +132,6 @@ namespace osu.Game.Tests.Visual.UserInterface var loadedBackgrounds = backgrounds.Where(b => b.ContentLoaded); - int initialLoadCount = 0; - AddUntilStep("some loaded", () => (initialLoadCount = loadedBackgrounds.Count()) > 0); AddStep("scroll to bottom", () => scrollContainer.ScrollToEnd()); AddUntilStep("all unloaded", () => !loadedBackgrounds.Any()); From 5dbf57046e894a965ebe86725e634cb4b12ee191 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 9 May 2019 10:38:22 +0900 Subject: [PATCH 23/34] Fix regression from removing unused variable --- .../UserInterface/TestCaseUpdateableBeatmapBackgroundSprite.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestCaseUpdateableBeatmapBackgroundSprite.cs b/osu.Game.Tests/Visual/UserInterface/TestCaseUpdateableBeatmapBackgroundSprite.cs index f57464e7c3..6185fbd34e 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestCaseUpdateableBeatmapBackgroundSprite.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestCaseUpdateableBeatmapBackgroundSprite.cs @@ -132,7 +132,7 @@ namespace osu.Game.Tests.Visual.UserInterface var loadedBackgrounds = backgrounds.Where(b => b.ContentLoaded); - AddUntilStep("some loaded", () => (initialLoadCount = loadedBackgrounds.Count()) > 0); + AddUntilStep("some loaded", () => loadedBackgrounds.Any()); AddStep("scroll to bottom", () => scrollContainer.ScrollToEnd()); AddUntilStep("all unloaded", () => !loadedBackgrounds.Any()); } From 9457a6128eb2a31c4863e52a80a4337b9317020c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 9 May 2019 10:57:55 +0900 Subject: [PATCH 24/34] Fix game pausing when made inactive while watching a replay --- osu.Game/Screens/Play/HUDOverlay.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index 3c1b33297a..f8e092c8b1 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -129,6 +129,7 @@ namespace osu.Game.Screens.Play private void replayLoadedValueChanged(ValueChangedEvent e) { PlayerSettingsOverlay.ReplayLoaded = e.NewValue; + HoldToQuit.PauseOnFocusLost = !e.NewValue; if (e.NewValue) { From 5b1ae1210ad01387a7ddf7996e17bfad1a455d95 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 9 May 2019 11:31:40 +0900 Subject: [PATCH 25/34] Add more asserts to pause test in an attempt to track down intermittent test failures --- osu.Game.Tests/Visual/Gameplay/TestCasePause.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs b/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs index b9c7fd14bd..14be10b65c 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs @@ -157,6 +157,8 @@ namespace osu.Game.Tests.Visual.Gameplay private void confirmPaused() { confirmClockRunning(false); + AddAssert("player not exited", () => Player.IsCurrentScreen()); + AddAssert("player not failed", () => !Player.HasFailed); AddAssert("pause overlay shown", () => Player.PauseOverlayVisible); } From d625f3c104df120ffeed7ed8f9a1203fb2504e90 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 9 May 2019 13:16:56 +0900 Subject: [PATCH 26/34] Private method --- .../Compose/Components/Timeline/ZoomableScrollContainer.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs index ee6e29c92e..eb78e827f0 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs @@ -92,6 +92,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline } } + private void updateZoomedContentWidth() => zoomedContent.Width = DrawWidth * currentZoom; + protected override bool OnScroll(ScrollEvent e) { if (e.IsPrecise) @@ -107,7 +109,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline base.LoadComplete(); // This width only gets updated on the application of a transform, so this needs to be initialized here. - zoomedContent.Width = DrawWidth * currentZoom; + updateZoomedContentWidth(); } private float zoomTarget = 1; @@ -171,7 +173,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline d.currentZoom = newZoom; - d.zoomedContent.Width = d.DrawWidth * d.currentZoom; + d.updateZoomedContentWidth(); // Temporarily here to make sure ScrollTo gets the correct DrawSize for scrollable area. // TODO: Make sure draw size gets invalidated properly on the framework side, and remove this once it is. d.Invalidate(Invalidation.DrawSize); From c69d813745ae55b66548d82e291215a1024ebe9f Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 9 May 2019 13:32:18 +0900 Subject: [PATCH 27/34] Fix bindable potentially being set from background thread --- osu.Game/Online/API/APIAccess.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index d62b53088a..70cd21b2db 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -352,10 +352,12 @@ namespace osu.Game.Online.API public void Logout() { flushQueue(); + password = null; authentication.Clear(); - LocalUser.Value = createGuestUser(); State = APIState.Offline; + + Schedule(() => LocalUser.Value = createGuestUser()); } private static User createGuestUser() => new GuestUser(); From 3fed165b749221af2c019885168030b1b4654f13 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 9 May 2019 13:33:18 +0900 Subject: [PATCH 28/34] Cleanup some schedules --- osu.Game/Online/API/APIAccess.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index 70cd21b2db..08bb9472c1 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -77,13 +77,13 @@ namespace osu.Game.Online.API /// public void Register(IOnlineComponent component) { - Scheduler.Add(delegate { components.Add(component); }); + Schedule(() => components.Add(component)); component.APIStateChanged(this, state); } public void Unregister(IOnlineComponent component) { - Scheduler.Add(delegate { components.Remove(component); }); + Schedule(() => components.Remove(component)); } public string AccessToken => authentication.RequestAccessToken(); @@ -274,7 +274,7 @@ namespace osu.Game.Online.API state = value; log.Add($@"We just went {state}!"); - Scheduler.Add(delegate + Schedule(() => { components.ForEach(c => c.APIStateChanged(this, state)); OnStateChange?.Invoke(oldState, state); From 35624a5d1cd5969cf12770bda40dab3a5343c9c7 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 9 May 2019 13:42:04 +0900 Subject: [PATCH 29/34] Invert scheduling order --- osu.Game/Online/API/APIAccess.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index 08bb9472c1..594bc1e3ca 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -355,9 +355,11 @@ namespace osu.Game.Online.API password = null; authentication.Clear(); - State = APIState.Offline; + // Scheduled prior to state change such that the state changed event is invoked with the correct user present Schedule(() => LocalUser.Value = createGuestUser()); + + State = APIState.Offline; } private static User createGuestUser() => new GuestUser(); From 5c6b4d923f04d63eaaf7a7c0978ba0bbf95cf977 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 9 May 2019 13:53:53 +0900 Subject: [PATCH 30/34] Reorder methods --- .../Timeline/ZoomableScrollContainer.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs index eb78e827f0..829437d599 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs @@ -92,7 +92,13 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline } } - private void updateZoomedContentWidth() => zoomedContent.Width = DrawWidth * currentZoom; + protected override void LoadComplete() + { + base.LoadComplete(); + + // This width only gets updated on the application of a transform, so this needs to be initialized here. + updateZoomedContentWidth(); + } protected override bool OnScroll(ScrollEvent e) { @@ -104,13 +110,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline return true; } - protected override void LoadComplete() - { - base.LoadComplete(); - - // This width only gets updated on the application of a transform, so this needs to be initialized here. - updateZoomedContentWidth(); - } + private void updateZoomedContentWidth() => zoomedContent.Width = DrawWidth * currentZoom; private float zoomTarget = 1; From 39fb5712f1a331720014ee5f8a62ca2261ba4741 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 9 May 2019 15:31:37 +0900 Subject: [PATCH 31/34] Only combo-incrementing results add to result count --- osu.Game/Rulesets/Scoring/ScoreProcessor.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs index 0ca92a8861..6beb393367 100644 --- a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs +++ b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs @@ -314,11 +314,11 @@ namespace osu.Game.Rulesets.Scoring JudgedHits++; - if (result.Type != HitResult.None) - scoreResultCounts[result.Type] = scoreResultCounts.GetOrDefault(result.Type) + 1; - if (result.Judgement.AffectsCombo) { + if (result.Type != HitResult.None) + scoreResultCounts[result.Type] = scoreResultCounts.GetOrDefault(result.Type) + 1; + switch (result.Type) { case HitResult.None: From b0e34d86d5016cb069a388dfe187decd0502a890 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 9 May 2019 16:16:20 +0900 Subject: [PATCH 32/34] Subtract a result from count if its been reverted --- osu.Game/Rulesets/Scoring/ScoreProcessor.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs index 6beb393367..2944b784ad 100644 --- a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs +++ b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs @@ -360,6 +360,12 @@ namespace osu.Game.Rulesets.Scoring JudgedHits--; + if (result.Judgement.AffectsCombo) + { + if (result.Type != HitResult.None) + scoreResultCounts[result.Type] = scoreResultCounts.GetOrDefault(result.Type) - 1; + } + if (result.Judgement.IsBonus) { if (result.IsHit) From 9e0af723cca8acca9bb4fad33e60da8ed5cadae8 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 9 May 2019 18:56:19 +0900 Subject: [PATCH 33/34] Split out affectscombo change --- osu.Game/Rulesets/Scoring/ScoreProcessor.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs index 2944b784ad..4adc29853d 100644 --- a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs +++ b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs @@ -314,11 +314,11 @@ namespace osu.Game.Rulesets.Scoring JudgedHits++; + if (result.Type != HitResult.None) + scoreResultCounts[result.Type] = scoreResultCounts.GetOrDefault(result.Type) + 1; + if (result.Judgement.AffectsCombo) { - if (result.Type != HitResult.None) - scoreResultCounts[result.Type] = scoreResultCounts.GetOrDefault(result.Type) + 1; - switch (result.Type) { case HitResult.None: From 5c096cbc910172aab8948576912acab0da033593 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 9 May 2019 18:59:00 +0900 Subject: [PATCH 34/34] Revert mirroring condition too --- osu.Game/Rulesets/Scoring/ScoreProcessor.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs index 4adc29853d..cf42a70640 100644 --- a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs +++ b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs @@ -360,11 +360,8 @@ namespace osu.Game.Rulesets.Scoring JudgedHits--; - if (result.Judgement.AffectsCombo) - { - if (result.Type != HitResult.None) - scoreResultCounts[result.Type] = scoreResultCounts.GetOrDefault(result.Type) - 1; - } + if (result.Type != HitResult.None) + scoreResultCounts[result.Type] = scoreResultCounts.GetOrDefault(result.Type) - 1; if (result.Judgement.IsBonus) {