From be977e25414cbd443f51f079347528d64b83de2d Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Mon, 16 Jul 2018 23:50:22 +0200 Subject: [PATCH 001/375] Header1 --- osu.Game.Tests/Visual/TestCaseChangelog.cs | 34 ++++ .../Visual/TestCaseTextBadgePair.cs | 76 +++++++ .../Overlays/Changelog/ChangelogHeader.cs | 190 ++++++++++++++++++ .../Overlays/Changelog/Header/LineBadge.cs | 35 ++++ .../Changelog/Header/TextBadgePair.cs | 113 +++++++++++ .../Changelog/Header/TextBadgePairListing.cs | 58 ++++++ .../Changelog/Header/TextBadgePairRelease.cs | 42 ++++ osu.Game/Overlays/ChangelogOverlay.cs | 87 ++++++++ 8 files changed, 635 insertions(+) create mode 100644 osu.Game.Tests/Visual/TestCaseChangelog.cs create mode 100644 osu.Game.Tests/Visual/TestCaseTextBadgePair.cs create mode 100644 osu.Game/Overlays/Changelog/ChangelogHeader.cs create mode 100644 osu.Game/Overlays/Changelog/Header/LineBadge.cs create mode 100644 osu.Game/Overlays/Changelog/Header/TextBadgePair.cs create mode 100644 osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs create mode 100644 osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs create mode 100644 osu.Game/Overlays/ChangelogOverlay.cs diff --git a/osu.Game.Tests/Visual/TestCaseChangelog.cs b/osu.Game.Tests/Visual/TestCaseChangelog.cs new file mode 100644 index 0000000000..688cf2b075 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseChangelog.cs @@ -0,0 +1,34 @@ +// Copyright(c) 2007-2018 ppy Pty Ltd. +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + + +using NUnit.Framework; +using osu.Game.Overlays; + +namespace osu.Game.Tests.Visual +{ + [TestFixture] + public class TestCaseChangelog : OsuTestCase + { + private ChangelogOverlay changelog; + + protected override void LoadComplete() + { + base.LoadComplete(); + + Add(changelog = new ChangelogOverlay()); + changelog.ToggleVisibility(); + + //AddStep(@"toggle", changelog.ToggleVisibility); + AddStep(@"toggle text 1", () => changelog.header.ActivateRelease("Release 20180626.1")); + AddStep(@"toggle text 2", () => changelog.header.ActivateRelease("Lazer 2018.713.1")); + AddStep(@"toggle text 3", () => changelog.header.ActivateRelease("Beta 20180626")); + AddStep(@"go to listing", changelog.header.ActivateListing); + } + + public TestCaseChangelog() + { + + } + } +} diff --git a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs b/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs new file mode 100644 index 0000000000..effce3d471 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs @@ -0,0 +1,76 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using NUnit.Framework; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Overlays.Changelog.Header; + +namespace osu.Game.Tests.Visual +{ + [TestFixture] + public class TestCaseTextBadgePair : OsuTestCase + { + private readonly Container container; + private readonly Box bottomLine; + private readonly TextBadgePair textBadgePair; + + public TestCaseTextBadgePair() + { + + Add(container = new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new OpenTK.Vector2(300, 40), + Children = new Drawable[] + { + new Box + { + Colour = Color4.Gray, + RelativeSizeAxes = Axes.Both, + }, + bottomLine = new Box // purple line + { + Colour = Color4.Purple, + RelativeSizeAxes = Axes.X, + Height = 3, + Anchor = Anchor.BottomLeft, + Origin = Anchor.CentreLeft, + }, + textBadgePair = new TextBadgePair(Color4.White, "testing") + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + } + }, + }); + + AddStep(@"deactivate", () => textBadgePair.Deactivate()); + AddStep(@"activate", () => textBadgePair.Activate()); + AddStep(@"purple text", () => textBadgePair.SetTextColor(Color4.Purple, 100)); + AddStep(@"white text", () => textBadgePair.SetTextColor(Color4.White, 100)); + AddStep(@"purple badge", () => textBadgePair.SetBadgeColor(Color4.Purple, 100)); + AddStep(@"white badge", () => textBadgePair.SetBadgeColor(Color4.White, 100)); + AddStep(@"hide text", () => textBadgePair.HideText(250)); + AddStep(@"show text", () => textBadgePair.ShowText(250)); + } + + //[BackgroundDependencyLoader] + //private void load(OsuColour colours) + //{ + + //} + + //private enum BreadcrumbTab + //{ + // Click, + // The, + // Circles, + //} + } +} diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs new file mode 100644 index 0000000000..c8fff5bd6b --- /dev/null +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -0,0 +1,190 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; +using osu.Game.Graphics.Backgrounds; +using osu.Game.Graphics.Sprites; +using osu.Game.Overlays.Changelog.Header; +using System; +using System.Collections.Generic; +using System.Text; + +namespace osu.Game.Overlays.Changelog +{ + public class ChangelogHeader : Container + { + private readonly Container coverContainer; + + private Color4 purple = new Color4(191, 4, 255, 255); + private readonly Sprite coverImage; + private readonly Sprite headerBadge; //50x50, margin-right: 20 + private readonly FillFlowContainer headerTextContainer; + private readonly OsuSpriteText title, titleStream; + private readonly TextBadgePairListing listing; + private readonly TextBadgePairRelease releaseStream; + private readonly FillFlowContainer breadcrumbContainer; + + private const float cover_height = 310; + private const float title_height = 50; + private const float icon_size = 50; + private const float icon_margin = 20; + private const float version_height = 40; + + public ChangelogHeader() + { + RelativeSizeAxes = Axes.X; + Height = cover_height + 5; // 5 is for the "badge" that sticks a bit out of the bottom + Masking = true; // is masking necessary? since I see it nearly everywhere + Children = new Drawable[] + { + coverContainer = new Container + { + RelativeSizeAxes = Axes.X, + Height = cover_height, + Children = new Drawable[] + { + coverImage = new Sprite + { + RelativeSizeAxes = Axes.Both, + Size = new OpenTK.Vector2(1), + }, + new Container // cover + { + RelativeSizeAxes = Axes.X, + Height = cover_height, + Children = new Drawable[] + { + new Container // this is the line badge-Changelog-Stream + { + Height = title_height, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Y = -version_height, + Children = new Drawable[] + { + new CircularContainer // a purple circle + { + X = icon_margin, + Masking = true, + BorderColour = purple, + BorderThickness = 3, + MaskingSmoothness = 1, + Size = new OpenTK.Vector2(50), + Children = new Drawable[] + { + headerBadge = new Sprite + { + Size = new OpenTK.Vector2(0.8f), + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + }, + new Box // this ensures the purple circle doesn't disappear..? + { + RelativeSizeAxes = Axes.Both, + Size = new OpenTK.Vector2(1), + AlwaysPresent = true, + Colour = Color4.Transparent, + } + } + }, + headerTextContainer = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + X = icon_size + icon_margin * 2, + Children = new Drawable[] + { + title = new OsuSpriteText + { + Text = "Changelog ", + TextSize = 30, + }, + titleStream = new OsuSpriteText + { + Text = "Listing", + TextSize = 30, + Colour = purple, + }, + } + } + } + }, + breadcrumbContainer = new FillFlowContainer // Listing > Lazer 2018.713.1 + { + X = 2 * icon_margin + icon_size - 10, + Height = version_height, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Direction = FillDirection.Horizontal, + Children = new Drawable[] + { + listing = new TextBadgePairListing(purple), + releaseStream = new TextBadgePairRelease(purple, "Lazer") + }, + }, + new Box // purple line + { + Colour = purple, + RelativeSizeAxes = Axes.X, + Height = 3, + Anchor = Anchor.BottomLeft, + Origin = Anchor.CentreLeft, + }, + } + } + } + } + }; + breadcrumbContainer.OnLoadComplete = d => + { + releaseStream.OnActivation = listing.Deactivate; + listing.OnActivation = releaseStream.Deactivate; + }; + listing.text.OnUpdate = d => + { + listing.lineBadge.ResizeWidthTo(listing.text.DrawWidth); + }; + } + + public void ListingActivation() + { + releaseStream.Deactivate(); + } + + public void ReleaseActivation() + { + listing.Deactivate(); + } + + public void ActivateRelease(string displayText) + { + releaseStream.Activate(displayText); + titleStream.Text = displayText; + } + + public void ActivateListing() + { + listing.Activate(); + } + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + // should be added to osu-resources? + // headerBadge.Texture = textures.Get(@"https://osu.ppy.sh/images/icons/changelog.svg"); // this is not working + headerBadge.Texture = textures.Get(@"https://i.imgur.com/HQM3Vhp.png"); + coverImage.Texture = textures.Get(@"https://osu.ppy.sh/images/headers/changelog.jpg"); + } + } +} diff --git a/osu.Game/Overlays/Changelog/Header/LineBadge.cs b/osu.Game/Overlays/Changelog/Header/LineBadge.cs new file mode 100644 index 0000000000..c3b4ecc187 --- /dev/null +++ b/osu.Game/Overlays/Changelog/Header/LineBadge.cs @@ -0,0 +1,35 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Input; +using osu.Game.Graphics.Containers; + +namespace osu.Game.Overlays.Changelog.Header +{ + public class LineBadge : Circle + { + private const float transition_duration = 100; + private const float uncollapsed_height = 10; + public float UncollapsedHeight => uncollapsed_height; + public float TransitionDuration => transition_duration; + private bool isCollapsed; + public bool IsCollapsed + { + get { return isCollapsed; } + set + { + isCollapsed = value; + this.ResizeHeightTo(value ? 1 : 10, transition_duration); + } + } + + public LineBadge(bool startCollapsed = false) + { + IsCollapsed = startCollapsed; + Anchor = Anchor.BottomCentre; + Origin = Anchor.Centre; + } + } +} diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs new file mode 100644 index 0000000000..01326938eb --- /dev/null +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -0,0 +1,113 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input; +using osu.Game.Overlays.Changelog; +using System; + +namespace osu.Game.Overlays.Changelog.Header +{ + + public class TextBadgePair : ClickableContainer + { + // When in listing, "Listing" is white and doesn't change on mouseover + // when release stream is chosen, "Listing" turns purple, and lighter font + // on mouseover, the badge scales up + // Version name steals "Listing"'s styling + + public SpriteText text; + public LineBadge lineBadge; + + public Action OnActivation; + public Action OnDeactivation; + + public void SetTextColor(ColourInfo newColour, double duration = 0, Easing easing = Easing.None) + { + text.FadeColour(newColour, duration, easing); + } + + public void SetBadgeColor(ColourInfo newColour, double duration = 0, Easing easing = Easing.None) + { + lineBadge.FadeColour(newColour, duration, easing); + } + + public void HideText(double duration = 0, Easing easing = Easing.InOutCubic) + { + lineBadge.IsCollapsed = true; + text.MoveToY(20, duration, easing) + .FadeOut(duration, easing); + } + + public void ShowText(double duration = 0, Easing easing = Easing.InOutCubic) + { + lineBadge.IsCollapsed = false; + text.MoveToY(0, duration, easing) + .FadeIn(duration, easing) + .Finally(d => lineBadge.ResizeWidthTo(text.DrawWidth, 250)); + } + + public void ChangeText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) + { + lineBadge.IsCollapsed = true; + text.MoveToY(20, duration, easing) + .FadeOut(duration, easing) + .Finally(d => + { + lineBadge.ResizeWidthTo(0); + if (!string.IsNullOrEmpty(displayText)) text.Text = displayText; + text.MoveToY(0, duration, easing) + .FadeIn(duration, easing) + .OnComplete(dd => { + lineBadge.ResizeWidthTo(text.DrawWidth); + lineBadge.IsCollapsed = false; + }); + }); + } + + public TextBadgePair(ColourInfo badgeColour, string displayText = "Listing") + { + AutoSizeAxes = Axes.X; + RelativeSizeAxes = Axes.Y; + Children = new Drawable[] + { + text = new SpriteText + { + TextSize = 20, + Text = displayText, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + AlwaysPresent = true, + Margin = new MarginPadding() + { + Top = 5, + Bottom = 15, + Left = 10, + Right = 10, + } + }, + lineBadge = new LineBadge + { + Colour = badgeColour, + } + }; + } + + public virtual void Deactivate() + { + lineBadge.IsCollapsed = true; + text.Font = "Exo2.0-Regular"; + } + + public virtual void Activate() + { + lineBadge.IsCollapsed = false; + text.Font = "Exo2.0-Bold"; + } + } +} diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs new file mode 100644 index 0000000000..569f5ff2f5 --- /dev/null +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs @@ -0,0 +1,58 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Input; +using System; + +namespace osu.Game.Overlays.Changelog.Header +{ + public class TextBadgePairListing : TextBadgePair + { + private TextBadgePairRelease releaseBadge; + private ColourInfo badgeColour; + + public TextBadgePairListing(ColourInfo badgeColour) : base(badgeColour, "Listing") + { + this.releaseBadge = releaseBadge; + this.badgeColour = badgeColour; + text.Font = "Exo2.0-Bold"; + } + + public override void Activate() + { + lineBadge.IsCollapsed = false; + text.Font = "Exo2.0-Bold"; + SetTextColor(Color4.White, 100); + OnActivation?.Invoke(); + } + + public override void Deactivate() + { + lineBadge.IsCollapsed = true; + //text.Font = "Exo2.0-Regular"; // commented out since it makes bad resize-jumping + SetTextColor(badgeColour, 100); + OnDeactivation?.Invoke(); + } + + protected override bool OnClick(InputState state) + { + Activate(); + return base.OnClick(state); + } + + protected override bool OnHover(InputState state) + { + lineBadge.ResizeHeightTo(lineBadge.UncollapsedHeight, lineBadge.TransitionDuration); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + if (lineBadge.IsCollapsed) lineBadge.ResizeHeightTo(1, lineBadge.TransitionDuration); + base.OnHoverLost(state); + } + } +} diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs new file mode 100644 index 0000000000..318e8a4c73 --- /dev/null +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs @@ -0,0 +1,42 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Input; + +namespace osu.Game.Overlays.Changelog.Header +{ + public class TextBadgePairRelease : TextBadgePair + { + private TextBadgePairListing listingBadge; + + public TextBadgePairRelease(ColourInfo badgeColour, string displayText) : base(badgeColour, displayText) + { + this.listingBadge = listingBadge; + text.Font = "Exo2.0-Bold"; + text.Y = 20; + text.Alpha = 0; + } + + public void SetText(string displayText) + { + text.Text = displayText; + } + + public void Activate(string displayText = null) + { + ClearTransforms(); + if (text.IsPresent) ChangeText(250, displayText); + else ShowText(); + OnActivation?.Invoke(); + } + + public override void Deactivate() + { + FinishTransforms(true); + HideText(250); + OnDeactivation?.Invoke(); + } + } +} diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs new file mode 100644 index 0000000000..f6a138e603 --- /dev/null +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -0,0 +1,87 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osu.Game.Overlays.Changelog; +using System; +using System.Collections.Generic; +using System.Text; + +namespace osu.Game.Overlays +{ + public class ChangelogOverlay : WaveOverlayContainer + { + private readonly ScrollContainer scroll; + + public ChangelogHeader header; + + public ChangelogOverlay() + { + Waves.FirstWaveColour = OsuColour.Gray(0.4f); + Waves.SecondWaveColour = OsuColour.Gray(0.3f); + Waves.ThirdWaveColour = OsuColour.Gray(0.2f); + Waves.FourthWaveColour = OsuColour.Gray(0.1f); + + Anchor = Anchor.TopCentre; + Origin = Anchor.TopCentre; + RelativeSizeAxes = Axes.Both; + Width = 0.85f; + + Masking = true; + EdgeEffect = new EdgeEffectParameters + { + Colour = Color4.Black.Opacity(0), + Type = EdgeEffectType.Shadow, + Radius = 3, + Offset = new Vector2(0f, 1f), + }; + + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = new Color4(20, 18, 23, 255) + }, + scroll = new ScrollContainer + { + RelativeSizeAxes = Axes.Both, + ScrollbarVisible = false, + Child = new ReverseChildIDFillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + header = new ChangelogHeader(), + }, + }, + }, + }; + } + + // receive input outside our bounds so we can trigger a close event on ourselves. + public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; + + protected override void PopIn() + { + base.PopIn(); + FadeEdgeEffectTo(0.25f, WaveContainer.APPEAR_DURATION, Easing.In); + } + + protected override void PopOut() + { + base.PopOut(); + FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out); + } + } +} From b4bb97fba89a577af78f38302e9d7f5925f6e820 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Tue, 17 Jul 2018 15:01:53 +0200 Subject: [PATCH 002/375] Header2 --- osu.Game.Tests/Visual/TestCaseChangelog.cs | 12 ++- .../Visual/TestCaseTextBadgePair.cs | 8 +- .../Input/Bindings/GlobalActionContainer.cs | 2 + osu.Game/OsuGame.cs | 11 ++- .../Overlays/Changelog/ChangelogHeader.cs | 81 +++++++++++-------- .../Overlays/Changelog/Header/LineBadge.cs | 5 ++ .../Changelog/Header/TextBadgePair.cs | 61 ++++++++------ .../Changelog/Header/TextBadgePairListing.cs | 14 ++-- .../Changelog/Header/TextBadgePairRelease.cs | 7 +- .../Toolbar/ToolbarChangelogButton.cs | 22 +++++ 10 files changed, 146 insertions(+), 77 deletions(-) create mode 100644 osu.Game/Overlays/Toolbar/ToolbarChangelogButton.cs diff --git a/osu.Game.Tests/Visual/TestCaseChangelog.cs b/osu.Game.Tests/Visual/TestCaseChangelog.cs index 688cf2b075..28c43b5153 100644 --- a/osu.Game.Tests/Visual/TestCaseChangelog.cs +++ b/osu.Game.Tests/Visual/TestCaseChangelog.cs @@ -17,13 +17,11 @@ namespace osu.Game.Tests.Visual base.LoadComplete(); Add(changelog = new ChangelogOverlay()); - changelog.ToggleVisibility(); - - //AddStep(@"toggle", changelog.ToggleVisibility); - AddStep(@"toggle text 1", () => changelog.header.ActivateRelease("Release 20180626.1")); - AddStep(@"toggle text 2", () => changelog.header.ActivateRelease("Lazer 2018.713.1")); - AddStep(@"toggle text 3", () => changelog.header.ActivateRelease("Beta 20180626")); - AddStep(@"go to listing", changelog.header.ActivateListing); + + AddStep(@"Show", changelog.Show); + AddStep(@"Stable Release Stream", () => changelog.header.ShowReleaseStream("Stable", "Stable 20180626.1")); + AddStep(@"Lazer Release Stream", () => changelog.header.ShowReleaseStream("Lazer", "Lazer 2018.713.1")); + AddStep(@"Listing", changelog.header.ActivateListing); } public TestCaseChangelog() diff --git a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs b/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs index effce3d471..659bcb26ef 100644 --- a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs +++ b/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs @@ -52,10 +52,10 @@ namespace osu.Game.Tests.Visual AddStep(@"deactivate", () => textBadgePair.Deactivate()); AddStep(@"activate", () => textBadgePair.Activate()); - AddStep(@"purple text", () => textBadgePair.SetTextColor(Color4.Purple, 100)); - AddStep(@"white text", () => textBadgePair.SetTextColor(Color4.White, 100)); - AddStep(@"purple badge", () => textBadgePair.SetBadgeColor(Color4.Purple, 100)); - AddStep(@"white badge", () => textBadgePair.SetBadgeColor(Color4.White, 100)); + AddStep(@"purple text", () => textBadgePair.SetTextColour(Color4.Purple, 100)); + AddStep(@"white text", () => textBadgePair.SetTextColour(Color4.White, 100)); + AddStep(@"purple badge", () => textBadgePair.SetBadgeColour(Color4.Purple, 100)); + AddStep(@"white badge", () => textBadgePair.SetBadgeColour(Color4.White, 100)); AddStep(@"hide text", () => textBadgePair.HideText(250)); AddStep(@"show text", () => textBadgePair.ShowText(250)); } diff --git a/osu.Game/Input/Bindings/GlobalActionContainer.cs b/osu.Game/Input/Bindings/GlobalActionContainer.cs index b21deff509..00857b9c9b 100644 --- a/osu.Game/Input/Bindings/GlobalActionContainer.cs +++ b/osu.Game/Input/Bindings/GlobalActionContainer.cs @@ -63,6 +63,8 @@ namespace osu.Game.Input.Bindings ToggleChat, [Description("Toggle social overlay")] ToggleSocial, + [Description("Toggle changelog")] + ToggleChangelog, [Description("Reset input settings")] ResetInputSettings, [Description("Toggle toolbar")] diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 557b6e4469..3eb4faf6aa 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -53,6 +53,8 @@ namespace osu.Game private DialogOverlay dialogOverlay; + private ChangelogOverlay changelog; + private DirectOverlay direct; private SocialOverlay social; @@ -110,6 +112,8 @@ namespace osu.Game public void ToggleDirect() => direct.ToggleVisibility(); + public void ToggleChangelog() => changelog.ToggleVisibility(); + /// /// Close all game-wide overlays. /// @@ -281,6 +285,7 @@ namespace osu.Game loadComponentSingleFile(screenshotManager, Add); //overlay elements + loadComponentSingleFile(changelog = new ChangelogOverlay { Depth = -1 }, mainContent.Add); loadComponentSingleFile(direct = new DirectOverlay { Depth = -1 }, mainContent.Add); loadComponentSingleFile(social = new SocialOverlay { Depth = -1 }, mainContent.Add); loadComponentSingleFile(chat = new ChatOverlay { Depth = -1 }, mainContent.Add); @@ -315,6 +320,7 @@ namespace osu.Game dependencies.Cache(settings); dependencies.Cache(onscreenDisplay); dependencies.Cache(social); + dependencies.Cache(changelog); dependencies.Cache(direct); dependencies.Cache(chat); dependencies.Cache(userProfile); @@ -349,7 +355,7 @@ namespace osu.Game } // ensure only one of these overlays are open at once. - var singleDisplayOverlays = new OverlayContainer[] { chat, social, direct }; + var singleDisplayOverlays = new OverlayContainer[] { chat, social, direct, changelog }; overlays.AddRange(singleDisplayOverlays); foreach (var overlay in singleDisplayOverlays) @@ -459,6 +465,9 @@ namespace osu.Game case GlobalAction.ToggleSocial: social.ToggleVisibility(); return true; + case GlobalAction.ToggleChangelog: + changelog.ToggleVisibility(); + return true; case GlobalAction.ResetInputSettings: var sensitivity = frameworkConfig.GetBindable(FrameworkSetting.CursorSensitivity); diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index c8fff5bd6b..09812f784b 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; @@ -10,6 +11,7 @@ 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.Backgrounds; using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Changelog.Header; @@ -55,13 +57,16 @@ namespace osu.Game.Overlays.Changelog { RelativeSizeAxes = Axes.Both, Size = new OpenTK.Vector2(1), + FillMode = FillMode.Fill, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, }, - new Container // cover - { - RelativeSizeAxes = Axes.X, - Height = cover_height, - Children = new Drawable[] - { + //new Container + //{ + // RelativeSizeAxes = Axes.X, + // Height = cover_height, + // Children = new Drawable[] + // { new Container // this is the line badge-Changelog-Stream { Height = title_height, @@ -108,12 +113,14 @@ namespace osu.Game.Overlays.Changelog title = new OsuSpriteText { Text = "Changelog ", - TextSize = 30, + Font = @"Exo2.0-Light", + TextSize = 38, // web: 30 }, titleStream = new OsuSpriteText { Text = "Listing", - TextSize = 30, + TextSize = 38, // web: 30 + Font = @"Exo2.0-Light", Colour = purple, }, } @@ -122,7 +129,7 @@ namespace osu.Game.Overlays.Changelog }, breadcrumbContainer = new FillFlowContainer // Listing > Lazer 2018.713.1 { - X = 2 * icon_margin + icon_size - 10, + X = 2 * icon_margin + icon_size - 8, // for some reason off by 3px Height = version_height, Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, @@ -130,6 +137,21 @@ namespace osu.Game.Overlays.Changelog Children = new Drawable[] { listing = new TextBadgePairListing(purple), + new SpriteIcon + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Size = new Vector2(7), + Colour = OsuColour.FromHex(@"bf04ff"), + Icon = FontAwesome.fa_chevron_right, + Margin = new MarginPadding() + { + Top = 8, + Left = 5, + Right = 5, + Bottom = 15, + }, + }, releaseStream = new TextBadgePairRelease(purple, "Lazer") }, }, @@ -141,42 +163,37 @@ namespace osu.Game.Overlays.Changelog Anchor = Anchor.BottomLeft, Origin = Anchor.CentreLeft, }, - } - } + // } + //} } } }; - breadcrumbContainer.OnLoadComplete = d => + + // is this a bad way to do this? + OnLoadComplete = d => { releaseStream.OnActivation = listing.Deactivate; - listing.OnActivation = releaseStream.Deactivate; - }; - listing.text.OnUpdate = d => - { - listing.lineBadge.ResizeWidthTo(listing.text.DrawWidth); + listing.OnActivation = () => + { + releaseStream.Deactivate(); + ChangeHeaderText("Listing"); + }; }; } - - public void ListingActivation() + + public void ShowReleaseStream(string headerText, string breadcrumbText) { - releaseStream.Deactivate(); + releaseStream.Activate(breadcrumbText); + ChangeHeaderText(headerText); } - public void ReleaseActivation() + private void ChangeHeaderText(string headerText) { - listing.Deactivate(); + titleStream.Text = headerText; + titleStream.FlashColour(Color4.White, 500, Easing.OutQuad); } - public void ActivateRelease(string displayText) - { - releaseStream.Activate(displayText); - titleStream.Text = displayText; - } - - public void ActivateListing() - { - listing.Activate(); - } + public void ActivateListing() => listing.Activate(); [BackgroundDependencyLoader] private void load(TextureStore textures) diff --git a/osu.Game/Overlays/Changelog/Header/LineBadge.cs b/osu.Game/Overlays/Changelog/Header/LineBadge.cs index c3b4ecc187..f321939a96 100644 --- a/osu.Game/Overlays/Changelog/Header/LineBadge.cs +++ b/osu.Game/Overlays/Changelog/Header/LineBadge.cs @@ -30,6 +30,11 @@ namespace osu.Game.Overlays.Changelog.Header IsCollapsed = startCollapsed; Anchor = Anchor.BottomCentre; Origin = Anchor.Centre; + Margin = new MarginPadding() + { + Left = 10, + Right = 10, + }; } } } diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs index 01326938eb..5d1018e504 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK; using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; @@ -8,6 +9,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Input; +using osu.Game.Graphics; using osu.Game.Overlays.Changelog; using System; @@ -16,23 +18,18 @@ namespace osu.Game.Overlays.Changelog.Header public class TextBadgePair : ClickableContainer { - // When in listing, "Listing" is white and doesn't change on mouseover - // when release stream is chosen, "Listing" turns purple, and lighter font - // on mouseover, the badge scales up - // Version name steals "Listing"'s styling - - public SpriteText text; - public LineBadge lineBadge; + protected SpriteText text; + protected LineBadge lineBadge; public Action OnActivation; public Action OnDeactivation; - public void SetTextColor(ColourInfo newColour, double duration = 0, Easing easing = Easing.None) + public void SetTextColour(ColourInfo newColour, double duration = 0, Easing easing = Easing.None) { text.FadeColour(newColour, duration, easing); } - public void SetBadgeColor(ColourInfo newColour, double duration = 0, Easing easing = Easing.None) + public void SetBadgeColour(ColourInfo newColour, double duration = 0, Easing easing = Easing.None) { lineBadge.FadeColour(newColour, duration, easing); } @@ -44,30 +41,42 @@ namespace osu.Game.Overlays.Changelog.Header .FadeOut(duration, easing); } - public void ShowText(double duration = 0, Easing easing = Easing.InOutCubic) + public void ShowText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) { - lineBadge.IsCollapsed = false; + if (!string.IsNullOrEmpty(displayText)) text.Text = displayText; text.MoveToY(0, duration, easing) .FadeIn(duration, easing) - .Finally(d => lineBadge.ResizeWidthTo(text.DrawWidth, 250)); + .Finally(d => { + // waiting until text is drawn to use its DrawWidth + UpdateBadgeWidth(); + lineBadge.IsCollapsed = false; + }); } + /// + /// The duration of popping in and popping out not combined. + /// Full change takes double this time. public void ChangeText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) { lineBadge.IsCollapsed = true; text.MoveToY(20, duration, easing) .FadeOut(duration, easing) - .Finally(d => - { - lineBadge.ResizeWidthTo(0); - if (!string.IsNullOrEmpty(displayText)) text.Text = displayText; - text.MoveToY(0, duration, easing) - .FadeIn(duration, easing) - .OnComplete(dd => { - lineBadge.ResizeWidthTo(text.DrawWidth); - lineBadge.IsCollapsed = false; - }); + .Then() + .MoveToY(0, duration, easing) + .FadeIn(duration, easing) + .OnComplete(dd => { + UpdateBadgeWidth(); + lineBadge.IsCollapsed = false; }); + + // since using .finally/.oncomplete after first fadeout made the badge + // not hide sometimes in visual tests(because FinishTransforms()/CancelTransforms() + // didn't apply to transforms that come after the .finally), I'm using a scheduler here + Scheduler.AddDelayed(() => + { + lineBadge.ResizeWidthTo(0); // resizes when not visible + if (!string.IsNullOrEmpty(displayText)) text.Text = displayText; + }, duration); } public TextBadgePair(ColourInfo badgeColour, string displayText = "Listing") @@ -78,10 +87,10 @@ namespace osu.Game.Overlays.Changelog.Header { text = new SpriteText { - TextSize = 20, + TextSize = 21, // web is 16, but here it looks too small? Text = displayText, - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, AlwaysPresent = true, Margin = new MarginPadding() { @@ -109,5 +118,7 @@ namespace osu.Game.Overlays.Changelog.Header lineBadge.IsCollapsed = false; text.Font = "Exo2.0-Bold"; } + + public void UpdateBadgeWidth() => lineBadge.ResizeWidthTo(text.DrawWidth); } } diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs index 569f5ff2f5..f89ed8362e 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs @@ -11,29 +11,33 @@ namespace osu.Game.Overlays.Changelog.Header { public class TextBadgePairListing : TextBadgePair { - private TextBadgePairRelease releaseBadge; private ColourInfo badgeColour; public TextBadgePairListing(ColourInfo badgeColour) : base(badgeColour, "Listing") { - this.releaseBadge = releaseBadge; this.badgeColour = badgeColour; text.Font = "Exo2.0-Bold"; + text.Anchor = Anchor.TopCentre; + text.Origin = Anchor.TopCentre; + + // this doesn't work without the scheduler + // (because the text isn't yet fully drawn when it's loaded?) + text.OnLoadComplete = d => Scheduler.Add(UpdateBadgeWidth); } public override void Activate() { lineBadge.IsCollapsed = false; text.Font = "Exo2.0-Bold"; - SetTextColor(Color4.White, 100); + SetTextColour(Color4.White, 100); OnActivation?.Invoke(); } public override void Deactivate() { lineBadge.IsCollapsed = true; - //text.Font = "Exo2.0-Regular"; // commented out since it makes bad resize-jumping - SetTextColor(badgeColour, 100); + text.Font = "Exo2.0-Regular"; // commented out since it makes bad resize-jumping + SetTextColour(badgeColour, 100); OnDeactivation?.Invoke(); } diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs index 318e8a4c73..71e3b251c2 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs @@ -10,6 +10,7 @@ namespace osu.Game.Overlays.Changelog.Header public class TextBadgePairRelease : TextBadgePair { private TextBadgePairListing listingBadge; + private const float transition_duration = 125; public TextBadgePairRelease(ColourInfo badgeColour, string displayText) : base(badgeColour, displayText) { @@ -27,15 +28,15 @@ namespace osu.Game.Overlays.Changelog.Header public void Activate(string displayText = null) { ClearTransforms(); - if (text.IsPresent) ChangeText(250, displayText); - else ShowText(); + if (!lineBadge.IsCollapsed) ChangeText(transition_duration, displayText); + else ShowText(transition_duration, displayText); OnActivation?.Invoke(); } public override void Deactivate() { FinishTransforms(true); - HideText(250); + HideText(transition_duration); OnDeactivation?.Invoke(); } } diff --git a/osu.Game/Overlays/Toolbar/ToolbarChangelogButton.cs b/osu.Game/Overlays/Toolbar/ToolbarChangelogButton.cs new file mode 100644 index 0000000000..db4fd4ba07 --- /dev/null +++ b/osu.Game/Overlays/Toolbar/ToolbarChangelogButton.cs @@ -0,0 +1,22 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Game.Graphics; + +namespace osu.Game.Overlays.Toolbar +{ + public class ToolbarChangelogButton : ToolbarOverlayToggleButton + { + public ToolbarChangelogButton() + { + SetIcon(FontAwesome.fa_list); + } + + [BackgroundDependencyLoader(true)] + private void load(ChangelogOverlay changelog) + { + StateContainer = changelog; + } + } +} From 3c1e445fdfddd13e64a71dc60739e0af5f3ea1b8 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Tue, 17 Jul 2018 18:32:11 +0200 Subject: [PATCH 003/375] Header3 --- .../Visual/TestCaseTextBadgePair.cs | 16 +- .../Overlays/Changelog/ChangelogHeader.cs | 193 +++++++++--------- .../Overlays/Changelog/Header/LineBadge.cs | 14 +- .../Changelog/Header/TextBadgePair.cs | 15 +- .../Changelog/Header/TextBadgePairListing.cs | 1 - .../Changelog/Header/TextBadgePairRelease.cs | 10 +- osu.Game/Overlays/ChangelogOverlay.cs | 17 +- 7 files changed, 127 insertions(+), 139 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs b/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs index 659bcb26ef..9a4e481ff8 100644 --- a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs +++ b/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs @@ -3,11 +3,9 @@ using NUnit.Framework; using OpenTK.Graphics; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics; using osu.Game.Overlays.Changelog.Header; namespace osu.Game.Tests.Visual @@ -58,19 +56,7 @@ namespace osu.Game.Tests.Visual AddStep(@"white badge", () => textBadgePair.SetBadgeColour(Color4.White, 100)); AddStep(@"hide text", () => textBadgePair.HideText(250)); AddStep(@"show text", () => textBadgePair.ShowText(250)); + AddStep(@"change text", () => textBadgePair.ChangeText(250)); } - - //[BackgroundDependencyLoader] - //private void load(OsuColour colours) - //{ - - //} - - //private enum BreadcrumbTab - //{ - // Click, - // The, - // Circles, - //} } } diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 09812f784b..cc07ffeb18 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -4,20 +4,14 @@ using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Game.Graphics; -using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Changelog.Header; -using System; -using System.Collections.Generic; -using System.Text; namespace osu.Game.Overlays.Changelog { @@ -25,11 +19,12 @@ namespace osu.Game.Overlays.Changelog { private readonly Container coverContainer; - private Color4 purple = new Color4(191, 4, 255, 255); + protected Color4 purple = new Color4(191, 4, 255, 255); private readonly Sprite coverImage; private readonly Sprite headerBadge; //50x50, margin-right: 20 private readonly FillFlowContainer headerTextContainer; private readonly OsuSpriteText title, titleStream; + private readonly SpriteIcon chevron; private readonly TextBadgePairListing listing; private readonly TextBadgePairRelease releaseStream; private readonly FillFlowContainer breadcrumbContainer; @@ -61,110 +56,117 @@ namespace osu.Game.Overlays.Changelog Anchor = Anchor.Centre, Origin = Anchor.Centre, }, - //new Container - //{ - // RelativeSizeAxes = Axes.X, - // Height = cover_height, - // Children = new Drawable[] - // { - new Container // this is the line badge-Changelog-Stream + new Container // this is the line badge-Changelog-Stream + { + Height = title_height, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Y = -version_height, + Children = new Drawable[] + { + new CircularContainer // a purple circle { - Height = title_height, - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Y = -version_height, + X = icon_margin, + Masking = true, + BorderColour = purple, + BorderThickness = 3, + MaskingSmoothness = 1, + Size = new OpenTK.Vector2(50), Children = new Drawable[] { - new CircularContainer // a purple circle + headerBadge = new Sprite { - X = icon_margin, - Masking = true, - BorderColour = purple, - BorderThickness = 3, - MaskingSmoothness = 1, - Size = new OpenTK.Vector2(50), - Children = new Drawable[] - { - headerBadge = new Sprite - { - Size = new OpenTK.Vector2(0.8f), - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - }, - new Box // this ensures the purple circle doesn't disappear..? - { - RelativeSizeAxes = Axes.Both, - Size = new OpenTK.Vector2(1), - AlwaysPresent = true, - Colour = Color4.Transparent, - } - } + RelativeSizeAxes = Axes.Both, + Size = new OpenTK.Vector2(0.8f), + Anchor = Anchor.Centre, + Origin = Anchor.Centre, }, - headerTextContainer = new FillFlowContainer + + // this box has 2 functions: + // - ensures the circle doesn't disappear on the X and Y edges + // - lessens the white "contamination" on the circle (due to smoothing) + new Box { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - X = icon_size + icon_margin * 2, - Children = new Drawable[] - { - title = new OsuSpriteText - { - Text = "Changelog ", - Font = @"Exo2.0-Light", - TextSize = 38, // web: 30 - }, - titleStream = new OsuSpriteText - { - Text = "Listing", - TextSize = 38, // web: 30 - Font = @"Exo2.0-Light", - Colour = purple, - }, - } + RelativeSizeAxes = Axes.Both, + Size = new OpenTK.Vector2(1), + Alpha = 0, + AlwaysPresent = true, + Colour = purple, } } }, - breadcrumbContainer = new FillFlowContainer // Listing > Lazer 2018.713.1 + headerTextContainer = new FillFlowContainer { - X = 2 * icon_margin + icon_size - 8, // for some reason off by 3px - Height = version_height, - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, + AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + X = icon_size + icon_margin * 2, Children = new Drawable[] { - listing = new TextBadgePairListing(purple), - new SpriteIcon + title = new OsuSpriteText { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, + Text = "Changelog ", + Font = @"Exo2.0-Light", + TextSize = 38, // web: 30 + }, + titleStream = new OsuSpriteText + { + Text = "Listing", + TextSize = 38, // web: 30 + Font = @"Exo2.0-Light", + Colour = purple, + }, + } + } + } + }, + breadcrumbContainer = new FillFlowContainer // Listing > Lazer 2018.713.1 + { + X = 2 * icon_margin + icon_size - 8, + Height = version_height, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Direction = FillDirection.Horizontal, + Children = new Drawable[] + { + listing = new TextBadgePairListing(purple), + new Container() // without a container, moving the chevron wont work + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Margin = new MarginPadding() + { + Top = 10, + Left = 7, + Right = 9, + Bottom = 15, + }, + Children = new Drawable[] + { + chevron = new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, Size = new Vector2(7), - Colour = OsuColour.FromHex(@"bf04ff"), + Colour = purple, Icon = FontAwesome.fa_chevron_right, - Margin = new MarginPadding() - { - Top = 8, - Left = 5, - Right = 5, - Bottom = 15, - }, + Alpha = 0, + X = -200, }, - releaseStream = new TextBadgePairRelease(purple, "Lazer") }, }, - new Box // purple line - { - Colour = purple, - RelativeSizeAxes = Axes.X, - Height = 3, - Anchor = Anchor.BottomLeft, - Origin = Anchor.CentreLeft, - }, - // } - //} + releaseStream = new TextBadgePairRelease(purple, "Lazer") + }, + }, + new Box // purple line + { + Colour = purple, + RelativeSizeAxes = Axes.X, + Height = 3, + Anchor = Anchor.BottomLeft, + Origin = Anchor.CentreLeft, + }, } } }; @@ -172,10 +174,15 @@ namespace osu.Game.Overlays.Changelog // is this a bad way to do this? OnLoadComplete = d => { - releaseStream.OnActivation = listing.Deactivate; + releaseStream.OnActivation = () => + { + listing.Deactivate(); + chevron.MoveToX(0, 100).FadeIn(100); + }; listing.OnActivation = () => { releaseStream.Deactivate(); + chevron.MoveToX(-20, 100).FadeOut(100); ChangeHeaderText("Listing"); }; }; diff --git a/osu.Game/Overlays/Changelog/Header/LineBadge.cs b/osu.Game/Overlays/Changelog/Header/LineBadge.cs index f321939a96..0846821c5c 100644 --- a/osu.Game/Overlays/Changelog/Header/LineBadge.cs +++ b/osu.Game/Overlays/Changelog/Header/LineBadge.cs @@ -3,8 +3,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; -using osu.Framework.Input; -using osu.Game.Graphics.Containers; namespace osu.Game.Overlays.Changelog.Header { @@ -12,24 +10,26 @@ namespace osu.Game.Overlays.Changelog.Header { private const float transition_duration = 100; private const float uncollapsed_height = 10; - public float UncollapsedHeight => uncollapsed_height; + public float TransitionDuration => transition_duration; - private bool isCollapsed; + public float UncollapsedHeight => uncollapsed_height; + protected bool isCollapsed; public bool IsCollapsed { get { return isCollapsed; } set { isCollapsed = value; - this.ResizeHeightTo(value ? 1 : 10, transition_duration); + this.ResizeHeightTo(value ? 1 : uncollapsed_height, transition_duration); } } - public LineBadge(bool startCollapsed = false) + public LineBadge() { - IsCollapsed = startCollapsed; Anchor = Anchor.BottomCentre; Origin = Anchor.Centre; + + // this margin prevents jumps when changing text's font weight Margin = new MarginPadding() { Left = 10, diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs index 5d1018e504..24ce873a95 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -1,16 +1,10 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; -using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; -using osu.Framework.Input; -using osu.Game.Graphics; -using osu.Game.Overlays.Changelog; using System; namespace osu.Game.Overlays.Changelog.Header @@ -43,7 +37,11 @@ namespace osu.Game.Overlays.Changelog.Header public void ShowText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) { - if (!string.IsNullOrEmpty(displayText)) text.Text = displayText; + if (!string.IsNullOrEmpty(displayText)) + { + text.Text = displayText; + } + text.MoveToY(0, duration, easing) .FadeIn(duration, easing) .Finally(d => { @@ -74,7 +72,7 @@ namespace osu.Game.Overlays.Changelog.Header // didn't apply to transforms that come after the .finally), I'm using a scheduler here Scheduler.AddDelayed(() => { - lineBadge.ResizeWidthTo(0); // resizes when not visible + //lineBadge.ResizeWidthTo(0); // resizes when not visible if (!string.IsNullOrEmpty(displayText)) text.Text = displayText; }, duration); } @@ -91,7 +89,6 @@ namespace osu.Game.Overlays.Changelog.Header Text = displayText, Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft, - AlwaysPresent = true, Margin = new MarginPadding() { Top = 5, diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs index f89ed8362e..4897aeedd1 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs @@ -5,7 +5,6 @@ using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Input; -using System; namespace osu.Game.Overlays.Changelog.Header { diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs index 71e3b251c2..f69c7dd6a7 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs @@ -1,9 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; -using osu.Framework.Input; namespace osu.Game.Overlays.Changelog.Header { @@ -27,15 +25,17 @@ namespace osu.Game.Overlays.Changelog.Header public void Activate(string displayText = null) { - ClearTransforms(); - if (!lineBadge.IsCollapsed) ChangeText(transition_duration, displayText); + //ClearTransforms(); + // not using if (!lineBadge.IsCollapsed) because the text sometimes gets reset + // when quickly switching release streams + if (text.IsPresent) ChangeText(transition_duration, displayText); else ShowText(transition_duration, displayText); OnActivation?.Invoke(); } public override void Deactivate() { - FinishTransforms(true); + //FinishTransforms(true); HideText(transition_duration); OnDeactivation?.Invoke(); } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index f6a138e603..915d747f00 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -9,11 +9,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.Containers; -using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Changelog; -using System; -using System.Collections.Generic; -using System.Text; namespace osu.Game.Overlays { @@ -23,19 +19,22 @@ namespace osu.Game.Overlays public ChangelogHeader header; + protected Color4 purple = new Color4(191, 4, 255, 255); + public ChangelogOverlay() { - Waves.FirstWaveColour = OsuColour.Gray(0.4f); - Waves.SecondWaveColour = OsuColour.Gray(0.3f); - Waves.ThirdWaveColour = OsuColour.Gray(0.2f); - Waves.FourthWaveColour = OsuColour.Gray(0.1f); + // these possibly need adjusting? + Waves.FirstWaveColour = OsuColour.FromHex(@"bf04ff"); + Waves.SecondWaveColour = OsuColour.FromHex(@"8F03BF"); + Waves.ThirdWaveColour = OsuColour.FromHex(@"600280"); + Waves.FourthWaveColour = OsuColour.FromHex(@"300140"); Anchor = Anchor.TopCentre; Origin = Anchor.TopCentre; RelativeSizeAxes = Axes.Both; Width = 0.85f; - Masking = true; + EdgeEffect = new EdgeEffectParameters { Colour = Color4.Black.Opacity(0), From 523d47e8154e573cf7873ec0650dd7bcde0db379 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Wed, 18 Jul 2018 01:35:06 +0200 Subject: [PATCH 004/375] Streams1 --- osu.Game.Tests/Visual/TestCaseChangelog.cs | 12 +- osu.Game/Graphics/StreamColour.cs | 17 ++ .../Overlays/Changelog/ChangelogHeader.cs | 217 +++++++++--------- .../Overlays/Changelog/ChangelogStreams.cs | 81 +++++++ .../Overlays/Changelog/Header/LineBadge.cs | 14 +- .../Changelog/Header/TextBadgePair.cs | 7 +- .../Changelog/Header/TextBadgePairListing.cs | 2 +- .../Overlays/Changelog/ReleaseStreamInfo.cs | 25 ++ .../Overlays/Changelog/Streams/StreamBadge.cs | 128 +++++++++++ osu.Game/Overlays/ChangelogOverlay.cs | 20 +- 10 files changed, 397 insertions(+), 126 deletions(-) create mode 100644 osu.Game/Graphics/StreamColour.cs create mode 100644 osu.Game/Overlays/Changelog/ChangelogStreams.cs create mode 100644 osu.Game/Overlays/Changelog/ReleaseStreamInfo.cs create mode 100644 osu.Game/Overlays/Changelog/Streams/StreamBadge.cs diff --git a/osu.Game.Tests/Visual/TestCaseChangelog.cs b/osu.Game.Tests/Visual/TestCaseChangelog.cs index 28c43b5153..c9b8a4d652 100644 --- a/osu.Game.Tests/Visual/TestCaseChangelog.cs +++ b/osu.Game.Tests/Visual/TestCaseChangelog.cs @@ -11,16 +11,22 @@ namespace osu.Game.Tests.Visual public class TestCaseChangelog : OsuTestCase { private ChangelogOverlay changelog; + private int releaseStreamCount; + private int index; protected override void LoadComplete() { base.LoadComplete(); Add(changelog = new ChangelogOverlay()); - + + releaseStreamCount = changelog.streams.badgesContainer.Children.Count; + AddStep(@"Show", changelog.Show); - AddStep(@"Stable Release Stream", () => changelog.header.ShowReleaseStream("Stable", "Stable 20180626.1")); - AddStep(@"Lazer Release Stream", () => changelog.header.ShowReleaseStream("Lazer", "Lazer 2018.713.1")); + AddRepeatStep(@"Toggle Release Stream", () => { + changelog.streams.badgesContainer.Children[index].Activate(); + index = (index == releaseStreamCount - 1) ? 0 : index + 1; + }, releaseStreamCount); AddStep(@"Listing", changelog.header.ActivateListing); } diff --git a/osu.Game/Graphics/StreamColour.cs b/osu.Game/Graphics/StreamColour.cs new file mode 100644 index 0000000000..fbb272c526 --- /dev/null +++ b/osu.Game/Graphics/StreamColour.cs @@ -0,0 +1,17 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; + +namespace osu.Game.Graphics +{ + public class StreamColour + { + public readonly Color4 Stable = new Color4(102, 204, 255, 255); + public readonly Color4 StableFallback = new Color4(34, 153, 187, 255); + public readonly Color4 Beta = new Color4(255, 221, 85, 255); + public readonly Color4 CuttingEdge = new Color4(238, 170, 0, 255); + public readonly Color4 Lazer = new Color4(237, 18, 33, 255); + public readonly Color4 Web = new Color4(136, 102, 238, 255); + } +} diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index cc07ffeb18..183a63575b 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -12,13 +12,12 @@ using osu.Framework.Graphics.Textures; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Changelog.Header; +using System; namespace osu.Game.Overlays.Changelog { public class ChangelogHeader : Container { - private readonly Container coverContainer; - protected Color4 purple = new Color4(191, 4, 255, 255); private readonly Sprite coverImage; private readonly Sprite headerBadge; //50x50, margin-right: 20 @@ -29,6 +28,8 @@ namespace osu.Game.Overlays.Changelog private readonly TextBadgePairRelease releaseStream; private readonly FillFlowContainer breadcrumbContainer; + public Action OnListingActivated; + private const float cover_height = 310; private const float title_height = 50; private const float icon_size = 50; @@ -38,137 +39,128 @@ namespace osu.Game.Overlays.Changelog public ChangelogHeader() { RelativeSizeAxes = Axes.X; - Height = cover_height + 5; // 5 is for the "badge" that sticks a bit out of the bottom - Masking = true; // is masking necessary? since I see it nearly everywhere + Height = cover_height; Children = new Drawable[] { - coverContainer = new Container + coverImage = new Sprite { - RelativeSizeAxes = Axes.X, - Height = cover_height, + RelativeSizeAxes = Axes.Both, + Size = new OpenTK.Vector2(1), + FillMode = FillMode.Fill, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, + new Container // this is the line badge-Changelog-Stream + { + Height = title_height, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Y = -version_height, Children = new Drawable[] { - coverImage = new Sprite + new CircularContainer // a purple circle { - RelativeSizeAxes = Axes.Both, - Size = new OpenTK.Vector2(1), - FillMode = FillMode.Fill, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }, - new Container // this is the line badge-Changelog-Stream - { - Height = title_height, - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Y = -version_height, + X = icon_margin, + Masking = true, + BorderColour = purple, + BorderThickness = 3, + MaskingSmoothness = 1, + Size = new OpenTK.Vector2(50), Children = new Drawable[] { - new CircularContainer // a purple circle + headerBadge = new Sprite { - X = icon_margin, - Masking = true, - BorderColour = purple, - BorderThickness = 3, - MaskingSmoothness = 1, - Size = new OpenTK.Vector2(50), - Children = new Drawable[] - { - headerBadge = new Sprite - { - RelativeSizeAxes = Axes.Both, - Size = new OpenTK.Vector2(0.8f), - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }, - - // this box has 2 functions: - // - ensures the circle doesn't disappear on the X and Y edges - // - lessens the white "contamination" on the circle (due to smoothing) - new Box - { - RelativeSizeAxes = Axes.Both, - Size = new OpenTK.Vector2(1), - Alpha = 0, - AlwaysPresent = true, - Colour = purple, - } - } + RelativeSizeAxes = Axes.Both, + Size = new OpenTK.Vector2(0.8f), + Anchor = Anchor.Centre, + Origin = Anchor.Centre, }, - headerTextContainer = new FillFlowContainer + + // this box has 2 functions: + // - ensures the circle doesn't disappear on the X and Y edges + // - lessens the white "contamination" on the circle (due to smoothing) + new Box { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - X = icon_size + icon_margin * 2, - Children = new Drawable[] - { - title = new OsuSpriteText - { - Text = "Changelog ", - Font = @"Exo2.0-Light", - TextSize = 38, // web: 30 - }, - titleStream = new OsuSpriteText - { - Text = "Listing", - TextSize = 38, // web: 30 - Font = @"Exo2.0-Light", - Colour = purple, - }, - } + RelativeSizeAxes = Axes.Both, + Size = new OpenTK.Vector2(1), + Alpha = 0, + AlwaysPresent = true, + Colour = purple, } } }, - breadcrumbContainer = new FillFlowContainer // Listing > Lazer 2018.713.1 + headerTextContainer = new FillFlowContainer { - X = 2 * icon_margin + icon_size - 8, - Height = version_height, - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, + AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + X = icon_size + icon_margin * 2, Children = new Drawable[] { - listing = new TextBadgePairListing(purple), - new Container() // without a container, moving the chevron wont work + title = new OsuSpriteText { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Margin = new MarginPadding() - { - Top = 10, - Left = 7, - Right = 9, - Bottom = 15, - }, - Children = new Drawable[] - { - chevron = new SpriteIcon - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(7), - Colour = purple, - Icon = FontAwesome.fa_chevron_right, - Alpha = 0, - X = -200, - }, - }, + Text = "Changelog ", + Font = @"Exo2.0-Light", + TextSize = 38, // web: 30 + }, + titleStream = new OsuSpriteText + { + Text = "Listing", + TextSize = 38, // web: 30 + Font = @"Exo2.0-Light", + Colour = purple, + }, + } + } + } + }, + breadcrumbContainer = new FillFlowContainer // Listing > Lazer 2018.713.1 + { + X = 2 * icon_margin + icon_size - 8, + Height = version_height, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Direction = FillDirection.Horizontal, + Children = new Drawable[] + { + listing = new TextBadgePairListing(purple), + new Container() // without a container, moving the chevron wont work + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Margin = new MarginPadding() + { + Top = 10, + Left = 7, + Right = 9, + Bottom = 15, + }, + Children = new Drawable[] + { + chevron = new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(7), + Colour = purple, + Icon = FontAwesome.fa_chevron_right, + Alpha = 0, + X = -200, }, - releaseStream = new TextBadgePairRelease(purple, "Lazer") }, }, - new Box // purple line - { - Colour = purple, - RelativeSizeAxes = Axes.X, - Height = 3, - Anchor = Anchor.BottomLeft, - Origin = Anchor.CentreLeft, - }, - } - } + releaseStream = new TextBadgePairRelease(purple, "Lazer") + }, + }, + new Box // purple line + { + Colour = purple, + RelativeSizeAxes = Axes.X, + Height = 3, + Anchor = Anchor.BottomLeft, + Origin = Anchor.CentreLeft, + }, }; // is this a bad way to do this? @@ -184,6 +176,7 @@ namespace osu.Game.Overlays.Changelog releaseStream.Deactivate(); chevron.MoveToX(-20, 100).FadeOut(100); ChangeHeaderText("Listing"); + OnListingActivated?.Invoke(); }; }; } @@ -201,7 +194,7 @@ namespace osu.Game.Overlays.Changelog } public void ActivateListing() => listing.Activate(); - + [BackgroundDependencyLoader] private void load(TextureStore textures) { diff --git a/osu.Game/Overlays/Changelog/ChangelogStreams.cs b/osu.Game/Overlays/Changelog/ChangelogStreams.cs new file mode 100644 index 0000000000..e7f7d44c80 --- /dev/null +++ b/osu.Game/Overlays/Changelog/ChangelogStreams.cs @@ -0,0 +1,81 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Configuration; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Overlays.Changelog.Streams; +using System; + +namespace osu.Game.Overlays.Changelog +{ + public class ChangelogStreams : Container + { + private const float containerHeight = 106.5f; + private const float containerTopBottomMargin = 20; + private const float containerSideMargin = 85; + + public Bindable SelectedRelease = new Bindable(); + + private readonly StreamColour streamColour; + public readonly FillFlowContainer badgesContainer; + + public ChangelogStreams() + { + streamColour = new StreamColour(); + Height = containerHeight; + RelativeSizeAxes = Axes.X; + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Size = new OpenTK.Vector2(1), + Colour = new Color4(32, 24, 35, 255), + }, + badgesContainer = new FillFlowContainer + { + Direction = FillDirection.Horizontal, + RelativeSizeAxes = Axes.Both, + Margin = new MarginPadding() + { + Top = containerTopBottomMargin, + Bottom = containerTopBottomMargin, + Left = containerSideMargin, + Right = containerSideMargin, + }, + Children = new[] + { + new StreamBadge(streamColour.Stable, "Stable", "20180626.1", 16370, true), + new StreamBadge(streamColour.Beta, "Beta", "20180626", 186), + new StreamBadge(streamColour.Lazer, "Lazer", "2018.713.1"), + }, + }, + }; + badgesContainer.OnLoadComplete = d => + { + foreach (StreamBadge streamBadge in badgesContainer.Children) + { + streamBadge.OnActivation = () => + { + SelectedRelease.Value = new ReleaseStreamInfo() + { + DisplayVersion = streamBadge.DisplayVersion, + IsFeatured = streamBadge.IsFeatured, + Name = streamBadge.Name, + Users = streamBadge.Users, + }; + foreach (StreamBadge item in badgesContainer.Children) + { + if (item.Name != streamBadge.Name) item.Deactivate(); + } + }; + } + }; + } + } +} diff --git a/osu.Game/Overlays/Changelog/Header/LineBadge.cs b/osu.Game/Overlays/Changelog/Header/LineBadge.cs index 0846821c5c..c33244d50b 100644 --- a/osu.Game/Overlays/Changelog/Header/LineBadge.cs +++ b/osu.Game/Overlays/Changelog/Header/LineBadge.cs @@ -8,11 +8,10 @@ namespace osu.Game.Overlays.Changelog.Header { public class LineBadge : Circle { - private const float transition_duration = 100; - private const float uncollapsed_height = 10; + public float TransitionDuration = 100; + public float UncollapsedHeight; + public float CollapsedHeight; - public float TransitionDuration => transition_duration; - public float UncollapsedHeight => uncollapsed_height; protected bool isCollapsed; public bool IsCollapsed { @@ -20,14 +19,17 @@ namespace osu.Game.Overlays.Changelog.Header set { isCollapsed = value; - this.ResizeHeightTo(value ? 1 : uncollapsed_height, transition_duration); + this.ResizeHeightTo(value ? CollapsedHeight : UncollapsedHeight, TransitionDuration); } } - public LineBadge() + public LineBadge(bool startCollapsed = true, float collapsedHeight = 1, float uncollapsedHeight = 10) { Anchor = Anchor.BottomCentre; Origin = Anchor.Centre; + CollapsedHeight = collapsedHeight; + UncollapsedHeight = uncollapsedHeight; + Height = startCollapsed ? CollapsedHeight : UncollapsedHeight; // this margin prevents jumps when changing text's font weight Margin = new MarginPadding() diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs index 24ce873a95..32910e26c6 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -14,10 +14,11 @@ namespace osu.Game.Overlays.Changelog.Header { protected SpriteText text; protected LineBadge lineBadge; + protected bool startCollapsed; public Action OnActivation; public Action OnDeactivation; - + public void SetTextColour(ColourInfo newColour, double duration = 0, Easing easing = Easing.None) { text.FadeColour(newColour, duration, easing); @@ -77,7 +78,7 @@ namespace osu.Game.Overlays.Changelog.Header }, duration); } - public TextBadgePair(ColourInfo badgeColour, string displayText = "Listing") + public TextBadgePair(ColourInfo badgeColour, string displayText = "Listing", bool startBadgeCollapsed = true) { AutoSizeAxes = Axes.X; RelativeSizeAxes = Axes.Y; @@ -97,7 +98,7 @@ namespace osu.Game.Overlays.Changelog.Header Right = 10, } }, - lineBadge = new LineBadge + lineBadge = new LineBadge(startCollapsed) { Colour = badgeColour, } diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs index 4897aeedd1..41d9a2a8ef 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs @@ -12,7 +12,7 @@ namespace osu.Game.Overlays.Changelog.Header { private ColourInfo badgeColour; - public TextBadgePairListing(ColourInfo badgeColour) : base(badgeColour, "Listing") + public TextBadgePairListing(ColourInfo badgeColour) : base(badgeColour, "Listing", false) { this.badgeColour = badgeColour; text.Font = "Exo2.0-Bold"; diff --git a/osu.Game/Overlays/Changelog/ReleaseStreamInfo.cs b/osu.Game/Overlays/Changelog/ReleaseStreamInfo.cs new file mode 100644 index 0000000000..90b2ab6cfb --- /dev/null +++ b/osu.Game/Overlays/Changelog/ReleaseStreamInfo.cs @@ -0,0 +1,25 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using Newtonsoft.Json; +using osu.Game.Database; +using osu.Game.IO.Serialization; +using osu.Game.Rulesets; + +namespace osu.Game.Overlays.Changelog +{ + [Serializable] + public class ReleaseStreamInfo : IJsonSerializable + { + public string Name; + public string DisplayVersion; + + public float Users; + + public bool IsFeatured; + } +} diff --git a/osu.Game/Overlays/Changelog/Streams/StreamBadge.cs b/osu.Game/Overlays/Changelog/Streams/StreamBadge.cs new file mode 100644 index 0000000000..e61fa22007 --- /dev/null +++ b/osu.Game/Overlays/Changelog/Streams/StreamBadge.cs @@ -0,0 +1,128 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input; +using System; + +namespace osu.Game.Overlays.Changelog.Streams +{ + public class StreamBadge : Container + { + private const float badgeHeight = 56.5f; + private const float badgeWidth = 100; + private const float badgeTopBottomMargin = 5; + private const float transition_duration = 100; + + public Action OnActivation; + + private bool isActive; + + private Header.LineBadge lineBadge; + + public string Name { get; private set; } + public string DisplayVersion { get; private set; } + public bool IsFeatured { get; private set; } + public float Users { get; private set; } + + public StreamBadge(ColourInfo colour, string streamName, string streamBuild, float onlineUsers = 0, bool isFeatured = false) + { + Name = streamName; + DisplayVersion = streamBuild; + IsFeatured = isFeatured; + Users = onlineUsers; + Height = badgeHeight; + Width = isFeatured ? badgeWidth * 2 : badgeWidth; + Margin = new MarginPadding(5); + isActive = true; + Children = new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.X, + RelativeSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Children = new[] + { + new SpriteText + { + Text = streamName, + Font = @"Exo2.0-Bold", + TextSize = 16, + Margin = new MarginPadding + { + Top = 5, + } + }, + new SpriteText + { + Text = streamBuild, + Font = @"Exo2.0-Light", + TextSize = 21, + }, + new SpriteText + { + Text = onlineUsers > 0 ? + string.Join(" ", onlineUsers.ToString("N0"), "users online"): + null, + TextSize = 12, + Font = @"Exo2.0-Regular", + Colour = new Color4(203, 164, 218, 255), + }, + } + }, + lineBadge = new Header.LineBadge(false, 2, 4) + { + Anchor = Anchor.TopCentre, + Width = 1, + Colour = colour, + RelativeSizeAxes = Axes.X, + }, + }; + } + + public void Activate(bool withoutHeaderUpdate = false) + { + isActive = true; + this.FadeIn(transition_duration); + lineBadge.IsCollapsed = false; + if (!withoutHeaderUpdate) OnActivation?.Invoke(); + } + + public void Deactivate() + { + isActive = false; + this.FadeTo(0.5f, transition_duration); + lineBadge.IsCollapsed = true; + } + + protected override bool OnClick(InputState state) + { + Activate(); + return base.OnClick(state); + } + + protected override bool OnHover(InputState state) + { + this.FadeIn(transition_duration); + lineBadge.IsCollapsed = false; + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + if (!isActive) + { + this.FadeTo(0.5f, transition_duration); + lineBadge.IsCollapsed = true; + } + base.OnHoverLost(state); + } + } +} diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 915d747f00..e47e290075 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -10,6 +10,7 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Overlays.Changelog; +using osu.Game.Overlays.Changelog.Streams; namespace osu.Game.Overlays { @@ -17,7 +18,8 @@ namespace osu.Game.Overlays { private readonly ScrollContainer scroll; - public ChangelogHeader header; + public readonly ChangelogHeader header; + public readonly ChangelogStreams streams; protected Color4 purple = new Color4(191, 4, 255, 255); @@ -62,10 +64,26 @@ namespace osu.Game.Overlays Children = new Drawable[] { header = new ChangelogHeader(), + streams = new ChangelogStreams(), }, }, }, }; + streams.SelectedRelease.ValueChanged += r => + { + if (streams.SelectedRelease != null) + header.ShowReleaseStream(r.Name, string.Join(" ", r.Name, r.DisplayVersion)); + }; + streams.badgesContainer.OnLoadComplete += d => + { + header.OnListingActivated += () => + { + foreach (StreamBadge item in streams.badgesContainer.Children) + { + item.Activate(true); + } + }; + }; } // receive input outside our bounds so we can trigger a close event on ourselves. From 6baa761b9ce852fa5f313b57a7f77dcd49e66aae Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Wed, 18 Jul 2018 03:26:08 +0200 Subject: [PATCH 005/375] Streams2 --- osu.Game.Tests/Visual/TestCaseChangelog.cs | 3 +- .../Visual/TestCaseTextBadgePair.cs | 62 ------------------- .../Overlays/Changelog/ChangelogStreams.cs | 29 ++++++++- .../Changelog/Header/TextBadgePair.cs | 3 +- .../Overlays/Changelog/Streams/StreamBadge.cs | 5 +- osu.Game/Overlays/ChangelogOverlay.cs | 3 +- 6 files changed, 35 insertions(+), 70 deletions(-) delete mode 100644 osu.Game.Tests/Visual/TestCaseTextBadgePair.cs diff --git a/osu.Game.Tests/Visual/TestCaseChangelog.cs b/osu.Game.Tests/Visual/TestCaseChangelog.cs index c9b8a4d652..afd06d8415 100644 --- a/osu.Game.Tests/Visual/TestCaseChangelog.cs +++ b/osu.Game.Tests/Visual/TestCaseChangelog.cs @@ -1,7 +1,6 @@ -// Copyright(c) 2007-2018 ppy Pty Ltd. +// Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - using NUnit.Framework; using osu.Game.Overlays; diff --git a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs b/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs deleted file mode 100644 index 9a4e481ff8..0000000000 --- a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using NUnit.Framework; -using OpenTK.Graphics; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osu.Game.Overlays.Changelog.Header; - -namespace osu.Game.Tests.Visual -{ - [TestFixture] - public class TestCaseTextBadgePair : OsuTestCase - { - private readonly Container container; - private readonly Box bottomLine; - private readonly TextBadgePair textBadgePair; - - public TestCaseTextBadgePair() - { - - Add(container = new Container - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new OpenTK.Vector2(300, 40), - Children = new Drawable[] - { - new Box - { - Colour = Color4.Gray, - RelativeSizeAxes = Axes.Both, - }, - bottomLine = new Box // purple line - { - Colour = Color4.Purple, - RelativeSizeAxes = Axes.X, - Height = 3, - Anchor = Anchor.BottomLeft, - Origin = Anchor.CentreLeft, - }, - textBadgePair = new TextBadgePair(Color4.White, "testing") - { - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - } - }, - }); - - AddStep(@"deactivate", () => textBadgePair.Deactivate()); - AddStep(@"activate", () => textBadgePair.Activate()); - AddStep(@"purple text", () => textBadgePair.SetTextColour(Color4.Purple, 100)); - AddStep(@"white text", () => textBadgePair.SetTextColour(Color4.White, 100)); - AddStep(@"purple badge", () => textBadgePair.SetBadgeColour(Color4.Purple, 100)); - AddStep(@"white badge", () => textBadgePair.SetBadgeColour(Color4.White, 100)); - AddStep(@"hide text", () => textBadgePair.HideText(250)); - AddStep(@"show text", () => textBadgePair.ShowText(250)); - AddStep(@"change text", () => textBadgePair.ChangeText(250)); - } - } -} diff --git a/osu.Game/Overlays/Changelog/ChangelogStreams.cs b/osu.Game/Overlays/Changelog/ChangelogStreams.cs index e7f7d44c80..99c9c0accd 100644 --- a/osu.Game/Overlays/Changelog/ChangelogStreams.cs +++ b/osu.Game/Overlays/Changelog/ChangelogStreams.cs @@ -7,6 +7,7 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input; using osu.Game.Graphics; using osu.Game.Overlays.Changelog.Streams; using System; @@ -23,7 +24,7 @@ namespace osu.Game.Overlays.Changelog private readonly StreamColour streamColour; public readonly FillFlowContainer badgesContainer; - + public ChangelogStreams() { streamColour = new StreamColour(); @@ -77,5 +78,31 @@ namespace osu.Game.Overlays.Changelog } }; } + + protected override bool OnHover(InputState state) + { + // is this nullreference-safe for badgesContainer? + foreach (StreamBadge streamBadge in badgesContainer.Children) + { + if (SelectedRelease.Value != null) + { + if (SelectedRelease.Value.Name != streamBadge.Name) + { + streamBadge.Deactivate(); + } + } + else streamBadge.Deactivate(); + } + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + if (SelectedRelease.Value == null) + { + foreach (StreamBadge streamBadge in badgesContainer.Children) streamBadge.Activate(true); + } + base.OnHoverLost(state); + } } } diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs index 32910e26c6..42f7bd601a 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -9,7 +9,6 @@ using System; namespace osu.Game.Overlays.Changelog.Header { - public class TextBadgePair : ClickableContainer { protected SpriteText text; @@ -18,7 +17,7 @@ namespace osu.Game.Overlays.Changelog.Header public Action OnActivation; public Action OnDeactivation; - + public void SetTextColour(ColourInfo newColour, double duration = 0, Easing easing = Easing.None) { text.FadeColour(newColour, duration, easing); diff --git a/osu.Game/Overlays/Changelog/Streams/StreamBadge.cs b/osu.Game/Overlays/Changelog/Streams/StreamBadge.cs index e61fa22007..9b70c9ce7f 100644 --- a/osu.Game/Overlays/Changelog/Streams/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/Streams/StreamBadge.cs @@ -13,7 +13,7 @@ using System; namespace osu.Game.Overlays.Changelog.Streams { - public class StreamBadge : Container + public class StreamBadge : ClickableContainer { private const float badgeHeight = 56.5f; private const float badgeWidth = 100; @@ -57,7 +57,7 @@ namespace osu.Game.Overlays.Changelog.Streams TextSize = 16, Margin = new MarginPadding { - Top = 5, + Top = 7, } }, new SpriteText @@ -80,6 +80,7 @@ namespace osu.Game.Overlays.Changelog.Streams lineBadge = new Header.LineBadge(false, 2, 4) { Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, Width = 1, Colour = colour, RelativeSizeAxes = Axes.X, diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index e47e290075..9d4ec2b806 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -71,13 +71,14 @@ namespace osu.Game.Overlays }; streams.SelectedRelease.ValueChanged += r => { - if (streams.SelectedRelease != null) + if (streams.SelectedRelease.Value != null) header.ShowReleaseStream(r.Name, string.Join(" ", r.Name, r.DisplayVersion)); }; streams.badgesContainer.OnLoadComplete += d => { header.OnListingActivated += () => { + streams.SelectedRelease.Value = null; foreach (StreamBadge item in streams.badgesContainer.Children) { item.Activate(true); From 837747e35f53a152b8f01e192fee6d06a30db688 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Wed, 18 Jul 2018 15:17:20 +0200 Subject: [PATCH 006/375] Streams3 --- osu.Game.Tests/Visual/TestCaseChangelog.cs | 40 +++++++++++++++++-- .../Overlays/Changelog/ChangelogHeader.cs | 4 +- .../Changelog/Header/TextBadgePair.cs | 28 ++++--------- .../Changelog/Header/TextBadgePairListing.cs | 7 ++++ .../Changelog/Header/TextBadgePairRelease.cs | 1 - osu.Game/Overlays/ChangelogOverlay.cs | 4 +- 6 files changed, 56 insertions(+), 28 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseChangelog.cs b/osu.Game.Tests/Visual/TestCaseChangelog.cs index afd06d8415..c7b9f3dd9e 100644 --- a/osu.Game.Tests/Visual/TestCaseChangelog.cs +++ b/osu.Game.Tests/Visual/TestCaseChangelog.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using NUnit.Framework; +using osu.Framework.Graphics.Containers; using osu.Game.Overlays; namespace osu.Game.Tests.Visual @@ -12,6 +13,7 @@ namespace osu.Game.Tests.Visual private ChangelogOverlay changelog; private int releaseStreamCount; private int index; + private void indexIncrement() => index = (index == releaseStreamCount - 1) ? 0 : index + 1; protected override void LoadComplete() { @@ -22,16 +24,46 @@ namespace osu.Game.Tests.Visual releaseStreamCount = changelog.streams.badgesContainer.Children.Count; AddStep(@"Show", changelog.Show); - AddRepeatStep(@"Toggle Release Stream", () => { + AddRepeatStep(@"Toggle Release Stream", () => + { changelog.streams.badgesContainer.Children[index].Activate(); - index = (index == releaseStreamCount - 1) ? 0 : index + 1; + indexIncrement(); }, releaseStreamCount); - AddStep(@"Listing", changelog.header.ActivateListing); + AddStep(@"Listing", changelog.ActivateListing); + AddStep(@"Hide", changelog.Hide); + AddWaitStep(4); + AddStep(@"Show with Release Stream", () => + { + changelog.streams.badgesContainer.Children[index].Activate(); + changelog.Show(); + indexIncrement(); + }); + AddWaitStep(4); + AddStep(@"Hide", changelog.Hide); + AddWaitStep(4); + AddStep(@"Show with listing", () => + { + // .maybe changelog should have a function that does header.ActivateListing() + changelog.ActivateListing(); + changelog.Show(); + }); + AddWaitStep(4); + AddStep(@"Hide", changelog.Hide); + AddWaitStep(4); + AddStep(@"Activate release", () => + { + changelog.streams.badgesContainer.Children[index].Activate(); + indexIncrement(); + }); + AddStep(@"Show with listing", () => + { + changelog.ActivateListing(); + changelog.Show(); + }); } public TestCaseChangelog() { - } } } diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 183a63575b..43349fb668 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -133,7 +133,9 @@ namespace osu.Game.Overlays.Changelog { Top = 10, Left = 7, - Right = 9, + // + chevron size, and account for gained space on left by + // listing's font draw width being smaller + Right = 18, Bottom = 15, }, Children = new Drawable[] diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs index 42f7bd601a..6482a69bb9 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -37,18 +37,10 @@ namespace osu.Game.Overlays.Changelog.Header public void ShowText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) { - if (!string.IsNullOrEmpty(displayText)) - { - text.Text = displayText; - } - + lineBadge.IsCollapsed = false; + if (!string.IsNullOrEmpty(displayText)) text.Text = displayText; text.MoveToY(0, duration, easing) - .FadeIn(duration, easing) - .Finally(d => { - // waiting until text is drawn to use its DrawWidth - UpdateBadgeWidth(); - lineBadge.IsCollapsed = false; - }); + .FadeIn(duration, easing); } /// @@ -61,19 +53,15 @@ namespace osu.Game.Overlays.Changelog.Header .FadeOut(duration, easing) .Then() .MoveToY(0, duration, easing) - .FadeIn(duration, easing) - .OnComplete(dd => { - UpdateBadgeWidth(); - lineBadge.IsCollapsed = false; - }); + .FadeIn(duration, easing); // since using .finally/.oncomplete after first fadeout made the badge // not hide sometimes in visual tests(because FinishTransforms()/CancelTransforms() // didn't apply to transforms that come after the .finally), I'm using a scheduler here Scheduler.AddDelayed(() => { - //lineBadge.ResizeWidthTo(0); // resizes when not visible if (!string.IsNullOrEmpty(displayText)) text.Text = displayText; + lineBadge.IsCollapsed = false; }, duration); } @@ -93,13 +81,13 @@ namespace osu.Game.Overlays.Changelog.Header { Top = 5, Bottom = 15, - Left = 10, - Right = 10, } }, lineBadge = new LineBadge(startCollapsed) { + Width = 1, Colour = badgeColour, + RelativeSizeAxes = Axes.X, } }; } @@ -115,7 +103,5 @@ namespace osu.Game.Overlays.Changelog.Header lineBadge.IsCollapsed = false; text.Font = "Exo2.0-Bold"; } - - public void UpdateBadgeWidth() => lineBadge.ResizeWidthTo(text.DrawWidth); } } diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs index 41d9a2a8ef..0e12e1a2c5 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs @@ -19,6 +19,11 @@ namespace osu.Game.Overlays.Changelog.Header text.Anchor = Anchor.TopCentre; text.Origin = Anchor.TopCentre; + // I'm using this for constant badge width here, so that the whole + // thing doesn't jump left/right when listing's size changes + // due to different font weight (and thus width) + lineBadge.RelativeSizeAxes = Axes.None; + // this doesn't work without the scheduler // (because the text isn't yet fully drawn when it's loaded?) text.OnLoadComplete = d => Scheduler.Add(UpdateBadgeWidth); @@ -57,5 +62,7 @@ namespace osu.Game.Overlays.Changelog.Header if (lineBadge.IsCollapsed) lineBadge.ResizeHeightTo(1, lineBadge.TransitionDuration); base.OnHoverLost(state); } + + public void UpdateBadgeWidth() => lineBadge.ResizeWidthTo(text.DrawWidth); } } diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs index f69c7dd6a7..d2fed56214 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs @@ -12,7 +12,6 @@ namespace osu.Game.Overlays.Changelog.Header public TextBadgePairRelease(ColourInfo badgeColour, string displayText) : base(badgeColour, displayText) { - this.listingBadge = listingBadge; text.Font = "Exo2.0-Bold"; text.Y = 20; text.Alpha = 0; diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 9d4ec2b806..20061317d2 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -18,7 +18,7 @@ namespace osu.Game.Overlays { private readonly ScrollContainer scroll; - public readonly ChangelogHeader header; + private ChangelogHeader header; public readonly ChangelogStreams streams; protected Color4 purple = new Color4(191, 4, 255, 255); @@ -87,6 +87,8 @@ namespace osu.Game.Overlays }; } + public void ActivateListing() => header.ActivateListing(); + // receive input outside our bounds so we can trigger a close event on ourselves. public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; From 11e0732a2733401f511a5aefbc88c45fa0a03fc8 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Wed, 18 Jul 2018 19:32:15 +0200 Subject: [PATCH 007/375] Refactor1, UX1 --- osu.Game.Tests/Visual/TestCaseChangelog.cs | 24 +++---- osu.Game/Graphics/StreamColour.cs | 12 ++-- .../Overlays/Changelog/ChangelogHeader.cs | 48 ++++++------- .../Overlays/Changelog/ChangelogStreams.cs | 44 ++++++------ .../Overlays/Changelog/Header/LineBadge.cs | 10 +-- .../Changelog/Header/TextBadgePair.cs | 68 ++++++++++++------- .../Changelog/Header/TextBadgePairListing.cs | 30 ++++---- .../Changelog/Header/TextBadgePairRelease.cs | 25 ++++--- .../Overlays/Changelog/ReleaseStreamInfo.cs | 6 -- .../Overlays/Changelog/Streams/StreamBadge.cs | 51 ++++++++------ osu.Game/Overlays/ChangelogOverlay.cs | 47 +++++++++---- 11 files changed, 205 insertions(+), 160 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseChangelog.cs b/osu.Game.Tests/Visual/TestCaseChangelog.cs index c7b9f3dd9e..da568e0eb3 100644 --- a/osu.Game.Tests/Visual/TestCaseChangelog.cs +++ b/osu.Game.Tests/Visual/TestCaseChangelog.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using NUnit.Framework; -using osu.Framework.Graphics.Containers; using osu.Game.Overlays; namespace osu.Game.Tests.Visual @@ -13,7 +12,7 @@ namespace osu.Game.Tests.Visual private ChangelogOverlay changelog; private int releaseStreamCount; private int index; - private void indexIncrement() => index = (index == releaseStreamCount - 1) ? 0 : index + 1; + private void indexIncrement() => index = index == releaseStreamCount - 1 ? 0 : index + 1; protected override void LoadComplete() { @@ -21,38 +20,37 @@ namespace osu.Game.Tests.Visual Add(changelog = new ChangelogOverlay()); - releaseStreamCount = changelog.streams.badgesContainer.Children.Count; + releaseStreamCount = changelog.Streams.BadgesContainer.Children.Count; AddStep(@"Show", changelog.Show); AddRepeatStep(@"Toggle Release Stream", () => { - changelog.streams.badgesContainer.Children[index].Activate(); + changelog.Streams.BadgesContainer.Children[index].Activate(); indexIncrement(); }, releaseStreamCount); AddStep(@"Listing", changelog.ActivateListing); AddStep(@"Hide", changelog.Hide); - AddWaitStep(4); + AddWaitStep(3); AddStep(@"Show with Release Stream", () => { - changelog.streams.badgesContainer.Children[index].Activate(); + changelog.Streams.BadgesContainer.Children[index].Activate(); changelog.Show(); indexIncrement(); }); - AddWaitStep(4); + AddWaitStep(3); AddStep(@"Hide", changelog.Hide); - AddWaitStep(4); + AddWaitStep(3); AddStep(@"Show with listing", () => { - // .maybe changelog should have a function that does header.ActivateListing() changelog.ActivateListing(); changelog.Show(); }); AddWaitStep(4); AddStep(@"Hide", changelog.Hide); - AddWaitStep(4); + AddWaitStep(3); AddStep(@"Activate release", () => { - changelog.streams.badgesContainer.Children[index].Activate(); + changelog.Streams.BadgesContainer.Children[index].Activate(); indexIncrement(); }); AddStep(@"Show with listing", () => @@ -61,9 +59,5 @@ namespace osu.Game.Tests.Visual changelog.Show(); }); } - - public TestCaseChangelog() - { - } } } diff --git a/osu.Game/Graphics/StreamColour.cs b/osu.Game/Graphics/StreamColour.cs index fbb272c526..0da0201c06 100644 --- a/osu.Game/Graphics/StreamColour.cs +++ b/osu.Game/Graphics/StreamColour.cs @@ -7,11 +7,11 @@ namespace osu.Game.Graphics { public class StreamColour { - public readonly Color4 Stable = new Color4(102, 204, 255, 255); - public readonly Color4 StableFallback = new Color4(34, 153, 187, 255); - public readonly Color4 Beta = new Color4(255, 221, 85, 255); - public readonly Color4 CuttingEdge = new Color4(238, 170, 0, 255); - public readonly Color4 Lazer = new Color4(237, 18, 33, 255); - public readonly Color4 Web = new Color4(136, 102, 238, 255); + public static readonly Color4 STABLE = new Color4(102, 204, 255, 255); + public static readonly Color4 STABLEFALLBACK = new Color4(34, 153, 187, 255); + public static readonly Color4 BETA = new Color4(255, 221, 85, 255); + public static readonly Color4 CUTTINGEDGE = new Color4(238, 170, 0, 255); + public static readonly Color4 LAZER = new Color4(237, 18, 33, 255); + public static readonly Color4 WEB = new Color4(136, 102, 238, 255); } } diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 43349fb668..ebf666b1d8 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -18,15 +18,12 @@ namespace osu.Game.Overlays.Changelog { public class ChangelogHeader : Container { - protected Color4 purple = new Color4(191, 4, 255, 255); + protected Color4 Purple = new Color4(191, 4, 255, 255); private readonly Sprite coverImage; private readonly Sprite headerBadge; //50x50, margin-right: 20 - private readonly FillFlowContainer headerTextContainer; - private readonly OsuSpriteText title, titleStream; - private readonly SpriteIcon chevron; + private readonly OsuSpriteText titleStream; private readonly TextBadgePairListing listing; private readonly TextBadgePairRelease releaseStream; - private readonly FillFlowContainer breadcrumbContainer; public Action OnListingActivated; @@ -38,6 +35,7 @@ namespace osu.Game.Overlays.Changelog public ChangelogHeader() { + SpriteIcon chevron; // AppVeyor told me this should be a local variable..? RelativeSizeAxes = Axes.X; Height = cover_height; Children = new Drawable[] @@ -45,7 +43,7 @@ namespace osu.Game.Overlays.Changelog coverImage = new Sprite { RelativeSizeAxes = Axes.Both, - Size = new OpenTK.Vector2(1), + Size = new Vector2(1), FillMode = FillMode.Fill, Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -62,16 +60,16 @@ namespace osu.Game.Overlays.Changelog { X = icon_margin, Masking = true, - BorderColour = purple, + BorderColour = Purple, BorderThickness = 3, MaskingSmoothness = 1, - Size = new OpenTK.Vector2(50), + Size = new Vector2(50), Children = new Drawable[] { headerBadge = new Sprite { RelativeSizeAxes = Axes.Both, - Size = new OpenTK.Vector2(0.8f), + Size = new Vector2(0.8f), Anchor = Anchor.Centre, Origin = Anchor.Centre, }, @@ -82,14 +80,14 @@ namespace osu.Game.Overlays.Changelog new Box { RelativeSizeAxes = Axes.Both, - Size = new OpenTK.Vector2(1), + Size = new Vector2(1), Alpha = 0, AlwaysPresent = true, - Colour = purple, + Colour = Purple, } } }, - headerTextContainer = new FillFlowContainer + new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, @@ -98,7 +96,7 @@ namespace osu.Game.Overlays.Changelog X = icon_size + icon_margin * 2, Children = new Drawable[] { - title = new OsuSpriteText + new OsuSpriteText { Text = "Changelog ", Font = @"Exo2.0-Light", @@ -109,13 +107,13 @@ namespace osu.Game.Overlays.Changelog Text = "Listing", TextSize = 38, // web: 30 Font = @"Exo2.0-Light", - Colour = purple, + Colour = Purple, }, } } } }, - breadcrumbContainer = new FillFlowContainer // Listing > Lazer 2018.713.1 + new FillFlowContainer // Listing > Lazer 2018.713.1 { X = 2 * icon_margin + icon_size - 8, Height = version_height, @@ -124,12 +122,12 @@ namespace osu.Game.Overlays.Changelog Direction = FillDirection.Horizontal, Children = new Drawable[] { - listing = new TextBadgePairListing(purple), - new Container() // without a container, moving the chevron wont work + listing = new TextBadgePairListing(Purple), + new Container // without a container, moving the chevron wont work { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - Margin = new MarginPadding() + Margin = new MarginPadding { Top = 10, Left = 7, @@ -145,19 +143,19 @@ namespace osu.Game.Overlays.Changelog Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(7), - Colour = purple, + Colour = Purple, Icon = FontAwesome.fa_chevron_right, Alpha = 0, X = -200, }, }, }, - releaseStream = new TextBadgePairRelease(purple, "Lazer") + releaseStream = new TextBadgePairRelease(Purple, "Lazer") }, }, new Box // purple line { - Colour = purple, + Colour = Purple, RelativeSizeAxes = Axes.X, Height = 3, Anchor = Anchor.BottomLeft, @@ -177,7 +175,7 @@ namespace osu.Game.Overlays.Changelog { releaseStream.Deactivate(); chevron.MoveToX(-20, 100).FadeOut(100); - ChangeHeaderText("Listing"); + changeHeaderText("Listing"); OnListingActivated?.Invoke(); }; }; @@ -186,10 +184,10 @@ namespace osu.Game.Overlays.Changelog public void ShowReleaseStream(string headerText, string breadcrumbText) { releaseStream.Activate(breadcrumbText); - ChangeHeaderText(headerText); + changeHeaderText(headerText); } - private void ChangeHeaderText(string headerText) + private void changeHeaderText(string headerText) { titleStream.Text = headerText; titleStream.FlashColour(Color4.White, 500, Easing.OutQuad); @@ -197,6 +195,8 @@ namespace osu.Game.Overlays.Changelog public void ActivateListing() => listing.Activate(); + public bool IsListingActivated() => listing.IsActivated; + [BackgroundDependencyLoader] private void load(TextureStore textures) { diff --git a/osu.Game/Overlays/Changelog/ChangelogStreams.cs b/osu.Game/Overlays/Changelog/ChangelogStreams.cs index 99c9c0accd..f0848188c8 100644 --- a/osu.Game/Overlays/Changelog/ChangelogStreams.cs +++ b/osu.Game/Overlays/Changelog/ChangelogStreams.cs @@ -3,32 +3,28 @@ using OpenTK.Graphics; using osu.Framework.Configuration; -using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Input; using osu.Game.Graphics; using osu.Game.Overlays.Changelog.Streams; -using System; namespace osu.Game.Overlays.Changelog { public class ChangelogStreams : Container { - private const float containerHeight = 106.5f; - private const float containerTopBottomMargin = 20; - private const float containerSideMargin = 85; + private const float container_height = 106.5f; + private const float container_margin_y = 20; + private const float container_margin_x = 85; public Bindable SelectedRelease = new Bindable(); - private readonly StreamColour streamColour; - public readonly FillFlowContainer badgesContainer; + public readonly FillFlowContainer BadgesContainer; public ChangelogStreams() { - streamColour = new StreamColour(); - Height = containerHeight; + Height = container_height; RelativeSizeAxes = Axes.X; Children = new Drawable[] { @@ -38,39 +34,39 @@ namespace osu.Game.Overlays.Changelog Size = new OpenTK.Vector2(1), Colour = new Color4(32, 24, 35, 255), }, - badgesContainer = new FillFlowContainer + BadgesContainer = new FillFlowContainer { Direction = FillDirection.Horizontal, RelativeSizeAxes = Axes.Both, - Margin = new MarginPadding() + Margin = new MarginPadding { - Top = containerTopBottomMargin, - Bottom = containerTopBottomMargin, - Left = containerSideMargin, - Right = containerSideMargin, + Top = container_margin_y, + Bottom = container_margin_y, + Left = container_margin_x, + Right = container_margin_x, }, Children = new[] { - new StreamBadge(streamColour.Stable, "Stable", "20180626.1", 16370, true), - new StreamBadge(streamColour.Beta, "Beta", "20180626", 186), - new StreamBadge(streamColour.Lazer, "Lazer", "2018.713.1"), + new StreamBadge(StreamColour.STABLE, "Stable", "20180626.1", 16370, true), + new StreamBadge(StreamColour.BETA, "Beta", "20180626", 186), + new StreamBadge(StreamColour.LAZER, "Lazer", "2018.713.1"), }, }, }; - badgesContainer.OnLoadComplete = d => + BadgesContainer.OnLoadComplete = d => { - foreach (StreamBadge streamBadge in badgesContainer.Children) + foreach (StreamBadge streamBadge in BadgesContainer.Children) { streamBadge.OnActivation = () => { - SelectedRelease.Value = new ReleaseStreamInfo() + SelectedRelease.Value = new ReleaseStreamInfo { DisplayVersion = streamBadge.DisplayVersion, IsFeatured = streamBadge.IsFeatured, Name = streamBadge.Name, Users = streamBadge.Users, }; - foreach (StreamBadge item in badgesContainer.Children) + foreach (StreamBadge item in BadgesContainer.Children) { if (item.Name != streamBadge.Name) item.Deactivate(); } @@ -82,7 +78,7 @@ namespace osu.Game.Overlays.Changelog protected override bool OnHover(InputState state) { // is this nullreference-safe for badgesContainer? - foreach (StreamBadge streamBadge in badgesContainer.Children) + foreach (StreamBadge streamBadge in BadgesContainer.Children) { if (SelectedRelease.Value != null) { @@ -100,7 +96,7 @@ namespace osu.Game.Overlays.Changelog { if (SelectedRelease.Value == null) { - foreach (StreamBadge streamBadge in badgesContainer.Children) streamBadge.Activate(true); + foreach (StreamBadge streamBadge in BadgesContainer.Children) streamBadge.Activate(true); } base.OnHoverLost(state); } diff --git a/osu.Game/Overlays/Changelog/Header/LineBadge.cs b/osu.Game/Overlays/Changelog/Header/LineBadge.cs index c33244d50b..93eca528c5 100644 --- a/osu.Game/Overlays/Changelog/Header/LineBadge.cs +++ b/osu.Game/Overlays/Changelog/Header/LineBadge.cs @@ -8,18 +8,20 @@ namespace osu.Game.Overlays.Changelog.Header { public class LineBadge : Circle { - public float TransitionDuration = 100; + public float TransitionDuration = 400; public float UncollapsedHeight; public float CollapsedHeight; - protected bool isCollapsed; + private bool isCollapsed; public bool IsCollapsed { get { return isCollapsed; } set { isCollapsed = value; - this.ResizeHeightTo(value ? CollapsedHeight : UncollapsedHeight, TransitionDuration); + this.ResizeHeightTo(value ? CollapsedHeight : UncollapsedHeight, + value ? TransitionDuration / 2f : TransitionDuration, + value ? Easing.Out : Easing.OutElastic); } } @@ -32,7 +34,7 @@ namespace osu.Game.Overlays.Changelog.Header Height = startCollapsed ? CollapsedHeight : UncollapsedHeight; // this margin prevents jumps when changing text's font weight - Margin = new MarginPadding() + Margin = new MarginPadding { Left = 10, Right = 10, diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs index 6482a69bb9..a888c436cf 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -1,45 +1,51 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Framework.Input; using System; namespace osu.Game.Overlays.Changelog.Header { - public class TextBadgePair : ClickableContainer + public class TextBadgePair : Container { - protected SpriteText text; - protected LineBadge lineBadge; - protected bool startCollapsed; + protected SpriteText Text; + protected LineBadge LineBadge; + public bool IsActivated { get; protected set; } public Action OnActivation; public Action OnDeactivation; + private SampleChannel sampleHover; + protected SampleChannel SampleActivate; public void SetTextColour(ColourInfo newColour, double duration = 0, Easing easing = Easing.None) { - text.FadeColour(newColour, duration, easing); + Text.FadeColour(newColour, duration, easing); } public void SetBadgeColour(ColourInfo newColour, double duration = 0, Easing easing = Easing.None) { - lineBadge.FadeColour(newColour, duration, easing); + LineBadge.FadeColour(newColour, duration, easing); } public void HideText(double duration = 0, Easing easing = Easing.InOutCubic) { - lineBadge.IsCollapsed = true; - text.MoveToY(20, duration, easing) + LineBadge.IsCollapsed = true; + Text.MoveToY(20, duration, easing) .FadeOut(duration, easing); } public void ShowText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) { - lineBadge.IsCollapsed = false; - if (!string.IsNullOrEmpty(displayText)) text.Text = displayText; - text.MoveToY(0, duration, easing) + LineBadge.IsCollapsed = false; + if (!string.IsNullOrEmpty(displayText)) Text.Text = displayText; + Text.MoveToY(0, duration, easing) .FadeIn(duration, easing); } @@ -48,8 +54,8 @@ namespace osu.Game.Overlays.Changelog.Header /// Full change takes double this time. public void ChangeText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) { - lineBadge.IsCollapsed = true; - text.MoveToY(20, duration, easing) + LineBadge.IsCollapsed = true; + Text.MoveToY(20, duration, easing) .FadeOut(duration, easing) .Then() .MoveToY(0, duration, easing) @@ -60,30 +66,30 @@ namespace osu.Game.Overlays.Changelog.Header // didn't apply to transforms that come after the .finally), I'm using a scheduler here Scheduler.AddDelayed(() => { - if (!string.IsNullOrEmpty(displayText)) text.Text = displayText; - lineBadge.IsCollapsed = false; + if (!string.IsNullOrEmpty(displayText)) Text.Text = displayText; + LineBadge.IsCollapsed = false; }, duration); } - public TextBadgePair(ColourInfo badgeColour, string displayText = "Listing", bool startBadgeCollapsed = true) + public TextBadgePair(ColourInfo badgeColour, string displayText = "Listing", bool startCollapsed = true) { AutoSizeAxes = Axes.X; RelativeSizeAxes = Axes.Y; Children = new Drawable[] { - text = new SpriteText + Text = new SpriteText { TextSize = 21, // web is 16, but here it looks too small? Text = displayText, Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft, - Margin = new MarginPadding() + Margin = new MarginPadding { Top = 5, Bottom = 15, } }, - lineBadge = new LineBadge(startCollapsed) + LineBadge = new LineBadge(startCollapsed) { Width = 1, Colour = badgeColour, @@ -94,14 +100,30 @@ namespace osu.Game.Overlays.Changelog.Header public virtual void Deactivate() { - lineBadge.IsCollapsed = true; - text.Font = "Exo2.0-Regular"; + IsActivated = false; + LineBadge.IsCollapsed = true; + Text.Font = "Exo2.0-Regular"; } public virtual void Activate() { - lineBadge.IsCollapsed = false; - text.Font = "Exo2.0-Bold"; + IsActivated = true; + LineBadge.IsCollapsed = false; + Text.Font = "Exo2.0-Bold"; + SampleActivate?.Play(); + } + + protected override bool OnHover(InputState state) + { + if (!IsActivated) sampleHover?.Play(); + return base.OnHover(state); + } + + [BackgroundDependencyLoader] + private void load(AudioManager audio) + { + sampleHover = audio.Sample.Get(@"UI/generic-hover-soft"); + SampleActivate = audio.Sample.Get(@"UI/generic-select-soft"); } } } diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs index 0e12e1a2c5..eaf7e1289b 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs @@ -10,37 +10,41 @@ namespace osu.Game.Overlays.Changelog.Header { public class TextBadgePairListing : TextBadgePair { - private ColourInfo badgeColour; + private readonly ColourInfo badgeColour; public TextBadgePairListing(ColourInfo badgeColour) : base(badgeColour, "Listing", false) { + IsActivated = true; this.badgeColour = badgeColour; - text.Font = "Exo2.0-Bold"; - text.Anchor = Anchor.TopCentre; - text.Origin = Anchor.TopCentre; + Text.Font = "Exo2.0-Bold"; + Text.Anchor = Anchor.TopCentre; + Text.Origin = Anchor.TopCentre; // I'm using this for constant badge width here, so that the whole // thing doesn't jump left/right when listing's size changes // due to different font weight (and thus width) - lineBadge.RelativeSizeAxes = Axes.None; + LineBadge.RelativeSizeAxes = Axes.None; // this doesn't work without the scheduler // (because the text isn't yet fully drawn when it's loaded?) - text.OnLoadComplete = d => Scheduler.Add(UpdateBadgeWidth); + Text.OnLoadComplete = d => Scheduler.Add(UpdateBadgeWidth); } public override void Activate() { - lineBadge.IsCollapsed = false; - text.Font = "Exo2.0-Bold"; + IsActivated = true; + LineBadge.IsCollapsed = false; + Text.Font = "Exo2.0-Bold"; SetTextColour(Color4.White, 100); + SampleActivate?.Play(); OnActivation?.Invoke(); } public override void Deactivate() { - lineBadge.IsCollapsed = true; - text.Font = "Exo2.0-Regular"; // commented out since it makes bad resize-jumping + IsActivated = false; + LineBadge.IsCollapsed = true; + Text.Font = "Exo2.0-Regular"; // commented out since it makes bad resize-jumping SetTextColour(badgeColour, 100); OnDeactivation?.Invoke(); } @@ -53,16 +57,16 @@ namespace osu.Game.Overlays.Changelog.Header protected override bool OnHover(InputState state) { - lineBadge.ResizeHeightTo(lineBadge.UncollapsedHeight, lineBadge.TransitionDuration); + LineBadge.ResizeHeightTo(LineBadge.UncollapsedHeight, LineBadge.TransitionDuration, Easing.OutElastic); return base.OnHover(state); } protected override void OnHoverLost(InputState state) { - if (lineBadge.IsCollapsed) lineBadge.ResizeHeightTo(1, lineBadge.TransitionDuration); + if (IsActivated == false) LineBadge.ResizeHeightTo(1, LineBadge.TransitionDuration, Easing.Out); base.OnHoverLost(state); } - public void UpdateBadgeWidth() => lineBadge.ResizeWidthTo(text.DrawWidth); + public void UpdateBadgeWidth() => LineBadge.ResizeWidthTo(Text.DrawWidth); } } diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs index d2fed56214..2186043035 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs @@ -12,29 +12,34 @@ namespace osu.Game.Overlays.Changelog.Header public TextBadgePairRelease(ColourInfo badgeColour, string displayText) : base(badgeColour, displayText) { - text.Font = "Exo2.0-Bold"; - text.Y = 20; - text.Alpha = 0; + Text.Font = "Exo2.0-Bold"; + Text.Y = 20; + Text.Alpha = 0; } public void SetText(string displayText) { - text.Text = displayText; + Text.Text = displayText; } public void Activate(string displayText = null) { - //ClearTransforms(); - // not using if (!lineBadge.IsCollapsed) because the text sometimes gets reset - // when quickly switching release streams - if (text.IsPresent) ChangeText(transition_duration, displayText); - else ShowText(transition_duration, displayText); + if (IsActivated) + { + if (displayText != Text.Text) ChangeText(transition_duration, displayText); + } + else + { + ShowText(transition_duration, displayText); + IsActivated = true; + } + SampleActivate?.Play(); OnActivation?.Invoke(); } public override void Deactivate() { - //FinishTransforms(true); + IsActivated = false; HideText(transition_duration); OnDeactivation?.Invoke(); } diff --git a/osu.Game/Overlays/Changelog/ReleaseStreamInfo.cs b/osu.Game/Overlays/Changelog/ReleaseStreamInfo.cs index 90b2ab6cfb..2934ae8f94 100644 --- a/osu.Game/Overlays/Changelog/ReleaseStreamInfo.cs +++ b/osu.Game/Overlays/Changelog/ReleaseStreamInfo.cs @@ -2,13 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using Newtonsoft.Json; -using osu.Game.Database; using osu.Game.IO.Serialization; -using osu.Game.Rulesets; namespace osu.Game.Overlays.Changelog { diff --git a/osu.Game/Overlays/Changelog/Streams/StreamBadge.cs b/osu.Game/Overlays/Changelog/Streams/StreamBadge.cs index 9b70c9ce7f..8bd10dcbb8 100644 --- a/osu.Game/Overlays/Changelog/Streams/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/Streams/StreamBadge.cs @@ -1,12 +1,13 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Input; using System; @@ -15,21 +16,20 @@ namespace osu.Game.Overlays.Changelog.Streams { public class StreamBadge : ClickableContainer { - private const float badgeHeight = 56.5f; - private const float badgeWidth = 100; - private const float badgeTopBottomMargin = 5; + private const float badge_height = 56.5f; + private const float badge_width = 100; private const float transition_duration = 100; public Action OnActivation; - private bool isActive; + private bool isActivated; - private Header.LineBadge lineBadge; - - public string Name { get; private set; } - public string DisplayVersion { get; private set; } - public bool IsFeatured { get; private set; } - public float Users { get; private set; } + private readonly Header.LineBadge lineBadge; + private SampleChannel sampleHover; + public readonly string Name; + public readonly string DisplayVersion; + public readonly bool IsFeatured; + public readonly float Users; public StreamBadge(ColourInfo colour, string streamName, string streamBuild, float onlineUsers = 0, bool isFeatured = false) { @@ -37,10 +37,10 @@ namespace osu.Game.Overlays.Changelog.Streams DisplayVersion = streamBuild; IsFeatured = isFeatured; Users = onlineUsers; - Height = badgeHeight; - Width = isFeatured ? badgeWidth * 2 : badgeWidth; + Height = badge_height; + Width = isFeatured ? badge_width * 2 : badge_width; Margin = new MarginPadding(5); - isActive = true; + isActivated = true; Children = new Drawable[] { new FillFlowContainer @@ -84,13 +84,14 @@ namespace osu.Game.Overlays.Changelog.Streams Width = 1, Colour = colour, RelativeSizeAxes = Axes.X, + TransitionDuration = 600, }, }; } public void Activate(bool withoutHeaderUpdate = false) { - isActive = true; + isActivated = true; this.FadeIn(transition_duration); lineBadge.IsCollapsed = false; if (!withoutHeaderUpdate) OnActivation?.Invoke(); @@ -98,9 +99,12 @@ namespace osu.Game.Overlays.Changelog.Streams public void Deactivate() { - isActive = false; - this.FadeTo(0.5f, transition_duration); - lineBadge.IsCollapsed = true; + isActivated = false; + if (!IsHovered) + { + this.FadeTo(0.5f, transition_duration); + lineBadge.IsCollapsed = true; + } } protected override bool OnClick(InputState state) @@ -111,6 +115,7 @@ namespace osu.Game.Overlays.Changelog.Streams protected override bool OnHover(InputState state) { + if (!isActivated) sampleHover?.Play(); this.FadeIn(transition_duration); lineBadge.IsCollapsed = false; return base.OnHover(state); @@ -118,12 +123,18 @@ namespace osu.Game.Overlays.Changelog.Streams protected override void OnHoverLost(InputState state) { - if (!isActive) + if (!isActivated) { this.FadeTo(0.5f, transition_duration); lineBadge.IsCollapsed = true; } base.OnHoverLost(state); } + + [BackgroundDependencyLoader] + private void load(AudioManager audio) + { + sampleHover = audio.Sample.Get(@"UI/generic-hover-soft"); + } } } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 20061317d2..f928f9ee58 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.Containers; +using osu.Game.Input.Bindings; using osu.Game.Overlays.Changelog; using osu.Game.Overlays.Changelog.Streams; @@ -16,12 +17,10 @@ namespace osu.Game.Overlays { public class ChangelogOverlay : WaveOverlayContainer { - private readonly ScrollContainer scroll; + private readonly ChangelogHeader header; + public readonly ChangelogStreams Streams; - private ChangelogHeader header; - public readonly ChangelogStreams streams; - - protected Color4 purple = new Color4(191, 4, 255, 255); + protected readonly Color4 Purple = new Color4(191, 4, 255, 255); public ChangelogOverlay() { @@ -52,7 +51,7 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.Both, Colour = new Color4(20, 18, 23, 255) }, - scroll = new ScrollContainer + new ScrollContainer { RelativeSizeAxes = Axes.Both, ScrollbarVisible = false, @@ -64,25 +63,25 @@ namespace osu.Game.Overlays Children = new Drawable[] { header = new ChangelogHeader(), - streams = new ChangelogStreams(), + Streams = new ChangelogStreams(), }, }, }, }; - streams.SelectedRelease.ValueChanged += r => + Streams.SelectedRelease.ValueChanged += r => { - if (streams.SelectedRelease.Value != null) + if (Streams.SelectedRelease.Value != null) header.ShowReleaseStream(r.Name, string.Join(" ", r.Name, r.DisplayVersion)); }; - streams.badgesContainer.OnLoadComplete += d => + Streams.BadgesContainer.OnLoadComplete += d => { header.OnListingActivated += () => { - streams.SelectedRelease.Value = null; - foreach (StreamBadge item in streams.badgesContainer.Children) - { - item.Activate(true); - } + Streams.SelectedRelease.Value = null; + if (!Streams.IsHovered) + foreach (StreamBadge item in Streams.BadgesContainer.Children) item.Activate(true); + else + foreach (StreamBadge item in Streams.BadgesContainer.Children) item.Deactivate(); }; }; } @@ -92,6 +91,24 @@ namespace osu.Game.Overlays // receive input outside our bounds so we can trigger a close event on ourselves. public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; + public override bool OnPressed(GlobalAction action) + { + switch (action) + { + case GlobalAction.Back: + if (header.IsListingActivated()) State = Visibility.Hidden; + + // the problem here is that when hovering over the builds' container + // and pressing back, they don't lower their opacity they're rehovered on + else header.ActivateListing(); + return true; + case GlobalAction.Select: + return true; + } + + return false; + } + protected override void PopIn() { base.PopIn(); From bcd132e87f99bacbe1d91f7e7e69abfe83371ddc Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Thu, 19 Jul 2018 19:07:24 +0200 Subject: [PATCH 008/375] API1 --- osu.Game.Tests/Visual/TestCaseChangelog.cs | 16 ++- osu.Game/Graphics/StreamColour.cs | 19 +++ .../UserInterface/TooltipIconButton.cs | 43 +++++++ .../GetChangelogLatestBuildsRequest.cs | 17 +++ .../API/Requests/GetChangelogRequest.cs | 13 +++ .../API/Requests/Responses/APIChangelog.cs | 54 +++++++++ osu.Game/Overlays/Changelog/ChangelogChart.cs | 36 ++++++ .../Overlays/Changelog/ChangelogContent.cs | 18 +++ .../Changelog/ChangelogContentGroup.cs | 109 ++++++++++++++++++ .../Overlays/Changelog/ChangelogHeader.cs | 10 +- .../Overlays/Changelog/ChangelogStreams.cs | 36 +++--- .../Overlays/Changelog/ReleaseStreamInfo.cs | 19 --- .../Changelog/{Streams => }/StreamBadge.cs | 29 ++--- osu.Game/Overlays/ChangelogOverlay.cs | 62 ++++++++-- 14 files changed, 399 insertions(+), 82 deletions(-) create mode 100644 osu.Game/Graphics/UserInterface/TooltipIconButton.cs create mode 100644 osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs create mode 100644 osu.Game/Online/API/Requests/GetChangelogRequest.cs create mode 100644 osu.Game/Online/API/Requests/Responses/APIChangelog.cs create mode 100644 osu.Game/Overlays/Changelog/ChangelogChart.cs create mode 100644 osu.Game/Overlays/Changelog/ChangelogContent.cs create mode 100644 osu.Game/Overlays/Changelog/ChangelogContentGroup.cs delete mode 100644 osu.Game/Overlays/Changelog/ReleaseStreamInfo.cs rename osu.Game/Overlays/Changelog/{Streams => }/StreamBadge.cs (81%) diff --git a/osu.Game.Tests/Visual/TestCaseChangelog.cs b/osu.Game.Tests/Visual/TestCaseChangelog.cs index da568e0eb3..894b117118 100644 --- a/osu.Game.Tests/Visual/TestCaseChangelog.cs +++ b/osu.Game.Tests/Visual/TestCaseChangelog.cs @@ -10,9 +10,9 @@ namespace osu.Game.Tests.Visual public class TestCaseChangelog : OsuTestCase { private ChangelogOverlay changelog; - private int releaseStreamCount; private int index; - private void indexIncrement() => index = index == releaseStreamCount - 1 ? 0 : index + 1; + private void indexIncrement() => index = index >= changelog.Streams.BadgesContainer.Children.Count - 1 ? 0 : index + 1; + private bool isLoaded => changelog.Streams.BadgesContainer.Children.Count > 0; protected override void LoadComplete() { @@ -20,20 +20,18 @@ namespace osu.Game.Tests.Visual Add(changelog = new ChangelogOverlay()); - releaseStreamCount = changelog.Streams.BadgesContainer.Children.Count; - AddStep(@"Show", changelog.Show); AddRepeatStep(@"Toggle Release Stream", () => { - changelog.Streams.BadgesContainer.Children[index].Activate(); + if (isLoaded) changelog.Streams.BadgesContainer.Children[index].Activate(); indexIncrement(); - }, releaseStreamCount); + }, 6); AddStep(@"Listing", changelog.ActivateListing); AddStep(@"Hide", changelog.Hide); AddWaitStep(3); AddStep(@"Show with Release Stream", () => { - changelog.Streams.BadgesContainer.Children[index].Activate(); + if (isLoaded) changelog.Streams.BadgesContainer.Children[index].Activate(); changelog.Show(); indexIncrement(); }); @@ -45,12 +43,12 @@ namespace osu.Game.Tests.Visual changelog.ActivateListing(); changelog.Show(); }); - AddWaitStep(4); + AddWaitStep(3); AddStep(@"Hide", changelog.Hide); AddWaitStep(3); AddStep(@"Activate release", () => { - changelog.Streams.BadgesContainer.Children[index].Activate(); + if (isLoaded) changelog.Streams.BadgesContainer.Children[index].Activate(); indexIncrement(); }); AddStep(@"Show with listing", () => diff --git a/osu.Game/Graphics/StreamColour.cs b/osu.Game/Graphics/StreamColour.cs index 0da0201c06..2a0d7fceab 100644 --- a/osu.Game/Graphics/StreamColour.cs +++ b/osu.Game/Graphics/StreamColour.cs @@ -2,6 +2,8 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; +using osu.Framework.Graphics.Colour; +using System.Collections.Generic; namespace osu.Game.Graphics { @@ -13,5 +15,22 @@ namespace osu.Game.Graphics public static readonly Color4 CUTTINGEDGE = new Color4(238, 170, 0, 255); public static readonly Color4 LAZER = new Color4(237, 18, 33, 255); public static readonly Color4 WEB = new Color4(136, 102, 238, 255); + + private static readonly Dictionary colours = new Dictionary + { + { "stable40", STABLE }, + { "stable", STABLEFALLBACK }, + { "beta40", BETA }, + { "cuttingedge", CUTTINGEDGE }, + { "lazer", LAZER }, + { "web", WEB }, + }; + + public static ColourInfo FromStreamName(string name) + { + if (colours.TryGetValue(name, out ColourInfo colour)) + return colour; + else return new Color4(255, 255, 255, 255); + } } } diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs new file mode 100644 index 0000000000..918e203bf4 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs @@ -0,0 +1,43 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics.Containers; + +namespace osu.Game.Graphics.UserInterface +{ + public class TooltipIconButton : OsuClickableContainer, IHasTooltip + { + private readonly SpriteIcon icon; + + public FontAwesome Icon + { + get { return icon.Icon; } + set { icon.Icon = value; } + } + + public TooltipIconButton() + { + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0, + }, + icon = new SpriteIcon + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Size = new Vector2(18), + } + }; + } + + + public string TooltipText { get; set; } + } +} diff --git a/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs b/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs new file mode 100644 index 0000000000..845760f2e4 --- /dev/null +++ b/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs @@ -0,0 +1,17 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Online.API.Requests.Responses; +using System.Collections.Generic; + +namespace osu.Game.Online.API.Requests +{ + /// + /// Obviously a placeholder + /// + public class GetChangelogLatestBuildsRequest : APIRequest> + { + protected override string Uri => Target; + protected override string Target => @"https://api.myjson.com/bins/16waui"; + } +} diff --git a/osu.Game/Online/API/Requests/GetChangelogRequest.cs b/osu.Game/Online/API/Requests/GetChangelogRequest.cs new file mode 100644 index 0000000000..652e638ab8 --- /dev/null +++ b/osu.Game/Online/API/Requests/GetChangelogRequest.cs @@ -0,0 +1,13 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Online.API.Requests.Responses; + +namespace osu.Game.Online.API.Requests +{ + public class GetChangelogRequest : APIRequest + { + protected override string Uri => Target; + protected override string Target => "https://api.myjson.com/bins/6zv2i"; + } +} diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelog.cs b/osu.Game/Online/API/Requests/Responses/APIChangelog.cs new file mode 100644 index 0000000000..f0dcafdc04 --- /dev/null +++ b/osu.Game/Online/API/Requests/Responses/APIChangelog.cs @@ -0,0 +1,54 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using Newtonsoft.Json; +using System; +using System.Collections.Generic; + +namespace osu.Game.Online.API.Requests.Responses +{ + public class APIChangelog + { + [JsonProperty("id")] + public long Id { get; set; } + + [JsonProperty("version")] + public string Version { get; set; } + + [JsonProperty("display_version")] + public string DisplayVersion { get; set; } + + [JsonProperty("users")] + public long Users { get; set; } + + [JsonProperty("is_featured")] + public bool IsFeatured { get; set; } + + [JsonProperty("created_at")] + public DateTimeOffset CreatedAt { get; set; } + + [JsonProperty("disqus_id")] + public string DisqusId { get; set; } + + [JsonProperty("disqus_title")] + public string DisqusTitle { get; set; } + + [JsonProperty("update_stream")] + public UpdateStream UpdateStream { get; set; } + + [JsonProperty("changelog_entries")] + public List ChangelogEntries { get; set; } + } + + public class UpdateStream + { + [JsonProperty("id")] + public long Id { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("display_name")] + public string DisplayName { get; set; } + } +} diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs new file mode 100644 index 0000000000..e885867c74 --- /dev/null +++ b/osu.Game/Overlays/Changelog/ChangelogChart.cs @@ -0,0 +1,36 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; + +namespace osu.Game.Overlays.Changelog +{ + // maybe look to osu.Game.Screens.Play.SquareGraph for reference later + public class ChangelogChart : BufferedContainer + { + public ChangelogChart() + { + RelativeSizeAxes = Axes.X; + Height = 100; + Children = new Drawable[] + { + new Box + { + Colour = StreamColour.STABLE, + RelativeSizeAxes = Axes.Both, + }, + new SpriteText + { + Text = "Graph Placeholder", + TextSize = 28, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, + }; + } + } +} diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs new file mode 100644 index 0000000000..d10fe19942 --- /dev/null +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -0,0 +1,18 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; + +namespace osu.Game.Overlays.Changelog +{ + public class ChangelogContent : FillFlowContainer + { + public ChangelogContent() + { + RelativeSizeAxes = Axes.X; + //AutoSizeAxes = Axes.Y; + Direction = FillDirection.Vertical; + } + } +} diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs new file mode 100644 index 0000000000..951cebb941 --- /dev/null +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -0,0 +1,109 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using osu.Game.Graphics.UserInterface; +using osu.Game.Online.API.Requests.Responses; + +namespace osu.Game.Overlays.Changelog +{ + public class ChangelogContentGroup : FillFlowContainer + { + // will porobably depend in some way on #1692 (https://github.com/ppy/osu-framework/pull/1692) + // need to keep in mind it looks different on Listing (one contains all builds from a date) + // and when a stream is selected (looks like now) + public ChangelogContentGroup(APIChangelog build) + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Direction = FillDirection.Vertical; + Padding = new MarginPadding + { + Left = 70, + Right = 70, + }; + Children = new Drawable[] + { + // build version, arrows + new FillFlowContainer + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Margin = new MarginPadding + { + Top = 20, + }, + Children = new Drawable[] + { + new TooltipIconButton + { + Icon = FontAwesome.fa_chevron_left, + Size = new Vector2(24), + // how do we link to previous/next builds? + // I'm thinking some linked list, but how do we make that + // from the available API data + TooltipText = "Previous", + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Margin = new MarginPadding + { + Left = 40, + Right = 40, + }, + Children = new[] + { + new SpriteText + { + Text = build.UpdateStream.DisplayName, + TextSize = 28, // web: 24, + Font = @"Exo2.0-Medium", + }, + new SpriteText // a space... + { + Text = " ", + TextSize = 28, + }, + new SpriteText + { + Text = build.DisplayVersion, + TextSize = 28, // web: 24, + Colour = StreamColour.STABLE, + }, + } + }, + new TooltipIconButton + { + Icon = FontAwesome.fa_chevron_right, + Size = new Vector2(24), + TooltipText = "Next", + }, + } + }, + new SpriteText + { + // do we need .ToUniversalTime() here? + // also, this is a temporary solution to weekdays in >localized< date strings + Text = build.CreatedAt.Date.ToLongDateString().Replace(build.CreatedAt.ToString("dddd") + ", ", ""), + TextSize = 17, // web: 14, + Colour = OsuColour.FromHex(@"FD5"), + Font = @"Exo2.0-Medium", + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Margin = new MarginPadding + { + Top = 5, + }, + }, + }; + } + //public ChangelogContentGroup(DateTimeOffset date) { } + } +} diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index ebf666b1d8..8332aeeaa4 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.Changelog.Header; using System; @@ -27,6 +28,8 @@ namespace osu.Game.Overlays.Changelog public Action OnListingActivated; + public APIChangelog ChangelogEntry; + private const float cover_height = 310; private const float title_height = 50; private const float icon_size = 50; @@ -181,10 +184,11 @@ namespace osu.Game.Overlays.Changelog }; } - public void ShowReleaseStream(string headerText, string breadcrumbText) + public void ShowReleaseStream() { - releaseStream.Activate(breadcrumbText); - changeHeaderText(headerText); + releaseStream.Activate(String.Join(" ", + ChangelogEntry.UpdateStream.DisplayName, ChangelogEntry.DisplayVersion)); + changeHeaderText(ChangelogEntry.UpdateStream.DisplayName); } private void changeHeaderText(string headerText) diff --git a/osu.Game/Overlays/Changelog/ChangelogStreams.cs b/osu.Game/Overlays/Changelog/ChangelogStreams.cs index f0848188c8..b857a23653 100644 --- a/osu.Game/Overlays/Changelog/ChangelogStreams.cs +++ b/osu.Game/Overlays/Changelog/ChangelogStreams.cs @@ -2,13 +2,12 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Input; -using osu.Game.Graphics; -using osu.Game.Overlays.Changelog.Streams; +using osu.Game.Online.API.Requests.Responses; +using System; namespace osu.Game.Overlays.Changelog { @@ -17,8 +16,9 @@ namespace osu.Game.Overlays.Changelog private const float container_height = 106.5f; private const float container_margin_y = 20; private const float container_margin_x = 85; + public Action OnSelection; - public Bindable SelectedRelease = new Bindable(); + public APIChangelog SelectedRelease; public readonly FillFlowContainer BadgesContainer; @@ -45,31 +45,23 @@ namespace osu.Game.Overlays.Changelog Left = container_margin_x, Right = container_margin_x, }, - Children = new[] - { - new StreamBadge(StreamColour.STABLE, "Stable", "20180626.1", 16370, true), - new StreamBadge(StreamColour.BETA, "Beta", "20180626", 186), - new StreamBadge(StreamColour.LAZER, "Lazer", "2018.713.1"), - }, }, }; - BadgesContainer.OnLoadComplete = d => + // ok, so this is probably not the best. + // will need to reflect on this. + // do we need the changelog to be updateable? + BadgesContainer.OnUpdate = d => { foreach (StreamBadge streamBadge in BadgesContainer.Children) { streamBadge.OnActivation = () => { - SelectedRelease.Value = new ReleaseStreamInfo - { - DisplayVersion = streamBadge.DisplayVersion, - IsFeatured = streamBadge.IsFeatured, - Name = streamBadge.Name, - Users = streamBadge.Users, - }; + SelectedRelease = streamBadge.ChangelogEntry; foreach (StreamBadge item in BadgesContainer.Children) { - if (item.Name != streamBadge.Name) item.Deactivate(); + if (item.ChangelogEntry.Id != streamBadge.ChangelogEntry.Id) item.Deactivate(); } + OnSelection?.Invoke(); }; } }; @@ -80,9 +72,9 @@ namespace osu.Game.Overlays.Changelog // is this nullreference-safe for badgesContainer? foreach (StreamBadge streamBadge in BadgesContainer.Children) { - if (SelectedRelease.Value != null) + if (SelectedRelease != null) { - if (SelectedRelease.Value.Name != streamBadge.Name) + if (SelectedRelease.UpdateStream.Id != streamBadge.ChangelogEntry.Id) { streamBadge.Deactivate(); } @@ -94,7 +86,7 @@ namespace osu.Game.Overlays.Changelog protected override void OnHoverLost(InputState state) { - if (SelectedRelease.Value == null) + if (SelectedRelease == null) { foreach (StreamBadge streamBadge in BadgesContainer.Children) streamBadge.Activate(true); } diff --git a/osu.Game/Overlays/Changelog/ReleaseStreamInfo.cs b/osu.Game/Overlays/Changelog/ReleaseStreamInfo.cs deleted file mode 100644 index 2934ae8f94..0000000000 --- a/osu.Game/Overlays/Changelog/ReleaseStreamInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using osu.Game.IO.Serialization; - -namespace osu.Game.Overlays.Changelog -{ - [Serializable] - public class ReleaseStreamInfo : IJsonSerializable - { - public string Name; - public string DisplayVersion; - - public float Users; - - public bool IsFeatured; - } -} diff --git a/osu.Game/Overlays/Changelog/Streams/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs similarity index 81% rename from osu.Game/Overlays/Changelog/Streams/StreamBadge.cs rename to osu.Game/Overlays/Changelog/StreamBadge.cs index 8bd10dcbb8..578a95f583 100644 --- a/osu.Game/Overlays/Changelog/Streams/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -6,13 +6,14 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Input; +using osu.Game.Graphics; +using osu.Game.Online.API.Requests.Responses; using System; -namespace osu.Game.Overlays.Changelog.Streams +namespace osu.Game.Overlays.Changelog { public class StreamBadge : ClickableContainer { @@ -26,19 +27,13 @@ namespace osu.Game.Overlays.Changelog.Streams private readonly Header.LineBadge lineBadge; private SampleChannel sampleHover; - public readonly string Name; - public readonly string DisplayVersion; - public readonly bool IsFeatured; - public readonly float Users; + public readonly APIChangelog ChangelogEntry; - public StreamBadge(ColourInfo colour, string streamName, string streamBuild, float onlineUsers = 0, bool isFeatured = false) + public StreamBadge(APIChangelog changelogEntry) { - Name = streamName; - DisplayVersion = streamBuild; - IsFeatured = isFeatured; - Users = onlineUsers; + ChangelogEntry = changelogEntry; Height = badge_height; - Width = isFeatured ? badge_width * 2 : badge_width; + Width = ChangelogEntry.IsFeatured ? badge_width * 2 : badge_width; Margin = new MarginPadding(5); isActivated = true; Children = new Drawable[] @@ -52,7 +47,7 @@ namespace osu.Game.Overlays.Changelog.Streams { new SpriteText { - Text = streamName, + Text = ChangelogEntry.UpdateStream.DisplayName, Font = @"Exo2.0-Bold", TextSize = 16, Margin = new MarginPadding @@ -62,14 +57,14 @@ namespace osu.Game.Overlays.Changelog.Streams }, new SpriteText { - Text = streamBuild, + Text = ChangelogEntry.DisplayVersion, Font = @"Exo2.0-Light", TextSize = 21, }, new SpriteText { - Text = onlineUsers > 0 ? - string.Join(" ", onlineUsers.ToString("N0"), "users online"): + Text = ChangelogEntry.Users > 0 ? + string.Join(" ", ChangelogEntry.Users.ToString("N0"), "users online"): null, TextSize = 12, Font = @"Exo2.0-Regular", @@ -82,7 +77,7 @@ namespace osu.Game.Overlays.Changelog.Streams Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Width = 1, - Colour = colour, + Colour = StreamColour.FromStreamName(ChangelogEntry.UpdateStream.Name), RelativeSizeAxes = Axes.X, TransitionDuration = 600, }, diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index f928f9ee58..259036537b 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -3,6 +3,7 @@ using OpenTK; using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -10,8 +11,10 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Input.Bindings; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.Changelog; -using osu.Game.Overlays.Changelog.Streams; namespace osu.Game.Overlays { @@ -19,6 +22,9 @@ namespace osu.Game.Overlays { private readonly ChangelogHeader header; public readonly ChangelogStreams Streams; + private APIChangelog changelogEntry; + + private APIAccess api; protected readonly Color4 Purple = new Color4(191, 4, 255, 255); @@ -36,6 +42,8 @@ namespace osu.Game.Overlays Width = 0.85f; Masking = true; + ChangelogContent content; // told by appveyor to conver to local variable.. + EdgeEffect = new EdgeEffectParameters { Colour = Color4.Black.Opacity(0), @@ -64,25 +72,36 @@ namespace osu.Game.Overlays { header = new ChangelogHeader(), Streams = new ChangelogStreams(), + new ChangelogChart(), + // will need to default to day-sorted content + content = new ChangelogContent(), }, }, }, }; - Streams.SelectedRelease.ValueChanged += r => + Streams.OnSelection = () => { - if (Streams.SelectedRelease.Value != null) - header.ShowReleaseStream(r.Name, string.Join(" ", r.Name, r.DisplayVersion)); + if (Streams.SelectedRelease != null) + { + header.ChangelogEntry = Streams.SelectedRelease; + } + header.ShowReleaseStream(); + content.Clear(); + content.Add(new ChangelogContentGroup(Streams.SelectedRelease)); }; Streams.BadgesContainer.OnLoadComplete += d => { - header.OnListingActivated += () => - { - Streams.SelectedRelease.Value = null; - if (!Streams.IsHovered) - foreach (StreamBadge item in Streams.BadgesContainer.Children) item.Activate(true); - else - foreach (StreamBadge item in Streams.BadgesContainer.Children) item.Deactivate(); - }; + FetchChangelog(); + }; + header.OnListingActivated += () => + { + Streams.SelectedRelease = null; + content.Clear(); + // should add listing to content here + if (!Streams.IsHovered) + foreach (StreamBadge item in Streams.BadgesContainer.Children) item.Activate(true); + else + foreach (StreamBadge item in Streams.BadgesContainer.Children) item.Deactivate(); }; } @@ -120,5 +139,24 @@ namespace osu.Game.Overlays base.PopOut(); FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out); } + + [BackgroundDependencyLoader] + private void load(APIAccess api) + { + this.api = api; + } + + public void FetchChangelog() + { + var req = new GetChangelogLatestBuildsRequest(); + req.Success += res => + { + foreach (APIChangelog item in res) + { + Streams.BadgesContainer.Add(new StreamBadge(item)); + } + }; + api.Queue(req); + } } } From a9299423cd79a08c36b8e2a0054e8e1f8cca3482 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Thu, 19 Jul 2018 21:49:13 +0200 Subject: [PATCH 009/375] Refactor2 --- .../Input/Bindings/GlobalActionContainer.cs | 2 -- osu.Game/OsuGame.cs | 11 +------- osu.Game/Overlays/Changelog/ChangelogChart.cs | 1 + .../Overlays/Changelog/ChangelogContent.cs | 7 ++++- .../Changelog/ChangelogContentGroup.cs | 5 ++-- .../Overlays/Changelog/ChangelogHeader.cs | 9 ++---- .../Overlays/Changelog/ChangelogStreams.cs | 28 ++++++++++--------- .../Changelog/Header/TextBadgePair.cs | 10 ++----- .../Changelog/Header/TextBadgePairRelease.cs | 5 +--- osu.Game/Overlays/Changelog/StreamBadge.cs | 2 -- osu.Game/Overlays/ChangelogOverlay.cs | 8 ++---- .../Toolbar/ToolbarChangelogButton.cs | 22 --------------- 12 files changed, 36 insertions(+), 74 deletions(-) delete mode 100644 osu.Game/Overlays/Toolbar/ToolbarChangelogButton.cs diff --git a/osu.Game/Input/Bindings/GlobalActionContainer.cs b/osu.Game/Input/Bindings/GlobalActionContainer.cs index 00857b9c9b..b21deff509 100644 --- a/osu.Game/Input/Bindings/GlobalActionContainer.cs +++ b/osu.Game/Input/Bindings/GlobalActionContainer.cs @@ -63,8 +63,6 @@ namespace osu.Game.Input.Bindings ToggleChat, [Description("Toggle social overlay")] ToggleSocial, - [Description("Toggle changelog")] - ToggleChangelog, [Description("Reset input settings")] ResetInputSettings, [Description("Toggle toolbar")] diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 3eb4faf6aa..557b6e4469 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -53,8 +53,6 @@ namespace osu.Game private DialogOverlay dialogOverlay; - private ChangelogOverlay changelog; - private DirectOverlay direct; private SocialOverlay social; @@ -112,8 +110,6 @@ namespace osu.Game public void ToggleDirect() => direct.ToggleVisibility(); - public void ToggleChangelog() => changelog.ToggleVisibility(); - /// /// Close all game-wide overlays. /// @@ -285,7 +281,6 @@ namespace osu.Game loadComponentSingleFile(screenshotManager, Add); //overlay elements - loadComponentSingleFile(changelog = new ChangelogOverlay { Depth = -1 }, mainContent.Add); loadComponentSingleFile(direct = new DirectOverlay { Depth = -1 }, mainContent.Add); loadComponentSingleFile(social = new SocialOverlay { Depth = -1 }, mainContent.Add); loadComponentSingleFile(chat = new ChatOverlay { Depth = -1 }, mainContent.Add); @@ -320,7 +315,6 @@ namespace osu.Game dependencies.Cache(settings); dependencies.Cache(onscreenDisplay); dependencies.Cache(social); - dependencies.Cache(changelog); dependencies.Cache(direct); dependencies.Cache(chat); dependencies.Cache(userProfile); @@ -355,7 +349,7 @@ namespace osu.Game } // ensure only one of these overlays are open at once. - var singleDisplayOverlays = new OverlayContainer[] { chat, social, direct, changelog }; + var singleDisplayOverlays = new OverlayContainer[] { chat, social, direct }; overlays.AddRange(singleDisplayOverlays); foreach (var overlay in singleDisplayOverlays) @@ -465,9 +459,6 @@ namespace osu.Game case GlobalAction.ToggleSocial: social.ToggleVisibility(); return true; - case GlobalAction.ToggleChangelog: - changelog.ToggleVisibility(); - return true; case GlobalAction.ResetInputSettings: var sensitivity = frameworkConfig.GetBindable(FrameworkSetting.CursorSensitivity); diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs index e885867c74..b113a509ec 100644 --- a/osu.Game/Overlays/Changelog/ChangelogChart.cs +++ b/osu.Game/Overlays/Changelog/ChangelogChart.cs @@ -10,6 +10,7 @@ using osu.Game.Graphics; namespace osu.Game.Overlays.Changelog { // maybe look to osu.Game.Screens.Play.SquareGraph for reference later + // placeholder json file: https://api.myjson.com/bins/10ye8a public class ChangelogChart : BufferedContainer { public ChangelogChart() diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index d10fe19942..325ec802d4 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -11,8 +11,13 @@ namespace osu.Game.Overlays.Changelog public ChangelogContent() { RelativeSizeAxes = Axes.X; - //AutoSizeAxes = Axes.Y; + AutoSizeAxes = Axes.Y; Direction = FillDirection.Vertical; + Padding = new MarginPadding + { + Left = 70, + Right = 70, + }; } } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 951cebb941..9675cf91f5 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -75,7 +75,8 @@ namespace osu.Game.Overlays.Changelog { Text = build.DisplayVersion, TextSize = 28, // web: 24, - Colour = StreamColour.STABLE, + Font = @"Exo2.0-Light", + Colour = StreamColour.FromStreamName(build.UpdateStream.Name), }, } }, @@ -90,7 +91,7 @@ namespace osu.Game.Overlays.Changelog new SpriteText { // do we need .ToUniversalTime() here? - // also, this is a temporary solution to weekdays in >localized< date strings + // also, this should be a temporary solution to weekdays in >localized< date strings Text = build.CreatedAt.Date.ToLongDateString().Replace(build.CreatedAt.ToString("dddd") + ", ", ""), TextSize = 17, // web: 14, Colour = OsuColour.FromHex(@"FD5"), diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 8332aeeaa4..a95d66158b 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Changelog { protected Color4 Purple = new Color4(191, 4, 255, 255); private readonly Sprite coverImage; - private readonly Sprite headerBadge; //50x50, margin-right: 20 + private readonly Sprite headerBadge; private readonly OsuSpriteText titleStream; private readonly TextBadgePairListing listing; private readonly TextBadgePairRelease releaseStream; @@ -46,10 +46,7 @@ namespace osu.Game.Overlays.Changelog coverImage = new Sprite { RelativeSizeAxes = Axes.Both, - Size = new Vector2(1), FillMode = FillMode.Fill, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, }, new Container // this is the line badge-Changelog-Stream { @@ -79,11 +76,11 @@ namespace osu.Game.Overlays.Changelog // this box has 2 functions: // - ensures the circle doesn't disappear on the X and Y edges - // - lessens the white "contamination" on the circle (due to smoothing) + // - gets rid of the white "contamination" on the circle (due to smoothing) + // (https://i.imgur.com/SMuvWBZ.png) new Box { RelativeSizeAxes = Axes.Both, - Size = new Vector2(1), Alpha = 0, AlwaysPresent = true, Colour = Purple, diff --git a/osu.Game/Overlays/Changelog/ChangelogStreams.cs b/osu.Game/Overlays/Changelog/ChangelogStreams.cs index b857a23653..aded31cb47 100644 --- a/osu.Game/Overlays/Changelog/ChangelogStreams.cs +++ b/osu.Game/Overlays/Changelog/ChangelogStreams.cs @@ -14,42 +14,44 @@ namespace osu.Game.Overlays.Changelog public class ChangelogStreams : Container { private const float container_height = 106.5f; - private const float container_margin_y = 20; - private const float container_margin_x = 85; + private const float padding_y = 20; + private const float padding_x = 85; public Action OnSelection; public APIChangelog SelectedRelease; + // not using SelectedRelease as a Bindable and then using .OnValueChange instead of OnSelection + // because it doesn't "refresh" the selection if the same stream is chosen public readonly FillFlowContainer BadgesContainer; public ChangelogStreams() { - Height = container_height; + // this should actually be resizeable (https://streamable.com/yw2ug) + // if not, with small width:height ratio it cuts off right-most content RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, - Size = new OpenTK.Vector2(1), Colour = new Color4(32, 24, 35, 255), }, BadgesContainer = new FillFlowContainer { - Direction = FillDirection.Horizontal, - RelativeSizeAxes = Axes.Both, - Margin = new MarginPadding + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding { - Top = container_margin_y, - Bottom = container_margin_y, - Left = container_margin_x, - Right = container_margin_x, + Top = padding_y, + Bottom = padding_y, + Left = padding_x, + Right = padding_x, }, }, }; // ok, so this is probably not the best. - // will need to reflect on this. - // do we need the changelog to be updateable? + // how else can this be done? BadgesContainer.OnUpdate = d => { foreach (StreamBadge streamBadge in BadgesContainer.Children) diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs index a888c436cf..c14414c6c4 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -61,9 +61,8 @@ namespace osu.Game.Overlays.Changelog.Header .MoveToY(0, duration, easing) .FadeIn(duration, easing); - // since using .finally/.oncomplete after first fadeout made the badge - // not hide sometimes in visual tests(because FinishTransforms()/CancelTransforms() - // didn't apply to transforms that come after the .finally), I'm using a scheduler here + // since using .finally/.oncomplete after first fadeout made the badge not hide + // sometimes in visual tests (https://streamable.com/0qssq), I'm using a scheduler here Scheduler.AddDelayed(() => { if (!string.IsNullOrEmpty(displayText)) Text.Text = displayText; @@ -79,10 +78,8 @@ namespace osu.Game.Overlays.Changelog.Header { Text = new SpriteText { - TextSize = 21, // web is 16, but here it looks too small? + TextSize = 21, // web: 16, Text = displayText, - Anchor = Anchor.TopLeft, - Origin = Anchor.TopLeft, Margin = new MarginPadding { Top = 5, @@ -91,7 +88,6 @@ namespace osu.Game.Overlays.Changelog.Header }, LineBadge = new LineBadge(startCollapsed) { - Width = 1, Colour = badgeColour, RelativeSizeAxes = Axes.X, } diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs index 2186043035..339f9f26d6 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs @@ -17,10 +17,7 @@ namespace osu.Game.Overlays.Changelog.Header Text.Alpha = 0; } - public void SetText(string displayText) - { - Text.Text = displayText; - } + public void SetText(string displayText) => Text.Text = displayText; public void Activate(string displayText = null) { diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 578a95f583..4fa9b2de88 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -76,10 +76,8 @@ namespace osu.Game.Overlays.Changelog { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Width = 1, Colour = StreamColour.FromStreamName(ChangelogEntry.UpdateStream.Name), RelativeSizeAxes = Axes.X, - TransitionDuration = 600, }, }; } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 259036537b..7723ab7659 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -79,6 +79,7 @@ namespace osu.Game.Overlays }, }, }; + OnLoadComplete += d => FetchChangelog(); // is i Streams.OnSelection = () => { if (Streams.SelectedRelease != null) @@ -86,13 +87,9 @@ namespace osu.Game.Overlays header.ChangelogEntry = Streams.SelectedRelease; } header.ShowReleaseStream(); - content.Clear(); + content.Clear(); // this should probably happen with some transition content.Add(new ChangelogContentGroup(Streams.SelectedRelease)); }; - Streams.BadgesContainer.OnLoadComplete += d => - { - FetchChangelog(); - }; header.OnListingActivated += () => { Streams.SelectedRelease = null; @@ -151,6 +148,7 @@ namespace osu.Game.Overlays var req = new GetChangelogLatestBuildsRequest(); req.Success += res => { + Streams.BadgesContainer.Clear(); foreach (APIChangelog item in res) { Streams.BadgesContainer.Add(new StreamBadge(item)); diff --git a/osu.Game/Overlays/Toolbar/ToolbarChangelogButton.cs b/osu.Game/Overlays/Toolbar/ToolbarChangelogButton.cs deleted file mode 100644 index db4fd4ba07..0000000000 --- a/osu.Game/Overlays/Toolbar/ToolbarChangelogButton.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Allocation; -using osu.Game.Graphics; - -namespace osu.Game.Overlays.Toolbar -{ - public class ToolbarChangelogButton : ToolbarOverlayToggleButton - { - public ToolbarChangelogButton() - { - SetIcon(FontAwesome.fa_list); - } - - [BackgroundDependencyLoader(true)] - private void load(ChangelogOverlay changelog) - { - StateContainer = changelog; - } - } -} From a857999950aa380f1d0d15557dfc89c9d00b6a69 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Fri, 20 Jul 2018 00:52:50 +0200 Subject: [PATCH 010/375] Refactor3 --- osu.Game.Tests/Visual/TestCaseChangelog.cs | 21 +++++++++++++--- .../UserInterface/TooltipIconButton.cs | 25 +++++++++---------- .../API/Requests/Responses/APIChangelog.cs | 6 ----- .../Overlays/Changelog/ChangelogStreams.cs | 15 +++++------ .../Changelog/Header/TextBadgePair.cs | 6 +++-- .../Changelog/Header/TextBadgePairListing.cs | 3 ++- .../Changelog/Header/TextBadgePairRelease.cs | 7 +++--- osu.Game/Overlays/Changelog/StreamBadge.cs | 5 ++-- osu.Game/Overlays/ChangelogOverlay.cs | 19 ++++++-------- 9 files changed, 56 insertions(+), 51 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseChangelog.cs b/osu.Game.Tests/Visual/TestCaseChangelog.cs index 894b117118..ea6aa8086f 100644 --- a/osu.Game.Tests/Visual/TestCaseChangelog.cs +++ b/osu.Game.Tests/Visual/TestCaseChangelog.cs @@ -23,7 +23,8 @@ namespace osu.Game.Tests.Visual AddStep(@"Show", changelog.Show); AddRepeatStep(@"Toggle Release Stream", () => { - if (isLoaded) changelog.Streams.BadgesContainer.Children[index].Activate(); + if (isLoaded) + changelog.Streams.BadgesContainer.Children[index].Activate(); indexIncrement(); }, 6); AddStep(@"Listing", changelog.ActivateListing); @@ -31,7 +32,8 @@ namespace osu.Game.Tests.Visual AddWaitStep(3); AddStep(@"Show with Release Stream", () => { - if (isLoaded) changelog.Streams.BadgesContainer.Children[index].Activate(); + if (isLoaded) + changelog.Streams.BadgesContainer.Children[index].Activate(); changelog.Show(); indexIncrement(); }); @@ -48,7 +50,8 @@ namespace osu.Game.Tests.Visual AddWaitStep(3); AddStep(@"Activate release", () => { - if (isLoaded) changelog.Streams.BadgesContainer.Children[index].Activate(); + if (isLoaded) + changelog.Streams.BadgesContainer.Children[index].Activate(); indexIncrement(); }); AddStep(@"Show with listing", () => @@ -56,6 +59,18 @@ namespace osu.Game.Tests.Visual changelog.ActivateListing(); changelog.Show(); }); + AddStep(@"Activate Release", () => + { + if (isLoaded) + changelog.Streams.BadgesContainer.Children[index].Activate(); + }); + AddStep(@"Activate Listing", changelog.ActivateListing); + AddStep(@"Activate Release", () => + { + if (isLoaded) + changelog.Streams.BadgesContainer.Children[index].Activate(); + indexIncrement(); + }); } } } diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs index 918e203bf4..7614c4510a 100644 --- a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs +++ b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs @@ -22,22 +22,21 @@ namespace osu.Game.Graphics.UserInterface public TooltipIconButton() { Children = new Drawable[] + { + new Box { - new Box - { - RelativeSizeAxes = Axes.Both, - Alpha = 0, - }, - icon = new SpriteIcon - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Size = new Vector2(18), - } - }; + RelativeSizeAxes = Axes.Both, + Alpha = 0, + }, + icon = new SpriteIcon + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Size = new Vector2(18), + } + }; } - public string TooltipText { get; set; } } } diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelog.cs b/osu.Game/Online/API/Requests/Responses/APIChangelog.cs index f0dcafdc04..b133888056 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelog.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelog.cs @@ -27,12 +27,6 @@ namespace osu.Game.Online.API.Requests.Responses [JsonProperty("created_at")] public DateTimeOffset CreatedAt { get; set; } - [JsonProperty("disqus_id")] - public string DisqusId { get; set; } - - [JsonProperty("disqus_title")] - public string DisqusTitle { get; set; } - [JsonProperty("update_stream")] public UpdateStream UpdateStream { get; set; } diff --git a/osu.Game/Overlays/Changelog/ChangelogStreams.cs b/osu.Game/Overlays/Changelog/ChangelogStreams.cs index aded31cb47..01c57b8214 100644 --- a/osu.Game/Overlays/Changelog/ChangelogStreams.cs +++ b/osu.Game/Overlays/Changelog/ChangelogStreams.cs @@ -60,9 +60,8 @@ namespace osu.Game.Overlays.Changelog { SelectedRelease = streamBadge.ChangelogEntry; foreach (StreamBadge item in BadgesContainer.Children) - { - if (item.ChangelogEntry.Id != streamBadge.ChangelogEntry.Id) item.Deactivate(); - } + if (item.ChangelogEntry.Id != streamBadge.ChangelogEntry.Id) + item.Deactivate(); OnSelection?.Invoke(); }; } @@ -77,11 +76,10 @@ namespace osu.Game.Overlays.Changelog if (SelectedRelease != null) { if (SelectedRelease.UpdateStream.Id != streamBadge.ChangelogEntry.Id) - { streamBadge.Deactivate(); - } } - else streamBadge.Deactivate(); + else + streamBadge.Deactivate(); } return base.OnHover(state); } @@ -89,9 +87,8 @@ namespace osu.Game.Overlays.Changelog protected override void OnHoverLost(InputState state) { if (SelectedRelease == null) - { - foreach (StreamBadge streamBadge in BadgesContainer.Children) streamBadge.Activate(true); - } + foreach (StreamBadge streamBadge in BadgesContainer.Children) + streamBadge.Activate(true); base.OnHoverLost(state); } } diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs index c14414c6c4..6256c52be2 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -44,7 +44,8 @@ namespace osu.Game.Overlays.Changelog.Header public void ShowText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) { LineBadge.IsCollapsed = false; - if (!string.IsNullOrEmpty(displayText)) Text.Text = displayText; + if (!string.IsNullOrEmpty(displayText)) + Text.Text = displayText; Text.MoveToY(0, duration, easing) .FadeIn(duration, easing); } @@ -111,7 +112,8 @@ namespace osu.Game.Overlays.Changelog.Header protected override bool OnHover(InputState state) { - if (!IsActivated) sampleHover?.Play(); + if (!IsActivated) + sampleHover?.Play(); return base.OnHover(state); } diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs index eaf7e1289b..425b4b111a 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs @@ -63,7 +63,8 @@ namespace osu.Game.Overlays.Changelog.Header protected override void OnHoverLost(InputState state) { - if (IsActivated == false) LineBadge.ResizeHeightTo(1, LineBadge.TransitionDuration, Easing.Out); + if (!IsActivated) + LineBadge.ResizeHeightTo(1, LineBadge.TransitionDuration, Easing.Out); base.OnHoverLost(state); } diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs index 339f9f26d6..32a76670f0 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs @@ -23,13 +23,12 @@ namespace osu.Game.Overlays.Changelog.Header { if (IsActivated) { - if (displayText != Text.Text) ChangeText(transition_duration, displayText); + if (displayText != Text.Text) + ChangeText(transition_duration, displayText); } else - { ShowText(transition_duration, displayText); - IsActivated = true; - } + IsActivated = true; SampleActivate?.Play(); OnActivation?.Invoke(); } diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 4fa9b2de88..7e367a63fa 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -64,7 +64,7 @@ namespace osu.Game.Overlays.Changelog new SpriteText { Text = ChangelogEntry.Users > 0 ? - string.Join(" ", ChangelogEntry.Users.ToString("N0"), "users online"): + string.Format($"{ChangelogEntry.Users:N0} users online") : null, TextSize = 12, Font = @"Exo2.0-Regular", @@ -87,7 +87,8 @@ namespace osu.Game.Overlays.Changelog isActivated = true; this.FadeIn(transition_duration); lineBadge.IsCollapsed = false; - if (!withoutHeaderUpdate) OnActivation?.Invoke(); + if (!withoutHeaderUpdate) + OnActivation?.Invoke(); } public void Deactivate() diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 7723ab7659..081b501cad 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -96,9 +96,11 @@ namespace osu.Game.Overlays content.Clear(); // should add listing to content here if (!Streams.IsHovered) - foreach (StreamBadge item in Streams.BadgesContainer.Children) item.Activate(true); + foreach (StreamBadge item in Streams.BadgesContainer.Children) + item.Activate(true); else - foreach (StreamBadge item in Streams.BadgesContainer.Children) item.Deactivate(); + foreach (StreamBadge item in Streams.BadgesContainer.Children) + item.Deactivate(); }; } @@ -112,13 +114,10 @@ namespace osu.Game.Overlays switch (action) { case GlobalAction.Back: - if (header.IsListingActivated()) State = Visibility.Hidden; - - // the problem here is that when hovering over the builds' container - // and pressing back, they don't lower their opacity they're rehovered on - else header.ActivateListing(); - return true; - case GlobalAction.Select: + if (header.IsListingActivated()) + State = Visibility.Hidden; + else + header.ActivateListing(); return true; } @@ -150,9 +149,7 @@ namespace osu.Game.Overlays { Streams.BadgesContainer.Clear(); foreach (APIChangelog item in res) - { Streams.BadgesContainer.Add(new StreamBadge(item)); - } }; api.Queue(req); } From 1857c91647caa6acf62b35b07b207b1b7f20b0f4 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Fri, 20 Jul 2018 11:20:01 +0200 Subject: [PATCH 011/375] Expand APIChangelog; Normalize its line endings --- .../API/Requests/Responses/APIChangelog.cs | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelog.cs b/osu.Game/Online/API/Requests/Responses/APIChangelog.cs index b133888056..f4e4760012 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelog.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelog.cs @@ -32,6 +32,78 @@ namespace osu.Game.Online.API.Requests.Responses [JsonProperty("changelog_entries")] public List ChangelogEntries { get; set; } + + [JsonProperty("versions")] + public Versions Versions { get; set; } + } + + public class Versions + { + [JsonProperty("next")] + public APIChangelog Next { get; set; } + + [JsonProperty("previous")] + public APIChangelog Previous { get; set; } + } + + public class ChangelogEntry + { + [JsonProperty("id")] + public long Id { get; set; } + + [JsonProperty("repository")] + public string Repository { get; set; } + + [JsonProperty("github_pull_request_id")] + public long GithubPullRequestId { get; set; } + + [JsonProperty("github_url")] + public string GithubUrl { get; set; } + + [JsonProperty("url")] + public object Url { get; set; } + + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("category")] + public string Category { get; set; } + + [JsonProperty("title")] + public string Title { get; set; } + + [JsonProperty("message_html")] + public string MessageHtml { get; set; } + + [JsonProperty("major")] + public bool Major { get; set; } + + [JsonProperty("created_at")] + public DateTimeOffset CreatedAt { get; set; } + + [JsonProperty("github_user")] + public GithubUser GithubUser { get; set; } + } + + public partial class GithubUser + { + [JsonProperty("id")] + public long Id { get; set; } + + [JsonProperty("display_name")] + public string DisplayName { get; set; } + + [JsonProperty("github_url")] + public string GithubUrl { get; set; } + + [JsonProperty("osu_username")] + public string OsuUsername { get; set; } + + [JsonProperty("user_id")] + public long? UserId { get; set; } + + [JsonProperty("user_url")] + public string UserUrl { get; set; } } public class UpdateStream From c7669b21282e7eecdb486f43a5fc3131633657af Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Fri, 20 Jul 2018 12:22:31 +0200 Subject: [PATCH 012/375] Add build-scoped requests; Add OnClick to TooltipIconButton; Actions on pressing previous/next in builds --- .../UserInterface/TooltipIconButton.cs | 9 +++++++++ .../API/Requests/GetChangelogBuildRequest.cs | 20 +++++++++++++++++++ .../Changelog/ChangelogContentGroup.cs | 8 ++++---- 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs index 7614c4510a..5617dc5b44 100644 --- a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs +++ b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs @@ -5,13 +5,16 @@ using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input; using osu.Game.Graphics.Containers; +using System; namespace osu.Game.Graphics.UserInterface { public class TooltipIconButton : OsuClickableContainer, IHasTooltip { private readonly SpriteIcon icon; + public Action OnPressed; public FontAwesome Icon { @@ -37,6 +40,12 @@ namespace osu.Game.Graphics.UserInterface }; } + protected override bool OnClick(InputState state) + { + OnPressed?.Invoke(); + return base.OnClick(state); + } + public string TooltipText { get; set; } } } diff --git a/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs b/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs new file mode 100644 index 0000000000..64bc6b4b59 --- /dev/null +++ b/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs @@ -0,0 +1,20 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Online.API.Requests.Responses; + +namespace osu.Game.Online.API.Requests +{ + public class GetChangelogBuildRequest : APIRequest + { + private string url; + /// This will need to be changed to "long Id" + /// Placeholder for testing + GetChangelogBuildRequest(string url) + { + this.url = url; + } + protected override string Uri => @""; + protected override string Target => url; + } +} diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 9675cf91f5..07577e18c1 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -8,12 +8,13 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API.Requests.Responses; +using System; namespace osu.Game.Overlays.Changelog { public class ChangelogContentGroup : FillFlowContainer { - // will porobably depend in some way on #1692 (https://github.com/ppy/osu-framework/pull/1692) + public Action NextRequested, PreviousRequested; // need to keep in mind it looks different on Listing (one contains all builds from a date) // and when a stream is selected (looks like now) public ChangelogContentGroup(APIChangelog build) @@ -45,10 +46,8 @@ namespace osu.Game.Overlays.Changelog { Icon = FontAwesome.fa_chevron_left, Size = new Vector2(24), - // how do we link to previous/next builds? - // I'm thinking some linked list, but how do we make that - // from the available API data TooltipText = "Previous", + OnPressed = PreviousRequested, }, new FillFlowContainer { @@ -85,6 +84,7 @@ namespace osu.Game.Overlays.Changelog Icon = FontAwesome.fa_chevron_right, Size = new Vector2(24), TooltipText = "Next", + OnPressed = NextRequested, }, } }, From 1b3010a1b534a9675582343f82c991cf9a2e704f Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Fri, 20 Jul 2018 12:33:44 +0200 Subject: [PATCH 013/375] Remove accidental partial modifier in APIChangelog --- osu.Game/Online/API/Requests/Responses/APIChangelog.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelog.cs b/osu.Game/Online/API/Requests/Responses/APIChangelog.cs index f4e4760012..02f9bd763d 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelog.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelog.cs @@ -85,7 +85,7 @@ namespace osu.Game.Online.API.Requests.Responses public GithubUser GithubUser { get; set; } } - public partial class GithubUser + public class GithubUser { [JsonProperty("id")] public long Id { get; set; } From 227394925a0603905989ba47f4e8a112d313ac3e Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Fri, 20 Jul 2018 13:51:31 +0200 Subject: [PATCH 014/375] Add neighboring builds handling; + provoke angry AppVeyor --- .../API/Requests/GetChangelogBuildRequest.cs | 16 +++--- .../Overlays/Changelog/ChangelogContent.cs | 54 +++++++++++++++++++ .../Changelog/ChangelogContentGroup.cs | 4 +- osu.Game/Overlays/Changelog/StreamBadge.cs | 2 +- osu.Game/Overlays/ChangelogOverlay.cs | 3 +- 5 files changed, 67 insertions(+), 12 deletions(-) diff --git a/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs b/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs index 64bc6b4b59..c4ddb9a0cc 100644 --- a/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs @@ -7,14 +7,16 @@ namespace osu.Game.Online.API.Requests { public class GetChangelogBuildRequest : APIRequest { - private string url; - /// This will need to be changed to "long Id" - /// Placeholder for testing - GetChangelogBuildRequest(string url) + private readonly string name; + private readonly string version; + + public GetChangelogBuildRequest(string streamName, string buildVersion) { - this.url = url; + name = streamName; + version = buildVersion; } - protected override string Uri => @""; - protected override string Target => url; + + //protected override string Target => $@"changelog/{name}/{version}"; + protected override string Uri => @"https://api.myjson.com/bins/ya5q2"; // for testing } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 325ec802d4..9b35f51721 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -1,13 +1,20 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests; +using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Overlays.Changelog { public class ChangelogContent : FillFlowContainer { + private APIChangelog currentBuild; + private APIAccess api; + public ChangelogContent() { RelativeSizeAxes = Axes.X; @@ -19,5 +26,52 @@ namespace osu.Game.Overlays.Changelog Right = 70, }; } + + public override void Add(ChangelogContentGroup changelogContentGroup) + { + changelogContentGroup.PreviousRequested = ShowPrevious; + changelogContentGroup.NextRequested = ShowNext; + base.Add(changelogContentGroup); + } + + public void ShowBuild(APIChangelog changelog) + { + Clear(); + Add(new ChangelogContentGroup(changelog)); + FetchChangelogBuild(changelog); + } + + private void ShowNext() + { + if (currentBuild.Versions.Next != null) + { + Clear(); + Add(new ChangelogContentGroup(currentBuild.Versions.Next)); + FetchChangelogBuild(currentBuild.Versions.Next); + } + } + + private void ShowPrevious() + { + if (currentBuild.Versions.Previous != null) + { + Clear(); + Add(new ChangelogContentGroup(currentBuild.Versions.Previous)); + FetchChangelogBuild(currentBuild.Versions.Previous); + } + } + + [BackgroundDependencyLoader] + private void load(APIAccess api) + { + this.api = api; + } + + private void FetchChangelogBuild(APIChangelog build) + { + var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); + req.Success += res => currentBuild = res; + api.Queue(req); + } } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 07577e18c1..4826379682 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -47,7 +47,7 @@ namespace osu.Game.Overlays.Changelog Icon = FontAwesome.fa_chevron_left, Size = new Vector2(24), TooltipText = "Previous", - OnPressed = PreviousRequested, + OnPressed = () => PreviousRequested(), }, new FillFlowContainer { @@ -84,7 +84,7 @@ namespace osu.Game.Overlays.Changelog Icon = FontAwesome.fa_chevron_right, Size = new Vector2(24), TooltipText = "Next", - OnPressed = NextRequested, + OnPressed = () => NextRequested(), }, } }, diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 7e367a63fa..ba98e0a4f7 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -64,7 +64,7 @@ namespace osu.Game.Overlays.Changelog new SpriteText { Text = ChangelogEntry.Users > 0 ? - string.Format($"{ChangelogEntry.Users:N0} users online") : + $"{ChangelogEntry.Users:N0} users online" : null, TextSize = 12, Font = @"Exo2.0-Regular", diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 081b501cad..417b4f7a30 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -87,8 +87,7 @@ namespace osu.Game.Overlays header.ChangelogEntry = Streams.SelectedRelease; } header.ShowReleaseStream(); - content.Clear(); // this should probably happen with some transition - content.Add(new ChangelogContentGroup(Streams.SelectedRelease)); + content.ShowBuild(Streams.SelectedRelease); }; header.OnListingActivated += () => { From 02a8fb2154e62a8566a0c3b8c3c1c710335a39a5 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Fri, 20 Jul 2018 15:48:20 +0200 Subject: [PATCH 015/375] Update comments; Improve neighboring builds handling; Apply fixes to things pointed out by AppVeyor --- .../UserInterface/TooltipIconButton.cs | 9 ------- .../API/Requests/GetChangelogBuildRequest.cs | 14 +++++----- .../GetChangelogLatestBuildsRequest.cs | 7 ++--- .../API/Requests/GetChangelogRequest.cs | 4 +-- .../Overlays/Changelog/ChangelogContent.cs | 26 ++++++++++++------- .../Changelog/ChangelogContentGroup.cs | 10 +++---- .../Overlays/Changelog/ChangelogHeader.cs | 8 +++--- .../Overlays/Changelog/ChangelogStreams.cs | 3 --- osu.Game/Overlays/ChangelogOverlay.cs | 5 ++-- 9 files changed, 37 insertions(+), 49 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs index 5617dc5b44..7614c4510a 100644 --- a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs +++ b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs @@ -5,16 +5,13 @@ using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; -using osu.Framework.Input; using osu.Game.Graphics.Containers; -using System; namespace osu.Game.Graphics.UserInterface { public class TooltipIconButton : OsuClickableContainer, IHasTooltip { private readonly SpriteIcon icon; - public Action OnPressed; public FontAwesome Icon { @@ -40,12 +37,6 @@ namespace osu.Game.Graphics.UserInterface }; } - protected override bool OnClick(InputState state) - { - OnPressed?.Invoke(); - return base.OnClick(state); - } - public string TooltipText { get; set; } } } diff --git a/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs b/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs index c4ddb9a0cc..5d4d3b860c 100644 --- a/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs @@ -7,14 +7,14 @@ namespace osu.Game.Online.API.Requests { public class GetChangelogBuildRequest : APIRequest { - private readonly string name; - private readonly string version; + //private readonly string name; + //private readonly string version; - public GetChangelogBuildRequest(string streamName, string buildVersion) - { - name = streamName; - version = buildVersion; - } + //public GetChangelogBuildRequest(string streamName, string buildVersion) + //{ + // name = streamName; + // version = buildVersion; + //} //protected override string Target => $@"changelog/{name}/{version}"; protected override string Uri => @"https://api.myjson.com/bins/ya5q2"; // for testing diff --git a/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs b/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs index 845760f2e4..962c8eab15 100644 --- a/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs @@ -6,12 +6,9 @@ using System.Collections.Generic; namespace osu.Game.Online.API.Requests { - /// - /// Obviously a placeholder - /// public class GetChangelogLatestBuildsRequest : APIRequest> { - protected override string Uri => Target; - protected override string Target => @"https://api.myjson.com/bins/16waui"; + //protected override string Target => @"changelog"; + protected override string Uri => @"https://api.myjson.com/bins/16waui"; // for testing } } diff --git a/osu.Game/Online/API/Requests/GetChangelogRequest.cs b/osu.Game/Online/API/Requests/GetChangelogRequest.cs index 652e638ab8..6ddff7052e 100644 --- a/osu.Game/Online/API/Requests/GetChangelogRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogRequest.cs @@ -7,7 +7,7 @@ namespace osu.Game.Online.API.Requests { public class GetChangelogRequest : APIRequest { - protected override string Uri => Target; - protected override string Target => "https://api.myjson.com/bins/6zv2i"; + //protected override string Target => @"changelog"; + protected override string Uri => @"https://api.myjson.com/bins/6zv2i"; // for testing } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 9b35f51721..23a1c54b51 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -29,8 +29,11 @@ namespace osu.Game.Overlays.Changelog public override void Add(ChangelogContentGroup changelogContentGroup) { - changelogContentGroup.PreviousRequested = ShowPrevious; - changelogContentGroup.NextRequested = ShowNext; + if (changelogContentGroup != null) + { + changelogContentGroup.PreviousRequested = showPrevious; + changelogContentGroup.NextRequested = showNext; + } base.Add(changelogContentGroup); } @@ -38,26 +41,29 @@ namespace osu.Game.Overlays.Changelog { Clear(); Add(new ChangelogContentGroup(changelog)); - FetchChangelogBuild(changelog); + //fetchChangelogBuild(changelog); + fetchChangelogBuild(); } - private void ShowNext() + private void showNext() { if (currentBuild.Versions.Next != null) { Clear(); Add(new ChangelogContentGroup(currentBuild.Versions.Next)); - FetchChangelogBuild(currentBuild.Versions.Next); + //fetchChangelogBuild(currentBuild.Versions.Next); + fetchChangelogBuild(); } } - private void ShowPrevious() + private void showPrevious() { if (currentBuild.Versions.Previous != null) { Clear(); Add(new ChangelogContentGroup(currentBuild.Versions.Previous)); - FetchChangelogBuild(currentBuild.Versions.Previous); + //fetchChangelogBuild(currentBuild.Versions.Previous); + fetchChangelogBuild(); } } @@ -67,9 +73,11 @@ namespace osu.Game.Overlays.Changelog this.api = api; } - private void FetchChangelogBuild(APIChangelog build) + //private void fetchChangelogBuild(APIChangelog build) + private void fetchChangelogBuild() { - var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); + //var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); + var req = new GetChangelogBuildRequest(); req.Success += res => currentBuild = res; api.Queue(req); } diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 4826379682..91b6ba0134 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -15,8 +15,6 @@ namespace osu.Game.Overlays.Changelog public class ChangelogContentGroup : FillFlowContainer { public Action NextRequested, PreviousRequested; - // need to keep in mind it looks different on Listing (one contains all builds from a date) - // and when a stream is selected (looks like now) public ChangelogContentGroup(APIChangelog build) { RelativeSizeAxes = Axes.X; @@ -47,7 +45,7 @@ namespace osu.Game.Overlays.Changelog Icon = FontAwesome.fa_chevron_left, Size = new Vector2(24), TooltipText = "Previous", - OnPressed = () => PreviousRequested(), + Action = () => PreviousRequested(), }, new FillFlowContainer { @@ -65,7 +63,7 @@ namespace osu.Game.Overlays.Changelog TextSize = 28, // web: 24, Font = @"Exo2.0-Medium", }, - new SpriteText // a space... + new SpriteText { Text = " ", TextSize = 28, @@ -84,7 +82,7 @@ namespace osu.Game.Overlays.Changelog Icon = FontAwesome.fa_chevron_right, Size = new Vector2(24), TooltipText = "Next", - OnPressed = () => NextRequested(), + Action = () => NextRequested(), }, } }, @@ -105,6 +103,6 @@ namespace osu.Game.Overlays.Changelog }, }; } - //public ChangelogContentGroup(DateTimeOffset date) { } + //public ChangelogContentGroup() { } // for listing } } diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index a95d66158b..1c3f6f0853 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -48,7 +48,7 @@ namespace osu.Game.Overlays.Changelog RelativeSizeAxes = Axes.Both, FillMode = FillMode.Fill, }, - new Container // this is the line badge-Changelog-Stream + new Container { Height = title_height, Anchor = Anchor.BottomLeft, @@ -56,7 +56,7 @@ namespace osu.Game.Overlays.Changelog Y = -version_height, Children = new Drawable[] { - new CircularContainer // a purple circle + new CircularContainer { X = icon_margin, Masking = true, @@ -131,8 +131,6 @@ namespace osu.Game.Overlays.Changelog { Top = 10, Left = 7, - // + chevron size, and account for gained space on left by - // listing's font draw width being smaller Right = 18, Bottom = 15, }, @@ -153,7 +151,7 @@ namespace osu.Game.Overlays.Changelog releaseStream = new TextBadgePairRelease(Purple, "Lazer") }, }, - new Box // purple line + new Box { Colour = Purple, RelativeSizeAxes = Axes.X, diff --git a/osu.Game/Overlays/Changelog/ChangelogStreams.cs b/osu.Game/Overlays/Changelog/ChangelogStreams.cs index 01c57b8214..cc2e1f3f31 100644 --- a/osu.Game/Overlays/Changelog/ChangelogStreams.cs +++ b/osu.Game/Overlays/Changelog/ChangelogStreams.cs @@ -26,8 +26,6 @@ namespace osu.Game.Overlays.Changelog public ChangelogStreams() { - // this should actually be resizeable (https://streamable.com/yw2ug) - // if not, with small width:height ratio it cuts off right-most content RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; Children = new Drawable[] @@ -70,7 +68,6 @@ namespace osu.Game.Overlays.Changelog protected override bool OnHover(InputState state) { - // is this nullreference-safe for badgesContainer? foreach (StreamBadge streamBadge in BadgesContainer.Children) { if (SelectedRelease != null) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 417b4f7a30..d98db9de94 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -42,7 +42,7 @@ namespace osu.Game.Overlays Width = 0.85f; Masking = true; - ChangelogContent content; // told by appveyor to conver to local variable.. + ChangelogContent content; // told by appveyor to convert to local variable.. EdgeEffect = new EdgeEffectParameters { @@ -73,13 +73,12 @@ namespace osu.Game.Overlays header = new ChangelogHeader(), Streams = new ChangelogStreams(), new ChangelogChart(), - // will need to default to day-sorted content content = new ChangelogContent(), }, }, }, }; - OnLoadComplete += d => FetchChangelog(); // is i + OnLoadComplete += d => FetchChangelog(); Streams.OnSelection = () => { if (Streams.SelectedRelease != null) From c50c946b352d130b10d378850cf1c2f2cdf8a03e Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Fri, 20 Jul 2018 17:24:21 +0200 Subject: [PATCH 016/375] Make chevrons updateable --- .../Overlays/Changelog/ChangelogContent.cs | 42 +++++++++---------- .../Changelog/ChangelogContentGroup.cs | 24 ++++++++++- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 23a1c54b51..16e9d1a074 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -14,6 +14,7 @@ namespace osu.Game.Overlays.Changelog { private APIChangelog currentBuild; private APIAccess api; + private ChangelogContentGroup changelogContentGroup; public ChangelogContent() { @@ -27,20 +28,19 @@ namespace osu.Game.Overlays.Changelog }; } - public override void Add(ChangelogContentGroup changelogContentGroup) + private void add(APIChangelog changelogBuild) { - if (changelogContentGroup != null) - { - changelogContentGroup.PreviousRequested = showPrevious; - changelogContentGroup.NextRequested = showNext; - } - base.Add(changelogContentGroup); + Add(changelogContentGroup = new ChangelogContentGroup(changelogBuild) + { + PreviousRequested = showPrevious, + NextRequested = showNext, + }); } public void ShowBuild(APIChangelog changelog) { Clear(); - Add(new ChangelogContentGroup(changelog)); + add(changelog); //fetchChangelogBuild(changelog); fetchChangelogBuild(); } @@ -48,23 +48,19 @@ namespace osu.Game.Overlays.Changelog private void showNext() { if (currentBuild.Versions.Next != null) - { - Clear(); - Add(new ChangelogContentGroup(currentBuild.Versions.Next)); - //fetchChangelogBuild(currentBuild.Versions.Next); - fetchChangelogBuild(); - } + ShowBuild(currentBuild.Versions.Next); } private void showPrevious() { if (currentBuild.Versions.Previous != null) - { - Clear(); - Add(new ChangelogContentGroup(currentBuild.Versions.Previous)); - //fetchChangelogBuild(currentBuild.Versions.Previous); - fetchChangelogBuild(); - } + ShowBuild(currentBuild.Versions.Previous); + } + + private void updateChevronTooltips() + { + changelogContentGroup.UpdateChevronTooltips(currentBuild.Versions.Previous?.DisplayVersion, + currentBuild.Versions.Next?.DisplayVersion); } [BackgroundDependencyLoader] @@ -78,7 +74,11 @@ namespace osu.Game.Overlays.Changelog { //var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); var req = new GetChangelogBuildRequest(); - req.Success += res => currentBuild = res; + req.Success += res => + { + currentBuild = res; + updateChevronTooltips(); + }; api.Queue(req); } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 91b6ba0134..5b22b360e5 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -14,6 +14,8 @@ namespace osu.Game.Overlays.Changelog { public class ChangelogContentGroup : FillFlowContainer { + private readonly TooltipIconButton chevronPrevious, chevronNext; + public Action NextRequested, PreviousRequested; public ChangelogContentGroup(APIChangelog build) { @@ -40,7 +42,7 @@ namespace osu.Game.Overlays.Changelog }, Children = new Drawable[] { - new TooltipIconButton + chevronPrevious = new TooltipIconButton { Icon = FontAwesome.fa_chevron_left, Size = new Vector2(24), @@ -77,7 +79,7 @@ namespace osu.Game.Overlays.Changelog }, } }, - new TooltipIconButton + chevronNext = new TooltipIconButton { Icon = FontAwesome.fa_chevron_right, Size = new Vector2(24), @@ -103,6 +105,24 @@ namespace osu.Game.Overlays.Changelog }, }; } + + public void UpdateChevronTooltips(string previousVersion, string nextVersion) + { + if (string.IsNullOrEmpty(previousVersion)) + chevronPrevious.IsEnabled = false; + else + { + chevronPrevious.TooltipText = previousVersion; + chevronPrevious.IsEnabled = true; + } + if (string.IsNullOrEmpty(nextVersion)) + chevronNext.IsEnabled = false; + else + { + chevronNext.TooltipText = nextVersion; + chevronNext.IsEnabled = true; + } + } //public ChangelogContentGroup() { } // for listing } } From b049ffa11d0c1b879ab36d18b1cb31de72cdb447 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Fri, 20 Jul 2018 18:23:25 +0200 Subject: [PATCH 017/375] Improve fake-api --- .../API/Requests/GetChangelogBuildRequest.cs | 18 +++++++++--------- .../GetChangelogLatestBuildsRequest.cs | 4 ++-- .../Online/API/Requests/GetChangelogRequest.cs | 4 ++-- .../Overlays/Changelog/ChangelogContent.cs | 9 +++------ .../Changelog/ChangelogContentGroup.cs | 14 ++------------ 5 files changed, 18 insertions(+), 31 deletions(-) diff --git a/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs b/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs index 5d4d3b860c..2338b90865 100644 --- a/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs @@ -7,16 +7,16 @@ namespace osu.Game.Online.API.Requests { public class GetChangelogBuildRequest : APIRequest { - //private readonly string name; - //private readonly string version; + private readonly string name; + private readonly string version; - //public GetChangelogBuildRequest(string streamName, string buildVersion) - //{ - // name = streamName; - // version = buildVersion; - //} + public GetChangelogBuildRequest(string streamName, string buildVersion) + { + name = streamName; + version = buildVersion; + } - //protected override string Target => $@"changelog/{name}/{version}"; - protected override string Uri => @"https://api.myjson.com/bins/ya5q2"; // for testing + protected override string Target => $@"changelog/{name}/{version}"; + protected override string Uri => $@"https://houtarouoreki.github.io/fake-api/{Target}"; // for testing } } diff --git a/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs b/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs index 962c8eab15..7940fd8ff5 100644 --- a/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs @@ -8,7 +8,7 @@ namespace osu.Game.Online.API.Requests { public class GetChangelogLatestBuildsRequest : APIRequest> { - //protected override string Target => @"changelog"; - protected override string Uri => @"https://api.myjson.com/bins/16waui"; // for testing + protected override string Target => @"changelog/latest-builds"; + protected override string Uri => $@"https://houtarouoreki.github.io/fake-api/{Target}"; // for testing } } diff --git a/osu.Game/Online/API/Requests/GetChangelogRequest.cs b/osu.Game/Online/API/Requests/GetChangelogRequest.cs index 6ddff7052e..2f2e0ffe67 100644 --- a/osu.Game/Online/API/Requests/GetChangelogRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogRequest.cs @@ -7,7 +7,7 @@ namespace osu.Game.Online.API.Requests { public class GetChangelogRequest : APIRequest { - //protected override string Target => @"changelog"; - protected override string Uri => @"https://api.myjson.com/bins/6zv2i"; // for testing + protected override string Target => @"changelog"; + protected override string Uri => $@"https://houtarouoreki.github.io/fake-api/{Target}"; // for testing } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 16e9d1a074..1f89fba9e1 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -41,8 +41,7 @@ namespace osu.Game.Overlays.Changelog { Clear(); add(changelog); - //fetchChangelogBuild(changelog); - fetchChangelogBuild(); + fetchChangelogBuild(changelog); } private void showNext() @@ -69,11 +68,9 @@ namespace osu.Game.Overlays.Changelog this.api = api; } - //private void fetchChangelogBuild(APIChangelog build) - private void fetchChangelogBuild() + private void fetchChangelogBuild(APIChangelog build) { - //var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); - var req = new GetChangelogBuildRequest(); + var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); req.Success += res => { currentBuild = res; diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 5b22b360e5..3b67aa36ec 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -108,20 +108,10 @@ namespace osu.Game.Overlays.Changelog public void UpdateChevronTooltips(string previousVersion, string nextVersion) { - if (string.IsNullOrEmpty(previousVersion)) - chevronPrevious.IsEnabled = false; - else - { + if (!string.IsNullOrEmpty(previousVersion)) chevronPrevious.TooltipText = previousVersion; - chevronPrevious.IsEnabled = true; - } - if (string.IsNullOrEmpty(nextVersion)) - chevronNext.IsEnabled = false; - else - { + if (!string.IsNullOrEmpty(nextVersion)) chevronNext.TooltipText = nextVersion; - chevronNext.IsEnabled = true; - } } //public ChangelogContentGroup() { } // for listing } From 835a8137151e27ddaeb2ab87466ec447ae615d40 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Fri, 20 Jul 2018 19:35:38 +0200 Subject: [PATCH 018/375] Improvements to TooltipIconButton Disable sounds when disabled; Remove default tooltip texts --- .../UserInterface/TooltipIconButton.cs | 52 ++++++++++++++++++- .../Changelog/ChangelogContentGroup.cs | 10 +++- 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs index 7614c4510a..68413e7460 100644 --- a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs +++ b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs @@ -2,16 +2,38 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics.Containers; +using osu.Framework.Input; +using System; namespace osu.Game.Graphics.UserInterface { - public class TooltipIconButton : OsuClickableContainer, IHasTooltip + // not inheriting osuclickablecontainer/osuhovercontainer + // because click/hover sounds cannot be disabled, and they make + // double sounds when reappearing under the cursor + public class TooltipIconButton : ClickableContainer, IHasTooltip { private readonly SpriteIcon icon; + private SampleChannel sampleClick; + private SampleChannel sampleHover; + public Action Action; + + private bool isEnabled; + public bool IsEnabled + { + get { return isEnabled; } + set + { + isEnabled = value; + icon.Alpha = value ? 1 : 0.5f; + } + } public FontAwesome Icon { @@ -21,6 +43,7 @@ namespace osu.Game.Graphics.UserInterface public TooltipIconButton() { + isEnabled = true; Children = new Drawable[] { new Box @@ -33,10 +56,35 @@ namespace osu.Game.Graphics.UserInterface Origin = Anchor.Centre, Anchor = Anchor.Centre, Size = new Vector2(18), + Alpha = 0.5f, } }; } + protected override bool OnClick(InputState state) + { + if (isEnabled) + { + Action?.Invoke(); + sampleClick?.Play(); + } + return base.OnClick(state); + } + + protected override bool OnHover(InputState state) + { + if (isEnabled) + sampleHover?.Play(); + return base.OnHover(state); + } + + [BackgroundDependencyLoader] + private void load(AudioManager audio) + { + sampleClick = audio.Sample.Get(@"UI/generic-select-soft"); + sampleHover = audio.Sample.Get(@"UI/generic-hover-soft"); + } + public string TooltipText { get; set; } } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 3b67aa36ec..3ec11beb35 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -44,9 +44,9 @@ namespace osu.Game.Overlays.Changelog { chevronPrevious = new TooltipIconButton { + IsEnabled = false, Icon = FontAwesome.fa_chevron_left, Size = new Vector2(24), - TooltipText = "Previous", Action = () => PreviousRequested(), }, new FillFlowContainer @@ -81,9 +81,9 @@ namespace osu.Game.Overlays.Changelog }, chevronNext = new TooltipIconButton { + IsEnabled = false, Icon = FontAwesome.fa_chevron_right, Size = new Vector2(24), - TooltipText = "Next", Action = () => NextRequested(), }, } @@ -109,9 +109,15 @@ namespace osu.Game.Overlays.Changelog public void UpdateChevronTooltips(string previousVersion, string nextVersion) { if (!string.IsNullOrEmpty(previousVersion)) + { chevronPrevious.TooltipText = previousVersion; + chevronPrevious.IsEnabled = true; + } if (!string.IsNullOrEmpty(nextVersion)) + { chevronNext.TooltipText = nextVersion; + chevronNext.IsEnabled = true; + } } //public ChangelogContentGroup() { } // for listing } From 709872d688fa0fe04ada59dea451fb99de54751f Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Fri, 20 Jul 2018 22:11:51 +0200 Subject: [PATCH 019/375] Improve showing up builds --- .../UserInterface/TooltipIconButton.cs | 9 ++--- .../Overlays/Changelog/ChangelogContent.cs | 33 ++++++++++++------- osu.Game/Overlays/ChangelogOverlay.cs | 5 +++ 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs index 68413e7460..8b85c8c0ec 100644 --- a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs +++ b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs @@ -20,7 +20,6 @@ namespace osu.Game.Graphics.UserInterface public class TooltipIconButton : ClickableContainer, IHasTooltip { private readonly SpriteIcon icon; - private SampleChannel sampleClick; private SampleChannel sampleHover; public Action Action; @@ -55,8 +54,8 @@ namespace osu.Game.Graphics.UserInterface { Origin = Anchor.Centre, Anchor = Anchor.Centre, - Size = new Vector2(18), - Alpha = 0.5f, + RelativeSizeAxes = Axes.Both, + Size = new Vector2(0.8f), } }; } @@ -64,10 +63,7 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnClick(InputState state) { if (isEnabled) - { Action?.Invoke(); - sampleClick?.Play(); - } return base.OnClick(state); } @@ -81,7 +77,6 @@ namespace osu.Game.Graphics.UserInterface [BackgroundDependencyLoader] private void load(AudioManager audio) { - sampleClick = audio.Sample.Get(@"UI/generic-select-soft"); sampleHover = audio.Sample.Get(@"UI/generic-hover-soft"); } diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 1f89fba9e1..8795c040ef 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -7,12 +7,14 @@ using osu.Framework.Graphics.Containers; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; +using System; namespace osu.Game.Overlays.Changelog { public class ChangelogContent : FillFlowContainer { - private APIChangelog currentBuild; + public APIChangelog CurrentBuild { get; private set; } + public Action OnBuildChanged; private APIAccess api; private ChangelogContentGroup changelogContentGroup; @@ -31,35 +33,42 @@ namespace osu.Game.Overlays.Changelog private void add(APIChangelog changelogBuild) { Add(changelogContentGroup = new ChangelogContentGroup(changelogBuild) - { - PreviousRequested = showPrevious, - NextRequested = showNext, - }); + { + PreviousRequested = showPrevious, + NextRequested = showNext, + }); } public void ShowBuild(APIChangelog changelog) { Clear(); add(changelog); + CurrentBuild = changelog; fetchChangelogBuild(changelog); } + private void showBuild(APIChangelog changelog) + { + ShowBuild(changelog); + OnBuildChanged(); + } + private void showNext() { - if (currentBuild.Versions.Next != null) - ShowBuild(currentBuild.Versions.Next); + if (CurrentBuild.Versions.Next != null) + showBuild(CurrentBuild.Versions.Next); } private void showPrevious() { - if (currentBuild.Versions.Previous != null) - ShowBuild(currentBuild.Versions.Previous); + if (CurrentBuild.Versions.Previous != null) + showBuild(CurrentBuild.Versions.Previous); } private void updateChevronTooltips() { - changelogContentGroup.UpdateChevronTooltips(currentBuild.Versions.Previous?.DisplayVersion, - currentBuild.Versions.Next?.DisplayVersion); + changelogContentGroup.UpdateChevronTooltips(CurrentBuild.Versions.Previous?.DisplayVersion, + CurrentBuild.Versions.Next?.DisplayVersion); } [BackgroundDependencyLoader] @@ -73,7 +82,7 @@ namespace osu.Game.Overlays.Changelog var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); req.Success += res => { - currentBuild = res; + CurrentBuild = res; updateChevronTooltips(); }; api.Queue(req); diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index d98db9de94..5932bbb9c8 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -100,6 +100,11 @@ namespace osu.Game.Overlays foreach (StreamBadge item in Streams.BadgesContainer.Children) item.Deactivate(); }; + content.OnBuildChanged = () => + { + header.ChangelogEntry = content.CurrentBuild; + header.ShowReleaseStream(); + }; } public void ActivateListing() => header.ActivateListing(); From c9f3e72b7a868082fc0d7ac2b97e1ec413a29bfe Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Fri, 20 Jul 2018 22:13:10 +0200 Subject: [PATCH 020/375] Unify build div's dimming mechanics with osu-web --- osu.Game/Overlays/Changelog/ChangelogStreams.cs | 12 +++++++++--- osu.Game/Overlays/Changelog/StreamBadge.cs | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogStreams.cs b/osu.Game/Overlays/Changelog/ChangelogStreams.cs index cc2e1f3f31..1e6e9e1e51 100644 --- a/osu.Game/Overlays/Changelog/ChangelogStreams.cs +++ b/osu.Game/Overlays/Changelog/ChangelogStreams.cs @@ -72,8 +72,10 @@ namespace osu.Game.Overlays.Changelog { if (SelectedRelease != null) { - if (SelectedRelease.UpdateStream.Id != streamBadge.ChangelogEntry.Id) + if (SelectedRelease.UpdateStream.Id != streamBadge.ChangelogEntry.UpdateStream.Id) streamBadge.Deactivate(); + else + streamBadge.EnableDim(); } else streamBadge.Deactivate(); @@ -83,9 +85,13 @@ namespace osu.Game.Overlays.Changelog protected override void OnHoverLost(InputState state) { - if (SelectedRelease == null) - foreach (StreamBadge streamBadge in BadgesContainer.Children) + foreach (StreamBadge streamBadge in BadgesContainer.Children) + { + if (SelectedRelease == null) streamBadge.Activate(true); + else if (streamBadge.ChangelogEntry.UpdateStream.Id == SelectedRelease.UpdateStream.Id) + streamBadge.DisableDim(); + } base.OnHoverLost(state); } } diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index ba98e0a4f7..388245db1a 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -28,6 +28,7 @@ namespace osu.Game.Overlays.Changelog private readonly Header.LineBadge lineBadge; private SampleChannel sampleHover; public readonly APIChangelog ChangelogEntry; + private readonly FillFlowContainer Text; public StreamBadge(APIChangelog changelogEntry) { @@ -38,7 +39,7 @@ namespace osu.Game.Overlays.Changelog isActivated = true; Children = new Drawable[] { - new FillFlowContainer + Text = new FillFlowContainer { AutoSizeAxes = Axes.X, RelativeSizeAxes = Axes.Y, @@ -86,6 +87,7 @@ namespace osu.Game.Overlays.Changelog { isActivated = true; this.FadeIn(transition_duration); + Text.FadeIn(transition_duration); lineBadge.IsCollapsed = false; if (!withoutHeaderUpdate) OnActivation?.Invoke(); @@ -94,6 +96,7 @@ namespace osu.Game.Overlays.Changelog public void Deactivate() { isActivated = false; + DisableDim(); if (!IsHovered) { this.FadeTo(0.5f, transition_duration); @@ -109,7 +112,8 @@ namespace osu.Game.Overlays.Changelog protected override bool OnHover(InputState state) { - if (!isActivated) sampleHover?.Play(); + sampleHover?.Play(); + DisableDim(); this.FadeIn(transition_duration); lineBadge.IsCollapsed = false; return base.OnHover(state); @@ -122,9 +126,15 @@ namespace osu.Game.Overlays.Changelog this.FadeTo(0.5f, transition_duration); lineBadge.IsCollapsed = true; } + else + EnableDim(); base.OnHoverLost(state); } + public void EnableDim() => Text.FadeTo(0.5f, transition_duration); + + public void DisableDim() => Text.FadeIn(transition_duration); + [BackgroundDependencyLoader] private void load(AudioManager audio) { From 311546423863a2442f658ce2f959735168f4076d Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Fri, 20 Jul 2018 22:16:16 +0200 Subject: [PATCH 021/375] Remove unnecessary statement; Uncapitalize private member; --- osu.Game/Overlays/Changelog/StreamBadge.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 388245db1a..80b2fb2a03 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -28,7 +28,7 @@ namespace osu.Game.Overlays.Changelog private readonly Header.LineBadge lineBadge; private SampleChannel sampleHover; public readonly APIChangelog ChangelogEntry; - private readonly FillFlowContainer Text; + private readonly FillFlowContainer text; public StreamBadge(APIChangelog changelogEntry) { @@ -39,7 +39,7 @@ namespace osu.Game.Overlays.Changelog isActivated = true; Children = new Drawable[] { - Text = new FillFlowContainer + text = new FillFlowContainer { AutoSizeAxes = Axes.X, RelativeSizeAxes = Axes.Y, @@ -87,7 +87,6 @@ namespace osu.Game.Overlays.Changelog { isActivated = true; this.FadeIn(transition_duration); - Text.FadeIn(transition_duration); lineBadge.IsCollapsed = false; if (!withoutHeaderUpdate) OnActivation?.Invoke(); @@ -131,9 +130,9 @@ namespace osu.Game.Overlays.Changelog base.OnHoverLost(state); } - public void EnableDim() => Text.FadeTo(0.5f, transition_duration); + public void EnableDim() => text.FadeTo(0.5f, transition_duration); - public void DisableDim() => Text.FadeIn(transition_duration); + public void DisableDim() => text.FadeIn(transition_duration); [BackgroundDependencyLoader] private void load(AudioManager audio) From c36a303b363bc6f6eba0fd07a118a2483c38a2cd Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Fri, 20 Jul 2018 23:14:05 +0200 Subject: [PATCH 022/375] Fix ChangelogEntries being a list of objects --- osu.Game/Online/API/Requests/Responses/APIChangelog.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelog.cs b/osu.Game/Online/API/Requests/Responses/APIChangelog.cs index 02f9bd763d..4ba7077863 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelog.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelog.cs @@ -31,7 +31,7 @@ namespace osu.Game.Online.API.Requests.Responses public UpdateStream UpdateStream { get; set; } [JsonProperty("changelog_entries")] - public List ChangelogEntries { get; set; } + public List ChangelogEntries { get; set; } [JsonProperty("versions")] public Versions Versions { get; set; } From 8d4de68c39e246ed01586a6e5a112d02a55048f6 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Fri, 20 Jul 2018 23:57:46 +0200 Subject: [PATCH 023/375] Nullables in APIChangelog; Primitive changelog entries display --- .../API/Requests/Responses/APIChangelog.cs | 14 ++++++------ .../Overlays/Changelog/ChangelogContent.cs | 1 + .../Changelog/ChangelogContentGroup.cs | 22 ++++++++++++++++++- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelog.cs b/osu.Game/Online/API/Requests/Responses/APIChangelog.cs index 4ba7077863..9d3357b071 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelog.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelog.cs @@ -25,7 +25,7 @@ namespace osu.Game.Online.API.Requests.Responses public bool IsFeatured { get; set; } [JsonProperty("created_at")] - public DateTimeOffset CreatedAt { get; set; } + public DateTimeOffset? CreatedAt { get; set; } [JsonProperty("update_stream")] public UpdateStream UpdateStream { get; set; } @@ -49,19 +49,19 @@ namespace osu.Game.Online.API.Requests.Responses public class ChangelogEntry { [JsonProperty("id")] - public long Id { get; set; } + public long? Id { get; set; } [JsonProperty("repository")] public string Repository { get; set; } [JsonProperty("github_pull_request_id")] - public long GithubPullRequestId { get; set; } + public long? GithubPullRequestId { get; set; } [JsonProperty("github_url")] public string GithubUrl { get; set; } [JsonProperty("url")] - public object Url { get; set; } + public string Url { get; set; } [JsonProperty("type")] public string Type { get; set; } @@ -76,10 +76,10 @@ namespace osu.Game.Online.API.Requests.Responses public string MessageHtml { get; set; } [JsonProperty("major")] - public bool Major { get; set; } + public bool? Major { get; set; } [JsonProperty("created_at")] - public DateTimeOffset CreatedAt { get; set; } + public DateTimeOffset? CreatedAt { get; set; } [JsonProperty("github_user")] public GithubUser GithubUser { get; set; } @@ -88,7 +88,7 @@ namespace osu.Game.Online.API.Requests.Responses public class GithubUser { [JsonProperty("id")] - public long Id { get; set; } + public long? Id { get; set; } [JsonProperty("display_name")] public string DisplayName { get; set; } diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 8795c040ef..1bae32b4ef 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -83,6 +83,7 @@ namespace osu.Game.Overlays.Changelog req.Success += res => { CurrentBuild = res; + changelogContentGroup.GenerateText(CurrentBuild.ChangelogEntries); updateChevronTooltips(); }; api.Queue(req); diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 3ec11beb35..bc6428450e 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -9,6 +9,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API.Requests.Responses; using System; +using System.Collections.Generic; namespace osu.Game.Overlays.Changelog { @@ -17,6 +18,8 @@ namespace osu.Game.Overlays.Changelog private readonly TooltipIconButton chevronPrevious, chevronNext; public Action NextRequested, PreviousRequested; + public readonly TextFlowContainer ChangelogEntries; + public ChangelogContentGroup(APIChangelog build) { RelativeSizeAxes = Axes.X; @@ -92,7 +95,8 @@ namespace osu.Game.Overlays.Changelog { // do we need .ToUniversalTime() here? // also, this should be a temporary solution to weekdays in >localized< date strings - Text = build.CreatedAt.Date.ToLongDateString().Replace(build.CreatedAt.ToString("dddd") + ", ", ""), + Text = build.CreatedAt.HasValue ? build.CreatedAt.Value.Date.ToLongDateString() + .Replace(build.CreatedAt.Value.ToString("dddd") + ", ", "") : null, TextSize = 17, // web: 14, Colour = OsuColour.FromHex(@"FD5"), Font = @"Exo2.0-Medium", @@ -103,6 +107,11 @@ namespace osu.Game.Overlays.Changelog Top = 5, }, }, + ChangelogEntries = new TextFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + }, }; } @@ -119,6 +128,17 @@ namespace osu.Game.Overlays.Changelog chevronNext.IsEnabled = true; } } + + public void GenerateText(List changelogEntries) + { + foreach (ChangelogEntry entry in changelogEntries) + { + ChangelogEntries.AddParagraph(entry.Type); + ChangelogEntries.AddParagraph(entry.Title); + ChangelogEntries.AddText($"({entry.Repository}#{entry.GithubPullRequestId})"); + ChangelogEntries.AddText($"by {entry.GithubUser.DisplayName}"); + } + } //public ChangelogContentGroup() { } // for listing } } From 1492d5cb29d26876c3d3d7d6a25cbcfc5920c66f Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sat, 21 Jul 2018 02:58:53 +0200 Subject: [PATCH 024/375] Improve primitive changelog entry formatting --- .../Changelog/ChangelogContentGroup.cs | 65 +++++++++++++++---- 1 file changed, 52 insertions(+), 13 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index bc6428450e..9393849d93 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; +using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -18,18 +19,13 @@ namespace osu.Game.Overlays.Changelog private readonly TooltipIconButton chevronPrevious, chevronNext; public Action NextRequested, PreviousRequested; - public readonly TextFlowContainer ChangelogEntries; + public readonly FillFlowContainer ChangelogEntries; public ChangelogContentGroup(APIChangelog build) { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; Direction = FillDirection.Vertical; - Padding = new MarginPadding - { - Left = 70, - Right = 70, - }; Children = new Drawable[] { // build version, arrows @@ -95,8 +91,7 @@ namespace osu.Game.Overlays.Changelog { // do we need .ToUniversalTime() here? // also, this should be a temporary solution to weekdays in >localized< date strings - Text = build.CreatedAt.HasValue ? build.CreatedAt.Value.Date.ToLongDateString() - .Replace(build.CreatedAt.Value.ToString("dddd") + ", ", "") : null, + Text = build.CreatedAt.Value.Date.ToLongDateString().Replace(build.CreatedAt.Value.ToString("dddd") + ", ", ""), TextSize = 17, // web: 14, Colour = OsuColour.FromHex(@"FD5"), Font = @"Exo2.0-Medium", @@ -107,10 +102,11 @@ namespace osu.Game.Overlays.Changelog Top = 5, }, }, - ChangelogEntries = new TextFlowContainer + ChangelogEntries = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, }, }; } @@ -133,10 +129,53 @@ namespace osu.Game.Overlays.Changelog { foreach (ChangelogEntry entry in changelogEntries) { - ChangelogEntries.AddParagraph(entry.Type); - ChangelogEntries.AddParagraph(entry.Title); - ChangelogEntries.AddText($"({entry.Repository}#{entry.GithubPullRequestId})"); - ChangelogEntries.AddText($"by {entry.GithubUser.DisplayName}"); + // textflowcontainer is unusable for formatting text + // this has to be a placeholder before we get a + // proper markdown/html formatting.. + // it can't handle overflowing properly + ChangelogEntries.Add(new SpriteText + { + Text = entry.Category, + TextSize = 24, // web: 18, + Font = @"Exo2.0-Bold", + Margin = new MarginPadding { Top = 35, Bottom = 15, }, + }); + ChangelogEntries.Add(new FillFlowContainer + { + Direction = FillDirection.Full, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + new SpriteIcon + { + Anchor = Anchor.TopLeft, + Origin = Anchor.TopRight, + Icon = FontAwesome.fa_check, + Size = new Vector2(14), + Margin = new MarginPadding { Top = 2, Right = 4 }, + }, + new TextFlowContainer(t => t.TextSize = 18) + { + Text = entry.Title, + AutoSizeAxes = Axes.Both, + }, + new SpriteText + { + Text = !string.IsNullOrEmpty(entry.Repository) ? + $" ({entry.Repository.Substring(4)}#{entry.GithubPullRequestId})" : + null, + TextSize = 18, + Colour = new Color4(153, 238, 255, 255), + }, + new SpriteText + { + Text = $" by {entry.GithubUser.DisplayName}", + TextSize = 14, // web: 12; + Margin = new MarginPadding { Top = 4, Left = 10, }, + }, + } + }); } } //public ChangelogContentGroup() { } // for listing From ce0029eabf68455d5a24ad6fdb5546512553abf1 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sat, 21 Jul 2018 03:19:30 +0200 Subject: [PATCH 025/375] Make build's creation date not nullable --- osu.Game/Online/API/Requests/Responses/APIChangelog.cs | 2 +- osu.Game/Overlays/Changelog/ChangelogContentGroup.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelog.cs b/osu.Game/Online/API/Requests/Responses/APIChangelog.cs index 9d3357b071..da5437515c 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelog.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelog.cs @@ -25,7 +25,7 @@ namespace osu.Game.Online.API.Requests.Responses public bool IsFeatured { get; set; } [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + public DateTimeOffset CreatedAt { get; set; } [JsonProperty("update_stream")] public UpdateStream UpdateStream { get; set; } diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 9393849d93..7c770dd153 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -91,7 +91,7 @@ namespace osu.Game.Overlays.Changelog { // do we need .ToUniversalTime() here? // also, this should be a temporary solution to weekdays in >localized< date strings - Text = build.CreatedAt.Value.Date.ToLongDateString().Replace(build.CreatedAt.Value.ToString("dddd") + ", ", ""), + Text = build.CreatedAt.Date.ToLongDateString().Replace(build.CreatedAt.ToString("dddd") + ", ", ""), TextSize = 17, // web: 14, Colour = OsuColour.FromHex(@"FD5"), Font = @"Exo2.0-Medium", From 50c4f6ff9521efeddeadd1db9ef59cef95a3e774 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sat, 21 Jul 2018 06:37:42 +0200 Subject: [PATCH 026/375] Prevent scrolling to top on build change; Add bottom margin --- osu.Game/Overlays/Changelog/ChangelogContent.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 1bae32b4ef..363b251383 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -25,24 +25,22 @@ namespace osu.Game.Overlays.Changelog Direction = FillDirection.Vertical; Padding = new MarginPadding { - Left = 70, - Right = 70, + Horizontal = 70, + Bottom = 100, }; } private void add(APIChangelog changelogBuild) { - Add(changelogContentGroup = new ChangelogContentGroup(changelogBuild) + Child = changelogContentGroup = new ChangelogContentGroup(changelogBuild) { PreviousRequested = showPrevious, NextRequested = showNext, - }); + }; } public void ShowBuild(APIChangelog changelog) { - Clear(); - add(changelog); CurrentBuild = changelog; fetchChangelogBuild(changelog); } @@ -83,6 +81,7 @@ namespace osu.Game.Overlays.Changelog req.Success += res => { CurrentBuild = res; + add(CurrentBuild); changelogContentGroup.GenerateText(CurrentBuild.ChangelogEntries); updateChevronTooltips(); }; From eca5fb6f052f4906233e1e10f7960133703e0035 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sat, 21 Jul 2018 06:38:02 +0200 Subject: [PATCH 027/375] Introduce better formatting to changelog entries; Sort by category --- .../Changelog/ChangelogContentGroup.cs | 79 ++++++++++--------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 7c770dd153..4a6eb27cc7 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; +using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API.Requests.Responses; using System; @@ -17,6 +18,8 @@ namespace osu.Game.Overlays.Changelog public class ChangelogContentGroup : FillFlowContainer { private readonly TooltipIconButton chevronPrevious, chevronNext; + private readonly SortedDictionary> categories = + new SortedDictionary>(); public Action NextRequested, PreviousRequested; public readonly FillFlowContainer ChangelogEntries; @@ -97,10 +100,7 @@ namespace osu.Game.Overlays.Changelog Font = @"Exo2.0-Medium", Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Margin = new MarginPadding - { - Top = 5, - }, + Margin = new MarginPadding{ Top = 5, } }, ChangelogEntries = new FillFlowContainer { @@ -127,7 +127,16 @@ namespace osu.Game.Overlays.Changelog public void GenerateText(List changelogEntries) { + // sort entries by category foreach (ChangelogEntry entry in changelogEntries) + { + if (!categories.ContainsKey(entry.Category)) + categories.Add(entry.Category, new List { entry }); + else + categories[entry.Category].Add(entry); + } + + foreach (KeyValuePair> category in categories) { // textflowcontainer is unusable for formatting text // this has to be a placeholder before we get a @@ -135,47 +144,43 @@ namespace osu.Game.Overlays.Changelog // it can't handle overflowing properly ChangelogEntries.Add(new SpriteText { - Text = entry.Category, + Text = category.Key, TextSize = 24, // web: 18, Font = @"Exo2.0-Bold", Margin = new MarginPadding { Top = 35, Bottom = 15, }, }); - ChangelogEntries.Add(new FillFlowContainer + foreach (ChangelogEntry entry in category.Value) { - Direction = FillDirection.Full, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Children = new Drawable[] + OsuTextFlowContainer title; + + ChangelogEntries.Add(title = new OsuTextFlowContainer { - new SpriteIcon + Direction = FillDirection.Full, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + LineSpacing = 0.25f, + }); + title.AddIcon(FontAwesome.fa_check, t => { t.TextSize = 12; t.Padding = new MarginPadding { Left = -17, Right = 5 }; }); + title.AddText(entry.Title, t => { t.TextSize = 18; }); //t.Padding = new MarginPadding(10); }); + if (!string.IsNullOrEmpty(entry.Repository)) + { + title.AddText($" ({entry.Repository.Substring(4)}#{entry.GithubPullRequestId})", t => { - Anchor = Anchor.TopLeft, - Origin = Anchor.TopRight, - Icon = FontAwesome.fa_check, - Size = new Vector2(14), - Margin = new MarginPadding { Top = 2, Right = 4 }, - }, - new TextFlowContainer(t => t.TextSize = 18) - { - Text = entry.Title, - AutoSizeAxes = Axes.Both, - }, - new SpriteText - { - Text = !string.IsNullOrEmpty(entry.Repository) ? - $" ({entry.Repository.Substring(4)}#{entry.GithubPullRequestId})" : - null, - TextSize = 18, - Colour = new Color4(153, 238, 255, 255), - }, - new SpriteText - { - Text = $" by {entry.GithubUser.DisplayName}", - TextSize = 14, // web: 12; - Margin = new MarginPadding { Top = 4, Left = 10, }, - }, + t.TextSize = 18; + t.Colour = Color4.SkyBlue; + }); } - }); + title.AddText($" by {entry.GithubUser.DisplayName}", t => t.TextSize = 14); //web: 12; + ChangelogEntries.Add(new SpriteText + { + TextSize = 14, // web: 12, + Colour = new Color4(235, 184, 254, 255), + Text = $"{entry.MessageHtml?.Replace("

", "").Replace("

", "")}\n", + Margin = new MarginPadding { Bottom = 10, }, + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + }); + } } } //public ChangelogContentGroup() { } // for listing From 78f0f37ee65c7c4666b668c25064daf14b63d6a9 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sat, 21 Jul 2018 07:16:22 +0200 Subject: [PATCH 028/375] Change graph's colour on stream selection --- osu.Game/Overlays/Changelog/ChangelogChart.cs | 10 +++++++++- osu.Game/Overlays/ChangelogOverlay.cs | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs index b113a509ec..18c74f4b51 100644 --- a/osu.Game/Overlays/Changelog/ChangelogChart.cs +++ b/osu.Game/Overlays/Changelog/ChangelogChart.cs @@ -6,6 +6,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; +using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Overlays.Changelog { @@ -13,13 +14,15 @@ namespace osu.Game.Overlays.Changelog // placeholder json file: https://api.myjson.com/bins/10ye8a public class ChangelogChart : BufferedContainer { + private Box background; + public ChangelogChart() { RelativeSizeAxes = Axes.X; Height = 100; Children = new Drawable[] { - new Box + background = new Box { Colour = StreamColour.STABLE, RelativeSizeAxes = Axes.Both, @@ -33,5 +36,10 @@ namespace osu.Game.Overlays.Changelog }, }; } + + public void ShowChart(APIChangelog releaseStream) + { + background.Colour = StreamColour.FromStreamName(releaseStream.UpdateStream.Name); + } } } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 5932bbb9c8..f2df54ac99 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -22,6 +22,7 @@ namespace osu.Game.Overlays { private readonly ChangelogHeader header; public readonly ChangelogStreams Streams; + private readonly ChangelogChart chart; private APIChangelog changelogEntry; private APIAccess api; @@ -72,7 +73,7 @@ namespace osu.Game.Overlays { header = new ChangelogHeader(), Streams = new ChangelogStreams(), - new ChangelogChart(), + chart = new ChangelogChart(), content = new ChangelogContent(), }, }, @@ -87,6 +88,7 @@ namespace osu.Game.Overlays } header.ShowReleaseStream(); content.ShowBuild(Streams.SelectedRelease); + chart.ShowChart(Streams.SelectedRelease); }; header.OnListingActivated += () => { From 22af3cd923a9e16e5a4643a511086b9d0b925fa5 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sat, 21 Jul 2018 09:37:58 +0200 Subject: [PATCH 029/375] Handle possible null reference; --- osu.Game/Graphics/StreamColour.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/StreamColour.cs b/osu.Game/Graphics/StreamColour.cs index 2a0d7fceab..3ee31c90e6 100644 --- a/osu.Game/Graphics/StreamColour.cs +++ b/osu.Game/Graphics/StreamColour.cs @@ -28,9 +28,10 @@ namespace osu.Game.Graphics public static ColourInfo FromStreamName(string name) { - if (colours.TryGetValue(name, out ColourInfo colour)) - return colour; - else return new Color4(255, 255, 255, 255); + if (!string.IsNullOrEmpty(name)) + if (colours.TryGetValue(name, out ColourInfo colour)) + return colour; + return new Color4(255, 255, 255, 255); } } } From e2af2b0409fe91d7239f69e2fb1e7e77df8ecc32 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sat, 21 Jul 2018 09:39:54 +0200 Subject: [PATCH 030/375] Change chart's colour depending on release stream; Show whether it's populated Fix chart requests --- .../API/Requests/GetChangelogChartRequest.cs | 21 +++++++++ .../Requests/Responses/APIChangelogChart.cs | 34 ++++++++++++++ osu.Game/Overlays/Changelog/ChangelogChart.cs | 44 +++++++++++++++++-- 3 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 osu.Game/Online/API/Requests/GetChangelogChartRequest.cs create mode 100644 osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs diff --git a/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs b/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs new file mode 100644 index 0000000000..4a9568af0b --- /dev/null +++ b/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs @@ -0,0 +1,21 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Online.API.Requests.Responses; +using System.Collections.Generic; + +namespace osu.Game.Online.API.Requests +{ + public class GetChangelogChartRequest : APIRequest + { + private readonly string updateStream; + + public GetChangelogChartRequest() => updateStream = null; + + public GetChangelogChartRequest(string updateStreamName) => updateStream = updateStreamName; + + protected override string Target => $@"changelog/{(!string.IsNullOrEmpty(updateStream) ? + updateStream + "/" : "")}chart-config"; + protected override string Uri => $@"https://houtarouoreki.github.io/fake-api/{Target}"; // for testing + } +} diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs new file mode 100644 index 0000000000..aa8c462018 --- /dev/null +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs @@ -0,0 +1,34 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using Newtonsoft.Json; +using osu.Framework.Lists; +using System; +using System.Collections.Generic; + +namespace osu.Game.Online.API.Requests.Responses +{ + public class APIChangelogChart + { + [JsonProperty("build_history")] + public List BuildHistory { get; set; } + + [JsonProperty("order")] + public List Order { get; set; } + + [JsonProperty("stream_name")] + public string StreamName { get; set; } + } + + public class BuildHistory + { + [JsonProperty("created_at")] + public DateTimeOffset CreatedAt { get; set; } + + [JsonProperty("user_count")] + public long UserCount { get; set; } + + [JsonProperty("label")] + public string Label { get; set; } + } +} diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs index 18c74f4b51..cb2d60c649 100644 --- a/osu.Game/Overlays/Changelog/ChangelogChart.cs +++ b/osu.Game/Overlays/Changelog/ChangelogChart.cs @@ -1,11 +1,15 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Overlays.Changelog @@ -15,6 +19,8 @@ namespace osu.Game.Overlays.Changelog public class ChangelogChart : BufferedContainer { private Box background; + private SpriteText text; + private APIAccess api; public ChangelogChart() { @@ -27,7 +33,7 @@ namespace osu.Game.Overlays.Changelog Colour = StreamColour.STABLE, RelativeSizeAxes = Axes.Both, }, - new SpriteText + text = new SpriteText { Text = "Graph Placeholder", TextSize = 28, @@ -37,9 +43,41 @@ namespace osu.Game.Overlays.Changelog }; } - public void ShowChart(APIChangelog releaseStream) + public void ShowChart(APIChangelog releaseStream) => fetchAndShowChangelogChart(releaseStream); + + private bool isEmpty(APIChangelogChart changelogChart) { - background.Colour = StreamColour.FromStreamName(releaseStream.UpdateStream.Name); + if (changelogChart != null) + foreach (BuildHistory buildHistory in changelogChart.BuildHistory) + if (buildHistory.UserCount > 0) return false; + return true; + } + + private void showChart(APIChangelogChart chartInfo, string updateStreamName) + { + if (!isEmpty(chartInfo)) + { + background.Colour = StreamColour.FromStreamName(updateStreamName); + text.Text = "Graph placeholder\n(chart is not empty)"; + } + else + { + background.Colour = Color4.Black; + text.Text = "Graph placeholder\n(chart is empty)"; + } + } + + [BackgroundDependencyLoader] + private void load(APIAccess api) + { + this.api = api; + } + + private void fetchAndShowChangelogChart(APIChangelog build) + { + var req = new GetChangelogChartRequest(build.UpdateStream.Name); + req.Success += res => showChart(res, build.UpdateStream.Name); + api.Queue(req); } } } From ba0430752caafec4abfabea92a9b6fe5822ac45a Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sat, 21 Jul 2018 09:45:14 +0200 Subject: [PATCH 031/375] Check wether a chart is populated; Fixes to graph's colour setting --- .../API/Requests/GetChangelogChartRequest.cs | 21 +++++++++ .../Requests/Responses/APIChangelogChart.cs | 34 ++++++++++++++ osu.Game/Overlays/Changelog/ChangelogChart.cs | 44 +++++++++++++++++-- 3 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 osu.Game/Online/API/Requests/GetChangelogChartRequest.cs create mode 100644 osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs diff --git a/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs b/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs new file mode 100644 index 0000000000..4a9568af0b --- /dev/null +++ b/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs @@ -0,0 +1,21 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Online.API.Requests.Responses; +using System.Collections.Generic; + +namespace osu.Game.Online.API.Requests +{ + public class GetChangelogChartRequest : APIRequest + { + private readonly string updateStream; + + public GetChangelogChartRequest() => updateStream = null; + + public GetChangelogChartRequest(string updateStreamName) => updateStream = updateStreamName; + + protected override string Target => $@"changelog/{(!string.IsNullOrEmpty(updateStream) ? + updateStream + "/" : "")}chart-config"; + protected override string Uri => $@"https://houtarouoreki.github.io/fake-api/{Target}"; // for testing + } +} diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs new file mode 100644 index 0000000000..aa8c462018 --- /dev/null +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs @@ -0,0 +1,34 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using Newtonsoft.Json; +using osu.Framework.Lists; +using System; +using System.Collections.Generic; + +namespace osu.Game.Online.API.Requests.Responses +{ + public class APIChangelogChart + { + [JsonProperty("build_history")] + public List BuildHistory { get; set; } + + [JsonProperty("order")] + public List Order { get; set; } + + [JsonProperty("stream_name")] + public string StreamName { get; set; } + } + + public class BuildHistory + { + [JsonProperty("created_at")] + public DateTimeOffset CreatedAt { get; set; } + + [JsonProperty("user_count")] + public long UserCount { get; set; } + + [JsonProperty("label")] + public string Label { get; set; } + } +} diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs index 18c74f4b51..cb2d60c649 100644 --- a/osu.Game/Overlays/Changelog/ChangelogChart.cs +++ b/osu.Game/Overlays/Changelog/ChangelogChart.cs @@ -1,11 +1,15 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Overlays.Changelog @@ -15,6 +19,8 @@ namespace osu.Game.Overlays.Changelog public class ChangelogChart : BufferedContainer { private Box background; + private SpriteText text; + private APIAccess api; public ChangelogChart() { @@ -27,7 +33,7 @@ namespace osu.Game.Overlays.Changelog Colour = StreamColour.STABLE, RelativeSizeAxes = Axes.Both, }, - new SpriteText + text = new SpriteText { Text = "Graph Placeholder", TextSize = 28, @@ -37,9 +43,41 @@ namespace osu.Game.Overlays.Changelog }; } - public void ShowChart(APIChangelog releaseStream) + public void ShowChart(APIChangelog releaseStream) => fetchAndShowChangelogChart(releaseStream); + + private bool isEmpty(APIChangelogChart changelogChart) { - background.Colour = StreamColour.FromStreamName(releaseStream.UpdateStream.Name); + if (changelogChart != null) + foreach (BuildHistory buildHistory in changelogChart.BuildHistory) + if (buildHistory.UserCount > 0) return false; + return true; + } + + private void showChart(APIChangelogChart chartInfo, string updateStreamName) + { + if (!isEmpty(chartInfo)) + { + background.Colour = StreamColour.FromStreamName(updateStreamName); + text.Text = "Graph placeholder\n(chart is not empty)"; + } + else + { + background.Colour = Color4.Black; + text.Text = "Graph placeholder\n(chart is empty)"; + } + } + + [BackgroundDependencyLoader] + private void load(APIAccess api) + { + this.api = api; + } + + private void fetchAndShowChangelogChart(APIChangelog build) + { + var req = new GetChangelogChartRequest(build.UpdateStream.Name); + req.Success += res => showChart(res, build.UpdateStream.Name); + api.Queue(req); } } } From b5207d65f7ab6fceb76c9ac423f63d4e999818f7 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sat, 21 Jul 2018 10:05:12 +0200 Subject: [PATCH 032/375] Show listing graph; Slight refactor --- osu.Game/Graphics/StreamColour.cs | 2 +- .../API/Requests/GetChangelogChartRequest.cs | 1 - .../Requests/Responses/APIChangelogChart.cs | 1 - osu.Game/Overlays/Changelog/ChangelogChart.cs | 21 ++++++++++++++++--- osu.Game/Overlays/ChangelogOverlay.cs | 2 ++ 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/osu.Game/Graphics/StreamColour.cs b/osu.Game/Graphics/StreamColour.cs index 3ee31c90e6..71626a0e3a 100644 --- a/osu.Game/Graphics/StreamColour.cs +++ b/osu.Game/Graphics/StreamColour.cs @@ -31,7 +31,7 @@ namespace osu.Game.Graphics if (!string.IsNullOrEmpty(name)) if (colours.TryGetValue(name, out ColourInfo colour)) return colour; - return new Color4(255, 255, 255, 255); + return new Color4(0, 0, 0, 255); } } } diff --git a/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs b/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs index 4a9568af0b..1e131fb91f 100644 --- a/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Game.Online.API.Requests.Responses; -using System.Collections.Generic; namespace osu.Game.Online.API.Requests { diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs index aa8c462018..3509ff7de1 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using Newtonsoft.Json; -using osu.Framework.Lists; using System; using System.Collections.Generic; diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs index cb2d60c649..b8df166a19 100644 --- a/osu.Game/Overlays/Changelog/ChangelogChart.cs +++ b/osu.Game/Overlays/Changelog/ChangelogChart.cs @@ -18,8 +18,8 @@ namespace osu.Game.Overlays.Changelog // placeholder json file: https://api.myjson.com/bins/10ye8a public class ChangelogChart : BufferedContainer { - private Box background; - private SpriteText text; + private readonly Box background; + private readonly SpriteText text; private APIAccess api; public ChangelogChart() @@ -43,6 +43,14 @@ namespace osu.Game.Overlays.Changelog }; } + /// + /// Draw the graph with all builds + /// + public void ShowChart() => fetchAndShowChangelogChart(); + + /// + /// Draw the graph for a specific build + /// public void ShowChart(APIChangelog releaseStream) => fetchAndShowChangelogChart(releaseStream); private bool isEmpty(APIChangelogChart changelogChart) @@ -53,7 +61,7 @@ namespace osu.Game.Overlays.Changelog return true; } - private void showChart(APIChangelogChart chartInfo, string updateStreamName) + private void showChart(APIChangelogChart chartInfo, string updateStreamName = null) { if (!isEmpty(chartInfo)) { @@ -79,5 +87,12 @@ namespace osu.Game.Overlays.Changelog req.Success += res => showChart(res, build.UpdateStream.Name); api.Queue(req); } + + private void fetchAndShowChangelogChart() + { + var req = new GetChangelogChartRequest(); + req.Success += res => showChart(res); + api.Queue(req); + } } } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index f2df54ac99..ce2878858f 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -101,6 +101,7 @@ namespace osu.Game.Overlays else foreach (StreamBadge item in Streams.BadgesContainer.Children) item.Deactivate(); + chart.ShowChart(); }; content.OnBuildChanged = () => { @@ -155,6 +156,7 @@ namespace osu.Game.Overlays Streams.BadgesContainer.Clear(); foreach (APIChangelog item in res) Streams.BadgesContainer.Add(new StreamBadge(item)); + chart.ShowChart(); }; api.Queue(req); } From 8f43b883b1509fa46b74ae8c094e022cbfa29893 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sat, 21 Jul 2018 23:00:05 +0200 Subject: [PATCH 033/375] Set the right colour for background --- osu.Game/Overlays/ChangelogOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index ce2878858f..cfa669534d 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -58,7 +58,7 @@ namespace osu.Game.Overlays new Box { RelativeSizeAxes = Axes.Both, - Colour = new Color4(20, 18, 23, 255) + Colour = new Color4(49, 36, 54, 255), }, new ScrollContainer { From 8e7efafba31193350088a0f0374060dd8eebad53 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sat, 21 Jul 2018 23:10:42 +0200 Subject: [PATCH 034/375] Lower height of the cover image, Adjust height of the purple line --- osu.Game/Overlays/Changelog/ChangelogHeader.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 1c3f6f0853..a744fc3c97 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -30,7 +30,7 @@ namespace osu.Game.Overlays.Changelog public APIChangelog ChangelogEntry; - private const float cover_height = 310; + private const float cover_height = 280; private const float title_height = 50; private const float icon_size = 50; private const float icon_margin = 20; @@ -155,7 +155,7 @@ namespace osu.Game.Overlays.Changelog { Colour = Purple, RelativeSizeAxes = Axes.X, - Height = 3, + Height = 2, Anchor = Anchor.BottomLeft, Origin = Anchor.CentreLeft, }, From 80808bddbf049e66e5b38c7e1c899a935d5b857c Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 05:28:43 +0200 Subject: [PATCH 035/375] Add changelog listing --- .../API/Requests/GetChangelogRequest.cs | 2 +- .../Overlays/Changelog/ChangelogContent.cs | 66 ++++++++++++++++-- .../Changelog/ChangelogContentGroup.cs | 69 +++++++++++++++++-- osu.Game/Overlays/ChangelogOverlay.cs | 3 +- 4 files changed, 124 insertions(+), 16 deletions(-) diff --git a/osu.Game/Online/API/Requests/GetChangelogRequest.cs b/osu.Game/Online/API/Requests/GetChangelogRequest.cs index 2f2e0ffe67..ec8536c607 100644 --- a/osu.Game/Online/API/Requests/GetChangelogRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogRequest.cs @@ -8,6 +8,6 @@ namespace osu.Game.Online.API.Requests public class GetChangelogRequest : APIRequest { protected override string Target => @"changelog"; - protected override string Uri => $@"https://houtarouoreki.github.io/fake-api/{Target}"; // for testing + protected override string Uri => $@"https://houtarouoreki.github.io/fake-api/{Target}/index"; // for testing } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 363b251383..a4797d6f7c 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -1,9 +1,11 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; @@ -11,7 +13,7 @@ using System; namespace osu.Game.Overlays.Changelog { - public class ChangelogContent : FillFlowContainer + public class ChangelogContent : FillFlowContainer { public APIChangelog CurrentBuild { get; private set; } public Action OnBuildChanged; @@ -23,11 +25,52 @@ namespace osu.Game.Overlays.Changelog RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; Direction = FillDirection.Vertical; - Padding = new MarginPadding + Padding = new MarginPadding{ Bottom = 100, }; + } + + private void add(APIChangelog[] changelog) + { + DateTime currentDate = new DateTime(); + + Clear(); + + foreach (APIChangelog build in changelog) { - Horizontal = 70, - Bottom = 100, - }; + if (build.CreatedAt.Date != currentDate) + { + if (Children.Count != 0) + { + Add(new Box + { + RelativeSizeAxes = Axes.X, + Height = 2, + Colour = new Color4(17, 17, 17, 255), + Margin = new MarginPadding { Top = 30, }, + }); + } + Add(changelogContentGroup = new ChangelogContentGroup(build, true) + { + BuildRequested = () => showBuild(build), + }); + changelogContentGroup.GenerateText(build.ChangelogEntries); + currentDate = build.CreatedAt.Date; + } + else + { + changelogContentGroup.Add(new Box + { + RelativeSizeAxes = Axes.X, + Height = 1, + Colour = new Color4(32, 24, 35, 255), + Margin = new MarginPadding { Top = 30, }, + }); + Add(changelogContentGroup = new ChangelogContentGroup(build, false) + { + BuildRequested = () => ShowBuild(build), + }); + changelogContentGroup.GenerateText(build.ChangelogEntries); + } + } } private void add(APIChangelog changelogBuild) @@ -41,10 +84,12 @@ namespace osu.Game.Overlays.Changelog public void ShowBuild(APIChangelog changelog) { + fetchAndShowChangelogBuild(changelog); CurrentBuild = changelog; - fetchChangelogBuild(changelog); } + public void ShowListing() => fetchAndShowChangelog(); + private void showBuild(APIChangelog changelog) { ShowBuild(changelog); @@ -75,7 +120,14 @@ namespace osu.Game.Overlays.Changelog this.api = api; } - private void fetchChangelogBuild(APIChangelog build) + private void fetchAndShowChangelog() + { + var req = new GetChangelogRequest(); + req.Success += res => add(res); + api.Queue(req); + } + + private void fetchAndShowChangelogBuild(APIChangelog build) { var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); req.Success += res => diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 4a6eb27cc7..0fc4c31bbe 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Changelog private readonly SortedDictionary> categories = new SortedDictionary>(); - public Action NextRequested, PreviousRequested; + public Action NextRequested, PreviousRequested, BuildRequested; public readonly FillFlowContainer ChangelogEntries; public ChangelogContentGroup(APIChangelog build) @@ -29,6 +29,7 @@ namespace osu.Game.Overlays.Changelog RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; Direction = FillDirection.Vertical; + Padding = new MarginPadding { Horizontal = 70 }; Children = new Drawable[] { // build version, arrows @@ -111,6 +112,67 @@ namespace osu.Game.Overlays.Changelog }; } + public ChangelogContentGroup(APIChangelog build, bool newDate = false) + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Direction = FillDirection.Vertical; + Padding = new MarginPadding { Horizontal = 70 }; + Children = new Drawable[] + { + new SpriteText + { + // do we need .ToUniversalTime() here? + // also, this should be a temporary solution to weekdays in >localized< date strings + Text = build.CreatedAt.Date.ToLongDateString().Replace(build.CreatedAt.ToString("dddd") + ", ", ""), + TextSize = 28, // web: 24, + Colour = OsuColour.FromHex(@"FD5"), + Font = @"Exo2.0-Light", + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Margin = new MarginPadding{ Top = 20, }, + Alpha = newDate ? 1 : 0, + }, + new FillFlowContainer + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Margin = new MarginPadding{ Top = 20, }, + Spacing = new Vector2(5), + Children = new Drawable[] + { + new SpriteText + { + Text = build.UpdateStream.DisplayName, + TextSize = 20, // web: 18, + Font = @"Exo2.0-Medium", + }, + new SpriteText + { + Text = build.DisplayVersion, + TextSize = 20, // web: 18, + Font = @"Exo2.0-Light", + Colour = StreamColour.FromStreamName(build.UpdateStream.Name), + }, + new ClickableText + { + Text = " ok ", + TextSize = 20, + Action = BuildRequested, + }, + } + }, + ChangelogEntries = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + }, + }; + } + public void UpdateChevronTooltips(string previousVersion, string nextVersion) { if (!string.IsNullOrEmpty(previousVersion)) @@ -138,10 +200,6 @@ namespace osu.Game.Overlays.Changelog foreach (KeyValuePair> category in categories) { - // textflowcontainer is unusable for formatting text - // this has to be a placeholder before we get a - // proper markdown/html formatting.. - // it can't handle overflowing properly ChangelogEntries.Add(new SpriteText { Text = category.Key, @@ -183,6 +241,5 @@ namespace osu.Game.Overlays.Changelog } } } - //public ChangelogContentGroup() { } // for listing } } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index cfa669534d..0a2c5e9b6f 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -93,8 +93,7 @@ namespace osu.Game.Overlays header.OnListingActivated += () => { Streams.SelectedRelease = null; - content.Clear(); - // should add listing to content here + content.ShowListing(); if (!Streams.IsHovered) foreach (StreamBadge item in Streams.BadgesContainer.Children) item.Activate(true); From c5bdfb885787cb6350bfa8f87d79c0ec5b7a1c8a Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 05:34:55 +0200 Subject: [PATCH 036/375] Use ClickableText for navigating to builds; Fix typo --- osu.Game/Overlays/Changelog/ChangelogContent.cs | 12 +++++++++--- osu.Game/Overlays/Changelog/ChangelogContentGroup.cs | 9 ++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index a4797d6f7c..36f9d3fec6 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -66,7 +66,7 @@ namespace osu.Game.Overlays.Changelog }); Add(changelogContentGroup = new ChangelogContentGroup(build, false) { - BuildRequested = () => ShowBuild(build), + BuildRequested = () => showBuild(build), }); changelogContentGroup.GenerateText(build.ChangelogEntries); } @@ -82,20 +82,26 @@ namespace osu.Game.Overlays.Changelog }; } + /// + /// Doesn't send back that the build has changed + /// public void ShowBuild(APIChangelog changelog) { fetchAndShowChangelogBuild(changelog); CurrentBuild = changelog; } - public void ShowListing() => fetchAndShowChangelog(); - + /// + /// Sends back that the build has changed + /// private void showBuild(APIChangelog changelog) { ShowBuild(changelog); OnBuildChanged(); } + public void ShowListing() => fetchAndShowChangelog(); + private void showNext() { if (CurrentBuild.Versions.Next != null) diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 0fc4c31bbe..36127d585e 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -149,18 +149,13 @@ namespace osu.Game.Overlays.Changelog TextSize = 20, // web: 18, Font = @"Exo2.0-Medium", }, - new SpriteText + new ClickableText { Text = build.DisplayVersion, TextSize = 20, // web: 18, Font = @"Exo2.0-Light", Colour = StreamColour.FromStreamName(build.UpdateStream.Name), - }, - new ClickableText - { - Text = " ok ", - TextSize = 20, - Action = BuildRequested, + Action = () => BuildRequested(), }, } }, From 2d36062159d8b3e5e77740eed2ec3c1305c2b60f Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 06:01:04 +0200 Subject: [PATCH 037/375] Add ClickableText --- .../Graphics/UserInterface/ClickableText.cs | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 osu.Game/Graphics/UserInterface/ClickableText.cs diff --git a/osu.Game/Graphics/UserInterface/ClickableText.cs b/osu.Game/Graphics/UserInterface/ClickableText.cs new file mode 100644 index 0000000000..8d0e98d687 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/ClickableText.cs @@ -0,0 +1,64 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input; +using System; + +namespace osu.Game.Graphics.UserInterface +{ + public class ClickableText : SpriteText, IHasTooltip + { + private bool isEnabled; + private SampleChannel sampleHover; + private SampleChannel sampleClick; + + public Action Action; + + public bool IsEnabled + { + get { return isEnabled; } + set + { + isEnabled = value; + Alpha = value ? 1 : 0.5f; + } + } + + public ClickableText() => isEnabled = true; + + public override bool HandleMouseInput => true; + + protected override bool OnHover(InputState state) + { + if (isEnabled) + sampleHover?.Play(); + return base.OnHover(state); + } + + protected override bool OnClick(InputState state) + { + if (isEnabled) + { + sampleClick?.Play(); + Action?.Invoke(); + } + return base.OnClick(state); + } + + public string TooltipText { get; set; } + + [BackgroundDependencyLoader] + private void load(AudioManager audio) + { + sampleHover = audio.Sample.Get(@"UI/generic-hover-soft"); + } + } +} From 9586ef7b0a28d160d13fb6c7989b8c79f010d103 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 08:28:12 +0200 Subject: [PATCH 038/375] ClickableText changes --- .../Visual/TestCaseClickableText.cs | 70 +++++++++++++++++++ .../Graphics/UserInterface/ClickableText.cs | 55 ++++++++++++--- 2 files changed, 117 insertions(+), 8 deletions(-) create mode 100644 osu.Game.Tests/Visual/TestCaseClickableText.cs diff --git a/osu.Game.Tests/Visual/TestCaseClickableText.cs b/osu.Game.Tests/Visual/TestCaseClickableText.cs new file mode 100644 index 0000000000..8bf58d8bf4 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseClickableText.cs @@ -0,0 +1,70 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.UserInterface; +using System; +using System.Collections.Generic; + +namespace osu.Game.Tests.Visual +{ + public class TestCaseClickableText : OsuTestCase + { + public override IReadOnlyList RequiredTypes => new[] { + typeof(ClickableText), + typeof(FillFlowContainer) + }; + + public TestCaseClickableText() + { + ClickableText text; + + Add(new FillFlowContainer + { + Spacing = new Vector2(10), + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Children = new[] + { + new ClickableText + { + Text = "Default", + }, + new ClickableText + { + IsEnabled = false, + Text = "Disabled", + }, + new ClickableText + { + Text = "Without sounds", + IsMuted = true, + }, + new ClickableText + { + Text = "Without click sounds", + IsClickMuted = true, + }, + new ClickableText + { + Text = "Without hover sounds", + IsHoverMuted = true, + }, + text = new ClickableText + { + Text = "Disables after click (Action)", + }, + new ClickableText + { + Text = "Has tooltip", + TooltipText = "Yep", + }, + }, + }); + text.Action = () => text.IsEnabled = false; + } + } +} diff --git a/osu.Game/Graphics/UserInterface/ClickableText.cs b/osu.Game/Graphics/UserInterface/ClickableText.cs index 8d0e98d687..a97569c4c1 100644 --- a/osu.Game/Graphics/UserInterface/ClickableText.cs +++ b/osu.Game/Graphics/UserInterface/ClickableText.cs @@ -1,44 +1,81 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Cursor; -using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; using osu.Framework.Input; +using osu.Game.Graphics.Sprites; using System; namespace osu.Game.Graphics.UserInterface -{ - public class ClickableText : SpriteText, IHasTooltip +{/// +/// +/// + public class ClickableText : OsuSpriteText, IHasTooltip { private bool isEnabled; + private bool isMuted; private SampleChannel sampleHover; private SampleChannel sampleClick; + /// + /// An action that can be set to execute after click. + /// public Action Action; + /// + /// If set to true, a sound will be played on click. + /// + public bool IsClickMuted; + + /// + /// If set to true, a sound will be played on hover. + /// + public bool IsHoverMuted; + + /// + /// If disabled, no sounds will be played and wont execute. + /// True by default. + /// public bool IsEnabled { get { return isEnabled; } set { isEnabled = value; - Alpha = value ? 1 : 0.5f; + this.FadeTo(value ? 1 : 0.5f, 250); } } + /// + /// Whether to play sounds on hover and click. Automatically sets + /// and to the same value.> + /// + public bool IsMuted { + get { return isMuted; } + set + { + IsHoverMuted = value; + IsClickMuted = value; + isMuted = value; + } + } + + /// + /// A text with sounds on hover and click, + /// an action that can be set to execute on click, + /// and a tooltip. + /// public ClickableText() => isEnabled = true; public override bool HandleMouseInput => true; protected override bool OnHover(InputState state) { - if (isEnabled) + if (isEnabled && !IsHoverMuted) sampleHover?.Play(); return base.OnHover(state); } @@ -47,7 +84,8 @@ namespace osu.Game.Graphics.UserInterface { if (isEnabled) { - sampleClick?.Play(); + if (!IsClickMuted) + sampleClick?.Play(); Action?.Invoke(); } return base.OnClick(state); @@ -58,6 +96,7 @@ namespace osu.Game.Graphics.UserInterface [BackgroundDependencyLoader] private void load(AudioManager audio) { + sampleClick = audio.Sample.Get(@"UI/generic-select-soft"); sampleHover = audio.Sample.Get(@"UI/generic-hover-soft"); } } From 2982fe35870d275d0fdbd93cd11c99fc92ad1130 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 09:19:26 +0200 Subject: [PATCH 039/375] Compress Test Case; Remove empty summary --- .../Visual/TestCaseClickableText.cs | 57 +++---------------- .../Graphics/UserInterface/ClickableText.cs | 4 +- 2 files changed, 10 insertions(+), 51 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseClickableText.cs b/osu.Game.Tests/Visual/TestCaseClickableText.cs index 8bf58d8bf4..fb0edf2989 100644 --- a/osu.Game.Tests/Visual/TestCaseClickableText.cs +++ b/osu.Game.Tests/Visual/TestCaseClickableText.cs @@ -1,8 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; -using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics.UserInterface; using System; @@ -12,57 +10,20 @@ namespace osu.Game.Tests.Visual { public class TestCaseClickableText : OsuTestCase { - public override IReadOnlyList RequiredTypes => new[] { - typeof(ClickableText), - typeof(FillFlowContainer) - }; + public override IReadOnlyList RequiredTypes => new[] { typeof(ClickableText) }; public TestCaseClickableText() { ClickableText text; - Add(new FillFlowContainer - { - Spacing = new Vector2(10), - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Children = new[] - { - new ClickableText - { - Text = "Default", - }, - new ClickableText - { - IsEnabled = false, - Text = "Disabled", - }, - new ClickableText - { - Text = "Without sounds", - IsMuted = true, - }, - new ClickableText - { - Text = "Without click sounds", - IsClickMuted = true, - }, - new ClickableText - { - Text = "Without hover sounds", - IsHoverMuted = true, - }, - text = new ClickableText - { - Text = "Disables after click (Action)", - }, - new ClickableText - { - Text = "Has tooltip", - TooltipText = "Yep", - }, - }, + AddRange(new[] { + new ClickableText{ Text = "Default", }, + new ClickableText{ IsEnabled = false, Text = "Disabled", }, + new ClickableText{ Text = "Without sounds", IsMuted = true, }, + new ClickableText{ Text = "Without click sounds", IsClickMuted = true, }, + new ClickableText{ Text = "Without hover sounds", IsHoverMuted = true, }, + text = new ClickableText{ Text = "Disables after click (Action)", }, + new ClickableText{ Text = "Has tooltip", TooltipText = "Yep", } }); text.Action = () => text.IsEnabled = false; } diff --git a/osu.Game/Graphics/UserInterface/ClickableText.cs b/osu.Game/Graphics/UserInterface/ClickableText.cs index a97569c4c1..f2f9f12228 100644 --- a/osu.Game/Graphics/UserInterface/ClickableText.cs +++ b/osu.Game/Graphics/UserInterface/ClickableText.cs @@ -11,9 +11,7 @@ using osu.Game.Graphics.Sprites; using System; namespace osu.Game.Graphics.UserInterface -{/// -/// -/// +{ public class ClickableText : OsuSpriteText, IHasTooltip { private bool isEnabled; From 2ea5a97784b7c46f4a34e28572ea5662e7829b58 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 09:31:51 +0200 Subject: [PATCH 040/375] Fix ClickableText test case --- .../Visual/TestCaseClickableText.cs | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseClickableText.cs b/osu.Game.Tests/Visual/TestCaseClickableText.cs index fb0edf2989..32167bc00a 100644 --- a/osu.Game.Tests/Visual/TestCaseClickableText.cs +++ b/osu.Game.Tests/Visual/TestCaseClickableText.cs @@ -10,20 +10,25 @@ namespace osu.Game.Tests.Visual { public class TestCaseClickableText : OsuTestCase { - public override IReadOnlyList RequiredTypes => new[] { typeof(ClickableText) }; + public override IReadOnlyList RequiredTypes => new[] { typeof(ClickableText), typeof(FillFlowContainer) }; public TestCaseClickableText() { ClickableText text; - AddRange(new[] { - new ClickableText{ Text = "Default", }, - new ClickableText{ IsEnabled = false, Text = "Disabled", }, - new ClickableText{ Text = "Without sounds", IsMuted = true, }, - new ClickableText{ Text = "Without click sounds", IsClickMuted = true, }, - new ClickableText{ Text = "Without hover sounds", IsHoverMuted = true, }, - text = new ClickableText{ Text = "Disables after click (Action)", }, - new ClickableText{ Text = "Has tooltip", TooltipText = "Yep", } + Add(new FillFlowContainer + { + Direction = FillDirection.Vertical, + Children = new[] + { + new ClickableText{ Text = "Default", }, + new ClickableText{ IsEnabled = false, Text = "Disabled", }, + new ClickableText{ Text = "Without sounds", IsMuted = true, }, + new ClickableText{ Text = "Without click sounds", IsClickMuted = true, }, + new ClickableText{ Text = "Without hover sounds", IsHoverMuted = true, }, + text = new ClickableText{ Text = "Disables after click (Action)", }, + new ClickableText{ Text = "Has tooltip", TooltipText = "Yep", } + } }); text.Action = () => text.IsEnabled = false; } From 8de65066dd0f70717ce1bb63ebac7fedd28a439f Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 10:28:53 +0200 Subject: [PATCH 041/375] Use shorter expression --- osu.Game/Overlays/Changelog/ChangelogContent.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 36f9d3fec6..f2f2c1b73d 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -129,7 +129,7 @@ namespace osu.Game.Overlays.Changelog private void fetchAndShowChangelog() { var req = new GetChangelogRequest(); - req.Success += res => add(res); + req.Success += add; api.Queue(req); } From 7e327fd084ddc6e2b0df9c4349e27d7a69d3cb59 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 12:02:45 +0200 Subject: [PATCH 042/375] Use using --- osu.Game.Tests/Visual/TestCaseClickableText.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseClickableText.cs b/osu.Game.Tests/Visual/TestCaseClickableText.cs index 32167bc00a..10b5e1b112 100644 --- a/osu.Game.Tests/Visual/TestCaseClickableText.cs +++ b/osu.Game.Tests/Visual/TestCaseClickableText.cs @@ -12,11 +12,11 @@ namespace osu.Game.Tests.Visual { public override IReadOnlyList RequiredTypes => new[] { typeof(ClickableText), typeof(FillFlowContainer) }; - public TestCaseClickableText() - { - ClickableText text; + ClickableText text; - Add(new FillFlowContainer + protected override void LoadComplete() + { + using (var fillFlowContainer = new FillFlowContainer { Direction = FillDirection.Vertical, Children = new[] @@ -29,8 +29,12 @@ namespace osu.Game.Tests.Visual text = new ClickableText{ Text = "Disables after click (Action)", }, new ClickableText{ Text = "Has tooltip", TooltipText = "Yep", } } - }); + }) + { + Add(fillFlowContainer); + } text.Action = () => text.IsEnabled = false; + base.LoadComplete(); } } } From 59cbc58edd93a04d9ed559e10f88e0a6dff7a09b Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 13:04:39 +0200 Subject: [PATCH 043/375] Show changelog by default --- osu.Game/Overlays/ChangelogOverlay.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 0a2c5e9b6f..0af9f57c03 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -74,12 +74,16 @@ namespace osu.Game.Overlays header = new ChangelogHeader(), Streams = new ChangelogStreams(), chart = new ChangelogChart(), - content = new ChangelogContent(), + content = new ChangelogContent() }, }, }, }; - OnLoadComplete += d => FetchChangelog(); + OnLoadComplete += d => + { + FetchChangelog(); + content.ShowListing(); + }; Streams.OnSelection = () => { if (Streams.SelectedRelease != null) From 2b7f657f2c579df5788d1d5789f9952855a8a822 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 14:44:11 +0200 Subject: [PATCH 044/375] Place HTML messages in a TextFlowContainer Add missing accessibility modifier in ClickableText test case and fix disposal --- .../Visual/TestCaseClickableText.cs | 31 ++++++------------- .../Changelog/ChangelogContentGroup.cs | 15 +++++---- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseClickableText.cs b/osu.Game.Tests/Visual/TestCaseClickableText.cs index 10b5e1b112..15401724d1 100644 --- a/osu.Game.Tests/Visual/TestCaseClickableText.cs +++ b/osu.Game.Tests/Visual/TestCaseClickableText.cs @@ -12,29 +12,18 @@ namespace osu.Game.Tests.Visual { public override IReadOnlyList RequiredTypes => new[] { typeof(ClickableText), typeof(FillFlowContainer) }; - ClickableText text; - - protected override void LoadComplete() + public TestCaseClickableText() => Child = new FillFlowContainer { - using (var fillFlowContainer = new FillFlowContainer + Children = new[] { - Direction = FillDirection.Vertical, - Children = new[] - { - new ClickableText{ Text = "Default", }, - new ClickableText{ IsEnabled = false, Text = "Disabled", }, - new ClickableText{ Text = "Without sounds", IsMuted = true, }, - new ClickableText{ Text = "Without click sounds", IsClickMuted = true, }, - new ClickableText{ Text = "Without hover sounds", IsHoverMuted = true, }, - text = new ClickableText{ Text = "Disables after click (Action)", }, - new ClickableText{ Text = "Has tooltip", TooltipText = "Yep", } - } - }) - { - Add(fillFlowContainer); + new ClickableText { Text = "Default", }, + new ClickableText { IsEnabled = false, Text = "Disabled", }, + new ClickableText { Text = "Without sounds", IsMuted = true, }, + new ClickableText { Text = "Without click sounds", IsClickMuted = true, }, + new ClickableText { Text = "Without hover sounds", IsHoverMuted = true, }, + new ClickableText { Text = "Disables after click (Action)", }, + new ClickableText { Text = "Has tooltip", TooltipText = "Yep", }, } - text.Action = () => text.IsEnabled = false; - base.LoadComplete(); - } + }; } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 36127d585e..504b3f78eb 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -156,6 +156,7 @@ namespace osu.Game.Overlays.Changelog Font = @"Exo2.0-Light", Colour = StreamColour.FromStreamName(build.UpdateStream.Name), Action = () => BuildRequested(), + IsClickMuted = true, }, } }, @@ -211,7 +212,7 @@ namespace osu.Game.Overlays.Changelog Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - LineSpacing = 0.25f, + Margin = new MarginPadding{ Vertical = 5, }, }); title.AddIcon(FontAwesome.fa_check, t => { t.TextSize = 12; t.Padding = new MarginPadding { Left = -17, Right = 5 }; }); title.AddText(entry.Title, t => { t.TextSize = 18; }); //t.Padding = new MarginPadding(10); }); @@ -224,15 +225,17 @@ namespace osu.Game.Overlays.Changelog }); } title.AddText($" by {entry.GithubUser.DisplayName}", t => t.TextSize = 14); //web: 12; - ChangelogEntries.Add(new SpriteText + TextFlowContainer messageContainer; + ChangelogEntries.Add(messageContainer = new OsuTextFlowContainer { - TextSize = 14, // web: 12, - Colour = new Color4(235, 184, 254, 255), - Text = $"{entry.MessageHtml?.Replace("

", "").Replace("

", "")}\n", - Margin = new MarginPadding { Bottom = 10, }, AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, }); + messageContainer.AddText($"{entry.MessageHtml?.Replace("

", "").Replace("

", "")}\n", t => + { + t.TextSize = 14; // web: 12, + t.Colour = new Color4(235, 184, 254, 255); + }); } } } From 421c95156b420c5eda20807419c19393646cc9ab Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 15:16:42 +0200 Subject: [PATCH 045/375] Fix ClickableText test case --- osu.Game.Tests/Visual/TestCaseClickableText.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/TestCaseClickableText.cs b/osu.Game.Tests/Visual/TestCaseClickableText.cs index 15401724d1..60ee764cfc 100644 --- a/osu.Game.Tests/Visual/TestCaseClickableText.cs +++ b/osu.Game.Tests/Visual/TestCaseClickableText.cs @@ -12,6 +12,7 @@ namespace osu.Game.Tests.Visual { public override IReadOnlyList RequiredTypes => new[] { typeof(ClickableText), typeof(FillFlowContainer) }; + private readonly ClickableText text; public TestCaseClickableText() => Child = new FillFlowContainer { Children = new[] @@ -21,7 +22,7 @@ namespace osu.Game.Tests.Visual new ClickableText { Text = "Without sounds", IsMuted = true, }, new ClickableText { Text = "Without click sounds", IsClickMuted = true, }, new ClickableText { Text = "Without hover sounds", IsHoverMuted = true, }, - new ClickableText { Text = "Disables after click (Action)", }, + text = new ClickableText { Text = "Disables after click (Action)", Action = () => text.IsEnabled = false }, new ClickableText { Text = "Has tooltip", TooltipText = "Yep", }, } }; From b3f789e19a0953e4f6a8596a9acfa2d283f11638 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 18:35:29 +0200 Subject: [PATCH 046/375] Rewrite ChangelogOverlay.cs --- osu.Game/Overlays/ChangelogOverlay.cs | 88 +++++++++++---------------- 1 file changed, 37 insertions(+), 51 deletions(-) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 0af9f57c03..4359741354 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -13,7 +13,6 @@ using osu.Game.Graphics.Containers; using osu.Game.Input.Bindings; using osu.Game.Online.API; using osu.Game.Online.API.Requests; -using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.Changelog; namespace osu.Game.Overlays @@ -21,13 +20,15 @@ namespace osu.Game.Overlays public class ChangelogOverlay : WaveOverlayContainer { private readonly ChangelogHeader header; - public readonly ChangelogStreams Streams; + private readonly ChangelogBadges badges; private readonly ChangelogChart chart; - private APIChangelog changelogEntry; + private readonly ChangelogContent content; + + private readonly Color4 purple = new Color4(191, 4, 255, 255); private APIAccess api; - protected readonly Color4 Purple = new Color4(191, 4, 255, 255); + private bool isAtListing; public ChangelogOverlay() { @@ -43,8 +44,6 @@ namespace osu.Game.Overlays Width = 0.85f; Masking = true; - ChangelogContent content; // told by appveyor to convert to local variable.. - EdgeEffect = new EdgeEffectParameters { Colour = Color4.Black.Opacity(0), @@ -72,49 +71,22 @@ namespace osu.Game.Overlays Children = new Drawable[] { header = new ChangelogHeader(), - Streams = new ChangelogStreams(), + badges = new ChangelogBadges(), chart = new ChangelogChart(), content = new ChangelogContent() }, }, }, }; - OnLoadComplete += d => - { - FetchChangelog(); - content.ShowListing(); - }; - Streams.OnSelection = () => - { - if (Streams.SelectedRelease != null) - { - header.ChangelogEntry = Streams.SelectedRelease; - } - header.ShowReleaseStream(); - content.ShowBuild(Streams.SelectedRelease); - chart.ShowChart(Streams.SelectedRelease); - }; - header.OnListingActivated += () => - { - Streams.SelectedRelease = null; - content.ShowListing(); - if (!Streams.IsHovered) - foreach (StreamBadge item in Streams.BadgesContainer.Children) - item.Activate(true); - else - foreach (StreamBadge item in Streams.BadgesContainer.Children) - item.Deactivate(); - chart.ShowChart(); - }; - content.OnBuildChanged = () => - { - header.ChangelogEntry = content.CurrentBuild; - header.ShowReleaseStream(); - }; + // content.ShowListing(); + // if (!Streams.IsHovered) + // foreach (StreamBadge item in Streams.BadgesContainer.Children) + // item.Activate(true); + // else + // foreach (StreamBadge item in Streams.BadgesContainer.Children) + // item.Deactivate(); } - public void ActivateListing() => header.ActivateListing(); - // receive input outside our bounds so we can trigger a close event on ourselves. public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; @@ -123,10 +95,10 @@ namespace osu.Game.Overlays switch (action) { case GlobalAction.Back: - if (header.IsListingActivated()) + if (isAtListing) State = Visibility.Hidden; else - header.ActivateListing(); + FetchAndShowListing(); return true; } @@ -151,16 +123,30 @@ namespace osu.Game.Overlays this.api = api; } - public void FetchChangelog() + /// + /// Fetches and shows changelog listing. + /// + public void FetchAndShowListing() { var req = new GetChangelogLatestBuildsRequest(); - req.Success += res => - { - Streams.BadgesContainer.Clear(); - foreach (APIChangelog item in res) - Streams.BadgesContainer.Add(new StreamBadge(item)); - chart.ShowChart(); - }; + header.ShowListing(); + badges.SelectNone(); + chart.ShowAllUpdateStreams(); + req.Success += content.ShowListing; + api.Queue(req); + } + + /// + /// Fetches and shows a specific build from a specific update stream. + /// + /// If true, will select fetched build's update stream badge. + public void FetchAndShowBuild(string updateStream, string version) + { + var req = new GetChangelogBuildRequest(updateStream, version); + header.ShowBuild(updateStream, version); + badges.SelectBadge(updateStream); + chart.ShowUpdateStream(updateStream); + req.Success += content.ShowBuild; api.Queue(req); } } From 797abd558f38647e042d283138c234addf1a6c87 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 18:44:45 +0200 Subject: [PATCH 047/375] Rewrite ChangelogHeader.cs --- .../Overlays/Changelog/ChangelogHeader.cs | 42 +++++-------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index a744fc3c97..6a7ccacdc3 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -26,9 +26,7 @@ namespace osu.Game.Overlays.Changelog private readonly TextBadgePairListing listing; private readonly TextBadgePairRelease releaseStream; - public Action OnListingActivated; - - public APIChangelog ChangelogEntry; + public Action ListingActivated; private const float cover_height = 280; private const float title_height = 50; @@ -160,41 +158,21 @@ namespace osu.Game.Overlays.Changelog Origin = Anchor.CentreLeft, }, }; - - // is this a bad way to do this? - OnLoadComplete = d => - { - releaseStream.OnActivation = () => - { - listing.Deactivate(); - chevron.MoveToX(0, 100).FadeIn(100); - }; - listing.OnActivation = () => - { - releaseStream.Deactivate(); - chevron.MoveToX(-20, 100).FadeOut(100); - changeHeaderText("Listing"); - OnListingActivated?.Invoke(); - }; - }; } - public void ShowReleaseStream() + public void ShowBuild(string updateStream, string version) { - releaseStream.Activate(String.Join(" ", - ChangelogEntry.UpdateStream.DisplayName, ChangelogEntry.DisplayVersion)); - changeHeaderText(ChangelogEntry.UpdateStream.DisplayName); - } - - private void changeHeaderText(string headerText) - { - titleStream.Text = headerText; + listing.Deactivate(); + releaseStream.Activate($"{updateStream} {version}"); + titleStream.Text = updateStream; titleStream.FlashColour(Color4.White, 500, Easing.OutQuad); } - public void ActivateListing() => listing.Activate(); - - public bool IsListingActivated() => listing.IsActivated; + public void ShowListing() + { + releaseStream.Deactivate(); + listing.Activate(); + } [BackgroundDependencyLoader] private void load(TextureStore textures) From a8bbcca0e06de761ddce0eac18024e00001df466 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 19:51:31 +0200 Subject: [PATCH 048/375] Rewrite ChangelogBadges --- .../Overlays/Changelog/ChangelogBadges.cs | 130 ++++++++++++++++++ osu.Game/Overlays/Changelog/StreamBadge.cs | 8 +- 2 files changed, 135 insertions(+), 3 deletions(-) create mode 100644 osu.Game/Overlays/Changelog/ChangelogBadges.cs diff --git a/osu.Game/Overlays/Changelog/ChangelogBadges.cs b/osu.Game/Overlays/Changelog/ChangelogBadges.cs new file mode 100644 index 0000000000..8bd52e76bc --- /dev/null +++ b/osu.Game/Overlays/Changelog/ChangelogBadges.cs @@ -0,0 +1,130 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Input; +using osu.Game.Online.API.Requests.Responses; +using System; +using System.Collections.Generic; + +namespace osu.Game.Overlays.Changelog +{ + public class ChangelogBadges : Container + { + private const float container_height = 106.5f; + private const float padding_y = 20; + private const float padding_x = 85; + + public delegate void SelectionHandler(string updateStream, string version, EventArgs args); + + public event SelectionHandler Selected; + + private readonly FillFlowContainer badgesContainer; + + public ChangelogBadges() + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = new Color4(32, 24, 35, 255), + }, + badgesContainer = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding + { + Top = padding_y, + Bottom = padding_y, + Left = padding_x, + Right = padding_x, + }, + }, + }; + //foreach (StreamBadge streamBadge in BadgesContainer.Children) + //{ + // streamBadge.OnActivation = () => + // { + // SelectedRelease = streamBadge.ChangelogEntry; + // foreach (StreamBadge item in BadgesContainer.Children) + // if (item.ChangelogEntry.Id != streamBadge.ChangelogEntry.Id) + // item.Deactivate(); + // OnSelection?.Invoke(); + // }; + //} + } + + public void Populate(List latestBuilds) + { + foreach (APIChangelog updateStream in latestBuilds) + { + var streamBadge = new StreamBadge(updateStream); + streamBadge.Selected += OnBadgeSelected; + badgesContainer.Add(streamBadge); + } + } + + public void SelectNone() + { + foreach (StreamBadge streamBadge in badgesContainer) + streamBadge.Deactivate(); + } + + public void SelectUpdateStream(string updateStream) + { + foreach (StreamBadge streamBadge in badgesContainer) + if (streamBadge.ChangelogEntry.UpdateStream.Name == updateStream) + { + streamBadge.Activate(); + return; + } + } + + private void OnBadgeSelected(StreamBadge source, EventArgs args) + { + OnSelected(source); + } + + protected virtual void OnSelected(StreamBadge source) + { + if (Selected != null) + Selected(source.ChangelogEntry.UpdateStream.Name, source.ChangelogEntry.Version, EventArgs.Empty); + } + + //protected override bool OnHover(InputState state) + //{ + // foreach (StreamBadge streamBadge in BadgesContainer.Children) + // { + // if (SelectedRelease != null) + // { + // if (SelectedRelease.UpdateStream.Id != streamBadge.ChangelogEntry.UpdateStream.Id) + // streamBadge.Deactivate(); + // else + // streamBadge.EnableDim(); + // } + // else + // streamBadge.Deactivate(); + // } + // return base.OnHover(state); + //} + + //protected override void OnHoverLost(InputState state) + //{ + // foreach (StreamBadge streamBadge in BadgesContainer.Children) + // { + // if (SelectedRelease == null) + // streamBadge.Activate(true); + // else if (streamBadge.ChangelogEntry.UpdateStream.Id == SelectedRelease.UpdateStream.Id) + // streamBadge.DisableDim(); + // } + // base.OnHoverLost(state); + //} + } +} diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 80b2fb2a03..8294e6c403 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -21,7 +21,9 @@ namespace osu.Game.Overlays.Changelog private const float badge_width = 100; private const float transition_duration = 100; - public Action OnActivation; + public delegate void SelectedHandler(StreamBadge source, EventArgs args); + + public event SelectedHandler Selected; private bool isActivated; @@ -88,8 +90,8 @@ namespace osu.Game.Overlays.Changelog isActivated = true; this.FadeIn(transition_duration); lineBadge.IsCollapsed = false; - if (!withoutHeaderUpdate) - OnActivation?.Invoke(); + if (!withoutHeaderUpdate && Selected != null) + Selected(this, EventArgs.Empty); } public void Deactivate() From eca6265186d7da9e14eafe9dab47b32a6ff5c6ff Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 20:14:28 +0200 Subject: [PATCH 049/375] Rewrite ChangelogContent.cs --- .../Overlays/Changelog/ChangelogContent.cs | 94 +++---------------- 1 file changed, 15 insertions(+), 79 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index f2f2c1b73d..d06ef32420 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -15,11 +15,13 @@ namespace osu.Game.Overlays.Changelog { public class ChangelogContent : FillFlowContainer { - public APIChangelog CurrentBuild { get; private set; } - public Action OnBuildChanged; private APIAccess api; private ChangelogContentGroup changelogContentGroup; + public delegate void BuildSelectedEventHandler(string updateStream, string version, EventArgs args); + + public event BuildSelectedEventHandler BuildSelected; + public ChangelogContent() { RelativeSizeAxes = Axes.X; @@ -48,10 +50,9 @@ namespace osu.Game.Overlays.Changelog Margin = new MarginPadding { Top = 30, }, }); } - Add(changelogContentGroup = new ChangelogContentGroup(build, true) - { - BuildRequested = () => showBuild(build), - }); + // watch out for this? + Add(changelogContentGroup = new ChangelogContentGroup(build, true)); + changelogContentGroup.BuildSelected += OnBuildSelected; changelogContentGroup.GenerateText(build.ChangelogEntries); currentDate = build.CreatedAt.Date; } @@ -64,86 +65,21 @@ namespace osu.Game.Overlays.Changelog Colour = new Color4(32, 24, 35, 255), Margin = new MarginPadding { Top = 30, }, }); - Add(changelogContentGroup = new ChangelogContentGroup(build, false) - { - BuildRequested = () => showBuild(build), - }); + Add(changelogContentGroup = new ChangelogContentGroup(build, false)); + changelogContentGroup.BuildSelected += OnBuildSelected; changelogContentGroup.GenerateText(build.ChangelogEntries); } } } + private void OnBuildSelected(string updateStream, string version, EventArgs args) + { + throw new NotImplementedException(); + } + private void add(APIChangelog changelogBuild) { - Child = changelogContentGroup = new ChangelogContentGroup(changelogBuild) - { - PreviousRequested = showPrevious, - NextRequested = showNext, - }; - } - - /// - /// Doesn't send back that the build has changed - /// - public void ShowBuild(APIChangelog changelog) - { - fetchAndShowChangelogBuild(changelog); - CurrentBuild = changelog; - } - - /// - /// Sends back that the build has changed - /// - private void showBuild(APIChangelog changelog) - { - ShowBuild(changelog); - OnBuildChanged(); - } - - public void ShowListing() => fetchAndShowChangelog(); - - private void showNext() - { - if (CurrentBuild.Versions.Next != null) - showBuild(CurrentBuild.Versions.Next); - } - - private void showPrevious() - { - if (CurrentBuild.Versions.Previous != null) - showBuild(CurrentBuild.Versions.Previous); - } - - private void updateChevronTooltips() - { - changelogContentGroup.UpdateChevronTooltips(CurrentBuild.Versions.Previous?.DisplayVersion, - CurrentBuild.Versions.Next?.DisplayVersion); - } - - [BackgroundDependencyLoader] - private void load(APIAccess api) - { - this.api = api; - } - - private void fetchAndShowChangelog() - { - var req = new GetChangelogRequest(); - req.Success += add; - api.Queue(req); - } - - private void fetchAndShowChangelogBuild(APIChangelog build) - { - var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); - req.Success += res => - { - CurrentBuild = res; - add(CurrentBuild); - changelogContentGroup.GenerateText(CurrentBuild.ChangelogEntries); - updateChevronTooltips(); - }; - api.Queue(req); + Child = changelogContentGroup = new ChangelogContentGroup(changelogBuild); } } } From 6683d4cabeac6446c1b402129716f2ece6bafe8c Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 20:14:58 +0200 Subject: [PATCH 050/375] Add event handling in content groups --- .../Changelog/ChangelogContentGroup.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 504b3f78eb..0efa8b70c6 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -21,7 +21,10 @@ namespace osu.Game.Overlays.Changelog private readonly SortedDictionary> categories = new SortedDictionary>(); - public Action NextRequested, PreviousRequested, BuildRequested; + public delegate void BuildSelectedEventHandler(string updateStream, string version, EventArgs args); + + public event BuildSelectedEventHandler BuildSelected; + public readonly FillFlowContainer ChangelogEntries; public ChangelogContentGroup(APIChangelog build) @@ -50,7 +53,8 @@ namespace osu.Game.Overlays.Changelog IsEnabled = false, Icon = FontAwesome.fa_chevron_left, Size = new Vector2(24), - Action = () => PreviousRequested(), + Action = () => OnBuildSelected(build.Versions.Previous.UpdateStream.Name, + build.Versions.Previous.Version), }, new FillFlowContainer { @@ -87,7 +91,8 @@ namespace osu.Game.Overlays.Changelog IsEnabled = false, Icon = FontAwesome.fa_chevron_right, Size = new Vector2(24), - Action = () => NextRequested(), + Action = () => OnBuildSelected(build.Versions.Next.UpdateStream.Name, + build.Versions.Next.Version), }, } }, @@ -155,7 +160,7 @@ namespace osu.Game.Overlays.Changelog TextSize = 20, // web: 18, Font = @"Exo2.0-Light", Colour = StreamColour.FromStreamName(build.UpdateStream.Name), - Action = () => BuildRequested(), + Action = () => OnBuildSelected(build.UpdateStream.Name, build.Version), IsClickMuted = true, }, } @@ -183,6 +188,12 @@ namespace osu.Game.Overlays.Changelog } } + protected virtual void OnBuildSelected(string updateStream, string version) + { + if (BuildSelected != null) + BuildSelected(updateStream, version, EventArgs.Empty); + } + public void GenerateText(List changelogEntries) { // sort entries by category From 23309b3b0045abe3fef10c93869761b97a57f48c Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 20:27:20 +0200 Subject: [PATCH 051/375] Strip test case --- osu.Game.Tests/Visual/TestCaseChangelog.cs | 55 ---------------------- 1 file changed, 55 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseChangelog.cs b/osu.Game.Tests/Visual/TestCaseChangelog.cs index ea6aa8086f..0710f7a254 100644 --- a/osu.Game.Tests/Visual/TestCaseChangelog.cs +++ b/osu.Game.Tests/Visual/TestCaseChangelog.cs @@ -10,67 +10,12 @@ namespace osu.Game.Tests.Visual public class TestCaseChangelog : OsuTestCase { private ChangelogOverlay changelog; - private int index; - private void indexIncrement() => index = index >= changelog.Streams.BadgesContainer.Children.Count - 1 ? 0 : index + 1; - private bool isLoaded => changelog.Streams.BadgesContainer.Children.Count > 0; protected override void LoadComplete() { base.LoadComplete(); Add(changelog = new ChangelogOverlay()); - - AddStep(@"Show", changelog.Show); - AddRepeatStep(@"Toggle Release Stream", () => - { - if (isLoaded) - changelog.Streams.BadgesContainer.Children[index].Activate(); - indexIncrement(); - }, 6); - AddStep(@"Listing", changelog.ActivateListing); - AddStep(@"Hide", changelog.Hide); - AddWaitStep(3); - AddStep(@"Show with Release Stream", () => - { - if (isLoaded) - changelog.Streams.BadgesContainer.Children[index].Activate(); - changelog.Show(); - indexIncrement(); - }); - AddWaitStep(3); - AddStep(@"Hide", changelog.Hide); - AddWaitStep(3); - AddStep(@"Show with listing", () => - { - changelog.ActivateListing(); - changelog.Show(); - }); - AddWaitStep(3); - AddStep(@"Hide", changelog.Hide); - AddWaitStep(3); - AddStep(@"Activate release", () => - { - if (isLoaded) - changelog.Streams.BadgesContainer.Children[index].Activate(); - indexIncrement(); - }); - AddStep(@"Show with listing", () => - { - changelog.ActivateListing(); - changelog.Show(); - }); - AddStep(@"Activate Release", () => - { - if (isLoaded) - changelog.Streams.BadgesContainer.Children[index].Activate(); - }); - AddStep(@"Activate Listing", changelog.ActivateListing); - AddStep(@"Activate Release", () => - { - if (isLoaded) - changelog.Streams.BadgesContainer.Children[index].Activate(); - indexIncrement(); - }); } } } From 61a8b98d32fe7a3295354ac6c1fc2787b14feec6 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 20:27:50 +0200 Subject: [PATCH 052/375] Rewrite improvements --- osu.Game/Overlays/Changelog/ChangelogChart.cs | 14 +-- .../Overlays/Changelog/ChangelogContent.cs | 20 ++-- .../Overlays/Changelog/ChangelogStreams.cs | 98 ------------------- osu.Game/Overlays/ChangelogOverlay.cs | 10 +- 4 files changed, 24 insertions(+), 118 deletions(-) delete mode 100644 osu.Game/Overlays/Changelog/ChangelogStreams.cs diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs index b8df166a19..91e2aa5e49 100644 --- a/osu.Game/Overlays/Changelog/ChangelogChart.cs +++ b/osu.Game/Overlays/Changelog/ChangelogChart.cs @@ -43,15 +43,9 @@ namespace osu.Game.Overlays.Changelog }; } - /// - /// Draw the graph with all builds - /// - public void ShowChart() => fetchAndShowChangelogChart(); - /// /// Draw the graph for a specific build /// - public void ShowChart(APIChangelog releaseStream) => fetchAndShowChangelogChart(releaseStream); private bool isEmpty(APIChangelogChart changelogChart) { @@ -81,14 +75,14 @@ namespace osu.Game.Overlays.Changelog this.api = api; } - private void fetchAndShowChangelogChart(APIChangelog build) + public void ShowUpdateStream(string updateStream) { - var req = new GetChangelogChartRequest(build.UpdateStream.Name); - req.Success += res => showChart(res, build.UpdateStream.Name); + var req = new GetChangelogChartRequest(updateStream); + req.Success += res => showChart(res, updateStream); api.Queue(req); } - private void fetchAndShowChangelogChart() + public void ShowAllUpdateStreams() { var req = new GetChangelogChartRequest(); req.Success += res => showChart(res); diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index d06ef32420..5eb19119ec 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -10,6 +10,7 @@ using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; using System; +using System.Collections.Generic; namespace osu.Game.Overlays.Changelog { @@ -30,7 +31,7 @@ namespace osu.Game.Overlays.Changelog Padding = new MarginPadding{ Bottom = 100, }; } - private void add(APIChangelog[] changelog) + public void ShowListing(List changelog) { DateTime currentDate = new DateTime(); @@ -52,7 +53,7 @@ namespace osu.Game.Overlays.Changelog } // watch out for this? Add(changelogContentGroup = new ChangelogContentGroup(build, true)); - changelogContentGroup.BuildSelected += OnBuildSelected; + changelogContentGroup.BuildSelected += onBuildSelected; changelogContentGroup.GenerateText(build.ChangelogEntries); currentDate = build.CreatedAt.Date; } @@ -66,20 +67,21 @@ namespace osu.Game.Overlays.Changelog Margin = new MarginPadding { Top = 30, }, }); Add(changelogContentGroup = new ChangelogContentGroup(build, false)); - changelogContentGroup.BuildSelected += OnBuildSelected; + changelogContentGroup.BuildSelected += onBuildSelected; changelogContentGroup.GenerateText(build.ChangelogEntries); } } } - private void OnBuildSelected(string updateStream, string version, EventArgs args) - { - throw new NotImplementedException(); - } - - private void add(APIChangelog changelogBuild) + public void ShowBuild(APIChangelog changelogBuild) { Child = changelogContentGroup = new ChangelogContentGroup(changelogBuild); } + + protected virtual void onBuildSelected(string updateStream, string version, EventArgs args) + { + if (BuildSelected != null) + BuildSelected(updateStream, version, EventArgs.Empty); + } } } diff --git a/osu.Game/Overlays/Changelog/ChangelogStreams.cs b/osu.Game/Overlays/Changelog/ChangelogStreams.cs deleted file mode 100644 index 1e6e9e1e51..0000000000 --- a/osu.Game/Overlays/Changelog/ChangelogStreams.cs +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using OpenTK.Graphics; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osu.Framework.Input; -using osu.Game.Online.API.Requests.Responses; -using System; - -namespace osu.Game.Overlays.Changelog -{ - public class ChangelogStreams : Container - { - private const float container_height = 106.5f; - private const float padding_y = 20; - private const float padding_x = 85; - public Action OnSelection; - - public APIChangelog SelectedRelease; - // not using SelectedRelease as a Bindable and then using .OnValueChange instead of OnSelection - // because it doesn't "refresh" the selection if the same stream is chosen - - public readonly FillFlowContainer BadgesContainer; - - public ChangelogStreams() - { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = new Color4(32, 24, 35, 255), - }, - BadgesContainer = new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Padding = new MarginPadding - { - Top = padding_y, - Bottom = padding_y, - Left = padding_x, - Right = padding_x, - }, - }, - }; - // ok, so this is probably not the best. - // how else can this be done? - BadgesContainer.OnUpdate = d => - { - foreach (StreamBadge streamBadge in BadgesContainer.Children) - { - streamBadge.OnActivation = () => - { - SelectedRelease = streamBadge.ChangelogEntry; - foreach (StreamBadge item in BadgesContainer.Children) - if (item.ChangelogEntry.Id != streamBadge.ChangelogEntry.Id) - item.Deactivate(); - OnSelection?.Invoke(); - }; - } - }; - } - - protected override bool OnHover(InputState state) - { - foreach (StreamBadge streamBadge in BadgesContainer.Children) - { - if (SelectedRelease != null) - { - if (SelectedRelease.UpdateStream.Id != streamBadge.ChangelogEntry.UpdateStream.Id) - streamBadge.Deactivate(); - else - streamBadge.EnableDim(); - } - else - streamBadge.Deactivate(); - } - return base.OnHover(state); - } - - protected override void OnHoverLost(InputState state) - { - foreach (StreamBadge streamBadge in BadgesContainer.Children) - { - if (SelectedRelease == null) - streamBadge.Activate(true); - else if (streamBadge.ChangelogEntry.UpdateStream.Id == SelectedRelease.UpdateStream.Id) - streamBadge.DisableDim(); - } - base.OnHoverLost(state); - } - } -} diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 4359741354..2ae5bbdd78 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -14,6 +14,7 @@ using osu.Game.Input.Bindings; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Overlays.Changelog; +using System; namespace osu.Game.Overlays { @@ -78,6 +79,8 @@ namespace osu.Game.Overlays }, }, }; + + badges.Selected += onBuildSelected; // content.ShowListing(); // if (!Streams.IsHovered) // foreach (StreamBadge item in Streams.BadgesContainer.Children) @@ -117,6 +120,11 @@ namespace osu.Game.Overlays FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out); } + private void onBuildSelected(string updateStream, string version, EventArgs e) + { + FetchAndShowBuild(updateStream, version); + } + [BackgroundDependencyLoader] private void load(APIAccess api) { @@ -144,7 +152,7 @@ namespace osu.Game.Overlays { var req = new GetChangelogBuildRequest(updateStream, version); header.ShowBuild(updateStream, version); - badges.SelectBadge(updateStream); + badges.SelectUpdateStream(updateStream); chart.ShowUpdateStream(updateStream); req.Success += content.ShowBuild; api.Queue(req); From 24abec43c1ff780fd017321434b9504649e34f6b Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 21:00:29 +0200 Subject: [PATCH 053/375] Show on test case --- osu.Game.Tests/Visual/TestCaseChangelog.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Tests/Visual/TestCaseChangelog.cs b/osu.Game.Tests/Visual/TestCaseChangelog.cs index 0710f7a254..da260c239b 100644 --- a/osu.Game.Tests/Visual/TestCaseChangelog.cs +++ b/osu.Game.Tests/Visual/TestCaseChangelog.cs @@ -16,6 +16,7 @@ namespace osu.Game.Tests.Visual base.LoadComplete(); Add(changelog = new ChangelogOverlay()); + AddStep(@"Show", changelog.Show); } } } From 51eec0dca44e11e7a9c1ae29c4d1ce451c5db325 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 22:13:14 +0200 Subject: [PATCH 054/375] Further rewrite --- .../Overlays/Changelog/ChangelogBadges.cs | 79 +++++++++++-------- .../Overlays/Changelog/ChangelogContent.cs | 3 +- .../Overlays/Changelog/ChangelogHeader.cs | 6 +- osu.Game/Overlays/Changelog/StreamBadge.cs | 6 +- osu.Game/Overlays/ChangelogOverlay.cs | 30 ++++--- 5 files changed, 71 insertions(+), 53 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogBadges.cs b/osu.Game/Overlays/Changelog/ChangelogBadges.cs index 8bd52e76bc..53f6a75bbc 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBadges.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBadges.cs @@ -23,6 +23,7 @@ namespace osu.Game.Overlays.Changelog public event SelectionHandler Selected; private readonly FillFlowContainer badgesContainer; + private long selectedStreamId = -1; public ChangelogBadges() { @@ -66,29 +67,43 @@ namespace osu.Game.Overlays.Changelog foreach (APIChangelog updateStream in latestBuilds) { var streamBadge = new StreamBadge(updateStream); - streamBadge.Selected += OnBadgeSelected; + streamBadge.Selected += onBadgeSelected; badgesContainer.Add(streamBadge); } } public void SelectNone() { - foreach (StreamBadge streamBadge in badgesContainer) - streamBadge.Deactivate(); + selectedStreamId = -1; + if (badgesContainer != null) + { + foreach (StreamBadge streamBadge in badgesContainer) + { + if (!IsHovered) + streamBadge.Activate(); + else + streamBadge.Deactivate(); + } + } } public void SelectUpdateStream(string updateStream) { foreach (StreamBadge streamBadge in badgesContainer) + { if (streamBadge.ChangelogEntry.UpdateStream.Name == updateStream) { + selectedStreamId = streamBadge.ChangelogEntry.UpdateStream.Id; streamBadge.Activate(); - return; } + else + streamBadge.Deactivate(); + } } - private void OnBadgeSelected(StreamBadge source, EventArgs args) + private void onBadgeSelected(StreamBadge source, EventArgs args) { + selectedStreamId = source.ChangelogEntry.UpdateStream.Id; OnSelected(source); } @@ -98,33 +113,33 @@ namespace osu.Game.Overlays.Changelog Selected(source.ChangelogEntry.UpdateStream.Name, source.ChangelogEntry.Version, EventArgs.Empty); } - //protected override bool OnHover(InputState state) - //{ - // foreach (StreamBadge streamBadge in BadgesContainer.Children) - // { - // if (SelectedRelease != null) - // { - // if (SelectedRelease.UpdateStream.Id != streamBadge.ChangelogEntry.UpdateStream.Id) - // streamBadge.Deactivate(); - // else - // streamBadge.EnableDim(); - // } - // else - // streamBadge.Deactivate(); - // } - // return base.OnHover(state); - //} + protected override bool OnHover(InputState state) + { + foreach (StreamBadge streamBadge in badgesContainer.Children) + { + if (selectedStreamId < 0) + { + if (selectedStreamId != streamBadge.ChangelogEntry.UpdateStream.Id) + streamBadge.Deactivate(); + else + streamBadge.EnableDim(); + } + else + streamBadge.Deactivate(); + } + return base.OnHover(state); + } - //protected override void OnHoverLost(InputState state) - //{ - // foreach (StreamBadge streamBadge in BadgesContainer.Children) - // { - // if (SelectedRelease == null) - // streamBadge.Activate(true); - // else if (streamBadge.ChangelogEntry.UpdateStream.Id == SelectedRelease.UpdateStream.Id) - // streamBadge.DisableDim(); - // } - // base.OnHoverLost(state); - //} + protected override void OnHoverLost(InputState state) + { + foreach (StreamBadge streamBadge in badgesContainer.Children) + { + if (selectedStreamId < 0) + streamBadge.Activate(true); + else if (streamBadge.ChangelogEntry.UpdateStream.Id == selectedStreamId) + streamBadge.DisableDim(); + } + base.OnHoverLost(state); + } } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 5eb19119ec..3b45e4af87 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -10,7 +10,6 @@ using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; using System; -using System.Collections.Generic; namespace osu.Game.Overlays.Changelog { @@ -31,7 +30,7 @@ namespace osu.Game.Overlays.Changelog Padding = new MarginPadding{ Bottom = 100, }; } - public void ShowListing(List changelog) + public void ShowListing(APIChangelog[] changelog) { DateTime currentDate = new DateTime(); diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 6a7ccacdc3..68875ef126 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -160,11 +160,11 @@ namespace osu.Game.Overlays.Changelog }; } - public void ShowBuild(string updateStream, string version) + public void ShowBuild(string displayName, string displayVersion) { listing.Deactivate(); - releaseStream.Activate($"{updateStream} {version}"); - titleStream.Text = updateStream; + releaseStream.Activate($"{displayName} {displayVersion}"); + titleStream.Text = displayName; titleStream.FlashColour(Color4.White, 500, Easing.OutQuad); } diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 8294e6c403..f4ae2a0cb2 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -85,12 +85,12 @@ namespace osu.Game.Overlays.Changelog }; } - public void Activate(bool withoutHeaderUpdate = false) + public void Activate(bool withoutFiringUpdates = true) { isActivated = true; this.FadeIn(transition_duration); lineBadge.IsCollapsed = false; - if (!withoutHeaderUpdate && Selected != null) + if (!withoutFiringUpdates && Selected != null) Selected(this, EventArgs.Empty); } @@ -107,7 +107,7 @@ namespace osu.Game.Overlays.Changelog protected override bool OnClick(InputState state) { - Activate(); + Activate(false); return base.OnClick(state); } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 2ae5bbdd78..d9a139c6ee 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -79,15 +79,8 @@ namespace osu.Game.Overlays }, }, }; - badges.Selected += onBuildSelected; - // content.ShowListing(); - // if (!Streams.IsHovered) - // foreach (StreamBadge item in Streams.BadgesContainer.Children) - // item.Activate(true); - // else - // foreach (StreamBadge item in Streams.BadgesContainer.Children) - // item.Deactivate(); + header.ListingActivated += FetchAndShowListing; } // receive input outside our bounds so we can trigger a close event on ourselves. @@ -131,12 +124,22 @@ namespace osu.Game.Overlays this.api = api; } + protected override void LoadComplete() + { + var req = new GetChangelogLatestBuildsRequest(); + req.Success += badges.Populate; + api.Queue(req); + FetchAndShowListing(); + base.LoadComplete(); + } + /// /// Fetches and shows changelog listing. /// public void FetchAndShowListing() { - var req = new GetChangelogLatestBuildsRequest(); + isAtListing = true; + var req = new GetChangelogRequest(); header.ShowListing(); badges.SelectNone(); chart.ShowAllUpdateStreams(); @@ -147,14 +150,15 @@ namespace osu.Game.Overlays /// /// Fetches and shows a specific build from a specific update stream. /// - /// If true, will select fetched build's update stream badge. - public void FetchAndShowBuild(string updateStream, string version) + public void FetchAndShowBuild(string updateStream, string version, bool sentByBadges = false) { + isAtListing = false; var req = new GetChangelogBuildRequest(updateStream, version); - header.ShowBuild(updateStream, version); - badges.SelectUpdateStream(updateStream); + if (!sentByBadges) + badges.SelectUpdateStream(updateStream); chart.ShowUpdateStream(updateStream); req.Success += content.ShowBuild; + req.Success += res => header.ShowBuild(res.UpdateStream.DisplayName, res.DisplayVersion); api.Queue(req); } } From 391da478813c0020166009fcc91451ba43a2fef3 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 22:31:24 +0200 Subject: [PATCH 055/375] Refactor the rewrite --- osu.Game/Overlays/Changelog/ChangelogBadges.cs | 5 ++--- osu.Game/Overlays/Changelog/ChangelogContent.cs | 11 ++++------- osu.Game/Overlays/Changelog/ChangelogContentGroup.cs | 3 +-- osu.Game/Overlays/Changelog/ChangelogHeader.cs | 5 +++-- osu.Game/Overlays/Changelog/StreamBadge.cs | 4 ++-- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogBadges.cs b/osu.Game/Overlays/Changelog/ChangelogBadges.cs index 53f6a75bbc..757f0e0727 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBadges.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBadges.cs @@ -109,8 +109,7 @@ namespace osu.Game.Overlays.Changelog protected virtual void OnSelected(StreamBadge source) { - if (Selected != null) - Selected(source.ChangelogEntry.UpdateStream.Name, source.ChangelogEntry.Version, EventArgs.Empty); + Selected?.Invoke(source.ChangelogEntry.UpdateStream.Name, source.ChangelogEntry.Version, EventArgs.Empty); } protected override bool OnHover(InputState state) @@ -135,7 +134,7 @@ namespace osu.Game.Overlays.Changelog foreach (StreamBadge streamBadge in badgesContainer.Children) { if (selectedStreamId < 0) - streamBadge.Activate(true); + streamBadge.Activate(); else if (streamBadge.ChangelogEntry.UpdateStream.Id == selectedStreamId) streamBadge.DisableDim(); } diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 3b45e4af87..f6e90b83a3 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -2,12 +2,10 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Online.API; -using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; using System; @@ -52,7 +50,7 @@ namespace osu.Game.Overlays.Changelog } // watch out for this? Add(changelogContentGroup = new ChangelogContentGroup(build, true)); - changelogContentGroup.BuildSelected += onBuildSelected; + changelogContentGroup.BuildSelected += OnBuildSelected; changelogContentGroup.GenerateText(build.ChangelogEntries); currentDate = build.CreatedAt.Date; } @@ -66,7 +64,7 @@ namespace osu.Game.Overlays.Changelog Margin = new MarginPadding { Top = 30, }, }); Add(changelogContentGroup = new ChangelogContentGroup(build, false)); - changelogContentGroup.BuildSelected += onBuildSelected; + changelogContentGroup.BuildSelected += OnBuildSelected; changelogContentGroup.GenerateText(build.ChangelogEntries); } } @@ -77,10 +75,9 @@ namespace osu.Game.Overlays.Changelog Child = changelogContentGroup = new ChangelogContentGroup(changelogBuild); } - protected virtual void onBuildSelected(string updateStream, string version, EventArgs args) + protected virtual void OnBuildSelected(string updateStream, string version, EventArgs args) { - if (BuildSelected != null) - BuildSelected(updateStream, version, EventArgs.Empty); + BuildSelected?.Invoke(updateStream, version, EventArgs.Empty); } } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 0efa8b70c6..aabc390d49 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -190,8 +190,7 @@ namespace osu.Game.Overlays.Changelog protected virtual void OnBuildSelected(string updateStream, string version) { - if (BuildSelected != null) - BuildSelected(updateStream, version, EventArgs.Empty); + BuildSelected?.Invoke(updateStream, version, EventArgs.Empty); } public void GenerateText(List changelogEntries) diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 68875ef126..a4be3bdf7f 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -11,7 +11,6 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.Changelog.Header; using System; @@ -24,6 +23,7 @@ namespace osu.Game.Overlays.Changelog private readonly Sprite headerBadge; private readonly OsuSpriteText titleStream; private readonly TextBadgePairListing listing; + private readonly SpriteIcon chevron; private readonly TextBadgePairRelease releaseStream; public Action ListingActivated; @@ -36,7 +36,6 @@ namespace osu.Game.Overlays.Changelog public ChangelogHeader() { - SpriteIcon chevron; // AppVeyor told me this should be a local variable..? RelativeSizeAxes = Axes.X; Height = cover_height; Children = new Drawable[] @@ -166,12 +165,14 @@ namespace osu.Game.Overlays.Changelog releaseStream.Activate($"{displayName} {displayVersion}"); titleStream.Text = displayName; titleStream.FlashColour(Color4.White, 500, Easing.OutQuad); + chevron.MoveToX(0, 100).FadeIn(100); } public void ShowListing() { releaseStream.Deactivate(); listing.Activate(); + chevron.MoveToX(-20, 100).FadeOut(100); } [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index f4ae2a0cb2..2a55b9a4b9 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -90,8 +90,8 @@ namespace osu.Game.Overlays.Changelog isActivated = true; this.FadeIn(transition_duration); lineBadge.IsCollapsed = false; - if (!withoutFiringUpdates && Selected != null) - Selected(this, EventArgs.Empty); + if (!withoutFiringUpdates) + Selected?.Invoke(this, EventArgs.Empty); } public void Deactivate() From 4cc5a657f3343ad226c4fe749f066bc8110886f3 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Mon, 23 Jul 2018 10:05:19 +0200 Subject: [PATCH 056/375] Follow up framework changes --- osu.Game/Graphics/UserInterface/ClickableText.cs | 2 +- osu.Game/Graphics/UserInterface/TooltipIconButton.cs | 2 +- osu.Game/Overlays/Changelog/ChangelogBadges.cs | 2 +- osu.Game/Overlays/Changelog/Header/TextBadgePair.cs | 2 +- osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs | 2 +- osu.Game/Overlays/Changelog/StreamBadge.cs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/ClickableText.cs b/osu.Game/Graphics/UserInterface/ClickableText.cs index f2f9f12228..c27bc56238 100644 --- a/osu.Game/Graphics/UserInterface/ClickableText.cs +++ b/osu.Game/Graphics/UserInterface/ClickableText.cs @@ -6,7 +6,7 @@ using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Cursor; -using osu.Framework.Input; +using osu.Framework.Input.States; using osu.Game.Graphics.Sprites; using System; diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs index 8b85c8c0ec..7f6641817a 100644 --- a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs +++ b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs @@ -9,7 +9,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; -using osu.Framework.Input; +using osu.Framework.Input.States; using System; namespace osu.Game.Graphics.UserInterface diff --git a/osu.Game/Overlays/Changelog/ChangelogBadges.cs b/osu.Game/Overlays/Changelog/ChangelogBadges.cs index 757f0e0727..0cfd220601 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBadges.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBadges.cs @@ -5,7 +5,7 @@ using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Input; +using osu.Framework.Input.States; using osu.Game.Online.API.Requests.Responses; using System; using System.Collections.Generic; diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs index 6256c52be2..c01501c308 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -8,7 +8,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Input; +using osu.Framework.Input.States; using System; namespace osu.Game.Overlays.Changelog.Header diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs index 425b4b111a..36db135675 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs @@ -4,7 +4,7 @@ using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; -using osu.Framework.Input; +using osu.Framework.Input.States; namespace osu.Game.Overlays.Changelog.Header { diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 2a55b9a4b9..44fdeb80a7 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -8,7 +8,7 @@ using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Input; +using osu.Framework.Input.States; using osu.Game.Graphics; using osu.Game.Online.API.Requests.Responses; using System; From e27292fef8bd11c6ab7b672278eb513db05fb684 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Mon, 23 Jul 2018 17:49:42 +0200 Subject: [PATCH 057/375] Rewrite LineBadge.cs + update all its references --- osu.Game.Tests/Visual/TestCaseLineBadge.cs | 51 +++++++++++ osu.Game/Graphics/UserInterface/LineBadge.cs | 84 +++++++++++++++++++ .../Overlays/Changelog/Header/LineBadge.cs | 44 ---------- .../Changelog/Header/TextBadgePair.cs | 17 ++-- .../Changelog/Header/TextBadgePairListing.cs | 8 +- osu.Game/Overlays/Changelog/StreamBadge.cs | 19 +++-- 6 files changed, 160 insertions(+), 63 deletions(-) create mode 100644 osu.Game.Tests/Visual/TestCaseLineBadge.cs create mode 100644 osu.Game/Graphics/UserInterface/LineBadge.cs delete mode 100644 osu.Game/Overlays/Changelog/Header/LineBadge.cs diff --git a/osu.Game.Tests/Visual/TestCaseLineBadge.cs b/osu.Game.Tests/Visual/TestCaseLineBadge.cs new file mode 100644 index 0000000000..304b0f9518 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseLineBadge.cs @@ -0,0 +1,51 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics.UserInterface; + +namespace osu.Game.Tests.Visual +{ + public class TestCaseLineBadge : OsuTestCase + { + public TestCaseLineBadge() + { + Container containerHorizontal; + LineBadge lineBadge; + + Add(containerHorizontal = new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Children = new Drawable[] + { + new Box + { + Colour = Color4.Gray, + Alpha = 0.5f, + RelativeSizeAxes = Axes.Both, + }, + lineBadge = new LineBadge + { + Anchor = Anchor.Centre, + UncollapsedSize = 10, + CollapsedSize = 2, + Colour = Color4.DeepSkyBlue, + } + } + }); + + AddStep(@"", () => { }); + AddStep(@"Collapse", () => lineBadge.Collapse()); + AddStep(@"Uncollapse", () => lineBadge.Uncollapse()); + AddSliderStep(@"Resize container", 1, 300, 150, value => containerHorizontal.ResizeTo(value)); + AddStep(@"Horizontal", () => lineBadge.IsHorizontal = true); + AddStep(@"Anchor top", () => lineBadge.Anchor = Anchor.TopCentre); + AddStep(@"Vertical", () => lineBadge.IsHorizontal = false); + AddStep(@"Anchor left", () => lineBadge.Anchor = Anchor.CentreLeft); + } + } +} diff --git a/osu.Game/Graphics/UserInterface/LineBadge.cs b/osu.Game/Graphics/UserInterface/LineBadge.cs new file mode 100644 index 0000000000..91dd2add1f --- /dev/null +++ b/osu.Game/Graphics/UserInterface/LineBadge.cs @@ -0,0 +1,84 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Shapes; + +namespace osu.Game.Graphics.UserInterface +{ + public class LineBadge : Circle + { + public float UncollapsedSize; + public float CollapsedSize; + + public bool IsCollapsed { get; private set; } + private bool isHorizontal; + + /// + /// Automatically sets the RelativeSizeAxes and switches X and Y components when changed. + /// + public bool IsHorizontal + { + get { return isHorizontal; } + set + { + if (value == isHorizontal) + return; + if (IsLoaded) + { + FinishTransforms(); + var height = Height; + var width = Width; + RelativeSizeAxes = value ? Axes.X : Axes.Y; + Width = height; + Height = width; + } + else + RelativeSizeAxes = value ? Axes.X : Axes.Y; + isHorizontal = value; + } + } + + /// + /// A simple rounded expandable line. Set its + /// property to the center of the edge it's meant stick with. By default, + /// takes up the full parent's axis defined by . + /// + /// Whether to initialize with the + /// or the + public LineBadge(bool startCollapsed = true) + { + IsCollapsed = startCollapsed; + RelativeSizeAxes = Axes.X; + isHorizontal = true; + Origin = Anchor.Centre; + } + + protected override void LoadComplete() + { + if (isHorizontal) + Height = IsCollapsed ? CollapsedSize : UncollapsedSize; + else + Width = IsCollapsed ? CollapsedSize : UncollapsedSize; + base.LoadComplete(); + } + + public void Collapse(float transitionDuration = 400, Easing easing = Easing.Out) + { + IsCollapsed = true; + if (IsHorizontal) + this.ResizeHeightTo(CollapsedSize, transitionDuration, easing); + else + this.ResizeWidthTo(CollapsedSize, transitionDuration, easing); + } + + public void Uncollapse(float transitionDuration = 400, Easing easing = Easing.OutElastic) + { + IsCollapsed = false; + if (IsHorizontal) + this.ResizeHeightTo(UncollapsedSize, transitionDuration, easing); + else + this.ResizeWidthTo(UncollapsedSize, transitionDuration, easing); + } + } +} diff --git a/osu.Game/Overlays/Changelog/Header/LineBadge.cs b/osu.Game/Overlays/Changelog/Header/LineBadge.cs deleted file mode 100644 index 93eca528c5..0000000000 --- a/osu.Game/Overlays/Changelog/Header/LineBadge.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Graphics; -using osu.Framework.Graphics.Shapes; - -namespace osu.Game.Overlays.Changelog.Header -{ - public class LineBadge : Circle - { - public float TransitionDuration = 400; - public float UncollapsedHeight; - public float CollapsedHeight; - - private bool isCollapsed; - public bool IsCollapsed - { - get { return isCollapsed; } - set - { - isCollapsed = value; - this.ResizeHeightTo(value ? CollapsedHeight : UncollapsedHeight, - value ? TransitionDuration / 2f : TransitionDuration, - value ? Easing.Out : Easing.OutElastic); - } - } - - public LineBadge(bool startCollapsed = true, float collapsedHeight = 1, float uncollapsedHeight = 10) - { - Anchor = Anchor.BottomCentre; - Origin = Anchor.Centre; - CollapsedHeight = collapsedHeight; - UncollapsedHeight = uncollapsedHeight; - Height = startCollapsed ? CollapsedHeight : UncollapsedHeight; - - // this margin prevents jumps when changing text's font weight - Margin = new MarginPadding - { - Left = 10, - Right = 10, - }; - } - } -} diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs index c01501c308..6ff945469c 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Input.States; +using osu.Game.Graphics.UserInterface; using System; namespace osu.Game.Overlays.Changelog.Header @@ -36,14 +37,14 @@ namespace osu.Game.Overlays.Changelog.Header public void HideText(double duration = 0, Easing easing = Easing.InOutCubic) { - LineBadge.IsCollapsed = true; + LineBadge.Collapse(); Text.MoveToY(20, duration, easing) .FadeOut(duration, easing); } public void ShowText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) { - LineBadge.IsCollapsed = false; + LineBadge.Uncollapse(); if (!string.IsNullOrEmpty(displayText)) Text.Text = displayText; Text.MoveToY(0, duration, easing) @@ -55,7 +56,7 @@ namespace osu.Game.Overlays.Changelog.Header /// Full change takes double this time. public void ChangeText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) { - LineBadge.IsCollapsed = true; + LineBadge.Collapse(); Text.MoveToY(20, duration, easing) .FadeOut(duration, easing) .Then() @@ -67,7 +68,7 @@ namespace osu.Game.Overlays.Changelog.Header Scheduler.AddDelayed(() => { if (!string.IsNullOrEmpty(displayText)) Text.Text = displayText; - LineBadge.IsCollapsed = false; + LineBadge.Uncollapse(); }, duration); } @@ -89,8 +90,10 @@ namespace osu.Game.Overlays.Changelog.Header }, LineBadge = new LineBadge(startCollapsed) { + CollapsedSize = 2, + UncollapsedSize = 10, Colour = badgeColour, - RelativeSizeAxes = Axes.X, + Anchor = Anchor.BottomCentre, } }; } @@ -98,14 +101,14 @@ namespace osu.Game.Overlays.Changelog.Header public virtual void Deactivate() { IsActivated = false; - LineBadge.IsCollapsed = true; + LineBadge.Collapse(); Text.Font = "Exo2.0-Regular"; } public virtual void Activate() { IsActivated = true; - LineBadge.IsCollapsed = false; + LineBadge.Uncollapse(); Text.Font = "Exo2.0-Bold"; SampleActivate?.Play(); } diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs index 36db135675..2e9152b256 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs @@ -33,7 +33,7 @@ namespace osu.Game.Overlays.Changelog.Header public override void Activate() { IsActivated = true; - LineBadge.IsCollapsed = false; + LineBadge.Uncollapse(); Text.Font = "Exo2.0-Bold"; SetTextColour(Color4.White, 100); SampleActivate?.Play(); @@ -43,7 +43,7 @@ namespace osu.Game.Overlays.Changelog.Header public override void Deactivate() { IsActivated = false; - LineBadge.IsCollapsed = true; + LineBadge.Collapse(); Text.Font = "Exo2.0-Regular"; // commented out since it makes bad resize-jumping SetTextColour(badgeColour, 100); OnDeactivation?.Invoke(); @@ -57,14 +57,14 @@ namespace osu.Game.Overlays.Changelog.Header protected override bool OnHover(InputState state) { - LineBadge.ResizeHeightTo(LineBadge.UncollapsedHeight, LineBadge.TransitionDuration, Easing.OutElastic); + LineBadge.Uncollapse(); return base.OnHover(state); } protected override void OnHoverLost(InputState state) { if (!IsActivated) - LineBadge.ResizeHeightTo(1, LineBadge.TransitionDuration, Easing.Out); + LineBadge.Collapse(); base.OnHoverLost(state); } diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 44fdeb80a7..59ce97bcc7 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -10,6 +10,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Input.States; using osu.Game.Graphics; +using osu.Game.Graphics.UserInterface; using osu.Game.Online.API.Requests.Responses; using System; @@ -27,7 +28,7 @@ namespace osu.Game.Overlays.Changelog private bool isActivated; - private readonly Header.LineBadge lineBadge; + private readonly LineBadge lineBadge; private SampleChannel sampleHover; public readonly APIChangelog ChangelogEntry; private readonly FillFlowContainer text; @@ -75,21 +76,23 @@ namespace osu.Game.Overlays.Changelog }, } }, - lineBadge = new Header.LineBadge(false, 2, 4) + lineBadge = new LineBadge(false) { Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, Colour = StreamColour.FromStreamName(ChangelogEntry.UpdateStream.Name), - RelativeSizeAxes = Axes.X, + UncollapsedSize = 4, + CollapsedSize = 2, }, }; } + /// In case we don't want to + /// fire the event. public void Activate(bool withoutFiringUpdates = true) { isActivated = true; this.FadeIn(transition_duration); - lineBadge.IsCollapsed = false; + lineBadge.Uncollapse(); if (!withoutFiringUpdates) Selected?.Invoke(this, EventArgs.Empty); } @@ -101,7 +104,7 @@ namespace osu.Game.Overlays.Changelog if (!IsHovered) { this.FadeTo(0.5f, transition_duration); - lineBadge.IsCollapsed = true; + lineBadge.Collapse(200); } } @@ -116,7 +119,7 @@ namespace osu.Game.Overlays.Changelog sampleHover?.Play(); DisableDim(); this.FadeIn(transition_duration); - lineBadge.IsCollapsed = false; + lineBadge.Uncollapse(); return base.OnHover(state); } @@ -125,7 +128,7 @@ namespace osu.Game.Overlays.Changelog if (!isActivated) { this.FadeTo(0.5f, transition_duration); - lineBadge.IsCollapsed = true; + lineBadge.Collapse(200); } else EnableDim(); From 554c56d51f8dd1eb7786581ce8079e88c2161c07 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Mon, 23 Jul 2018 18:17:50 +0200 Subject: [PATCH 058/375] Change order in TextBadgePair.cs --- .../Changelog/Header/TextBadgePair.cs | 94 +++++++++---------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs index 6ff945469c..ec99604df5 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -25,53 +25,6 @@ namespace osu.Game.Overlays.Changelog.Header private SampleChannel sampleHover; protected SampleChannel SampleActivate; - public void SetTextColour(ColourInfo newColour, double duration = 0, Easing easing = Easing.None) - { - Text.FadeColour(newColour, duration, easing); - } - - public void SetBadgeColour(ColourInfo newColour, double duration = 0, Easing easing = Easing.None) - { - LineBadge.FadeColour(newColour, duration, easing); - } - - public void HideText(double duration = 0, Easing easing = Easing.InOutCubic) - { - LineBadge.Collapse(); - Text.MoveToY(20, duration, easing) - .FadeOut(duration, easing); - } - - public void ShowText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) - { - LineBadge.Uncollapse(); - if (!string.IsNullOrEmpty(displayText)) - Text.Text = displayText; - Text.MoveToY(0, duration, easing) - .FadeIn(duration, easing); - } - - /// - /// The duration of popping in and popping out not combined. - /// Full change takes double this time. - public void ChangeText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) - { - LineBadge.Collapse(); - Text.MoveToY(20, duration, easing) - .FadeOut(duration, easing) - .Then() - .MoveToY(0, duration, easing) - .FadeIn(duration, easing); - - // since using .finally/.oncomplete after first fadeout made the badge not hide - // sometimes in visual tests (https://streamable.com/0qssq), I'm using a scheduler here - Scheduler.AddDelayed(() => - { - if (!string.IsNullOrEmpty(displayText)) Text.Text = displayText; - LineBadge.Uncollapse(); - }, duration); - } - public TextBadgePair(ColourInfo badgeColour, string displayText = "Listing", bool startCollapsed = true) { AutoSizeAxes = Axes.X; @@ -98,6 +51,27 @@ namespace osu.Game.Overlays.Changelog.Header }; } + /// + /// The duration of popping in and popping out not combined. + /// Full change takes double this time. + public void ChangeText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) + { + LineBadge.Collapse(); + Text.MoveToY(20, duration, easing) + .FadeOut(duration, easing) + .Then() + .MoveToY(0, duration, easing) + .FadeIn(duration, easing); + + // since using .finally/.oncomplete after first fadeout made the badge not hide + // sometimes in visual tests (https://streamable.com/0qssq), I'm using a scheduler here + Scheduler.AddDelayed(() => + { + if (!string.IsNullOrEmpty(displayText)) Text.Text = displayText; + LineBadge.Uncollapse(); + }, duration); + } + public virtual void Deactivate() { IsActivated = false; @@ -113,6 +87,32 @@ namespace osu.Game.Overlays.Changelog.Header SampleActivate?.Play(); } + public void SetTextColour(ColourInfo newColour, double duration = 0, Easing easing = Easing.None) + { + Text.FadeColour(newColour, duration, easing); + } + + public void SetBadgeColour(ColourInfo newColour, double duration = 0, Easing easing = Easing.None) + { + LineBadge.FadeColour(newColour, duration, easing); + } + + public void HideText(double duration = 0, Easing easing = Easing.InOutCubic) + { + LineBadge.Collapse(); + Text.MoveToY(20, duration, easing) + .FadeOut(duration, easing); + } + + public void ShowText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) + { + LineBadge.Uncollapse(); + if (!string.IsNullOrEmpty(displayText)) + Text.Text = displayText; + Text.MoveToY(0, duration, easing) + .FadeIn(duration, easing); + } + protected override bool OnHover(InputState state) { if (!IsActivated) From f685c5ba5852355b3b2419051b3b61dd7ab8c000 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Mon, 23 Jul 2018 18:38:20 +0200 Subject: [PATCH 059/375] Fix typos; remove outdated comments; minor order changes --- osu.Game.Tests/Visual/TestCaseLineBadge.cs | 6 +++--- osu.Game/Graphics/UserInterface/LineBadge.cs | 2 +- osu.Game/Graphics/UserInterface/TooltipIconButton.cs | 3 ++- osu.Game/Overlays/Changelog/ChangelogChart.cs | 5 ----- osu.Game/Overlays/Changelog/ChangelogContent.cs | 9 +++++---- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseLineBadge.cs b/osu.Game.Tests/Visual/TestCaseLineBadge.cs index 304b0f9518..d80ef0131b 100644 --- a/osu.Game.Tests/Visual/TestCaseLineBadge.cs +++ b/osu.Game.Tests/Visual/TestCaseLineBadge.cs @@ -13,10 +13,10 @@ namespace osu.Game.Tests.Visual { public TestCaseLineBadge() { - Container containerHorizontal; + Container container; LineBadge lineBadge; - Add(containerHorizontal = new Container + Add(container = new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -41,7 +41,7 @@ namespace osu.Game.Tests.Visual AddStep(@"", () => { }); AddStep(@"Collapse", () => lineBadge.Collapse()); AddStep(@"Uncollapse", () => lineBadge.Uncollapse()); - AddSliderStep(@"Resize container", 1, 300, 150, value => containerHorizontal.ResizeTo(value)); + AddSliderStep(@"Resize container", 1, 300, 150, value => container.ResizeTo(value)); AddStep(@"Horizontal", () => lineBadge.IsHorizontal = true); AddStep(@"Anchor top", () => lineBadge.Anchor = Anchor.TopCentre); AddStep(@"Vertical", () => lineBadge.IsHorizontal = false); diff --git a/osu.Game/Graphics/UserInterface/LineBadge.cs b/osu.Game/Graphics/UserInterface/LineBadge.cs index 91dd2add1f..0283559aee 100644 --- a/osu.Game/Graphics/UserInterface/LineBadge.cs +++ b/osu.Game/Graphics/UserInterface/LineBadge.cs @@ -45,7 +45,7 @@ namespace osu.Game.Graphics.UserInterface /// takes up the full parent's axis defined by . /// /// Whether to initialize with the - /// or the + /// or the . public LineBadge(bool startCollapsed = true) { IsCollapsed = startCollapsed; diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs index 7f6641817a..1dfec5cb80 100644 --- a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs +++ b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs @@ -21,6 +21,7 @@ namespace osu.Game.Graphics.UserInterface { private readonly SpriteIcon icon; private SampleChannel sampleHover; + public Action Action; private bool isEnabled; @@ -30,7 +31,7 @@ namespace osu.Game.Graphics.UserInterface set { isEnabled = value; - icon.Alpha = value ? 1 : 0.5f; + icon.FadeTo(value ? 1 : 0.5f, 250); } } diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs index 91e2aa5e49..667f206250 100644 --- a/osu.Game/Overlays/Changelog/ChangelogChart.cs +++ b/osu.Game/Overlays/Changelog/ChangelogChart.cs @@ -15,7 +15,6 @@ using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Overlays.Changelog { // maybe look to osu.Game.Screens.Play.SquareGraph for reference later - // placeholder json file: https://api.myjson.com/bins/10ye8a public class ChangelogChart : BufferedContainer { private readonly Box background; @@ -43,10 +42,6 @@ namespace osu.Game.Overlays.Changelog }; } - /// - /// Draw the graph for a specific build - /// - private bool isEmpty(APIChangelogChart changelogChart) { if (changelogChart != null) diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index f6e90b83a3..9d81fcb30f 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -31,7 +31,6 @@ namespace osu.Game.Overlays.Changelog public void ShowListing(APIChangelog[] changelog) { DateTime currentDate = new DateTime(); - Clear(); foreach (APIChangelog build in changelog) @@ -48,10 +47,10 @@ namespace osu.Game.Overlays.Changelog Margin = new MarginPadding { Top = 30, }, }); } - // watch out for this? - Add(changelogContentGroup = new ChangelogContentGroup(build, true)); + changelogContentGroup = new ChangelogContentGroup(build, true); changelogContentGroup.BuildSelected += OnBuildSelected; changelogContentGroup.GenerateText(build.ChangelogEntries); + Add(changelogContentGroup); currentDate = build.CreatedAt.Date; } else @@ -63,9 +62,11 @@ namespace osu.Game.Overlays.Changelog Colour = new Color4(32, 24, 35, 255), Margin = new MarginPadding { Top = 30, }, }); - Add(changelogContentGroup = new ChangelogContentGroup(build, false)); + + changelogContentGroup = new ChangelogContentGroup(build, false); changelogContentGroup.BuildSelected += OnBuildSelected; changelogContentGroup.GenerateText(build.ChangelogEntries); + Add(changelogContentGroup); } } } From f526d6696970fa3fa7c430982ed597d0d8a69bd1 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Mon, 23 Jul 2018 19:40:58 +0200 Subject: [PATCH 060/375] Fix showing builds --- osu.Game/Overlays/Changelog/ChangelogContent.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 9d81fcb30f..4f336dc48b 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -74,6 +74,9 @@ namespace osu.Game.Overlays.Changelog public void ShowBuild(APIChangelog changelogBuild) { Child = changelogContentGroup = new ChangelogContentGroup(changelogBuild); + changelogContentGroup.GenerateText(changelogBuild.ChangelogEntries); + changelogContentGroup.UpdateChevronTooltips(changelogBuild.Versions.Previous?.DisplayVersion, + changelogBuild.Versions.Next?.DisplayVersion); } protected virtual void OnBuildSelected(string updateStream, string version, EventArgs args) From 6cd6ca432c0d43cca651ea5ffe26da3a05eb3806 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Mon, 23 Jul 2018 20:36:24 +0200 Subject: [PATCH 061/375] Fix links not working due to rewrite regression --- osu.Game/Overlays/Changelog/ChangelogContent.cs | 1 + osu.Game/Overlays/Changelog/ChangelogHeader.cs | 12 ++++++++++-- .../Overlays/Changelog/Header/TextBadgePair.cs | 17 +++++++++++++++-- .../Changelog/Header/TextBadgePairListing.cs | 6 +++--- .../Changelog/Header/TextBadgePairRelease.cs | 2 -- osu.Game/Overlays/ChangelogOverlay.cs | 6 +++++- 6 files changed, 34 insertions(+), 10 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 4f336dc48b..3b64003104 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -77,6 +77,7 @@ namespace osu.Game.Overlays.Changelog changelogContentGroup.GenerateText(changelogBuild.ChangelogEntries); changelogContentGroup.UpdateChevronTooltips(changelogBuild.Versions.Previous?.DisplayVersion, changelogBuild.Versions.Next?.DisplayVersion); + changelogContentGroup.BuildSelected += OnBuildSelected; } protected virtual void OnBuildSelected(string updateStream, string version, EventArgs args) diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index a4be3bdf7f..8617aff6a0 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -26,7 +26,9 @@ namespace osu.Game.Overlays.Changelog private readonly SpriteIcon chevron; private readonly TextBadgePairRelease releaseStream; - public Action ListingActivated; + public delegate void ListingSelectedEventHandler(); + + public event ListingSelectedEventHandler ListingSelected; private const float cover_height = 280; private const float title_height = 50; @@ -127,7 +129,7 @@ namespace osu.Game.Overlays.Changelog Margin = new MarginPadding { Top = 10, - Left = 7, + Left = 15, Right = 18, Bottom = 15, }, @@ -157,6 +159,7 @@ namespace osu.Game.Overlays.Changelog Origin = Anchor.CentreLeft, }, }; + listing.Activated += OnListingSelected; } public void ShowBuild(string displayName, string displayVersion) @@ -175,6 +178,11 @@ namespace osu.Game.Overlays.Changelog chevron.MoveToX(-20, 100).FadeOut(100); } + protected virtual void OnListingSelected(object source, EventArgs e) + { + ListingSelected?.Invoke(); + } + [BackgroundDependencyLoader] private void load(TextureStore textures) { diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs index ec99604df5..732edc2a58 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -20,8 +20,10 @@ namespace osu.Game.Overlays.Changelog.Header protected LineBadge LineBadge; public bool IsActivated { get; protected set; } - public Action OnActivation; - public Action OnDeactivation; + public delegate void ActivatedEventHandler(object source, EventArgs args); + + public event ActivatedEventHandler Activated; + private SampleChannel sampleHover; protected SampleChannel SampleActivate; @@ -120,6 +122,17 @@ namespace osu.Game.Overlays.Changelog.Header return base.OnHover(state); } + protected override bool OnClick(InputState state) + { + OnActivated(); + return base.OnClick(state); + } + + protected virtual void OnActivated() + { + Activated?.Invoke(this, EventArgs.Empty); + } + [BackgroundDependencyLoader] private void load(AudioManager audio) { diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs index 2e9152b256..3876e8a226 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs @@ -32,21 +32,21 @@ namespace osu.Game.Overlays.Changelog.Header public override void Activate() { + if (IsActivated) + return; IsActivated = true; LineBadge.Uncollapse(); Text.Font = "Exo2.0-Bold"; SetTextColour(Color4.White, 100); SampleActivate?.Play(); - OnActivation?.Invoke(); } public override void Deactivate() { IsActivated = false; LineBadge.Collapse(); - Text.Font = "Exo2.0-Regular"; // commented out since it makes bad resize-jumping + Text.Font = "Exo2.0-Regular"; SetTextColour(badgeColour, 100); - OnDeactivation?.Invoke(); } protected override bool OnClick(InputState state) diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs index 32a76670f0..7f60dbabbd 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs @@ -30,14 +30,12 @@ namespace osu.Game.Overlays.Changelog.Header ShowText(transition_duration, displayText); IsActivated = true; SampleActivate?.Play(); - OnActivation?.Invoke(); } public override void Deactivate() { IsActivated = false; HideText(transition_duration); - OnDeactivation?.Invoke(); } } } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index d9a139c6ee..a4e3e8a91c 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -79,8 +79,9 @@ namespace osu.Game.Overlays }, }, }; + header.ListingSelected += FetchAndShowListing; badges.Selected += onBuildSelected; - header.ListingActivated += FetchAndShowListing; + content.BuildSelected += onBuildSelected; } // receive input outside our bounds so we can trigger a close event on ourselves. @@ -152,6 +153,9 @@ namespace osu.Game.Overlays /// public void FetchAndShowBuild(string updateStream, string version, bool sentByBadges = false) { + //// I should probably change this to take APIChangelog as an argument, + //// instantly update the header and badge, and if it doesn't contain the + //// needed info, just subscribe to when the info will be available isAtListing = false; var req = new GetChangelogBuildRequest(updateStream, version); if (!sentByBadges) From 7c6be4a07538077759630b6e2e2069f400423ebf Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Mon, 23 Jul 2018 21:38:14 +0200 Subject: [PATCH 062/375] Handle around an APIChangelog instead of just Name and Version: Makes showing up the header immediately possible --- .../Overlays/Changelog/ChangelogBadges.cs | 15 ++---------- .../Overlays/Changelog/ChangelogContent.cs | 6 ++--- .../Changelog/ChangelogContentGroup.cs | 14 +++++------ osu.Game/Overlays/ChangelogOverlay.cs | 24 +++++++++++-------- 4 files changed, 25 insertions(+), 34 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogBadges.cs b/osu.Game/Overlays/Changelog/ChangelogBadges.cs index 0cfd220601..6f088677d9 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBadges.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBadges.cs @@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Changelog private const float padding_y = 20; private const float padding_x = 85; - public delegate void SelectionHandler(string updateStream, string version, EventArgs args); + public delegate void SelectionHandler(APIChangelog releaseStream, EventArgs args); public event SelectionHandler Selected; @@ -49,17 +49,6 @@ namespace osu.Game.Overlays.Changelog }, }, }; - //foreach (StreamBadge streamBadge in BadgesContainer.Children) - //{ - // streamBadge.OnActivation = () => - // { - // SelectedRelease = streamBadge.ChangelogEntry; - // foreach (StreamBadge item in BadgesContainer.Children) - // if (item.ChangelogEntry.Id != streamBadge.ChangelogEntry.Id) - // item.Deactivate(); - // OnSelection?.Invoke(); - // }; - //} } public void Populate(List latestBuilds) @@ -109,7 +98,7 @@ namespace osu.Game.Overlays.Changelog protected virtual void OnSelected(StreamBadge source) { - Selected?.Invoke(source.ChangelogEntry.UpdateStream.Name, source.ChangelogEntry.Version, EventArgs.Empty); + Selected?.Invoke(source.ChangelogEntry, EventArgs.Empty); } protected override bool OnHover(InputState state) diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 3b64003104..7e92ab4c26 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Changelog private APIAccess api; private ChangelogContentGroup changelogContentGroup; - public delegate void BuildSelectedEventHandler(string updateStream, string version, EventArgs args); + public delegate void BuildSelectedEventHandler(APIChangelog build, EventArgs args); public event BuildSelectedEventHandler BuildSelected; @@ -80,9 +80,9 @@ namespace osu.Game.Overlays.Changelog changelogContentGroup.BuildSelected += OnBuildSelected; } - protected virtual void OnBuildSelected(string updateStream, string version, EventArgs args) + protected virtual void OnBuildSelected(APIChangelog build, EventArgs args) { - BuildSelected?.Invoke(updateStream, version, EventArgs.Empty); + BuildSelected?.Invoke(build, EventArgs.Empty); } } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index aabc390d49..444e81a75d 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Changelog private readonly SortedDictionary> categories = new SortedDictionary>(); - public delegate void BuildSelectedEventHandler(string updateStream, string version, EventArgs args); + public delegate void BuildSelectedEventHandler(APIChangelog build, EventArgs args); public event BuildSelectedEventHandler BuildSelected; @@ -53,8 +53,7 @@ namespace osu.Game.Overlays.Changelog IsEnabled = false, Icon = FontAwesome.fa_chevron_left, Size = new Vector2(24), - Action = () => OnBuildSelected(build.Versions.Previous.UpdateStream.Name, - build.Versions.Previous.Version), + Action = () => OnBuildSelected(build.Versions.Previous), }, new FillFlowContainer { @@ -91,8 +90,7 @@ namespace osu.Game.Overlays.Changelog IsEnabled = false, Icon = FontAwesome.fa_chevron_right, Size = new Vector2(24), - Action = () => OnBuildSelected(build.Versions.Next.UpdateStream.Name, - build.Versions.Next.Version), + Action = () => OnBuildSelected(build.Versions.Next), }, } }, @@ -160,7 +158,7 @@ namespace osu.Game.Overlays.Changelog TextSize = 20, // web: 18, Font = @"Exo2.0-Light", Colour = StreamColour.FromStreamName(build.UpdateStream.Name), - Action = () => OnBuildSelected(build.UpdateStream.Name, build.Version), + Action = () => OnBuildSelected(build), IsClickMuted = true, }, } @@ -188,9 +186,9 @@ namespace osu.Game.Overlays.Changelog } } - protected virtual void OnBuildSelected(string updateStream, string version) + protected virtual void OnBuildSelected(APIChangelog build) { - BuildSelected?.Invoke(updateStream, version, EventArgs.Empty); + BuildSelected?.Invoke(build, EventArgs.Empty); } public void GenerateText(List changelogEntries) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index a4e3e8a91c..fd0515a0b3 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -13,6 +13,7 @@ using osu.Game.Graphics.Containers; using osu.Game.Input.Bindings; using osu.Game.Online.API; using osu.Game.Online.API.Requests; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.Changelog; using System; @@ -114,9 +115,9 @@ namespace osu.Game.Overlays FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out); } - private void onBuildSelected(string updateStream, string version, EventArgs e) + private void onBuildSelected(APIChangelog build, EventArgs e) { - FetchAndShowBuild(updateStream, version); + FetchAndShowBuild(build); } [BackgroundDependencyLoader] @@ -151,18 +152,21 @@ namespace osu.Game.Overlays /// /// Fetches and shows a specific build from a specific update stream. /// - public void FetchAndShowBuild(string updateStream, string version, bool sentByBadges = false) + public void FetchAndShowBuild(APIChangelog build, bool sentByBadges = false) { - //// I should probably change this to take APIChangelog as an argument, - //// instantly update the header and badge, and if it doesn't contain the - //// needed info, just subscribe to when the info will be available isAtListing = false; - var req = new GetChangelogBuildRequest(updateStream, version); + var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); + + if (build.UpdateStream.DisplayName != null && build.DisplayVersion != null) + header.ShowBuild(build.UpdateStream.DisplayName, build.DisplayVersion); + else + req.Success += res => header.ShowBuild(res.UpdateStream.DisplayName, res.DisplayVersion); + if (!sentByBadges) - badges.SelectUpdateStream(updateStream); - chart.ShowUpdateStream(updateStream); + badges.SelectUpdateStream(build.UpdateStream.Name); + + chart.ShowUpdateStream(build.UpdateStream.Name); req.Success += content.ShowBuild; - req.Success += res => header.ShowBuild(res.UpdateStream.DisplayName, res.DisplayVersion); api.Queue(req); } } From 054f578bc8c3cf76055fca4d9e1a976609e677c6 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Mon, 23 Jul 2018 23:15:14 +0200 Subject: [PATCH 063/375] Update few links not working; Reasses sample playing; Slight renames --- .../UserInterface/TooltipIconButton.cs | 5 +++++ .../Overlays/Changelog/ChangelogBadges.cs | 12 +++++----- .../Changelog/ChangelogContentGroup.cs | 1 - .../Overlays/Changelog/ChangelogHeader.cs | 8 +++++++ .../Changelog/Header/TextBadgePair.cs | 6 ++--- .../Changelog/Header/TextBadgePairListing.cs | 1 - .../Changelog/Header/TextBadgePairRelease.cs | 1 - osu.Game/Overlays/Changelog/StreamBadge.cs | 22 +++++++++++-------- osu.Game/Overlays/ChangelogOverlay.cs | 10 ++++++++- 9 files changed, 44 insertions(+), 22 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs index 1dfec5cb80..ecae010889 100644 --- a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs +++ b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs @@ -21,6 +21,7 @@ namespace osu.Game.Graphics.UserInterface { private readonly SpriteIcon icon; private SampleChannel sampleHover; + private SampleChannel sampleClick; public Action Action; @@ -64,7 +65,10 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnClick(InputState state) { if (isEnabled) + { + sampleClick?.Play(); Action?.Invoke(); + } return base.OnClick(state); } @@ -79,6 +83,7 @@ namespace osu.Game.Graphics.UserInterface private void load(AudioManager audio) { sampleHover = audio.Sample.Get(@"UI/generic-hover-soft"); + sampleClick = audio.Sample.Get(@"UI/generic-select-soft"); } public string TooltipText { get; set; } diff --git a/osu.Game/Overlays/Changelog/ChangelogBadges.cs b/osu.Game/Overlays/Changelog/ChangelogBadges.cs index 6f088677d9..3d1762e9f6 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBadges.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBadges.cs @@ -80,9 +80,9 @@ namespace osu.Game.Overlays.Changelog { foreach (StreamBadge streamBadge in badgesContainer) { - if (streamBadge.ChangelogEntry.UpdateStream.Name == updateStream) + if (streamBadge.LatestBuild.UpdateStream.Name == updateStream) { - selectedStreamId = streamBadge.ChangelogEntry.UpdateStream.Id; + selectedStreamId = streamBadge.LatestBuild.UpdateStream.Id; streamBadge.Activate(); } else @@ -92,13 +92,13 @@ namespace osu.Game.Overlays.Changelog private void onBadgeSelected(StreamBadge source, EventArgs args) { - selectedStreamId = source.ChangelogEntry.UpdateStream.Id; + selectedStreamId = source.LatestBuild.UpdateStream.Id; OnSelected(source); } protected virtual void OnSelected(StreamBadge source) { - Selected?.Invoke(source.ChangelogEntry, EventArgs.Empty); + Selected?.Invoke(source.LatestBuild, EventArgs.Empty); } protected override bool OnHover(InputState state) @@ -107,7 +107,7 @@ namespace osu.Game.Overlays.Changelog { if (selectedStreamId < 0) { - if (selectedStreamId != streamBadge.ChangelogEntry.UpdateStream.Id) + if (selectedStreamId != streamBadge.LatestBuild.UpdateStream.Id) streamBadge.Deactivate(); else streamBadge.EnableDim(); @@ -124,7 +124,7 @@ namespace osu.Game.Overlays.Changelog { if (selectedStreamId < 0) streamBadge.Activate(); - else if (streamBadge.ChangelogEntry.UpdateStream.Id == selectedStreamId) + else if (streamBadge.LatestBuild.UpdateStream.Id == selectedStreamId) streamBadge.DisableDim(); } base.OnHoverLost(state); diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 444e81a75d..763be79a43 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -159,7 +159,6 @@ namespace osu.Game.Overlays.Changelog Font = @"Exo2.0-Light", Colour = StreamColour.FromStreamName(build.UpdateStream.Name), Action = () => OnBuildSelected(build), - IsClickMuted = true, }, } }, diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 8617aff6a0..37b9c0a047 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -160,6 +160,7 @@ namespace osu.Game.Overlays.Changelog }, }; listing.Activated += OnListingSelected; + releaseStream.Activated += OnReleaseSelected; } public void ShowBuild(string displayName, string displayVersion) @@ -175,6 +176,8 @@ namespace osu.Game.Overlays.Changelog { releaseStream.Deactivate(); listing.Activate(); + titleStream.Text = "Listing"; + titleStream.FlashColour(Color4.White, 500, Easing.OutQuad); chevron.MoveToX(-20, 100).FadeOut(100); } @@ -183,6 +186,11 @@ namespace osu.Game.Overlays.Changelog ListingSelected?.Invoke(); } + protected virtual void OnReleaseSelected(object source, EventArgs e) + { + titleStream.FlashColour(Color4.White, 500, Easing.OutQuad); + } + [BackgroundDependencyLoader] private void load(TextureStore textures) { diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs index 732edc2a58..c8801771d3 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -25,7 +25,7 @@ namespace osu.Game.Overlays.Changelog.Header public event ActivatedEventHandler Activated; private SampleChannel sampleHover; - protected SampleChannel SampleActivate; + private SampleChannel sampleActivate; public TextBadgePair(ColourInfo badgeColour, string displayText = "Listing", bool startCollapsed = true) { @@ -86,7 +86,6 @@ namespace osu.Game.Overlays.Changelog.Header IsActivated = true; LineBadge.Uncollapse(); Text.Font = "Exo2.0-Bold"; - SampleActivate?.Play(); } public void SetTextColour(ColourInfo newColour, double duration = 0, Easing easing = Easing.None) @@ -125,6 +124,7 @@ namespace osu.Game.Overlays.Changelog.Header protected override bool OnClick(InputState state) { OnActivated(); + sampleActivate?.Play(); return base.OnClick(state); } @@ -137,7 +137,7 @@ namespace osu.Game.Overlays.Changelog.Header private void load(AudioManager audio) { sampleHover = audio.Sample.Get(@"UI/generic-hover-soft"); - SampleActivate = audio.Sample.Get(@"UI/generic-select-soft"); + sampleActivate = audio.Sample.Get(@"UI/generic-select-soft"); } } } diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs index 3876e8a226..31a06ce67d 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs @@ -38,7 +38,6 @@ namespace osu.Game.Overlays.Changelog.Header LineBadge.Uncollapse(); Text.Font = "Exo2.0-Bold"; SetTextColour(Color4.White, 100); - SampleActivate?.Play(); } public override void Deactivate() diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs index 7f60dbabbd..97ce799509 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs @@ -29,7 +29,6 @@ namespace osu.Game.Overlays.Changelog.Header else ShowText(transition_duration, displayText); IsActivated = true; - SampleActivate?.Play(); } public override void Deactivate() diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 59ce97bcc7..2a82620995 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -29,15 +29,17 @@ namespace osu.Game.Overlays.Changelog private bool isActivated; private readonly LineBadge lineBadge; + private SampleChannel sampleClick; private SampleChannel sampleHover; - public readonly APIChangelog ChangelogEntry; + + public readonly APIChangelog LatestBuild; private readonly FillFlowContainer text; - public StreamBadge(APIChangelog changelogEntry) + public StreamBadge(APIChangelog latestBuild) { - ChangelogEntry = changelogEntry; + this.LatestBuild = latestBuild; Height = badge_height; - Width = ChangelogEntry.IsFeatured ? badge_width * 2 : badge_width; + base.Width = this.LatestBuild.IsFeatured ? badge_width * 2 : badge_width; Margin = new MarginPadding(5); isActivated = true; Children = new Drawable[] @@ -51,7 +53,7 @@ namespace osu.Game.Overlays.Changelog { new SpriteText { - Text = ChangelogEntry.UpdateStream.DisplayName, + Text = this.LatestBuild.UpdateStream.DisplayName, Font = @"Exo2.0-Bold", TextSize = 16, Margin = new MarginPadding @@ -61,14 +63,14 @@ namespace osu.Game.Overlays.Changelog }, new SpriteText { - Text = ChangelogEntry.DisplayVersion, + Text = this.LatestBuild.DisplayVersion, Font = @"Exo2.0-Light", TextSize = 21, }, new SpriteText { - Text = ChangelogEntry.Users > 0 ? - $"{ChangelogEntry.Users:N0} users online" : + Text = this.LatestBuild.Users > 0 ? + $"{this.LatestBuild.Users:N0} users online" : null, TextSize = 12, Font = @"Exo2.0-Regular", @@ -79,7 +81,7 @@ namespace osu.Game.Overlays.Changelog lineBadge = new LineBadge(false) { Anchor = Anchor.TopCentre, - Colour = StreamColour.FromStreamName(ChangelogEntry.UpdateStream.Name), + Colour = StreamColour.FromStreamName(this.LatestBuild.UpdateStream.Name), UncollapsedSize = 4, CollapsedSize = 2, }, @@ -111,6 +113,7 @@ namespace osu.Game.Overlays.Changelog protected override bool OnClick(InputState state) { Activate(false); + sampleClick?.Play(); return base.OnClick(state); } @@ -142,6 +145,7 @@ namespace osu.Game.Overlays.Changelog [BackgroundDependencyLoader] private void load(AudioManager audio) { + sampleClick = audio.Sample.Get(@"UI/generic-select-soft"); sampleHover = audio.Sample.Get(@"UI/generic-hover-soft"); } } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index fd0515a0b3..4a133870f7 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -4,6 +4,8 @@ using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -26,6 +28,8 @@ namespace osu.Game.Overlays private readonly ChangelogChart chart; private readonly ChangelogContent content; + private SampleChannel sampleBack; + private readonly Color4 purple = new Color4(191, 4, 255, 255); private APIAccess api; @@ -96,7 +100,10 @@ namespace osu.Game.Overlays if (isAtListing) State = Visibility.Hidden; else + { FetchAndShowListing(); + sampleBack?.Play(); + } return true; } @@ -121,9 +128,10 @@ namespace osu.Game.Overlays } [BackgroundDependencyLoader] - private void load(APIAccess api) + private void load(APIAccess api, AudioManager audio) { this.api = api; + sampleBack = audio.Sample.Get(@"UI/generic-select-soft"); // @"UI/screen-back" feels non-fitting here } protected override void LoadComplete() From 9a84747fe678cfe9dff3f1751992458acfa42391 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Mon, 23 Jul 2018 23:24:34 +0200 Subject: [PATCH 064/375] Fix reversed if/else statement causing inproper behavior for badges --- osu.Game/Overlays/Changelog/ChangelogBadges.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogBadges.cs b/osu.Game/Overlays/Changelog/ChangelogBadges.cs index 3d1762e9f6..1a5e4f7d18 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBadges.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBadges.cs @@ -105,7 +105,7 @@ namespace osu.Game.Overlays.Changelog { foreach (StreamBadge streamBadge in badgesContainer.Children) { - if (selectedStreamId < 0) + if (selectedStreamId >= 0) { if (selectedStreamId != streamBadge.LatestBuild.UpdateStream.Id) streamBadge.Deactivate(); From 9e9d7a855d5c9b266f294635f5ce5d317d96a046 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Tue, 24 Jul 2018 04:03:56 +0200 Subject: [PATCH 065/375] Remove reduntant .base and .this --- osu.Game/Overlays/Changelog/StreamBadge.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 2a82620995..8c881348c7 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -37,9 +37,9 @@ namespace osu.Game.Overlays.Changelog public StreamBadge(APIChangelog latestBuild) { - this.LatestBuild = latestBuild; + LatestBuild = latestBuild; Height = badge_height; - base.Width = this.LatestBuild.IsFeatured ? badge_width * 2 : badge_width; + Width = LatestBuild.IsFeatured ? badge_width * 2 : badge_width; Margin = new MarginPadding(5); isActivated = true; Children = new Drawable[] @@ -53,7 +53,7 @@ namespace osu.Game.Overlays.Changelog { new SpriteText { - Text = this.LatestBuild.UpdateStream.DisplayName, + Text = LatestBuild.UpdateStream.DisplayName, Font = @"Exo2.0-Bold", TextSize = 16, Margin = new MarginPadding @@ -63,14 +63,14 @@ namespace osu.Game.Overlays.Changelog }, new SpriteText { - Text = this.LatestBuild.DisplayVersion, + Text = LatestBuild.DisplayVersion, Font = @"Exo2.0-Light", TextSize = 21, }, new SpriteText { - Text = this.LatestBuild.Users > 0 ? - $"{this.LatestBuild.Users:N0} users online" : + Text = LatestBuild.Users > 0 ? + $"{LatestBuild.Users:N0} users online" : null, TextSize = 12, Font = @"Exo2.0-Regular", @@ -81,7 +81,7 @@ namespace osu.Game.Overlays.Changelog lineBadge = new LineBadge(false) { Anchor = Anchor.TopCentre, - Colour = StreamColour.FromStreamName(this.LatestBuild.UpdateStream.Name), + Colour = StreamColour.FromStreamName(LatestBuild.UpdateStream.Name), UncollapsedSize = 4, CollapsedSize = 2, }, From 24bb44a152d42fb67eb6acf03d86dfcb011a597a Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Tue, 24 Jul 2018 04:04:18 +0200 Subject: [PATCH 066/375] Add TextBadgePair test case --- .../Visual/TestCaseTextBadgePair.cs | 50 +++++++++++++++++++ .../Changelog/Header/TextBadgePair.cs | 6 ++- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Tests/Visual/TestCaseTextBadgePair.cs diff --git a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs b/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs new file mode 100644 index 0000000000..c61213ce3c --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs @@ -0,0 +1,50 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Overlays.Changelog.Header; + +namespace osu.Game.Tests.Visual +{ + public class TestCaseTextBadgePair : OsuTestCase + { + public TestCaseTextBadgePair() + { + Container container; + TextBadgePair textBadgePair; + + Add(container = new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Width = 250, + Height = 50, + Children = new Drawable[] + { + new Box + { + Colour = Color4.Gray, + Alpha = 0.5f, + RelativeSizeAxes = Axes.Both, + }, + textBadgePair = new TextBadgePair(Color4.DeepSkyBlue, "Test") + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + } + } + }); + + AddStep(@"Deactivate", textBadgePair.Deactivate); + AddStep(@"Activate", textBadgePair.Activate); + AddStep(@"Hide text", () => textBadgePair.HideText(200)); + AddStep(@"Show text", () => textBadgePair.ShowText(200)); + AddStep(@"Different text", () => textBadgePair.ChangeText(200, "This one's a little bit wider")); + AddWaitStep(1); + AddStep(@"Different text", () => textBadgePair.ChangeText(200, "Ok?..")); + } + } +} diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs index c8801771d3..201524cc2f 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -37,6 +37,8 @@ namespace osu.Game.Overlays.Changelog.Header { TextSize = 21, // web: 16, Text = displayText, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, Margin = new MarginPadding { Top = 5, @@ -49,6 +51,7 @@ namespace osu.Game.Overlays.Changelog.Header UncollapsedSize = 10, Colour = badgeColour, Anchor = Anchor.BottomCentre, + Origin = Anchor.Centre, } }; } @@ -69,7 +72,8 @@ namespace osu.Game.Overlays.Changelog.Header // sometimes in visual tests (https://streamable.com/0qssq), I'm using a scheduler here Scheduler.AddDelayed(() => { - if (!string.IsNullOrEmpty(displayText)) Text.Text = displayText; + if (!string.IsNullOrEmpty(displayText)) + Text.Text = displayText; LineBadge.Uncollapse(); }, duration); } From fa6074925e8bf58d010b9d3a5459277643560dc1 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Tue, 24 Jul 2018 17:02:24 +0200 Subject: [PATCH 067/375] Remove unused variable --- osu.Game.Tests/Visual/TestCaseTextBadgePair.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs b/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs index c61213ce3c..6d2fe20f2b 100644 --- a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs +++ b/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs @@ -13,10 +13,9 @@ namespace osu.Game.Tests.Visual { public TestCaseTextBadgePair() { - Container container; TextBadgePair textBadgePair; - Add(container = new Container + Add(new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, From 175c20a1043b101cb69667c66d050bcc3fbb2f21 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Tue, 24 Jul 2018 18:41:47 +0200 Subject: [PATCH 068/375] Slight reorder --- osu.Game/Overlays/ChangelogOverlay.cs | 69 +++++++++++++-------------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 4a133870f7..08bcaff58b 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -28,14 +28,17 @@ namespace osu.Game.Overlays private readonly ChangelogChart chart; private readonly ChangelogContent content; - private SampleChannel sampleBack; - private readonly Color4 purple = new Color4(191, 4, 255, 255); + private SampleChannel sampleBack; + private APIAccess api; private bool isAtListing; + // receive input outside our bounds so we can trigger a close event on ourselves. + public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; + public ChangelogOverlay() { // these possibly need adjusting? @@ -89,8 +92,33 @@ namespace osu.Game.Overlays content.BuildSelected += onBuildSelected; } - // receive input outside our bounds so we can trigger a close event on ourselves. - public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; + [BackgroundDependencyLoader] + private void load(APIAccess api, AudioManager audio) + { + this.api = api; + sampleBack = audio.Sample.Get(@"UI/generic-select-soft"); // @"UI/screen-back" feels non-fitting here + } + + protected override void LoadComplete() + { + var req = new GetChangelogLatestBuildsRequest(); + req.Success += badges.Populate; + api.Queue(req); + FetchAndShowListing(); + base.LoadComplete(); + } + + protected override void PopIn() + { + base.PopIn(); + FadeEdgeEffectTo(0.25f, WaveContainer.APPEAR_DURATION, Easing.In); + } + + protected override void PopOut() + { + base.PopOut(); + FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out); + } public override bool OnPressed(GlobalAction action) { @@ -110,38 +138,7 @@ namespace osu.Game.Overlays return false; } - protected override void PopIn() - { - base.PopIn(); - FadeEdgeEffectTo(0.25f, WaveContainer.APPEAR_DURATION, Easing.In); - } - - protected override void PopOut() - { - base.PopOut(); - FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out); - } - - private void onBuildSelected(APIChangelog build, EventArgs e) - { - FetchAndShowBuild(build); - } - - [BackgroundDependencyLoader] - private void load(APIAccess api, AudioManager audio) - { - this.api = api; - sampleBack = audio.Sample.Get(@"UI/generic-select-soft"); // @"UI/screen-back" feels non-fitting here - } - - protected override void LoadComplete() - { - var req = new GetChangelogLatestBuildsRequest(); - req.Success += badges.Populate; - api.Queue(req); - FetchAndShowListing(); - base.LoadComplete(); - } + private void onBuildSelected(APIChangelog build, EventArgs e) => FetchAndShowBuild(build); /// /// Fetches and shows changelog listing. From 255c252f6aa3be47b6fdd8331e930fe5f46d65cb Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Tue, 24 Jul 2018 18:47:05 +0200 Subject: [PATCH 069/375] Shorten MarginPaddings in ChangelogContentGroup --- .../Changelog/ChangelogContentGroup.cs | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 763be79a43..f768b06da7 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -42,10 +42,7 @@ namespace osu.Game.Overlays.Changelog Origin = Anchor.TopCentre, AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, - Margin = new MarginPadding - { - Top = 20, - }, + Margin = new MarginPadding { Top = 20 }, Children = new Drawable[] { chevronPrevious = new TooltipIconButton @@ -58,11 +55,7 @@ namespace osu.Game.Overlays.Changelog new FillFlowContainer { AutoSizeAxes = Axes.Both, - Margin = new MarginPadding - { - Left = 40, - Right = 40, - }, + Margin = new MarginPadding { Horizontal = 40 }, Children = new[] { new SpriteText @@ -104,7 +97,7 @@ namespace osu.Game.Overlays.Changelog Font = @"Exo2.0-Medium", Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Margin = new MarginPadding{ Top = 5, } + Margin = new MarginPadding { Top = 5 } }, ChangelogEntries = new FillFlowContainer { @@ -133,7 +126,7 @@ namespace osu.Game.Overlays.Changelog Font = @"Exo2.0-Light", Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Margin = new MarginPadding{ Top = 20, }, + Margin = new MarginPadding { Top = 20 }, Alpha = newDate ? 1 : 0, }, new FillFlowContainer @@ -142,7 +135,7 @@ namespace osu.Game.Overlays.Changelog Origin = Anchor.TopCentre, AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, - Margin = new MarginPadding{ Top = 20, }, + Margin = new MarginPadding { Top = 20 }, Spacing = new Vector2(5), Children = new Drawable[] { @@ -208,7 +201,7 @@ namespace osu.Game.Overlays.Changelog Text = category.Key, TextSize = 24, // web: 18, Font = @"Exo2.0-Bold", - Margin = new MarginPadding { Top = 35, Bottom = 15, }, + Margin = new MarginPadding { Top = 35, Bottom = 15 }, }); foreach (ChangelogEntry entry in category.Value) { @@ -219,10 +212,14 @@ namespace osu.Game.Overlays.Changelog Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Margin = new MarginPadding{ Vertical = 5, }, + Margin = new MarginPadding { Vertical = 5 }, }); - title.AddIcon(FontAwesome.fa_check, t => { t.TextSize = 12; t.Padding = new MarginPadding { Left = -17, Right = 5 }; }); - title.AddText(entry.Title, t => { t.TextSize = 18; }); //t.Padding = new MarginPadding(10); }); + title.AddIcon(FontAwesome.fa_check, t => + { + t.TextSize = 12; + t.Padding = new MarginPadding { Left = -17, Right = 5 }; + }); + title.AddText(entry.Title, t => { t.TextSize = 18; }); if (!string.IsNullOrEmpty(entry.Repository)) { title.AddText($" ({entry.Repository.Substring(4)}#{entry.GithubPullRequestId})", t => From 225ff35907432cd9787c77cc8ff5ee9b69c7fe71 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Tue, 24 Jul 2018 18:55:50 +0200 Subject: [PATCH 070/375] XML for TooltipIconButton.cs --- osu.Game/Graphics/UserInterface/TooltipIconButton.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs index ecae010889..65ab5de036 100644 --- a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs +++ b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs @@ -23,9 +23,16 @@ namespace osu.Game.Graphics.UserInterface private SampleChannel sampleHover; private SampleChannel sampleClick; + /// + /// The action to fire upon click, if is set to true. + /// public Action Action; private bool isEnabled; + + /// + /// If set to true, upon click the will execute. It wont otherwise. + /// public bool IsEnabled { get { return isEnabled; } @@ -42,6 +49,9 @@ namespace osu.Game.Graphics.UserInterface set { icon.Icon = value; } } + /// + /// A simple icon that has an action upon click and can be disabled. + /// public TooltipIconButton() { isEnabled = true; From 16d3ca20731ea986382f4583c454b0f3cf2674b4 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Tue, 24 Jul 2018 19:01:24 +0200 Subject: [PATCH 071/375] Move breadcrumb to the right position --- osu.Game/Overlays/Changelog/ChangelogHeader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 37b9c0a047..035574bd1c 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -114,7 +114,7 @@ namespace osu.Game.Overlays.Changelog }, new FillFlowContainer // Listing > Lazer 2018.713.1 { - X = 2 * icon_margin + icon_size - 8, + X = 2 * icon_margin + icon_size, Height = version_height, Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, From dfe4153c95b0cbfc56603741bb231b569d776a54 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Tue, 24 Jul 2018 19:34:40 +0200 Subject: [PATCH 072/375] Prevent duplicated fetching for listing and builds: - listing when already at it; - builds by immediately disabling links to them (chevrons and links in listing) --- .../Overlays/Changelog/ChangelogContentGroup.cs | 16 +++++++++++++--- osu.Game/Overlays/ChangelogOverlay.cs | 6 ++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index f768b06da7..44d5e33c56 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -50,7 +50,11 @@ namespace osu.Game.Overlays.Changelog IsEnabled = false, Icon = FontAwesome.fa_chevron_left, Size = new Vector2(24), - Action = () => OnBuildSelected(build.Versions.Previous), + Action = () => + { + OnBuildSelected(build.Versions.Previous); + chevronPrevious.IsEnabled = false; + }, }, new FillFlowContainer { @@ -83,7 +87,11 @@ namespace osu.Game.Overlays.Changelog IsEnabled = false, Icon = FontAwesome.fa_chevron_right, Size = new Vector2(24), - Action = () => OnBuildSelected(build.Versions.Next), + Action = () => + { + OnBuildSelected(build.Versions.Next); + chevronNext.IsEnabled = false; + }, }, } }, @@ -110,6 +118,7 @@ namespace osu.Game.Overlays.Changelog public ChangelogContentGroup(APIChangelog build, bool newDate = false) { + ClickableText clickableText; RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; Direction = FillDirection.Vertical; @@ -145,7 +154,7 @@ namespace osu.Game.Overlays.Changelog TextSize = 20, // web: 18, Font = @"Exo2.0-Medium", }, - new ClickableText + clickableText = new ClickableText { Text = build.DisplayVersion, TextSize = 20, // web: 18, @@ -162,6 +171,7 @@ namespace osu.Game.Overlays.Changelog Direction = FillDirection.Vertical, }, }; + clickableText.Action += () => clickableText.IsEnabled = false; } public void UpdateChevronTooltips(string previousVersion, string nextVersion) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 08bcaff58b..ad8d60d6ca 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -141,13 +141,15 @@ namespace osu.Game.Overlays private void onBuildSelected(APIChangelog build, EventArgs e) => FetchAndShowBuild(build); /// - /// Fetches and shows changelog listing. + /// If we're not already at it, fetches and shows changelog listing. /// public void FetchAndShowListing() { + header.ShowListing(); + if (isAtListing) + return; isAtListing = true; var req = new GetChangelogRequest(); - header.ShowListing(); badges.SelectNone(); chart.ShowAllUpdateStreams(); req.Success += content.ShowListing; From 3b362881853195936282bc8ade46b5b9fd94ae0c Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Tue, 24 Jul 2018 20:13:53 +0200 Subject: [PATCH 073/375] Rename TestCaseChangelog to TestCaseChangelogOverlay --- .../{TestCaseChangelog.cs => TestCaseChangelogOverlay.cs} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename osu.Game.Tests/Visual/{TestCaseChangelog.cs => TestCaseChangelogOverlay.cs} (90%) diff --git a/osu.Game.Tests/Visual/TestCaseChangelog.cs b/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs similarity index 90% rename from osu.Game.Tests/Visual/TestCaseChangelog.cs rename to osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs index da260c239b..53143bd924 100644 --- a/osu.Game.Tests/Visual/TestCaseChangelog.cs +++ b/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs @@ -7,7 +7,7 @@ using osu.Game.Overlays; namespace osu.Game.Tests.Visual { [TestFixture] - public class TestCaseChangelog : OsuTestCase + public class TestCaseChangelogOverlay : OsuTestCase { private ChangelogOverlay changelog; From 8e412fe4037f78d5db5f4bea73a233a1646bb80f Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Tue, 24 Jul 2018 20:57:09 +0200 Subject: [PATCH 074/375] Add scrolling to the previous position when on "Back" --- osu.Game/Overlays/ChangelogOverlay.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index ad8d60d6ca..965d6fcf49 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -28,6 +28,8 @@ namespace osu.Game.Overlays private readonly ChangelogChart chart; private readonly ChangelogContent content; + private readonly ScrollContainer scroll; + private readonly Color4 purple = new Color4(191, 4, 255, 255); private SampleChannel sampleBack; @@ -35,6 +37,7 @@ namespace osu.Game.Overlays private APIAccess api; private bool isAtListing; + private float savedScrollPosition; // receive input outside our bounds so we can trigger a close event on ourselves. public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; @@ -68,7 +71,7 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.Both, Colour = new Color4(49, 36, 54, 255), }, - new ScrollContainer + scroll = new ScrollContainer { RelativeSizeAxes = Axes.Both, ScrollbarVisible = false, @@ -152,7 +155,11 @@ namespace osu.Game.Overlays var req = new GetChangelogRequest(); badges.SelectNone(); chart.ShowAllUpdateStreams(); - req.Success += content.ShowListing; + req.Success += listing => + { + content.ShowListing(listing); + scroll.ScrollTo(savedScrollPosition); + }; api.Queue(req); } @@ -173,7 +180,13 @@ namespace osu.Game.Overlays badges.SelectUpdateStream(build.UpdateStream.Name); chart.ShowUpdateStream(build.UpdateStream.Name); - req.Success += content.ShowBuild; + req.Success += APIChangelog => + { + savedScrollPosition = scroll.Current; + content.ShowBuild(APIChangelog); + if (scroll.Current > scroll.GetChildPosInContent(content)) + scroll.ScrollTo(content); + }; api.Queue(req); } } From 08a291f0d45e6dd507986dc2f97e0e4deec685c4 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Tue, 24 Jul 2018 21:19:29 +0200 Subject: [PATCH 075/375] Improve scroll handling --- osu.Game/Overlays/ChangelogOverlay.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 965d6fcf49..3e52e66e35 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -168,7 +168,6 @@ namespace osu.Game.Overlays /// public void FetchAndShowBuild(APIChangelog build, bool sentByBadges = false) { - isAtListing = false; var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); if (build.UpdateStream.DisplayName != null && build.DisplayVersion != null) @@ -182,10 +181,12 @@ namespace osu.Game.Overlays chart.ShowUpdateStream(build.UpdateStream.Name); req.Success += APIChangelog => { - savedScrollPosition = scroll.Current; content.ShowBuild(APIChangelog); if (scroll.Current > scroll.GetChildPosInContent(content)) scroll.ScrollTo(content); + if (isAtListing) + savedScrollPosition = scroll.Current; + isAtListing = false; }; api.Queue(req); } From 43a7b3a82510a073fe4aab2da4cce8b5fd001dfa Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Tue, 24 Jul 2018 21:42:25 +0200 Subject: [PATCH 076/375] Fetch listing only once; Reenable disabled links as they wont be regenerated --- .../Changelog/ChangelogContentGroup.cs | 8 ++++- osu.Game/Overlays/ChangelogOverlay.cs | 36 ++++++++++++------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 44d5e33c56..88be51bb47 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -171,7 +171,13 @@ namespace osu.Game.Overlays.Changelog Direction = FillDirection.Vertical, }, }; - clickableText.Action += () => clickableText.IsEnabled = false; + + // we may not want double clicks to make it double the work + clickableText.Action += () => + { + clickableText.IsEnabled = false; + Scheduler.AddDelayed(() => clickableText.IsEnabled = true, 2000); + }; } public void UpdateChevronTooltips(string previousVersion, string nextVersion) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 3e52e66e35..ccf2884422 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -26,6 +26,7 @@ namespace osu.Game.Overlays private readonly ChangelogHeader header; private readonly ChangelogBadges badges; private readonly ChangelogChart chart; + private readonly ChangelogContent listing; private readonly ChangelogContent content; private readonly ScrollContainer scroll; @@ -85,13 +86,15 @@ namespace osu.Game.Overlays header = new ChangelogHeader(), badges = new ChangelogBadges(), chart = new ChangelogChart(), + listing = new ChangelogContent(), content = new ChangelogContent() }, }, }, }; - header.ListingSelected += FetchAndShowListing; + header.ListingSelected += ShowListing; badges.Selected += onBuildSelected; + listing.BuildSelected += onBuildSelected; content.BuildSelected += onBuildSelected; } @@ -107,7 +110,7 @@ namespace osu.Game.Overlays var req = new GetChangelogLatestBuildsRequest(); req.Success += badges.Populate; api.Queue(req); - FetchAndShowListing(); + fetchListing(); base.LoadComplete(); } @@ -132,7 +135,7 @@ namespace osu.Game.Overlays State = Visibility.Hidden; else { - FetchAndShowListing(); + ShowListing(); sampleBack?.Play(); } return true; @@ -143,10 +146,7 @@ namespace osu.Game.Overlays private void onBuildSelected(APIChangelog build, EventArgs e) => FetchAndShowBuild(build); - /// - /// If we're not already at it, fetches and shows changelog listing. - /// - public void FetchAndShowListing() + private void fetchListing() { header.ShowListing(); if (isAtListing) @@ -155,14 +155,24 @@ namespace osu.Game.Overlays var req = new GetChangelogRequest(); badges.SelectNone(); chart.ShowAllUpdateStreams(); - req.Success += listing => - { - content.ShowListing(listing); - scroll.ScrollTo(savedScrollPosition); - }; + req.Success += listing.ShowListing; api.Queue(req); } + public void ShowListing() + { + header.ShowListing(); + if (isAtListing) + return; + isAtListing = true; + content.Hide(); + listing.Show(); + badges.SelectNone(); + chart.ShowAllUpdateStreams(); + listing.Show(); + scroll.ScrollTo(savedScrollPosition); + } + /// /// Fetches and shows a specific build from a specific update stream. /// @@ -181,6 +191,8 @@ namespace osu.Game.Overlays chart.ShowUpdateStream(build.UpdateStream.Name); req.Success += APIChangelog => { + listing.Hide(); + content.Show(); content.ShowBuild(APIChangelog); if (scroll.Current > scroll.GetChildPosInContent(content)) scroll.ScrollTo(content); From 74540bba83dd62594a6c1447ac36adfe18baef64 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Tue, 24 Jul 2018 21:59:09 +0200 Subject: [PATCH 077/375] Non-breaking space for "by ..." Doesn't work for now(?) --- osu.Game/Overlays/Changelog/ChangelogContentGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 88be51bb47..23e05d8065 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -244,7 +244,7 @@ namespace osu.Game.Overlays.Changelog t.Colour = Color4.SkyBlue; }); } - title.AddText($" by {entry.GithubUser.DisplayName}", t => t.TextSize = 14); //web: 12; + title.AddText($" by\u00A0{entry.GithubUser.DisplayName}", t => t.TextSize = 14); //web: 12; TextFlowContainer messageContainer; ChangelogEntries.Add(messageContainer = new OsuTextFlowContainer { From d2b2c4c19b3ef6778d73f8867b99c0be9966bc97 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Tue, 24 Jul 2018 23:25:57 +0200 Subject: [PATCH 078/375] Make PR-link surrounding parenthesis white --- .../Overlays/Changelog/ChangelogContentGroup.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 23e05d8065..821f6aadc4 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -221,15 +221,13 @@ namespace osu.Game.Overlays.Changelog }); foreach (ChangelogEntry entry in category.Value) { - OsuTextFlowContainer title; - - ChangelogEntries.Add(title = new OsuTextFlowContainer + OsuTextFlowContainer title = new OsuTextFlowContainer { Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Margin = new MarginPadding { Vertical = 5 }, - }); + }; title.AddIcon(FontAwesome.fa_check, t => { t.TextSize = 12; @@ -238,24 +236,27 @@ namespace osu.Game.Overlays.Changelog title.AddText(entry.Title, t => { t.TextSize = 18; }); if (!string.IsNullOrEmpty(entry.Repository)) { - title.AddText($" ({entry.Repository.Substring(4)}#{entry.GithubPullRequestId})", t => + title.AddText(" (", t => t.TextSize = 18); + title.AddText($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}", t => { t.TextSize = 18; t.Colour = Color4.SkyBlue; }); + title.AddText(")", t => t.TextSize = 18); } title.AddText($" by\u00A0{entry.GithubUser.DisplayName}", t => t.TextSize = 14); //web: 12; - TextFlowContainer messageContainer; - ChangelogEntries.Add(messageContainer = new OsuTextFlowContainer + ChangelogEntries.Add(title); + TextFlowContainer messageContainer = new TextFlowContainer { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, - }); + }; messageContainer.AddText($"{entry.MessageHtml?.Replace("

", "").Replace("

", "")}\n", t => { t.TextSize = 14; // web: 12, t.Colour = new Color4(235, 184, 254, 255); }); + ChangelogEntries.Add(messageContainer); } } } From a00f4e81788fe1dd49f139d509e13a12ff848458 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Wed, 25 Jul 2018 00:12:05 +0200 Subject: [PATCH 079/375] Make Back action go to the top of listing before exiting the changelog screen --- osu.Game/Overlays/ChangelogOverlay.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index ccf2884422..fc21ac64ac 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -132,7 +132,15 @@ namespace osu.Game.Overlays { case GlobalAction.Back: if (isAtListing) - State = Visibility.Hidden; + { + if (scroll.Current > scroll.GetChildPosInContent(listing)) + { + scroll.ScrollTo(0); + sampleBack?.Play(); + } + else + State = Visibility.Hidden; + } else { ShowListing(); From cd79c2cc45c70cc59a07e42b5257a7799075086e Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Wed, 25 Jul 2018 00:59:21 +0200 Subject: [PATCH 080/375] Hide graph when it's unavailable; Scroll change --- osu.Game/Overlays/Changelog/ChangelogChart.cs | 40 +++++++++++-------- osu.Game/Overlays/ChangelogOverlay.cs | 6 +-- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs index 667f206250..3313e4adcc 100644 --- a/osu.Game/Overlays/Changelog/ChangelogChart.cs +++ b/osu.Game/Overlays/Changelog/ChangelogChart.cs @@ -17,6 +17,10 @@ namespace osu.Game.Overlays.Changelog // maybe look to osu.Game.Screens.Play.SquareGraph for reference later public class ChangelogChart : BufferedContainer { + private const float height = 100; + private const float transition_duration = 300; + + private readonly Container container; private readonly Box background; private readonly SpriteText text; private APIAccess api; @@ -24,20 +28,25 @@ namespace osu.Game.Overlays.Changelog public ChangelogChart() { RelativeSizeAxes = Axes.X; - Height = 100; - Children = new Drawable[] + AutoSizeAxes = Axes.Y; + Child = container = new Container { - background = new Box + RelativeSizeAxes = Axes.X, + Height = height, + Children = new Drawable[] { - Colour = StreamColour.STABLE, - RelativeSizeAxes = Axes.Both, - }, - text = new SpriteText - { - Text = "Graph Placeholder", - TextSize = 28, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, + background = new Box + { + Colour = StreamColour.STABLE, + RelativeSizeAxes = Axes.Both, + }, + text = new SpriteText + { + Text = "Graph Placeholder", + TextSize = 28, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, }, }; } @@ -55,13 +64,10 @@ namespace osu.Game.Overlays.Changelog if (!isEmpty(chartInfo)) { background.Colour = StreamColour.FromStreamName(updateStreamName); - text.Text = "Graph placeholder\n(chart is not empty)"; + container.MoveToY(0, transition_duration, Easing.InOutQuad).FadeIn(transition_duration); } else - { - background.Colour = Color4.Black; - text.Text = "Graph placeholder\n(chart is empty)"; - } + container.MoveToY(-height, transition_duration, Easing.InOutQuad).FadeOut(transition_duration); } [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index fc21ac64ac..a0d0726c01 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -197,13 +197,13 @@ namespace osu.Game.Overlays badges.SelectUpdateStream(build.UpdateStream.Name); chart.ShowUpdateStream(build.UpdateStream.Name); - req.Success += APIChangelog => + req.Success += apiChangelog => { listing.Hide(); content.Show(); - content.ShowBuild(APIChangelog); + content.ShowBuild(apiChangelog); if (scroll.Current > scroll.GetChildPosInContent(content)) - scroll.ScrollTo(content); + scroll.ScrollTo(chart); if (isAtListing) savedScrollPosition = scroll.Current; isAtListing = false; From 05a59f352547a716c149e70b198f111d4a1923da Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Wed, 25 Jul 2018 03:54:16 +0200 Subject: [PATCH 081/375] Add links to GitHub --- .../Changelog/ChangelogContentGroup.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 821f6aadc4..07e695b439 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -221,7 +221,7 @@ namespace osu.Game.Overlays.Changelog }); foreach (ChangelogEntry entry in category.Value) { - OsuTextFlowContainer title = new OsuTextFlowContainer + LinkFlowContainer title = new LinkFlowContainer { Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, @@ -237,14 +237,18 @@ namespace osu.Game.Overlays.Changelog if (!string.IsNullOrEmpty(entry.Repository)) { title.AddText(" (", t => t.TextSize = 18); - title.AddText($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}", t => - { - t.TextSize = 18; - t.Colour = Color4.SkyBlue; - }); + title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}", + entry.GithubUrl, Online.Chat.LinkAction.External, null, + null, t => { t.TextSize = 18; }); title.AddText(")", t => t.TextSize = 18); } - title.AddText($" by\u00A0{entry.GithubUser.DisplayName}", t => t.TextSize = 14); //web: 12; + title.AddText(" by ", t => t.TextSize = 14); + if (entry.GithubUser.GithubUrl != null) + title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, + Online.Chat.LinkAction.External, null, null, + t => t.TextSize = 14); + else + title.AddText(entry.GithubUser.DisplayName, t => t.TextSize = 14); //web: 12; ChangelogEntries.Add(title); TextFlowContainer messageContainer = new TextFlowContainer { @@ -255,6 +259,7 @@ namespace osu.Game.Overlays.Changelog { t.TextSize = 14; // web: 12, t.Colour = new Color4(235, 184, 254, 255); + t = new ClickableText(); }); ChangelogEntries.Add(messageContainer); } From c8f36a0c66626103df5611b143b1bfd19448f8c4 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Wed, 25 Jul 2018 03:58:08 +0200 Subject: [PATCH 082/375] Add links to GitHub; Remove reduntant using directive and variable --- osu.Game/Overlays/Changelog/ChangelogChart.cs | 4 +--- osu.Game/Overlays/Changelog/ChangelogContentGroup.cs | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs index 3313e4adcc..c88eae98a4 100644 --- a/osu.Game/Overlays/Changelog/ChangelogChart.cs +++ b/osu.Game/Overlays/Changelog/ChangelogChart.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -22,7 +21,6 @@ namespace osu.Game.Overlays.Changelog private readonly Container container; private readonly Box background; - private readonly SpriteText text; private APIAccess api; public ChangelogChart() @@ -40,7 +38,7 @@ namespace osu.Game.Overlays.Changelog Colour = StreamColour.STABLE, RelativeSizeAxes = Axes.Both, }, - text = new SpriteText + new SpriteText { Text = "Graph Placeholder", TextSize = 28, diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 07e695b439..1346689cb7 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -259,7 +259,6 @@ namespace osu.Game.Overlays.Changelog { t.TextSize = 14; // web: 12, t.Colour = new Color4(235, 184, 254, 255); - t = new ClickableText(); }); ChangelogEntries.Add(messageContainer); } From 2906f4b401fcbc69828cf02ef1d06f00c4d4d21c Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Wed, 25 Jul 2018 14:31:41 +0200 Subject: [PATCH 083/375] Change initial chart colour --- .../Visual/TestCaseChangelogOverlay.cs | 20 +++++++++++++++++++ osu.Game/Overlays/Changelog/ChangelogChart.cs | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs b/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs index 53143bd924..d64f1c00f7 100644 --- a/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs +++ b/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using NUnit.Framework; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays; namespace osu.Game.Tests.Visual @@ -17,6 +18,25 @@ namespace osu.Game.Tests.Visual Add(changelog = new ChangelogOverlay()); AddStep(@"Show", changelog.Show); + AddStep(@"Hide", changelog.Hide); + AddWaitStep(3); + AddStep(@"Show with Lazer 2018.712.0", () => + { + changelog.FetchAndShowBuild(new APIChangelog + { + Version = "2018.712.0", + UpdateStream = new UpdateStream { Name = "lazer" }, + }); + changelog.Show(); + }); + AddWaitStep(3); + AddStep(@"Hide", changelog.Hide); + AddWaitStep(3); + AddStep(@"Show with listing", () => + { + changelog.ShowListing(); + changelog.Show(); + }); } } } diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs index c88eae98a4..369982a2ac 100644 --- a/osu.Game/Overlays/Changelog/ChangelogChart.cs +++ b/osu.Game/Overlays/Changelog/ChangelogChart.cs @@ -35,7 +35,7 @@ namespace osu.Game.Overlays.Changelog { background = new Box { - Colour = StreamColour.STABLE, + Colour = OsuColour.Gray(0), RelativeSizeAxes = Axes.Both, }, new SpriteText @@ -44,6 +44,7 @@ namespace osu.Game.Overlays.Changelog TextSize = 28, Anchor = Anchor.Centre, Origin = Anchor.Centre, + Colour = OsuColour.Gray(1), }, }, }; From a7a6e52c16a1f2e9dde1c397e090e0cd4b765a83 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Wed, 25 Jul 2018 14:58:18 +0200 Subject: [PATCH 084/375] Bring StreamBadge visual proportions closer to the upstream design --- osu.Game/Overlays/Changelog/StreamBadge.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 8c881348c7..fc12d58f7a 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Changelog { public class StreamBadge : ClickableContainer { - private const float badge_height = 56.5f; + private const float badge_height = 66.5f; private const float badge_width = 100; private const float transition_duration = 100; @@ -40,7 +40,7 @@ namespace osu.Game.Overlays.Changelog LatestBuild = latestBuild; Height = badge_height; Width = LatestBuild.IsFeatured ? badge_width * 2 : badge_width; - Margin = new MarginPadding(5); + Padding = new MarginPadding(5); isActivated = true; Children = new Drawable[] { @@ -55,24 +55,21 @@ namespace osu.Game.Overlays.Changelog { Text = LatestBuild.UpdateStream.DisplayName, Font = @"Exo2.0-Bold", - TextSize = 16, - Margin = new MarginPadding - { - Top = 7, - } + TextSize = 14, // web: 12, + Margin = new MarginPadding { Top = 6, }, }, new SpriteText { Text = LatestBuild.DisplayVersion, Font = @"Exo2.0-Light", - TextSize = 21, + TextSize = 20, // web: 16, }, new SpriteText { Text = LatestBuild.Users > 0 ? $"{LatestBuild.Users:N0} users online" : null, - TextSize = 12, + TextSize = 12, // web: 10, Font = @"Exo2.0-Regular", Colour = new Color4(203, 164, 218, 255), }, From 3e6968b57ebf6baf488f0e7bf893f57370bf1030 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Wed, 25 Jul 2018 17:04:36 +0200 Subject: [PATCH 085/375] Unify MarginPadding --- osu.Game/Overlays/Changelog/ChangelogBadges.cs | 12 +++--------- osu.Game/Overlays/Changelog/ChangelogContent.cs | 6 +++--- osu.Game/Overlays/Changelog/ChangelogContentGroup.cs | 2 +- osu.Game/Overlays/Changelog/Header/TextBadgePair.cs | 6 +----- osu.Game/Overlays/Changelog/StreamBadge.cs | 2 +- 5 files changed, 9 insertions(+), 19 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogBadges.cs b/osu.Game/Overlays/Changelog/ChangelogBadges.cs index 1a5e4f7d18..365d808108 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBadges.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBadges.cs @@ -15,8 +15,8 @@ namespace osu.Game.Overlays.Changelog public class ChangelogBadges : Container { private const float container_height = 106.5f; - private const float padding_y = 20; - private const float padding_x = 85; + private const float vertical_padding = 20; + private const float horizontal_padding = 85; public delegate void SelectionHandler(APIChangelog releaseStream, EventArgs args); @@ -40,13 +40,7 @@ namespace osu.Game.Overlays.Changelog { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Padding = new MarginPadding - { - Top = padding_y, - Bottom = padding_y, - Left = padding_x, - Right = padding_x, - }, + Padding = new MarginPadding { Vertical = vertical_padding, Horizontal = horizontal_padding }, }, }; } diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 7e92ab4c26..588a61f678 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -25,7 +25,7 @@ namespace osu.Game.Overlays.Changelog RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; Direction = FillDirection.Vertical; - Padding = new MarginPadding{ Bottom = 100, }; + Padding = new MarginPadding{ Bottom = 100 }; } public void ShowListing(APIChangelog[] changelog) @@ -44,7 +44,7 @@ namespace osu.Game.Overlays.Changelog RelativeSizeAxes = Axes.X, Height = 2, Colour = new Color4(17, 17, 17, 255), - Margin = new MarginPadding { Top = 30, }, + Margin = new MarginPadding { Top = 30 }, }); } changelogContentGroup = new ChangelogContentGroup(build, true); @@ -60,7 +60,7 @@ namespace osu.Game.Overlays.Changelog RelativeSizeAxes = Axes.X, Height = 1, Colour = new Color4(32, 24, 35, 255), - Margin = new MarginPadding { Top = 30, }, + Margin = new MarginPadding { Top = 30 }, }); changelogContentGroup = new ChangelogContentGroup(build, false); diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 1346689cb7..8768f3623b 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -105,7 +105,7 @@ namespace osu.Game.Overlays.Changelog Font = @"Exo2.0-Medium", Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Margin = new MarginPadding { Top = 5 } + Margin = new MarginPadding { Top = 5 }, }, ChangelogEntries = new FillFlowContainer { diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs index 201524cc2f..dd4ca1ce0b 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -39,11 +39,7 @@ namespace osu.Game.Overlays.Changelog.Header Text = displayText, Anchor = Anchor.Centre, Origin = Anchor.Centre, - Margin = new MarginPadding - { - Top = 5, - Bottom = 15, - } + Margin = new MarginPadding { Top = 5, Bottom = 15 }, }, LineBadge = new LineBadge(startCollapsed) { diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index fc12d58f7a..ad5a858545 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -56,7 +56,7 @@ namespace osu.Game.Overlays.Changelog Text = LatestBuild.UpdateStream.DisplayName, Font = @"Exo2.0-Bold", TextSize = 14, // web: 12, - Margin = new MarginPadding { Top = 6, }, + Margin = new MarginPadding { Top = 6 }, }, new SpriteText { From dcb5eb1767c3772a033172524f81f0bbb45ab153 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Wed, 25 Jul 2018 17:05:29 +0200 Subject: [PATCH 086/375] Remove reduntant comment --- osu.Game/Overlays/Changelog/ChangelogChart.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs index 369982a2ac..7880ad8021 100644 --- a/osu.Game/Overlays/Changelog/ChangelogChart.cs +++ b/osu.Game/Overlays/Changelog/ChangelogChart.cs @@ -13,7 +13,6 @@ using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Overlays.Changelog { - // maybe look to osu.Game.Screens.Play.SquareGraph for reference later public class ChangelogChart : BufferedContainer { private const float height = 100; From fb8ea770aef05d199d49cfdaed7c5692dd73dd97 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Wed, 25 Jul 2018 18:55:02 +0200 Subject: [PATCH 087/375] Make ChangelogChart's child buffered --- osu.Game/Overlays/Changelog/ChangelogChart.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs index 7880ad8021..ee41b8085b 100644 --- a/osu.Game/Overlays/Changelog/ChangelogChart.cs +++ b/osu.Game/Overlays/Changelog/ChangelogChart.cs @@ -13,12 +13,13 @@ using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Overlays.Changelog { - public class ChangelogChart : BufferedContainer + public class ChangelogChart : Container { private const float height = 100; private const float transition_duration = 300; - private readonly Container container; + // why make the child buffered? https://streamable.com/swbdj + private readonly BufferedContainer container; private readonly Box background; private APIAccess api; @@ -26,7 +27,7 @@ namespace osu.Game.Overlays.Changelog { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - Child = container = new Container + Child = container = new BufferedContainer { RelativeSizeAxes = Axes.X, Height = height, From 81786c4763a3ccf68f66ac80f380b60243fad7cf Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Wed, 25 Jul 2018 20:01:24 +0200 Subject: [PATCH 088/375] Move statement to a new line --- osu.Game/Overlays/Changelog/ChangelogChart.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs index ee41b8085b..d965651e27 100644 --- a/osu.Game/Overlays/Changelog/ChangelogChart.cs +++ b/osu.Game/Overlays/Changelog/ChangelogChart.cs @@ -54,7 +54,8 @@ namespace osu.Game.Overlays.Changelog { if (changelogChart != null) foreach (BuildHistory buildHistory in changelogChart.BuildHistory) - if (buildHistory.UserCount > 0) return false; + if (buildHistory.UserCount > 0) + return false; return true; } From e1a24f55cfc84cb0aef8be7784dae73c36f753ff Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Wed, 25 Jul 2018 20:31:26 +0200 Subject: [PATCH 089/375] Update comments --- osu.Game/Graphics/UserInterface/ClickableText.cs | 4 ++++ osu.Game/Graphics/UserInterface/TooltipIconButton.cs | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/ClickableText.cs b/osu.Game/Graphics/UserInterface/ClickableText.cs index c27bc56238..159a2c3377 100644 --- a/osu.Game/Graphics/UserInterface/ClickableText.cs +++ b/osu.Game/Graphics/UserInterface/ClickableText.cs @@ -12,6 +12,10 @@ using System; namespace osu.Game.Graphics.UserInterface { + // created a new class instead of using a Link in + // some kind of textflowcontainer because they aren't + // capable of having delegates/actions on click + // and (probably) can't be disabled public class ClickableText : OsuSpriteText, IHasTooltip { private bool isEnabled; diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs index 65ab5de036..19c5421f6a 100644 --- a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs +++ b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs @@ -15,8 +15,7 @@ using System; namespace osu.Game.Graphics.UserInterface { // not inheriting osuclickablecontainer/osuhovercontainer - // because click/hover sounds cannot be disabled, and they make - // double sounds when reappearing under the cursor + // because click/hover sounds cannot be disabled public class TooltipIconButton : ClickableContainer, IHasTooltip { private readonly SpriteIcon icon; From 6e6e43e8dffade2c4c1a551448c3a8827b17b3ae Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Wed, 25 Jul 2018 21:38:32 +0200 Subject: [PATCH 090/375] ClickableText changes colour on hover --- .../Graphics/UserInterface/ClickableText.cs | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/ClickableText.cs b/osu.Game/Graphics/UserInterface/ClickableText.cs index 159a2c3377..739c5067d2 100644 --- a/osu.Game/Graphics/UserInterface/ClickableText.cs +++ b/osu.Game/Graphics/UserInterface/ClickableText.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -20,9 +21,13 @@ namespace osu.Game.Graphics.UserInterface { private bool isEnabled; private bool isMuted; + private SampleChannel sampleHover; private SampleChannel sampleClick; + protected Color4 HoverColour; + protected Color4 IdleColour; + /// /// An action that can be set to execute after click. /// @@ -78,10 +83,19 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnHover(InputState state) { if (isEnabled && !IsHoverMuted) + { + this.FadeColour(HoverColour, 500, Easing.OutQuint); sampleHover?.Play(); + } return base.OnHover(state); } + protected override void OnHoverLost(InputState state) + { + this.FadeColour(IdleColour, 500, Easing.OutQuint); + base.OnHoverLost(state); + } + protected override bool OnClick(InputState state) { if (isEnabled) @@ -93,13 +107,20 @@ namespace osu.Game.Graphics.UserInterface return base.OnClick(state); } + protected override void LoadComplete() + { + IdleColour = Colour; + base.LoadComplete(); + } + public string TooltipText { get; set; } [BackgroundDependencyLoader] - private void load(AudioManager audio) + private void load(AudioManager audio, OsuColour colours) { sampleClick = audio.Sample.Get(@"UI/generic-select-soft"); sampleHover = audio.Sample.Get(@"UI/generic-hover-soft"); + HoverColour = colours.Yellow; } } } From 93dbc55738957e7561a2cf1f128dd804e30b825e Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Thu, 26 Jul 2018 10:47:43 +0200 Subject: [PATCH 091/375] Fix wrong conditional expression --- osu.Game/Graphics/UserInterface/ClickableText.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/ClickableText.cs b/osu.Game/Graphics/UserInterface/ClickableText.cs index 739c5067d2..e0121ae28c 100644 --- a/osu.Game/Graphics/UserInterface/ClickableText.cs +++ b/osu.Game/Graphics/UserInterface/ClickableText.cs @@ -82,10 +82,11 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnHover(InputState state) { - if (isEnabled && !IsHoverMuted) + if (isEnabled) { this.FadeColour(HoverColour, 500, Easing.OutQuint); - sampleHover?.Play(); + if (!IsHoverMuted) + sampleHover?.Play(); } return base.OnHover(state); } From a2959e9171114496ec61b56f982caefae22d7e26 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Thu, 26 Jul 2018 13:43:47 +0200 Subject: [PATCH 092/375] Remove default value without use --- osu.Game/Overlays/Changelog/ChangelogContentGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 8768f3623b..3e0023ea9a 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -116,7 +116,7 @@ namespace osu.Game.Overlays.Changelog }; } - public ChangelogContentGroup(APIChangelog build, bool newDate = false) + public ChangelogContentGroup(APIChangelog build, bool newDate) { ClickableText clickableText; RelativeSizeAxes = Axes.X; From 0f263e2ccabfd9bb751148527c860baf0261d62f Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Thu, 26 Jul 2018 14:19:58 +0200 Subject: [PATCH 093/375] Delete ClickableText class, use OsuHoverContainer instead --- .../Visual/TestCaseClickableText.cs | 30 ----- .../Graphics/UserInterface/ClickableText.cs | 127 ------------------ .../Changelog/ChangelogContentGroup.cs | 49 ++++--- 3 files changed, 29 insertions(+), 177 deletions(-) delete mode 100644 osu.Game.Tests/Visual/TestCaseClickableText.cs delete mode 100644 osu.Game/Graphics/UserInterface/ClickableText.cs diff --git a/osu.Game.Tests/Visual/TestCaseClickableText.cs b/osu.Game.Tests/Visual/TestCaseClickableText.cs deleted file mode 100644 index 60ee764cfc..0000000000 --- a/osu.Game.Tests/Visual/TestCaseClickableText.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Graphics.Containers; -using osu.Game.Graphics.UserInterface; -using System; -using System.Collections.Generic; - -namespace osu.Game.Tests.Visual -{ - public class TestCaseClickableText : OsuTestCase - { - public override IReadOnlyList RequiredTypes => new[] { typeof(ClickableText), typeof(FillFlowContainer) }; - - private readonly ClickableText text; - public TestCaseClickableText() => Child = new FillFlowContainer - { - Children = new[] - { - new ClickableText { Text = "Default", }, - new ClickableText { IsEnabled = false, Text = "Disabled", }, - new ClickableText { Text = "Without sounds", IsMuted = true, }, - new ClickableText { Text = "Without click sounds", IsClickMuted = true, }, - new ClickableText { Text = "Without hover sounds", IsHoverMuted = true, }, - text = new ClickableText { Text = "Disables after click (Action)", Action = () => text.IsEnabled = false }, - new ClickableText { Text = "Has tooltip", TooltipText = "Yep", }, - } - }; - } -} diff --git a/osu.Game/Graphics/UserInterface/ClickableText.cs b/osu.Game/Graphics/UserInterface/ClickableText.cs deleted file mode 100644 index e0121ae28c..0000000000 --- a/osu.Game/Graphics/UserInterface/ClickableText.cs +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using OpenTK.Graphics; -using osu.Framework.Allocation; -using osu.Framework.Audio; -using osu.Framework.Audio.Sample; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Cursor; -using osu.Framework.Input.States; -using osu.Game.Graphics.Sprites; -using System; - -namespace osu.Game.Graphics.UserInterface -{ - // created a new class instead of using a Link in - // some kind of textflowcontainer because they aren't - // capable of having delegates/actions on click - // and (probably) can't be disabled - public class ClickableText : OsuSpriteText, IHasTooltip - { - private bool isEnabled; - private bool isMuted; - - private SampleChannel sampleHover; - private SampleChannel sampleClick; - - protected Color4 HoverColour; - protected Color4 IdleColour; - - /// - /// An action that can be set to execute after click. - /// - public Action Action; - - /// - /// If set to true, a sound will be played on click. - /// - public bool IsClickMuted; - - /// - /// If set to true, a sound will be played on hover. - /// - public bool IsHoverMuted; - - /// - /// If disabled, no sounds will be played and wont execute. - /// True by default. - /// - public bool IsEnabled - { - get { return isEnabled; } - set - { - isEnabled = value; - this.FadeTo(value ? 1 : 0.5f, 250); - } - } - - /// - /// Whether to play sounds on hover and click. Automatically sets - /// and to the same value.> - /// - public bool IsMuted { - get { return isMuted; } - set - { - IsHoverMuted = value; - IsClickMuted = value; - isMuted = value; - } - } - - /// - /// A text with sounds on hover and click, - /// an action that can be set to execute on click, - /// and a tooltip. - /// - public ClickableText() => isEnabled = true; - - public override bool HandleMouseInput => true; - - protected override bool OnHover(InputState state) - { - if (isEnabled) - { - this.FadeColour(HoverColour, 500, Easing.OutQuint); - if (!IsHoverMuted) - sampleHover?.Play(); - } - return base.OnHover(state); - } - - protected override void OnHoverLost(InputState state) - { - this.FadeColour(IdleColour, 500, Easing.OutQuint); - base.OnHoverLost(state); - } - - protected override bool OnClick(InputState state) - { - if (isEnabled) - { - if (!IsClickMuted) - sampleClick?.Play(); - Action?.Invoke(); - } - return base.OnClick(state); - } - - protected override void LoadComplete() - { - IdleColour = Colour; - base.LoadComplete(); - } - - public string TooltipText { get; set; } - - [BackgroundDependencyLoader] - private void load(AudioManager audio, OsuColour colours) - { - sampleClick = audio.Sample.Get(@"UI/generic-select-soft"); - sampleHover = audio.Sample.Get(@"UI/generic-hover-soft"); - HoverColour = colours.Yellow; - } - } -} diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 3e0023ea9a..3208f424ce 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -118,7 +118,7 @@ namespace osu.Game.Overlays.Changelog public ChangelogContentGroup(APIChangelog build, bool newDate) { - ClickableText clickableText; + OsuHoverContainer clickableBuildText; RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; Direction = FillDirection.Vertical; @@ -138,29 +138,33 @@ namespace osu.Game.Overlays.Changelog Margin = new MarginPadding { Top = 20 }, Alpha = newDate ? 1 : 0, }, - new FillFlowContainer + clickableBuildText = new OsuHoverContainer { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, Margin = new MarginPadding { Top = 20 }, - Spacing = new Vector2(5), - Children = new Drawable[] + Action = () => OnBuildSelected(build), + Child = new FillFlowContainer { - new SpriteText + Direction = FillDirection.Horizontal, + Spacing = new Vector2(5), + AutoSizeAxes = Axes.Both, + Children = new Drawable[] { - Text = build.UpdateStream.DisplayName, - TextSize = 20, // web: 18, - Font = @"Exo2.0-Medium", - }, - clickableText = new ClickableText - { - Text = build.DisplayVersion, - TextSize = 20, // web: 18, - Font = @"Exo2.0-Light", - Colour = StreamColour.FromStreamName(build.UpdateStream.Name), - Action = () => OnBuildSelected(build), + new SpriteText + { + Text = build.UpdateStream.DisplayName, + TextSize = 20, // web: 18, + Font = @"Exo2.0-Medium", + }, + new SpriteText + { + Text = build.DisplayVersion, + TextSize = 20, // web: 18, + Font = @"Exo2.0-Light", + Colour = StreamColour.FromStreamName(build.UpdateStream.Name), + }, }, } }, @@ -173,10 +177,15 @@ namespace osu.Game.Overlays.Changelog }; // we may not want double clicks to make it double the work - clickableText.Action += () => + // can be clicked again only after a delay + clickableBuildText.Action += () => { - clickableText.IsEnabled = false; - Scheduler.AddDelayed(() => clickableText.IsEnabled = true, 2000); + clickableBuildText.Action = null; + clickableBuildText.FadeTo(0.5f, 500); + Scheduler.AddDelayed(() => { + clickableBuildText.Action = () => OnBuildSelected(build); + clickableBuildText.FadeIn(500); + }, 2000); }; } From 2d8277f4137868e91d620e24d881fc4c63c092f5 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Thu, 26 Jul 2018 17:02:51 +0200 Subject: [PATCH 094/375] Plotting the chart 1 --- osu.Game/Overlays/Changelog/ChangelogChart.cs | 54 ++++++++++++++++--- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs index d965651e27..0141a3b3e1 100644 --- a/osu.Game/Overlays/Changelog/ChangelogChart.cs +++ b/osu.Game/Overlays/Changelog/ChangelogChart.cs @@ -3,13 +3,16 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; +using osu.Framework.Logging; using osu.Game.Graphics; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; +using System; namespace osu.Game.Overlays.Changelog { @@ -19,7 +22,7 @@ namespace osu.Game.Overlays.Changelog private const float transition_duration = 300; // why make the child buffered? https://streamable.com/swbdj - private readonly BufferedContainer container; + private readonly Container container; private readonly Box background; private APIAccess api; @@ -27,17 +30,17 @@ namespace osu.Game.Overlays.Changelog { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - Child = container = new BufferedContainer + Child = container = new Container { RelativeSizeAxes = Axes.X, Height = height, Children = new Drawable[] { - background = new Box - { - Colour = OsuColour.Gray(0), - RelativeSizeAxes = Axes.Both, - }, + //background = new Box + //{ + // Colour = OsuColour.Gray(0), + // RelativeSizeAxes = Axes.Both, + //}, new SpriteText { Text = "Graph Placeholder", @@ -63,8 +66,8 @@ namespace osu.Game.Overlays.Changelog { if (!isEmpty(chartInfo)) { - background.Colour = StreamColour.FromStreamName(updateStreamName); container.MoveToY(0, transition_duration, Easing.InOutQuad).FadeIn(transition_duration); + plotChart(chartInfo, StreamColour.FromStreamName(updateStreamName)); } else container.MoveToY(-height, transition_duration, Easing.InOutQuad).FadeOut(transition_duration); @@ -89,5 +92,40 @@ namespace osu.Game.Overlays.Changelog req.Success += res => showChart(res); api.Queue(req); } + + // this could probably be combined with isEmpty, todo + private float getMaxUserCount(APIChangelogChart changelogChartInfo) + { + var maxUserCount = 0l; + foreach (BuildHistory build in changelogChartInfo.BuildHistory) + { + if (build.UserCount > maxUserCount) + maxUserCount = build.UserCount; + } + return maxUserCount; + } + + private void plotChart(APIChangelogChart changelogChartInfo, ColourInfo colour) + { + var maxUserCount = getMaxUserCount(changelogChartInfo); + var currentPos = 0f; + + container.Clear(); + + foreach (BuildHistory build in changelogChartInfo.BuildHistory) + { + container.Add(new Box + { + RelativeSizeAxes = Axes.Y, + Width = Math.Max(container.DrawWidth / changelogChartInfo.BuildHistory.Count, 2), + Height = build.UserCount / maxUserCount, + X = currentPos, + Colour = colour, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + }); + currentPos += container.DrawWidth / changelogChartInfo.BuildHistory.Count; + } + } } } From 516ba10dadbe321a19ae285392fa9719d468ccb5 Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Thu, 26 Jul 2018 17:26:42 +0200 Subject: [PATCH 095/375] Plotting the chart 2 --- osu.Game/Overlays/Changelog/ChangelogChart.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs index 0141a3b3e1..730c0e2ad7 100644 --- a/osu.Game/Overlays/Changelog/ChangelogChart.cs +++ b/osu.Game/Overlays/Changelog/ChangelogChart.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; -using osu.Framework.Logging; using osu.Game.Graphics; using osu.Game.Online.API; using osu.Game.Online.API.Requests; @@ -30,6 +29,7 @@ namespace osu.Game.Overlays.Changelog { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; + Masking = true; Child = container = new Container { RelativeSizeAxes = Axes.X, @@ -117,12 +117,13 @@ namespace osu.Game.Overlays.Changelog container.Add(new Box { RelativeSizeAxes = Axes.Y, - Width = Math.Max(container.DrawWidth / changelogChartInfo.BuildHistory.Count, 2), + Width = Math.Max(container.DrawWidth / changelogChartInfo.BuildHistory.Count, 1), Height = build.UserCount / maxUserCount, X = currentPos, Colour = colour, Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, + Blending = BlendingMode.None, }); currentPos += container.DrawWidth / changelogChartInfo.BuildHistory.Count; } From 46134ed63d7bc012b67701a15dcc3b5155de14fd Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Thu, 26 Jul 2018 23:53:12 +0200 Subject: [PATCH 096/375] Add "ok" chart plotting; Add more keys to StreamColour .FromStreamName function --- osu.Game/Graphics/StreamColour.cs | 5 ++ osu.Game/Overlays/Changelog/ChangelogChart.cs | 86 ++++++++++++------- 2 files changed, 60 insertions(+), 31 deletions(-) diff --git a/osu.Game/Graphics/StreamColour.cs b/osu.Game/Graphics/StreamColour.cs index 71626a0e3a..9149c29b0a 100644 --- a/osu.Game/Graphics/StreamColour.cs +++ b/osu.Game/Graphics/StreamColour.cs @@ -19,10 +19,15 @@ namespace osu.Game.Graphics private static readonly Dictionary colours = new Dictionary { { "stable40", STABLE }, + { "Stable", STABLE }, { "stable", STABLEFALLBACK }, + { "Stable Fallback", STABLEFALLBACK }, { "beta40", BETA }, + { "Beta", BETA }, { "cuttingedge", CUTTINGEDGE }, + { "Cutting Edge", CUTTINGEDGE }, { "lazer", LAZER }, + { "Lazer", LAZER }, { "web", WEB }, }; diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs index 730c0e2ad7..57b3022724 100644 --- a/osu.Game/Overlays/Changelog/ChangelogChart.cs +++ b/osu.Game/Overlays/Changelog/ChangelogChart.cs @@ -8,10 +8,12 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; +using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; using System; +using System.Collections.Generic; namespace osu.Game.Overlays.Changelog { @@ -29,27 +31,10 @@ namespace osu.Game.Overlays.Changelog { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - Masking = true; Child = container = new Container { RelativeSizeAxes = Axes.X, Height = height, - Children = new Drawable[] - { - //background = new Box - //{ - // Colour = OsuColour.Gray(0), - // RelativeSizeAxes = Axes.Both, - //}, - new SpriteText - { - Text = "Graph Placeholder", - TextSize = 28, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Colour = OsuColour.Gray(1), - }, - }, }; } @@ -67,7 +52,10 @@ namespace osu.Game.Overlays.Changelog if (!isEmpty(chartInfo)) { container.MoveToY(0, transition_duration, Easing.InOutQuad).FadeIn(transition_duration); - plotChart(chartInfo, StreamColour.FromStreamName(updateStreamName)); + if (string.IsNullOrEmpty(updateStreamName)) + plotCharts(chartInfo); + else + plotChart(chartInfo, StreamColour.FromStreamName(updateStreamName)); } else container.MoveToY(-height, transition_duration, Easing.InOutQuad).FadeOut(transition_duration); @@ -105,27 +93,63 @@ namespace osu.Game.Overlays.Changelog return maxUserCount; } + private List clearUpDips(List buildHistories, float maxUserCount) + { + var buildHistory = new List(); + foreach (BuildHistory build in buildHistories) + { + if (build.UserCount / maxUserCount > 0.2f) + buildHistory.Add(build.UserCount); + } + return buildHistory; + } + private void plotChart(APIChangelogChart changelogChartInfo, ColourInfo colour) { var maxUserCount = getMaxUserCount(changelogChartInfo); - var currentPos = 0f; - container.Clear(); + container.Child = new BarGraph + { + Colour = colour, + Values = clearUpDips(changelogChartInfo.BuildHistory, maxUserCount), + RelativeSizeAxes = Axes.Both, + Direction = BarDirection.BottomToTop, + }; + } + + private void plotCharts(APIChangelogChart changelogChartInfo) + { + var maxUserCount = getMaxUserCount(changelogChartInfo); + + var releaseStreams = new Dictionary>(changelogChartInfo.Order.Count); + var highestUserCounts = new Dictionary(changelogChartInfo.Order.Count); + + foreach (string updateStream in changelogChartInfo.Order) + { + releaseStreams.Add(updateStream, new List()); + highestUserCounts.Add(updateStream, 0); + } foreach (BuildHistory build in changelogChartInfo.BuildHistory) { - container.Add(new Box + releaseStreams[build.Label].Add(build.UserCount); + if (highestUserCounts[build.Label] < build.UserCount) + highestUserCounts[build.Label] = build.UserCount; + } + + container.Clear(); + + foreach (KeyValuePair> releaseStream in releaseStreams) + { + var barGraph = new BarGraph { - RelativeSizeAxes = Axes.Y, - Width = Math.Max(container.DrawWidth / changelogChartInfo.BuildHistory.Count, 1), - Height = build.UserCount / maxUserCount, - X = currentPos, - Colour = colour, - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Blending = BlendingMode.None, - }); - currentPos += container.DrawWidth / changelogChartInfo.BuildHistory.Count; + Colour = StreamColour.FromStreamName(releaseStream.Key), + Values = releaseStream.Value, + RelativeSizeAxes = Axes.Both, + Direction = BarDirection.BottomToTop, + //Height = highestUserCounts[releaseStream.Key] / maxUserCount, + }; + container.Add(barGraph); } } } From fba817b4e110f7c44f30dd79139c3ede7c8f39df Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Fri, 27 Jul 2018 00:34:44 +0200 Subject: [PATCH 097/375] Resign ChangelogChart and disable its references --- osu.Game/Overlays/Changelog/ChangelogChart.cs | 156 ------------------ osu.Game/Overlays/ChangelogOverlay.cs | 20 ++- 2 files changed, 12 insertions(+), 164 deletions(-) delete mode 100644 osu.Game/Overlays/Changelog/ChangelogChart.cs diff --git a/osu.Game/Overlays/Changelog/ChangelogChart.cs b/osu.Game/Overlays/Changelog/ChangelogChart.cs deleted file mode 100644 index 57b3022724..0000000000 --- a/osu.Game/Overlays/Changelog/ChangelogChart.cs +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; -using osu.Game.Graphics; -using osu.Game.Graphics.UserInterface; -using osu.Game.Online.API; -using osu.Game.Online.API.Requests; -using osu.Game.Online.API.Requests.Responses; -using System; -using System.Collections.Generic; - -namespace osu.Game.Overlays.Changelog -{ - public class ChangelogChart : Container - { - private const float height = 100; - private const float transition_duration = 300; - - // why make the child buffered? https://streamable.com/swbdj - private readonly Container container; - private readonly Box background; - private APIAccess api; - - public ChangelogChart() - { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - Child = container = new Container - { - RelativeSizeAxes = Axes.X, - Height = height, - }; - } - - private bool isEmpty(APIChangelogChart changelogChart) - { - if (changelogChart != null) - foreach (BuildHistory buildHistory in changelogChart.BuildHistory) - if (buildHistory.UserCount > 0) - return false; - return true; - } - - private void showChart(APIChangelogChart chartInfo, string updateStreamName = null) - { - if (!isEmpty(chartInfo)) - { - container.MoveToY(0, transition_duration, Easing.InOutQuad).FadeIn(transition_duration); - if (string.IsNullOrEmpty(updateStreamName)) - plotCharts(chartInfo); - else - plotChart(chartInfo, StreamColour.FromStreamName(updateStreamName)); - } - else - container.MoveToY(-height, transition_duration, Easing.InOutQuad).FadeOut(transition_duration); - } - - [BackgroundDependencyLoader] - private void load(APIAccess api) - { - this.api = api; - } - - public void ShowUpdateStream(string updateStream) - { - var req = new GetChangelogChartRequest(updateStream); - req.Success += res => showChart(res, updateStream); - api.Queue(req); - } - - public void ShowAllUpdateStreams() - { - var req = new GetChangelogChartRequest(); - req.Success += res => showChart(res); - api.Queue(req); - } - - // this could probably be combined with isEmpty, todo - private float getMaxUserCount(APIChangelogChart changelogChartInfo) - { - var maxUserCount = 0l; - foreach (BuildHistory build in changelogChartInfo.BuildHistory) - { - if (build.UserCount > maxUserCount) - maxUserCount = build.UserCount; - } - return maxUserCount; - } - - private List clearUpDips(List buildHistories, float maxUserCount) - { - var buildHistory = new List(); - foreach (BuildHistory build in buildHistories) - { - if (build.UserCount / maxUserCount > 0.2f) - buildHistory.Add(build.UserCount); - } - return buildHistory; - } - - private void plotChart(APIChangelogChart changelogChartInfo, ColourInfo colour) - { - var maxUserCount = getMaxUserCount(changelogChartInfo); - - container.Child = new BarGraph - { - Colour = colour, - Values = clearUpDips(changelogChartInfo.BuildHistory, maxUserCount), - RelativeSizeAxes = Axes.Both, - Direction = BarDirection.BottomToTop, - }; - } - - private void plotCharts(APIChangelogChart changelogChartInfo) - { - var maxUserCount = getMaxUserCount(changelogChartInfo); - - var releaseStreams = new Dictionary>(changelogChartInfo.Order.Count); - var highestUserCounts = new Dictionary(changelogChartInfo.Order.Count); - - foreach (string updateStream in changelogChartInfo.Order) - { - releaseStreams.Add(updateStream, new List()); - highestUserCounts.Add(updateStream, 0); - } - - foreach (BuildHistory build in changelogChartInfo.BuildHistory) - { - releaseStreams[build.Label].Add(build.UserCount); - if (highestUserCounts[build.Label] < build.UserCount) - highestUserCounts[build.Label] = build.UserCount; - } - - container.Clear(); - - foreach (KeyValuePair> releaseStream in releaseStreams) - { - var barGraph = new BarGraph - { - Colour = StreamColour.FromStreamName(releaseStream.Key), - Values = releaseStream.Value, - RelativeSizeAxes = Axes.Both, - Direction = BarDirection.BottomToTop, - //Height = highestUserCounts[releaseStream.Key] / maxUserCount, - }; - container.Add(barGraph); - } - } - } -} diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index a0d0726c01..a14fa77da3 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -25,7 +25,7 @@ namespace osu.Game.Overlays { private readonly ChangelogHeader header; private readonly ChangelogBadges badges; - private readonly ChangelogChart chart; + //private readonly ChangelogChart chart; private readonly ChangelogContent listing; private readonly ChangelogContent content; @@ -85,7 +85,7 @@ namespace osu.Game.Overlays { header = new ChangelogHeader(), badges = new ChangelogBadges(), - chart = new ChangelogChart(), + //chart = new ChangelogChart(), listing = new ChangelogContent(), content = new ChangelogContent() }, @@ -162,7 +162,6 @@ namespace osu.Game.Overlays isAtListing = true; var req = new GetChangelogRequest(); badges.SelectNone(); - chart.ShowAllUpdateStreams(); req.Success += listing.ShowListing; api.Queue(req); } @@ -176,7 +175,7 @@ namespace osu.Game.Overlays content.Hide(); listing.Show(); badges.SelectNone(); - chart.ShowAllUpdateStreams(); + //chart.ShowAllUpdateStreams(); listing.Show(); scroll.ScrollTo(savedScrollPosition); } @@ -184,7 +183,12 @@ namespace osu.Game.Overlays /// /// Fetches and shows a specific build from a specific update stream. /// - public void FetchAndShowBuild(APIChangelog build, bool sentByBadges = false) + /// Must contain at least and + /// . If and + /// are specified, the header will instantly display them. + /// Whether to update badges. Should be set to false in case + /// the function is called by selecting a badge, to avoid an infinite loop. + public void FetchAndShowBuild(APIChangelog build, bool updateBadges = true) { var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); @@ -193,17 +197,17 @@ namespace osu.Game.Overlays else req.Success += res => header.ShowBuild(res.UpdateStream.DisplayName, res.DisplayVersion); - if (!sentByBadges) + if (updateBadges) badges.SelectUpdateStream(build.UpdateStream.Name); - chart.ShowUpdateStream(build.UpdateStream.Name); + //chart.ShowUpdateStream(build.UpdateStream.Name); req.Success += apiChangelog => { listing.Hide(); content.Show(); content.ShowBuild(apiChangelog); if (scroll.Current > scroll.GetChildPosInContent(content)) - scroll.ScrollTo(chart); + scroll.ScrollTo(content); if (isAtListing) savedScrollPosition = scroll.Current; isAtListing = false; From 6a5908801403a25db3864730b2fc615c1d44b1bf Mon Sep 17 00:00:00 2001 From: Houtarou Oreki Date: Wed, 22 Aug 2018 13:43:39 +0200 Subject: [PATCH 098/375] Move xml docs from ctors onto classes --- osu.Game/Graphics/UserInterface/LineBadge.cs | 10 +++++----- osu.Game/Graphics/UserInterface/TooltipIconButton.cs | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/LineBadge.cs b/osu.Game/Graphics/UserInterface/LineBadge.cs index 0283559aee..aaf225eb4c 100644 --- a/osu.Game/Graphics/UserInterface/LineBadge.cs +++ b/osu.Game/Graphics/UserInterface/LineBadge.cs @@ -6,6 +6,11 @@ using osu.Framework.Graphics.Shapes; namespace osu.Game.Graphics.UserInterface { + /// + /// A simple rounded expandable line. Set its + /// property to the center of the edge it's meant stick with. By default, + /// takes up the full parent's axis defined by . + /// public class LineBadge : Circle { public float UncollapsedSize; @@ -39,11 +44,6 @@ namespace osu.Game.Graphics.UserInterface } } - /// - /// A simple rounded expandable line. Set its - /// property to the center of the edge it's meant stick with. By default, - /// takes up the full parent's axis defined by . - /// /// Whether to initialize with the /// or the . public LineBadge(bool startCollapsed = true) diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs index 19c5421f6a..86fdd32bd2 100644 --- a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs +++ b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs @@ -16,6 +16,9 @@ namespace osu.Game.Graphics.UserInterface { // not inheriting osuclickablecontainer/osuhovercontainer // because click/hover sounds cannot be disabled + /// + /// An icon with an action upon click that can be disabled. + /// public class TooltipIconButton : ClickableContainer, IHasTooltip { private readonly SpriteIcon icon; @@ -48,9 +51,6 @@ namespace osu.Game.Graphics.UserInterface set { icon.Icon = value; } } - /// - /// A simple icon that has an action upon click and can be disabled. - /// public TooltipIconButton() { isEnabled = true; From 164a1a8e6e25797493c7ff44154ce90e6e776774 Mon Sep 17 00:00:00 2001 From: Houtarou Oreki Date: Wed, 22 Aug 2018 13:47:09 +0200 Subject: [PATCH 099/375] Remove unnecessary inheritance --- osu.Game/Graphics/UserInterface/TooltipIconButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs index 86fdd32bd2..ffd7153570 100644 --- a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs +++ b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs @@ -19,7 +19,7 @@ namespace osu.Game.Graphics.UserInterface /// /// An icon with an action upon click that can be disabled. /// - public class TooltipIconButton : ClickableContainer, IHasTooltip + public class TooltipIconButton : Container, IHasTooltip { private readonly SpriteIcon icon; private SampleChannel sampleHover; From a817164cb2cf339261f4b86cf339b4b7f159a3af Mon Sep 17 00:00:00 2001 From: Houtarou Oreki Date: Wed, 22 Aug 2018 13:49:08 +0200 Subject: [PATCH 100/375] Update comments --- osu.Game/Graphics/UserInterface/LineBadge.cs | 2 +- osu.Game/Graphics/UserInterface/TooltipIconButton.cs | 6 ++---- osu.Game/Overlays/Changelog/ChangelogContentGroup.cs | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/LineBadge.cs b/osu.Game/Graphics/UserInterface/LineBadge.cs index aaf225eb4c..53f057f4b3 100644 --- a/osu.Game/Graphics/UserInterface/LineBadge.cs +++ b/osu.Game/Graphics/UserInterface/LineBadge.cs @@ -20,7 +20,7 @@ namespace osu.Game.Graphics.UserInterface private bool isHorizontal; /// - /// Automatically sets the RelativeSizeAxes and switches X and Y components when changed. + /// Automatically sets the RelativeSizeAxes and switches X and Y size components when changed. /// public bool IsHorizontal { diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs index ffd7153570..f26df3f8c1 100644 --- a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs +++ b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs @@ -14,8 +14,6 @@ using System; namespace osu.Game.Graphics.UserInterface { - // not inheriting osuclickablecontainer/osuhovercontainer - // because click/hover sounds cannot be disabled /// /// An icon with an action upon click that can be disabled. /// @@ -26,14 +24,14 @@ namespace osu.Game.Graphics.UserInterface private SampleChannel sampleClick; /// - /// The action to fire upon click, if is set to true. + /// The action to fire upon click if is set to true. /// public Action Action; private bool isEnabled; /// - /// If set to true, upon click the will execute. It wont otherwise. + /// If set to true, upon click the will execute. /// public bool IsEnabled { diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 3208f424ce..c349f44d37 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -35,7 +35,6 @@ namespace osu.Game.Overlays.Changelog Padding = new MarginPadding { Horizontal = 70 }; Children = new Drawable[] { - // build version, arrows new FillFlowContainer { Anchor = Anchor.TopCentre, @@ -176,7 +175,7 @@ namespace osu.Game.Overlays.Changelog }, }; - // we may not want double clicks to make it double the work + // we may not want double clicks, // can be clicked again only after a delay clickableBuildText.Action += () => { From 510b52a50379c8a8fab72d529c3dc74e9f89822d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C5=8Dtar=C5=8D=20Oreki?= Date: Thu, 18 Oct 2018 20:56:43 +0200 Subject: [PATCH 101/375] Update overrided functions to match their bases --- .../Graphics/UserInterface/TooltipIconButton.cs | 9 +++++---- osu.Game/Overlays/Changelog/ChangelogBadges.cs | 9 +++++---- osu.Game/Overlays/Changelog/Header/TextBadgePair.cs | 9 +++++---- .../Changelog/Header/TextBadgePairListing.cs | 13 +++++++------ osu.Game/Overlays/Changelog/StreamBadge.cs | 13 +++++++------ osu.Game/Overlays/ChangelogOverlay.cs | 2 +- 6 files changed, 30 insertions(+), 25 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs index f26df3f8c1..8e26b2d47c 100644 --- a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs +++ b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input.Events; using osu.Framework.Input.States; using System; @@ -69,21 +70,21 @@ namespace osu.Game.Graphics.UserInterface }; } - protected override bool OnClick(InputState state) + protected override bool OnClick(ClickEvent e) { if (isEnabled) { sampleClick?.Play(); Action?.Invoke(); } - return base.OnClick(state); + return base.OnClick(e); } - protected override bool OnHover(InputState state) + protected override bool OnHover(HoverEvent e) { if (isEnabled) sampleHover?.Play(); - return base.OnHover(state); + return base.OnHover(e); } [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/Changelog/ChangelogBadges.cs b/osu.Game/Overlays/Changelog/ChangelogBadges.cs index 365d808108..f5d263bec0 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBadges.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBadges.cs @@ -5,6 +5,7 @@ using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input.Events; using osu.Framework.Input.States; using osu.Game.Online.API.Requests.Responses; using System; @@ -95,7 +96,7 @@ namespace osu.Game.Overlays.Changelog Selected?.Invoke(source.LatestBuild, EventArgs.Empty); } - protected override bool OnHover(InputState state) + protected override bool OnHover(HoverEvent e) { foreach (StreamBadge streamBadge in badgesContainer.Children) { @@ -109,10 +110,10 @@ namespace osu.Game.Overlays.Changelog else streamBadge.Deactivate(); } - return base.OnHover(state); + return base.OnHover(e); } - protected override void OnHoverLost(InputState state) + protected override void OnHoverLost(HoverLostEvent e) { foreach (StreamBadge streamBadge in badgesContainer.Children) { @@ -121,7 +122,7 @@ namespace osu.Game.Overlays.Changelog else if (streamBadge.LatestBuild.UpdateStream.Id == selectedStreamId) streamBadge.DisableDim(); } - base.OnHoverLost(state); + base.OnHoverLost(e); } } } diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs index dd4ca1ce0b..76db9e4444 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Framework.Input.Events; using osu.Framework.Input.States; using osu.Game.Graphics.UserInterface; using System; @@ -114,18 +115,18 @@ namespace osu.Game.Overlays.Changelog.Header .FadeIn(duration, easing); } - protected override bool OnHover(InputState state) + protected override bool OnHover(HoverEvent e) { if (!IsActivated) sampleHover?.Play(); - return base.OnHover(state); + return base.OnHover(e); } - protected override bool OnClick(InputState state) + protected override bool OnClick(ClickEvent e) { OnActivated(); sampleActivate?.Play(); - return base.OnClick(state); + return base.OnClick(e); } protected virtual void OnActivated() diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs index 31a06ce67d..19f1674551 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs @@ -4,6 +4,7 @@ using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; +using osu.Framework.Input.Events; using osu.Framework.Input.States; namespace osu.Game.Overlays.Changelog.Header @@ -48,23 +49,23 @@ namespace osu.Game.Overlays.Changelog.Header SetTextColour(badgeColour, 100); } - protected override bool OnClick(InputState state) + protected override bool OnClick(ClickEvent e) { Activate(); - return base.OnClick(state); + return base.OnClick(e); } - protected override bool OnHover(InputState state) + protected override bool OnHover(HoverEvent e) { LineBadge.Uncollapse(); - return base.OnHover(state); + return base.OnHover(e); } - protected override void OnHoverLost(InputState state) + protected override void OnHoverLost(HoverLostEvent e) { if (!IsActivated) LineBadge.Collapse(); - base.OnHoverLost(state); + base.OnHoverLost(e); } public void UpdateBadgeWidth() => LineBadge.ResizeWidthTo(Text.DrawWidth); diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index ad5a858545..552af17eb6 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -8,6 +8,7 @@ using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Framework.Input.Events; using osu.Framework.Input.States; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; @@ -107,23 +108,23 @@ namespace osu.Game.Overlays.Changelog } } - protected override bool OnClick(InputState state) + protected override bool OnClick(ClickEvent e) { Activate(false); sampleClick?.Play(); - return base.OnClick(state); + return base.OnClick(e); } - protected override bool OnHover(InputState state) + protected override bool OnHover(HoverEvent e) { sampleHover?.Play(); DisableDim(); this.FadeIn(transition_duration); lineBadge.Uncollapse(); - return base.OnHover(state); + return base.OnHover(e); } - protected override void OnHoverLost(InputState state) + protected override void OnHoverLost(HoverLostEvent e) { if (!isActivated) { @@ -132,7 +133,7 @@ namespace osu.Game.Overlays.Changelog } else EnableDim(); - base.OnHoverLost(state); + base.OnHoverLost(e); } public void EnableDim() => text.FadeTo(0.5f, transition_duration); diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index a14fa77da3..30b24d40bb 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -41,7 +41,7 @@ namespace osu.Game.Overlays private float savedScrollPosition; // receive input outside our bounds so we can trigger a close event on ourselves. - public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; + public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; public ChangelogOverlay() { From b8ac328ae9a02c639efd5670ca176c80d72feff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C5=8Dtar=C5=8D=20Oreki?= Date: Thu, 18 Oct 2018 21:04:21 +0200 Subject: [PATCH 102/375] Rename APIChangelog to APIChangelogBuild --- osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs | 2 +- .../Online/API/Requests/GetChangelogBuildRequest.cs | 2 +- .../API/Requests/GetChangelogLatestBuildsRequest.cs | 2 +- osu.Game/Online/API/Requests/GetChangelogRequest.cs | 2 +- .../{APIChangelog.cs => APIChangelogBuild.cs} | 6 +++--- osu.Game/Overlays/Changelog/ChangelogBadges.cs | 6 +++--- osu.Game/Overlays/Changelog/ChangelogContent.cs | 10 +++++----- osu.Game/Overlays/Changelog/ChangelogContentGroup.cs | 8 ++++---- osu.Game/Overlays/Changelog/StreamBadge.cs | 4 ++-- osu.Game/Overlays/ChangelogOverlay.cs | 10 +++++----- 10 files changed, 26 insertions(+), 26 deletions(-) rename osu.Game/Online/API/Requests/Responses/{APIChangelog.cs => APIChangelogBuild.cs} (95%) diff --git a/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs b/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs index d64f1c00f7..2bd8cc2016 100644 --- a/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs +++ b/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs @@ -22,7 +22,7 @@ namespace osu.Game.Tests.Visual AddWaitStep(3); AddStep(@"Show with Lazer 2018.712.0", () => { - changelog.FetchAndShowBuild(new APIChangelog + changelog.FetchAndShowBuild(new APIChangelogBuild { Version = "2018.712.0", UpdateStream = new UpdateStream { Name = "lazer" }, diff --git a/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs b/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs index 2338b90865..73d0ec6d20 100644 --- a/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs @@ -5,7 +5,7 @@ using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Online.API.Requests { - public class GetChangelogBuildRequest : APIRequest + public class GetChangelogBuildRequest : APIRequest { private readonly string name; private readonly string version; diff --git a/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs b/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs index 7940fd8ff5..314a03e7f6 100644 --- a/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; namespace osu.Game.Online.API.Requests { - public class GetChangelogLatestBuildsRequest : APIRequest> + public class GetChangelogLatestBuildsRequest : APIRequest> { protected override string Target => @"changelog/latest-builds"; protected override string Uri => $@"https://houtarouoreki.github.io/fake-api/{Target}"; // for testing diff --git a/osu.Game/Online/API/Requests/GetChangelogRequest.cs b/osu.Game/Online/API/Requests/GetChangelogRequest.cs index ec8536c607..b43f8d8ee1 100644 --- a/osu.Game/Online/API/Requests/GetChangelogRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogRequest.cs @@ -5,7 +5,7 @@ using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Online.API.Requests { - public class GetChangelogRequest : APIRequest + public class GetChangelogRequest : APIRequest { protected override string Target => @"changelog"; protected override string Uri => $@"https://houtarouoreki.github.io/fake-api/{Target}/index"; // for testing diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelog.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs similarity index 95% rename from osu.Game/Online/API/Requests/Responses/APIChangelog.cs rename to osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs index da5437515c..86ee8b49dd 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelog.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; namespace osu.Game.Online.API.Requests.Responses { - public class APIChangelog + public class APIChangelogBuild { [JsonProperty("id")] public long Id { get; set; } @@ -40,10 +40,10 @@ namespace osu.Game.Online.API.Requests.Responses public class Versions { [JsonProperty("next")] - public APIChangelog Next { get; set; } + public APIChangelogBuild Next { get; set; } [JsonProperty("previous")] - public APIChangelog Previous { get; set; } + public APIChangelogBuild Previous { get; set; } } public class ChangelogEntry diff --git a/osu.Game/Overlays/Changelog/ChangelogBadges.cs b/osu.Game/Overlays/Changelog/ChangelogBadges.cs index f5d263bec0..875aa9cd58 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBadges.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBadges.cs @@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Changelog private const float vertical_padding = 20; private const float horizontal_padding = 85; - public delegate void SelectionHandler(APIChangelog releaseStream, EventArgs args); + public delegate void SelectionHandler(APIChangelogBuild releaseStream, EventArgs args); public event SelectionHandler Selected; @@ -46,9 +46,9 @@ namespace osu.Game.Overlays.Changelog }; } - public void Populate(List latestBuilds) + public void Populate(List latestBuilds) { - foreach (APIChangelog updateStream in latestBuilds) + foreach (APIChangelogBuild updateStream in latestBuilds) { var streamBadge = new StreamBadge(updateStream); streamBadge.Selected += onBadgeSelected; diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 588a61f678..fadfb9048f 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Changelog private APIAccess api; private ChangelogContentGroup changelogContentGroup; - public delegate void BuildSelectedEventHandler(APIChangelog build, EventArgs args); + public delegate void BuildSelectedEventHandler(APIChangelogBuild build, EventArgs args); public event BuildSelectedEventHandler BuildSelected; @@ -28,12 +28,12 @@ namespace osu.Game.Overlays.Changelog Padding = new MarginPadding{ Bottom = 100 }; } - public void ShowListing(APIChangelog[] changelog) + public void ShowListing(APIChangelogBuild[] changelog) { DateTime currentDate = new DateTime(); Clear(); - foreach (APIChangelog build in changelog) + foreach (APIChangelogBuild build in changelog) { if (build.CreatedAt.Date != currentDate) { @@ -71,7 +71,7 @@ namespace osu.Game.Overlays.Changelog } } - public void ShowBuild(APIChangelog changelogBuild) + public void ShowBuild(APIChangelogBuild changelogBuild) { Child = changelogContentGroup = new ChangelogContentGroup(changelogBuild); changelogContentGroup.GenerateText(changelogBuild.ChangelogEntries); @@ -80,7 +80,7 @@ namespace osu.Game.Overlays.Changelog changelogContentGroup.BuildSelected += OnBuildSelected; } - protected virtual void OnBuildSelected(APIChangelog build, EventArgs args) + protected virtual void OnBuildSelected(APIChangelogBuild build, EventArgs args) { BuildSelected?.Invoke(build, EventArgs.Empty); } diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index c349f44d37..2dc8fd2bf7 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -21,13 +21,13 @@ namespace osu.Game.Overlays.Changelog private readonly SortedDictionary> categories = new SortedDictionary>(); - public delegate void BuildSelectedEventHandler(APIChangelog build, EventArgs args); + public delegate void BuildSelectedEventHandler(APIChangelogBuild build, EventArgs args); public event BuildSelectedEventHandler BuildSelected; public readonly FillFlowContainer ChangelogEntries; - public ChangelogContentGroup(APIChangelog build) + public ChangelogContentGroup(APIChangelogBuild build) { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; @@ -115,7 +115,7 @@ namespace osu.Game.Overlays.Changelog }; } - public ChangelogContentGroup(APIChangelog build, bool newDate) + public ChangelogContentGroup(APIChangelogBuild build, bool newDate) { OsuHoverContainer clickableBuildText; RelativeSizeAxes = Axes.X; @@ -202,7 +202,7 @@ namespace osu.Game.Overlays.Changelog } } - protected virtual void OnBuildSelected(APIChangelog build) + protected virtual void OnBuildSelected(APIChangelogBuild build) { BuildSelected?.Invoke(build, EventArgs.Empty); } diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 552af17eb6..5fb466769e 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -33,10 +33,10 @@ namespace osu.Game.Overlays.Changelog private SampleChannel sampleClick; private SampleChannel sampleHover; - public readonly APIChangelog LatestBuild; + public readonly APIChangelogBuild LatestBuild; private readonly FillFlowContainer text; - public StreamBadge(APIChangelog latestBuild) + public StreamBadge(APIChangelogBuild latestBuild) { LatestBuild = latestBuild; Height = badge_height; diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 30b24d40bb..302a9b351f 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -152,7 +152,7 @@ namespace osu.Game.Overlays return false; } - private void onBuildSelected(APIChangelog build, EventArgs e) => FetchAndShowBuild(build); + private void onBuildSelected(APIChangelogBuild build, EventArgs e) => FetchAndShowBuild(build); private void fetchListing() { @@ -183,12 +183,12 @@ namespace osu.Game.Overlays /// /// Fetches and shows a specific build from a specific update stream. /// - /// Must contain at least and - /// . If and - /// are specified, the header will instantly display them. + /// Must contain at least and + /// . If and + /// are specified, the header will instantly display them. /// Whether to update badges. Should be set to false in case /// the function is called by selecting a badge, to avoid an infinite loop. - public void FetchAndShowBuild(APIChangelog build, bool updateBadges = true) + public void FetchAndShowBuild(APIChangelogBuild build, bool updateBadges = true) { var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); From 390d8d230fb41bd01de3d9d0af1f24eadcef30a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C5=8Dtar=C5=8D=20Oreki?= Date: Thu, 18 Oct 2018 21:30:09 +0200 Subject: [PATCH 103/375] Remove redundant usings --- osu.Game/Graphics/UserInterface/TooltipIconButton.cs | 1 - osu.Game/Overlays/Changelog/ChangelogBadges.cs | 1 - osu.Game/Overlays/Changelog/Header/TextBadgePair.cs | 1 - osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs | 1 - osu.Game/Overlays/Changelog/StreamBadge.cs | 1 - 5 files changed, 5 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs index 8e26b2d47c..1233483054 100644 --- a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs +++ b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs @@ -10,7 +10,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; -using osu.Framework.Input.States; using System; namespace osu.Game.Graphics.UserInterface diff --git a/osu.Game/Overlays/Changelog/ChangelogBadges.cs b/osu.Game/Overlays/Changelog/ChangelogBadges.cs index 875aa9cd58..eabe5fe258 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBadges.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBadges.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; -using osu.Framework.Input.States; using osu.Game.Online.API.Requests.Responses; using System; using System.Collections.Generic; diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs index 76db9e4444..387b7d4405 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -9,7 +9,6 @@ using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; -using osu.Framework.Input.States; using osu.Game.Graphics.UserInterface; using System; diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs index 19f1674551..ab4165b30b 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs @@ -5,7 +5,6 @@ using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Input.Events; -using osu.Framework.Input.States; namespace osu.Game.Overlays.Changelog.Header { diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 5fb466769e..dcae8dc04f 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -9,7 +9,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; -using osu.Framework.Input.States; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API.Requests.Responses; From 69dda0ffd43caa6b94efd871e887cd3667433a9c Mon Sep 17 00:00:00 2001 From: Lucas A Date: Fri, 12 Apr 2019 22:36:01 +0200 Subject: [PATCH 104/375] OsuScreens can now set a per screen user status which defaults to UserStatusOnline --- osu.Game/Screens/OsuScreen.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index e0a25deecf..d54936ffda 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -14,6 +14,8 @@ using osu.Game.Input.Bindings; using osu.Game.Rulesets; using osu.Game.Screens.Menu; using osu.Game.Overlays; +using osu.Game.Users; +using osu.Game.Online.API; namespace osu.Game.Screens { @@ -50,6 +52,14 @@ namespace osu.Game.Screens protected new OsuGameBase Game => base.Game as OsuGameBase; + /// + /// The to set the user's status automatically to when this screen is entered / resumed. + /// Note that the user status won't be automatically set if : + /// - is overriden and returns null + /// - The current is or + /// + protected virtual UserStatus ScreenStatus => new UserStatusOnline(); + /// /// Whether to disallow changes to game-wise Beatmap/Ruleset bindables for this screen (and all children). /// @@ -83,6 +93,9 @@ namespace osu.Game.Screens [Resolved(canBeNull: true)] private OsuLogo logo { get; set; } + [Resolved(canBeNull: true)] + private IAPIProvider api { get; set; } + protected OsuScreen() { Anchor = Anchor.Centre; @@ -115,6 +128,8 @@ namespace osu.Game.Screens sampleExit?.Play(); applyArrivingDefaults(true); + setUserStatus(ScreenStatus); + base.OnResuming(last); } @@ -130,6 +145,8 @@ namespace osu.Game.Screens backgroundStack?.Push(localBackground = CreateBackground()); + setUserStatus(ScreenStatus); + base.OnEntering(last); } @@ -147,6 +164,12 @@ namespace osu.Game.Screens return false; } + private void setUserStatus(UserStatus status) + { + if (api != null && status != null && !(api.LocalUser.Value.Status.Value is UserStatusDoNotDisturb) && !(api.LocalUser.Value.Status.Value is UserStatusOffline)) //only sets the user's status to the given one if + api.LocalUser.Value.Status.Value = status; //status is not null and the current status isn't either UserStatusDoNotDisturb or UserStatusOffline + } + /// /// Fired when this screen was entered or resumed and the logo state is required to be adjusted. /// From da5d6cb1d48c7622e8f4e365dbea1a840fd48e22 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Fri, 12 Apr 2019 22:54:35 +0200 Subject: [PATCH 105/375] Add Beatmap fields to UserStatusSoloGame & UserStatusEditing so they can carry metadata about the played / edited beatmap --- osu.Game/Screens/Edit/Editor.cs | 3 +++ osu.Game/Screens/Play/Player.cs | 3 +++ osu.Game/Screens/Select/PlaySongSelect.cs | 3 +++ osu.Game/Users/UserStatus.cs | 27 +++++++++++++++++++++++ 4 files changed, 36 insertions(+) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 0ba1e74aca..bf00d23903 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -24,6 +24,7 @@ using osu.Game.Screens.Edit.Design; using osuTK.Input; using System.Collections.Generic; using osu.Framework; +using osu.Game.Users; namespace osu.Game.Screens.Edit { @@ -47,6 +48,8 @@ namespace osu.Game.Screens.Edit private DependencyContainer dependencies; private GameHost host; + protected override UserStatus ScreenStatus => new UserStatusEditing(Beatmap.Value.BeatmapInfo); + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 0eebefec86..edb6f9f865 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -26,6 +26,7 @@ using osu.Game.Scoring; using osu.Game.Screens.Ranking; using osu.Game.Skinning; using osu.Game.Storyboards.Drawables; +using osu.Game.Users; namespace osu.Game.Screens.Play { @@ -33,6 +34,8 @@ namespace osu.Game.Screens.Play { protected override bool AllowBackButton => false; // handled by HoldForMenuButton + protected override UserStatus ScreenStatus => new UserStatusSoloGame(Beatmap.Value.BeatmapInfo); + public override float BackgroundParallaxAmount => 0.1f; public override bool HideOverlaysOnEnter => true; diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 340ceb6864..384064d2a8 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Screens; using osu.Game.Graphics; using osu.Game.Screens.Play; +using osu.Game.Users; using osuTK.Input; namespace osu.Game.Screens.Select @@ -18,6 +19,8 @@ namespace osu.Game.Screens.Select public override bool AllowExternalScreenChange => true; + protected override UserStatus ScreenStatus => new UserStatusChoosingBeatmap(); + [BackgroundDependencyLoader] private void load(OsuColour colours) { diff --git a/osu.Game/Users/UserStatus.cs b/osu.Game/Users/UserStatus.cs index 14b4538a00..60e637d7e4 100644 --- a/osu.Game/Users/UserStatus.cs +++ b/osu.Game/Users/UserStatus.cs @@ -3,6 +3,7 @@ using osuTK.Graphics; using osu.Game.Graphics; +using osu.Game.Beatmaps; namespace osu.Game.Users { @@ -41,7 +42,33 @@ namespace osu.Game.Users public class UserStatusSoloGame : UserStatusBusy { + public UserStatusSoloGame(BeatmapInfo info) + { + Beatmap = info; + } + public override string Message => @"Solo Game"; + + public BeatmapInfo Beatmap { get; } + } + + public class UserStatusEditing : UserStatusBusy + { + public UserStatusEditing(BeatmapInfo info) + { + Beatmap = info; + } + + public override string Message => @"Editing a beatmap"; + + public override Color4 GetAppropriateColour(OsuColour colours) => colours.GreenDarker; + + public BeatmapInfo Beatmap { get; } + } + + public class UserStatusChoosingBeatmap : UserStatusOnline + { + public override string Message => @"Choosing a beatmap"; } public class UserStatusMultiplayerGame : UserStatusBusy From 5ab278f9eac4a3d72b8da0e37b07bfc037117717 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Fri, 12 Apr 2019 23:01:11 +0200 Subject: [PATCH 106/375] Add missing user statuses to tests --- osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs b/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs index b2877f7bd7..182ea6da01 100644 --- a/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs +++ b/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs @@ -43,11 +43,13 @@ namespace osu.Game.Tests.Visual.Online }); flyte.Status.Value = new UserStatusOnline(); - peppy.Status.Value = new UserStatusSoloGame(); + peppy.Status.Value = new UserStatusSoloGame(new Game.Beatmaps.BeatmapInfo()); AddStep(@"spectating", () => { flyte.Status.Value = new UserStatusSpectating(); }); AddStep(@"multiplaying", () => { flyte.Status.Value = new UserStatusMultiplayerGame(); }); AddStep(@"modding", () => { flyte.Status.Value = new UserStatusModding(); }); + AddStep(@"editing", () => { flyte.Status.Value = new UserStatusEditing(null); }); + AddStep(@"choosing", () => { flyte.Status.Value = new UserStatusChoosingBeatmap(); }); AddStep(@"offline", () => { flyte.Status.Value = new UserStatusOffline(); }); AddStep(@"null status", () => { flyte.Status.Value = null; }); } From 361c0ec9f26d9c066cb4830e16343bc3d5b6e02b Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sat, 13 Apr 2019 13:18:44 +0200 Subject: [PATCH 107/375] Allow UserStatusSoloGame to provide metadata such as the ruleset the current beatmap is played in --- osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs | 2 +- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Play/PlayerLoader.cs | 3 +++ osu.Game/Users/UserStatus.cs | 5 ++++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs b/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs index 182ea6da01..90cdd48a1e 100644 --- a/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs +++ b/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs @@ -43,7 +43,7 @@ namespace osu.Game.Tests.Visual.Online }); flyte.Status.Value = new UserStatusOnline(); - peppy.Status.Value = new UserStatusSoloGame(new Game.Beatmaps.BeatmapInfo()); + peppy.Status.Value = new UserStatusSoloGame(null, null); AddStep(@"spectating", () => { flyte.Status.Value = new UserStatusSpectating(); }); AddStep(@"multiplaying", () => { flyte.Status.Value = new UserStatusMultiplayerGame(); }); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index edb6f9f865..97133773fa 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -34,7 +34,7 @@ namespace osu.Game.Screens.Play { protected override bool AllowBackButton => false; // handled by HoldForMenuButton - protected override UserStatus ScreenStatus => new UserStatusSoloGame(Beatmap.Value.BeatmapInfo); + protected override UserStatus ScreenStatus => new UserStatusSoloGame(Beatmap.Value.BeatmapInfo, Ruleset.Value); public override float BackgroundParallaxAmount => 0.1f; diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index e9ee5d3fa8..4d2e3a8cca 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -19,6 +19,7 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Screens.Menu; using osu.Game.Screens.Play.HUD; using osu.Game.Screens.Play.PlayerSettings; +using osu.Game.Users; using osuTK; using osuTK.Graphics; @@ -39,6 +40,8 @@ namespace osu.Game.Screens.Play private bool hideOverlays; public override bool HideOverlaysOnEnter => hideOverlays; + protected override UserStatus ScreenStatus => null; //shows the previous screen status + public override bool DisallowExternalBeatmapRulesetChanges => true; private Task loadTask; diff --git a/osu.Game/Users/UserStatus.cs b/osu.Game/Users/UserStatus.cs index 60e637d7e4..39f295f445 100644 --- a/osu.Game/Users/UserStatus.cs +++ b/osu.Game/Users/UserStatus.cs @@ -42,14 +42,17 @@ namespace osu.Game.Users public class UserStatusSoloGame : UserStatusBusy { - public UserStatusSoloGame(BeatmapInfo info) + public UserStatusSoloGame(BeatmapInfo info, Rulesets.RulesetInfo ruleset) { Beatmap = info; + Ruleset = ruleset; } public override string Message => @"Solo Game"; public BeatmapInfo Beatmap { get; } + + public Rulesets.RulesetInfo Ruleset { get; } } public class UserStatusEditing : UserStatusBusy From a3541339f541b7d6a2f71a7a96e479d89dff082d Mon Sep 17 00:00:00 2001 From: Lucas A Date: Tue, 30 Apr 2019 21:40:44 +0200 Subject: [PATCH 108/375] Handle the restoring of the screen status when the user status is changed back to online after having being set to DND / offline via the login overlay --- osu.Game/Screens/OsuScreen.cs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index cf743db9f7..11161dd688 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -98,8 +98,7 @@ namespace osu.Game.Screens [Resolved(canBeNull: true)] private OsuLogo logo { get; set; } - [Resolved(canBeNull: true)] - private IAPIProvider api { get; set; } + private IAPIProvider api; protected OsuScreen() { @@ -108,9 +107,10 @@ namespace osu.Game.Screens } [BackgroundDependencyLoader(true)] - private void load(OsuGame osu, AudioManager audio) + private void load(OsuGame osu, AudioManager audio, IAPIProvider provider) { sampleExit = audio.Sample.Get(@"UI/screen-back"); + api = provider; } public virtual bool OnPressed(GlobalAction action) @@ -133,14 +133,27 @@ namespace osu.Game.Screens sampleExit?.Play(); applyArrivingDefaults(true); + if (api != null) + api.LocalUser.Value.Status.ValueChanged += userStatusChanged; + setUserStatus(ScreenStatus); base.OnResuming(last); } + private void userStatusChanged(ValueChangedEvent obj) + { + if (obj.NewValue?.GetType() != ScreenStatus?.GetType()) //restore the status back to this screen's status when the user status is changed back to online after having being set to DND / offline + setUserStatus(ScreenStatus); + } + public override void OnSuspending(IScreen next) { base.OnSuspending(next); + + if (api != null) + api.LocalUser.Value.Status.ValueChanged -= userStatusChanged; + onSuspendingLogo(); } @@ -150,6 +163,9 @@ namespace osu.Game.Screens backgroundStack?.Push(localBackground = CreateBackground()); + if (api != null) + api.LocalUser.Value.Status.ValueChanged += userStatusChanged; + setUserStatus(ScreenStatus); base.OnEntering(last); @@ -160,6 +176,9 @@ namespace osu.Game.Screens if (ValidForResume && logo != null) onExitingLogo(); + if (api != null) + api.LocalUser.Value.Status.ValueChanged -= userStatusChanged; + if (base.OnExiting(next)) return true; From e02def58f3213513deecabaac7f01b6febc5a663 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Wed, 1 May 2019 19:20:18 +0200 Subject: [PATCH 109/375] Fix tests failing --- .../Visual/Background/TestCaseBackgroundScreenBeatmap.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs index 81fab5b4b3..d4e563220b 100644 --- a/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs @@ -318,6 +318,8 @@ namespace osu.Game.Tests.Visual.Background private class FadeAccessibleResults : SoloResults { + protected override UserStatus ScreenStatus => null; + public FadeAccessibleResults(ScoreInfo score) : base(score) { @@ -330,6 +332,8 @@ namespace osu.Game.Tests.Visual.Background private class TestPlayer : Player { + protected override UserStatus ScreenStatus => null; + protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); protected override UserDimContainer CreateStoryboardContainer() @@ -377,6 +381,8 @@ namespace osu.Game.Tests.Visual.Background public VisualSettings VisualSettingsPos => VisualSettings; public BackgroundScreen ScreenPos => Background; + protected override UserStatus ScreenStatus => null; + public TestPlayerLoader(Player player) : base(() => player) { From 84b41b3886297d939c71fcba5bc21faeb1c0cbdc Mon Sep 17 00:00:00 2001 From: Lucas A Date: Thu, 2 May 2019 19:44:07 +0200 Subject: [PATCH 110/375] Split out setUserStatus() logic to multiple lines. + Make UserStatusDoNotDisturb inherit from UserStatus --- osu.Game.Tests/Visual/Gameplay/TestCasePause.cs | 3 +++ osu.Game/Screens/OsuScreen.cs | 13 +++++++++---- osu.Game/Users/UserStatus.cs | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs b/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs index a52e84ed62..eb84fe6316 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs @@ -12,6 +12,7 @@ using osu.Game.Rulesets; using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Scoring; using osu.Game.Screens.Play; +using osu.Game.Users; using osuTK; using osuTK.Input; @@ -192,6 +193,8 @@ namespace osu.Game.Tests.Visual.Gameplay public new HUDOverlay HUDOverlay => base.HUDOverlay; + protected override UserStatus ScreenStatus => null; + public bool FailOverlayVisible => FailOverlay.State == Visibility.Visible; public bool PauseOverlayVisible => PauseOverlay.State == Visibility.Visible; diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 11161dd688..f00d18271d 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -143,8 +143,9 @@ namespace osu.Game.Screens private void userStatusChanged(ValueChangedEvent obj) { - if (obj.NewValue?.GetType() != ScreenStatus?.GetType()) //restore the status back to this screen's status when the user status is changed back to online after having being set to DND / offline - setUserStatus(ScreenStatus); + if (obj.NewValue?.GetType() == ScreenStatus?.GetType()) return; //don't update the user's status if the current status is of the same type as the given one + + setUserStatus(ScreenStatus); } public override void OnSuspending(IScreen next) @@ -190,8 +191,12 @@ namespace osu.Game.Screens private void setUserStatus(UserStatus status) { - if (api != null && status != null && !(api.LocalUser.Value.Status.Value is UserStatusDoNotDisturb) && !(api.LocalUser.Value.Status.Value is UserStatusOffline)) //only sets the user's status to the given one if - api.LocalUser.Value.Status.Value = status; //status is not null and the current status isn't either UserStatusDoNotDisturb or UserStatusOffline + if (api == null) return; + if (status == null) return; + + if (!(api.LocalUser.Value.Status.Value is UserStatusOnline)) return; //don't update the user's status if the current status doesn't allow to be modified by screens (eg: DND / Offline) + + api.LocalUser.Value.Status.Value = status; } /// diff --git a/osu.Game/Users/UserStatus.cs b/osu.Game/Users/UserStatus.cs index 39f295f445..0ee12ed63f 100644 --- a/osu.Game/Users/UserStatus.cs +++ b/osu.Game/Users/UserStatus.cs @@ -85,7 +85,7 @@ namespace osu.Game.Users public override Color4 GetAppropriateColour(OsuColour colours) => colours.PurpleDark; } - public class UserStatusDoNotDisturb : UserStatusBusy + public class UserStatusDoNotDisturb : UserStatus { public override string Message => @"Do not disturb"; public override Color4 GetAppropriateColour(OsuColour colours) => colours.RedDark; From 5d4aa5a12e669e77edb03ef14be284cf23741fc2 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Thu, 2 May 2019 20:51:19 +0200 Subject: [PATCH 111/375] Add ScreenStatus property to change the OsuScreen's status + Renamed old ScreenStatus property to InitialScreenStatus --- .../TestCaseBackgroundScreenBeatmap.cs | 8 +++-- .../Visual/Gameplay/TestCasePause.cs | 2 +- osu.Game/Screens/Edit/Editor.cs | 2 +- osu.Game/Screens/OsuScreen.cs | 33 +++++++++++++++---- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Play/PlayerLoader.cs | 2 +- osu.Game/Screens/Select/PlaySongSelect.cs | 2 +- 7 files changed, 36 insertions(+), 15 deletions(-) diff --git a/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs index d4e563220b..58404d307f 100644 --- a/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs @@ -275,6 +275,8 @@ namespace osu.Game.Tests.Visual.Background private class DummySongSelect : PlaySongSelect { + protected override UserStatusOnline InitialScreenStatus => null; + protected override BackgroundScreen CreateBackground() { FadeAccessibleBackground background = new FadeAccessibleBackground(Beatmap.Value); @@ -318,7 +320,7 @@ namespace osu.Game.Tests.Visual.Background private class FadeAccessibleResults : SoloResults { - protected override UserStatus ScreenStatus => null; + protected override UserStatusOnline InitialScreenStatus => null; public FadeAccessibleResults(ScoreInfo score) : base(score) @@ -332,7 +334,7 @@ namespace osu.Game.Tests.Visual.Background private class TestPlayer : Player { - protected override UserStatus ScreenStatus => null; + protected override UserStatusOnline InitialScreenStatus => null; protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); @@ -381,7 +383,7 @@ namespace osu.Game.Tests.Visual.Background public VisualSettings VisualSettingsPos => VisualSettings; public BackgroundScreen ScreenPos => Background; - protected override UserStatus ScreenStatus => null; + protected override UserStatusOnline InitialScreenStatus => null; public TestPlayerLoader(Player player) : base(() => player) diff --git a/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs b/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs index eb84fe6316..ae7faf318f 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs @@ -193,7 +193,7 @@ namespace osu.Game.Tests.Visual.Gameplay public new HUDOverlay HUDOverlay => base.HUDOverlay; - protected override UserStatus ScreenStatus => null; + protected override UserStatusOnline InitialScreenStatus => null; public bool FailOverlayVisible => FailOverlay.State == Visibility.Visible; diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 6cbbc90ada..a04124082c 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -48,7 +48,7 @@ namespace osu.Game.Screens.Edit private DependencyContainer dependencies; private GameHost host; - protected override UserStatus ScreenStatus => new UserStatusEditing(Beatmap.Value.BeatmapInfo); + protected override UserStatusOnline InitialScreenStatus => new UserStatusEditing(Beatmap.Value.BeatmapInfo); protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index f00d18271d..17b8ca60dc 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -55,12 +55,29 @@ namespace osu.Game.Screens protected new OsuGameBase Game => base.Game as OsuGameBase; /// - /// The to set the user's status automatically to when this screen is entered / resumed. - /// Note that the user status won't be automatically set if : - /// - is overriden and returns null - /// - The current is or + /// The to set the user's status automatically to when this screen is entered /// - protected virtual UserStatus ScreenStatus => new UserStatusOnline(); + protected virtual UserStatusOnline InitialScreenStatus => new UserStatusOnline(); + + /// + /// The for this screen. + /// Note that the status won't be updated for the user if : + /// - The is set to null + /// - The current of the user is or + /// + protected UserStatusOnline ScreenStatus + { + set + { + if (value == null) return; + + status = value; + setUserStatus(value); + } + get => status; + } + + private UserStatusOnline status; /// /// Whether to disallow changes to game-wise Beatmap/Ruleset bindables for this screen (and all children). @@ -104,6 +121,8 @@ namespace osu.Game.Screens { Anchor = Anchor.Centre; Origin = Anchor.Centre; + + status = null; } [BackgroundDependencyLoader(true)] @@ -136,7 +155,7 @@ namespace osu.Game.Screens if (api != null) api.LocalUser.Value.Status.ValueChanged += userStatusChanged; - setUserStatus(ScreenStatus); + ScreenStatus = ScreenStatus; base.OnResuming(last); } @@ -167,7 +186,7 @@ namespace osu.Game.Screens if (api != null) api.LocalUser.Value.Status.ValueChanged += userStatusChanged; - setUserStatus(ScreenStatus); + ScreenStatus = InitialScreenStatus; base.OnEntering(last); } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 3a3bac8070..883e96b316 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -35,7 +35,7 @@ namespace osu.Game.Screens.Play { protected override bool AllowBackButton => false; // handled by HoldForMenuButton - protected override UserStatus ScreenStatus => new UserStatusSoloGame(Beatmap.Value.BeatmapInfo, Ruleset.Value); + protected override UserStatusOnline InitialScreenStatus => new UserStatusSoloGame(Beatmap.Value.BeatmapInfo, Ruleset.Value); public override float BackgroundParallaxAmount => 0.1f; diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 1099fbdcfd..8c4bf079ea 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -43,7 +43,7 @@ namespace osu.Game.Screens.Play private bool hideOverlays; public override bool HideOverlaysOnEnter => hideOverlays; - protected override UserStatus ScreenStatus => null; //shows the previous screen status + protected override UserStatusOnline InitialScreenStatus => null; //shows the previous screen status public override bool DisallowExternalBeatmapRulesetChanges => true; diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 8c6872846e..58b8ef3d28 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -19,7 +19,7 @@ namespace osu.Game.Screens.Select public override bool AllowExternalScreenChange => true; - protected override UserStatus ScreenStatus => new UserStatusChoosingBeatmap(); + protected override UserStatusOnline InitialScreenStatus => new UserStatusChoosingBeatmap(); [BackgroundDependencyLoader] private void load(OsuColour colours) From b216635488b934bc1a6c114750184879d6fdcac8 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 5 May 2019 20:07:55 +0200 Subject: [PATCH 112/375] Added UserActivity class holding information about the current activity for the local user --- osu.Game/Users/User.cs | 2 + osu.Game/Users/UserActivity.cs | 70 ++++++++++++++++++++++++++++++++++ osu.Game/Users/UserStatus.cs | 56 --------------------------- 3 files changed, 72 insertions(+), 56 deletions(-) create mode 100644 osu.Game/Users/UserActivity.cs diff --git a/osu.Game/Users/User.cs b/osu.Game/Users/User.cs index 314684069a..cf67af7bb8 100644 --- a/osu.Game/Users/User.cs +++ b/osu.Game/Users/User.cs @@ -25,6 +25,8 @@ namespace osu.Game.Users public Bindable Status = new Bindable(); + public Bindable Activity = new Bindable(); + //public Team Team; [JsonProperty(@"profile_colour")] diff --git a/osu.Game/Users/UserActivity.cs b/osu.Game/Users/UserActivity.cs new file mode 100644 index 0000000000..1e69cc3e8e --- /dev/null +++ b/osu.Game/Users/UserActivity.cs @@ -0,0 +1,70 @@ +// 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.Beatmaps; +using osu.Game.Graphics; +using osuTK.Graphics; + +namespace osu.Game.Users +{ + public abstract class UserActivity + { + public abstract string Status { get; } + public virtual Color4 GetAppropriateColour(OsuColour colours) => colours.GreenDarker; + } + + public class UserActivityModding : UserActivity + { + public override string Status => "Modding a map"; + public override Color4 GetAppropriateColour(OsuColour colours) => colours.PurpleDark; + } + + public class UserActivityChoosingBeatmap : UserActivity + { + public override string Status => "Choosing a beatmap"; + } + + public class UserActivityMultiplayerGame : UserActivity + { + public override string Status => "Multiplaying"; + } + + public class UserActivityEditing : UserActivity + { + public UserActivityEditing(BeatmapInfo info) + { + Beatmap = info; + } + + public override string Status => @"Editing a beatmap"; + + public BeatmapInfo Beatmap { get; } + } + + public class UserActivitySoloGame : UserActivity + { + public UserActivitySoloGame(BeatmapInfo info, Rulesets.RulesetInfo ruleset) + { + Beatmap = info; + Ruleset = ruleset; + } + + public override string Status => @"Solo Game"; + + public BeatmapInfo Beatmap { get; } + + public Rulesets.RulesetInfo Ruleset { get; } + } + + public class UserActivitySpectating : UserActivity + { + public override string Status => @"Spectating a game"; + } + + public class UserActivityInLobby : UserActivity + { + public override string Status => @"in Multiplayer Lobby"; + } + + +} diff --git a/osu.Game/Users/UserStatus.cs b/osu.Game/Users/UserStatus.cs index 0ee12ed63f..cf372560af 100644 --- a/osu.Game/Users/UserStatus.cs +++ b/osu.Game/Users/UserStatus.cs @@ -3,7 +3,6 @@ using osuTK.Graphics; using osu.Game.Graphics; -using osu.Game.Beatmaps; namespace osu.Game.Users { @@ -30,61 +29,6 @@ namespace osu.Game.Users public override Color4 GetAppropriateColour(OsuColour colours) => colours.Gray7; } - public class UserStatusSpectating : UserStatusOnline - { - public override string Message => @"Spectating a game"; - } - - public class UserStatusInLobby : UserStatusOnline - { - public override string Message => @"in Multiplayer Lobby"; - } - - public class UserStatusSoloGame : UserStatusBusy - { - public UserStatusSoloGame(BeatmapInfo info, Rulesets.RulesetInfo ruleset) - { - Beatmap = info; - Ruleset = ruleset; - } - - public override string Message => @"Solo Game"; - - public BeatmapInfo Beatmap { get; } - - public Rulesets.RulesetInfo Ruleset { get; } - } - - public class UserStatusEditing : UserStatusBusy - { - public UserStatusEditing(BeatmapInfo info) - { - Beatmap = info; - } - - public override string Message => @"Editing a beatmap"; - - public override Color4 GetAppropriateColour(OsuColour colours) => colours.GreenDarker; - - public BeatmapInfo Beatmap { get; } - } - - public class UserStatusChoosingBeatmap : UserStatusOnline - { - public override string Message => @"Choosing a beatmap"; - } - - public class UserStatusMultiplayerGame : UserStatusBusy - { - public override string Message => @"Multiplaying"; - } - - public class UserStatusModding : UserStatusOnline - { - public override string Message => @"Modding a map"; - public override Color4 GetAppropriateColour(OsuColour colours) => colours.PurpleDark; - } - public class UserStatusDoNotDisturb : UserStatus { public override string Message => @"Do not disturb"; From fa986bb5e94b255a6d9bbf0715fc9735ec1acea9 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 5 May 2019 20:26:56 +0200 Subject: [PATCH 113/375] Rework OsuScreen user activity logic --- osu.Game/Screens/OsuScreen.cs | 53 ++++++++--------------------------- 1 file changed, 11 insertions(+), 42 deletions(-) diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 17b8ca60dc..d8b38ff20a 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -55,29 +55,27 @@ namespace osu.Game.Screens protected new OsuGameBase Game => base.Game as OsuGameBase; /// - /// The to set the user's status automatically to when this screen is entered + /// The to set the user's activity automatically to when this screen is entered /// - protected virtual UserStatusOnline InitialScreenStatus => new UserStatusOnline(); + protected virtual UserActivity InitialScreenActivity => null; /// - /// The for this screen. - /// Note that the status won't be updated for the user if : - /// - The is set to null - /// - The current of the user is or + /// The for this screen. /// - protected UserStatusOnline ScreenStatus + protected UserActivity ScreenActivity { set { if (value == null) return; + if (api == null) return; - status = value; - setUserStatus(value); + activity = value; + api.LocalUser.Value.Activity.Value = activity; } - get => status; + get => activity; } - private UserStatusOnline status; + private UserActivity activity; /// /// Whether to disallow changes to game-wise Beatmap/Ruleset bindables for this screen (and all children). @@ -122,7 +120,7 @@ namespace osu.Game.Screens Anchor = Anchor.Centre; Origin = Anchor.Centre; - status = null; + activity = null; } [BackgroundDependencyLoader(true)] @@ -152,28 +150,15 @@ namespace osu.Game.Screens sampleExit?.Play(); applyArrivingDefaults(true); - if (api != null) - api.LocalUser.Value.Status.ValueChanged += userStatusChanged; - ScreenStatus = ScreenStatus; base.OnResuming(last); } - private void userStatusChanged(ValueChangedEvent obj) - { - if (obj.NewValue?.GetType() == ScreenStatus?.GetType()) return; //don't update the user's status if the current status is of the same type as the given one - - setUserStatus(ScreenStatus); - } - public override void OnSuspending(IScreen next) { base.OnSuspending(next); - if (api != null) - api.LocalUser.Value.Status.ValueChanged -= userStatusChanged; - onSuspendingLogo(); } @@ -183,10 +168,7 @@ namespace osu.Game.Screens backgroundStack?.Push(localBackground = CreateBackground()); - if (api != null) - api.LocalUser.Value.Status.ValueChanged += userStatusChanged; - - ScreenStatus = InitialScreenStatus; + ScreenStatus = InitialScreenActivity; base.OnEntering(last); } @@ -196,9 +178,6 @@ namespace osu.Game.Screens if (ValidForResume && logo != null) onExitingLogo(); - if (api != null) - api.LocalUser.Value.Status.ValueChanged -= userStatusChanged; - if (base.OnExiting(next)) return true; @@ -208,16 +187,6 @@ namespace osu.Game.Screens return false; } - private void setUserStatus(UserStatus status) - { - if (api == null) return; - if (status == null) return; - - if (!(api.LocalUser.Value.Status.Value is UserStatusOnline)) return; //don't update the user's status if the current status doesn't allow to be modified by screens (eg: DND / Offline) - - api.LocalUser.Value.Status.Value = status; - } - /// /// Fired when this screen was entered or resumed and the logo state is required to be adjusted. /// From 88b8afbb6aa0c8468b3b9e22e760ca9735e4fda2 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 5 May 2019 20:51:55 +0200 Subject: [PATCH 114/375] Make UserPanel show current user activity when user status is online. --- .../Sections/General/LoginSettings.cs | 1 + osu.Game/Overlays/SocialOverlay.cs | 1 + osu.Game/Screens/OsuScreen.cs | 4 ++-- osu.Game/Users/UserPanel.cs | 21 +++++++++++++++---- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 98eb4b662f..bf5a3c12f5 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -152,6 +152,7 @@ namespace osu.Game.Overlays.Settings.Sections.General }; panel.Status.BindTo(api.LocalUser.Value.Status); + panel.Activity.BindTo(api.LocalUser.Value.Activity); dropdown.Current.ValueChanged += action => { diff --git a/osu.Game/Overlays/SocialOverlay.cs b/osu.Game/Overlays/SocialOverlay.cs index daf3d1c576..0ad3541071 100644 --- a/osu.Game/Overlays/SocialOverlay.cs +++ b/osu.Game/Overlays/SocialOverlay.cs @@ -126,6 +126,7 @@ namespace osu.Game.Overlays } panel.Status.BindTo(u.Status); + panel.Activity.BindTo(u.Activity); return panel; }) }; diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index d8b38ff20a..170f548676 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -150,7 +150,7 @@ namespace osu.Game.Screens sampleExit?.Play(); applyArrivingDefaults(true); - ScreenStatus = ScreenStatus; + ScreenActivity = ScreenActivity; base.OnResuming(last); } @@ -168,7 +168,7 @@ namespace osu.Game.Screens backgroundStack?.Push(localBackground = CreateBackground()); - ScreenStatus = InitialScreenActivity; + ScreenActivity = InitialScreenActivity; base.OnEntering(last); } diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index 47571b673d..d5061ad423 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -30,6 +30,9 @@ namespace osu.Game.Users private const float content_padding = 10; private const float status_height = 30; + [Resolved(canBeNull: true)] + private OsuColour colours { get; set; } + private Container statusBar; private Box statusBg; private OsuSpriteText statusMessage; @@ -39,6 +42,8 @@ namespace osu.Game.Users public readonly Bindable Status = new Bindable(); + public readonly Bindable Activity = new Bindable(); + public new Action Action; protected Action ViewProfile; @@ -54,7 +59,7 @@ namespace osu.Game.Users } [BackgroundDependencyLoader(permitNulls: true)] - private void load(OsuColour colours, UserProfileOverlay profile) + private void load(UserProfileOverlay profile) { if (colours == null) throw new ArgumentNullException(nameof(colours)); @@ -195,8 +200,8 @@ namespace osu.Game.Users }); } - Status.ValueChanged += status => displayStatus(status.NewValue); - Status.ValueChanged += status => statusBg.FadeColour(status.NewValue?.GetAppropriateColour(colours) ?? colours.Gray5, 500, Easing.OutQuint); + Status.ValueChanged += status => displayStatus(status.NewValue, Activity.Value); + Activity.ValueChanged += activity => displayStatus(Status.Value, activity.NewValue); base.Action = ViewProfile = () => { @@ -211,7 +216,7 @@ namespace osu.Game.Users Status.TriggerChange(); } - private void displayStatus(UserStatus status) + private void displayStatus(UserStatus status, UserActivity activity = null) { const float transition_duration = 500; @@ -227,7 +232,15 @@ namespace osu.Game.Users statusBar.FadeIn(transition_duration, Easing.OutQuint); this.ResizeHeightTo(height, transition_duration, Easing.OutQuint); + if (status is UserStatusOnline && activity != null) + { + statusMessage.Text = activity.Status; + statusBg.FadeColour(status.GetAppropriateColour(colours), 500, Easing.OutQuint); + return; + } + statusMessage.Text = status.Message; + statusBg.FadeColour(status?.GetAppropriateColour(colours) ?? colours.Gray5, 500, Easing.OutQuint); } } From d5d31282e520511de72eb5c4e91fe25507ec250b Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 5 May 2019 20:55:42 +0200 Subject: [PATCH 115/375] Rename InitialScreenStatus to InitialScreenActivity in Editor / Player classes --- osu.Game/Screens/Edit/Editor.cs | 2 +- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Play/PlayerLoader.cs | 2 +- osu.Game/Screens/Select/PlaySongSelect.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index a04124082c..33f86b99bf 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -48,7 +48,7 @@ namespace osu.Game.Screens.Edit private DependencyContainer dependencies; private GameHost host; - protected override UserStatusOnline InitialScreenStatus => new UserStatusEditing(Beatmap.Value.BeatmapInfo); + protected override UserActivity InitialScreenActivity => new UserActivityEditing(Beatmap.Value.BeatmapInfo); protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index b75bfa9e04..f59c87d79e 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -35,7 +35,7 @@ namespace osu.Game.Screens.Play { protected override bool AllowBackButton => false; // handled by HoldForMenuButton - protected override UserStatusOnline InitialScreenStatus => new UserStatusSoloGame(Beatmap.Value.BeatmapInfo, Ruleset.Value); + protected override UserActivity InitialScreenActivity => new UserActivitySoloGame(Beatmap.Value.BeatmapInfo, Ruleset.Value); public override float BackgroundParallaxAmount => 0.1f; diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 8c4bf079ea..0385a70206 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -43,7 +43,7 @@ namespace osu.Game.Screens.Play private bool hideOverlays; public override bool HideOverlaysOnEnter => hideOverlays; - protected override UserStatusOnline InitialScreenStatus => null; //shows the previous screen status + protected override UserActivity InitialScreenActivity => null; //shows the previous screen status public override bool DisallowExternalBeatmapRulesetChanges => true; diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 58b8ef3d28..d52b6d44f5 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -19,7 +19,7 @@ namespace osu.Game.Screens.Select public override bool AllowExternalScreenChange => true; - protected override UserStatusOnline InitialScreenStatus => new UserStatusChoosingBeatmap(); + protected override UserActivity InitialScreenActivity => new UserActivityChoosingBeatmap(); [BackgroundDependencyLoader] private void load(OsuColour colours) From 8beb2f6e90d4e1fbe33f6d823886646b036be8b8 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 5 May 2019 21:01:35 +0200 Subject: [PATCH 116/375] Remove hackery from unit tests. --- .../Visual/Background/TestCaseBackgroundScreenBeatmap.cs | 5 ----- osu.Game.Tests/Visual/Gameplay/TestCasePause.cs | 2 -- 2 files changed, 7 deletions(-) diff --git a/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs index 58404d307f..e9208d8f5b 100644 --- a/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs @@ -275,7 +275,6 @@ namespace osu.Game.Tests.Visual.Background private class DummySongSelect : PlaySongSelect { - protected override UserStatusOnline InitialScreenStatus => null; protected override BackgroundScreen CreateBackground() { @@ -320,7 +319,6 @@ namespace osu.Game.Tests.Visual.Background private class FadeAccessibleResults : SoloResults { - protected override UserStatusOnline InitialScreenStatus => null; public FadeAccessibleResults(ScoreInfo score) : base(score) @@ -334,7 +332,6 @@ namespace osu.Game.Tests.Visual.Background private class TestPlayer : Player { - protected override UserStatusOnline InitialScreenStatus => null; protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); @@ -383,8 +380,6 @@ namespace osu.Game.Tests.Visual.Background public VisualSettings VisualSettingsPos => VisualSettings; public BackgroundScreen ScreenPos => Background; - protected override UserStatusOnline InitialScreenStatus => null; - public TestPlayerLoader(Player player) : base(() => player) { diff --git a/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs b/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs index ae7faf318f..dec4830188 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs @@ -193,8 +193,6 @@ namespace osu.Game.Tests.Visual.Gameplay public new HUDOverlay HUDOverlay => base.HUDOverlay; - protected override UserStatusOnline InitialScreenStatus => null; - public bool FailOverlayVisible => FailOverlay.State == Visibility.Visible; public bool PauseOverlayVisible => PauseOverlay.State == Visibility.Visible; From 3d8b56fe57b6f5d72e25dc06370692f9ded43918 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 5 May 2019 21:11:52 +0200 Subject: [PATCH 117/375] Fix user status related unit tests --- .../Visual/Online/TestCaseUserPanel.cs | 33 +++++++++++++------ osu.Game/Users/UserPanel.cs | 2 +- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs b/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs index ef91c843f2..3929fe6c50 100644 --- a/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs +++ b/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs @@ -12,10 +12,11 @@ namespace osu.Game.Tests.Visual.Online [TestFixture] public class TestCaseUserPanel : OsuTestCase { + UserPanel flyte; + UserPanel peppy; + public TestCaseUserPanel() { - UserPanel flyte; - UserPanel peppy; Add(new FillFlowContainer { Anchor = Anchor.Centre, @@ -44,15 +45,27 @@ namespace osu.Game.Tests.Visual.Online }); flyte.Status.Value = new UserStatusOnline(); - peppy.Status.Value = new UserStatusSoloGame(null, null); + peppy.Status.Value = null; + } - AddStep(@"spectating", () => { flyte.Status.Value = new UserStatusSpectating(); }); - AddStep(@"multiplaying", () => { flyte.Status.Value = new UserStatusMultiplayerGame(); }); - AddStep(@"modding", () => { flyte.Status.Value = new UserStatusModding(); }); - AddStep(@"editing", () => { flyte.Status.Value = new UserStatusEditing(null); }); - AddStep(@"choosing", () => { flyte.Status.Value = new UserStatusChoosingBeatmap(); }); - AddStep(@"offline", () => { flyte.Status.Value = new UserStatusOffline(); }); - AddStep(@"null status", () => { flyte.Status.Value = null; }); + [Test] + public void UserStatusesTests() + { + AddStep("online", () => { peppy.Status.Value = new UserStatusOnline(); }); + AddStep(@"do not disturb", () => { peppy.Status.Value = new UserStatusDoNotDisturb(); }); + AddStep(@"offline", () => { peppy.Status.Value = new UserStatusOffline(); }); + AddStep(@"null status", () => { peppy.Status.Value = null; }); + } + + [Test] + public void UserActivitiesTests() + { + AddStep("idle", () => { flyte.Activity.Value = null; }); + AddStep("spectating", () => { flyte.Activity.Value = new UserActivitySpectating(); }); + AddStep("solo", () => { flyte.Activity.Value = new UserActivitySoloGame(null, null); }); + AddStep("choosing", () => { flyte.Activity.Value = new UserActivityChoosingBeatmap(); }); + AddStep("editing", () => { flyte.Activity.Value = new UserActivityEditing(null); }); + AddStep("modding", () => { flyte.Activity.Value = new UserActivityModding(); }); } } } diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index d5061ad423..410ade33fb 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -235,7 +235,7 @@ namespace osu.Game.Users if (status is UserStatusOnline && activity != null) { statusMessage.Text = activity.Status; - statusBg.FadeColour(status.GetAppropriateColour(colours), 500, Easing.OutQuint); + statusBg.FadeColour(activity.GetAppropriateColour(colours), 500, Easing.OutQuint); return; } From a50bbf7f4208bbd5998ffdc2094bd5c58f721c2c Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 5 May 2019 21:32:23 +0200 Subject: [PATCH 118/375] Make appveyor happy. --- .../Visual/Background/TestCaseBackgroundScreenBeatmap.cs | 3 --- osu.Game.Tests/Visual/Gameplay/TestCasePause.cs | 1 - osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs | 4 ++-- osu.Game/Screens/OsuScreen.cs | 4 ++-- osu.Game/Users/UserActivity.cs | 2 -- osu.Game/Users/UserPanel.cs | 6 +++--- 6 files changed, 7 insertions(+), 13 deletions(-) diff --git a/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs index e9208d8f5b..81fab5b4b3 100644 --- a/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs @@ -275,7 +275,6 @@ namespace osu.Game.Tests.Visual.Background private class DummySongSelect : PlaySongSelect { - protected override BackgroundScreen CreateBackground() { FadeAccessibleBackground background = new FadeAccessibleBackground(Beatmap.Value); @@ -319,7 +318,6 @@ namespace osu.Game.Tests.Visual.Background private class FadeAccessibleResults : SoloResults { - public FadeAccessibleResults(ScoreInfo score) : base(score) { @@ -332,7 +330,6 @@ namespace osu.Game.Tests.Visual.Background private class TestPlayer : Player { - protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); protected override UserDimContainer CreateStoryboardContainer() diff --git a/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs b/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs index dec4830188..a52e84ed62 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestCasePause.cs @@ -12,7 +12,6 @@ using osu.Game.Rulesets; using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Scoring; using osu.Game.Screens.Play; -using osu.Game.Users; using osuTK; using osuTK.Input; diff --git a/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs b/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs index 3929fe6c50..0e958f45c6 100644 --- a/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs +++ b/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs @@ -12,8 +12,8 @@ namespace osu.Game.Tests.Visual.Online [TestFixture] public class TestCaseUserPanel : OsuTestCase { - UserPanel flyte; - UserPanel peppy; + private readonly UserPanel flyte; + private readonly UserPanel peppy; public TestCaseUserPanel() { diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 170f548676..8a6049b6fd 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -64,15 +64,15 @@ namespace osu.Game.Screens /// protected UserActivity ScreenActivity { + get => activity; set { - if (value == null) return; + if (value == activity) return; if (api == null) return; activity = value; api.LocalUser.Value.Activity.Value = activity; } - get => activity; } private UserActivity activity; diff --git a/osu.Game/Users/UserActivity.cs b/osu.Game/Users/UserActivity.cs index 1e69cc3e8e..fb896413e5 100644 --- a/osu.Game/Users/UserActivity.cs +++ b/osu.Game/Users/UserActivity.cs @@ -65,6 +65,4 @@ namespace osu.Game.Users { public override string Status => @"in Multiplayer Lobby"; } - - } diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index 410ade33fb..1f31ead1e7 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -238,10 +238,10 @@ namespace osu.Game.Users statusBg.FadeColour(activity.GetAppropriateColour(colours), 500, Easing.OutQuint); return; } - - statusMessage.Text = status.Message; - statusBg.FadeColour(status?.GetAppropriateColour(colours) ?? colours.Gray5, 500, Easing.OutQuint); } + + statusMessage.Text = status?.Message; + statusBg.FadeColour(status?.GetAppropriateColour(colours) ?? colours.Gray5, 500, Easing.OutQuint); } public MenuItem[] ContextMenuItems => new MenuItem[] From 59b8da5c77ab5e9d6304daea09621fa6a36bca53 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Mon, 6 May 2019 18:37:21 +0200 Subject: [PATCH 119/375] Move OsuScreen activity logic to setUserActivity() --- osu.Game/Screens/OsuScreen.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 8a6049b6fd..ad90e97a09 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -68,10 +68,9 @@ namespace osu.Game.Screens set { if (value == activity) return; - if (api == null) return; activity = value; - api.LocalUser.Value.Activity.Value = activity; + setUserActivity(activity); } } @@ -150,7 +149,7 @@ namespace osu.Game.Screens sampleExit?.Play(); applyArrivingDefaults(true); - ScreenActivity = ScreenActivity; + setUserActivity(activity); base.OnResuming(last); } @@ -159,6 +158,8 @@ namespace osu.Game.Screens { base.OnSuspending(next); + setUserActivity(null); + onSuspendingLogo(); } @@ -175,6 +176,8 @@ namespace osu.Game.Screens public override bool OnExiting(IScreen next) { + setUserActivity(null); + if (ValidForResume && logo != null) onExitingLogo(); @@ -187,6 +190,13 @@ namespace osu.Game.Screens return false; } + private void setUserActivity(UserActivity activity) + { + if (api == null) return; + + api.LocalUser.Value.Activity.Value = activity; + } + /// /// Fired when this screen was entered or resumed and the logo state is required to be adjusted. /// From 3ecfa9dcdb3dd513ca90b4b580bfaae69551b9ab Mon Sep 17 00:00:00 2001 From: Lucas A Date: Tue, 7 May 2019 18:26:34 +0200 Subject: [PATCH 120/375] Invert partialy activity logic introduced in latest commit --- osu.Game/Screens/OsuScreen.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index ad90e97a09..cc9aa285ff 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -158,8 +158,6 @@ namespace osu.Game.Screens { base.OnSuspending(next); - setUserActivity(null); - onSuspendingLogo(); } @@ -176,8 +174,6 @@ namespace osu.Game.Screens public override bool OnExiting(IScreen next) { - setUserActivity(null); - if (ValidForResume && logo != null) onExitingLogo(); From 34f54aa94599f9e07ba7ee7391eea2a65d9d5c40 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 13 May 2019 00:36:05 +0900 Subject: [PATCH 121/375] Resolve compile-time issues --- .../Visual/TestCaseChangelogOverlay.cs | 5 +++-- osu.Game.Tests/Visual/TestCaseLineBadge.cs | 2 +- osu.Game.Tests/Visual/TestCaseTextBadgePair.cs | 2 +- osu.Game/Graphics/StreamColour.cs | 2 +- osu.Game/Graphics/UserInterface/LineBadge.cs | 5 +++-- .../UserInterface/TooltipIconButton.cs | 9 +++++---- .../API/Requests/GetChangelogBuildRequest.cs | 5 +++-- .../API/Requests/GetChangelogChartRequest.cs | 5 +++-- .../GetChangelogLatestBuildsRequest.cs | 5 +++-- .../Online/API/Requests/GetChangelogRequest.cs | 5 +++-- .../Requests/Responses/APIChangelogBuild.cs | 5 +++-- .../Requests/Responses/APIChangelogChart.cs | 5 +++-- osu.Game/Overlays/Changelog/ChangelogBadges.cs | 5 ++++- .../Overlays/Changelog/ChangelogContent.cs | 5 +++-- .../Changelog/ChangelogContentGroup.cs | 18 ++++++++++++------ osu.Game/Overlays/Changelog/ChangelogHeader.cs | 7 +++---- .../Overlays/Changelog/Header/TextBadgePair.cs | 5 +++-- .../Changelog/Header/TextBadgePairListing.cs | 12 +++++++----- .../Changelog/Header/TextBadgePairRelease.cs | 9 +++++---- osu.Game/Overlays/Changelog/StreamBadge.cs | 8 ++++---- osu.Game/Overlays/ChangelogOverlay.cs | 14 +++++++++----- 21 files changed, 82 insertions(+), 56 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs b/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs index 2bd8cc2016..12961aeda7 100644 --- a/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs +++ b/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs @@ -1,5 +1,6 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + using NUnit.Framework; using osu.Game.Online.API.Requests.Responses; diff --git a/osu.Game.Tests/Visual/TestCaseLineBadge.cs b/osu.Game.Tests/Visual/TestCaseLineBadge.cs index d80ef0131b..06311ea7f9 100644 --- a/osu.Game.Tests/Visual/TestCaseLineBadge.cs +++ b/osu.Game.Tests/Visual/TestCaseLineBadge.cs @@ -1,11 +1,11 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics.UserInterface; +using osuTK.Graphics; namespace osu.Game.Tests.Visual { diff --git a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs b/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs index 6d2fe20f2b..df2f796407 100644 --- a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs +++ b/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs @@ -1,11 +1,11 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Overlays.Changelog.Header; +using osuTK.Graphics; namespace osu.Game.Tests.Visual { diff --git a/osu.Game/Graphics/StreamColour.cs b/osu.Game/Graphics/StreamColour.cs index 9149c29b0a..b730286608 100644 --- a/osu.Game/Graphics/StreamColour.cs +++ b/osu.Game/Graphics/StreamColour.cs @@ -1,9 +1,9 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK.Graphics; using osu.Framework.Graphics.Colour; using System.Collections.Generic; +using osuTK.Graphics; namespace osu.Game.Graphics { diff --git a/osu.Game/Graphics/UserInterface/LineBadge.cs b/osu.Game/Graphics/UserInterface/LineBadge.cs index 53f057f4b3..ef55cb03ef 100644 --- a/osu.Game/Graphics/UserInterface/LineBadge.cs +++ b/osu.Game/Graphics/UserInterface/LineBadge.cs @@ -1,5 +1,6 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/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.Graphics; using osu.Framework.Graphics.Shapes; diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs index 1233483054..af203d316a 100644 --- a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs +++ b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -11,6 +10,8 @@ using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; using System; +using osu.Framework.Graphics.Sprites; +using osuTK; namespace osu.Game.Graphics.UserInterface { @@ -43,10 +44,10 @@ namespace osu.Game.Graphics.UserInterface } } - public FontAwesome Icon + public IconUsage Icon { - get { return icon.Icon; } - set { icon.Icon = value; } + get => icon.Icon; + set => icon.Icon = value; } public TooltipIconButton() diff --git a/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs b/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs index 73d0ec6d20..52b87eda73 100644 --- a/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs @@ -1,5 +1,6 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/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.Game.Online.API.Requests.Responses; diff --git a/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs b/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs index 1e131fb91f..9d2e20c184 100644 --- a/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs @@ -1,5 +1,6 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/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.Game.Online.API.Requests.Responses; diff --git a/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs b/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs index 314a03e7f6..1d485edb4d 100644 --- a/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs @@ -1,5 +1,6 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/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.Game.Online.API.Requests.Responses; using System.Collections.Generic; diff --git a/osu.Game/Online/API/Requests/GetChangelogRequest.cs b/osu.Game/Online/API/Requests/GetChangelogRequest.cs index b43f8d8ee1..17fb1992f3 100644 --- a/osu.Game/Online/API/Requests/GetChangelogRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogRequest.cs @@ -1,5 +1,6 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/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.Game.Online.API.Requests.Responses; diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs index 86ee8b49dd..ab4bd9e613 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs @@ -1,5 +1,6 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + using Newtonsoft.Json; using System; diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs index 3509ff7de1..0d6487e01a 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs @@ -1,5 +1,6 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + using Newtonsoft.Json; using System; diff --git a/osu.Game/Overlays/Changelog/ChangelogBadges.cs b/osu.Game/Overlays/Changelog/ChangelogBadges.cs index eabe5fe258..f5a7737896 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBadges.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBadges.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -9,6 +8,7 @@ using osu.Framework.Input.Events; using osu.Game.Online.API.Requests.Responses; using System; using System.Collections.Generic; +using osuTK.Graphics; namespace osu.Game.Overlays.Changelog { @@ -58,6 +58,7 @@ namespace osu.Game.Overlays.Changelog public void SelectNone() { selectedStreamId = -1; + if (badgesContainer != null) { foreach (StreamBadge streamBadge in badgesContainer) @@ -109,6 +110,7 @@ namespace osu.Game.Overlays.Changelog else streamBadge.Deactivate(); } + return base.OnHover(e); } @@ -121,6 +123,7 @@ namespace osu.Game.Overlays.Changelog else if (streamBadge.LatestBuild.UpdateStream.Id == selectedStreamId) streamBadge.DisableDim(); } + base.OnHoverLost(e); } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index fadfb9048f..aa95b54d0c 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -1,13 +1,13 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Online.API; using osu.Game.Online.API.Requests.Responses; using System; +using osuTK.Graphics; namespace osu.Game.Overlays.Changelog { @@ -25,7 +25,7 @@ namespace osu.Game.Overlays.Changelog RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; Direction = FillDirection.Vertical; - Padding = new MarginPadding{ Bottom = 100 }; + Padding = new MarginPadding { Bottom = 100 }; } public void ShowListing(APIChangelogBuild[] changelog) @@ -47,6 +47,7 @@ namespace osu.Game.Overlays.Changelog Margin = new MarginPadding { Top = 30 }, }); } + changelogContentGroup = new ChangelogContentGroup(build, true); changelogContentGroup.BuildSelected += OnBuildSelected; changelogContentGroup.GenerateText(build.ChangelogEntries); diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 2dc8fd2bf7..6f12ff973a 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -1,8 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; -using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -12,12 +10,15 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Online.API.Requests.Responses; using System; using System.Collections.Generic; +using osuTK; +using osuTK.Graphics; namespace osu.Game.Overlays.Changelog { public class ChangelogContentGroup : FillFlowContainer { private readonly TooltipIconButton chevronPrevious, chevronNext; + private readonly SortedDictionary> categories = new SortedDictionary>(); @@ -47,7 +48,7 @@ namespace osu.Game.Overlays.Changelog chevronPrevious = new TooltipIconButton { IsEnabled = false, - Icon = FontAwesome.fa_chevron_left, + Icon = FontAwesome.Solid.ChevronLeft, Size = new Vector2(24), Action = () => { @@ -84,7 +85,7 @@ namespace osu.Game.Overlays.Changelog chevronNext = new TooltipIconButton { IsEnabled = false, - Icon = FontAwesome.fa_chevron_right, + Icon = FontAwesome.Solid.ChevronRight, Size = new Vector2(24), Action = () => { @@ -181,7 +182,8 @@ namespace osu.Game.Overlays.Changelog { clickableBuildText.Action = null; clickableBuildText.FadeTo(0.5f, 500); - Scheduler.AddDelayed(() => { + Scheduler.AddDelayed(() => + { clickableBuildText.Action = () => OnBuildSelected(build); clickableBuildText.FadeIn(500); }, 2000); @@ -195,6 +197,7 @@ namespace osu.Game.Overlays.Changelog chevronPrevious.TooltipText = previousVersion; chevronPrevious.IsEnabled = true; } + if (!string.IsNullOrEmpty(nextVersion)) { chevronNext.TooltipText = nextVersion; @@ -227,6 +230,7 @@ namespace osu.Game.Overlays.Changelog Font = @"Exo2.0-Bold", Margin = new MarginPadding { Top = 35, Bottom = 15 }, }); + foreach (ChangelogEntry entry in category.Value) { LinkFlowContainer title = new LinkFlowContainer @@ -236,12 +240,13 @@ namespace osu.Game.Overlays.Changelog AutoSizeAxes = Axes.Y, Margin = new MarginPadding { Vertical = 5 }, }; - title.AddIcon(FontAwesome.fa_check, t => + title.AddIcon(FontAwesome.Solid.Check, t => { t.TextSize = 12; t.Padding = new MarginPadding { Left = -17, Right = 5 }; }); title.AddText(entry.Title, t => { t.TextSize = 18; }); + if (!string.IsNullOrEmpty(entry.Repository)) { title.AddText(" (", t => t.TextSize = 18); @@ -250,6 +255,7 @@ namespace osu.Game.Overlays.Changelog null, t => { t.TextSize = 18; }); title.AddText(")", t => t.TextSize = 18); } + title.AddText(" by ", t => t.TextSize = 14); if (entry.GithubUser.GithubUrl != null) title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 035574bd1c..c23951bf23 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -1,18 +1,17 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; -using OpenTK.Graphics; using osu.Framework.Allocation; 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.Overlays.Changelog.Header; using System; +using osuTK; +using osuTK.Graphics; namespace osu.Game.Overlays.Changelog { @@ -141,7 +140,7 @@ namespace osu.Game.Overlays.Changelog Origin = Anchor.Centre, Size = new Vector2(7), Colour = Purple, - Icon = FontAwesome.fa_chevron_right, + Icon = FontAwesome.Solid.ChevronRight, Alpha = 0, X = -200, }, diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs index 387b7d4405..46a46913fd 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -1,5 +1,6 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/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.Allocation; using osu.Framework.Audio; diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs index ab4165b30b..b51948e849 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs @@ -1,10 +1,10 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. -using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Input.Events; +using osuTK.Graphics; namespace osu.Game.Overlays.Changelog.Header { @@ -12,7 +12,8 @@ namespace osu.Game.Overlays.Changelog.Header { private readonly ColourInfo badgeColour; - public TextBadgePairListing(ColourInfo badgeColour) : base(badgeColour, "Listing", false) + public TextBadgePairListing(ColourInfo badgeColour) + : base(badgeColour, "Listing", false) { IsActivated = true; this.badgeColour = badgeColour; @@ -27,13 +28,14 @@ namespace osu.Game.Overlays.Changelog.Header // this doesn't work without the scheduler // (because the text isn't yet fully drawn when it's loaded?) - Text.OnLoadComplete = d => Scheduler.Add(UpdateBadgeWidth); + Text.OnLoadComplete += d => Scheduler.Add(UpdateBadgeWidth); } public override void Activate() { if (IsActivated) return; + IsActivated = true; LineBadge.Uncollapse(); Text.Font = "Exo2.0-Bold"; diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs index 97ce799509..f677bf62fe 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs @@ -1,5 +1,5 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/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.Graphics.Colour; @@ -7,10 +7,10 @@ namespace osu.Game.Overlays.Changelog.Header { public class TextBadgePairRelease : TextBadgePair { - private TextBadgePairListing listingBadge; private const float transition_duration = 125; - public TextBadgePairRelease(ColourInfo badgeColour, string displayText) : base(badgeColour, displayText) + public TextBadgePairRelease(ColourInfo badgeColour, string displayText) + : base(badgeColour, displayText) { Text.Font = "Exo2.0-Bold"; Text.Y = 20; @@ -28,6 +28,7 @@ namespace osu.Game.Overlays.Changelog.Header } else ShowText(transition_duration, displayText); + IsActivated = true; } diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index dcae8dc04f..fc143c46d2 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -13,6 +12,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API.Requests.Responses; using System; +using osuTK.Graphics; namespace osu.Game.Overlays.Changelog { @@ -66,9 +66,7 @@ namespace osu.Game.Overlays.Changelog }, new SpriteText { - Text = LatestBuild.Users > 0 ? - $"{LatestBuild.Users:N0} users online" : - null, + Text = LatestBuild.Users > 0 ? $"{LatestBuild.Users:N0} users online" : null, TextSize = 12, // web: 10, Font = @"Exo2.0-Regular", Colour = new Color4(203, 164, 218, 255), @@ -100,6 +98,7 @@ namespace osu.Game.Overlays.Changelog { isActivated = false; DisableDim(); + if (!IsHovered) { this.FadeTo(0.5f, transition_duration); @@ -132,6 +131,7 @@ namespace osu.Game.Overlays.Changelog } else EnableDim(); + base.OnHoverLost(e); } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 302a9b351f..d3db26889f 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -1,12 +1,9 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; -using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; -using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -18,13 +15,19 @@ using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.Changelog; using System; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics.Effects; +using osuTK; +using osuTK.Graphics; namespace osu.Game.Overlays { public class ChangelogOverlay : WaveOverlayContainer { private readonly ChangelogHeader header; + private readonly ChangelogBadges badges; + //private readonly ChangelogChart chart; private readonly ChangelogContent listing; private readonly ChangelogContent content; @@ -35,7 +38,7 @@ namespace osu.Game.Overlays private SampleChannel sampleBack; - private APIAccess api; + private IAPIProvider api; private bool isAtListing; private float savedScrollPosition; @@ -99,7 +102,7 @@ namespace osu.Game.Overlays } [BackgroundDependencyLoader] - private void load(APIAccess api, AudioManager audio) + private void load(IAPIProvider api, AudioManager audio) { this.api = api; sampleBack = audio.Sample.Get(@"UI/generic-select-soft"); // @"UI/screen-back" feels non-fitting here @@ -146,6 +149,7 @@ namespace osu.Game.Overlays ShowListing(); sampleBack?.Play(); } + return true; } From 55663b3576c7e18c4c5beb030225f21e8b2a2f8c Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 12 May 2019 17:38:02 +0200 Subject: [PATCH 122/375] Nest all UserActivities into UserActivity --- osu.Game/Screens/Edit/Editor.cs | 2 +- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Select/PlaySongSelect.cs | 2 +- osu.Game/Users/UserActivity.cs | 87 ++++++++++++----------- 4 files changed, 47 insertions(+), 46 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 9384587bbb..a4cb659183 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -48,7 +48,7 @@ namespace osu.Game.Screens.Edit private DependencyContainer dependencies; private GameHost host; - protected override UserActivity InitialScreenActivity => new UserActivityEditing(Beatmap.Value.BeatmapInfo); + protected override UserActivity InitialScreenActivity => new UserActivity.UserActivityEditing(Beatmap.Value.BeatmapInfo); protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 8f6ed43206..6a548cb6e4 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -35,7 +35,7 @@ namespace osu.Game.Screens.Play { protected override bool AllowBackButton => false; // handled by HoldForMenuButton - protected override UserActivity InitialScreenActivity => new UserActivitySoloGame(Beatmap.Value.BeatmapInfo, Ruleset.Value); + protected override UserActivity InitialScreenActivity => new UserActivity.UserActivitySoloGame(Beatmap.Value.BeatmapInfo, Ruleset.Value); public override float BackgroundParallaxAmount => 0.1f; diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 608cd52bce..aba3343d69 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -19,7 +19,7 @@ namespace osu.Game.Screens.Select public override bool AllowExternalScreenChange => true; - protected override UserActivity InitialScreenActivity => new UserActivityChoosingBeatmap(); + protected override UserActivity InitialScreenActivity => new UserActivity.UserActivityChoosingBeatmap(); [BackgroundDependencyLoader] private void load(OsuColour colours) diff --git a/osu.Game/Users/UserActivity.cs b/osu.Game/Users/UserActivity.cs index fb896413e5..3e59b2a219 100644 --- a/osu.Game/Users/UserActivity.cs +++ b/osu.Game/Users/UserActivity.cs @@ -11,58 +11,59 @@ namespace osu.Game.Users { public abstract string Status { get; } public virtual Color4 GetAppropriateColour(OsuColour colours) => colours.GreenDarker; - } - public class UserActivityModding : UserActivity - { - public override string Status => "Modding a map"; - public override Color4 GetAppropriateColour(OsuColour colours) => colours.PurpleDark; - } - - public class UserActivityChoosingBeatmap : UserActivity - { - public override string Status => "Choosing a beatmap"; - } - - public class UserActivityMultiplayerGame : UserActivity - { - public override string Status => "Multiplaying"; - } - - public class UserActivityEditing : UserActivity - { - public UserActivityEditing(BeatmapInfo info) + public class UserActivityModding : UserActivity { - Beatmap = info; + public override string Status => "Modding a map"; + public override Color4 GetAppropriateColour(OsuColour colours) => colours.PurpleDark; } - public override string Status => @"Editing a beatmap"; - - public BeatmapInfo Beatmap { get; } - } - - public class UserActivitySoloGame : UserActivity - { - public UserActivitySoloGame(BeatmapInfo info, Rulesets.RulesetInfo ruleset) + public class UserActivityChoosingBeatmap : UserActivity { - Beatmap = info; - Ruleset = ruleset; + public override string Status => "Choosing a beatmap"; } - public override string Status => @"Solo Game"; + public class UserActivityMultiplayerGame : UserActivity + { + public override string Status => "Multiplaying"; + } - public BeatmapInfo Beatmap { get; } + public class UserActivityEditing : UserActivity + { + public UserActivityEditing(BeatmapInfo info) + { + Beatmap = info; + } - public Rulesets.RulesetInfo Ruleset { get; } + public override string Status => @"Editing a beatmap"; + + public BeatmapInfo Beatmap { get; } + } + + public class UserActivitySoloGame : UserActivity + { + public UserActivitySoloGame(BeatmapInfo info, Rulesets.RulesetInfo ruleset) + { + Beatmap = info; + Ruleset = ruleset; + } + + public override string Status => @"Solo Game"; + + public BeatmapInfo Beatmap { get; } + + public Rulesets.RulesetInfo Ruleset { get; } + } + + public class UserActivitySpectating : UserActivity + { + public override string Status => @"Spectating a game"; + } + + public class UserActivityInLobby : UserActivity + { + public override string Status => @"in Multiplayer Lobby"; + } } - public class UserActivitySpectating : UserActivity - { - public override string Status => @"Spectating a game"; - } - - public class UserActivityInLobby : UserActivity - { - public override string Status => @"in Multiplayer Lobby"; - } } From 2f663622ccaaba1945ea424a0fb19d64ae1c4e33 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 12 May 2019 17:40:18 +0200 Subject: [PATCH 123/375] Fix CI inspections --- osu.Game/Users/UserActivity.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Users/UserActivity.cs b/osu.Game/Users/UserActivity.cs index 3e59b2a219..fe72f116ee 100644 --- a/osu.Game/Users/UserActivity.cs +++ b/osu.Game/Users/UserActivity.cs @@ -65,5 +65,4 @@ namespace osu.Game.Users public override string Status => @"in Multiplayer Lobby"; } } - } From 31b72f168d4851a59b64afb640be3e5e112fc639 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 13 May 2019 00:46:22 +0900 Subject: [PATCH 124/375] Fix deprecated calls and code styling (partly) --- .../Visual/TestCaseChangelogOverlay.cs | 11 +++-- .../Visual/TestCaseTextBadgePair.cs | 1 - osu.Game/Graphics/StreamColour.cs | 1 + osu.Game/Graphics/UserInterface/LineBadge.cs | 5 +- .../UserInterface/TooltipIconButton.cs | 3 +- .../API/Requests/GetChangelogBuildRequest.cs | 1 - .../API/Requests/GetChangelogChartRequest.cs | 12 +++-- .../GetChangelogLatestBuildsRequest.cs | 1 - .../API/Requests/GetChangelogRequest.cs | 1 - .../Requests/Responses/APIChangelogBuild.cs | 1 - .../Requests/Responses/APIChangelogChart.cs | 1 - .../Overlays/Changelog/ChangelogContent.cs | 2 - .../Changelog/ChangelogContentGroup.cs | 48 +++++++++---------- .../Overlays/Changelog/ChangelogHeader.cs | 7 ++- .../Changelog/Header/TextBadgePair.cs | 6 ++- osu.Game/Overlays/Changelog/StreamBadge.cs | 9 ++-- osu.Game/Overlays/ChangelogOverlay.cs | 8 +++- 17 files changed, 62 insertions(+), 56 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs b/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs index 12961aeda7..063555cf76 100644 --- a/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs +++ b/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs @@ -1,7 +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 NUnit.Framework; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays; @@ -20,7 +19,9 @@ namespace osu.Game.Tests.Visual Add(changelog = new ChangelogOverlay()); AddStep(@"Show", changelog.Show); AddStep(@"Hide", changelog.Hide); - AddWaitStep(3); + + AddWaitStep("wait for hide", 3); + AddStep(@"Show with Lazer 2018.712.0", () => { changelog.FetchAndShowBuild(new APIChangelogBuild @@ -30,9 +31,11 @@ namespace osu.Game.Tests.Visual }); changelog.Show(); }); - AddWaitStep(3); + + AddWaitStep("wait for show", 3); AddStep(@"Hide", changelog.Hide); - AddWaitStep(3); + AddWaitStep("wait for hide", 3); + AddStep(@"Show with listing", () => { changelog.ShowListing(); diff --git a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs b/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs index df2f796407..bfd77ee3c7 100644 --- a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs +++ b/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs @@ -42,7 +42,6 @@ namespace osu.Game.Tests.Visual AddStep(@"Hide text", () => textBadgePair.HideText(200)); AddStep(@"Show text", () => textBadgePair.ShowText(200)); AddStep(@"Different text", () => textBadgePair.ChangeText(200, "This one's a little bit wider")); - AddWaitStep(1); AddStep(@"Different text", () => textBadgePair.ChangeText(200, "Ok?..")); } } diff --git a/osu.Game/Graphics/StreamColour.cs b/osu.Game/Graphics/StreamColour.cs index b730286608..c4df3b64a3 100644 --- a/osu.Game/Graphics/StreamColour.cs +++ b/osu.Game/Graphics/StreamColour.cs @@ -36,6 +36,7 @@ namespace osu.Game.Graphics if (!string.IsNullOrEmpty(name)) if (colours.TryGetValue(name, out ColourInfo colour)) return colour; + return new Color4(0, 0, 0, 255); } } diff --git a/osu.Game/Graphics/UserInterface/LineBadge.cs b/osu.Game/Graphics/UserInterface/LineBadge.cs index ef55cb03ef..fc87acab0a 100644 --- a/osu.Game/Graphics/UserInterface/LineBadge.cs +++ b/osu.Game/Graphics/UserInterface/LineBadge.cs @@ -1,7 +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.Graphics; using osu.Framework.Graphics.Shapes; @@ -25,11 +24,12 @@ namespace osu.Game.Graphics.UserInterface /// public bool IsHorizontal { - get { return isHorizontal; } + get => isHorizontal; set { if (value == isHorizontal) return; + if (IsLoaded) { FinishTransforms(); @@ -41,6 +41,7 @@ namespace osu.Game.Graphics.UserInterface } else RelativeSizeAxes = value ? Axes.X : Axes.Y; + isHorizontal = value; } } diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs index af203d316a..ce546c5358 100644 --- a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs +++ b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs @@ -36,7 +36,7 @@ namespace osu.Game.Graphics.UserInterface /// public bool IsEnabled { - get { return isEnabled; } + get => isEnabled; set { isEnabled = value; @@ -77,6 +77,7 @@ namespace osu.Game.Graphics.UserInterface sampleClick?.Play(); Action?.Invoke(); } + return base.OnClick(e); } diff --git a/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs b/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs index 52b87eda73..6c32abee42 100644 --- a/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs @@ -1,7 +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.Game.Online.API.Requests.Responses; namespace osu.Game.Online.API.Requests diff --git a/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs b/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs index 9d2e20c184..cf5dc5a65a 100644 --- a/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs @@ -1,7 +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.Game.Online.API.Requests.Responses; namespace osu.Game.Online.API.Requests @@ -10,12 +9,19 @@ namespace osu.Game.Online.API.Requests { private readonly string updateStream; - public GetChangelogChartRequest() => updateStream = null; + public GetChangelogChartRequest() + { + updateStream = null; + } - public GetChangelogChartRequest(string updateStreamName) => updateStream = updateStreamName; + public GetChangelogChartRequest(string updateStreamName) + { + updateStream = updateStreamName; + } protected override string Target => $@"changelog/{(!string.IsNullOrEmpty(updateStream) ? updateStream + "/" : "")}chart-config"; + protected override string Uri => $@"https://houtarouoreki.github.io/fake-api/{Target}"; // for testing } } diff --git a/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs b/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs index 1d485edb4d..087d4bb49c 100644 --- a/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs @@ -1,7 +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.Game.Online.API.Requests.Responses; using System.Collections.Generic; diff --git a/osu.Game/Online/API/Requests/GetChangelogRequest.cs b/osu.Game/Online/API/Requests/GetChangelogRequest.cs index 17fb1992f3..483182e720 100644 --- a/osu.Game/Online/API/Requests/GetChangelogRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogRequest.cs @@ -1,7 +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.Game.Online.API.Requests.Responses; namespace osu.Game.Online.API.Requests diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs index ab4bd9e613..3ae992c22d 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs @@ -1,7 +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 Newtonsoft.Json; using System; using System.Collections.Generic; diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs index 0d6487e01a..598928d309 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs @@ -1,7 +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 Newtonsoft.Json; using System; using System.Collections.Generic; diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index aa95b54d0c..1f1bfae40a 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -4,7 +4,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Game.Online.API; using osu.Game.Online.API.Requests.Responses; using System; using osuTK.Graphics; @@ -13,7 +12,6 @@ namespace osu.Game.Overlays.Changelog { public class ChangelogContent : FillFlowContainer { - private APIAccess api; private ChangelogContentGroup changelogContentGroup; public delegate void BuildSelectedEventHandler(APIChangelogBuild build, EventArgs args); diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 6f12ff973a..837ce24522 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -65,19 +65,17 @@ namespace osu.Game.Overlays.Changelog new SpriteText { Text = build.UpdateStream.DisplayName, - TextSize = 28, // web: 24, - Font = @"Exo2.0-Medium", + Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 28), // web: 24, }, new SpriteText { Text = " ", - TextSize = 28, + Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 28), // web: 24, }, new SpriteText { Text = build.DisplayVersion, - TextSize = 28, // web: 24, - Font = @"Exo2.0-Light", + Font = OsuFont.GetFont(weight: FontWeight.Light, size: 28), // web: 24, Colour = StreamColour.FromStreamName(build.UpdateStream.Name), }, } @@ -100,9 +98,8 @@ namespace osu.Game.Overlays.Changelog // do we need .ToUniversalTime() here? // also, this should be a temporary solution to weekdays in >localized< date strings Text = build.CreatedAt.Date.ToLongDateString().Replace(build.CreatedAt.ToString("dddd") + ", ", ""), - TextSize = 17, // web: 14, + Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 17), // web: 14, Colour = OsuColour.FromHex(@"FD5"), - Font = @"Exo2.0-Medium", Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Margin = new MarginPadding { Top = 5 }, @@ -130,9 +127,8 @@ namespace osu.Game.Overlays.Changelog // do we need .ToUniversalTime() here? // also, this should be a temporary solution to weekdays in >localized< date strings Text = build.CreatedAt.Date.ToLongDateString().Replace(build.CreatedAt.ToString("dddd") + ", ", ""), - TextSize = 28, // web: 24, + Font = OsuFont.GetFont(weight: FontWeight.Light, size: 28), // web: 24, Colour = OsuColour.FromHex(@"FD5"), - Font = @"Exo2.0-Light", Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Margin = new MarginPadding { Top = 20 }, @@ -155,14 +151,12 @@ namespace osu.Game.Overlays.Changelog new SpriteText { Text = build.UpdateStream.DisplayName, - TextSize = 20, // web: 18, - Font = @"Exo2.0-Medium", + Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 20), // web: 19, }, new SpriteText { Text = build.DisplayVersion, - TextSize = 20, // web: 18, - Font = @"Exo2.0-Light", + Font = OsuFont.GetFont(weight: FontWeight.Light, size: 20), // web: 19, Colour = StreamColour.FromStreamName(build.UpdateStream.Name), }, }, @@ -226,8 +220,7 @@ namespace osu.Game.Overlays.Changelog ChangelogEntries.Add(new SpriteText { Text = category.Key, - TextSize = 24, // web: 18, - Font = @"Exo2.0-Bold", + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 24), // web: 24, Margin = new MarginPadding { Top = 35, Bottom = 15 }, }); @@ -240,40 +233,47 @@ namespace osu.Game.Overlays.Changelog AutoSizeAxes = Axes.Y, Margin = new MarginPadding { Vertical = 5 }, }; + title.AddIcon(FontAwesome.Solid.Check, t => { - t.TextSize = 12; + t.Font = OsuFont.GetFont(size: 12); t.Padding = new MarginPadding { Left = -17, Right = 5 }; }); - title.AddText(entry.Title, t => { t.TextSize = 18; }); + + title.AddText(entry.Title, t => { t.Font = OsuFont.GetFont(size: 18); }); if (!string.IsNullOrEmpty(entry.Repository)) { - title.AddText(" (", t => t.TextSize = 18); + title.AddText(" (", t => t.Font = OsuFont.GetFont(size: 18)); title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}", entry.GithubUrl, Online.Chat.LinkAction.External, null, - null, t => { t.TextSize = 18; }); - title.AddText(")", t => t.TextSize = 18); + null, t => { t.Font = OsuFont.GetFont(size: 18); }); + title.AddText(")", t => t.Font = OsuFont.GetFont(size: 18)); } - title.AddText(" by ", t => t.TextSize = 14); + title.AddText(" by ", t => t.Font = OsuFont.GetFont(size: 14)); + if (entry.GithubUser.GithubUrl != null) title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, Online.Chat.LinkAction.External, null, null, - t => t.TextSize = 14); + t => t.Font = OsuFont.GetFont(size: 14)); else - title.AddText(entry.GithubUser.DisplayName, t => t.TextSize = 14); //web: 12; + title.AddText(entry.GithubUser.DisplayName, t => t.Font = OsuFont.GetFont(size: 14)); //web: 12; + ChangelogEntries.Add(title); + TextFlowContainer messageContainer = new TextFlowContainer { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, }; + messageContainer.AddText($"{entry.MessageHtml?.Replace("

", "").Replace("

", "")}\n", t => { - t.TextSize = 14; // web: 12, + t.Font = OsuFont.GetFont(size: 14); // web: 12, t.Colour = new Color4(235, 184, 254, 255); }); + ChangelogEntries.Add(messageContainer); } } diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index c23951bf23..b14e065b1e 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -10,6 +10,7 @@ using osu.Framework.Graphics.Textures; using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Changelog.Header; using System; +using osu.Game.Graphics; using osuTK; using osuTK.Graphics; @@ -97,14 +98,12 @@ namespace osu.Game.Overlays.Changelog new OsuSpriteText { Text = "Changelog ", - Font = @"Exo2.0-Light", - TextSize = 38, // web: 30 + Font = OsuFont.GetFont(weight: FontWeight.Light, size: 38), // web: 30, }, titleStream = new OsuSpriteText { Text = "Listing", - TextSize = 38, // web: 30 - Font = @"Exo2.0-Light", + Font = OsuFont.GetFont(weight: FontWeight.Light, size: 38), // web: 30, Colour = Purple, }, } diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs index 46a46913fd..e044d4c342 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs @@ -1,7 +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.Audio; using osu.Framework.Audio.Sample; @@ -12,6 +11,7 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; using osu.Game.Graphics.UserInterface; using System; +using osu.Game.Graphics; namespace osu.Game.Overlays.Changelog.Header { @@ -36,7 +36,7 @@ namespace osu.Game.Overlays.Changelog.Header { Text = new SpriteText { - TextSize = 21, // web: 16, + Font = OsuFont.GetFont(size: 21), // web: 16, Text = displayText, Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -56,6 +56,8 @@ namespace osu.Game.Overlays.Changelog.Header /// /// The duration of popping in and popping out not combined. /// Full change takes double this time. + /// + /// public void ChangeText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) { LineBadge.Collapse(); diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index fc143c46d2..c9ed04168c 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -54,21 +54,18 @@ namespace osu.Game.Overlays.Changelog new SpriteText { Text = LatestBuild.UpdateStream.DisplayName, - Font = @"Exo2.0-Bold", - TextSize = 14, // web: 12, + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14), // web: 12, Margin = new MarginPadding { Top = 6 }, }, new SpriteText { Text = LatestBuild.DisplayVersion, - Font = @"Exo2.0-Light", - TextSize = 20, // web: 16, + Font = OsuFont.GetFont(weight: FontWeight.Light, size: 20), // web: 16, }, new SpriteText { Text = LatestBuild.Users > 0 ? $"{LatestBuild.Users:N0} users online" : null, - TextSize = 12, // web: 10, - Font = @"Exo2.0-Regular", + Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 12), // web: 10, Colour = new Color4(203, 164, 218, 255), }, } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index d3db26889f..8f77862c99 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -161,8 +161,10 @@ namespace osu.Game.Overlays private void fetchListing() { header.ShowListing(); + if (isAtListing) return; + isAtListing = true; var req = new GetChangelogRequest(); badges.SelectNone(); @@ -173,8 +175,10 @@ namespace osu.Game.Overlays public void ShowListing() { header.ShowListing(); + if (isAtListing) return; + isAtListing = true; content.Hide(); listing.Show(); @@ -187,8 +191,8 @@ namespace osu.Game.Overlays /// /// Fetches and shows a specific build from a specific update stream. /// - /// Must contain at least and - /// . If and + /// Must contain at least and + /// . If and /// are specified, the header will instantly display them. /// Whether to update badges. Should be set to false in case /// the function is called by selecting a badge, to avoid an infinite loop. From 1fe4d20d9ba3794e9894414ee6c62e91753e7aba Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 12 May 2019 17:47:02 +0200 Subject: [PATCH 125/375] Fix references to UserActivities in Tests --- osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs b/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs index 0e958f45c6..b800c361cf 100644 --- a/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs +++ b/osu.Game.Tests/Visual/Online/TestCaseUserPanel.cs @@ -61,11 +61,11 @@ namespace osu.Game.Tests.Visual.Online public void UserActivitiesTests() { AddStep("idle", () => { flyte.Activity.Value = null; }); - AddStep("spectating", () => { flyte.Activity.Value = new UserActivitySpectating(); }); - AddStep("solo", () => { flyte.Activity.Value = new UserActivitySoloGame(null, null); }); - AddStep("choosing", () => { flyte.Activity.Value = new UserActivityChoosingBeatmap(); }); - AddStep("editing", () => { flyte.Activity.Value = new UserActivityEditing(null); }); - AddStep("modding", () => { flyte.Activity.Value = new UserActivityModding(); }); + AddStep("spectating", () => { flyte.Activity.Value = new UserActivity.UserActivitySpectating(); }); + AddStep("solo", () => { flyte.Activity.Value = new UserActivity.UserActivitySoloGame(null, null); }); + AddStep("choosing", () => { flyte.Activity.Value = new UserActivity.UserActivityChoosingBeatmap(); }); + AddStep("editing", () => { flyte.Activity.Value = new UserActivity.UserActivityEditing(null); }); + AddStep("modding", () => { flyte.Activity.Value = new UserActivity.UserActivityModding(); }); } } } From 219c590b8ab11b1a3fd4c2b81c9aedb8657ff121 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 13 May 2019 16:24:32 +0900 Subject: [PATCH 126/375] Initial pass to make work with real API --- .../API/Requests/GetChangelogBuildRequest.cs | 1 - .../API/Requests/GetChangelogChartRequest.cs | 2 -- .../GetChangelogLatestBuildsRequest.cs | 7 +------ .../Online/API/Requests/GetChangelogRequest.cs | 3 +-- .../Requests/Responses/APIChangelogBuild.cs | 9 ++++++--- .../Requests/Responses/APIChangelogIndex.cs | 14 ++++++++++++++ osu.Game/Overlays/Changelog/ChangelogBadges.cs | 16 ++++++++-------- .../Overlays/Changelog/ChangelogContent.cs | 3 ++- osu.Game/Overlays/Changelog/StreamBadge.cs | 18 ++++++++++-------- osu.Game/Overlays/ChangelogOverlay.cs | 4 ++-- 10 files changed, 44 insertions(+), 33 deletions(-) create mode 100644 osu.Game/Online/API/Requests/Responses/APIChangelogIndex.cs diff --git a/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs b/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs index 6c32abee42..baa15c70c4 100644 --- a/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogBuildRequest.cs @@ -17,6 +17,5 @@ namespace osu.Game.Online.API.Requests } protected override string Target => $@"changelog/{name}/{version}"; - protected override string Uri => $@"https://houtarouoreki.github.io/fake-api/{Target}"; // for testing } } diff --git a/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs b/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs index cf5dc5a65a..66e7d198c2 100644 --- a/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs @@ -21,7 +21,5 @@ namespace osu.Game.Online.API.Requests protected override string Target => $@"changelog/{(!string.IsNullOrEmpty(updateStream) ? updateStream + "/" : "")}chart-config"; - - protected override string Uri => $@"https://houtarouoreki.github.io/fake-api/{Target}"; // for testing } } diff --git a/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs b/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs index 087d4bb49c..dd50701e39 100644 --- a/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs @@ -1,14 +1,9 @@ // 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.Online.API.Requests.Responses; -using System.Collections.Generic; - namespace osu.Game.Online.API.Requests { - public class GetChangelogLatestBuildsRequest : APIRequest> + public class GetChangelogLatestBuildsRequest : GetChangelogRequest { - protected override string Target => @"changelog/latest-builds"; - protected override string Uri => $@"https://houtarouoreki.github.io/fake-api/{Target}"; // for testing } } diff --git a/osu.Game/Online/API/Requests/GetChangelogRequest.cs b/osu.Game/Online/API/Requests/GetChangelogRequest.cs index 483182e720..97799ff66a 100644 --- a/osu.Game/Online/API/Requests/GetChangelogRequest.cs +++ b/osu.Game/Online/API/Requests/GetChangelogRequest.cs @@ -5,9 +5,8 @@ using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Online.API.Requests { - public class GetChangelogRequest : APIRequest + public class GetChangelogRequest : APIRequest { protected override string Target => @"changelog"; - protected override string Uri => $@"https://houtarouoreki.github.io/fake-api/{Target}/index"; // for testing } } diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs index 3ae992c22d..64b62e1f73 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs @@ -21,9 +21,6 @@ namespace osu.Game.Online.API.Requests.Responses [JsonProperty("users")] public long Users { get; set; } - [JsonProperty("is_featured")] - public bool IsFeatured { get; set; } - [JsonProperty("created_at")] public DateTimeOffset CreatedAt { get; set; } @@ -114,7 +111,13 @@ namespace osu.Game.Online.API.Requests.Responses [JsonProperty("name")] public string Name { get; set; } + [JsonProperty("is_featured")] + public bool IsFeatured { get; set; } + [JsonProperty("display_name")] public string DisplayName { get; set; } + + [JsonProperty("latest_build")] + public APIChangelogBuild LatestBuild { get; set; } } } diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogIndex.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogIndex.cs new file mode 100644 index 0000000000..957694b887 --- /dev/null +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogIndex.cs @@ -0,0 +1,14 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; + +namespace osu.Game.Online.API.Requests.Responses +{ + public class APIChangelogIndex + { + public List Builds; + + public List Streams; + } +} diff --git a/osu.Game/Overlays/Changelog/ChangelogBadges.cs b/osu.Game/Overlays/Changelog/ChangelogBadges.cs index f5a7737896..cf14ddbb01 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBadges.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBadges.cs @@ -45,9 +45,9 @@ namespace osu.Game.Overlays.Changelog }; } - public void Populate(List latestBuilds) + public void Populate(List streams) { - foreach (APIChangelogBuild updateStream in latestBuilds) + foreach (UpdateStream updateStream in streams) { var streamBadge = new StreamBadge(updateStream); streamBadge.Selected += onBadgeSelected; @@ -75,9 +75,9 @@ namespace osu.Game.Overlays.Changelog { foreach (StreamBadge streamBadge in badgesContainer) { - if (streamBadge.LatestBuild.UpdateStream.Name == updateStream) + if (streamBadge.Stream.Name == updateStream) { - selectedStreamId = streamBadge.LatestBuild.UpdateStream.Id; + selectedStreamId = streamBadge.Stream.Id; streamBadge.Activate(); } else @@ -87,13 +87,13 @@ namespace osu.Game.Overlays.Changelog private void onBadgeSelected(StreamBadge source, EventArgs args) { - selectedStreamId = source.LatestBuild.UpdateStream.Id; + selectedStreamId = source.Stream.Id; OnSelected(source); } protected virtual void OnSelected(StreamBadge source) { - Selected?.Invoke(source.LatestBuild, EventArgs.Empty); + Selected?.Invoke(source.Stream.LatestBuild, EventArgs.Empty); } protected override bool OnHover(HoverEvent e) @@ -102,7 +102,7 @@ namespace osu.Game.Overlays.Changelog { if (selectedStreamId >= 0) { - if (selectedStreamId != streamBadge.LatestBuild.UpdateStream.Id) + if (selectedStreamId != streamBadge.Stream.Id) streamBadge.Deactivate(); else streamBadge.EnableDim(); @@ -120,7 +120,7 @@ namespace osu.Game.Overlays.Changelog { if (selectedStreamId < 0) streamBadge.Activate(); - else if (streamBadge.LatestBuild.UpdateStream.Id == selectedStreamId) + else if (streamBadge.Stream.Id == selectedStreamId) streamBadge.DisableDim(); } diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 1f1bfae40a..e71769595f 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -6,6 +6,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Online.API.Requests.Responses; using System; +using System.Collections.Generic; using osuTK.Graphics; namespace osu.Game.Overlays.Changelog @@ -26,7 +27,7 @@ namespace osu.Game.Overlays.Changelog Padding = new MarginPadding { Bottom = 100 }; } - public void ShowListing(APIChangelogBuild[] changelog) + public void ShowListing(List changelog) { DateTime currentDate = new DateTime(); Clear(); diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index c9ed04168c..424c344e91 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -32,14 +32,16 @@ namespace osu.Game.Overlays.Changelog private SampleChannel sampleClick; private SampleChannel sampleHover; - public readonly APIChangelogBuild LatestBuild; + public readonly UpdateStream Stream; + private readonly FillFlowContainer text; - public StreamBadge(APIChangelogBuild latestBuild) + public StreamBadge(UpdateStream stream) { - LatestBuild = latestBuild; + Stream = stream; + Height = badge_height; - Width = LatestBuild.IsFeatured ? badge_width * 2 : badge_width; + Width = stream.IsFeatured ? badge_width * 2 : badge_width; Padding = new MarginPadding(5); isActivated = true; Children = new Drawable[] @@ -53,18 +55,18 @@ namespace osu.Game.Overlays.Changelog { new SpriteText { - Text = LatestBuild.UpdateStream.DisplayName, + Text = stream.DisplayName, Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14), // web: 12, Margin = new MarginPadding { Top = 6 }, }, new SpriteText { - Text = LatestBuild.DisplayVersion, + Text = stream.LatestBuild.DisplayVersion, Font = OsuFont.GetFont(weight: FontWeight.Light, size: 20), // web: 16, }, new SpriteText { - Text = LatestBuild.Users > 0 ? $"{LatestBuild.Users:N0} users online" : null, + Text = stream.LatestBuild.Users > 0 ? $"{stream.LatestBuild.Users:N0} users online" : null, Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 12), // web: 10, Colour = new Color4(203, 164, 218, 255), }, @@ -73,7 +75,7 @@ namespace osu.Game.Overlays.Changelog lineBadge = new LineBadge(false) { Anchor = Anchor.TopCentre, - Colour = StreamColour.FromStreamName(LatestBuild.UpdateStream.Name), + Colour = StreamColour.FromStreamName(stream.Name), UncollapsedSize = 4, CollapsedSize = 2, }, diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 8f77862c99..aa32b8dae4 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -111,7 +111,7 @@ namespace osu.Game.Overlays protected override void LoadComplete() { var req = new GetChangelogLatestBuildsRequest(); - req.Success += badges.Populate; + req.Success += res => badges.Populate(res.Streams); api.Queue(req); fetchListing(); base.LoadComplete(); @@ -168,7 +168,7 @@ namespace osu.Game.Overlays isAtListing = true; var req = new GetChangelogRequest(); badges.SelectNone(); - req.Success += listing.ShowListing; + req.Success += res => listing.ShowListing(res.Builds); api.Queue(req); } From 37a8d9eb801bdacacc47ca5e628526b2cdf2da3e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 13 May 2019 16:27:54 +0900 Subject: [PATCH 127/375] Remove chart references for now --- .../API/Requests/GetChangelogChartRequest.cs | 25 -------------- .../Requests/Responses/APIChangelogChart.cs | 33 ------------------- osu.Game/Overlays/ChangelogOverlay.cs | 4 --- 3 files changed, 62 deletions(-) delete mode 100644 osu.Game/Online/API/Requests/GetChangelogChartRequest.cs delete mode 100644 osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs diff --git a/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs b/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs deleted file mode 100644 index 66e7d198c2..0000000000 --- a/osu.Game/Online/API/Requests/GetChangelogChartRequest.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Game.Online.API.Requests.Responses; - -namespace osu.Game.Online.API.Requests -{ - public class GetChangelogChartRequest : APIRequest - { - private readonly string updateStream; - - public GetChangelogChartRequest() - { - updateStream = null; - } - - public GetChangelogChartRequest(string updateStreamName) - { - updateStream = updateStreamName; - } - - protected override string Target => $@"changelog/{(!string.IsNullOrEmpty(updateStream) ? - updateStream + "/" : "")}chart-config"; - } -} diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs deleted file mode 100644 index 598928d309..0000000000 --- a/osu.Game/Online/API/Requests/Responses/APIChangelogChart.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using Newtonsoft.Json; -using System; -using System.Collections.Generic; - -namespace osu.Game.Online.API.Requests.Responses -{ - public class APIChangelogChart - { - [JsonProperty("build_history")] - public List BuildHistory { get; set; } - - [JsonProperty("order")] - public List Order { get; set; } - - [JsonProperty("stream_name")] - public string StreamName { get; set; } - } - - public class BuildHistory - { - [JsonProperty("created_at")] - public DateTimeOffset CreatedAt { get; set; } - - [JsonProperty("user_count")] - public long UserCount { get; set; } - - [JsonProperty("label")] - public string Label { get; set; } - } -} diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index aa32b8dae4..eb1d4ca69f 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -28,7 +28,6 @@ namespace osu.Game.Overlays private readonly ChangelogBadges badges; - //private readonly ChangelogChart chart; private readonly ChangelogContent listing; private readonly ChangelogContent content; @@ -88,7 +87,6 @@ namespace osu.Game.Overlays { header = new ChangelogHeader(), badges = new ChangelogBadges(), - //chart = new ChangelogChart(), listing = new ChangelogContent(), content = new ChangelogContent() }, @@ -183,7 +181,6 @@ namespace osu.Game.Overlays content.Hide(); listing.Show(); badges.SelectNone(); - //chart.ShowAllUpdateStreams(); listing.Show(); scroll.ScrollTo(savedScrollPosition); } @@ -208,7 +205,6 @@ namespace osu.Game.Overlays if (updateBadges) badges.SelectUpdateStream(build.UpdateStream.Name); - //chart.ShowUpdateStream(build.UpdateStream.Name); req.Success += apiChangelog => { listing.Hide(); From e9c3f5430722912aa88add88731dffc3f33819c7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 13 May 2019 16:44:43 +0900 Subject: [PATCH 128/375] Share web request between builds and streams --- .../API/Requests/GetChangelogLatestBuildsRequest.cs | 9 --------- osu.Game/Overlays/ChangelogOverlay.cs | 11 ++++++----- 2 files changed, 6 insertions(+), 14 deletions(-) delete mode 100644 osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs diff --git a/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs b/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs deleted file mode 100644 index dd50701e39..0000000000 --- a/osu.Game/Online/API/Requests/GetChangelogLatestBuildsRequest.cs +++ /dev/null @@ -1,9 +0,0 @@ -// 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.Online.API.Requests -{ - public class GetChangelogLatestBuildsRequest : GetChangelogRequest - { - } -} diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index eb1d4ca69f..ddbd755696 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -108,11 +108,8 @@ namespace osu.Game.Overlays protected override void LoadComplete() { - var req = new GetChangelogLatestBuildsRequest(); - req.Success += res => badges.Populate(res.Streams); - api.Queue(req); - fetchListing(); base.LoadComplete(); + fetchListing(); } protected override void PopIn() @@ -166,7 +163,11 @@ namespace osu.Game.Overlays isAtListing = true; var req = new GetChangelogRequest(); badges.SelectNone(); - req.Success += res => listing.ShowListing(res.Builds); + req.Success += res => + { + listing.ShowListing(res.Builds); + badges.Populate(res.Streams); + }; api.Queue(req); } From 50c440de8d336130a69730bbcb642685399314ec Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 13 May 2019 17:01:17 +0900 Subject: [PATCH 129/375] Add toolbar button --- osu.Game/OsuGame.cs | 4 ++++ osu.Game/Overlays/Toolbar/Toolbar.cs | 1 + .../Toolbar/ToolbarChangelogButton.cs | 22 +++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 osu.Game/Overlays/Toolbar/ToolbarChangelogButton.cs diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 7b2a8184d1..679f067f22 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -76,6 +76,8 @@ namespace osu.Game private BeatmapSetOverlay beatmapSetOverlay; + private ChangelogOverlay changelogOverlay; + [Cached] private readonly ScreenshotManager screenshotManager = new ScreenshotManager(); @@ -448,6 +450,7 @@ namespace osu.Game loadComponentSingleFile(settings = new MainSettings { GetToolbarHeight = () => ToolbarOffset }, leftFloatingOverlayContent.Add); loadComponentSingleFile(userProfile = new UserProfileOverlay(), overlayContent.Add); loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add); + loadComponentSingleFile(changelogOverlay = new ChangelogOverlay(), overlayContent.Add); loadComponentSingleFile(loginOverlay = new LoginOverlay { @@ -480,6 +483,7 @@ namespace osu.Game dependencies.Cache(notifications); dependencies.Cache(loginOverlay); dependencies.Cache(dialogOverlay); + dependencies.Cache(changelogOverlay); dependencies.Cache(accountCreation); chatOverlay.StateChanged += state => channelManager.HighPollRate.Value = state == Visibility.Visible; diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index a7f2a0e8d0..3c8b96fe8a 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -69,6 +69,7 @@ namespace osu.Game.Overlays.Toolbar AutoSizeAxes = Axes.X, Children = new Drawable[] { + new ToolbarChangelogButton(), new ToolbarDirectButton(), new ToolbarChatButton(), new ToolbarSocialButton(), diff --git a/osu.Game/Overlays/Toolbar/ToolbarChangelogButton.cs b/osu.Game/Overlays/Toolbar/ToolbarChangelogButton.cs new file mode 100644 index 0000000000..84210e27a4 --- /dev/null +++ b/osu.Game/Overlays/Toolbar/ToolbarChangelogButton.cs @@ -0,0 +1,22 @@ +// 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.Sprites; + +namespace osu.Game.Overlays.Toolbar +{ + public class ToolbarChangelogButton : ToolbarOverlayToggleButton + { + public ToolbarChangelogButton() + { + SetIcon(FontAwesome.Solid.Bullhorn); + } + + [BackgroundDependencyLoader(true)] + private void load(ChangelogOverlay changelog) + { + StateContainer = changelog; + } + } +} From 27ca0944212450417faf839fce80ca70e5123b70 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 13 May 2019 17:14:52 +0900 Subject: [PATCH 130/375] Update outdated licence headers --- osu.Game.Tests/Visual/TestCaseLineBadge.cs | 4 ++-- osu.Game.Tests/Visual/TestCaseTextBadgePair.cs | 4 ++-- osu.Game/Graphics/StreamColour.cs | 4 ++-- osu.Game/Graphics/UserInterface/TooltipIconButton.cs | 4 ++-- osu.Game/Overlays/Changelog/ChangelogBadges.cs | 4 ++-- osu.Game/Overlays/Changelog/ChangelogContent.cs | 4 ++-- osu.Game/Overlays/Changelog/ChangelogContentGroup.cs | 4 ++-- osu.Game/Overlays/Changelog/ChangelogHeader.cs | 4 ++-- osu.Game/Overlays/Changelog/StreamBadge.cs | 4 ++-- osu.Game/Overlays/ChangelogOverlay.cs | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseLineBadge.cs b/osu.Game.Tests/Visual/TestCaseLineBadge.cs index 06311ea7f9..ae94767640 100644 --- a/osu.Game.Tests/Visual/TestCaseLineBadge.cs +++ b/osu.Game.Tests/Visual/TestCaseLineBadge.cs @@ -1,5 +1,5 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/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.Graphics; using osu.Framework.Graphics.Containers; diff --git a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs b/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs index bfd77ee3c7..3c461a2dd6 100644 --- a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs +++ b/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs @@ -1,5 +1,5 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/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.Graphics; using osu.Framework.Graphics.Containers; diff --git a/osu.Game/Graphics/StreamColour.cs b/osu.Game/Graphics/StreamColour.cs index c4df3b64a3..b7740c3be0 100644 --- a/osu.Game/Graphics/StreamColour.cs +++ b/osu.Game/Graphics/StreamColour.cs @@ -1,5 +1,5 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/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.Graphics.Colour; using System.Collections.Generic; diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs index ce546c5358..7287794f89 100644 --- a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs +++ b/osu.Game/Graphics/UserInterface/TooltipIconButton.cs @@ -1,5 +1,5 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/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.Allocation; using osu.Framework.Audio; diff --git a/osu.Game/Overlays/Changelog/ChangelogBadges.cs b/osu.Game/Overlays/Changelog/ChangelogBadges.cs index cf14ddbb01..372ef76351 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBadges.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBadges.cs @@ -1,5 +1,5 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/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.Graphics; using osu.Framework.Graphics.Containers; diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index e71769595f..fdc9fac404 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -1,5 +1,5 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/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.Graphics; using osu.Framework.Graphics.Containers; diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 837ce24522..0e846ae115 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -1,5 +1,5 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/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.Graphics; using osu.Framework.Graphics.Containers; diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index b14e065b1e..bae84bd4ac 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -1,5 +1,5 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/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.Allocation; using osu.Framework.Graphics; diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 424c344e91..6c3c95a2b3 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -1,5 +1,5 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/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.Allocation; using osu.Framework.Audio; diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index ddbd755696..276ec622c7 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -1,5 +1,5 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/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.Allocation; using osu.Framework.Audio; From 8ecd1912e1da5ffdeb92c677af53aeb8bdea76d6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 13 May 2019 17:24:33 +0900 Subject: [PATCH 131/375] Split out web response classes into own files --- .../Visual/TestCaseChangelogOverlay.cs | 2 +- .../Requests/Responses/APIChangelogBuild.cs | 98 ++----------------- .../Requests/Responses/APIChangelogEntry.cs | 47 +++++++++ .../Requests/Responses/APIChangelogIndex.cs | 2 +- .../Requests/Responses/APIChangelogUser.cs | 28 ++++++ .../API/Requests/Responses/APIUpdateStream.cs | 25 +++++ .../Overlays/Changelog/ChangelogBadges.cs | 4 +- .../Changelog/ChangelogContentGroup.cs | 14 +-- osu.Game/Overlays/Changelog/StreamBadge.cs | 4 +- osu.Game/Overlays/ChangelogOverlay.cs | 4 +- 10 files changed, 125 insertions(+), 103 deletions(-) create mode 100644 osu.Game/Online/API/Requests/Responses/APIChangelogEntry.cs create mode 100644 osu.Game/Online/API/Requests/Responses/APIChangelogUser.cs create mode 100644 osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs diff --git a/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs b/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs index 063555cf76..851cf17cfc 100644 --- a/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs +++ b/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs @@ -27,7 +27,7 @@ namespace osu.Game.Tests.Visual changelog.FetchAndShowBuild(new APIChangelogBuild { Version = "2018.712.0", - UpdateStream = new UpdateStream { Name = "lazer" }, + UpdateStream = new APIUpdateStream { Name = "lazer" }, }); changelog.Show(); }); diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs index 64b62e1f73..03c3ed0957 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs @@ -25,99 +25,21 @@ namespace osu.Game.Online.API.Requests.Responses public DateTimeOffset CreatedAt { get; set; } [JsonProperty("update_stream")] - public UpdateStream UpdateStream { get; set; } + public APIUpdateStream UpdateStream { get; set; } [JsonProperty("changelog_entries")] - public List ChangelogEntries { get; set; } + public List ChangelogEntries { get; set; } [JsonProperty("versions")] - public Versions Versions { get; set; } - } + public VersionNativation Versions { get; set; } - public class Versions - { - [JsonProperty("next")] - public APIChangelogBuild Next { get; set; } + public class VersionNativation + { + [JsonProperty("next")] + public APIChangelogBuild Next { get; set; } - [JsonProperty("previous")] - public APIChangelogBuild Previous { get; set; } - } - - public class ChangelogEntry - { - [JsonProperty("id")] - public long? Id { get; set; } - - [JsonProperty("repository")] - public string Repository { get; set; } - - [JsonProperty("github_pull_request_id")] - public long? GithubPullRequestId { get; set; } - - [JsonProperty("github_url")] - public string GithubUrl { get; set; } - - [JsonProperty("url")] - public string Url { get; set; } - - [JsonProperty("type")] - public string Type { get; set; } - - [JsonProperty("category")] - public string Category { get; set; } - - [JsonProperty("title")] - public string Title { get; set; } - - [JsonProperty("message_html")] - public string MessageHtml { get; set; } - - [JsonProperty("major")] - public bool? Major { get; set; } - - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } - - [JsonProperty("github_user")] - public GithubUser GithubUser { get; set; } - } - - public class GithubUser - { - [JsonProperty("id")] - public long? Id { get; set; } - - [JsonProperty("display_name")] - public string DisplayName { get; set; } - - [JsonProperty("github_url")] - public string GithubUrl { get; set; } - - [JsonProperty("osu_username")] - public string OsuUsername { get; set; } - - [JsonProperty("user_id")] - public long? UserId { get; set; } - - [JsonProperty("user_url")] - public string UserUrl { get; set; } - } - - public class UpdateStream - { - [JsonProperty("id")] - public long Id { get; set; } - - [JsonProperty("name")] - public string Name { get; set; } - - [JsonProperty("is_featured")] - public bool IsFeatured { get; set; } - - [JsonProperty("display_name")] - public string DisplayName { get; set; } - - [JsonProperty("latest_build")] - public APIChangelogBuild LatestBuild { get; set; } + [JsonProperty("previous")] + public APIChangelogBuild Previous { get; set; } + } } } diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogEntry.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogEntry.cs new file mode 100644 index 0000000000..abaff9b7ae --- /dev/null +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogEntry.cs @@ -0,0 +1,47 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using Newtonsoft.Json; + +namespace osu.Game.Online.API.Requests.Responses +{ + public class APIChangelogEntry + { + [JsonProperty("id")] + public long? Id { get; set; } + + [JsonProperty("repository")] + public string Repository { get; set; } + + [JsonProperty("github_pull_request_id")] + public long? GithubPullRequestId { get; set; } + + [JsonProperty("github_url")] + public string GithubUrl { get; set; } + + [JsonProperty("url")] + public string Url { get; set; } + + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("category")] + public string Category { get; set; } + + [JsonProperty("title")] + public string Title { get; set; } + + [JsonProperty("message_html")] + public string MessageHtml { get; set; } + + [JsonProperty("major")] + public bool? Major { get; set; } + + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } + + [JsonProperty("github_user")] + public APIChangelogUser GithubUser { get; set; } + } +} diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogIndex.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogIndex.cs index 957694b887..2c31ba6659 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelogIndex.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogIndex.cs @@ -9,6 +9,6 @@ namespace osu.Game.Online.API.Requests.Responses { public List Builds; - public List Streams; + public List Streams; } } diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogUser.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogUser.cs new file mode 100644 index 0000000000..5891391e83 --- /dev/null +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogUser.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 Newtonsoft.Json; + +namespace osu.Game.Online.API.Requests.Responses +{ + public class APIChangelogUser + { + [JsonProperty("id")] + public long? Id { get; set; } + + [JsonProperty("display_name")] + public string DisplayName { get; set; } + + [JsonProperty("github_url")] + public string GithubUrl { get; set; } + + [JsonProperty("osu_username")] + public string OsuUsername { get; set; } + + [JsonProperty("user_id")] + public long? UserId { get; set; } + + [JsonProperty("user_url")] + public string UserUrl { get; set; } + } +} diff --git a/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs b/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs new file mode 100644 index 0000000000..5cf56333bb --- /dev/null +++ b/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs @@ -0,0 +1,25 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using Newtonsoft.Json; + +namespace osu.Game.Online.API.Requests.Responses +{ + public class APIUpdateStream + { + [JsonProperty("id")] + public long Id { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("is_featured")] + public bool IsFeatured { get; set; } + + [JsonProperty("display_name")] + public string DisplayName { get; set; } + + [JsonProperty("latest_build")] + public APIChangelogBuild LatestBuild { get; set; } + } +} diff --git a/osu.Game/Overlays/Changelog/ChangelogBadges.cs b/osu.Game/Overlays/Changelog/ChangelogBadges.cs index 372ef76351..e95fa72f2e 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBadges.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBadges.cs @@ -45,9 +45,9 @@ namespace osu.Game.Overlays.Changelog }; } - public void Populate(List streams) + public void Populate(List streams) { - foreach (UpdateStream updateStream in streams) + foreach (APIUpdateStream updateStream in streams) { var streamBadge = new StreamBadge(updateStream); streamBadge.Selected += onBadgeSelected; diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 0e846ae115..e9ca025425 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -19,8 +19,8 @@ namespace osu.Game.Overlays.Changelog { private readonly TooltipIconButton chevronPrevious, chevronNext; - private readonly SortedDictionary> categories = - new SortedDictionary>(); + private readonly SortedDictionary> categories = + new SortedDictionary>(); public delegate void BuildSelectedEventHandler(APIChangelogBuild build, EventArgs args); @@ -204,18 +204,18 @@ namespace osu.Game.Overlays.Changelog BuildSelected?.Invoke(build, EventArgs.Empty); } - public void GenerateText(List changelogEntries) + public void GenerateText(List changelogEntries) { // sort entries by category - foreach (ChangelogEntry entry in changelogEntries) + foreach (APIChangelogEntry entry in changelogEntries) { if (!categories.ContainsKey(entry.Category)) - categories.Add(entry.Category, new List { entry }); + categories.Add(entry.Category, new List { entry }); else categories[entry.Category].Add(entry); } - foreach (KeyValuePair> category in categories) + foreach (KeyValuePair> category in categories) { ChangelogEntries.Add(new SpriteText { @@ -224,7 +224,7 @@ namespace osu.Game.Overlays.Changelog Margin = new MarginPadding { Top = 35, Bottom = 15 }, }); - foreach (ChangelogEntry entry in category.Value) + foreach (APIChangelogEntry entry in category.Value) { LinkFlowContainer title = new LinkFlowContainer { diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 6c3c95a2b3..b617ae8f53 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -32,11 +32,11 @@ namespace osu.Game.Overlays.Changelog private SampleChannel sampleClick; private SampleChannel sampleHover; - public readonly UpdateStream Stream; + public readonly APIUpdateStream Stream; private readonly FillFlowContainer text; - public StreamBadge(UpdateStream stream) + public StreamBadge(APIUpdateStream stream) { Stream = stream; diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 276ec622c7..e9fd5789ed 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -189,8 +189,8 @@ namespace osu.Game.Overlays /// /// Fetches and shows a specific build from a specific update stream. /// - /// Must contain at least and - /// . If and + /// Must contain at least and + /// . If and /// are specified, the header will instantly display them. /// Whether to update badges. Should be set to false in case /// the function is called by selecting a badge, to avoid an infinite loop. From d66a26cd116bc45f9fd240cefbfd0acfc7f727b8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 13 May 2019 17:26:50 +0900 Subject: [PATCH 132/375] Add JsonProperty hinting --- osu.Game/Online/API/Requests/Responses/APIChangelogIndex.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogIndex.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogIndex.cs index 2c31ba6659..778e8754fe 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelogIndex.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogIndex.cs @@ -2,13 +2,16 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; +using Newtonsoft.Json; namespace osu.Game.Online.API.Requests.Responses { public class APIChangelogIndex { + [JsonProperty] public List Builds; + [JsonProperty] public List Streams; } } From 66df784e9a7cc7b858a98dd81f272bde81f3af82 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 13 May 2019 17:32:49 +0900 Subject: [PATCH 133/375] Adjust header image sizing --- osu.Game/Overlays/Changelog/ChangelogHeader.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index bae84bd4ac..0c92aa3755 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -30,7 +30,7 @@ namespace osu.Game.Overlays.Changelog public event ListingSelectedEventHandler ListingSelected; - private const float cover_height = 280; + private const float cover_height = 150; private const float title_height = 50; private const float icon_size = 50; private const float icon_margin = 20; @@ -40,12 +40,22 @@ namespace osu.Game.Overlays.Changelog { RelativeSizeAxes = Axes.X; Height = cover_height; + Children = new Drawable[] { - coverImage = new Sprite + new Container { - RelativeSizeAxes = Axes.Both, - FillMode = FillMode.Fill, + RelativeSizeAxes = Axes.X, + Height = cover_height, + Masking = true, + Children = new Drawable[] + { + coverImage = new Sprite + { + RelativeSizeAxes = Axes.Both, + FillMode = FillMode.Fill, + }, + } }, new Container { From 31e7f2fa877a4804d399119bf44f0f52305bcbfc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 14 May 2019 14:18:36 +0900 Subject: [PATCH 134/375] Update ChangelogOverlay to use FullScreenOverlay --- osu.Game/Overlays/ChangelogOverlay.cs | 49 +++++++-------------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index e9fd5789ed..b13b28afe9 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -10,63 +10,43 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Input.Bindings; -using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.Changelog; using System; -using osu.Framework.Extensions.Color4Extensions; -using osu.Framework.Graphics.Effects; using osuTK; using osuTK.Graphics; namespace osu.Game.Overlays { - public class ChangelogOverlay : WaveOverlayContainer + public class ChangelogOverlay : FullscreenOverlay { - private readonly ChangelogHeader header; + private ChangelogHeader header; - private readonly ChangelogBadges badges; + private ChangelogBadges badges; - private readonly ChangelogContent listing; - private readonly ChangelogContent content; + private ChangelogContent listing; + private ChangelogContent content; - private readonly ScrollContainer scroll; - - private readonly Color4 purple = new Color4(191, 4, 255, 255); + private ScrollContainer scroll; private SampleChannel sampleBack; - private IAPIProvider api; - private bool isAtListing; private float savedScrollPosition; // receive input outside our bounds so we can trigger a close event on ourselves. public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; - public ChangelogOverlay() + [BackgroundDependencyLoader] + private void load(AudioManager audio, OsuColour colour) { // these possibly need adjusting? - Waves.FirstWaveColour = OsuColour.FromHex(@"bf04ff"); + Waves.FirstWaveColour = colour.Violet; Waves.SecondWaveColour = OsuColour.FromHex(@"8F03BF"); Waves.ThirdWaveColour = OsuColour.FromHex(@"600280"); Waves.FourthWaveColour = OsuColour.FromHex(@"300140"); - Anchor = Anchor.TopCentre; - Origin = Anchor.TopCentre; - RelativeSizeAxes = Axes.Both; - Width = 0.85f; - Masking = true; - - EdgeEffect = new EdgeEffectParameters - { - Colour = Color4.Black.Opacity(0), - Type = EdgeEffectType.Shadow, - Radius = 3, - Offset = new Vector2(0f, 1f), - }; - Children = new Drawable[] { new Box @@ -97,12 +77,7 @@ namespace osu.Game.Overlays badges.Selected += onBuildSelected; listing.BuildSelected += onBuildSelected; content.BuildSelected += onBuildSelected; - } - [BackgroundDependencyLoader] - private void load(IAPIProvider api, AudioManager audio) - { - this.api = api; sampleBack = audio.Sample.Get(@"UI/generic-select-soft"); // @"UI/screen-back" feels non-fitting here } @@ -168,7 +143,8 @@ namespace osu.Game.Overlays listing.ShowListing(res.Builds); badges.Populate(res.Streams); }; - api.Queue(req); + + API.Queue(req); } public void ShowListing() @@ -217,7 +193,8 @@ namespace osu.Game.Overlays savedScrollPosition = scroll.Current; isAtListing = false; }; - api.Queue(req); + + API.Queue(req); } } } From eece4d878fb31d862e753ada76ab2e4aa278cfc6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 14 May 2019 18:03:54 +0900 Subject: [PATCH 135/375] Tidy up colour references and texture assignment in ChangelogHeader --- .../Overlays/Changelog/ChangelogHeader.cs | 45 ++++++++----------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 0c92aa3755..1bc30b87d4 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -18,13 +18,10 @@ namespace osu.Game.Overlays.Changelog { public class ChangelogHeader : Container { - protected Color4 Purple = new Color4(191, 4, 255, 255); - private readonly Sprite coverImage; - private readonly Sprite headerBadge; - private readonly OsuSpriteText titleStream; - private readonly TextBadgePairListing listing; - private readonly SpriteIcon chevron; - private readonly TextBadgePairRelease releaseStream; + private OsuSpriteText titleStream; + private TextBadgePairListing listing; + private SpriteIcon chevron; + private TextBadgePairRelease releaseStream; public delegate void ListingSelectedEventHandler(); @@ -36,7 +33,8 @@ namespace osu.Game.Overlays.Changelog private const float icon_margin = 20; private const float version_height = 40; - public ChangelogHeader() + [BackgroundDependencyLoader] + private void load(OsuColour colours, TextureStore textures) { RelativeSizeAxes = Axes.X; Height = cover_height; @@ -50,9 +48,10 @@ namespace osu.Game.Overlays.Changelog Masking = true, Children = new Drawable[] { - coverImage = new Sprite + new Sprite { RelativeSizeAxes = Axes.Both, + Texture = textures.Get(@"https://osu.ppy.sh/images/headers/changelog.jpg"), FillMode = FillMode.Fill, }, } @@ -69,15 +68,17 @@ namespace osu.Game.Overlays.Changelog { X = icon_margin, Masking = true, - BorderColour = Purple, + BorderColour = colours.Violet, BorderThickness = 3, MaskingSmoothness = 1, Size = new Vector2(50), Children = new Drawable[] { - headerBadge = new Sprite + new Sprite { RelativeSizeAxes = Axes.Both, + // todo: https://osu.ppy.sh/images/icons/changelog.svg + Texture = textures.Get(@"https://i.imgur.com/HQM3Vhp.png"), Size = new Vector2(0.8f), Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -92,7 +93,7 @@ namespace osu.Game.Overlays.Changelog RelativeSizeAxes = Axes.Both, Alpha = 0, AlwaysPresent = true, - Colour = Purple, + Colour = colours.Violet, } } }, @@ -114,7 +115,7 @@ namespace osu.Game.Overlays.Changelog { Text = "Listing", Font = OsuFont.GetFont(weight: FontWeight.Light, size: 38), // web: 30, - Colour = Purple, + Colour = colours.Violet, }, } } @@ -129,7 +130,7 @@ namespace osu.Game.Overlays.Changelog Direction = FillDirection.Horizontal, Children = new Drawable[] { - listing = new TextBadgePairListing(Purple), + listing = new TextBadgePairListing(colours.Violet), new Container // without a container, moving the chevron wont work { Anchor = Anchor.CentreLeft, @@ -148,25 +149,26 @@ namespace osu.Game.Overlays.Changelog Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(7), - Colour = Purple, + Colour = colours.Violet, Icon = FontAwesome.Solid.ChevronRight, Alpha = 0, X = -200, }, }, }, - releaseStream = new TextBadgePairRelease(Purple, "Lazer") + releaseStream = new TextBadgePairRelease(colours.Violet, "Lazer") }, }, new Box { - Colour = Purple, + Colour = colours.Violet, RelativeSizeAxes = Axes.X, Height = 2, Anchor = Anchor.BottomLeft, Origin = Anchor.CentreLeft, }, }; + listing.Activated += OnListingSelected; releaseStream.Activated += OnReleaseSelected; } @@ -198,14 +200,5 @@ namespace osu.Game.Overlays.Changelog { titleStream.FlashColour(Color4.White, 500, Easing.OutQuad); } - - [BackgroundDependencyLoader] - private void load(TextureStore textures) - { - // should be added to osu-resources? - // headerBadge.Texture = textures.Get(@"https://osu.ppy.sh/images/icons/changelog.svg"); // this is not working - headerBadge.Texture = textures.Get(@"https://i.imgur.com/HQM3Vhp.png"); - coverImage.Texture = textures.Get(@"https://osu.ppy.sh/images/headers/changelog.jpg"); - } } } From 5ddd28bf309f219322cc3e82d7afcf9c540067e2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 15 May 2019 16:42:12 +0900 Subject: [PATCH 136/375] Fix message display / html stripping --- .../Changelog/ChangelogContentGroup.cs | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index e9ca025425..190720df04 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -10,6 +10,7 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Online.API.Requests.Responses; using System; using System.Collections.Generic; +using System.Text.RegularExpressions; using osuTK; using osuTK.Graphics; @@ -262,19 +263,23 @@ namespace osu.Game.Overlays.Changelog ChangelogEntries.Add(title); - TextFlowContainer messageContainer = new TextFlowContainer + if (!string.IsNullOrEmpty(entry.MessageHtml)) { - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - }; + TextFlowContainer messageContainer = new TextFlowContainer + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + }; - messageContainer.AddText($"{entry.MessageHtml?.Replace("

", "").Replace("

", "")}\n", t => - { - t.Font = OsuFont.GetFont(size: 14); // web: 12, - t.Colour = new Color4(235, 184, 254, 255); - }); + // todo: use markdown parsing once API returns markdown + messageContainer.AddText(Regex.Replace(entry.MessageHtml, @"<(.|\n)*?>", string.Empty), t => + { + t.Font = OsuFont.GetFont(size: 14); // web: 12, + t.Colour = new Color4(235, 184, 254, 255); + }); - ChangelogEntries.Add(messageContainer); + ChangelogEntries.Add(messageContainer); + } } } } From e46a61febfa33ffaacc6e04f95f5db7affaec6c2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 15 May 2019 17:36:29 +0900 Subject: [PATCH 137/375] Allow chaining of loadComponentSingleFile --- osu.Game/OsuGame.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index ab643b1469..b214f48485 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; @@ -589,7 +589,7 @@ namespace osu.Game private Task asyncLoadStream; - private void loadComponentSingleFile(T d, Action add, bool cache = false) + private T loadComponentSingleFile(T d, Action add, bool cache = false) where T : Drawable { if (cache) @@ -637,6 +637,8 @@ namespace osu.Game } }); }); + + return d; } public bool OnPressed(GlobalAction action) From d7098e2066186dc0300447a097b4497eb0f7ccd6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 15 May 2019 17:38:19 +0900 Subject: [PATCH 138/375] Hide other overlays when showing changelog --- osu.Game/OsuGame.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index b214f48485..752762ee50 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; @@ -437,7 +437,7 @@ namespace osu.Game loadComponentSingleFile(settings = new SettingsOverlay { GetToolbarHeight = () => ToolbarOffset }, leftFloatingOverlayContent.Add, true); loadComponentSingleFile(userProfile = new UserProfileOverlay(), overlayContent.Add, true); loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true); - loadComponentSingleFile(new ChangelogOverlay(), overlayContent.Add, true); + var changelogOverlay = loadComponentSingleFile(new ChangelogOverlay(), overlayContent.Add, true); loadComponentSingleFile(new LoginOverlay { @@ -479,7 +479,7 @@ namespace osu.Game } // eventually informational overlays should be displayed in a stack, but for now let's only allow one to stay open at a time. - var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile }; + var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile, changelogOverlay }; overlays.AddRange(informationalOverlays); foreach (var overlay in informationalOverlays) From f49b0dc16df3aa6270f82ddb29e3a31cef51c448 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 15 May 2019 17:55:26 +0900 Subject: [PATCH 139/375] Initial clean-up pass of breadcrumb and header --- .../Visual/TestCaseTextBadgePair.cs | 25 ++++--- .../{ChangelogBadges.cs => BadgeDisplay.cs} | 7 +- .../Overlays/Changelog/ChangelogHeader.cs | 30 +++----- .../{TextBadgePair.cs => Breadcrumb.cs} | 72 +++++++------------ ...dgePairListing.cs => BreadcrumbListing.cs} | 42 +++++------ ...dgePairRelease.cs => BreadcrumbRelease.cs} | 21 ++---- osu.Game/Overlays/ChangelogOverlay.cs | 15 ++-- 7 files changed, 89 insertions(+), 123 deletions(-) rename osu.Game/Overlays/Changelog/{ChangelogBadges.cs => BadgeDisplay.cs} (95%) rename osu.Game/Overlays/Changelog/Header/{TextBadgePair.cs => Breadcrumb.cs} (68%) rename osu.Game/Overlays/Changelog/Header/{TextBadgePairListing.cs => BreadcrumbListing.cs} (54%) rename osu.Game/Overlays/Changelog/Header/{TextBadgePairRelease.cs => BreadcrumbRelease.cs} (53%) diff --git a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs b/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs index 3c461a2dd6..2f7ab5deba 100644 --- a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs +++ b/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Overlays.Changelog.Header; @@ -13,7 +14,7 @@ namespace osu.Game.Tests.Visual { public TestCaseTextBadgePair() { - TextBadgePair textBadgePair; + Breadcrumb breadcrumb; Add(new Container { @@ -29,7 +30,7 @@ namespace osu.Game.Tests.Visual Alpha = 0.5f, RelativeSizeAxes = Axes.Both, }, - textBadgePair = new TextBadgePair(Color4.DeepSkyBlue, "Test") + breadcrumb = new TestBadgePair(Color4.DeepSkyBlue, "Test") { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -37,12 +38,20 @@ namespace osu.Game.Tests.Visual } }); - AddStep(@"Deactivate", textBadgePair.Deactivate); - AddStep(@"Activate", textBadgePair.Activate); - AddStep(@"Hide text", () => textBadgePair.HideText(200)); - AddStep(@"Show text", () => textBadgePair.ShowText(200)); - AddStep(@"Different text", () => textBadgePair.ChangeText(200, "This one's a little bit wider")); - AddStep(@"Different text", () => textBadgePair.ChangeText(200, "Ok?..")); + AddStep(@"Deactivate", breadcrumb.Deactivate); + AddStep(@"Activate", breadcrumb.Activate); + AddStep(@"Hide text", () => breadcrumb.HideText(200)); + AddStep(@"Show text", () => breadcrumb.ShowText(200)); + AddStep(@"Different text", () => breadcrumb.ShowText(200, "This one's a little bit wider")); + AddStep(@"Different text", () => breadcrumb.ShowText(200, "Ok?..")); + } + + private class TestBadgePair : Breadcrumb + { + public TestBadgePair(ColourInfo badgeColour, string displayText = "Listing", bool startCollapsed = true) + : base(badgeColour, displayText, startCollapsed) + { + } } } } diff --git a/osu.Game/Overlays/Changelog/ChangelogBadges.cs b/osu.Game/Overlays/Changelog/BadgeDisplay.cs similarity index 95% rename from osu.Game/Overlays/Changelog/ChangelogBadges.cs rename to osu.Game/Overlays/Changelog/BadgeDisplay.cs index e95fa72f2e..441909132a 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBadges.cs +++ b/osu.Game/Overlays/Changelog/BadgeDisplay.cs @@ -12,9 +12,8 @@ using osuTK.Graphics; namespace osu.Game.Overlays.Changelog { - public class ChangelogBadges : Container + public class BadgeDisplay : CompositeDrawable { - private const float container_height = 106.5f; private const float vertical_padding = 20; private const float horizontal_padding = 85; @@ -25,11 +24,11 @@ namespace osu.Game.Overlays.Changelog private readonly FillFlowContainer badgesContainer; private long selectedStreamId = -1; - public ChangelogBadges() + public BadgeDisplay() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - Children = new Drawable[] + InternalChildren = new Drawable[] { new Box { diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 1bc30b87d4..4186356bd4 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -9,7 +9,6 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Changelog.Header; -using System; using osu.Game.Graphics; using osuTK; using osuTK.Graphics; @@ -19,9 +18,9 @@ namespace osu.Game.Overlays.Changelog public class ChangelogHeader : Container { private OsuSpriteText titleStream; - private TextBadgePairListing listing; + private BreadcrumbListing listing; private SpriteIcon chevron; - private TextBadgePairRelease releaseStream; + private BreadcrumbRelease releaseStream; public delegate void ListingSelectedEventHandler(); @@ -130,7 +129,10 @@ namespace osu.Game.Overlays.Changelog Direction = FillDirection.Horizontal, Children = new Drawable[] { - listing = new TextBadgePairListing(colours.Violet), + listing = new BreadcrumbListing(colours.Violet) + { + Action = () => ListingSelected?.Invoke() + }, new Container // without a container, moving the chevron wont work { Anchor = Anchor.CentreLeft, @@ -156,7 +158,10 @@ namespace osu.Game.Overlays.Changelog }, }, }, - releaseStream = new TextBadgePairRelease(colours.Violet, "Lazer") + releaseStream = new BreadcrumbRelease(colours.Violet, "Lazer") + { + Action = () => titleStream.FlashColour(Color4.White, 500, Easing.OutQuad) + } }, }, new Box @@ -168,15 +173,12 @@ namespace osu.Game.Overlays.Changelog Origin = Anchor.CentreLeft, }, }; - - listing.Activated += OnListingSelected; - releaseStream.Activated += OnReleaseSelected; } public void ShowBuild(string displayName, string displayVersion) { listing.Deactivate(); - releaseStream.Activate($"{displayName} {displayVersion}"); + releaseStream.ShowBuild($"{displayName} {displayVersion}"); titleStream.Text = displayName; titleStream.FlashColour(Color4.White, 500, Easing.OutQuad); chevron.MoveToX(0, 100).FadeIn(100); @@ -190,15 +192,5 @@ namespace osu.Game.Overlays.Changelog titleStream.FlashColour(Color4.White, 500, Easing.OutQuad); chevron.MoveToX(-20, 100).FadeOut(100); } - - protected virtual void OnListingSelected(object source, EventArgs e) - { - ListingSelected?.Invoke(); - } - - protected virtual void OnReleaseSelected(object source, EventArgs e) - { - titleStream.FlashColour(Color4.White, 500, Easing.OutQuad); - } } } diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs b/osu.Game/Overlays/Changelog/Header/Breadcrumb.cs similarity index 68% rename from osu.Game/Overlays/Changelog/Header/TextBadgePair.cs rename to osu.Game/Overlays/Changelog/Header/Breadcrumb.cs index e044d4c342..43dcaf22ca 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePair.cs +++ b/osu.Game/Overlays/Changelog/Header/Breadcrumb.cs @@ -15,20 +15,19 @@ using osu.Game.Graphics; namespace osu.Game.Overlays.Changelog.Header { - public class TextBadgePair : Container + public abstract class Breadcrumb : Container { protected SpriteText Text; protected LineBadge LineBadge; + public bool IsActivated { get; protected set; } - public delegate void ActivatedEventHandler(object source, EventArgs args); - - public event ActivatedEventHandler Activated; + public Action Action; private SampleChannel sampleHover; private SampleChannel sampleActivate; - public TextBadgePair(ColourInfo badgeColour, string displayText = "Listing", bool startCollapsed = true) + protected Breadcrumb(ColourInfo badgeColour, string displayText = "Listing", bool startCollapsed = true) { AutoSizeAxes = Axes.X; RelativeSizeAxes = Axes.Y; @@ -53,42 +52,24 @@ namespace osu.Game.Overlays.Changelog.Header }; } - /// - /// The duration of popping in and popping out not combined. - /// Full change takes double this time. - /// - /// - public void ChangeText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) - { - LineBadge.Collapse(); - Text.MoveToY(20, duration, easing) - .FadeOut(duration, easing) - .Then() - .MoveToY(0, duration, easing) - .FadeIn(duration, easing); - - // since using .finally/.oncomplete after first fadeout made the badge not hide - // sometimes in visual tests (https://streamable.com/0qssq), I'm using a scheduler here - Scheduler.AddDelayed(() => - { - if (!string.IsNullOrEmpty(displayText)) - Text.Text = displayText; - LineBadge.Uncollapse(); - }, duration); - } - public virtual void Deactivate() { + if (!IsActivated) + return; + IsActivated = false; LineBadge.Collapse(); - Text.Font = "Exo2.0-Regular"; + Text.Font = Text.Font.With(weight: FontWeight.Regular); } public virtual void Activate() { + if (IsActivated) + return; + IsActivated = true; LineBadge.Uncollapse(); - Text.Font = "Exo2.0-Bold"; + Text.Font = Text.Font.With(weight: FontWeight.Bold); } public void SetTextColour(ColourInfo newColour, double duration = 0, Easing easing = Easing.None) @@ -96,11 +77,6 @@ namespace osu.Game.Overlays.Changelog.Header Text.FadeColour(newColour, duration, easing); } - public void SetBadgeColour(ColourInfo newColour, double duration = 0, Easing easing = Easing.None) - { - LineBadge.FadeColour(newColour, duration, easing); - } - public void HideText(double duration = 0, Easing easing = Easing.InOutCubic) { LineBadge.Collapse(); @@ -110,11 +86,18 @@ namespace osu.Game.Overlays.Changelog.Header public void ShowText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) { - LineBadge.Uncollapse(); - if (!string.IsNullOrEmpty(displayText)) - Text.Text = displayText; - Text.MoveToY(0, duration, easing) + LineBadge.Collapse(); + Text.MoveToY(20, duration, easing) + .FadeOut(duration, easing) + .Then() + .MoveToY(0, duration, easing) .FadeIn(duration, easing); + + Scheduler.AddDelayed(() => + { + Text.Text = displayText; + LineBadge.Uncollapse(); + }, duration); } protected override bool OnHover(HoverEvent e) @@ -126,14 +109,11 @@ namespace osu.Game.Overlays.Changelog.Header protected override bool OnClick(ClickEvent e) { - OnActivated(); + Action?.Invoke(); + Activate(); sampleActivate?.Play(); - return base.OnClick(e); - } - protected virtual void OnActivated() - { - Activated?.Invoke(this, EventArgs.Empty); + return true; } [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs b/osu.Game/Overlays/Changelog/Header/BreadcrumbListing.cs similarity index 54% rename from osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs rename to osu.Game/Overlays/Changelog/Header/BreadcrumbListing.cs index b51948e849..50db916e7e 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairListing.cs +++ b/osu.Game/Overlays/Changelog/Header/BreadcrumbListing.cs @@ -4,31 +4,32 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Input.Events; +using osu.Game.Graphics; using osuTK.Graphics; namespace osu.Game.Overlays.Changelog.Header { - public class TextBadgePairListing : TextBadgePair + public class BreadcrumbListing : Breadcrumb { private readonly ColourInfo badgeColour; - public TextBadgePairListing(ColourInfo badgeColour) + public BreadcrumbListing(ColourInfo badgeColour) : base(badgeColour, "Listing", false) { - IsActivated = true; this.badgeColour = badgeColour; - Text.Font = "Exo2.0-Bold"; + Text.Font = Text.Font.With(weight: FontWeight.Bold); Text.Anchor = Anchor.TopCentre; Text.Origin = Anchor.TopCentre; - // I'm using this for constant badge width here, so that the whole - // thing doesn't jump left/right when listing's size changes - // due to different font weight (and thus width) - LineBadge.RelativeSizeAxes = Axes.None; + AutoSizeAxes = Axes.None; + } - // this doesn't work without the scheduler - // (because the text isn't yet fully drawn when it's loaded?) - Text.OnLoadComplete += d => Scheduler.Add(UpdateBadgeWidth); + protected override void LoadComplete() + { + base.LoadComplete(); + + Activate(); + Width = Text.DrawWidth; } public override void Activate() @@ -36,24 +37,17 @@ namespace osu.Game.Overlays.Changelog.Header if (IsActivated) return; - IsActivated = true; - LineBadge.Uncollapse(); - Text.Font = "Exo2.0-Bold"; + base.Activate(); SetTextColour(Color4.White, 100); } public override void Deactivate() { - IsActivated = false; - LineBadge.Collapse(); - Text.Font = "Exo2.0-Regular"; - SetTextColour(badgeColour, 100); - } + if (!IsActivated) + return; - protected override bool OnClick(ClickEvent e) - { - Activate(); - return base.OnClick(e); + base.Deactivate(); + SetTextColour(badgeColour, 100); } protected override bool OnHover(HoverEvent e) @@ -68,7 +62,5 @@ namespace osu.Game.Overlays.Changelog.Header LineBadge.Collapse(); base.OnHoverLost(e); } - - public void UpdateBadgeWidth() => LineBadge.ResizeWidthTo(Text.DrawWidth); } } diff --git a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs b/osu.Game/Overlays/Changelog/Header/BreadcrumbRelease.cs similarity index 53% rename from osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs rename to osu.Game/Overlays/Changelog/Header/BreadcrumbRelease.cs index f677bf62fe..86000ea4d1 100644 --- a/osu.Game/Overlays/Changelog/Header/TextBadgePairRelease.cs +++ b/osu.Game/Overlays/Changelog/Header/BreadcrumbRelease.cs @@ -5,11 +5,11 @@ using osu.Framework.Graphics.Colour; namespace osu.Game.Overlays.Changelog.Header { - public class TextBadgePairRelease : TextBadgePair + public class BreadcrumbRelease : Breadcrumb { private const float transition_duration = 125; - public TextBadgePairRelease(ColourInfo badgeColour, string displayText) + public BreadcrumbRelease(ColourInfo badgeColour, string displayText) : base(badgeColour, displayText) { Text.Font = "Exo2.0-Bold"; @@ -17,24 +17,17 @@ namespace osu.Game.Overlays.Changelog.Header Text.Alpha = 0; } - public void SetText(string displayText) => Text.Text = displayText; - - public void Activate(string displayText = null) + public void ShowBuild(string displayText = null) { - if (IsActivated) - { - if (displayText != Text.Text) - ChangeText(transition_duration, displayText); - } - else - ShowText(transition_duration, displayText); - + ShowText(transition_duration, displayText); IsActivated = true; } public override void Deactivate() { - IsActivated = false; + if (!IsActivated) + return; + HideText(transition_duration); } } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index b13b28afe9..a571879192 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -23,7 +23,7 @@ namespace osu.Game.Overlays { private ChangelogHeader header; - private ChangelogBadges badges; + private BadgeDisplay badgeDisplay; private ChangelogContent listing; private ChangelogContent content; @@ -66,15 +66,16 @@ namespace osu.Game.Overlays Children = new Drawable[] { header = new ChangelogHeader(), - badges = new ChangelogBadges(), + badgeDisplay = new BadgeDisplay(), listing = new ChangelogContent(), content = new ChangelogContent() }, }, }, }; + header.ListingSelected += ShowListing; - badges.Selected += onBuildSelected; + badgeDisplay.Selected += onBuildSelected; listing.BuildSelected += onBuildSelected; content.BuildSelected += onBuildSelected; @@ -137,11 +138,11 @@ namespace osu.Game.Overlays isAtListing = true; var req = new GetChangelogRequest(); - badges.SelectNone(); + badgeDisplay.SelectNone(); req.Success += res => { listing.ShowListing(res.Builds); - badges.Populate(res.Streams); + badgeDisplay.Populate(res.Streams); }; API.Queue(req); @@ -157,7 +158,7 @@ namespace osu.Game.Overlays isAtListing = true; content.Hide(); listing.Show(); - badges.SelectNone(); + badgeDisplay.SelectNone(); listing.Show(); scroll.ScrollTo(savedScrollPosition); } @@ -180,7 +181,7 @@ namespace osu.Game.Overlays req.Success += res => header.ShowBuild(res.UpdateStream.DisplayName, res.DisplayVersion); if (updateBadges) - badges.SelectUpdateStream(build.UpdateStream.Name); + badgeDisplay.SelectUpdateStream(build.UpdateStream.Name); req.Success += apiChangelog => { From 60d244d2d60ae4d1fcc1e68997be7874c1f34671 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 15 May 2019 18:08:19 +0900 Subject: [PATCH 140/375] Clean up events and states --- .../Visual/TestCaseChangelogOverlay.cs | 2 +- osu.Game/Overlays/Changelog/BadgeDisplay.cs | 8 ++-- .../Overlays/Changelog/ChangelogContent.cs | 15 ++----- .../Changelog/ChangelogContentGroup.cs | 17 +++----- osu.Game/Overlays/ChangelogOverlay.cs | 39 +++++++------------ 5 files changed, 27 insertions(+), 54 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs b/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs index 851cf17cfc..89b4fd2d18 100644 --- a/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs +++ b/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs @@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual AddStep(@"Show with Lazer 2018.712.0", () => { - changelog.FetchAndShowBuild(new APIChangelogBuild + changelog.ShowBuild(new APIChangelogBuild { Version = "2018.712.0", UpdateStream = new APIUpdateStream { Name = "lazer" }, diff --git a/osu.Game/Overlays/Changelog/BadgeDisplay.cs b/osu.Game/Overlays/Changelog/BadgeDisplay.cs index 441909132a..8c58decf49 100644 --- a/osu.Game/Overlays/Changelog/BadgeDisplay.cs +++ b/osu.Game/Overlays/Changelog/BadgeDisplay.cs @@ -17,9 +17,7 @@ namespace osu.Game.Overlays.Changelog private const float vertical_padding = 20; private const float horizontal_padding = 85; - public delegate void SelectionHandler(APIChangelogBuild releaseStream, EventArgs args); - - public event SelectionHandler Selected; + public event Action Selected; private readonly FillFlowContainer badgesContainer; private long selectedStreamId = -1; @@ -46,6 +44,8 @@ namespace osu.Game.Overlays.Changelog public void Populate(List streams) { + SelectNone(); + foreach (APIUpdateStream updateStream in streams) { var streamBadge = new StreamBadge(updateStream); @@ -92,7 +92,7 @@ namespace osu.Game.Overlays.Changelog protected virtual void OnSelected(StreamBadge source) { - Selected?.Invoke(source.Stream.LatestBuild, EventArgs.Empty); + Selected?.Invoke(source.Stream.LatestBuild); } protected override bool OnHover(HoverEvent e) diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index fdc9fac404..45fb98add0 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -15,9 +15,7 @@ namespace osu.Game.Overlays.Changelog { private ChangelogContentGroup changelogContentGroup; - public delegate void BuildSelectedEventHandler(APIChangelogBuild build, EventArgs args); - - public event BuildSelectedEventHandler BuildSelected; + public event Action BuildSelected; public ChangelogContent() { @@ -48,7 +46,7 @@ namespace osu.Game.Overlays.Changelog } changelogContentGroup = new ChangelogContentGroup(build, true); - changelogContentGroup.BuildSelected += OnBuildSelected; + changelogContentGroup.BuildSelected += b => BuildSelected?.Invoke(b); changelogContentGroup.GenerateText(build.ChangelogEntries); Add(changelogContentGroup); currentDate = build.CreatedAt.Date; @@ -64,7 +62,7 @@ namespace osu.Game.Overlays.Changelog }); changelogContentGroup = new ChangelogContentGroup(build, false); - changelogContentGroup.BuildSelected += OnBuildSelected; + changelogContentGroup.BuildSelected += b => BuildSelected?.Invoke(b); changelogContentGroup.GenerateText(build.ChangelogEntries); Add(changelogContentGroup); } @@ -77,12 +75,7 @@ namespace osu.Game.Overlays.Changelog changelogContentGroup.GenerateText(changelogBuild.ChangelogEntries); changelogContentGroup.UpdateChevronTooltips(changelogBuild.Versions.Previous?.DisplayVersion, changelogBuild.Versions.Next?.DisplayVersion); - changelogContentGroup.BuildSelected += OnBuildSelected; - } - - protected virtual void OnBuildSelected(APIChangelogBuild build, EventArgs args) - { - BuildSelected?.Invoke(build, EventArgs.Empty); + changelogContentGroup.BuildSelected += b => BuildSelected?.Invoke(b); } } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 190720df04..1b03ade7e0 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -23,9 +23,7 @@ namespace osu.Game.Overlays.Changelog private readonly SortedDictionary> categories = new SortedDictionary>(); - public delegate void BuildSelectedEventHandler(APIChangelogBuild build, EventArgs args); - - public event BuildSelectedEventHandler BuildSelected; + public event Action BuildSelected; public readonly FillFlowContainer ChangelogEntries; @@ -53,7 +51,7 @@ namespace osu.Game.Overlays.Changelog Size = new Vector2(24), Action = () => { - OnBuildSelected(build.Versions.Previous); + BuildSelected?.Invoke(build.Versions.Previous); chevronPrevious.IsEnabled = false; }, }, @@ -88,7 +86,7 @@ namespace osu.Game.Overlays.Changelog Size = new Vector2(24), Action = () => { - OnBuildSelected(build.Versions.Next); + BuildSelected?.Invoke(build.Versions.Next); chevronNext.IsEnabled = false; }, }, @@ -141,7 +139,7 @@ namespace osu.Game.Overlays.Changelog Origin = Anchor.TopCentre, AutoSizeAxes = Axes.Both, Margin = new MarginPadding { Top = 20 }, - Action = () => OnBuildSelected(build), + Action = () => BuildSelected?.Invoke(build), Child = new FillFlowContainer { Direction = FillDirection.Horizontal, @@ -179,7 +177,7 @@ namespace osu.Game.Overlays.Changelog clickableBuildText.FadeTo(0.5f, 500); Scheduler.AddDelayed(() => { - clickableBuildText.Action = () => OnBuildSelected(build); + clickableBuildText.Action = () => BuildSelected?.Invoke(build); clickableBuildText.FadeIn(500); }, 2000); }; @@ -200,11 +198,6 @@ namespace osu.Game.Overlays.Changelog } } - protected virtual void OnBuildSelected(APIChangelogBuild build) - { - BuildSelected?.Invoke(build, EventArgs.Empty); - } - public void GenerateText(List changelogEntries) { // sort entries by category diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index a571879192..2bf5f0336c 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -13,7 +13,6 @@ using osu.Game.Input.Bindings; using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.Changelog; -using System; using osuTK; using osuTK.Graphics; @@ -23,7 +22,7 @@ namespace osu.Game.Overlays { private ChangelogHeader header; - private BadgeDisplay badgeDisplay; + private BadgeDisplay badges; private ChangelogContent listing; private ChangelogContent content; @@ -32,7 +31,6 @@ namespace osu.Game.Overlays private SampleChannel sampleBack; - private bool isAtListing; private float savedScrollPosition; // receive input outside our bounds so we can trigger a close event on ourselves. @@ -66,7 +64,7 @@ namespace osu.Game.Overlays Children = new Drawable[] { header = new ChangelogHeader(), - badgeDisplay = new BadgeDisplay(), + badges = new BadgeDisplay(), listing = new ChangelogContent(), content = new ChangelogContent() }, @@ -75,9 +73,10 @@ namespace osu.Game.Overlays }; header.ListingSelected += ShowListing; - badgeDisplay.Selected += onBuildSelected; - listing.BuildSelected += onBuildSelected; - content.BuildSelected += onBuildSelected; + + badges.Selected += ShowBuild; + listing.BuildSelected += ShowBuild; + content.BuildSelected += ShowBuild; sampleBack = audio.Sample.Get(@"UI/generic-select-soft"); // @"UI/screen-back" feels non-fitting here } @@ -127,38 +126,29 @@ namespace osu.Game.Overlays return false; } - private void onBuildSelected(APIChangelogBuild build, EventArgs e) => FetchAndShowBuild(build); - private void fetchListing() { header.ShowListing(); - if (isAtListing) - return; - - isAtListing = true; var req = new GetChangelogRequest(); - badgeDisplay.SelectNone(); req.Success += res => { listing.ShowListing(res.Builds); - badgeDisplay.Populate(res.Streams); + badges.Populate(res.Streams); }; API.Queue(req); } + private bool isAtListing; + public void ShowListing() { + isAtListing = true; header.ShowListing(); - if (isAtListing) - return; - - isAtListing = true; content.Hide(); - listing.Show(); - badgeDisplay.SelectNone(); + badges.SelectNone(); listing.Show(); scroll.ScrollTo(savedScrollPosition); } @@ -169,9 +159,7 @@ namespace osu.Game.Overlays /// Must contain at least and /// . If and /// are specified, the header will instantly display them. - /// Whether to update badges. Should be set to false in case - /// the function is called by selecting a badge, to avoid an infinite loop. - public void FetchAndShowBuild(APIChangelogBuild build, bool updateBadges = true) + public void ShowBuild(APIChangelogBuild build) { var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); @@ -180,8 +168,7 @@ namespace osu.Game.Overlays else req.Success += res => header.ShowBuild(res.UpdateStream.DisplayName, res.DisplayVersion); - if (updateBadges) - badgeDisplay.SelectUpdateStream(build.UpdateStream.Name); + badges.SelectUpdateStream(build.UpdateStream.Name); req.Success += apiChangelog => { From 827ca445b1efa8f9180e7e83ef3ccb9d33442e06 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 15 May 2019 18:11:22 +0900 Subject: [PATCH 141/375] Remove unnecessary ReceivePositionalinputAt modification --- osu.Game/Overlays/ChangelogOverlay.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 2bf5f0336c..2b3fda39a4 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -13,7 +13,6 @@ using osu.Game.Input.Bindings; using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.Changelog; -using osuTK; using osuTK.Graphics; namespace osu.Game.Overlays @@ -33,9 +32,6 @@ namespace osu.Game.Overlays private float savedScrollPosition; - // receive input outside our bounds so we can trigger a close event on ourselves. - public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; - [BackgroundDependencyLoader] private void load(AudioManager audio, OsuColour colour) { From 1505ca976bc94a30967bba4c5dd66b1da74da59b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 15 May 2019 18:21:06 +0900 Subject: [PATCH 142/375] API request clean-up --- .../Requests/Responses/APIChangelogBuild.cs | 4 +-- osu.Game/Overlays/ChangelogOverlay.cs | 28 +++++++++++-------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs index 03c3ed0957..3377800c2b 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs @@ -31,9 +31,9 @@ namespace osu.Game.Online.API.Requests.Responses public List ChangelogEntries { get; set; } [JsonProperty("versions")] - public VersionNativation Versions { get; set; } + public VersionNatigation Versions { get; set; } - public class VersionNativation + public class VersionNatigation { [JsonProperty("next")] public APIChangelogBuild Next { get; set; } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 2b3fda39a4..ef049035c3 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -157,28 +157,32 @@ namespace osu.Game.Overlays /// are specified, the header will instantly display them. public void ShowBuild(APIChangelogBuild build) { - var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); - - if (build.UpdateStream.DisplayName != null && build.DisplayVersion != null) - header.ShowBuild(build.UpdateStream.DisplayName, build.DisplayVersion); - else - req.Success += res => header.ShowBuild(res.UpdateStream.DisplayName, res.DisplayVersion); - + header.ShowBuild(build.UpdateStream.DisplayName, build.DisplayVersion); badges.SelectUpdateStream(build.UpdateStream.Name); - req.Success += apiChangelog => + listing.Hide(); + + void displayBuild(APIChangelogBuild populatedBuild) { - listing.Hide(); content.Show(); - content.ShowBuild(apiChangelog); + content.ShowBuild(populatedBuild); + if (scroll.Current > scroll.GetChildPosInContent(content)) scroll.ScrollTo(content); + if (isAtListing) savedScrollPosition = scroll.Current; isAtListing = false; - }; + } - API.Queue(req); + if (build.Versions != null) + displayBuild(build); + else + { + var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); + req.Success += displayBuild; + API.Queue(req); + } } } } From 084ea3efa98734c6cb5deca2ae6b4ca3cdc22bd0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 15 May 2019 18:27:43 +0900 Subject: [PATCH 143/375] Fix another font usage case --- osu.Game/Overlays/Changelog/Header/BreadcrumbRelease.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Changelog/Header/BreadcrumbRelease.cs b/osu.Game/Overlays/Changelog/Header/BreadcrumbRelease.cs index 86000ea4d1..43711af61b 100644 --- a/osu.Game/Overlays/Changelog/Header/BreadcrumbRelease.cs +++ b/osu.Game/Overlays/Changelog/Header/BreadcrumbRelease.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Graphics.Colour; +using osu.Game.Graphics; namespace osu.Game.Overlays.Changelog.Header { @@ -12,7 +13,7 @@ namespace osu.Game.Overlays.Changelog.Header public BreadcrumbRelease(ColourInfo badgeColour, string displayText) : base(badgeColour, displayText) { - Text.Font = "Exo2.0-Bold"; + Text.Font = Text.Font.With(weight: FontWeight.Bold); Text.Y = 20; Text.Alpha = 0; } From 19a179db923aa9aad5f13f37fd24112baada60be Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 15 May 2019 18:30:02 +0900 Subject: [PATCH 144/375] Bring up-to-date with master --- .../TestSceneChangelogOverlay.cs} | 4 ++-- .../TestSceneLineBadge.cs} | 6 +++--- .../TestSceneTextBadgePair.cs} | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) rename osu.Game.Tests/Visual/{TestCaseChangelogOverlay.cs => Online/TestSceneChangelogOverlay.cs} (92%) rename osu.Game.Tests/Visual/{TestCaseLineBadge.cs => UserInterface/TestSceneLineBadge.cs} (92%) rename osu.Game.Tests/Visual/{TestCaseTextBadgePair.cs => UserInterface/TestSceneTextBadgePair.cs} (92%) diff --git a/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs similarity index 92% rename from osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs rename to osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs index 89b4fd2d18..7ad410ac71 100644 --- a/osu.Game.Tests/Visual/TestCaseChangelogOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs @@ -5,10 +5,10 @@ using NUnit.Framework; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays; -namespace osu.Game.Tests.Visual +namespace osu.Game.Tests.Visual.Online { [TestFixture] - public class TestCaseChangelogOverlay : OsuTestCase + public class TestSceneChangelogOverlay : OsuTestScene { private ChangelogOverlay changelog; diff --git a/osu.Game.Tests/Visual/TestCaseLineBadge.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneLineBadge.cs similarity index 92% rename from osu.Game.Tests/Visual/TestCaseLineBadge.cs rename to osu.Game.Tests/Visual/UserInterface/TestSceneLineBadge.cs index ae94767640..9f80cd40cf 100644 --- a/osu.Game.Tests/Visual/TestCaseLineBadge.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneLineBadge.cs @@ -7,11 +7,11 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Graphics.UserInterface; using osuTK.Graphics; -namespace osu.Game.Tests.Visual +namespace osu.Game.Tests.Visual.UserInterface { - public class TestCaseLineBadge : OsuTestCase + public class TestSceneLineBadge : OsuTestScene { - public TestCaseLineBadge() + public TestSceneLineBadge() { Container container; LineBadge lineBadge; diff --git a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneTextBadgePair.cs similarity index 92% rename from osu.Game.Tests/Visual/TestCaseTextBadgePair.cs rename to osu.Game.Tests/Visual/UserInterface/TestSceneTextBadgePair.cs index 2f7ab5deba..67b2b9854d 100644 --- a/osu.Game.Tests/Visual/TestCaseTextBadgePair.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneTextBadgePair.cs @@ -8,11 +8,11 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Overlays.Changelog.Header; using osuTK.Graphics; -namespace osu.Game.Tests.Visual +namespace osu.Game.Tests.Visual.UserInterface { - public class TestCaseTextBadgePair : OsuTestCase + public class TestSceneTextBadgePair : OsuTestScene { - public TestCaseTextBadgePair() + public TestSceneTextBadgePair() { Breadcrumb breadcrumb; From 409d89eecf1d6baff6aafaffe7b7d36934ea9ecc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 May 2019 18:53:20 +0900 Subject: [PATCH 145/375] Match header titles with web (pt size) --- .../Graphics/UserInterface/ScreenTitle.cs | 4 ++-- .../Changelog/ChangelogContentGroup.cs | 20 +++++++++---------- .../Overlays/Changelog/ChangelogHeader.cs | 4 ++-- .../Overlays/Changelog/Header/Breadcrumb.cs | 2 +- osu.Game/Overlays/Changelog/StreamBadge.cs | 6 +++--- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/ScreenTitle.cs b/osu.Game/Graphics/UserInterface/ScreenTitle.cs index b9d9b5427d..34c70f2bed 100644 --- a/osu.Game/Graphics/UserInterface/ScreenTitle.cs +++ b/osu.Game/Graphics/UserInterface/ScreenTitle.cs @@ -66,11 +66,11 @@ namespace osu.Game.Graphics.UserInterface { titleText = new OsuSpriteText { - Font = OsuFont.GetFont(size: 25), + Font = OsuFont.GetFont(size: 30, weight: FontWeight.Light), }, pageText = new OsuSpriteText { - Font = OsuFont.GetFont(size: 25), + Font = OsuFont.GetFont(size: 30, weight: FontWeight.Light), } } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 1b03ade7e0..9f3da7eade 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -64,17 +64,17 @@ namespace osu.Game.Overlays.Changelog new SpriteText { Text = build.UpdateStream.DisplayName, - Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 28), // web: 24, + Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 24), }, new SpriteText { Text = " ", - Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 28), // web: 24, + Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 24), }, new SpriteText { Text = build.DisplayVersion, - Font = OsuFont.GetFont(weight: FontWeight.Light, size: 28), // web: 24, + Font = OsuFont.GetFont(weight: FontWeight.Light, size: 24), Colour = StreamColour.FromStreamName(build.UpdateStream.Name), }, } @@ -97,7 +97,7 @@ namespace osu.Game.Overlays.Changelog // do we need .ToUniversalTime() here? // also, this should be a temporary solution to weekdays in >localized< date strings Text = build.CreatedAt.Date.ToLongDateString().Replace(build.CreatedAt.ToString("dddd") + ", ", ""), - Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 17), // web: 14, + Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 14), Colour = OsuColour.FromHex(@"FD5"), Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, @@ -126,7 +126,7 @@ namespace osu.Game.Overlays.Changelog // do we need .ToUniversalTime() here? // also, this should be a temporary solution to weekdays in >localized< date strings Text = build.CreatedAt.Date.ToLongDateString().Replace(build.CreatedAt.ToString("dddd") + ", ", ""), - Font = OsuFont.GetFont(weight: FontWeight.Light, size: 28), // web: 24, + Font = OsuFont.GetFont(weight: FontWeight.Light, size: 24), Colour = OsuColour.FromHex(@"FD5"), Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, @@ -150,12 +150,12 @@ namespace osu.Game.Overlays.Changelog new SpriteText { Text = build.UpdateStream.DisplayName, - Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 20), // web: 19, + Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 19), }, new SpriteText { Text = build.DisplayVersion, - Font = OsuFont.GetFont(weight: FontWeight.Light, size: 20), // web: 19, + Font = OsuFont.GetFont(weight: FontWeight.Light, size: 19), Colour = StreamColour.FromStreamName(build.UpdateStream.Name), }, }, @@ -214,7 +214,7 @@ namespace osu.Game.Overlays.Changelog ChangelogEntries.Add(new SpriteText { Text = category.Key, - Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 24), // web: 24, + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 24), Margin = new MarginPadding { Top = 35, Bottom = 15 }, }); @@ -252,7 +252,7 @@ namespace osu.Game.Overlays.Changelog Online.Chat.LinkAction.External, null, null, t => t.Font = OsuFont.GetFont(size: 14)); else - title.AddText(entry.GithubUser.DisplayName, t => t.Font = OsuFont.GetFont(size: 14)); //web: 12; + title.AddText(entry.GithubUser.DisplayName, t => t.Font = OsuFont.GetFont(size: 12)); ChangelogEntries.Add(title); @@ -267,7 +267,7 @@ namespace osu.Game.Overlays.Changelog // todo: use markdown parsing once API returns markdown messageContainer.AddText(Regex.Replace(entry.MessageHtml, @"<(.|\n)*?>", string.Empty), t => { - t.Font = OsuFont.GetFont(size: 14); // web: 12, + t.Font = OsuFont.GetFont(size: 12); t.Colour = new Color4(235, 184, 254, 255); }); diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 4186356bd4..c2a341cfe8 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -108,12 +108,12 @@ namespace osu.Game.Overlays.Changelog new OsuSpriteText { Text = "Changelog ", - Font = OsuFont.GetFont(weight: FontWeight.Light, size: 38), // web: 30, + Font = OsuFont.GetFont(weight: FontWeight.Light, size: 30), }, titleStream = new OsuSpriteText { Text = "Listing", - Font = OsuFont.GetFont(weight: FontWeight.Light, size: 38), // web: 30, + Font = OsuFont.GetFont(weight: FontWeight.Light, size: 30), Colour = colours.Violet, }, } diff --git a/osu.Game/Overlays/Changelog/Header/Breadcrumb.cs b/osu.Game/Overlays/Changelog/Header/Breadcrumb.cs index 43dcaf22ca..ae902043e3 100644 --- a/osu.Game/Overlays/Changelog/Header/Breadcrumb.cs +++ b/osu.Game/Overlays/Changelog/Header/Breadcrumb.cs @@ -35,7 +35,7 @@ namespace osu.Game.Overlays.Changelog.Header { Text = new SpriteText { - Font = OsuFont.GetFont(size: 21), // web: 16, + Font = OsuFont.GetFont(size: 16), Text = displayText, Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index b617ae8f53..721689c75d 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -56,18 +56,18 @@ namespace osu.Game.Overlays.Changelog new SpriteText { Text = stream.DisplayName, - Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14), // web: 12, + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 12), Margin = new MarginPadding { Top = 6 }, }, new SpriteText { Text = stream.LatestBuild.DisplayVersion, - Font = OsuFont.GetFont(weight: FontWeight.Light, size: 20), // web: 16, + Font = OsuFont.GetFont(weight: FontWeight.Light, size: 16), }, new SpriteText { Text = stream.LatestBuild.Users > 0 ? $"{stream.LatestBuild.Users:N0} users online" : null, - Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 12), // web: 10, + Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 10), Colour = new Color4(203, 164, 218, 255), }, } From 880bfe9b6b4037866d17460d5e3afbebded8bb9b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 May 2019 10:29:27 +0900 Subject: [PATCH 146/375] Move resources to osu-resources --- osu.Game/Overlays/Changelog/ChangelogHeader.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index c2a341cfe8..7502ef1773 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.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.Allocation; @@ -50,7 +50,7 @@ namespace osu.Game.Overlays.Changelog new Sprite { RelativeSizeAxes = Axes.Both, - Texture = textures.Get(@"https://osu.ppy.sh/images/headers/changelog.jpg"), + Texture = textures.Get(@"Headers/changelog"), FillMode = FillMode.Fill, }, } @@ -76,8 +76,7 @@ namespace osu.Game.Overlays.Changelog new Sprite { RelativeSizeAxes = Axes.Both, - // todo: https://osu.ppy.sh/images/icons/changelog.svg - Texture = textures.Get(@"https://i.imgur.com/HQM3Vhp.png"), + Texture = textures.Get(@"Icons/changelog"), Size = new Vector2(0.8f), Anchor = Anchor.Centre, Origin = Anchor.Centre, From e94b9feebd04c8f56f6df087e56607c0814bd97a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 May 2019 10:29:43 +0900 Subject: [PATCH 147/375] Fix dynamic recompilation in TestSceneChangelogOverlay --- .../Visual/Online/TestSceneChangelogOverlay.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs index 7ad410ac71..0e4f31c217 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs @@ -1,9 +1,13 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; +using System.Collections.Generic; using NUnit.Framework; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays; +using osu.Game.Overlays.Changelog; +using osu.Game.Overlays.Changelog.Header; namespace osu.Game.Tests.Visual.Online { @@ -12,6 +16,18 @@ namespace osu.Game.Tests.Visual.Online { private ChangelogOverlay changelog; + public override IReadOnlyList RequiredTypes => new[] + { + typeof(BadgeDisplay), + typeof(StreamBadge), + typeof(ChangelogHeader), + typeof(ChangelogContent), + typeof(ChangelogContentGroup), + typeof(Breadcrumb), + typeof(BreadcrumbListing), + typeof(BreadcrumbRelease), + }; + protected override void LoadComplete() { base.LoadComplete(); From e606c7332931f3af3a9d58d85c882c6f62603ffe Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 May 2019 11:43:36 +0900 Subject: [PATCH 148/375] Convert BadgeDisplay to use bindable --- osu.Game/Overlays/Changelog/BadgeDisplay.cs | 66 +++++-------------- .../Overlays/Changelog/ChangelogHeader.cs | 11 +--- osu.Game/Overlays/Changelog/StreamBadge.cs | 6 +- osu.Game/Overlays/ChangelogOverlay.cs | 15 ++++- 4 files changed, 36 insertions(+), 62 deletions(-) diff --git a/osu.Game/Overlays/Changelog/BadgeDisplay.cs b/osu.Game/Overlays/Changelog/BadgeDisplay.cs index 8c58decf49..e04624cfcb 100644 --- a/osu.Game/Overlays/Changelog/BadgeDisplay.cs +++ b/osu.Game/Overlays/Changelog/BadgeDisplay.cs @@ -6,8 +6,8 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; using osu.Game.Online.API.Requests.Responses; -using System; using System.Collections.Generic; +using osu.Framework.Bindables; using osuTK.Graphics; namespace osu.Game.Overlays.Changelog @@ -17,10 +17,9 @@ namespace osu.Game.Overlays.Changelog private const float vertical_padding = 20; private const float horizontal_padding = 85; - public event Action Selected; + public readonly Bindable Current = new Bindable(); private readonly FillFlowContainer badgesContainer; - private long selectedStreamId = -1; public BadgeDisplay() { @@ -40,23 +39,34 @@ namespace osu.Game.Overlays.Changelog Padding = new MarginPadding { Vertical = vertical_padding, Horizontal = horizontal_padding }, }, }; + + Current.ValueChanged += e => + { + foreach (StreamBadge streamBadge in badgesContainer) + { + if (!IsHovered || e.NewValue.Id == streamBadge.Stream.Id) + streamBadge.Activate(); + else + streamBadge.Deactivate(); + } + }; } public void Populate(List streams) { - SelectNone(); + Current.Value = null; foreach (APIUpdateStream updateStream in streams) { var streamBadge = new StreamBadge(updateStream); - streamBadge.Selected += onBadgeSelected; + streamBadge.Selected += () => Current.Value = updateStream; badgesContainer.Add(streamBadge); } } public void SelectNone() { - selectedStreamId = -1; + Current.Value = null; if (badgesContainer != null) { @@ -70,45 +80,10 @@ namespace osu.Game.Overlays.Changelog } } - public void SelectUpdateStream(string updateStream) - { - foreach (StreamBadge streamBadge in badgesContainer) - { - if (streamBadge.Stream.Name == updateStream) - { - selectedStreamId = streamBadge.Stream.Id; - streamBadge.Activate(); - } - else - streamBadge.Deactivate(); - } - } - - private void onBadgeSelected(StreamBadge source, EventArgs args) - { - selectedStreamId = source.Stream.Id; - OnSelected(source); - } - - protected virtual void OnSelected(StreamBadge source) - { - Selected?.Invoke(source.Stream.LatestBuild); - } - protected override bool OnHover(HoverEvent e) { foreach (StreamBadge streamBadge in badgesContainer.Children) - { - if (selectedStreamId >= 0) - { - if (selectedStreamId != streamBadge.Stream.Id) - streamBadge.Deactivate(); - else - streamBadge.EnableDim(); - } - else - streamBadge.Deactivate(); - } + streamBadge.EnableDim(); return base.OnHover(e); } @@ -116,12 +91,7 @@ namespace osu.Game.Overlays.Changelog protected override void OnHoverLost(HoverLostEvent e) { foreach (StreamBadge streamBadge in badgesContainer.Children) - { - if (selectedStreamId < 0) - streamBadge.Activate(); - else if (streamBadge.Stream.Id == selectedStreamId) - streamBadge.DisableDim(); - } + streamBadge.DisableDim(); base.OnHoverLost(e); } diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 7502ef1773..94046d5762 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.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.Allocation; @@ -81,18 +81,13 @@ namespace osu.Game.Overlays.Changelog Anchor = Anchor.Centre, Origin = Anchor.Centre, }, - - // this box has 2 functions: - // - ensures the circle doesn't disappear on the X and Y edges - // - gets rid of the white "contamination" on the circle (due to smoothing) - // (https://i.imgur.com/SMuvWBZ.png) new Box { RelativeSizeAxes = Axes.Both, + Colour = colours.Violet, Alpha = 0, AlwaysPresent = true, - Colour = colours.Violet, - } + }, } }, new FillFlowContainer diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 721689c75d..2be6aba926 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -22,9 +22,7 @@ namespace osu.Game.Overlays.Changelog private const float badge_width = 100; private const float transition_duration = 100; - public delegate void SelectedHandler(StreamBadge source, EventArgs args); - - public event SelectedHandler Selected; + public event Action Selected; private bool isActivated; @@ -90,7 +88,7 @@ namespace osu.Game.Overlays.Changelog this.FadeIn(transition_duration); lineBadge.Uncollapse(); if (!withoutFiringUpdates) - Selected?.Invoke(this, EventArgs.Empty); + Selected?.Invoke(); } public void Deactivate() diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index ef049035c3..71393141bd 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -70,7 +70,8 @@ namespace osu.Game.Overlays header.ListingSelected += ShowListing; - badges.Selected += ShowBuild; + // todo: better + badges.Current.ValueChanged += e => ShowBuild(e.NewValue.LatestBuild); listing.BuildSelected += ShowBuild; content.BuildSelected += ShowBuild; @@ -129,6 +130,10 @@ namespace osu.Game.Overlays var req = new GetChangelogRequest(); req.Success += res => { + // remap streams to builds to ensure model equality + res.Builds.ForEach(b => b.UpdateStream = res.Streams.Find(s => s.Id == b.UpdateStream.Id)); + res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id)); + listing.ShowListing(res.Builds); badges.Populate(res.Streams); }; @@ -157,8 +162,14 @@ namespace osu.Game.Overlays /// are specified, the header will instantly display them. public void ShowBuild(APIChangelogBuild build) { + if (build == null) + { + ShowListing(); + return; + } + header.ShowBuild(build.UpdateStream.DisplayName, build.DisplayVersion); - badges.SelectUpdateStream(build.UpdateStream.Name); + badges.Current.Value = build.UpdateStream; listing.Hide(); From 37e989fc64351f181bf6d0b8152e213375e05599 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 May 2019 12:40:15 +0900 Subject: [PATCH 149/375] fixup! Convert BadgeDisplay to use bindable --- .../API/Requests/Responses/APIUpdateStream.cs | 11 ++++++++++- osu.Game/Overlays/Changelog/BadgeDisplay.cs | 16 ---------------- osu.Game/Overlays/ChangelogOverlay.cs | 9 +++++++-- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs b/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs index 5cf56333bb..25f1a413d6 100644 --- a/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs +++ b/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs @@ -1,11 +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 System; using Newtonsoft.Json; namespace osu.Game.Online.API.Requests.Responses { - public class APIUpdateStream + public class APIUpdateStream : IEquatable { [JsonProperty("id")] public long Id { get; set; } @@ -21,5 +22,13 @@ namespace osu.Game.Online.API.Requests.Responses [JsonProperty("latest_build")] public APIChangelogBuild LatestBuild { get; set; } + + public bool Equals(APIUpdateStream other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return Id == other.Id; + } } } diff --git a/osu.Game/Overlays/Changelog/BadgeDisplay.cs b/osu.Game/Overlays/Changelog/BadgeDisplay.cs index e04624cfcb..9b0f152eb0 100644 --- a/osu.Game/Overlays/Changelog/BadgeDisplay.cs +++ b/osu.Game/Overlays/Changelog/BadgeDisplay.cs @@ -64,22 +64,6 @@ namespace osu.Game.Overlays.Changelog } } - public void SelectNone() - { - Current.Value = null; - - if (badgesContainer != null) - { - foreach (StreamBadge streamBadge in badgesContainer) - { - if (!IsHovered) - streamBadge.Activate(); - else - streamBadge.Deactivate(); - } - } - } - protected override bool OnHover(HoverEvent e) { foreach (StreamBadge streamBadge in badgesContainer.Children) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 71393141bd..17a2441a9e 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -71,7 +71,12 @@ namespace osu.Game.Overlays header.ListingSelected += ShowListing; // todo: better - badges.Current.ValueChanged += e => ShowBuild(e.NewValue.LatestBuild); + badges.Current.ValueChanged += e => + { + if (e.NewValue?.LatestBuild != null) + ShowBuild(e.NewValue.LatestBuild); + }; + listing.BuildSelected += ShowBuild; content.BuildSelected += ShowBuild; @@ -149,7 +154,7 @@ namespace osu.Game.Overlays header.ShowListing(); content.Hide(); - badges.SelectNone(); + badges.Current.Value = null; listing.Show(); scroll.ScrollTo(savedScrollPosition); } From 876f108e0a035ff9d4b901c5849fc59c30906dc9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 May 2019 12:42:08 +0900 Subject: [PATCH 150/375] Remove custom scroll logic --- osu.Game/Overlays/ChangelogOverlay.cs | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 17a2441a9e..afa4f4185e 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -26,12 +26,8 @@ namespace osu.Game.Overlays private ChangelogContent listing; private ChangelogContent content; - private ScrollContainer scroll; - private SampleChannel sampleBack; - private float savedScrollPosition; - [BackgroundDependencyLoader] private void load(AudioManager audio, OsuColour colour) { @@ -48,7 +44,7 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.Both, Colour = new Color4(49, 36, 54, 255), }, - scroll = new ScrollContainer + new ScrollContainer { RelativeSizeAxes = Axes.Both, ScrollbarVisible = false, @@ -106,15 +102,9 @@ namespace osu.Game.Overlays switch (action) { case GlobalAction.Back: - if (isAtListing) + if (listing.Alpha == 1) { - if (scroll.Current > scroll.GetChildPosInContent(listing)) - { - scroll.ScrollTo(0); - sampleBack?.Play(); - } - else - State = Visibility.Hidden; + State = Visibility.Hidden; } else { @@ -146,17 +136,13 @@ namespace osu.Game.Overlays API.Queue(req); } - private bool isAtListing; - public void ShowListing() { - isAtListing = true; header.ShowListing(); content.Hide(); badges.Current.Value = null; listing.Show(); - scroll.ScrollTo(savedScrollPosition); } /// @@ -182,13 +168,6 @@ namespace osu.Game.Overlays { content.Show(); content.ShowBuild(populatedBuild); - - if (scroll.Current > scroll.GetChildPosInContent(content)) - scroll.ScrollTo(content); - - if (isAtListing) - savedScrollPosition = scroll.Current; - isAtListing = false; } if (build.Versions != null) From dd2d58d4f7c64726cd4ef1b277954d83ad55912c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 May 2019 17:15:51 +0900 Subject: [PATCH 151/375] Split out ChangelogContent into two classes --- osu.Game/Overlays/Changelog/ChangelogBuild.cs | 30 ++++++++ .../Overlays/Changelog/ChangelogContent.cs | 60 +--------------- .../Overlays/Changelog/ChangelogListing.cs | 70 +++++++++++++++++++ osu.Game/Overlays/ChangelogOverlay.cs | 37 +++++----- 4 files changed, 118 insertions(+), 79 deletions(-) create mode 100644 osu.Game/Overlays/Changelog/ChangelogBuild.cs create mode 100644 osu.Game/Overlays/Changelog/ChangelogListing.cs diff --git a/osu.Game/Overlays/Changelog/ChangelogBuild.cs b/osu.Game/Overlays/Changelog/ChangelogBuild.cs new file mode 100644 index 0000000000..0f3e76021b --- /dev/null +++ b/osu.Game/Overlays/Changelog/ChangelogBuild.cs @@ -0,0 +1,30 @@ +// 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.Game.Online.API.Requests.Responses; + +namespace osu.Game.Overlays.Changelog +{ + public class ChangelogBuild : ChangelogContent + { + private readonly APIChangelogBuild changelogBuild; + + public ChangelogBuild(APIChangelogBuild changelogBuild) + { + this.changelogBuild = changelogBuild; + } + + [BackgroundDependencyLoader] + private void load() + { + var changelogContentGroup = new ChangelogContentGroup(changelogBuild); + changelogContentGroup.GenerateText(changelogBuild.ChangelogEntries); + changelogContentGroup.UpdateChevronTooltips(changelogBuild.Versions.Previous?.DisplayVersion, + changelogBuild.Versions.Next?.DisplayVersion); + changelogContentGroup.BuildSelected += SelectBuild; + + Add(changelogContentGroup); + } + } +} diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 45fb98add0..92c33567a8 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -3,20 +3,17 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; using osu.Game.Online.API.Requests.Responses; using System; -using System.Collections.Generic; -using osuTK.Graphics; namespace osu.Game.Overlays.Changelog { public class ChangelogContent : FillFlowContainer { - private ChangelogContentGroup changelogContentGroup; - public event Action BuildSelected; + public void SelectBuild(APIChangelogBuild build) => BuildSelected?.Invoke(build); + public ChangelogContent() { RelativeSizeAxes = Axes.X; @@ -24,58 +21,5 @@ namespace osu.Game.Overlays.Changelog Direction = FillDirection.Vertical; Padding = new MarginPadding { Bottom = 100 }; } - - public void ShowListing(List changelog) - { - DateTime currentDate = new DateTime(); - Clear(); - - foreach (APIChangelogBuild build in changelog) - { - if (build.CreatedAt.Date != currentDate) - { - if (Children.Count != 0) - { - Add(new Box - { - RelativeSizeAxes = Axes.X, - Height = 2, - Colour = new Color4(17, 17, 17, 255), - Margin = new MarginPadding { Top = 30 }, - }); - } - - changelogContentGroup = new ChangelogContentGroup(build, true); - changelogContentGroup.BuildSelected += b => BuildSelected?.Invoke(b); - changelogContentGroup.GenerateText(build.ChangelogEntries); - Add(changelogContentGroup); - currentDate = build.CreatedAt.Date; - } - else - { - changelogContentGroup.Add(new Box - { - RelativeSizeAxes = Axes.X, - Height = 1, - Colour = new Color4(32, 24, 35, 255), - Margin = new MarginPadding { Top = 30 }, - }); - - changelogContentGroup = new ChangelogContentGroup(build, false); - changelogContentGroup.BuildSelected += b => BuildSelected?.Invoke(b); - changelogContentGroup.GenerateText(build.ChangelogEntries); - Add(changelogContentGroup); - } - } - } - - public void ShowBuild(APIChangelogBuild changelogBuild) - { - Child = changelogContentGroup = new ChangelogContentGroup(changelogBuild); - changelogContentGroup.GenerateText(changelogBuild.ChangelogEntries); - changelogContentGroup.UpdateChevronTooltips(changelogBuild.Versions.Previous?.DisplayVersion, - changelogBuild.Versions.Next?.DisplayVersion); - changelogContentGroup.BuildSelected += b => BuildSelected?.Invoke(b); - } } } diff --git a/osu.Game/Overlays/Changelog/ChangelogListing.cs b/osu.Game/Overlays/Changelog/ChangelogListing.cs new file mode 100644 index 0000000000..8e615d1dc9 --- /dev/null +++ b/osu.Game/Overlays/Changelog/ChangelogListing.cs @@ -0,0 +1,70 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Collections.Generic; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Shapes; +using osu.Game.Online.API.Requests.Responses; +using osuTK.Graphics; + +namespace osu.Game.Overlays.Changelog +{ + public class ChangelogListing : ChangelogContent + { + private readonly List entries; + + public ChangelogListing(List entries) + { + this.entries = entries; + } + + [BackgroundDependencyLoader] + private void load() + { + DateTime currentDate = new DateTime(); + Clear(); + + ChangelogContentGroup changelogContentGroup = null; + + foreach (APIChangelogBuild build in entries) + { + if (build.CreatedAt.Date != currentDate) + { + if (Children.Count != 0) + { + Add(new Box + { + RelativeSizeAxes = Axes.X, + Height = 2, + Colour = new Color4(17, 17, 17, 255), + Margin = new MarginPadding { Top = 30 }, + }); + } + + changelogContentGroup = new ChangelogContentGroup(build, true); + changelogContentGroup.BuildSelected += SelectBuild; + changelogContentGroup.GenerateText(build.ChangelogEntries); + Add(changelogContentGroup); + currentDate = build.CreatedAt.Date; + } + else + { + changelogContentGroup?.Add(new Box + { + RelativeSizeAxes = Axes.X, + Height = 1, + Colour = new Color4(32, 24, 35, 255), + Margin = new MarginPadding { Top = 30 }, + }); + + changelogContentGroup = new ChangelogContentGroup(build, false); + changelogContentGroup.BuildSelected += SelectBuild; + changelogContentGroup.GenerateText(build.ChangelogEntries); + Add(changelogContentGroup); + } + } + } + } +} diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index afa4f4185e..6ef239733d 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.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.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -23,15 +24,15 @@ namespace osu.Game.Overlays private BadgeDisplay badges; - private ChangelogContent listing; - private ChangelogContent content; + private Container content; private SampleChannel sampleBack; + private List builds; + [BackgroundDependencyLoader] private void load(AudioManager audio, OsuColour colour) { - // these possibly need adjusting? Waves.FirstWaveColour = colour.Violet; Waves.SecondWaveColour = OsuColour.FromHex(@"8F03BF"); Waves.ThirdWaveColour = OsuColour.FromHex(@"600280"); @@ -57,8 +58,11 @@ namespace osu.Game.Overlays { header = new ChangelogHeader(), badges = new BadgeDisplay(), - listing = new ChangelogContent(), - content = new ChangelogContent() + content = new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + } }, }, }, @@ -73,10 +77,7 @@ namespace osu.Game.Overlays ShowBuild(e.NewValue.LatestBuild); }; - listing.BuildSelected += ShowBuild; - content.BuildSelected += ShowBuild; - - sampleBack = audio.Sample.Get(@"UI/generic-select-soft"); // @"UI/screen-back" feels non-fitting here + sampleBack = audio.Sample.Get(@"UI/generic-select-soft"); } protected override void LoadComplete() @@ -102,7 +103,7 @@ namespace osu.Game.Overlays switch (action) { case GlobalAction.Back: - if (listing.Alpha == 1) + if (content.Child is ChangelogContent) { State = Visibility.Hidden; } @@ -129,7 +130,8 @@ namespace osu.Game.Overlays res.Builds.ForEach(b => b.UpdateStream = res.Streams.Find(s => s.Id == b.UpdateStream.Id)); res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id)); - listing.ShowListing(res.Builds); + builds = res.Builds; + ShowListing(); badges.Populate(res.Streams); }; @@ -139,10 +141,8 @@ namespace osu.Game.Overlays public void ShowListing() { header.ShowListing(); - - content.Hide(); badges.Current.Value = null; - listing.Show(); + content.Child = new ChangelogListing(builds); } /// @@ -162,13 +162,8 @@ namespace osu.Game.Overlays header.ShowBuild(build.UpdateStream.DisplayName, build.DisplayVersion); badges.Current.Value = build.UpdateStream; - listing.Hide(); - - void displayBuild(APIChangelogBuild populatedBuild) - { - content.Show(); - content.ShowBuild(populatedBuild); - } + void displayBuild(APIChangelogBuild populatedBuild) => + content.Child = new ChangelogBuild(populatedBuild); if (build.Versions != null) displayBuild(build); From c5c1896a11e9acebe93e30b57ae7d43e6f374f07 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 May 2019 17:20:50 +0900 Subject: [PATCH 152/375] Use new colour palette --- osu.Game/Overlays/ChangelogOverlay.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 6ef239733d..c9a9aee895 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -33,10 +33,10 @@ namespace osu.Game.Overlays [BackgroundDependencyLoader] private void load(AudioManager audio, OsuColour colour) { - Waves.FirstWaveColour = colour.Violet; - Waves.SecondWaveColour = OsuColour.FromHex(@"8F03BF"); - Waves.ThirdWaveColour = OsuColour.FromHex(@"600280"); - Waves.FourthWaveColour = OsuColour.FromHex(@"300140"); + Waves.FirstWaveColour = colour.GreyVioletLight; + Waves.SecondWaveColour = colour.GreyViolet; + Waves.ThirdWaveColour = colour.GreyVioletDark; + Waves.FourthWaveColour = colour.GreyVioletDarker; Children = new Drawable[] { From c41ec20236a7c57da0a62dfc53bd162c49e6abad Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 May 2019 17:47:28 +0900 Subject: [PATCH 153/375] Improve load and switch logic between views --- .../Online/TestSceneChangelogOverlay.cs | 2 + osu.Game/Overlays/Changelog/ChangelogBuild.cs | 24 +++++- .../Overlays/Changelog/ChangelogContent.cs | 2 +- osu.Game/Overlays/ChangelogOverlay.cs | 75 +++++++++++-------- 4 files changed, 68 insertions(+), 35 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs index 0e4f31c217..e1cb6e6a85 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs @@ -22,6 +22,8 @@ namespace osu.Game.Tests.Visual.Online typeof(StreamBadge), typeof(ChangelogHeader), typeof(ChangelogContent), + typeof(ChangelogListing), + typeof(ChangelogBuild), typeof(ChangelogContentGroup), typeof(Breadcrumb), typeof(BreadcrumbListing), diff --git a/osu.Game/Overlays/Changelog/ChangelogBuild.cs b/osu.Game/Overlays/Changelog/ChangelogBuild.cs index 0f3e76021b..0af117c11e 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBuild.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBuild.cs @@ -1,14 +1,18 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Threading; +using System.Threading.Tasks; using osu.Framework.Allocation; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Overlays.Changelog { public class ChangelogBuild : ChangelogContent { - private readonly APIChangelogBuild changelogBuild; + private APIChangelogBuild changelogBuild; public ChangelogBuild(APIChangelogBuild changelogBuild) { @@ -16,8 +20,24 @@ namespace osu.Game.Overlays.Changelog } [BackgroundDependencyLoader] - private void load() + private void load(CancellationToken? cancellation, IAPIProvider api) { + var req = new GetChangelogBuildRequest(changelogBuild.UpdateStream.Name, changelogBuild.Version); + bool complete = false; + + req.Success += res => + { + changelogBuild = res; + complete = true; + }; + + req.Failure += _ => complete = true; + + api.Queue(req); + + while (!complete && cancellation?.IsCancellationRequested != true) + Task.Delay(1); + var changelogContentGroup = new ChangelogContentGroup(changelogBuild); changelogContentGroup.GenerateText(changelogBuild.ChangelogEntries); changelogContentGroup.UpdateChevronTooltips(changelogBuild.Versions.Previous?.DisplayVersion, diff --git a/osu.Game/Overlays/Changelog/ChangelogContent.cs b/osu.Game/Overlays/Changelog/ChangelogContent.cs index 92c33567a8..f8d5bbd66c 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContent.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContent.cs @@ -10,7 +10,7 @@ namespace osu.Game.Overlays.Changelog { public class ChangelogContent : FillFlowContainer { - public event Action BuildSelected; + public Action BuildSelected; public void SelectBuild(APIChangelogBuild build) => BuildSelected?.Invoke(build); diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index c9a9aee895..b8449f618d 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -2,6 +2,8 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; +using System.Linq; +using System.Threading; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -24,7 +26,7 @@ namespace osu.Game.Overlays private BadgeDisplay badges; - private Container content; + private Container content; private SampleChannel sampleBack; @@ -58,7 +60,7 @@ namespace osu.Game.Overlays { header = new ChangelogHeader(), badges = new BadgeDisplay(), - content = new Container + content = new Container { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, @@ -103,7 +105,7 @@ namespace osu.Game.Overlays switch (action) { case GlobalAction.Back: - if (content.Child is ChangelogContent) + if (content.Child is ChangelogListing) { State = Visibility.Hidden; } @@ -119,30 +121,14 @@ namespace osu.Game.Overlays return false; } - private void fetchListing() - { - header.ShowListing(); - - var req = new GetChangelogRequest(); - req.Success += res => - { - // remap streams to builds to ensure model equality - res.Builds.ForEach(b => b.UpdateStream = res.Streams.Find(s => s.Id == b.UpdateStream.Id)); - res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id)); - - builds = res.Builds; - ShowListing(); - badges.Populate(res.Streams); - }; - - API.Queue(req); - } - public void ShowListing() { + if (content.Children.FirstOrDefault() is ChangelogListing) + return; + header.ShowListing(); badges.Current.Value = null; - content.Child = new ChangelogListing(builds); + loadContent(new ChangelogListing(builds)); } /// @@ -162,17 +148,42 @@ namespace osu.Game.Overlays header.ShowBuild(build.UpdateStream.DisplayName, build.DisplayVersion); badges.Current.Value = build.UpdateStream; - void displayBuild(APIChangelogBuild populatedBuild) => - content.Child = new ChangelogBuild(populatedBuild); + loadContent(new ChangelogBuild(build)); + } - if (build.Versions != null) - displayBuild(build); - else + private void fetchListing() + { + var req = new GetChangelogRequest(); + req.Success += res => { - var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); - req.Success += displayBuild; - API.Queue(req); - } + // remap streams to builds to ensure model equality + res.Builds.ForEach(b => b.UpdateStream = res.Streams.Find(s => s.Id == b.UpdateStream.Id)); + res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id)); + + builds = res.Builds; + badges.Populate(res.Streams); + + ShowListing(); + }; + + API.Queue(req); + } + + private CancellationTokenSource loadContentTask; + + private void loadContent(ChangelogContent newContent) + { + content.FadeTo(0.2f, 300, Easing.OutQuint); + + loadContentTask?.Cancel(); + + LoadComponentAsync(newContent, c => + { + content.FadeIn(300, Easing.OutQuint); + + c.BuildSelected = ShowBuild; + content.Child = c; + }, (loadContentTask = new CancellationTokenSource()).Token); } } } From 0b076c9ca0807f2c4e2e38c17c5b85064cee5464 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 May 2019 17:49:05 +0900 Subject: [PATCH 154/375] Only fetch after initial pop in --- osu.Game/Overlays/ChangelogOverlay.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index b8449f618d..f4c0338436 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -82,22 +82,12 @@ namespace osu.Game.Overlays sampleBack = audio.Sample.Get(@"UI/generic-select-soft"); } - protected override void LoadComplete() - { - base.LoadComplete(); - fetchListing(); - } - protected override void PopIn() { base.PopIn(); - FadeEdgeEffectTo(0.25f, WaveContainer.APPEAR_DURATION, Easing.In); - } - protected override void PopOut() - { - base.PopOut(); - FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out); + if (!initialFetchPerformed) + fetchListing(); } public override bool OnPressed(GlobalAction action) @@ -151,8 +141,12 @@ namespace osu.Game.Overlays loadContent(new ChangelogBuild(build)); } + private bool initialFetchPerformed; + private void fetchListing() { + initialFetchPerformed = true; + var req = new GetChangelogRequest(); req.Success += res => { @@ -165,6 +159,7 @@ namespace osu.Game.Overlays ShowListing(); }; + req.Failure += _ => initialFetchPerformed = false; API.Queue(req); } From dbc42fd59e1b1b786a84b8d672b2502d5924ce95 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 May 2019 18:09:11 +0900 Subject: [PATCH 155/375] Remove StreamColour class and implement locally --- osu.Game/Graphics/StreamColour.cs | 43 ------------------- .../API/Requests/Responses/APIUpdateStream.cs | 32 ++++++++++++++ .../Changelog/ChangelogContentGroup.cs | 4 +- osu.Game/Overlays/Changelog/StreamBadge.cs | 2 +- 4 files changed, 35 insertions(+), 46 deletions(-) delete mode 100644 osu.Game/Graphics/StreamColour.cs diff --git a/osu.Game/Graphics/StreamColour.cs b/osu.Game/Graphics/StreamColour.cs deleted file mode 100644 index b7740c3be0..0000000000 --- a/osu.Game/Graphics/StreamColour.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Graphics.Colour; -using System.Collections.Generic; -using osuTK.Graphics; - -namespace osu.Game.Graphics -{ - public class StreamColour - { - public static readonly Color4 STABLE = new Color4(102, 204, 255, 255); - public static readonly Color4 STABLEFALLBACK = new Color4(34, 153, 187, 255); - public static readonly Color4 BETA = new Color4(255, 221, 85, 255); - public static readonly Color4 CUTTINGEDGE = new Color4(238, 170, 0, 255); - public static readonly Color4 LAZER = new Color4(237, 18, 33, 255); - public static readonly Color4 WEB = new Color4(136, 102, 238, 255); - - private static readonly Dictionary colours = new Dictionary - { - { "stable40", STABLE }, - { "Stable", STABLE }, - { "stable", STABLEFALLBACK }, - { "Stable Fallback", STABLEFALLBACK }, - { "beta40", BETA }, - { "Beta", BETA }, - { "cuttingedge", CUTTINGEDGE }, - { "Cutting Edge", CUTTINGEDGE }, - { "lazer", LAZER }, - { "Lazer", LAZER }, - { "web", WEB }, - }; - - public static ColourInfo FromStreamName(string name) - { - if (!string.IsNullOrEmpty(name)) - if (colours.TryGetValue(name, out ColourInfo colour)) - return colour; - - return new Color4(0, 0, 0, 255); - } - } -} diff --git a/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs b/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs index 25f1a413d6..4c65b562dd 100644 --- a/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs +++ b/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs @@ -3,6 +3,8 @@ using System; using Newtonsoft.Json; +using osu.Framework.Graphics.Colour; +using osuTK.Graphics; namespace osu.Game.Online.API.Requests.Responses { @@ -30,5 +32,35 @@ namespace osu.Game.Online.API.Requests.Responses return Id == other.Id; } + + public ColourInfo Colour + { + get + { + switch (Name) + { + case "stable40": + return new Color4(102, 204, 255, 255); + + case "stable": + return new Color4(34, 153, 187, 255); + + case "beta40": + return new Color4(255, 221, 85, 255); + + case "cuttingedge": + return new Color4(238, 170, 0, 255); + + case "lazer": + return new Color4(237, 18, 33, 255); + + case "web": + return new Color4(136, 102, 238, 255); + + default: + return new Color4(0, 0, 0, 255); + } + } + } } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 9f3da7eade..52186ec37c 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -75,7 +75,7 @@ namespace osu.Game.Overlays.Changelog { Text = build.DisplayVersion, Font = OsuFont.GetFont(weight: FontWeight.Light, size: 24), - Colour = StreamColour.FromStreamName(build.UpdateStream.Name), + Colour = build.UpdateStream.Colour, }, } }, @@ -156,7 +156,7 @@ namespace osu.Game.Overlays.Changelog { Text = build.DisplayVersion, Font = OsuFont.GetFont(weight: FontWeight.Light, size: 19), - Colour = StreamColour.FromStreamName(build.UpdateStream.Name), + Colour = build.UpdateStream.Colour, }, }, } diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 2be6aba926..61bdf9f537 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -73,7 +73,7 @@ namespace osu.Game.Overlays.Changelog lineBadge = new LineBadge(false) { Anchor = Anchor.TopCentre, - Colour = StreamColour.FromStreamName(stream.Name), + Colour = stream.Colour, UncollapsedSize = 4, CollapsedSize = 2, }, From 9bc3aa3d467677a7516e41041edb1fbee024a4b7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 May 2019 19:15:25 +0900 Subject: [PATCH 156/375] Move new classes for now --- .../UserInterface => Overlays/Changelog/Components}/LineBadge.cs | 0 .../Changelog/Components}/TooltipIconButton.cs | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename osu.Game/{Graphics/UserInterface => Overlays/Changelog/Components}/LineBadge.cs (100%) rename osu.Game/{Graphics/UserInterface => Overlays/Changelog/Components}/TooltipIconButton.cs (100%) diff --git a/osu.Game/Graphics/UserInterface/LineBadge.cs b/osu.Game/Overlays/Changelog/Components/LineBadge.cs similarity index 100% rename from osu.Game/Graphics/UserInterface/LineBadge.cs rename to osu.Game/Overlays/Changelog/Components/LineBadge.cs diff --git a/osu.Game/Graphics/UserInterface/TooltipIconButton.cs b/osu.Game/Overlays/Changelog/Components/TooltipIconButton.cs similarity index 100% rename from osu.Game/Graphics/UserInterface/TooltipIconButton.cs rename to osu.Game/Overlays/Changelog/Components/TooltipIconButton.cs From 2d56413e3509401ede5fb916ef57adf220cff84c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 May 2019 19:15:39 +0900 Subject: [PATCH 157/375] Update namespaces --- osu.Game.Tests/Visual/UserInterface/TestSceneLineBadge.cs | 2 +- osu.Game/Overlays/Changelog/ChangelogContentGroup.cs | 2 +- osu.Game/Overlays/Changelog/Components/LineBadge.cs | 2 +- osu.Game/Overlays/Changelog/Components/TooltipIconButton.cs | 6 +++--- osu.Game/Overlays/Changelog/Header/Breadcrumb.cs | 2 +- osu.Game/Overlays/Changelog/StreamBadge.cs | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneLineBadge.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneLineBadge.cs index 9f80cd40cf..14e7b45ee6 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneLineBadge.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneLineBadge.cs @@ -4,7 +4,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics.UserInterface; +using osu.Game.Overlays.Changelog.Components; using osuTK.Graphics; namespace osu.Game.Tests.Visual.UserInterface diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 52186ec37c..44c2c4cf9c 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -6,11 +6,11 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.Containers; -using osu.Game.Graphics.UserInterface; using osu.Game.Online.API.Requests.Responses; using System; using System.Collections.Generic; using System.Text.RegularExpressions; +using osu.Game.Overlays.Changelog.Components; using osuTK; using osuTK.Graphics; diff --git a/osu.Game/Overlays/Changelog/Components/LineBadge.cs b/osu.Game/Overlays/Changelog/Components/LineBadge.cs index fc87acab0a..84cd712eef 100644 --- a/osu.Game/Overlays/Changelog/Components/LineBadge.cs +++ b/osu.Game/Overlays/Changelog/Components/LineBadge.cs @@ -4,7 +4,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; -namespace osu.Game.Graphics.UserInterface +namespace osu.Game.Overlays.Changelog.Components { /// /// A simple rounded expandable line. Set its diff --git a/osu.Game/Overlays/Changelog/Components/TooltipIconButton.cs b/osu.Game/Overlays/Changelog/Components/TooltipIconButton.cs index 7287794f89..5721481685 100644 --- a/osu.Game/Overlays/Changelog/Components/TooltipIconButton.cs +++ b/osu.Game/Overlays/Changelog/Components/TooltipIconButton.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -8,12 +9,11 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; -using osu.Framework.Input.Events; -using System; using osu.Framework.Graphics.Sprites; +using osu.Framework.Input.Events; using osuTK; -namespace osu.Game.Graphics.UserInterface +namespace osu.Game.Overlays.Changelog.Components { /// /// An icon with an action upon click that can be disabled. diff --git a/osu.Game/Overlays/Changelog/Header/Breadcrumb.cs b/osu.Game/Overlays/Changelog/Header/Breadcrumb.cs index ae902043e3..c9b1430b5d 100644 --- a/osu.Game/Overlays/Changelog/Header/Breadcrumb.cs +++ b/osu.Game/Overlays/Changelog/Header/Breadcrumb.cs @@ -9,9 +9,9 @@ using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; -using osu.Game.Graphics.UserInterface; using System; using osu.Game.Graphics; +using osu.Game.Overlays.Changelog.Components; namespace osu.Game.Overlays.Changelog.Header { diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 61bdf9f537..ce2ae8baf6 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -9,9 +9,9 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; using osu.Game.Graphics; -using osu.Game.Graphics.UserInterface; using osu.Game.Online.API.Requests.Responses; using System; +using osu.Game.Overlays.Changelog.Components; using osuTK.Graphics; namespace osu.Game.Overlays.Changelog From 3fa1545ea445f7fe8aca58153e03a839d2a74091 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 19 May 2019 02:09:08 +0900 Subject: [PATCH 158/375] Huge refactor pass focusing on ChangelogContent --- .../Online/TestSceneChangelogOverlay.cs | 2 +- .../Graphics/Containers/OsuHoverContainer.cs | 3 +- .../BeatmapSet/Scores/TopScoreUserSection.cs | 2 +- osu.Game/Overlays/Changelog/ChangelogBuild.cs | 176 +++++++++-- .../Changelog/ChangelogContentGroup.cs | 280 ------------------ .../Overlays/Changelog/ChangelogListing.cs | 32 +- .../Changelog/ChangelogSingleBuild.cs | 118 ++++++++ .../Overlays/Changelog/Header/Breadcrumb.cs | 3 +- osu.Game/Overlays/Changelog/StreamBadge.cs | 7 +- osu.Game/Overlays/ChangelogOverlay.cs | 2 +- 10 files changed, 294 insertions(+), 331 deletions(-) delete mode 100644 osu.Game/Overlays/Changelog/ChangelogContentGroup.cs create mode 100644 osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs index e1cb6e6a85..4ac5514019 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs @@ -23,8 +23,8 @@ namespace osu.Game.Tests.Visual.Online typeof(ChangelogHeader), typeof(ChangelogContent), typeof(ChangelogListing), + typeof(ChangelogSingleBuild), typeof(ChangelogBuild), - typeof(ChangelogContentGroup), typeof(Breadcrumb), typeof(BreadcrumbListing), typeof(BreadcrumbRelease), diff --git a/osu.Game/Graphics/Containers/OsuHoverContainer.cs b/osu.Game/Graphics/Containers/OsuHoverContainer.cs index d5ae7cba57..b1fe1e81f1 100644 --- a/osu.Game/Graphics/Containers/OsuHoverContainer.cs +++ b/osu.Game/Graphics/Containers/OsuHoverContainer.cs @@ -22,7 +22,8 @@ namespace osu.Game.Graphics.Containers protected override bool OnHover(HoverEvent e) { - EffectTargets.ForEach(d => d.FadeColour(HoverColour, FADE_DURATION, Easing.OutQuint)); + if (Action != null) + EffectTargets.ForEach(d => d.FadeColour(HoverColour, FADE_DURATION, Easing.OutQuint)); return base.OnHover(e); } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs index e70bf4c572..89da0fc254 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs @@ -83,7 +83,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Origin = Anchor.CentreLeft, AutoSizeAxes = Axes.Both, }, - date = new SpriteText + date = new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, diff --git a/osu.Game/Overlays/Changelog/ChangelogBuild.cs b/osu.Game/Overlays/Changelog/ChangelogBuild.cs index 0af117c11e..09706a419e 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBuild.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBuild.cs @@ -1,50 +1,168 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Threading; -using System.Threading.Tasks; -using osu.Framework.Allocation; -using osu.Game.Online.API; -using osu.Game.Online.API.Requests; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; using osu.Game.Online.API.Requests.Responses; +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using osu.Game.Graphics.Sprites; +using osuTK.Graphics; namespace osu.Game.Overlays.Changelog { - public class ChangelogBuild : ChangelogContent + public class ChangelogBuild : FillFlowContainer { - private APIChangelogBuild changelogBuild; + public Action SelectBuild; - public ChangelogBuild(APIChangelogBuild changelogBuild) + protected readonly APIChangelogBuild Build; + + public readonly FillFlowContainer ChangelogEntries; + + public ChangelogBuild(APIChangelogBuild build) { - this.changelogBuild = changelogBuild; - } + Build = build; - [BackgroundDependencyLoader] - private void load(CancellationToken? cancellation, IAPIProvider api) - { - var req = new GetChangelogBuildRequest(changelogBuild.UpdateStream.Name, changelogBuild.Version); - bool complete = false; + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Direction = FillDirection.Vertical; + Padding = new MarginPadding { Horizontal = 70 }; - req.Success += res => + Children = new Drawable[] { - changelogBuild = res; - complete = true; + CreateHeader(), + ChangelogEntries = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + }, }; - req.Failure += _ => complete = true; + var categories = new SortedDictionary>(); - api.Queue(req); + // sort entries by category + foreach (APIChangelogEntry entry in build.ChangelogEntries) + { + if (!categories.ContainsKey(entry.Category)) + categories.Add(entry.Category, new List { entry }); + else + categories[entry.Category].Add(entry); + } - while (!complete && cancellation?.IsCancellationRequested != true) - Task.Delay(1); + foreach (KeyValuePair> category in categories) + { + ChangelogEntries.Add(new OsuSpriteText + { + Text = category.Key, + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 24), + Margin = new MarginPadding { Top = 35, Bottom = 15 }, + }); - var changelogContentGroup = new ChangelogContentGroup(changelogBuild); - changelogContentGroup.GenerateText(changelogBuild.ChangelogEntries); - changelogContentGroup.UpdateChevronTooltips(changelogBuild.Versions.Previous?.DisplayVersion, - changelogBuild.Versions.Next?.DisplayVersion); - changelogContentGroup.BuildSelected += SelectBuild; + foreach (APIChangelogEntry entry in category.Value) + { + LinkFlowContainer title = new LinkFlowContainer + { + Direction = FillDirection.Full, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Margin = new MarginPadding { Vertical = 5 }, + }; - Add(changelogContentGroup); + title.AddIcon(FontAwesome.Solid.Check, t => + { + t.Font = OsuFont.GetFont(size: 12); + t.Padding = new MarginPadding { Left = -17, Right = 5 }; + }); + + title.AddText(entry.Title, t => { t.Font = OsuFont.GetFont(size: 18); }); + + if (!string.IsNullOrEmpty(entry.Repository)) + { + title.AddText(" (", t => t.Font = OsuFont.GetFont(size: 18)); + title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}", + entry.GithubUrl, Online.Chat.LinkAction.External, null, + null, t => { t.Font = OsuFont.GetFont(size: 18); }); + title.AddText(")", t => t.Font = OsuFont.GetFont(size: 18)); + } + + title.AddText(" by ", t => t.Font = OsuFont.GetFont(size: 14)); + + if (entry.GithubUser.GithubUrl != null) + title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, + Online.Chat.LinkAction.External, null, null, + t => t.Font = OsuFont.GetFont(size: 14)); + else + title.AddText(entry.GithubUser.DisplayName, t => t.Font = OsuFont.GetFont(size: 12)); + + ChangelogEntries.Add(title); + + if (!string.IsNullOrEmpty(entry.MessageHtml)) + { + TextFlowContainer messageContainer = new TextFlowContainer + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + }; + + // todo: use markdown parsing once API returns markdown + messageContainer.AddText(Regex.Replace(entry.MessageHtml, @"<(.|\n)*?>", string.Empty), t => + { + t.Font = OsuFont.GetFont(size: 12); + t.Colour = new Color4(235, 184, 254, 255); + }); + + ChangelogEntries.Add(messageContainer); + } + } + } } + + protected virtual FillFlowContainer CreateHeader() => new FillFlowContainer + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Margin = new MarginPadding { Top = 20 }, + Children = new Drawable[] + { + new OsuHoverContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Action = () => SelectBuild?.Invoke(Build), + Child = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Margin = new MarginPadding { Horizontal = 40 }, + Children = new[] + { + new OsuSpriteText + { + Text = Build.UpdateStream.DisplayName, + Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 19), + }, + new OsuSpriteText + { + Text = " ", + Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 19), + }, + new OsuSpriteText + { + Text = Build.DisplayVersion, + Font = OsuFont.GetFont(weight: FontWeight.Light, size: 19), + Colour = Build.UpdateStream.Colour, + }, + } + } + }, + } + }; } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs deleted file mode 100644 index 44c2c4cf9c..0000000000 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ /dev/null @@ -1,280 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Game.Graphics; -using osu.Game.Graphics.Containers; -using osu.Game.Online.API.Requests.Responses; -using System; -using System.Collections.Generic; -using System.Text.RegularExpressions; -using osu.Game.Overlays.Changelog.Components; -using osuTK; -using osuTK.Graphics; - -namespace osu.Game.Overlays.Changelog -{ - public class ChangelogContentGroup : FillFlowContainer - { - private readonly TooltipIconButton chevronPrevious, chevronNext; - - private readonly SortedDictionary> categories = - new SortedDictionary>(); - - public event Action BuildSelected; - - public readonly FillFlowContainer ChangelogEntries; - - public ChangelogContentGroup(APIChangelogBuild build) - { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - Direction = FillDirection.Vertical; - Padding = new MarginPadding { Horizontal = 70 }; - Children = new Drawable[] - { - new FillFlowContainer - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Margin = new MarginPadding { Top = 20 }, - Children = new Drawable[] - { - chevronPrevious = new TooltipIconButton - { - IsEnabled = false, - Icon = FontAwesome.Solid.ChevronLeft, - Size = new Vector2(24), - Action = () => - { - BuildSelected?.Invoke(build.Versions.Previous); - chevronPrevious.IsEnabled = false; - }, - }, - new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Margin = new MarginPadding { Horizontal = 40 }, - Children = new[] - { - new SpriteText - { - Text = build.UpdateStream.DisplayName, - Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 24), - }, - new SpriteText - { - Text = " ", - Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 24), - }, - new SpriteText - { - Text = build.DisplayVersion, - Font = OsuFont.GetFont(weight: FontWeight.Light, size: 24), - Colour = build.UpdateStream.Colour, - }, - } - }, - chevronNext = new TooltipIconButton - { - IsEnabled = false, - Icon = FontAwesome.Solid.ChevronRight, - Size = new Vector2(24), - Action = () => - { - BuildSelected?.Invoke(build.Versions.Next); - chevronNext.IsEnabled = false; - }, - }, - } - }, - new SpriteText - { - // do we need .ToUniversalTime() here? - // also, this should be a temporary solution to weekdays in >localized< date strings - Text = build.CreatedAt.Date.ToLongDateString().Replace(build.CreatedAt.ToString("dddd") + ", ", ""), - Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 14), - Colour = OsuColour.FromHex(@"FD5"), - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Margin = new MarginPadding { Top = 5 }, - }, - ChangelogEntries = new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - }, - }; - } - - public ChangelogContentGroup(APIChangelogBuild build, bool newDate) - { - OsuHoverContainer clickableBuildText; - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - Direction = FillDirection.Vertical; - Padding = new MarginPadding { Horizontal = 70 }; - Children = new Drawable[] - { - new SpriteText - { - // do we need .ToUniversalTime() here? - // also, this should be a temporary solution to weekdays in >localized< date strings - Text = build.CreatedAt.Date.ToLongDateString().Replace(build.CreatedAt.ToString("dddd") + ", ", ""), - Font = OsuFont.GetFont(weight: FontWeight.Light, size: 24), - Colour = OsuColour.FromHex(@"FD5"), - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Margin = new MarginPadding { Top = 20 }, - Alpha = newDate ? 1 : 0, - }, - clickableBuildText = new OsuHoverContainer - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - AutoSizeAxes = Axes.Both, - Margin = new MarginPadding { Top = 20 }, - Action = () => BuildSelected?.Invoke(build), - Child = new FillFlowContainer - { - Direction = FillDirection.Horizontal, - Spacing = new Vector2(5), - AutoSizeAxes = Axes.Both, - Children = new Drawable[] - { - new SpriteText - { - Text = build.UpdateStream.DisplayName, - Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 19), - }, - new SpriteText - { - Text = build.DisplayVersion, - Font = OsuFont.GetFont(weight: FontWeight.Light, size: 19), - Colour = build.UpdateStream.Colour, - }, - }, - } - }, - ChangelogEntries = new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - }, - }; - - // we may not want double clicks, - // can be clicked again only after a delay - clickableBuildText.Action += () => - { - clickableBuildText.Action = null; - clickableBuildText.FadeTo(0.5f, 500); - Scheduler.AddDelayed(() => - { - clickableBuildText.Action = () => BuildSelected?.Invoke(build); - clickableBuildText.FadeIn(500); - }, 2000); - }; - } - - public void UpdateChevronTooltips(string previousVersion, string nextVersion) - { - if (!string.IsNullOrEmpty(previousVersion)) - { - chevronPrevious.TooltipText = previousVersion; - chevronPrevious.IsEnabled = true; - } - - if (!string.IsNullOrEmpty(nextVersion)) - { - chevronNext.TooltipText = nextVersion; - chevronNext.IsEnabled = true; - } - } - - public void GenerateText(List changelogEntries) - { - // sort entries by category - foreach (APIChangelogEntry entry in changelogEntries) - { - if (!categories.ContainsKey(entry.Category)) - categories.Add(entry.Category, new List { entry }); - else - categories[entry.Category].Add(entry); - } - - foreach (KeyValuePair> category in categories) - { - ChangelogEntries.Add(new SpriteText - { - Text = category.Key, - Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 24), - Margin = new MarginPadding { Top = 35, Bottom = 15 }, - }); - - foreach (APIChangelogEntry entry in category.Value) - { - LinkFlowContainer title = new LinkFlowContainer - { - Direction = FillDirection.Full, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Vertical = 5 }, - }; - - title.AddIcon(FontAwesome.Solid.Check, t => - { - t.Font = OsuFont.GetFont(size: 12); - t.Padding = new MarginPadding { Left = -17, Right = 5 }; - }); - - title.AddText(entry.Title, t => { t.Font = OsuFont.GetFont(size: 18); }); - - if (!string.IsNullOrEmpty(entry.Repository)) - { - title.AddText(" (", t => t.Font = OsuFont.GetFont(size: 18)); - title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}", - entry.GithubUrl, Online.Chat.LinkAction.External, null, - null, t => { t.Font = OsuFont.GetFont(size: 18); }); - title.AddText(")", t => t.Font = OsuFont.GetFont(size: 18)); - } - - title.AddText(" by ", t => t.Font = OsuFont.GetFont(size: 14)); - - if (entry.GithubUser.GithubUrl != null) - title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, - Online.Chat.LinkAction.External, null, null, - t => t.Font = OsuFont.GetFont(size: 14)); - else - title.AddText(entry.GithubUser.DisplayName, t => t.Font = OsuFont.GetFont(size: 12)); - - ChangelogEntries.Add(title); - - if (!string.IsNullOrEmpty(entry.MessageHtml)) - { - TextFlowContainer messageContainer = new TextFlowContainer - { - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - }; - - // todo: use markdown parsing once API returns markdown - messageContainer.AddText(Regex.Replace(entry.MessageHtml, @"<(.|\n)*?>", string.Empty), t => - { - t.Font = OsuFont.GetFont(size: 12); - t.Colour = new Color4(235, 184, 254, 255); - }); - - ChangelogEntries.Add(messageContainer); - } - } - } - } - } -} diff --git a/osu.Game/Overlays/Changelog/ChangelogListing.cs b/osu.Game/Overlays/Changelog/ChangelogListing.cs index 8e615d1dc9..907c122232 100644 --- a/osu.Game/Overlays/Changelog/ChangelogListing.cs +++ b/osu.Game/Overlays/Changelog/ChangelogListing.cs @@ -6,6 +6,8 @@ using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; using osu.Game.Online.API.Requests.Responses; using osuTK.Graphics; @@ -23,10 +25,7 @@ namespace osu.Game.Overlays.Changelog [BackgroundDependencyLoader] private void load() { - DateTime currentDate = new DateTime(); - Clear(); - - ChangelogContentGroup changelogContentGroup = null; + DateTime currentDate = DateTime.MinValue; foreach (APIChangelogBuild build in entries) { @@ -43,27 +42,32 @@ namespace osu.Game.Overlays.Changelog }); } - changelogContentGroup = new ChangelogContentGroup(build, true); - changelogContentGroup.BuildSelected += SelectBuild; - changelogContentGroup.GenerateText(build.ChangelogEntries); - Add(changelogContentGroup); + Add(new OsuSpriteText + { + // do we need .ToUniversalTime() here? + // also, this should be a temporary solution to weekdays in >localized< date strings + Text = build.CreatedAt.Date.ToLongDateString().Replace(build.CreatedAt.ToString("dddd") + ", ", ""), + Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 24), + Colour = OsuColour.FromHex(@"FD5"), + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Margin = new MarginPadding { Top = 15 }, + }); + currentDate = build.CreatedAt.Date; } else { - changelogContentGroup?.Add(new Box + Add(new Box { RelativeSizeAxes = Axes.X, Height = 1, Colour = new Color4(32, 24, 35, 255), Margin = new MarginPadding { Top = 30 }, }); - - changelogContentGroup = new ChangelogContentGroup(build, false); - changelogContentGroup.BuildSelected += SelectBuild; - changelogContentGroup.GenerateText(build.ChangelogEntries); - Add(changelogContentGroup); } + + Add(new ChangelogBuild(build) { SelectBuild = SelectBuild }); } } } diff --git a/osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs b/osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs new file mode 100644 index 0000000000..af4603fddf --- /dev/null +++ b/osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs @@ -0,0 +1,118 @@ +// 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 System.Threading; +using System.Threading.Tasks; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests; +using osu.Game.Online.API.Requests.Responses; +using osu.Game.Overlays.Changelog.Components; +using osuTK; + +namespace osu.Game.Overlays.Changelog +{ + public class ChangelogSingleBuild : ChangelogContent + { + private APIChangelogBuild build; + + public ChangelogSingleBuild(APIChangelogBuild build) + { + this.build = build; + } + + [BackgroundDependencyLoader] + private void load(CancellationToken? cancellation, IAPIProvider api) + { + var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); + bool complete = false; + + req.Success += res => + { + build = res; + complete = true; + }; + + req.Failure += _ => complete = true; + + api.Queue(req); + + while (!complete && cancellation?.IsCancellationRequested != true) + Task.Delay(1); + + Children = new Drawable[] + { + new ChangelogBuildWithNavigation(build) { SelectBuild = SelectBuild }, + }; + } + + public class ChangelogBuildWithNavigation : ChangelogBuild + { + public ChangelogBuildWithNavigation(APIChangelogBuild build) + : base(build) + { + } + + protected override FillFlowContainer CreateHeader() + { + var fill = base.CreateHeader(); + + foreach (var existing in fill.Children.OfType()) + { + existing.Scale = new Vector2(1.25f); + existing.Action = null; + + existing.Add(new OsuSpriteText + { + // do we need .ToUniversalTime() here? + // also, this should be a temporary solution to weekdays in >localized< date strings + Text = Build.CreatedAt.Date.ToLongDateString().Replace(Build.CreatedAt.ToString("dddd") + ", ", ""), + Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 14), + Colour = OsuColour.FromHex(@"FD5"), + Anchor = Anchor.BottomCentre, + Origin = Anchor.TopCentre, + Margin = new MarginPadding { Top = 5 }, + }); + } + + TooltipIconButton left, right; + + fill.AddRange(new[] + { + left = new TooltipIconButton + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Icon = FontAwesome.Solid.ChevronLeft, + Size = new Vector2(24), + TooltipText = Build.Versions?.Previous?.DisplayVersion, + IsEnabled = Build.Versions?.Previous != null, + Action = () => { SelectBuild?.Invoke(Build.Versions.Previous); }, + }, + right = new TooltipIconButton + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Icon = FontAwesome.Solid.ChevronRight, + Size = new Vector2(24), + TooltipText = Build.Versions?.Next?.DisplayVersion, + IsEnabled = Build.Versions?.Next != null, + Action = () => { SelectBuild?.Invoke(Build.Versions.Next); }, + }, + }); + + fill.SetLayoutPosition(left, -1); + fill.SetLayoutPosition(right, 1); + + return fill; + } + } + } +} diff --git a/osu.Game/Overlays/Changelog/Header/Breadcrumb.cs b/osu.Game/Overlays/Changelog/Header/Breadcrumb.cs index c9b1430b5d..f960111a53 100644 --- a/osu.Game/Overlays/Changelog/Header/Breadcrumb.cs +++ b/osu.Game/Overlays/Changelog/Header/Breadcrumb.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; using System; using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Changelog.Components; namespace osu.Game.Overlays.Changelog.Header @@ -33,7 +34,7 @@ namespace osu.Game.Overlays.Changelog.Header RelativeSizeAxes = Axes.Y; Children = new Drawable[] { - Text = new SpriteText + Text = new OsuSpriteText { Font = OsuFont.GetFont(size: 16), Text = displayText, diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index ce2ae8baf6..bdddc1f968 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -11,6 +11,7 @@ using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Online.API.Requests.Responses; using System; +using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Changelog.Components; using osuTK.Graphics; @@ -51,18 +52,18 @@ namespace osu.Game.Overlays.Changelog Direction = FillDirection.Vertical, Children = new[] { - new SpriteText + new OsuSpriteText { Text = stream.DisplayName, Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 12), Margin = new MarginPadding { Top = 6 }, }, - new SpriteText + new OsuSpriteText { Text = stream.LatestBuild.DisplayVersion, Font = OsuFont.GetFont(weight: FontWeight.Light, size: 16), }, - new SpriteText + new OsuSpriteText { Text = stream.LatestBuild.Users > 0 ? $"{stream.LatestBuild.Users:N0} users online" : null, Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 10), diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index f4c0338436..22c362d49d 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -138,7 +138,7 @@ namespace osu.Game.Overlays header.ShowBuild(build.UpdateStream.DisplayName, build.DisplayVersion); badges.Current.Value = build.UpdateStream; - loadContent(new ChangelogBuild(build)); + loadContent(new ChangelogSingleBuild(build)); } private bool initialFetchPerformed; From dae315ec0a458fd7390f7b97d6439c8445da5709 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 19 May 2019 11:28:24 +0900 Subject: [PATCH 159/375] Move TooltipText to OsuClickableContainer --- osu.Game/Graphics/Containers/OsuClickableContainer.cs | 5 ++++- osu.Game/Online/Chat/DrawableLinkCompiler.cs | 5 +---- osu.Game/Overlays/BeatmapSet/AuthorInfo.cs | 7 ------- .../Profile/Header/Components/ProfileHeaderButton.cs | 5 +---- .../Overlays/Profile/Sections/BeatmapMetadataContainer.cs | 5 +---- osu.Game/Users/Avatar.cs | 5 ++--- 6 files changed, 9 insertions(+), 23 deletions(-) diff --git a/osu.Game/Graphics/Containers/OsuClickableContainer.cs b/osu.Game/Graphics/Containers/OsuClickableContainer.cs index e4d30cebb7..6dbe340efb 100644 --- a/osu.Game/Graphics/Containers/OsuClickableContainer.cs +++ b/osu.Game/Graphics/Containers/OsuClickableContainer.cs @@ -4,11 +4,12 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; using osu.Game.Graphics.UserInterface; namespace osu.Game.Graphics.Containers { - public class OsuClickableContainer : ClickableContainer + public class OsuClickableContainer : ClickableContainer, IHasTooltip { private readonly HoverSampleSet sampleSet; @@ -23,6 +24,8 @@ namespace osu.Game.Graphics.Containers this.sampleSet = sampleSet; } + public virtual string TooltipText { get; set; } + [BackgroundDependencyLoader] private void load() { diff --git a/osu.Game/Online/Chat/DrawableLinkCompiler.cs b/osu.Game/Online/Chat/DrawableLinkCompiler.cs index d34ec8091c..d27a3fbffe 100644 --- a/osu.Game/Online/Chat/DrawableLinkCompiler.cs +++ b/osu.Game/Online/Chat/DrawableLinkCompiler.cs @@ -1,7 +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.Graphics.Cursor; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; @@ -16,7 +15,7 @@ namespace osu.Game.Online.Chat /// /// An invisible drawable that brings multiple pieces together to form a consumable clickable link. /// - public class DrawableLinkCompiler : OsuHoverContainer, IHasTooltip + public class DrawableLinkCompiler : OsuHoverContainer { /// /// Each word part of a chat link (split for word-wrap support). @@ -40,8 +39,6 @@ namespace osu.Game.Online.Chat protected override IEnumerable EffectTargets => Parts; - public string TooltipText { get; set; } - private class LinkHoverSounds : HoverClickSounds { private readonly List parts; diff --git a/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs b/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs index abe954aa80..7331faa618 100644 --- a/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs +++ b/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs @@ -9,8 +9,6 @@ using osu.Game.Graphics.Sprites; using osu.Game.Users; using osuTK; using osuTK.Graphics; -using osu.Game.Graphics.Containers; -using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; @@ -129,10 +127,5 @@ namespace osu.Game.Overlays.BeatmapSet }; } } - - private class ClickableArea : OsuClickableContainer, IHasTooltip - { - public string TooltipText => @"View Profile"; - } } } diff --git a/osu.Game/Overlays/Profile/Header/Components/ProfileHeaderButton.cs b/osu.Game/Overlays/Profile/Header/Components/ProfileHeaderButton.cs index 1650f11523..ddcf011277 100644 --- a/osu.Game/Overlays/Profile/Header/Components/ProfileHeaderButton.cs +++ b/osu.Game/Overlays/Profile/Header/Components/ProfileHeaderButton.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.Containers; @@ -12,10 +11,8 @@ using osuTK.Graphics; namespace osu.Game.Overlays.Profile.Header.Components { - public abstract class ProfileHeaderButton : OsuHoverContainer, IHasTooltip + public abstract class ProfileHeaderButton : OsuHoverContainer { - public abstract string TooltipText { get; } - private readonly Box background; private readonly Container content; diff --git a/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs b/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs index bb55816880..16326900f1 100644 --- a/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Cursor; using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Graphics; @@ -16,7 +15,7 @@ namespace osu.Game.Overlays.Profile.Sections /// /// Display artist/title/mapper information, commonly used as the left portion of a profile or score display row (see ). /// - public class BeatmapMetadataContainer : OsuHoverContainer, IHasTooltip + public class BeatmapMetadataContainer : OsuHoverContainer { private readonly BeatmapInfo beatmap; @@ -27,8 +26,6 @@ namespace osu.Game.Overlays.Profile.Sections TooltipText = $"{beatmap.Metadata.Artist} - {beatmap.Metadata.Title}"; } - public string TooltipText { get; } - [BackgroundDependencyLoader(true)] private void load(BeatmapSetOverlay beatmapSetOverlay) { diff --git a/osu.Game/Users/Avatar.cs b/osu.Game/Users/Avatar.cs index 3df5957ff9..8937f94768 100644 --- a/osu.Game/Users/Avatar.cs +++ b/osu.Game/Users/Avatar.cs @@ -6,7 +6,6 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Framework.Input.Events; @@ -72,9 +71,9 @@ namespace osu.Game.Users game?.ShowUser(user.Id); } - private class ClickableArea : OsuClickableContainer, IHasTooltip + private class ClickableArea : OsuClickableContainer { - public string TooltipText => Enabled.Value ? @"View Profile" : null; + public override string TooltipText => Enabled.Value ? @"View Profile" : null; protected override bool OnClick(ClickEvent e) { From 1c85fcbc81dca20cf9d72aa72e3dd5e0703a4d50 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 19 May 2019 11:28:34 +0900 Subject: [PATCH 160/375] Remove usage of TooltipIconButton completely --- .../Changelog/ChangelogSingleBuild.cs | 52 ++++++--- .../Changelog/Components/TooltipIconButton.cs | 100 ------------------ 2 files changed, 36 insertions(+), 116 deletions(-) delete mode 100644 osu.Game/Overlays/Changelog/Components/TooltipIconButton.cs diff --git a/osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs b/osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs index af4603fddf..50a7946ee7 100644 --- a/osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs +++ b/osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs @@ -1,20 +1,22 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Linq; using System.Threading; using System.Threading.Tasks; using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; -using osu.Game.Overlays.Changelog.Components; using osuTK; namespace osu.Game.Overlays.Changelog @@ -82,29 +84,19 @@ namespace osu.Game.Overlays.Changelog }); } - TooltipIconButton left, right; + NavigationIconButton left, right; fill.AddRange(new[] { - left = new TooltipIconButton + left = new NavigationIconButton(Build.Versions?.Previous) { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, Icon = FontAwesome.Solid.ChevronLeft, - Size = new Vector2(24), - TooltipText = Build.Versions?.Previous?.DisplayVersion, - IsEnabled = Build.Versions?.Previous != null, - Action = () => { SelectBuild?.Invoke(Build.Versions.Previous); }, + SelectBuild = b => SelectBuild(b) }, - right = new TooltipIconButton + right = new NavigationIconButton(Build.Versions?.Next) { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, Icon = FontAwesome.Solid.ChevronRight, - Size = new Vector2(24), - TooltipText = Build.Versions?.Next?.DisplayVersion, - IsEnabled = Build.Versions?.Next != null, - Action = () => { SelectBuild?.Invoke(Build.Versions.Next); }, + SelectBuild = b => SelectBuild(b) }, }); @@ -114,5 +106,33 @@ namespace osu.Game.Overlays.Changelog return fill; } } + + private class NavigationIconButton : IconButton + { + public Action SelectBuild; + + public NavigationIconButton(APIChangelogBuild build) + { + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + + if (build == null) return; + + TooltipText = build.DisplayVersion; + + Action = () => + { + SelectBuild?.Invoke(build); + Enabled.Value = false; + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + HoverColour = colours.GreyVioletLight.Opacity(0.6f); + FlashColour = colours.GreyVioletLighter; + } + } } } diff --git a/osu.Game/Overlays/Changelog/Components/TooltipIconButton.cs b/osu.Game/Overlays/Changelog/Components/TooltipIconButton.cs deleted file mode 100644 index 5721481685..0000000000 --- a/osu.Game/Overlays/Changelog/Components/TooltipIconButton.cs +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; -using osu.Framework.Allocation; -using osu.Framework.Audio; -using osu.Framework.Audio.Sample; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Cursor; -using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Input.Events; -using osuTK; - -namespace osu.Game.Overlays.Changelog.Components -{ - /// - /// An icon with an action upon click that can be disabled. - /// - public class TooltipIconButton : Container, IHasTooltip - { - private readonly SpriteIcon icon; - private SampleChannel sampleHover; - private SampleChannel sampleClick; - - /// - /// The action to fire upon click if is set to true. - /// - public Action Action; - - private bool isEnabled; - - /// - /// If set to true, upon click the will execute. - /// - public bool IsEnabled - { - get => isEnabled; - set - { - isEnabled = value; - icon.FadeTo(value ? 1 : 0.5f, 250); - } - } - - public IconUsage Icon - { - get => icon.Icon; - set => icon.Icon = value; - } - - public TooltipIconButton() - { - isEnabled = true; - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Alpha = 0, - }, - icon = new SpriteIcon - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Size = new Vector2(0.8f), - } - }; - } - - protected override bool OnClick(ClickEvent e) - { - if (isEnabled) - { - sampleClick?.Play(); - Action?.Invoke(); - } - - return base.OnClick(e); - } - - protected override bool OnHover(HoverEvent e) - { - if (isEnabled) - sampleHover?.Play(); - return base.OnHover(e); - } - - [BackgroundDependencyLoader] - private void load(AudioManager audio) - { - sampleHover = audio.Sample.Get(@"UI/generic-hover-soft"); - sampleClick = audio.Sample.Get(@"UI/generic-select-soft"); - } - - public string TooltipText { get; set; } - } -} From 39e03ae7058f3bd18821fb23190bdd2900286ab2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 19 May 2019 11:58:47 +0900 Subject: [PATCH 161/375] Fix tests failing when not logged in --- osu.Game/Overlays/Changelog/ChangelogListing.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Overlays/Changelog/ChangelogListing.cs b/osu.Game/Overlays/Changelog/ChangelogListing.cs index 907c122232..ebfcf76738 100644 --- a/osu.Game/Overlays/Changelog/ChangelogListing.cs +++ b/osu.Game/Overlays/Changelog/ChangelogListing.cs @@ -27,6 +27,8 @@ namespace osu.Game.Overlays.Changelog { DateTime currentDate = DateTime.MinValue; + if (entries == null) return; + foreach (APIChangelogBuild build in entries) { if (build.CreatedAt.Date != currentDate) From 455301de2c1501433836411385bd1a82cda6220f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 20 May 2019 15:58:40 +0900 Subject: [PATCH 162/375] Use OsuColour for profile overlay --- osu.Game/Graphics/OsuColour.cs | 12 +----------- .../Overlays/Profile/Header/BottomHeaderContainer.cs | 4 ++-- .../Overlays/Profile/Header/CentreHeaderContainer.cs | 2 +- .../Profile/Header/Components/ExpandDetailsButton.cs | 4 ++-- .../Overlays/Profile/Header/Components/RankGraph.cs | 4 ++-- .../Profile/Header/Components/SupporterIcon.cs | 2 +- .../Overlays/Profile/Header/DetailHeaderContainer.cs | 2 +- .../Overlays/Profile/Header/MedalHeaderContainer.cs | 2 +- .../Overlays/Profile/Header/TopHeaderContainer.cs | 6 +++--- osu.Game/Overlays/Profile/ProfileHeader.cs | 4 ++-- 10 files changed, 16 insertions(+), 26 deletions(-) diff --git a/osu.Game/Graphics/OsuColour.cs b/osu.Game/Graphics/OsuColour.cs index a73a8bcbc1..d337455176 100644 --- a/osu.Game/Graphics/OsuColour.cs +++ b/osu.Game/Graphics/OsuColour.cs @@ -77,7 +77,7 @@ namespace osu.Game.Graphics public readonly Color4 Seafoam = FromHex(@"05ffa2"); public readonly Color4 GreySeafoamLighter = FromHex(@"9ebab1"); - public readonly Color4 GreySeafoamLight = FromHex(@"4d7365"); + public readonly Color4 GreySeafoamLight = FromHex(@"4e7466"); public readonly Color4 GreySeafoam = FromHex(@"33413c"); public readonly Color4 GreySeafoamDark = FromHex(@"2c3532"); public readonly Color4 GreySeafoamDarker = FromHex(@"1e2422"); @@ -136,15 +136,5 @@ namespace osu.Game.Graphics public readonly Color4 ChatBlue = FromHex(@"17292e"); public readonly Color4 ContextMenuGray = FromHex(@"223034"); - - public readonly Color4 CommunityUserGreenLight = FromHex(@"deff87"); - public readonly Color4 CommunityUserGreen = FromHex(@"05ffa2"); - public readonly Color4 CommunityUserGreenDark = FromHex(@"a6cc00"); - public readonly Color4 CommunityUserGrayGreenLighter = FromHex(@"9ebab1"); - public readonly Color4 CommunityUserGrayGreenLight = FromHex(@"77998e"); - public readonly Color4 CommunityUserGrayGreen = FromHex(@"4e7466"); - public readonly Color4 CommunityUserGrayGreenDark = FromHex(@"33413c"); - public readonly Color4 CommunityUserGrayGreenDarker = FromHex(@"2c3532"); - public readonly Color4 CommunityUserGrayGreenDarkest = FromHex(@"1e2422"); } } diff --git a/osu.Game/Overlays/Profile/Header/BottomHeaderContainer.cs b/osu.Game/Overlays/Profile/Header/BottomHeaderContainer.cs index 633085960b..ffbb9ad218 100644 --- a/osu.Game/Overlays/Profile/Header/BottomHeaderContainer.cs +++ b/osu.Game/Overlays/Profile/Header/BottomHeaderContainer.cs @@ -35,14 +35,14 @@ namespace osu.Game.Overlays.Profile.Header [BackgroundDependencyLoader] private void load(OsuColour colours) { - iconColour = colours.CommunityUserGrayGreenLighter; + iconColour = colours.GreySeafoamLighter; InternalChildren = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, - Colour = colours.CommunityUserGrayGreenDarker, + Colour = colours.GreySeafoamDark, }, new FillFlowContainer { diff --git a/osu.Game/Overlays/Profile/Header/CentreHeaderContainer.cs b/osu.Game/Overlays/Profile/Header/CentreHeaderContainer.cs index b441775393..68fd77dd84 100644 --- a/osu.Game/Overlays/Profile/Header/CentreHeaderContainer.cs +++ b/osu.Game/Overlays/Profile/Header/CentreHeaderContainer.cs @@ -38,7 +38,7 @@ namespace osu.Game.Overlays.Profile.Header new Box { RelativeSizeAxes = Axes.Both, - Colour = colours.CommunityUserGrayGreenDark + Colour = colours.GreySeafoam }, new FillFlowContainer { diff --git a/osu.Game/Overlays/Profile/Header/Components/ExpandDetailsButton.cs b/osu.Game/Overlays/Profile/Header/Components/ExpandDetailsButton.cs index 089228b2cd..46d24608ed 100644 --- a/osu.Game/Overlays/Profile/Header/Components/ExpandDetailsButton.cs +++ b/osu.Game/Overlays/Profile/Header/Components/ExpandDetailsButton.cs @@ -27,8 +27,8 @@ namespace osu.Game.Overlays.Profile.Header.Components [BackgroundDependencyLoader] private void load(OsuColour colours) { - IdleColour = colours.CommunityUserGrayGreen; - HoverColour = colours.CommunityUserGrayGreen.Darken(0.2f); + IdleColour = colours.GreySeafoamLight; + HoverColour = colours.GreySeafoamLight.Darken(0.2f); Child = icon = new SpriteIcon { diff --git a/osu.Game/Overlays/Profile/Header/Components/RankGraph.cs b/osu.Game/Overlays/Profile/Header/Components/RankGraph.cs index 1dabf167e3..85ea2a175a 100644 --- a/osu.Game/Overlays/Profile/Header/Components/RankGraph.cs +++ b/osu.Game/Overlays/Profile/Header/Components/RankGraph.cs @@ -154,7 +154,7 @@ namespace osu.Game.Overlays.Profile.Header.Components [BackgroundDependencyLoader] private void load(OsuColour colours) { - ballBg.Colour = colours.CommunityUserGrayGreenDarkest; + ballBg.Colour = colours.GreySeafoamDarker; movingBall.BorderColour = colours.Yellow; movingBar.Colour = colours.Yellow; } @@ -249,7 +249,7 @@ namespace osu.Game.Overlays.Profile.Header.Components [BackgroundDependencyLoader] private void load(OsuColour colours) { - background.Colour = colours.CommunityUserGrayGreenDarker; + background.Colour = colours.GreySeafoamDark; } public void Refresh() diff --git a/osu.Game/Overlays/Profile/Header/Components/SupporterIcon.cs b/osu.Game/Overlays/Profile/Header/Components/SupporterIcon.cs index 97454d7327..c5e61f68f4 100644 --- a/osu.Game/Overlays/Profile/Header/Components/SupporterIcon.cs +++ b/osu.Game/Overlays/Profile/Header/Components/SupporterIcon.cs @@ -80,7 +80,7 @@ namespace osu.Game.Overlays.Profile.Header.Components private void load(OsuColour colours) { background.Colour = colours.Pink; - iconContainer.Colour = colours.CommunityUserGrayGreenDark; + iconContainer.Colour = colours.GreySeafoam; } } } diff --git a/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs b/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs index e41c90be45..f26cc360a2 100644 --- a/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs +++ b/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs @@ -65,7 +65,7 @@ namespace osu.Game.Overlays.Profile.Header new Box { RelativeSizeAxes = Axes.Both, - Colour = colours.CommunityUserGrayGreenDarkest, + Colour = colours.GreySeafoamDarker, }, fillFlow = new FillFlowContainer { diff --git a/osu.Game/Overlays/Profile/Header/MedalHeaderContainer.cs b/osu.Game/Overlays/Profile/Header/MedalHeaderContainer.cs index 25d04195b2..67229a80c0 100644 --- a/osu.Game/Overlays/Profile/Header/MedalHeaderContainer.cs +++ b/osu.Game/Overlays/Profile/Header/MedalHeaderContainer.cs @@ -34,7 +34,7 @@ namespace osu.Game.Overlays.Profile.Header new Box { RelativeSizeAxes = Axes.Both, - Colour = colours.CommunityUserGrayGreenDarkest, + Colour = colours.GreySeafoamDarker, }, new Container //artificial shadow { diff --git a/osu.Game/Overlays/Profile/Header/TopHeaderContainer.cs b/osu.Game/Overlays/Profile/Header/TopHeaderContainer.cs index 2ac7f3cc96..6fe55e2368 100644 --- a/osu.Game/Overlays/Profile/Header/TopHeaderContainer.cs +++ b/osu.Game/Overlays/Profile/Header/TopHeaderContainer.cs @@ -41,7 +41,7 @@ namespace osu.Game.Overlays.Profile.Header new Box { RelativeSizeAxes = Axes.Both, - Colour = colours.CommunityUserGrayGreenDarker, + Colour = colours.GreySeafoamDark, }, new FillFlowContainer { @@ -107,7 +107,7 @@ namespace osu.Game.Overlays.Profile.Header RelativeSizeAxes = Axes.X, Height = 1.5f, Margin = new MarginPadding { Top = 10 }, - Colour = colours.CommunityUserGrayGreenLighter, + Colour = colours.GreySeafoamLighter, }, new Container { @@ -125,7 +125,7 @@ namespace osu.Game.Overlays.Profile.Header Margin = new MarginPadding { Left = 40 }, Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, - Colour = colours.CommunityUserGrayGreenLighter, + Colour = colours.GreySeafoamLighter, } } }, diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 2d8c47b11a..f2ac94b7ff 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -124,7 +124,7 @@ namespace osu.Game.Overlays.Profile [BackgroundDependencyLoader] private void load(OsuColour colours) { - infoTabControl.AccentColour = colours.CommunityUserGreen; + infoTabControl.AccentColour = colours.Seafoam; } public Bindable User = new Bindable(); @@ -145,7 +145,7 @@ namespace osu.Game.Overlays.Profile [BackgroundDependencyLoader] private void load(OsuColour colours) { - AccentColour = colours.CommunityUserGreen; + AccentColour = colours.Seafoam; } } } From a5bd3262beabe43ff5a4e39eba5e29398f0e58b3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 20 May 2019 18:02:13 +0900 Subject: [PATCH 163/375] Move UserProfileOverlay's header into an abstract implementation --- .../Online/TestSceneUserProfileHeader.cs | 2 +- osu.Game/Overlays/OverlayHeader.cs | 71 ++++++++ ...eaderTabControl.cs => HeaderTabControl.cs} | 12 +- osu.Game/Overlays/Profile/ProfileHeader.cs | 165 +++++++----------- 4 files changed, 142 insertions(+), 108 deletions(-) create mode 100644 osu.Game/Overlays/OverlayHeader.cs rename osu.Game/Overlays/Profile/Header/{ProfileHeaderTabControl.cs => HeaderTabControl.cs} (92%) diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs b/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs index 14c81558c1..730140faed 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs @@ -21,7 +21,7 @@ namespace osu.Game.Tests.Visual.Online typeof(ProfileHeader), typeof(RankGraph), typeof(LineGraph), - typeof(ProfileHeaderTabControl), + typeof(HeaderTabControl), typeof(CentreHeaderContainer), typeof(BottomHeaderContainer), typeof(DetailHeaderContainer), diff --git a/osu.Game/Overlays/OverlayHeader.cs b/osu.Game/Overlays/OverlayHeader.cs new file mode 100644 index 0000000000..fe50d4a2be --- /dev/null +++ b/osu.Game/Overlays/OverlayHeader.cs @@ -0,0 +1,71 @@ +// 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.UserInterface; +using osu.Game.Overlays.Profile.Header; + +namespace osu.Game.Overlays +{ + public abstract class OverlayHeader : Container + { + protected readonly HeaderTabControl TabControl; + + private const float cover_height = 150; + private const float cover_info_height = 75; + + protected OverlayHeader() + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.X, + Height = cover_height, + Masking = true, + Child = CreateBackground() + }, + new Container + { + Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN }, + Y = cover_height, + Height = cover_info_height, + RelativeSizeAxes = Axes.X, + Anchor = Anchor.TopLeft, + Origin = Anchor.BottomLeft, + Depth = -float.MaxValue, + Children = new Drawable[] + { + CreateTitle().With(t => t.X = -ScreenTitle.ICON_WIDTH), + TabControl = new HeaderTabControl + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + Height = cover_info_height - 30, + Margin = new MarginPadding { Left = -UserProfileOverlay.CONTENT_X_MARGIN }, + Padding = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN } + } + } + }, + new Container + { + Margin = new MarginPadding { Top = cover_height }, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Child = CreateContent() + } + }; + } + + protected abstract Drawable CreateBackground(); + + protected abstract Drawable CreateContent(); + + protected abstract ScreenTitle CreateTitle(); + } +} diff --git a/osu.Game/Overlays/Profile/Header/ProfileHeaderTabControl.cs b/osu.Game/Overlays/Profile/Header/HeaderTabControl.cs similarity index 92% rename from osu.Game/Overlays/Profile/Header/ProfileHeaderTabControl.cs rename to osu.Game/Overlays/Profile/Header/HeaderTabControl.cs index 3b16b102d5..1169ef7013 100644 --- a/osu.Game/Overlays/Profile/Header/ProfileHeaderTabControl.cs +++ b/osu.Game/Overlays/Profile/Header/HeaderTabControl.cs @@ -13,7 +13,7 @@ using osuTK.Graphics; namespace osu.Game.Overlays.Profile.Header { - public class ProfileHeaderTabControl : TabControl + public class HeaderTabControl : TabControl { private readonly Box bar; @@ -32,7 +32,7 @@ namespace osu.Game.Overlays.Profile.Header foreach (TabItem tabItem in TabContainer) { - ((ProfileHeaderTabItem)tabItem).AccentColour = value; + ((HeaderTabItem)tabItem).AccentColour = value; } } } @@ -43,7 +43,7 @@ namespace osu.Game.Overlays.Profile.Header set => TabContainer.Padding = value; } - public ProfileHeaderTabControl() + public HeaderTabControl() { TabContainer.Masking = false; TabContainer.Spacing = new Vector2(15, 0); @@ -59,12 +59,12 @@ namespace osu.Game.Overlays.Profile.Header protected override Dropdown CreateDropdown() => null; - protected override TabItem CreateTabItem(string value) => new ProfileHeaderTabItem(value) + protected override TabItem CreateTabItem(string value) => new HeaderTabItem(value) { AccentColour = AccentColour }; - private class ProfileHeaderTabItem : TabItem + private class HeaderTabItem : TabItem { private readonly OsuSpriteText text; private readonly Drawable bar; @@ -86,7 +86,7 @@ namespace osu.Game.Overlays.Profile.Header } } - public ProfileHeaderTabItem(string value) + public HeaderTabItem(string value) : base(value) { AutoSizeAxes = Axes.X; diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index f2ac94b7ff..702bd6c2c4 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -15,124 +15,85 @@ using osu.Game.Users; namespace osu.Game.Overlays.Profile { - public class ProfileHeader : Container + public class ProfileHeader : OverlayHeader { - private readonly UserCoverBackground coverContainer; - private readonly ProfileHeaderTabControl infoTabControl; + private UserCoverBackground coverContainer; - private const float cover_height = 150; - private const float cover_info_height = 75; + public Bindable User = new Bindable(); + + private CentreHeaderContainer centreHeaderContainer; + private DetailHeaderContainer detailHeaderContainer; public ProfileHeader() { - CentreHeaderContainer centreHeaderContainer; - DetailHeaderContainer detailHeaderContainer; + User.ValueChanged += e => updateDisplay(e.NewValue); - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - - Children = new Drawable[] - { - new Container - { - RelativeSizeAxes = Axes.X, - Height = cover_height, - Masking = true, - Children = new Drawable[] - { - coverContainer = new UserCoverBackground - { - RelativeSizeAxes = Axes.Both, - }, - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = ColourInfo.GradientVertical(OsuColour.FromHex("222").Opacity(0.8f), OsuColour.FromHex("222").Opacity(0.2f)) - }, - } - }, - new Container - { - Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN }, - Y = cover_height, - Height = cover_info_height, - RelativeSizeAxes = Axes.X, - Anchor = Anchor.TopLeft, - Origin = Anchor.BottomLeft, - Depth = -float.MaxValue, - Children = new Drawable[] - { - new ProfileHeaderTitle - { - X = -ScreenTitle.ICON_WIDTH, - }, - infoTabControl = new ProfileHeaderTabControl - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - RelativeSizeAxes = Axes.X, - Height = cover_info_height - 30, - Margin = new MarginPadding { Left = -UserProfileOverlay.CONTENT_X_MARGIN }, - Padding = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN } - } - } - }, - new FillFlowContainer - { - Margin = new MarginPadding { Top = cover_height }, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Children = new Drawable[] - { - new TopHeaderContainer - { - RelativeSizeAxes = Axes.X, - User = { BindTarget = User }, - }, - centreHeaderContainer = new CentreHeaderContainer - { - RelativeSizeAxes = Axes.X, - User = { BindTarget = User }, - }, - detailHeaderContainer = new DetailHeaderContainer - { - RelativeSizeAxes = Axes.X, - User = { BindTarget = User }, - }, - new MedalHeaderContainer - { - RelativeSizeAxes = Axes.X, - User = { BindTarget = User }, - }, - new BottomHeaderContainer - { - RelativeSizeAxes = Axes.X, - User = { BindTarget = User }, - }, - } - } - }; - - infoTabControl.AddItem("Info"); - infoTabControl.AddItem("Modding"); + TabControl.AddItem("Info"); + TabControl.AddItem("Modding"); centreHeaderContainer.DetailsVisible.BindValueChanged(visible => detailHeaderContainer.Expanded = visible.NewValue, true); - User.ValueChanged += e => updateDisplay(e.NewValue); } [BackgroundDependencyLoader] private void load(OsuColour colours) { - infoTabControl.AccentColour = colours.Seafoam; + TabControl.AccentColour = colours.Seafoam; } - public Bindable User = new Bindable(); + protected override Drawable CreateBackground() => + new Container + { + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + coverContainer = new UserCoverBackground + { + RelativeSizeAxes = Axes.Both, + }, + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = ColourInfo.GradientVertical(OsuColour.FromHex("222").Opacity(0.8f), OsuColour.FromHex("222").Opacity(0.2f)) + }, + } + }; - private void updateDisplay(User user) + protected override Drawable CreateContent() => new FillFlowContainer { - coverContainer.User = user; - } + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + new TopHeaderContainer + { + RelativeSizeAxes = Axes.X, + User = { BindTarget = User }, + }, + centreHeaderContainer = new CentreHeaderContainer + { + RelativeSizeAxes = Axes.X, + User = { BindTarget = User }, + }, + detailHeaderContainer = new DetailHeaderContainer + { + RelativeSizeAxes = Axes.X, + User = { BindTarget = User }, + }, + new MedalHeaderContainer + { + RelativeSizeAxes = Axes.X, + User = { BindTarget = User }, + }, + new BottomHeaderContainer + { + RelativeSizeAxes = Axes.X, + User = { BindTarget = User }, + }, + } + }; + + protected override ScreenTitle CreateTitle() => new ProfileHeaderTitle(); private class ProfileHeaderTitle : ScreenTitle { @@ -148,5 +109,7 @@ namespace osu.Game.Overlays.Profile AccentColour = colours.Seafoam; } } + + private void updateDisplay(User user) => coverContainer.User = user; } } From 6a8a743eaa5d5e5f630d05ac23a12051b67c7ddd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 20 May 2019 18:02:27 +0900 Subject: [PATCH 164/375] Begin to consume abstract header implementation --- .../Overlays/Changelog/ChangelogHeader.cs | 104 ++++++++++-------- 1 file changed, 60 insertions(+), 44 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 94046d5762..9ef3316985 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -10,12 +10,13 @@ using osu.Framework.Graphics.Textures; using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Changelog.Header; using osu.Game.Graphics; +using osu.Game.Graphics.UserInterface; using osuTK; using osuTK.Graphics; namespace osu.Game.Overlays.Changelog { - public class ChangelogHeader : Container + public class ChangelogHeader : OverlayHeader { private OsuSpriteText titleStream; private BreadcrumbListing listing; @@ -26,35 +27,36 @@ namespace osu.Game.Overlays.Changelog public event ListingSelectedEventHandler ListingSelected; - private const float cover_height = 150; private const float title_height = 50; private const float icon_size = 50; private const float icon_margin = 20; private const float version_height = 40; - [BackgroundDependencyLoader] - private void load(OsuColour colours, TextureStore textures) + public void ShowBuild(string displayName, string displayVersion) { - RelativeSizeAxes = Axes.X; - Height = cover_height; + listing.Deactivate(); + releaseStream.ShowBuild($"{displayName} {displayVersion}"); + titleStream.Text = displayName; + titleStream.FlashColour(Color4.White, 500, Easing.OutQuad); + chevron.MoveToX(0, 100).FadeIn(100); + } + public void ShowListing() + { + releaseStream.Deactivate(); + listing.Activate(); + titleStream.Text = "Listing"; + titleStream.FlashColour(Color4.White, 500, Easing.OutQuad); + chevron.MoveToX(-20, 100).FadeOut(100); + } + + protected override Drawable CreateBackground() => new HeaderBackground(); + + protected override Drawable CreateContent() => new Container + { + RelativeSizeAxes = Axes.Both, Children = new Drawable[] { - new Container - { - RelativeSizeAxes = Axes.X, - Height = cover_height, - Masking = true, - Children = new Drawable[] - { - new Sprite - { - RelativeSizeAxes = Axes.Both, - Texture = textures.Get(@"Headers/changelog"), - FillMode = FillMode.Fill, - }, - } - }, new Container { Height = title_height, @@ -67,7 +69,7 @@ namespace osu.Game.Overlays.Changelog { X = icon_margin, Masking = true, - BorderColour = colours.Violet, + //BorderColour = colours.Violet, BorderThickness = 3, MaskingSmoothness = 1, Size = new Vector2(50), @@ -76,7 +78,7 @@ namespace osu.Game.Overlays.Changelog new Sprite { RelativeSizeAxes = Axes.Both, - Texture = textures.Get(@"Icons/changelog"), + //Texture = textures.Get(@"Icons/changelog"), Size = new Vector2(0.8f), Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -84,7 +86,7 @@ namespace osu.Game.Overlays.Changelog new Box { RelativeSizeAxes = Axes.Both, - Colour = colours.Violet, + //Colour = colours.Violet, Alpha = 0, AlwaysPresent = true, }, @@ -108,7 +110,7 @@ namespace osu.Game.Overlays.Changelog { Text = "Listing", Font = OsuFont.GetFont(weight: FontWeight.Light, size: 30), - Colour = colours.Violet, + //Colour = colours.Violet, }, } } @@ -123,7 +125,7 @@ namespace osu.Game.Overlays.Changelog Direction = FillDirection.Horizontal, Children = new Drawable[] { - listing = new BreadcrumbListing(colours.Violet) + listing = new BreadcrumbListing( /*colours.Violet*/ Color4.WhiteSmoke) { Action = () => ListingSelected?.Invoke() }, @@ -145,14 +147,14 @@ namespace osu.Game.Overlays.Changelog Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(7), - Colour = colours.Violet, + // Colour = colours.Violet, Icon = FontAwesome.Solid.ChevronRight, Alpha = 0, X = -200, }, }, }, - releaseStream = new BreadcrumbRelease(colours.Violet, "Lazer") + releaseStream = new BreadcrumbRelease( /*colours.Violet*/ Color4.WhiteSmoke, "Lazer") { Action = () => titleStream.FlashColour(Color4.White, 500, Easing.OutQuad) } @@ -160,31 +162,45 @@ namespace osu.Game.Overlays.Changelog }, new Box { - Colour = colours.Violet, + //Colour = colours.Violet, RelativeSizeAxes = Axes.X, Height = 2, Anchor = Anchor.BottomLeft, Origin = Anchor.CentreLeft, }, - }; + } + }; + + protected override ScreenTitle CreateTitle() => new ChangelogHeaderTitle(); + + public class HeaderBackground : Sprite + { + public HeaderBackground() + { + RelativeSizeAxes = Axes.Both; + FillMode = FillMode.Fill; + } + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + Texture = textures.Get(@"Headers/changelog"); + } } - public void ShowBuild(string displayName, string displayVersion) + private class ChangelogHeaderTitle : ScreenTitle { - listing.Deactivate(); - releaseStream.ShowBuild($"{displayName} {displayVersion}"); - titleStream.Text = displayName; - titleStream.FlashColour(Color4.White, 500, Easing.OutQuad); - chevron.MoveToX(0, 100).FadeIn(100); - } + public ChangelogHeaderTitle() + { + Title = "Changelog"; + Section = "Listing"; + } - public void ShowListing() - { - releaseStream.Deactivate(); - listing.Activate(); - titleStream.Text = "Listing"; - titleStream.FlashColour(Color4.White, 500, Easing.OutQuad); - chevron.MoveToX(-20, 100).FadeOut(100); + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + AccentColour = colours.Seafoam; + } } } } From 6c26d6fdf908513348548c4c148f73f16b1bb27e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 May 2019 11:13:36 +0900 Subject: [PATCH 165/375] Remove unnecessary getters from ScreenTitle --- osu.Game/Graphics/UserInterface/ScreenTitle.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/ScreenTitle.cs b/osu.Game/Graphics/UserInterface/ScreenTitle.cs index 34c70f2bed..3c3aa8fe85 100644 --- a/osu.Game/Graphics/UserInterface/ScreenTitle.cs +++ b/osu.Game/Graphics/UserInterface/ScreenTitle.cs @@ -19,19 +19,16 @@ namespace osu.Game.Graphics.UserInterface protected IconUsage Icon { - get => iconSprite.Icon; set => iconSprite.Icon = value; } protected string Title { - get => titleText.Text; set => titleText.Text = value; } protected string Section { - get => pageText.Text; set => pageText.Text = value; } From 808b45ac645ce2488dff52de7f55428f386e4044 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 May 2019 11:50:03 +0900 Subject: [PATCH 166/375] Allow custom icon specification in ScreenTitle Not all icons are available in fonts so IconUsage alone is not enough to cover all scenarios. --- .../Graphics/UserInterface/ScreenTitle.cs | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/ScreenTitle.cs b/osu.Game/Graphics/UserInterface/ScreenTitle.cs index 3c3aa8fe85..7b39238e5e 100644 --- a/osu.Game/Graphics/UserInterface/ScreenTitle.cs +++ b/osu.Game/Graphics/UserInterface/ScreenTitle.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -12,14 +13,24 @@ namespace osu.Game.Graphics.UserInterface { public abstract class ScreenTitle : CompositeDrawable, IHasAccentColour { - private readonly SpriteIcon iconSprite; + public const float ICON_WIDTH = ICON_SIZE + icon_spacing; + + protected const float ICON_SIZE = 25; + + private SpriteIcon iconSprite; private readonly OsuSpriteText titleText, pageText; - public const float ICON_WIDTH = icon_size + icon_spacing; - private const float icon_size = 25, icon_spacing = 10; + + private const float icon_spacing = 10; protected IconUsage Icon { - set => iconSprite.Icon = value; + set + { + if (iconSprite == null) + throw new InvalidOperationException($"Cannot use {nameof(Icon)} with a custom {nameof(CreateIcon)} function."); + + iconSprite.Icon = value; + } } protected string Title @@ -38,6 +49,11 @@ namespace osu.Game.Graphics.UserInterface set => pageText.Colour = value; } + protected virtual Drawable CreateIcon() => iconSprite = new SpriteIcon + { + Size = new Vector2(ICON_SIZE), + }; + protected ScreenTitle() { AutoSizeAxes = Axes.Both; @@ -48,12 +64,9 @@ namespace osu.Game.Graphics.UserInterface { AutoSizeAxes = Axes.Both, Spacing = new Vector2(icon_spacing, 0), - Children = new Drawable[] + Children = new[] { - iconSprite = new SpriteIcon - { - Size = new Vector2(icon_size), - }, + CreateIcon(), new FillFlowContainer { AutoSizeAxes = Axes.Both, From aca0fc80a8e25679226b267a9919375d4afff748 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 May 2019 12:45:20 +0900 Subject: [PATCH 167/375] Set HeaderTabControl's default AccentColour to non-transparent Avoids items disappearing if no accent colour is set. --- osu.Game/Overlays/Profile/Header/HeaderTabControl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/Header/HeaderTabControl.cs b/osu.Game/Overlays/Profile/Header/HeaderTabControl.cs index 1169ef7013..5fd9195945 100644 --- a/osu.Game/Overlays/Profile/Header/HeaderTabControl.cs +++ b/osu.Game/Overlays/Profile/Header/HeaderTabControl.cs @@ -17,7 +17,7 @@ namespace osu.Game.Overlays.Profile.Header { private readonly Box bar; - private Color4 accentColour; + private Color4 accentColour = Color4.White; public Color4 AccentColour { From 58a3480b6aa428734449262be6046a12657581cf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 May 2019 12:52:50 +0900 Subject: [PATCH 168/375] Update ChangelogHeader to work again with OverlayHeader --- .../Requests/Responses/APIChangelogBuild.cs | 2 + .../Overlays/Changelog/ChangelogHeader.cs | 237 +++++++----------- osu.Game/Overlays/ChangelogOverlay.cs | 9 +- 3 files changed, 104 insertions(+), 144 deletions(-) diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs index 3377800c2b..504c65928d 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs @@ -41,5 +41,7 @@ namespace osu.Game.Online.API.Requests.Responses [JsonProperty("previous")] public APIChangelogBuild Previous { get; set; } } + + public override string ToString() => $"{UpdateStream.DisplayName} {DisplayVersion}"; } } diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 9ef3316985..4f406daabe 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -1,53 +1,72 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osu.Framework.Allocation; using osu.Framework.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.Sprites; -using osu.Game.Overlays.Changelog.Header; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; +using osu.Game.Online.API.Requests.Responses; using osuTK; -using osuTK.Graphics; namespace osu.Game.Overlays.Changelog { public class ChangelogHeader : OverlayHeader { - private OsuSpriteText titleStream; - private BreadcrumbListing listing; - private SpriteIcon chevron; - private BreadcrumbRelease releaseStream; + public Action ListingSelected; - public delegate void ListingSelectedEventHandler(); + private const string listing_string = "Listing"; - public event ListingSelectedEventHandler ListingSelected; - - private const float title_height = 50; - private const float icon_size = 50; - private const float icon_margin = 20; - private const float version_height = 40; - - public void ShowBuild(string displayName, string displayVersion) + public ChangelogHeader() { - listing.Deactivate(); - releaseStream.ShowBuild($"{displayName} {displayVersion}"); - titleStream.Text = displayName; - titleStream.FlashColour(Color4.White, 500, Easing.OutQuad); - chevron.MoveToX(0, 100).FadeIn(100); + TabControl.AddItem(listing_string); + TabControl.Current.ValueChanged += e => + { + if (e.NewValue == listing_string) + ListingSelected?.Invoke(); + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + TabControl.AccentColour = colours.Violet; + } + + private APIChangelogBuild displayedBuild; + + private ChangelogHeaderTitle title; + + public void ShowBuild(APIChangelogBuild build) + { + hideBuildTab(); + + displayedBuild = build; + + TabControl.AddItem(build.ToString()); + TabControl.Current.Value = build.ToString(); + + title.Version = build.UpdateStream.DisplayName; } public void ShowListing() { - releaseStream.Deactivate(); - listing.Activate(); - titleStream.Text = "Listing"; - titleStream.FlashColour(Color4.White, 500, Easing.OutQuad); - chevron.MoveToX(-20, 100).FadeOut(100); + hideBuildTab(); + + title.Version = null; + } + + private void hideBuildTab() + { + if (displayedBuild != null) + { + TabControl.RemoveItem(displayedBuild.ToString()); + displayedBuild = null; + } } protected override Drawable CreateBackground() => new HeaderBackground(); @@ -57,121 +76,11 @@ namespace osu.Game.Overlays.Changelog RelativeSizeAxes = Axes.Both, Children = new Drawable[] { - new Container - { - Height = title_height, - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Y = -version_height, - Children = new Drawable[] - { - new CircularContainer - { - X = icon_margin, - Masking = true, - //BorderColour = colours.Violet, - BorderThickness = 3, - MaskingSmoothness = 1, - Size = new Vector2(50), - Children = new Drawable[] - { - new Sprite - { - RelativeSizeAxes = Axes.Both, - //Texture = textures.Get(@"Icons/changelog"), - Size = new Vector2(0.8f), - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }, - new Box - { - RelativeSizeAxes = Axes.Both, - //Colour = colours.Violet, - Alpha = 0, - AlwaysPresent = true, - }, - } - }, - new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - X = icon_size + icon_margin * 2, - Children = new Drawable[] - { - new OsuSpriteText - { - Text = "Changelog ", - Font = OsuFont.GetFont(weight: FontWeight.Light, size: 30), - }, - titleStream = new OsuSpriteText - { - Text = "Listing", - Font = OsuFont.GetFont(weight: FontWeight.Light, size: 30), - //Colour = colours.Violet, - }, - } - } - } - }, - new FillFlowContainer // Listing > Lazer 2018.713.1 - { - X = 2 * icon_margin + icon_size, - Height = version_height, - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Direction = FillDirection.Horizontal, - Children = new Drawable[] - { - listing = new BreadcrumbListing( /*colours.Violet*/ Color4.WhiteSmoke) - { - Action = () => ListingSelected?.Invoke() - }, - new Container // without a container, moving the chevron wont work - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Margin = new MarginPadding - { - Top = 10, - Left = 15, - Right = 18, - Bottom = 15, - }, - Children = new Drawable[] - { - chevron = new SpriteIcon - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(7), - // Colour = colours.Violet, - Icon = FontAwesome.Solid.ChevronRight, - Alpha = 0, - X = -200, - }, - }, - }, - releaseStream = new BreadcrumbRelease( /*colours.Violet*/ Color4.WhiteSmoke, "Lazer") - { - Action = () => titleStream.FlashColour(Color4.White, 500, Easing.OutQuad) - } - }, - }, - new Box - { - //Colour = colours.Violet, - RelativeSizeAxes = Axes.X, - Height = 2, - Anchor = Anchor.BottomLeft, - Origin = Anchor.CentreLeft, - }, + // todo: move badge display here } }; - protected override ScreenTitle CreateTitle() => new ChangelogHeaderTitle(); + protected override ScreenTitle CreateTitle() => title = new ChangelogHeaderTitle(); public class HeaderBackground : Sprite { @@ -190,16 +99,64 @@ namespace osu.Game.Overlays.Changelog private class ChangelogHeaderTitle : ScreenTitle { + public string Version + { + set => Section = value ?? listing_string; + } + public ChangelogHeaderTitle() { Title = "Changelog"; - Section = "Listing"; + Version = null; } [BackgroundDependencyLoader] private void load(OsuColour colours) { - AccentColour = colours.Seafoam; + AccentColour = colours.Violet; + } + + protected override Drawable CreateIcon() => new ChangelogIcon(); + + internal class ChangelogIcon : CompositeDrawable + { + private const float circle_allowance = 0.8f; + + [BackgroundDependencyLoader] + private void load(TextureStore textures, OsuColour colours) + { + Size = new Vector2(ICON_SIZE / circle_allowance); + + InternalChildren = new Drawable[] + { + new CircularContainer + { + Masking = true, + BorderColour = colours.Violet, + BorderThickness = 3, + MaskingSmoothness = 1, + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + new Sprite + { + RelativeSizeAxes = Axes.Both, + Texture = textures.Get(@"Icons/changelog"), + Size = new Vector2(circle_allowance), + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colours.Violet, + Alpha = 0, + AlwaysPresent = true, + }, + } + }, + }; + } } } } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 22c362d49d..430fa569f1 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -58,7 +58,10 @@ namespace osu.Game.Overlays Direction = FillDirection.Vertical, Children = new Drawable[] { - header = new ChangelogHeader(), + header = new ChangelogHeader + { + ListingSelected = ShowListing, + }, badges = new BadgeDisplay(), content = new Container { @@ -70,8 +73,6 @@ namespace osu.Game.Overlays }, }; - header.ListingSelected += ShowListing; - // todo: better badges.Current.ValueChanged += e => { @@ -135,7 +136,7 @@ namespace osu.Game.Overlays return; } - header.ShowBuild(build.UpdateStream.DisplayName, build.DisplayVersion); + header.ShowBuild(build); badges.Current.Value = build.UpdateStream; loadContent(new ChangelogSingleBuild(build)); From a131875a7b40346b62f67175a40016fe7c998c0a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 May 2019 13:34:35 +0900 Subject: [PATCH 169/375] Use bindables the whole way --- .../Requests/Responses/APIChangelogBuild.cs | 4 +- .../API/Requests/Responses/APIUpdateStream.cs | 8 +- .../Overlays/Changelog/ChangelogHeader.cs | 42 +++++----- osu.Game/Overlays/ChangelogOverlay.cs | 81 ++++++++++--------- 4 files changed, 65 insertions(+), 70 deletions(-) diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs index 504c65928d..36c9cc610f 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; namespace osu.Game.Online.API.Requests.Responses { - public class APIChangelogBuild + public class APIChangelogBuild : IEquatable { [JsonProperty("id")] public long Id { get; set; } @@ -42,6 +42,8 @@ namespace osu.Game.Online.API.Requests.Responses public APIChangelogBuild Previous { get; set; } } + public bool Equals(APIChangelogBuild other) => this.Id == other?.Id; + public override string ToString() => $"{UpdateStream.DisplayName} {DisplayVersion}"; } } diff --git a/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs b/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs index 4c65b562dd..0c3fee88c7 100644 --- a/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs +++ b/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs @@ -25,13 +25,7 @@ namespace osu.Game.Online.API.Requests.Responses [JsonProperty("latest_build")] public APIChangelogBuild LatestBuild { get; set; } - public bool Equals(APIUpdateStream other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - - return Id == other.Id; - } + public bool Equals(APIUpdateStream other) => this.Id == other?.Id; public ColourInfo Colour { diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 4f406daabe..ccc976c4dc 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -3,6 +3,7 @@ using System; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -17,6 +18,8 @@ namespace osu.Game.Overlays.Changelog { public class ChangelogHeader : OverlayHeader { + public readonly Bindable Current = new Bindable(); + public Action ListingSelected; private const string listing_string = "Listing"; @@ -29,6 +32,8 @@ namespace osu.Game.Overlays.Changelog if (e.NewValue == listing_string) ListingSelected?.Invoke(); }; + + Current.ValueChanged += showBuild; } [BackgroundDependencyLoader] @@ -37,35 +42,24 @@ namespace osu.Game.Overlays.Changelog TabControl.AccentColour = colours.Violet; } - private APIChangelogBuild displayedBuild; - private ChangelogHeaderTitle title; - public void ShowBuild(APIChangelogBuild build) + private void showBuild(ValueChangedEvent e) { - hideBuildTab(); + if (e.OldValue != null) + TabControl.RemoveItem(e.OldValue.ToString()); - displayedBuild = build; - - TabControl.AddItem(build.ToString()); - TabControl.Current.Value = build.ToString(); - - title.Version = build.UpdateStream.DisplayName; - } - - public void ShowListing() - { - hideBuildTab(); - - title.Version = null; - } - - private void hideBuildTab() - { - if (displayedBuild != null) + if (e.NewValue != null) { - TabControl.RemoveItem(displayedBuild.ToString()); - displayedBuild = null; + TabControl.AddItem(e.NewValue.ToString()); + TabControl.Current.Value = e.NewValue.ToString(); + + title.Version = e.NewValue.UpdateStream.DisplayName; + } + else + { + TabControl.Current.Value = listing_string; + title.Version = null; } } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 430fa569f1..34347d8e0a 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -1,12 +1,14 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Collections.Generic; -using System.Linq; using System.Threading; +using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -32,6 +34,23 @@ namespace osu.Game.Overlays private List builds; + public readonly Bindable Current = new Bindable(); + + public void ShowListing() => Current.Value = null; + + /// + /// Fetches and shows a specific build from a specific update stream. + /// + /// Must contain at least and + /// . If and + /// are specified, the header will instantly display them. + public void ShowBuild([NotNull] APIChangelogBuild build) + { + if (build == null) throw new ArgumentNullException(nameof(build)); + + Current.Value = build; + } + [BackgroundDependencyLoader] private void load(AudioManager audio, OsuColour colour) { @@ -73,22 +92,30 @@ namespace osu.Game.Overlays }, }; - // todo: better badges.Current.ValueChanged += e => { - if (e.NewValue?.LatestBuild != null) + if (e.NewValue != null) ShowBuild(e.NewValue.LatestBuild); }; sampleBack = audio.Sample.Get(@"UI/generic-select-soft"); - } - protected override void PopIn() - { - base.PopIn(); + header.Current.BindTo(Current); - if (!initialFetchPerformed) - fetchListing(); + Current.BindValueChanged(e => + { + if (e.NewValue != null) + { + badges.Current.Value = e.NewValue.UpdateStream; + + loadContent(new ChangelogSingleBuild(e.NewValue)); + } + else + { + badges.Current.Value = null; + loadContent(new ChangelogListing(builds)); + } + }); } public override bool OnPressed(GlobalAction action) @@ -96,13 +123,13 @@ namespace osu.Game.Overlays switch (action) { case GlobalAction.Back: - if (content.Child is ChangelogListing) + if (Current.Value == null) { State = Visibility.Hidden; } else { - ShowListing(); + Current.Value = null; sampleBack?.Play(); } @@ -112,34 +139,12 @@ namespace osu.Game.Overlays return false; } - public void ShowListing() + protected override void PopIn() { - if (content.Children.FirstOrDefault() is ChangelogListing) - return; + base.PopIn(); - header.ShowListing(); - badges.Current.Value = null; - loadContent(new ChangelogListing(builds)); - } - - /// - /// Fetches and shows a specific build from a specific update stream. - /// - /// Must contain at least and - /// . If and - /// are specified, the header will instantly display them. - public void ShowBuild(APIChangelogBuild build) - { - if (build == null) - { - ShowListing(); - return; - } - - header.ShowBuild(build); - badges.Current.Value = build.UpdateStream; - - loadContent(new ChangelogSingleBuild(build)); + if (!initialFetchPerformed) + fetchListing(); } private bool initialFetchPerformed; @@ -158,7 +163,7 @@ namespace osu.Game.Overlays builds = res.Builds; badges.Populate(res.Streams); - ShowListing(); + Current.TriggerChange(); }; req.Failure += _ => initialFetchPerformed = false; From 9a769c9f15801ff781621b160a953e7c5c777c32 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 May 2019 13:36:21 +0900 Subject: [PATCH 170/375] Move OverlayHeaderTabControl to correct namespace --- osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs | 3 ++- osu.Game/Overlays/OverlayHeader.cs | 5 ++--- .../HeaderTabControl.cs => OverlayHeaderTabControl.cs} | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) rename osu.Game/Overlays/{Profile/Header/HeaderTabControl.cs => OverlayHeaderTabControl.cs} (97%) diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs b/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs index 730140faed..d9230090fc 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs @@ -7,6 +7,7 @@ using osu.Framework.Allocation; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Game.Online.API.Requests; +using osu.Game.Overlays; using osu.Game.Overlays.Profile; using osu.Game.Overlays.Profile.Header; using osu.Game.Overlays.Profile.Header.Components; @@ -21,7 +22,7 @@ namespace osu.Game.Tests.Visual.Online typeof(ProfileHeader), typeof(RankGraph), typeof(LineGraph), - typeof(HeaderTabControl), + typeof(OverlayHeaderTabControl), typeof(CentreHeaderContainer), typeof(BottomHeaderContainer), typeof(DetailHeaderContainer), diff --git a/osu.Game/Overlays/OverlayHeader.cs b/osu.Game/Overlays/OverlayHeader.cs index fe50d4a2be..2e032db2ba 100644 --- a/osu.Game/Overlays/OverlayHeader.cs +++ b/osu.Game/Overlays/OverlayHeader.cs @@ -4,13 +4,12 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics.UserInterface; -using osu.Game.Overlays.Profile.Header; namespace osu.Game.Overlays { public abstract class OverlayHeader : Container { - protected readonly HeaderTabControl TabControl; + protected readonly OverlayHeaderTabControl TabControl; private const float cover_height = 150; private const float cover_info_height = 75; @@ -41,7 +40,7 @@ namespace osu.Game.Overlays Children = new Drawable[] { CreateTitle().With(t => t.X = -ScreenTitle.ICON_WIDTH), - TabControl = new HeaderTabControl + TabControl = new OverlayHeaderTabControl { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, diff --git a/osu.Game/Overlays/Profile/Header/HeaderTabControl.cs b/osu.Game/Overlays/OverlayHeaderTabControl.cs similarity index 97% rename from osu.Game/Overlays/Profile/Header/HeaderTabControl.cs rename to osu.Game/Overlays/OverlayHeaderTabControl.cs index 5fd9195945..21b42cfbf4 100644 --- a/osu.Game/Overlays/Profile/Header/HeaderTabControl.cs +++ b/osu.Game/Overlays/OverlayHeaderTabControl.cs @@ -11,9 +11,9 @@ using osu.Game.Graphics.UserInterface; using osuTK; using osuTK.Graphics; -namespace osu.Game.Overlays.Profile.Header +namespace osu.Game.Overlays { - public class HeaderTabControl : TabControl + public class OverlayHeaderTabControl : TabControl { private readonly Box bar; @@ -43,7 +43,7 @@ namespace osu.Game.Overlays.Profile.Header set => TabContainer.Padding = value; } - public HeaderTabControl() + public OverlayHeaderTabControl() { TabContainer.Masking = false; TabContainer.Spacing = new Vector2(15, 0); From 340b207fa0013b9fee8d99bdf4e5f17967bcd160 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 May 2019 13:37:35 +0900 Subject: [PATCH 171/375] Delete breadcrumb implementation --- .../Online/TestSceneChangelogOverlay.cs | 4 - .../UserInterface/TestSceneTextBadgePair.cs | 57 -------- .../Overlays/Changelog/Header/Breadcrumb.cs | 127 ------------------ .../Changelog/Header/BreadcrumbListing.cs | 66 --------- .../Changelog/Header/BreadcrumbRelease.cs | 35 ----- 5 files changed, 289 deletions(-) delete mode 100644 osu.Game.Tests/Visual/UserInterface/TestSceneTextBadgePair.cs delete mode 100644 osu.Game/Overlays/Changelog/Header/Breadcrumb.cs delete mode 100644 osu.Game/Overlays/Changelog/Header/BreadcrumbListing.cs delete mode 100644 osu.Game/Overlays/Changelog/Header/BreadcrumbRelease.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs index 4ac5514019..c97ef384d3 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs @@ -7,7 +7,6 @@ using NUnit.Framework; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays; using osu.Game.Overlays.Changelog; -using osu.Game.Overlays.Changelog.Header; namespace osu.Game.Tests.Visual.Online { @@ -25,9 +24,6 @@ namespace osu.Game.Tests.Visual.Online typeof(ChangelogListing), typeof(ChangelogSingleBuild), typeof(ChangelogBuild), - typeof(Breadcrumb), - typeof(BreadcrumbListing), - typeof(BreadcrumbRelease), }; protected override void LoadComplete() diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneTextBadgePair.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneTextBadgePair.cs deleted file mode 100644 index 67b2b9854d..0000000000 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneTextBadgePair.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osu.Game.Overlays.Changelog.Header; -using osuTK.Graphics; - -namespace osu.Game.Tests.Visual.UserInterface -{ - public class TestSceneTextBadgePair : OsuTestScene - { - public TestSceneTextBadgePair() - { - Breadcrumb breadcrumb; - - Add(new Container - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Width = 250, - Height = 50, - Children = new Drawable[] - { - new Box - { - Colour = Color4.Gray, - Alpha = 0.5f, - RelativeSizeAxes = Axes.Both, - }, - breadcrumb = new TestBadgePair(Color4.DeepSkyBlue, "Test") - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - } - } - }); - - AddStep(@"Deactivate", breadcrumb.Deactivate); - AddStep(@"Activate", breadcrumb.Activate); - AddStep(@"Hide text", () => breadcrumb.HideText(200)); - AddStep(@"Show text", () => breadcrumb.ShowText(200)); - AddStep(@"Different text", () => breadcrumb.ShowText(200, "This one's a little bit wider")); - AddStep(@"Different text", () => breadcrumb.ShowText(200, "Ok?..")); - } - - private class TestBadgePair : Breadcrumb - { - public TestBadgePair(ColourInfo badgeColour, string displayText = "Listing", bool startCollapsed = true) - : base(badgeColour, displayText, startCollapsed) - { - } - } - } -} diff --git a/osu.Game/Overlays/Changelog/Header/Breadcrumb.cs b/osu.Game/Overlays/Changelog/Header/Breadcrumb.cs deleted file mode 100644 index f960111a53..0000000000 --- a/osu.Game/Overlays/Changelog/Header/Breadcrumb.cs +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Allocation; -using osu.Framework.Audio; -using osu.Framework.Audio.Sample; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Input.Events; -using System; -using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; -using osu.Game.Overlays.Changelog.Components; - -namespace osu.Game.Overlays.Changelog.Header -{ - public abstract class Breadcrumb : Container - { - protected SpriteText Text; - protected LineBadge LineBadge; - - public bool IsActivated { get; protected set; } - - public Action Action; - - private SampleChannel sampleHover; - private SampleChannel sampleActivate; - - protected Breadcrumb(ColourInfo badgeColour, string displayText = "Listing", bool startCollapsed = true) - { - AutoSizeAxes = Axes.X; - RelativeSizeAxes = Axes.Y; - Children = new Drawable[] - { - Text = new OsuSpriteText - { - Font = OsuFont.GetFont(size: 16), - Text = displayText, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Margin = new MarginPadding { Top = 5, Bottom = 15 }, - }, - LineBadge = new LineBadge(startCollapsed) - { - CollapsedSize = 2, - UncollapsedSize = 10, - Colour = badgeColour, - Anchor = Anchor.BottomCentre, - Origin = Anchor.Centre, - } - }; - } - - public virtual void Deactivate() - { - if (!IsActivated) - return; - - IsActivated = false; - LineBadge.Collapse(); - Text.Font = Text.Font.With(weight: FontWeight.Regular); - } - - public virtual void Activate() - { - if (IsActivated) - return; - - IsActivated = true; - LineBadge.Uncollapse(); - Text.Font = Text.Font.With(weight: FontWeight.Bold); - } - - public void SetTextColour(ColourInfo newColour, double duration = 0, Easing easing = Easing.None) - { - Text.FadeColour(newColour, duration, easing); - } - - public void HideText(double duration = 0, Easing easing = Easing.InOutCubic) - { - LineBadge.Collapse(); - Text.MoveToY(20, duration, easing) - .FadeOut(duration, easing); - } - - public void ShowText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) - { - LineBadge.Collapse(); - Text.MoveToY(20, duration, easing) - .FadeOut(duration, easing) - .Then() - .MoveToY(0, duration, easing) - .FadeIn(duration, easing); - - Scheduler.AddDelayed(() => - { - Text.Text = displayText; - LineBadge.Uncollapse(); - }, duration); - } - - protected override bool OnHover(HoverEvent e) - { - if (!IsActivated) - sampleHover?.Play(); - return base.OnHover(e); - } - - protected override bool OnClick(ClickEvent e) - { - Action?.Invoke(); - Activate(); - sampleActivate?.Play(); - - return true; - } - - [BackgroundDependencyLoader] - private void load(AudioManager audio) - { - sampleHover = audio.Sample.Get(@"UI/generic-hover-soft"); - sampleActivate = audio.Sample.Get(@"UI/generic-select-soft"); - } - } -} diff --git a/osu.Game/Overlays/Changelog/Header/BreadcrumbListing.cs b/osu.Game/Overlays/Changelog/Header/BreadcrumbListing.cs deleted file mode 100644 index 50db916e7e..0000000000 --- a/osu.Game/Overlays/Changelog/Header/BreadcrumbListing.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; -using osu.Framework.Input.Events; -using osu.Game.Graphics; -using osuTK.Graphics; - -namespace osu.Game.Overlays.Changelog.Header -{ - public class BreadcrumbListing : Breadcrumb - { - private readonly ColourInfo badgeColour; - - public BreadcrumbListing(ColourInfo badgeColour) - : base(badgeColour, "Listing", false) - { - this.badgeColour = badgeColour; - Text.Font = Text.Font.With(weight: FontWeight.Bold); - Text.Anchor = Anchor.TopCentre; - Text.Origin = Anchor.TopCentre; - - AutoSizeAxes = Axes.None; - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - Activate(); - Width = Text.DrawWidth; - } - - public override void Activate() - { - if (IsActivated) - return; - - base.Activate(); - SetTextColour(Color4.White, 100); - } - - public override void Deactivate() - { - if (!IsActivated) - return; - - base.Deactivate(); - SetTextColour(badgeColour, 100); - } - - protected override bool OnHover(HoverEvent e) - { - LineBadge.Uncollapse(); - return base.OnHover(e); - } - - protected override void OnHoverLost(HoverLostEvent e) - { - if (!IsActivated) - LineBadge.Collapse(); - base.OnHoverLost(e); - } - } -} diff --git a/osu.Game/Overlays/Changelog/Header/BreadcrumbRelease.cs b/osu.Game/Overlays/Changelog/Header/BreadcrumbRelease.cs deleted file mode 100644 index 43711af61b..0000000000 --- a/osu.Game/Overlays/Changelog/Header/BreadcrumbRelease.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Graphics.Colour; -using osu.Game.Graphics; - -namespace osu.Game.Overlays.Changelog.Header -{ - public class BreadcrumbRelease : Breadcrumb - { - private const float transition_duration = 125; - - public BreadcrumbRelease(ColourInfo badgeColour, string displayText) - : base(badgeColour, displayText) - { - Text.Font = Text.Font.With(weight: FontWeight.Bold); - Text.Y = 20; - Text.Alpha = 0; - } - - public void ShowBuild(string displayText = null) - { - ShowText(transition_duration, displayText); - IsActivated = true; - } - - public override void Deactivate() - { - if (!IsActivated) - return; - - HideText(transition_duration); - } - } -} From e7c8c4f787fac5005521a92a05ef5a3f805af4f8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 May 2019 14:02:17 +0900 Subject: [PATCH 172/375] Fix incorrectly changed colour --- osu.Game/Graphics/OsuColour.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/OsuColour.cs b/osu.Game/Graphics/OsuColour.cs index d337455176..53693a1e38 100644 --- a/osu.Game/Graphics/OsuColour.cs +++ b/osu.Game/Graphics/OsuColour.cs @@ -77,7 +77,7 @@ namespace osu.Game.Graphics public readonly Color4 Seafoam = FromHex(@"05ffa2"); public readonly Color4 GreySeafoamLighter = FromHex(@"9ebab1"); - public readonly Color4 GreySeafoamLight = FromHex(@"4e7466"); + public readonly Color4 GreySeafoamLight = FromHex(@"4d7365"); public readonly Color4 GreySeafoam = FromHex(@"33413c"); public readonly Color4 GreySeafoamDark = FromHex(@"2c3532"); public readonly Color4 GreySeafoamDarker = FromHex(@"1e2422"); From a9447eaf7b2beee0e7f99589855dc39201303f71 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 May 2019 14:02:34 +0900 Subject: [PATCH 173/375] Remove redundant prefixes --- osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs | 2 +- osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs index 36c9cc610f..40f1b791f9 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogBuild.cs @@ -42,7 +42,7 @@ namespace osu.Game.Online.API.Requests.Responses public APIChangelogBuild Previous { get; set; } } - public bool Equals(APIChangelogBuild other) => this.Id == other?.Id; + public bool Equals(APIChangelogBuild other) => Id == other?.Id; public override string ToString() => $"{UpdateStream.DisplayName} {DisplayVersion}"; } diff --git a/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs b/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs index 0c3fee88c7..ef204c7687 100644 --- a/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs +++ b/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs @@ -25,7 +25,7 @@ namespace osu.Game.Online.API.Requests.Responses [JsonProperty("latest_build")] public APIChangelogBuild LatestBuild { get; set; } - public bool Equals(APIUpdateStream other) => this.Id == other?.Id; + public bool Equals(APIUpdateStream other) => Id == other?.Id; public ColourInfo Colour { From 24a7e624df1464eedd64b3c56bf999bb76c8f15a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 May 2019 14:35:11 +0900 Subject: [PATCH 174/375] Only propagate badge value changes if not the current UpdateStream --- osu.Game/Overlays/ChangelogOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 34347d8e0a..daee91416c 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -94,7 +94,7 @@ namespace osu.Game.Overlays badges.Current.ValueChanged += e => { - if (e.NewValue != null) + if (e.NewValue?.LatestBuild != null && e.NewValue != Current.Value?.UpdateStream) ShowBuild(e.NewValue.LatestBuild); }; From a18e0b3b2faa0d94601021a688ee88efe09cb15b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 May 2019 14:46:12 +0900 Subject: [PATCH 175/375] Fix test scene --- .../Visual/Online/TestSceneChangelogOverlay.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs index c97ef384d3..2c941d4a48 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs @@ -41,7 +41,17 @@ namespace osu.Game.Tests.Visual.Online changelog.ShowBuild(new APIChangelogBuild { Version = "2018.712.0", + DisplayVersion = "2018.712.0", UpdateStream = new APIUpdateStream { Name = "lazer" }, + ChangelogEntries = new List() + { + new APIChangelogEntry + { + Category = "Test", + Title = "Title", + MessageHtml = "Message", + } + } }); changelog.Show(); }); From 9e1f2d4fbcb3ab924f8b2a73c6314eb936688f48 Mon Sep 17 00:00:00 2001 From: Welsar55 Date: Tue, 21 May 2019 21:48:09 -0500 Subject: [PATCH 176/375] Added ability to reset all mods by pressing 1 as present on stable. --- osu.Game/Overlays/Mods/ModSection.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Mods/ModSection.cs b/osu.Game/Overlays/Mods/ModSection.cs index 50400e254f..f584eff0f9 100644 --- a/osu.Game/Overlays/Mods/ModSection.cs +++ b/osu.Game/Overlays/Mods/ModSection.cs @@ -57,7 +57,11 @@ namespace osu.Game.Overlays.Mods protected override bool OnKeyDown(KeyDownEvent e) { - if (ToggleKeys != null) + if(e.Key == Key.Number1) + { + DeselectAll(); + } + else if (ToggleKeys != null) { var index = Array.IndexOf(ToggleKeys, e.Key); if (index > -1 && index < buttons.Length) From 555822a68da554b9f3e63e4436f6b6e3d8189ab7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 22 May 2019 13:28:41 +0900 Subject: [PATCH 177/375] Remove unnecessary brackets --- osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs index 2c941d4a48..6db289efd7 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs @@ -43,7 +43,7 @@ namespace osu.Game.Tests.Visual.Online Version = "2018.712.0", DisplayVersion = "2018.712.0", UpdateStream = new APIUpdateStream { Name = "lazer" }, - ChangelogEntries = new List() + ChangelogEntries = new List { new APIChangelogEntry { From 92c991494d8dab709e8adb9bacba8d7c86093811 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 22 May 2019 16:33:50 +0900 Subject: [PATCH 178/375] Fix (and rename) ExpandingBar --- ...eLineBadge.cs => TestSceneExpandingBar.cs} | 25 +++-- .../Graphics/UserInterface/ExpandingBar.cs | 101 ++++++++++++++++++ .../Changelog/Components/LineBadge.cs | 86 --------------- osu.Game/Overlays/Changelog/StreamBadge.cs | 16 +-- osu.Game/Overlays/OverlayHeaderTabControl.cs | 17 ++- 5 files changed, 129 insertions(+), 116 deletions(-) rename osu.Game.Tests/Visual/UserInterface/{TestSceneLineBadge.cs => TestSceneExpandingBar.cs} (60%) create mode 100644 osu.Game/Graphics/UserInterface/ExpandingBar.cs delete mode 100644 osu.Game/Overlays/Changelog/Components/LineBadge.cs diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneLineBadge.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneExpandingBar.cs similarity index 60% rename from osu.Game.Tests/Visual/UserInterface/TestSceneLineBadge.cs rename to osu.Game.Tests/Visual/UserInterface/TestSceneExpandingBar.cs index 14e7b45ee6..974dbf0282 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneLineBadge.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneExpandingBar.cs @@ -4,17 +4,17 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Game.Overlays.Changelog.Components; +using osu.Game.Graphics.UserInterface; using osuTK.Graphics; namespace osu.Game.Tests.Visual.UserInterface { - public class TestSceneLineBadge : OsuTestScene + public class TestSceneExpandingBar : OsuTestScene { - public TestSceneLineBadge() + public TestSceneExpandingBar() { Container container; - LineBadge lineBadge; + ExpandingBar expandingBar; Add(container = new Container { @@ -28,24 +28,23 @@ namespace osu.Game.Tests.Visual.UserInterface Alpha = 0.5f, RelativeSizeAxes = Axes.Both, }, - lineBadge = new LineBadge + expandingBar = new ExpandingBar { Anchor = Anchor.Centre, - UncollapsedSize = 10, + ExpandedSize = 10, CollapsedSize = 2, Colour = Color4.DeepSkyBlue, } } }); - AddStep(@"", () => { }); - AddStep(@"Collapse", () => lineBadge.Collapse()); - AddStep(@"Uncollapse", () => lineBadge.Uncollapse()); + AddStep(@"Collapse", () => expandingBar.Collapse()); + AddStep(@"Uncollapse", () => expandingBar.Expand()); AddSliderStep(@"Resize container", 1, 300, 150, value => container.ResizeTo(value)); - AddStep(@"Horizontal", () => lineBadge.IsHorizontal = true); - AddStep(@"Anchor top", () => lineBadge.Anchor = Anchor.TopCentre); - AddStep(@"Vertical", () => lineBadge.IsHorizontal = false); - AddStep(@"Anchor left", () => lineBadge.Anchor = Anchor.CentreLeft); + AddStep(@"Horizontal", () => expandingBar.RelativeSizeAxes = Axes.X); + AddStep(@"Anchor top", () => expandingBar.Anchor = Anchor.TopCentre); + AddStep(@"Vertical", () => expandingBar.RelativeSizeAxes = Axes.Y); + AddStep(@"Anchor left", () => expandingBar.Anchor = Anchor.CentreLeft); } } } diff --git a/osu.Game/Graphics/UserInterface/ExpandingBar.cs b/osu.Game/Graphics/UserInterface/ExpandingBar.cs new file mode 100644 index 0000000000..439a6002d8 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/ExpandingBar.cs @@ -0,0 +1,101 @@ +// 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.Shapes; +using osuTK; + +namespace osu.Game.Graphics.UserInterface +{ + /// + /// A rounded bar which can be expanded or collapsed. + /// Generally used for tabs or breadcrumbs. + /// + public class ExpandingBar : Circle + { + private bool isCollapsed; + + public bool IsCollapsed + { + get => isCollapsed; + set + { + if (value == isCollapsed) + return; + + isCollapsed = value; + updateState(); + } + } + + private float expandedSize = 4; + + public float ExpandedSize + { + get => expandedSize; + set + { + if (value == expandedSize) + return; + + expandedSize = value; + updateState(); + } + } + + private float collapsedSize = 2; + + public float CollapsedSize + { + get => collapsedSize; + set + { + if (value == collapsedSize) + return; + + collapsedSize = value; + updateState(); + } + } + + public override Axes RelativeSizeAxes + { + get => base.RelativeSizeAxes; + set + { + base.RelativeSizeAxes = Axes.None; + Size = Vector2.Zero; + + base.RelativeSizeAxes = value; + updateState(); + } + } + + public ExpandingBar() + { + RelativeSizeAxes = Axes.X; + Origin = Anchor.Centre; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + updateState(); + } + + public void Collapse() => IsCollapsed = true; + + public void Expand() => IsCollapsed = false; + + private void updateState() + { + float newSize = IsCollapsed ? CollapsedSize : ExpandedSize; + Easing easingType = IsCollapsed ? Easing.Out : Easing.OutElastic; + + if (RelativeSizeAxes == Axes.X) + this.ResizeHeightTo(newSize, 400, easingType); + else + this.ResizeWidthTo(newSize, 400, easingType); + } + } +} diff --git a/osu.Game/Overlays/Changelog/Components/LineBadge.cs b/osu.Game/Overlays/Changelog/Components/LineBadge.cs deleted file mode 100644 index 84cd712eef..0000000000 --- a/osu.Game/Overlays/Changelog/Components/LineBadge.cs +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Graphics; -using osu.Framework.Graphics.Shapes; - -namespace osu.Game.Overlays.Changelog.Components -{ - /// - /// A simple rounded expandable line. Set its - /// property to the center of the edge it's meant stick with. By default, - /// takes up the full parent's axis defined by . - /// - public class LineBadge : Circle - { - public float UncollapsedSize; - public float CollapsedSize; - - public bool IsCollapsed { get; private set; } - private bool isHorizontal; - - /// - /// Automatically sets the RelativeSizeAxes and switches X and Y size components when changed. - /// - public bool IsHorizontal - { - get => isHorizontal; - set - { - if (value == isHorizontal) - return; - - if (IsLoaded) - { - FinishTransforms(); - var height = Height; - var width = Width; - RelativeSizeAxes = value ? Axes.X : Axes.Y; - Width = height; - Height = width; - } - else - RelativeSizeAxes = value ? Axes.X : Axes.Y; - - isHorizontal = value; - } - } - - /// Whether to initialize with the - /// or the . - public LineBadge(bool startCollapsed = true) - { - IsCollapsed = startCollapsed; - RelativeSizeAxes = Axes.X; - isHorizontal = true; - Origin = Anchor.Centre; - } - - protected override void LoadComplete() - { - if (isHorizontal) - Height = IsCollapsed ? CollapsedSize : UncollapsedSize; - else - Width = IsCollapsed ? CollapsedSize : UncollapsedSize; - base.LoadComplete(); - } - - public void Collapse(float transitionDuration = 400, Easing easing = Easing.Out) - { - IsCollapsed = true; - if (IsHorizontal) - this.ResizeHeightTo(CollapsedSize, transitionDuration, easing); - else - this.ResizeWidthTo(CollapsedSize, transitionDuration, easing); - } - - public void Uncollapse(float transitionDuration = 400, Easing easing = Easing.OutElastic) - { - IsCollapsed = false; - if (IsHorizontal) - this.ResizeHeightTo(UncollapsedSize, transitionDuration, easing); - else - this.ResizeWidthTo(UncollapsedSize, transitionDuration, easing); - } - } -} diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index bdddc1f968..e3c5cba496 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -12,7 +12,7 @@ using osu.Game.Graphics; using osu.Game.Online.API.Requests.Responses; using System; using osu.Game.Graphics.Sprites; -using osu.Game.Overlays.Changelog.Components; +using osu.Game.Graphics.UserInterface; using osuTK.Graphics; namespace osu.Game.Overlays.Changelog @@ -27,7 +27,7 @@ namespace osu.Game.Overlays.Changelog private bool isActivated; - private readonly LineBadge lineBadge; + private readonly ExpandingBar expandingBar; private SampleChannel sampleClick; private SampleChannel sampleHover; @@ -71,11 +71,11 @@ namespace osu.Game.Overlays.Changelog }, } }, - lineBadge = new LineBadge(false) + expandingBar = new ExpandingBar { Anchor = Anchor.TopCentre, Colour = stream.Colour, - UncollapsedSize = 4, + ExpandedSize = 4, CollapsedSize = 2, }, }; @@ -87,7 +87,7 @@ namespace osu.Game.Overlays.Changelog { isActivated = true; this.FadeIn(transition_duration); - lineBadge.Uncollapse(); + expandingBar.Expand(); if (!withoutFiringUpdates) Selected?.Invoke(); } @@ -100,7 +100,7 @@ namespace osu.Game.Overlays.Changelog if (!IsHovered) { this.FadeTo(0.5f, transition_duration); - lineBadge.Collapse(200); + expandingBar.Collapse(); } } @@ -116,7 +116,7 @@ namespace osu.Game.Overlays.Changelog sampleHover?.Play(); DisableDim(); this.FadeIn(transition_duration); - lineBadge.Uncollapse(); + expandingBar.Expand(); return base.OnHover(e); } @@ -125,7 +125,7 @@ namespace osu.Game.Overlays.Changelog if (!isActivated) { this.FadeTo(0.5f, transition_duration); - lineBadge.Collapse(200); + expandingBar.Collapse(); } else EnableDim(); diff --git a/osu.Game/Overlays/OverlayHeaderTabControl.cs b/osu.Game/Overlays/OverlayHeaderTabControl.cs index 21b42cfbf4..dfe7e52420 100644 --- a/osu.Game/Overlays/OverlayHeaderTabControl.cs +++ b/osu.Game/Overlays/OverlayHeaderTabControl.cs @@ -67,7 +67,7 @@ namespace osu.Game.Overlays private class HeaderTabItem : TabItem { private readonly OsuSpriteText text; - private readonly Drawable bar; + private readonly ExpandingBar bar; private Color4 accentColour; @@ -92,7 +92,7 @@ namespace osu.Game.Overlays AutoSizeAxes = Axes.X; RelativeSizeAxes = Axes.Y; - Children = new[] + Children = new Drawable[] { text = new OsuSpriteText { @@ -102,12 +102,11 @@ namespace osu.Game.Overlays Text = value, Font = OsuFont.GetFont() }, - bar = new Circle + bar = new ExpandingBar { - RelativeSizeAxes = Axes.X, - Height = 0, - Origin = Anchor.CentreLeft, - Anchor = Anchor.BottomLeft, + Anchor = Anchor.BottomCentre, + ExpandedSize = 7.5f, + CollapsedSize = 0 }, new HoverClickSounds() }; @@ -138,7 +137,7 @@ namespace osu.Game.Overlays if (Active.Value || IsHovered) { text.FadeColour(Color4.White, 120, Easing.InQuad); - bar.ResizeHeightTo(7.5f, 120, Easing.InQuad); + bar.Expand(); if (Active.Value) text.Font = text.Font.With(weight: FontWeight.Bold); @@ -146,7 +145,7 @@ namespace osu.Game.Overlays else { text.FadeColour(AccentColour, 120, Easing.InQuad); - bar.ResizeHeightTo(0, 120, Easing.InQuad); + bar.Collapse(); text.Font = text.Font.With(weight: FontWeight.Medium); } } From 9f9e86f18c92d65773714532180fc0cb566bf67b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 22 May 2019 17:04:21 +0900 Subject: [PATCH 179/375] Rename classes and fix back-to-front state --- .../Visual/Online/TestSceneChangelogOverlay.cs | 2 +- osu.Game/Overlays/Changelog/StreamBadge.cs | 1 + .../{BadgeDisplay.cs => StreamBadgeArea.cs} | 4 ++-- osu.Game/Overlays/ChangelogOverlay.cs | 12 ++++++------ 4 files changed, 10 insertions(+), 9 deletions(-) rename osu.Game/Overlays/Changelog/{BadgeDisplay.cs => StreamBadgeArea.cs} (96%) diff --git a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs index 6db289efd7..2e8e05fb0f 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs @@ -17,7 +17,7 @@ namespace osu.Game.Tests.Visual.Online public override IReadOnlyList RequiredTypes => new[] { - typeof(BadgeDisplay), + typeof(StreamBadgeArea), typeof(StreamBadge), typeof(ChangelogHeader), typeof(ChangelogContent), diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index e3c5cba496..ef1dda5b41 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -77,6 +77,7 @@ namespace osu.Game.Overlays.Changelog Colour = stream.Colour, ExpandedSize = 4, CollapsedSize = 2, + IsCollapsed = true }, }; } diff --git a/osu.Game/Overlays/Changelog/BadgeDisplay.cs b/osu.Game/Overlays/Changelog/StreamBadgeArea.cs similarity index 96% rename from osu.Game/Overlays/Changelog/BadgeDisplay.cs rename to osu.Game/Overlays/Changelog/StreamBadgeArea.cs index 9b0f152eb0..9d8fc6773d 100644 --- a/osu.Game/Overlays/Changelog/BadgeDisplay.cs +++ b/osu.Game/Overlays/Changelog/StreamBadgeArea.cs @@ -12,7 +12,7 @@ using osuTK.Graphics; namespace osu.Game.Overlays.Changelog { - public class BadgeDisplay : CompositeDrawable + public class StreamBadgeArea : CompositeDrawable { private const float vertical_padding = 20; private const float horizontal_padding = 85; @@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Changelog private readonly FillFlowContainer badgesContainer; - public BadgeDisplay() + public StreamBadgeArea() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index daee91416c..4fea4bd220 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -26,7 +26,7 @@ namespace osu.Game.Overlays { private ChangelogHeader header; - private BadgeDisplay badges; + private StreamBadgeArea streamBadges; private Container content; @@ -81,7 +81,7 @@ namespace osu.Game.Overlays { ListingSelected = ShowListing, }, - badges = new BadgeDisplay(), + streamBadges = new StreamBadgeArea(), content = new Container { RelativeSizeAxes = Axes.X, @@ -92,7 +92,7 @@ namespace osu.Game.Overlays }, }; - badges.Current.ValueChanged += e => + streamBadges.Current.ValueChanged += e => { if (e.NewValue?.LatestBuild != null && e.NewValue != Current.Value?.UpdateStream) ShowBuild(e.NewValue.LatestBuild); @@ -106,13 +106,13 @@ namespace osu.Game.Overlays { if (e.NewValue != null) { - badges.Current.Value = e.NewValue.UpdateStream; + streamBadges.Current.Value = e.NewValue.UpdateStream; loadContent(new ChangelogSingleBuild(e.NewValue)); } else { - badges.Current.Value = null; + streamBadges.Current.Value = null; loadContent(new ChangelogListing(builds)); } }); @@ -161,7 +161,7 @@ namespace osu.Game.Overlays res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id)); builds = res.Builds; - badges.Populate(res.Streams); + streamBadges.Populate(res.Streams); Current.TriggerChange(); }; From b588638740470bdc97668a9a96bea58aa5f1590b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 22 May 2019 19:51:16 +0900 Subject: [PATCH 180/375] Use TabControl instead of custom logic --- .../Online/TestSceneChangelogOverlay.cs | 4 +- .../Overlays/Changelog/StreamBadgeArea.cs | 83 ------------------- .../{StreamBadge.cs => UpdateStreamBadge.cs} | 35 ++------ .../Changelog/UpdateStreamBadgeArea.cs | 80 ++++++++++++++++++ osu.Game/Overlays/ChangelogOverlay.cs | 12 +-- 5 files changed, 97 insertions(+), 117 deletions(-) delete mode 100644 osu.Game/Overlays/Changelog/StreamBadgeArea.cs rename osu.Game/Overlays/Changelog/{StreamBadge.cs => UpdateStreamBadge.cs} (82%) create mode 100644 osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs index 2e8e05fb0f..d1a7730bee 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs @@ -17,8 +17,8 @@ namespace osu.Game.Tests.Visual.Online public override IReadOnlyList RequiredTypes => new[] { - typeof(StreamBadgeArea), - typeof(StreamBadge), + typeof(UpdateStreamBadgeArea), + typeof(UpdateStreamBadge), typeof(ChangelogHeader), typeof(ChangelogContent), typeof(ChangelogListing), diff --git a/osu.Game/Overlays/Changelog/StreamBadgeArea.cs b/osu.Game/Overlays/Changelog/StreamBadgeArea.cs deleted file mode 100644 index 9d8fc6773d..0000000000 --- a/osu.Game/Overlays/Changelog/StreamBadgeArea.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osu.Framework.Input.Events; -using osu.Game.Online.API.Requests.Responses; -using System.Collections.Generic; -using osu.Framework.Bindables; -using osuTK.Graphics; - -namespace osu.Game.Overlays.Changelog -{ - public class StreamBadgeArea : CompositeDrawable - { - private const float vertical_padding = 20; - private const float horizontal_padding = 85; - - public readonly Bindable Current = new Bindable(); - - private readonly FillFlowContainer badgesContainer; - - public StreamBadgeArea() - { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - InternalChildren = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = new Color4(32, 24, 35, 255), - }, - badgesContainer = new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Padding = new MarginPadding { Vertical = vertical_padding, Horizontal = horizontal_padding }, - }, - }; - - Current.ValueChanged += e => - { - foreach (StreamBadge streamBadge in badgesContainer) - { - if (!IsHovered || e.NewValue.Id == streamBadge.Stream.Id) - streamBadge.Activate(); - else - streamBadge.Deactivate(); - } - }; - } - - public void Populate(List streams) - { - Current.Value = null; - - foreach (APIUpdateStream updateStream in streams) - { - var streamBadge = new StreamBadge(updateStream); - streamBadge.Selected += () => Current.Value = updateStream; - badgesContainer.Add(streamBadge); - } - } - - protected override bool OnHover(HoverEvent e) - { - foreach (StreamBadge streamBadge in badgesContainer.Children) - streamBadge.EnableDim(); - - return base.OnHover(e); - } - - protected override void OnHoverLost(HoverLostEvent e) - { - foreach (StreamBadge streamBadge in badgesContainer.Children) - streamBadge.DisableDim(); - - base.OnHoverLost(e); - } - } -} diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs similarity index 82% rename from osu.Game/Overlays/Changelog/StreamBadge.cs rename to osu.Game/Overlays/Changelog/UpdateStreamBadge.cs index ef1dda5b41..9500f080e7 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs @@ -10,35 +10,30 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Online.API.Requests.Responses; -using System; +using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osuTK.Graphics; namespace osu.Game.Overlays.Changelog { - public class StreamBadge : ClickableContainer + public class UpdateStreamBadge : TabItem { private const float badge_height = 66.5f; private const float badge_width = 100; private const float transition_duration = 100; - public event Action Selected; - - private bool isActivated; + private readonly bool isActivated; private readonly ExpandingBar expandingBar; private SampleChannel sampleClick; private SampleChannel sampleHover; - public readonly APIUpdateStream Stream; - private readonly FillFlowContainer text; - public StreamBadge(APIUpdateStream stream) + public UpdateStreamBadge(APIUpdateStream stream) + : base(stream) { - Stream = stream; - Height = badge_height; Width = stream.IsFeatured ? badge_width * 2 : badge_width; Padding = new MarginPadding(5); @@ -82,32 +77,20 @@ namespace osu.Game.Overlays.Changelog }; } - /// In case we don't want to - /// fire the event. - public void Activate(bool withoutFiringUpdates = true) + protected override void OnActivated() { - isActivated = true; this.FadeIn(transition_duration); expandingBar.Expand(); - if (!withoutFiringUpdates) - Selected?.Invoke(); } - public void Deactivate() + protected override void OnDeactivated() { - isActivated = false; - DisableDim(); - - if (!IsHovered) - { - this.FadeTo(0.5f, transition_duration); - expandingBar.Collapse(); - } + this.FadeTo(0.5f, transition_duration); + expandingBar.Collapse(); } protected override bool OnClick(ClickEvent e) { - Activate(false); sampleClick?.Play(); return base.OnClick(e); } diff --git a/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs b/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs new file mode 100644 index 0000000000..4d357ed944 --- /dev/null +++ b/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs @@ -0,0 +1,80 @@ +// 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.Input.Events; +using osu.Game.Online.API.Requests.Responses; +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.UserInterface; +using osuTK.Graphics; + +namespace osu.Game.Overlays.Changelog +{ + public class UpdateStreamBadgeArea : TabControl + { + private const float vertical_padding = 20; + private const float horizontal_padding = 85; + + public UpdateStreamBadgeArea() + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + AddInternal(new Box + { + Colour = Color4.Black, + Alpha = 0.12f, + RelativeSizeAxes = Axes.Both, + }); + } + + public void Populate(List streams) + { + Current.Value = null; + + foreach (APIUpdateStream updateStream in streams) + { + AddItem(updateStream); + } + } + + protected override bool OnHover(HoverEvent e) + { + foreach (UpdateStreamBadge streamBadge in TabContainer.Children.OfType()) + streamBadge.EnableDim(); + + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + foreach (UpdateStreamBadge streamBadge in TabContainer.Children.OfType()) + streamBadge.DisableDim(); + + base.OnHoverLost(e); + } + + protected override TabFillFlowContainer CreateTabFlow() + { + var flow = base.CreateTabFlow(); + + flow.RelativeSizeAxes = Axes.X; + flow.AutoSizeAxes = Axes.Y; + flow.AllowMultiline = true; + flow.Padding = new MarginPadding + { + Vertical = vertical_padding, + Horizontal = horizontal_padding, + }; + + return flow; + } + + protected override Dropdown CreateDropdown() => null; + + protected override TabItem CreateTabItem(APIUpdateStream value) => + new UpdateStreamBadge(value); + } +} diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 4fea4bd220..6176e93609 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -26,7 +26,7 @@ namespace osu.Game.Overlays { private ChangelogHeader header; - private StreamBadgeArea streamBadges; + private UpdateStreamBadgeArea updateStreamBadges; private Container content; @@ -81,7 +81,7 @@ namespace osu.Game.Overlays { ListingSelected = ShowListing, }, - streamBadges = new StreamBadgeArea(), + updateStreamBadges = new UpdateStreamBadgeArea(), content = new Container { RelativeSizeAxes = Axes.X, @@ -92,7 +92,7 @@ namespace osu.Game.Overlays }, }; - streamBadges.Current.ValueChanged += e => + updateStreamBadges.Current.ValueChanged += e => { if (e.NewValue?.LatestBuild != null && e.NewValue != Current.Value?.UpdateStream) ShowBuild(e.NewValue.LatestBuild); @@ -106,13 +106,13 @@ namespace osu.Game.Overlays { if (e.NewValue != null) { - streamBadges.Current.Value = e.NewValue.UpdateStream; + updateStreamBadges.Current.Value = e.NewValue.UpdateStream; loadContent(new ChangelogSingleBuild(e.NewValue)); } else { - streamBadges.Current.Value = null; + updateStreamBadges.Current.Value = null; loadContent(new ChangelogListing(builds)); } }); @@ -161,7 +161,7 @@ namespace osu.Game.Overlays res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id)); builds = res.Builds; - streamBadges.Populate(res.Streams); + updateStreamBadges.Populate(res.Streams); Current.TriggerChange(); }; From 66f5dbaa9f2f4fea5eaa6870aa57f3fb10f983cf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 22 May 2019 23:44:37 +0900 Subject: [PATCH 181/375] Fix badge state regressions from tab control usage --- .../Overlays/Changelog/UpdateStreamBadge.cs | 134 ++++++++++-------- .../Changelog/UpdateStreamBadgeArea.cs | 9 +- 2 files changed, 79 insertions(+), 64 deletions(-) diff --git a/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs b/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs index 9500f080e7..925412f94d 100644 --- a/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs +++ b/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs @@ -4,6 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -23,71 +24,70 @@ namespace osu.Game.Overlays.Changelog private const float badge_width = 100; private const float transition_duration = 100; - private readonly bool isActivated; - private readonly ExpandingBar expandingBar; private SampleChannel sampleClick; private SampleChannel sampleHover; private readonly FillFlowContainer text; + public readonly Bindable SelectedTab = new Bindable(); + + private readonly Container fadeContainer; + public UpdateStreamBadge(APIUpdateStream stream) : base(stream) { Height = badge_height; Width = stream.IsFeatured ? badge_width * 2 : badge_width; Padding = new MarginPadding(5); - isActivated = true; - Children = new Drawable[] + Child = fadeContainer = new Container { - text = new FillFlowContainer + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] { - AutoSizeAxes = Axes.X, - RelativeSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Children = new[] + text = new FillFlowContainer { - new OsuSpriteText + AutoSizeAxes = Axes.X, + RelativeSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Children = new[] { - Text = stream.DisplayName, - Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 12), - Margin = new MarginPadding { Top = 6 }, - }, - new OsuSpriteText - { - Text = stream.LatestBuild.DisplayVersion, - Font = OsuFont.GetFont(weight: FontWeight.Light, size: 16), - }, - new OsuSpriteText - { - Text = stream.LatestBuild.Users > 0 ? $"{stream.LatestBuild.Users:N0} users online" : null, - Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 10), - Colour = new Color4(203, 164, 218, 255), - }, - } - }, - expandingBar = new ExpandingBar - { - Anchor = Anchor.TopCentre, - Colour = stream.Colour, - ExpandedSize = 4, - CollapsedSize = 2, - IsCollapsed = true - }, + new OsuSpriteText + { + Text = stream.DisplayName, + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 12), + Margin = new MarginPadding { Top = 6 }, + }, + new OsuSpriteText + { + Text = stream.LatestBuild.DisplayVersion, + Font = OsuFont.GetFont(weight: FontWeight.Light, size: 16), + }, + new OsuSpriteText + { + Text = stream.LatestBuild.Users > 0 ? $"{stream.LatestBuild.Users:N0} users online" : null, + Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 10), + Colour = new Color4(203, 164, 218, 255), + }, + } + }, + expandingBar = new ExpandingBar + { + Anchor = Anchor.TopCentre, + Colour = stream.Colour, + ExpandedSize = 4, + CollapsedSize = 2, + IsCollapsed = true + }, + } }; + + SelectedTab.ValueChanged += _ => updateState(); } - protected override void OnActivated() - { - this.FadeIn(transition_duration); - expandingBar.Expand(); - } + protected override void OnActivated() => updateState(); - protected override void OnDeactivated() - { - this.FadeTo(0.5f, transition_duration); - expandingBar.Collapse(); - } + protected override void OnDeactivated() => updateState(); protected override bool OnClick(ClickEvent e) { @@ -98,28 +98,46 @@ namespace osu.Game.Overlays.Changelog protected override bool OnHover(HoverEvent e) { sampleHover?.Play(); - DisableDim(); - this.FadeIn(transition_duration); - expandingBar.Expand(); + updateState(); + return base.OnHover(e); } protected override void OnHoverLost(HoverLostEvent e) { - if (!isActivated) - { - this.FadeTo(0.5f, transition_duration); - expandingBar.Collapse(); - } - else - EnableDim(); - + updateState(); base.OnHoverLost(e); } - public void EnableDim() => text.FadeTo(0.5f, transition_duration); + private void updateState() + { + if (Active.Value || IsHovered || SelectedTab.Value == null) + { + expandingBar.Expand(); + fadeContainer.FadeTo(1, transition_duration); + } + else + { + expandingBar.Collapse(); + fadeContainer.FadeTo(0.5f, transition_duration); + } - public void DisableDim() => text.FadeIn(transition_duration); + text.FadeTo(externalDimRequested && !IsHovered ? 0.5f : 1, transition_duration); + } + + private bool externalDimRequested; + + public void EnableDim() + { + externalDimRequested = true; + updateState(); + } + + public void DisableDim() + { + externalDimRequested = false; + updateState(); + } [BackgroundDependencyLoader] private void load(AudioManager audio) diff --git a/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs b/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs index 4d357ed944..925be48cd1 100644 --- a/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs +++ b/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs @@ -14,9 +14,6 @@ namespace osu.Game.Overlays.Changelog { public class UpdateStreamBadgeArea : TabControl { - private const float vertical_padding = 20; - private const float horizontal_padding = 85; - public UpdateStreamBadgeArea() { RelativeSizeAxes = Axes.X; @@ -65,8 +62,8 @@ namespace osu.Game.Overlays.Changelog flow.AllowMultiline = true; flow.Padding = new MarginPadding { - Vertical = vertical_padding, - Horizontal = horizontal_padding, + Vertical = 20, + Horizontal = 85, }; return flow; @@ -75,6 +72,6 @@ namespace osu.Game.Overlays.Changelog protected override Dropdown CreateDropdown() => null; protected override TabItem CreateTabItem(APIUpdateStream value) => - new UpdateStreamBadge(value); + new UpdateStreamBadge(value) { SelectedTab = { BindTarget = Current } }; } } From 661fc01e7d88920f8e6cc62f9052d577d3d5234e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 22 May 2019 23:49:54 +0900 Subject: [PATCH 182/375] Fix date string --- osu.Game/Overlays/Changelog/ChangelogListing.cs | 4 +--- osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogListing.cs b/osu.Game/Overlays/Changelog/ChangelogListing.cs index ebfcf76738..20b7a32eba 100644 --- a/osu.Game/Overlays/Changelog/ChangelogListing.cs +++ b/osu.Game/Overlays/Changelog/ChangelogListing.cs @@ -46,9 +46,7 @@ namespace osu.Game.Overlays.Changelog Add(new OsuSpriteText { - // do we need .ToUniversalTime() here? - // also, this should be a temporary solution to weekdays in >localized< date strings - Text = build.CreatedAt.Date.ToLongDateString().Replace(build.CreatedAt.ToString("dddd") + ", ", ""), + Text = build.CreatedAt.Date.ToString("dd MMM yyyy"), Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 24), Colour = OsuColour.FromHex(@"FD5"), Anchor = Anchor.TopCentre, diff --git a/osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs b/osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs index 50a7946ee7..98fe68c015 100644 --- a/osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs +++ b/osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs @@ -73,9 +73,7 @@ namespace osu.Game.Overlays.Changelog existing.Add(new OsuSpriteText { - // do we need .ToUniversalTime() here? - // also, this should be a temporary solution to weekdays in >localized< date strings - Text = Build.CreatedAt.Date.ToLongDateString().Replace(Build.CreatedAt.ToString("dddd") + ", ", ""), + Text = Build.CreatedAt.Date.ToString("dd MMM yyyy"), Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 14), Colour = OsuColour.FromHex(@"FD5"), Anchor = Anchor.BottomCentre, From 81e42041e6fab9e336a2f5f18601335d613a3a3f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 22 May 2019 23:56:50 +0900 Subject: [PATCH 183/375] Move update streams inside header content --- osu.Game/Overlays/Changelog/ChangelogHeader.cs | 16 ++++++++++++++-- osu.Game/Overlays/ChangelogOverlay.cs | 18 +----------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index ccc976c4dc..9be6eef295 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -22,6 +22,8 @@ namespace osu.Game.Overlays.Changelog public Action ListingSelected; + public UpdateStreamBadgeArea Streams; + private const string listing_string = "Listing"; public ChangelogHeader() @@ -34,6 +36,12 @@ namespace osu.Game.Overlays.Changelog }; Current.ValueChanged += showBuild; + + Streams.Current.ValueChanged += e => + { + if (e.NewValue?.LatestBuild != null && e.NewValue != Current.Value?.UpdateStream) + Current.Value = e.NewValue.LatestBuild; + }; } [BackgroundDependencyLoader] @@ -54,11 +62,14 @@ namespace osu.Game.Overlays.Changelog TabControl.AddItem(e.NewValue.ToString()); TabControl.Current.Value = e.NewValue.ToString(); + Streams.Current.Value = e.NewValue.UpdateStream; + title.Version = e.NewValue.UpdateStream.DisplayName; } else { TabControl.Current.Value = listing_string; + Streams.Current.Value = null; title.Version = null; } } @@ -67,10 +78,11 @@ namespace osu.Game.Overlays.Changelog protected override Drawable CreateContent() => new Container { - RelativeSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, Children = new Drawable[] { - // todo: move badge display here + Streams = new UpdateStreamBadgeArea(), } }; diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 6176e93609..865c6b8de2 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -26,8 +26,6 @@ namespace osu.Game.Overlays { private ChangelogHeader header; - private UpdateStreamBadgeArea updateStreamBadges; - private Container content; private SampleChannel sampleBack; @@ -81,7 +79,6 @@ namespace osu.Game.Overlays { ListingSelected = ShowListing, }, - updateStreamBadges = new UpdateStreamBadgeArea(), content = new Container { RelativeSizeAxes = Axes.X, @@ -92,12 +89,6 @@ namespace osu.Game.Overlays }, }; - updateStreamBadges.Current.ValueChanged += e => - { - if (e.NewValue?.LatestBuild != null && e.NewValue != Current.Value?.UpdateStream) - ShowBuild(e.NewValue.LatestBuild); - }; - sampleBack = audio.Sample.Get(@"UI/generic-select-soft"); header.Current.BindTo(Current); @@ -105,16 +96,9 @@ namespace osu.Game.Overlays Current.BindValueChanged(e => { if (e.NewValue != null) - { - updateStreamBadges.Current.Value = e.NewValue.UpdateStream; - loadContent(new ChangelogSingleBuild(e.NewValue)); - } else - { - updateStreamBadges.Current.Value = null; loadContent(new ChangelogListing(builds)); - } }); } @@ -161,7 +145,7 @@ namespace osu.Game.Overlays res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id)); builds = res.Builds; - updateStreamBadges.Populate(res.Streams); + header.Streams.Populate(res.Streams); Current.TriggerChange(); }; From ba98c68cbd2c017927d35790350dec0031f16377 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 May 2019 00:11:26 +0900 Subject: [PATCH 184/375] Add support for osu! user links --- osu.Game/Overlays/Changelog/ChangelogBuild.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogBuild.cs b/osu.Game/Overlays/Changelog/ChangelogBuild.cs index 09706a419e..2a207efe01 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBuild.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBuild.cs @@ -11,6 +11,7 @@ using System; using System.Collections.Generic; using System.Text.RegularExpressions; using osu.Game.Graphics.Sprites; +using osu.Game.Users; using osuTK.Graphics; namespace osu.Game.Overlays.Changelog @@ -84,18 +85,21 @@ namespace osu.Game.Overlays.Changelog if (!string.IsNullOrEmpty(entry.Repository)) { title.AddText(" (", t => t.Font = OsuFont.GetFont(size: 18)); - title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}", - entry.GithubUrl, Online.Chat.LinkAction.External, null, - null, t => { t.Font = OsuFont.GetFont(size: 18); }); + title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}", entry.GithubUrl, Online.Chat.LinkAction.External, + creationParameters: t => { t.Font = OsuFont.GetFont(size: 18); }); title.AddText(")", t => t.Font = OsuFont.GetFont(size: 18)); } title.AddText(" by ", t => t.Font = OsuFont.GetFont(size: 14)); - if (entry.GithubUser.GithubUrl != null) - title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, - Online.Chat.LinkAction.External, null, null, - t => t.Font = OsuFont.GetFont(size: 14)); + if (entry.GithubUser.UserId != null) + title.AddUserLink(new User + { + Username = entry.GithubUser.OsuUsername, + Id = entry.GithubUser.UserId.Value + }, t => t.Font = OsuFont.GetFont(size: 14)); + else if (entry.GithubUser.GithubUrl != null) + title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, Online.Chat.LinkAction.External, null, null, t => t.Font = OsuFont.GetFont(size: 14)); else title.AddText(entry.GithubUser.DisplayName, t => t.Font = OsuFont.GetFont(size: 12)); From c96d7bfb672196072efadd39fb1bdf2c63e99725 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 May 2019 00:13:47 +0900 Subject: [PATCH 185/375] Centralise font specification --- osu.Game/Overlays/Changelog/ChangelogBuild.cs | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogBuild.cs b/osu.Game/Overlays/Changelog/ChangelogBuild.cs index 2a207efe01..6d0b7a8739 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBuild.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBuild.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.Graphics; @@ -65,6 +65,9 @@ namespace osu.Game.Overlays.Changelog }); foreach (APIChangelogEntry entry in category.Value) + var fontMedium = OsuFont.GetFont(size: 14); + var fontSmall = OsuFont.GetFont(size: 12); + { LinkFlowContainer title = new LinkFlowContainer { @@ -76,51 +79,51 @@ namespace osu.Game.Overlays.Changelog title.AddIcon(FontAwesome.Solid.Check, t => { - t.Font = OsuFont.GetFont(size: 12); + t.Font = fontSmall; t.Padding = new MarginPadding { Left = -17, Right = 5 }; }); - title.AddText(entry.Title, t => { t.Font = OsuFont.GetFont(size: 18); }); + title.AddText(entry.Title, t => { t.Font = fontLarge; }); if (!string.IsNullOrEmpty(entry.Repository)) { - title.AddText(" (", t => t.Font = OsuFont.GetFont(size: 18)); + title.AddText(" (", t => t.Font = fontLarge); title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}", entry.GithubUrl, Online.Chat.LinkAction.External, - creationParameters: t => { t.Font = OsuFont.GetFont(size: 18); }); - title.AddText(")", t => t.Font = OsuFont.GetFont(size: 18)); + creationParameters: t => { t.Font = fontLarge; }); + title.AddText(")", t => t.Font = fontLarge); } - title.AddText(" by ", t => t.Font = OsuFont.GetFont(size: 14)); + title.AddText(" by ", t => t.Font = fontMedium); if (entry.GithubUser.UserId != null) title.AddUserLink(new User { Username = entry.GithubUser.OsuUsername, Id = entry.GithubUser.UserId.Value - }, t => t.Font = OsuFont.GetFont(size: 14)); + }, t => t.Font = fontMedium); else if (entry.GithubUser.GithubUrl != null) - title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, Online.Chat.LinkAction.External, null, null, t => t.Font = OsuFont.GetFont(size: 14)); + title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, Online.Chat.LinkAction.External, null, null, t => t.Font = fontMedium); else - title.AddText(entry.GithubUser.DisplayName, t => t.Font = OsuFont.GetFont(size: 12)); + title.AddText(entry.GithubUser.DisplayName, t => t.Font = fontSmall); ChangelogEntries.Add(title); if (!string.IsNullOrEmpty(entry.MessageHtml)) { - TextFlowContainer messageContainer = new TextFlowContainer + TextFlowContainer message = new TextFlowContainer { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, }; // todo: use markdown parsing once API returns markdown - messageContainer.AddText(Regex.Replace(entry.MessageHtml, @"<(.|\n)*?>", string.Empty), t => + message.AddText(Regex.Replace(entry.MessageHtml, @"<(.|\n)*?>", string.Empty), t => { - t.Font = OsuFont.GetFont(size: 12); + t.Font = fontSmall; t.Colour = new Color4(235, 184, 254, 255); }); - ChangelogEntries.Add(messageContainer); + ChangelogEntries.Add(message); } } } From a0ddc6d77a3930bad3abb540b2a91e2caed863da Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 May 2019 00:13:59 +0900 Subject: [PATCH 186/375] Use linq instead of a temporary sorted list --- osu.Game/Overlays/Changelog/ChangelogBuild.cs | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogBuild.cs b/osu.Game/Overlays/Changelog/ChangelogBuild.cs index 6d0b7a8739..a76211a0ae 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBuild.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBuild.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.Graphics; @@ -8,7 +8,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Online.API.Requests.Responses; using System; -using System.Collections.Generic; +using System.Linq; using System.Text.RegularExpressions; using osu.Game.Graphics.Sprites; using osu.Game.Users; @@ -44,30 +44,20 @@ namespace osu.Game.Overlays.Changelog }, }; - var categories = new SortedDictionary>(); - - // sort entries by category - foreach (APIChangelogEntry entry in build.ChangelogEntries) - { - if (!categories.ContainsKey(entry.Category)) - categories.Add(entry.Category, new List { entry }); - else - categories[entry.Category].Add(entry); - } - - foreach (KeyValuePair> category in categories) + foreach (var categoryEntries in build.ChangelogEntries.GroupBy(b => b.Category).OrderBy(c => c.Key)) { ChangelogEntries.Add(new OsuSpriteText { - Text = category.Key, + Text = categoryEntries.Key, Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 24), Margin = new MarginPadding { Top = 35, Bottom = 15 }, }); - foreach (APIChangelogEntry entry in category.Value) + var fontLarge = OsuFont.GetFont(size: 18); var fontMedium = OsuFont.GetFont(size: 14); var fontSmall = OsuFont.GetFont(size: 12); + foreach (APIChangelogEntry entry in categoryEntries) { LinkFlowContainer title = new LinkFlowContainer { From cb620082802164d24b793ae990134db7f5857d93 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 May 2019 11:23:24 +0900 Subject: [PATCH 187/375] Cleanup pass --- osu.Game/Graphics/OsuColour.cs | 2 + .../Changelog/UpdateStreamBadgeArea.cs | 5 +-- osu.Game/Overlays/ChangelogOverlay.cs | 37 +++++++++---------- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/osu.Game/Graphics/OsuColour.cs b/osu.Game/Graphics/OsuColour.cs index 53693a1e38..63ec24f84f 100644 --- a/osu.Game/Graphics/OsuColour.cs +++ b/osu.Game/Graphics/OsuColour.cs @@ -40,8 +40,10 @@ namespace osu.Game.Graphics // See https://github.com/ppy/osu-web/blob/master/resources/assets/less/colors.less public readonly Color4 PurpleLighter = FromHex(@"eeeeff"); public readonly Color4 PurpleLight = FromHex(@"aa88ff"); + public readonly Color4 PurpleLightAlternative = FromHex(@"cba4da"); public readonly Color4 Purple = FromHex(@"8866ee"); public readonly Color4 PurpleDark = FromHex(@"6644cc"); + public readonly Color4 PurpleDarkAlternative = FromHex(@"312436"); public readonly Color4 PurpleDarker = FromHex(@"441188"); public readonly Color4 PinkLighter = FromHex(@"ffddee"); diff --git a/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs b/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs index 925be48cd1..f564f03652 100644 --- a/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs +++ b/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs @@ -31,10 +31,7 @@ namespace osu.Game.Overlays.Changelog { Current.Value = null; - foreach (APIUpdateStream updateStream in streams) - { - AddItem(updateStream); - } + foreach (APIUpdateStream updateStream in streams) AddItem(updateStream); } protected override bool OnHover(HoverEvent e) diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 865c6b8de2..17d2ab93dc 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -18,12 +18,13 @@ using osu.Game.Input.Bindings; using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.Changelog; -using osuTK.Graphics; namespace osu.Game.Overlays { public class ChangelogOverlay : FullscreenOverlay { + public readonly Bindable Current = new Bindable(); + private ChangelogHeader header; private Container content; @@ -32,23 +33,6 @@ namespace osu.Game.Overlays private List builds; - public readonly Bindable Current = new Bindable(); - - public void ShowListing() => Current.Value = null; - - /// - /// Fetches and shows a specific build from a specific update stream. - /// - /// Must contain at least and - /// . If and - /// are specified, the header will instantly display them. - public void ShowBuild([NotNull] APIChangelogBuild build) - { - if (build == null) throw new ArgumentNullException(nameof(build)); - - Current.Value = build; - } - [BackgroundDependencyLoader] private void load(AudioManager audio, OsuColour colour) { @@ -62,7 +46,7 @@ namespace osu.Game.Overlays new Box { RelativeSizeAxes = Axes.Both, - Colour = new Color4(49, 36, 54, 255), + Colour = colour.PurpleDarkAlternative, }, new ScrollContainer { @@ -102,6 +86,21 @@ namespace osu.Game.Overlays }); } + public void ShowListing() => Current.Value = null; + + /// + /// Fetches and shows a specific build from a specific update stream. + /// + /// Must contain at least and + /// . If and + /// are specified, the header will instantly display them. + public void ShowBuild([NotNull] APIChangelogBuild build) + { + if (build == null) throw new ArgumentNullException(nameof(build)); + + Current.Value = build; + } + public override bool OnPressed(GlobalAction action) { switch (action) From 5a887dabfe660e40ed0d962e392d095c4b0dcdfa Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 May 2019 11:38:13 +0900 Subject: [PATCH 188/375] Prepare changelog api requests to work when not logged in --- .../Changelog/ChangelogSingleBuild.cs | 23 +++++++++------- osu.Game/Overlays/ChangelogOverlay.cs | 26 +++++++++++-------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs b/osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs index 98fe68c015..81c7905e84 100644 --- a/osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs +++ b/osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs @@ -33,26 +33,31 @@ namespace osu.Game.Overlays.Changelog [BackgroundDependencyLoader] private void load(CancellationToken? cancellation, IAPIProvider api) { - var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); bool complete = false; + var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version); req.Success += res => { build = res; complete = true; }; - req.Failure += _ => complete = true; - api.Queue(req); + Task.Run(() => req.Perform(api)); - while (!complete && cancellation?.IsCancellationRequested != true) - Task.Delay(1); - - Children = new Drawable[] + while (!complete) { - new ChangelogBuildWithNavigation(build) { SelectBuild = SelectBuild }, - }; + if (cancellation?.IsCancellationRequested == true) + { + req.Cancel(); + return; + } + + Task.Delay(1); + } + + if (build != null) + Child = new ChangelogBuildWithNavigation(build) { SelectBuild = SelectBuild }; } public class ChangelogBuildWithNavigation : ChangelogBuild diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 17d2ab93dc..6ce82d342a 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Threading; +using System.Threading.Tasks; using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -136,21 +137,24 @@ namespace osu.Game.Overlays { initialFetchPerformed = true; - var req = new GetChangelogRequest(); - req.Success += res => + Task.Run(() => { - // remap streams to builds to ensure model equality - res.Builds.ForEach(b => b.UpdateStream = res.Streams.Find(s => s.Id == b.UpdateStream.Id)); - res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id)); + var req = new GetChangelogRequest(); + req.Success += res => + { + // remap streams to builds to ensure model equality + res.Builds.ForEach(b => b.UpdateStream = res.Streams.Find(s => s.Id == b.UpdateStream.Id)); + res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id)); - builds = res.Builds; - header.Streams.Populate(res.Streams); + builds = res.Builds; + header.Streams.Populate(res.Streams); - Current.TriggerChange(); - }; - req.Failure += _ => initialFetchPerformed = false; + Current.TriggerChange(); + }; + req.Failure += _ => initialFetchPerformed = false; - API.Queue(req); + req.Perform(API); + }); } private CancellationTokenSource loadContentTask; From 7229975fef4b4ea6d365e459fe3d33f90bbefd47 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 May 2019 12:41:45 +0900 Subject: [PATCH 189/375] Further minor refactoring --- osu.Game/Overlays/Changelog/UpdateStreamBadge.cs | 8 +++++--- osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs b/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs index 925412f94d..c39e6a6784 100644 --- a/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs +++ b/osu.Game/Overlays/Changelog/UpdateStreamBadge.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 Humanizer; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -14,6 +15,7 @@ using osu.Game.Online.API.Requests.Responses; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; +using osuTK; using osuTK.Graphics; namespace osu.Game.Overlays.Changelog @@ -37,9 +39,9 @@ namespace osu.Game.Overlays.Changelog public UpdateStreamBadge(APIUpdateStream stream) : base(stream) { - Height = badge_height; - Width = stream.IsFeatured ? badge_width * 2 : badge_width; + Size = new Vector2(stream.IsFeatured ? badge_width * 2 : badge_width, badge_height); Padding = new MarginPadding(5); + Child = fadeContainer = new Container { RelativeSizeAxes = Axes.Both, @@ -65,7 +67,7 @@ namespace osu.Game.Overlays.Changelog }, new OsuSpriteText { - Text = stream.LatestBuild.Users > 0 ? $"{stream.LatestBuild.Users:N0} users online" : null, + Text = stream.LatestBuild.Users > 0 ? $"{stream.LatestBuild.Users:N0} {"user".Pluralize(stream.LatestBuild.Users == 1)} online" : null, Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 10), Colour = new Color4(203, 164, 218, 255), }, diff --git a/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs b/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs index f564f03652..2b48811bd6 100644 --- a/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs +++ b/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs @@ -31,7 +31,8 @@ namespace osu.Game.Overlays.Changelog { Current.Value = null; - foreach (APIUpdateStream updateStream in streams) AddItem(updateStream); + foreach (APIUpdateStream updateStream in streams) + AddItem(updateStream); } protected override bool OnHover(HoverEvent e) From acaf2f9fbb538a3aa335ce1319ea624a33486a91 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 May 2019 18:54:42 +0900 Subject: [PATCH 190/375] Show changelog from new build notification --- osu.Desktop/Overlays/VersionManager.cs | 25 +++++++----- osu.Game/Overlays/ChangelogOverlay.cs | 56 +++++++++++++++++++++----- 2 files changed, 61 insertions(+), 20 deletions(-) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index e9c5d06f3c..7e4257c23b 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -1,7 +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 System; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -96,33 +95,37 @@ namespace osu.Desktop.Overlays var version = game.Version; var lastVersion = config.Get(OsuSetting.Version); - if (game.IsDeployedBuild && version != lastVersion) + //if (game.IsDeployedBuild && version != lastVersion) { config.Set(OsuSetting.Version, version); // only show a notification if we've previously saved a version to the config file (ie. not the first run). if (!string.IsNullOrEmpty(lastVersion)) - notificationOverlay.Post(new UpdateCompleteNotification(version, host.OpenUrlExternally)); + notificationOverlay.Post(new UpdateCompleteNotification(version)); } } private class UpdateCompleteNotification : SimpleNotification { - public UpdateCompleteNotification(string version, Action openUrl = null) + private readonly string version; + + public UpdateCompleteNotification(string version) { + this.version = version; Text = $"You are now running osu!lazer {version}.\nClick to see what's new!"; - Icon = FontAwesome.Solid.CheckSquare; - Activated = delegate - { - openUrl?.Invoke($"https://osu.ppy.sh/home/changelog/lazer/{version}"); - return true; - }; } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OsuColour colours, ChangelogOverlay changelog) { + Icon = FontAwesome.Solid.CheckSquare; IconBackgound.Colour = colours.BlueDark; + + Activated = delegate + { + changelog.ShowBuild("lazer", version); + return true; + }; } } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 6ce82d342a..a957227c6b 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -34,6 +34,8 @@ namespace osu.Game.Overlays private List builds; + private List streams; + [BackgroundDependencyLoader] private void load(AudioManager audio, OsuColour colour) { @@ -87,7 +89,11 @@ namespace osu.Game.Overlays }); } - public void ShowListing() => Current.Value = null; + public void ShowListing() + { + Current.Value = null; + State = Visibility.Visible; + } /// /// Fetches and shows a specific build from a specific update stream. @@ -100,6 +106,27 @@ namespace osu.Game.Overlays if (build == null) throw new ArgumentNullException(nameof(build)); Current.Value = build; + State = Visibility.Visible; + } + + public void ShowBuild([NotNull] string updateStream, [NotNull] string version) + { + if (updateStream == null) throw new ArgumentNullException(nameof(updateStream)); + if (version == null) throw new ArgumentNullException(nameof(version)); + + performAfterFetch(() => + { + var build = builds.Find(b => b.Version == version && b.UpdateStream.Name == updateStream) + ?? streams.Find(s => s.Name == updateStream)?.LatestBuild; + + if (build != null) + { + Current.Value = build; + State = Visibility.Visible; + } + }); + + State = Visibility.Visible; } public override bool OnPressed(GlobalAction action) @@ -127,15 +154,23 @@ namespace osu.Game.Overlays { base.PopIn(); - if (!initialFetchPerformed) - fetchListing(); + if (initialFetchTask == null) + // fetch and refresh to show listing, if no other request was made via Show methods + performAfterFetch(() => Current.TriggerChange()); } - private bool initialFetchPerformed; + private Task initialFetchTask; - private void fetchListing() + private void performAfterFetch(Action action) => fetchListing()?.ContinueWith(_ => Schedule(action)); + + private Task fetchListing() { - initialFetchPerformed = true; + if (initialFetchTask != null) + return initialFetchTask; + + var tcs = new TaskCompletionSource(); + + initialFetchTask = tcs.Task; Task.Run(() => { @@ -147,14 +182,17 @@ namespace osu.Game.Overlays res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id)); builds = res.Builds; + streams = res.Streams; + header.Streams.Populate(res.Streams); - Current.TriggerChange(); + tcs.SetResult(true); }; - req.Failure += _ => initialFetchPerformed = false; - + req.Failure += _ => initialFetchTask = null; req.Perform(API); }); + + return initialFetchTask; } private CancellationTokenSource loadContentTask; From e034b3d514af9ec9e5e6d9976ecd8617ffb0b1dc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 May 2019 19:08:44 +0900 Subject: [PATCH 191/375] Use TaskCompletionSource in a better manner --- osu.Desktop/Overlays/VersionManager.cs | 5 +---- osu.Game/Overlays/ChangelogOverlay.cs | 12 +++++------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index 7e4257c23b..2bba1723ec 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; -using osu.Framework.Platform; using osu.Game; using osu.Game.Configuration; using osu.Game.Graphics; @@ -24,15 +23,13 @@ namespace osu.Desktop.Overlays private OsuConfigManager config; private OsuGameBase game; private NotificationOverlay notificationOverlay; - private GameHost host; [BackgroundDependencyLoader] - private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config, GameHost host) + private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config) { notificationOverlay = notification; this.config = config; this.game = game; - this.host = host; AutoSizeAxes = Axes.Both; Anchor = Anchor.BottomCentre; diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index a957227c6b..552e213a45 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -168,12 +168,10 @@ namespace osu.Game.Overlays if (initialFetchTask != null) return initialFetchTask; - var tcs = new TaskCompletionSource(); - - initialFetchTask = tcs.Task; - - Task.Run(() => + return initialFetchTask = Task.Run(async () => { + var tcs = new TaskCompletionSource(); + var req = new GetChangelogRequest(); req.Success += res => { @@ -190,9 +188,9 @@ namespace osu.Game.Overlays }; req.Failure += _ => initialFetchTask = null; req.Perform(API); - }); - return initialFetchTask; + await tcs.Task; + }); } private CancellationTokenSource loadContentTask; From 492dd3eee266cb59c3882cc868d2762dc6cb6fba Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 24 May 2019 10:53:02 +0900 Subject: [PATCH 192/375] Restore accidentally commented conditional --- osu.Desktop/Overlays/VersionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index 2bba1723ec..d2aad99f41 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -92,7 +92,7 @@ namespace osu.Desktop.Overlays var version = game.Version; var lastVersion = config.Get(OsuSetting.Version); - //if (game.IsDeployedBuild && version != lastVersion) + if (game.IsDeployedBuild && version != lastVersion) { config.Set(OsuSetting.Version, version); From a272004610ec31fa7499ccfb69ccd2df4f737bc8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 24 May 2019 11:04:36 +0900 Subject: [PATCH 193/375] Use a more friendly set method for tab control --- osu.Game/Overlays/Changelog/ChangelogHeader.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 9be6eef295..fca62fbb44 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -62,7 +63,7 @@ namespace osu.Game.Overlays.Changelog TabControl.AddItem(e.NewValue.ToString()); TabControl.Current.Value = e.NewValue.ToString(); - Streams.Current.Value = e.NewValue.UpdateStream; + Streams.Current.Value = Streams.Items.FirstOrDefault(s => s.Name == e.NewValue.UpdateStream.Name); title.Version = e.NewValue.UpdateStream.DisplayName; } From 53b22453305f3ed1dc676412115485fcfb5bbf4b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 27 May 2019 01:36:07 +0900 Subject: [PATCH 194/375] Move common settings sub-panel logic to own class --- osu.Game/Overlays/KeyBindingPanel.cs | 88 +--------------------- osu.Game/Overlays/SettingsPanel.cs | 2 - osu.Game/Overlays/SettingsSubPanel.cs | 103 ++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 89 deletions(-) create mode 100644 osu.Game/Overlays/SettingsSubPanel.cs diff --git a/osu.Game/Overlays/KeyBindingPanel.cs b/osu.Game/Overlays/KeyBindingPanel.cs index 301c8faca2..928bd080fa 100644 --- a/osu.Game/Overlays/KeyBindingPanel.cs +++ b/osu.Game/Overlays/KeyBindingPanel.cs @@ -3,22 +3,14 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Input.Bindings; -using osu.Framework.Input.Events; -using osu.Game.Graphics; -using osu.Game.Graphics.Containers; -using osu.Game.Graphics.Sprites; using osu.Game.Input.Bindings; using osu.Game.Overlays.KeyBinding; using osu.Game.Overlays.Settings; using osu.Game.Rulesets; -using osu.Game.Screens.Ranking; -using osuTK; namespace osu.Game.Overlays { - public class KeyBindingPanel : SettingsPanel + public class KeyBindingPanel : SettingsSubPanel { protected override Drawable CreateHeader() => new SettingsHeader("key configuration", "Customise your keys!"); @@ -29,84 +21,6 @@ namespace osu.Game.Overlays foreach (var ruleset in rulesets.AvailableRulesets) AddSection(new RulesetBindingsSection(ruleset)); - - AddInternal(new BackButton - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Action = Hide - }); - } - - public KeyBindingPanel() - : base(true) - { - } - - private class BackButton : OsuClickableContainer, IKeyBindingHandler - { - private AspectContainer aspect; - - [BackgroundDependencyLoader] - private void load() - { - Size = new Vector2(Sidebar.DEFAULT_WIDTH); - Children = new Drawable[] - { - aspect = new AspectContainer - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Y, - Children = new Drawable[] - { - new SpriteIcon - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Y = -15, - Size = new Vector2(15), - Shadow = true, - Icon = FontAwesome.Solid.ChevronLeft - }, - new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Y = 15, - Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), - Text = @"back", - }, - } - } - }; - } - - protected override bool OnMouseDown(MouseDownEvent e) - { - aspect.ScaleTo(0.75f, 2000, Easing.OutQuint); - return base.OnMouseDown(e); - } - - protected override bool OnMouseUp(MouseUpEvent e) - { - aspect.ScaleTo(1, 1000, Easing.OutElastic); - return base.OnMouseUp(e); - } - - public bool OnPressed(GlobalAction action) - { - switch (action) - { - case GlobalAction.Back: - Click(); - return true; - } - - return false; - } - - public bool OnReleased(GlobalAction action) => false; } } } diff --git a/osu.Game/Overlays/SettingsPanel.cs b/osu.Game/Overlays/SettingsPanel.cs index 85b74c0fad..474f529bb1 100644 --- a/osu.Game/Overlays/SettingsPanel.cs +++ b/osu.Game/Overlays/SettingsPanel.cs @@ -28,8 +28,6 @@ namespace osu.Game.Overlays protected const float WIDTH = 400; - private const float sidebar_padding = 10; - protected Container ContentContainer; protected override Container Content => ContentContainer; diff --git a/osu.Game/Overlays/SettingsSubPanel.cs b/osu.Game/Overlays/SettingsSubPanel.cs new file mode 100644 index 0000000000..576be71ee6 --- /dev/null +++ b/osu.Game/Overlays/SettingsSubPanel.cs @@ -0,0 +1,103 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input.Bindings; +using osu.Framework.Input.Events; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osu.Game.Input.Bindings; +using osu.Game.Overlays.Settings; +using osu.Game.Screens.Ranking; +using osuTK; + +namespace osu.Game.Overlays +{ + public abstract class SettingsSubPanel : SettingsPanel + { + protected SettingsSubPanel() + : base(true) + { + } + + [BackgroundDependencyLoader] + private void load() + { + AddInternal(new BackButton + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Action = Hide + }); + } + + private class BackButton : OsuClickableContainer, IKeyBindingHandler + { + private AspectContainer aspect; + + [BackgroundDependencyLoader] + private void load() + { + Size = new Vector2(Sidebar.DEFAULT_WIDTH); + Children = new Drawable[] + { + aspect = new AspectContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Y, + Children = new Drawable[] + { + new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Y = -15, + Size = new Vector2(15), + Shadow = true, + Icon = FontAwesome.Solid.ChevronLeft + }, + new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Y = 15, + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), + Text = @"back", + }, + } + } + }; + } + + protected override bool OnMouseDown(MouseDownEvent e) + { + aspect.ScaleTo(0.75f, 2000, Easing.OutQuint); + return base.OnMouseDown(e); + } + + protected override bool OnMouseUp(MouseUpEvent e) + { + aspect.ScaleTo(1, 1000, Easing.OutElastic); + return base.OnMouseUp(e); + } + + public bool OnPressed(GlobalAction action) + { + switch (action) + { + case GlobalAction.Back: + Click(); + return true; + } + + return false; + } + + public bool OnReleased(GlobalAction action) => false; + } + } +} From 02e2fb963a9c25a0bda62120b892b2714d0e2495 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 27 May 2019 01:45:37 +0900 Subject: [PATCH 195/375] Tidy up how subpanels are handled in SettingsOverlay --- osu.Game/Overlays/SettingsOverlay.cs | 34 +++++++++++++++++----------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/osu.Game/Overlays/SettingsOverlay.cs b/osu.Game/Overlays/SettingsOverlay.cs index 4f3a71a1b3..6e3eaae0a1 100644 --- a/osu.Game/Overlays/SettingsOverlay.cs +++ b/osu.Game/Overlays/SettingsOverlay.cs @@ -8,13 +8,12 @@ using osu.Game.Overlays.Settings; using osu.Game.Overlays.Settings.Sections; using osuTK.Graphics; using System.Collections.Generic; +using System.Linq; namespace osu.Game.Overlays { public class SettingsOverlay : SettingsPanel { - private readonly KeyBindingPanel keyBindingPanel; - protected override IEnumerable CreateSections() => new SettingsSection[] { new GeneralSection(), @@ -22,29 +21,37 @@ namespace osu.Game.Overlays new GameplaySection(), new AudioSection(), new SkinSection(), - new InputSection(keyBindingPanel), + new InputSection(createSubPanel(new KeyBindingPanel())), new OnlineSection(), new MaintenanceSection(), new DebugSection(), }; + private readonly List subPanels = new List(); + protected override Drawable CreateHeader() => new SettingsHeader("settings", "Change the way osu! behaves"); protected override Drawable CreateFooter() => new SettingsFooter(); public SettingsOverlay() : base(true) { - keyBindingPanel = new KeyBindingPanel - { - Depth = 1, - Anchor = Anchor.TopRight, - }; - keyBindingPanel.StateChanged += keyBindingPanelStateChanged; } - public override bool AcceptsFocus => keyBindingPanel.State != Visibility.Visible; + public override bool AcceptsFocus => subPanels.All(s => s.State != Visibility.Visible); - private void keyBindingPanelStateChanged(Visibility visibility) + private T createSubPanel(T subPanel) + where T : SettingsSubPanel + { + subPanel.Depth = 1; + subPanel.Anchor = Anchor.TopRight; + subPanel.StateChanged += subPanelStateChanged; + + subPanels.Add(subPanel); + + return subPanel; + } + + private void subPanelStateChanged(Visibility visibility) { switch (visibility) { @@ -66,12 +73,13 @@ namespace osu.Game.Overlays } } - protected override float ExpandedPosition => keyBindingPanel.State == Visibility.Visible ? -WIDTH : base.ExpandedPosition; + protected override float ExpandedPosition => subPanels.Any(s => s.State == Visibility.Visible) ? -WIDTH : base.ExpandedPosition; [BackgroundDependencyLoader] private void load() { - ContentContainer.Add(keyBindingPanel); + foreach (var s in subPanels) + ContentContainer.Add(s); } } } From e7b9d1efa32c7d7d46991071247b8ab3a860ec48 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 27 May 2019 00:55:12 +0900 Subject: [PATCH 196/375] Isolate alpha usage in OsuCheckbox --- osu.Game/Graphics/UserInterface/OsuCheckbox.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs index de3d93d845..2944fc87af 100644 --- a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs +++ b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs @@ -78,7 +78,7 @@ namespace osu.Game.Graphics.UserInterface Current.DisabledChanged += disabled => { - Alpha = disabled ? 0.3f : 1; + labelSpriteText.Alpha = Nub.Alpha = disabled ? 0.3f : 1; }; } From 127858d39855c7670377b3ff4e32af02fa864966 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 25 May 2019 15:00:53 +0900 Subject: [PATCH 197/375] Store databased settings based on string keys rather than ints Allows for rearranging/removal from enums without consequence. --- .../Configuration/DatabasedConfigManager.cs | 19 +++++++++++++++++-- osu.Game/Configuration/DatabasedSetting.cs | 11 +++-------- osu.Game/Configuration/SettingsStore.cs | 6 ++++++ .../Migrations/20180125143340_Settings.cs | 2 +- .../Migrations/OsuDbContextModelSnapshot.cs | 4 ++-- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/osu.Game/Configuration/DatabasedConfigManager.cs b/osu.Game/Configuration/DatabasedConfigManager.cs index 8f1780cab5..d5cdd7e4bc 100644 --- a/osu.Game/Configuration/DatabasedConfigManager.cs +++ b/osu.Game/Configuration/DatabasedConfigManager.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; +using System.Linq; using osu.Framework.Bindables; using osu.Framework.Configuration; using osu.Game.Rulesets; @@ -19,6 +20,8 @@ namespace osu.Game.Configuration private readonly RulesetInfo ruleset; + private readonly bool legacySettingsExist; + protected DatabasedConfigManager(SettingsStore settings, RulesetInfo ruleset = null, int? variant = null) { this.settings = settings; @@ -26,6 +29,7 @@ namespace osu.Game.Configuration this.variant = variant; databasedSettings = settings.Query(ruleset?.ID, variant); + legacySettingsExist = databasedSettings.Any(s => int.TryParse(s.Key, out var _)); InitialiseDefaults(); } @@ -43,7 +47,18 @@ namespace osu.Game.Configuration { base.AddBindable(lookup, bindable); - var setting = databasedSettings.Find(s => (int)s.Key == (int)(object)lookup); + if (legacySettingsExist) + { + var legacySetting = databasedSettings.Find(s => s.Key == ((int)(object)lookup).ToString()); + + if (legacySetting != null) + { + bindable.Parse(legacySetting.Value); + settings.Delete(legacySetting); + } + } + + var setting = databasedSettings.Find(s => s.Key == lookup.ToString()); if (setting != null) { @@ -53,7 +68,7 @@ namespace osu.Game.Configuration { settings.Update(setting = new DatabasedSetting { - Key = lookup, + Key = lookup.ToString(), Value = bindable.Value, RulesetID = ruleset?.ID, Variant = variant, diff --git a/osu.Game/Configuration/DatabasedSetting.cs b/osu.Game/Configuration/DatabasedSetting.cs index d56ac49358..3e0a9ecd28 100644 --- a/osu.Game/Configuration/DatabasedSetting.cs +++ b/osu.Game/Configuration/DatabasedSetting.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.ComponentModel.DataAnnotations.Schema; @@ -16,11 +16,7 @@ namespace osu.Game.Configuration public int? Variant { get; set; } [Column("Key")] - public int IntKey - { - get => (int)Key; - private set => Key = value; - } + public string Key { get; set; } [Column("Value")] public string StringValue @@ -29,10 +25,9 @@ namespace osu.Game.Configuration set => Value = value; } - public object Key; public object Value; - public DatabasedSetting(object key, object value) + public DatabasedSetting(string key, object value) { Key = key; Value = value; diff --git a/osu.Game/Configuration/SettingsStore.cs b/osu.Game/Configuration/SettingsStore.cs index f15fd1f17b..f8c9bdeaf8 100644 --- a/osu.Game/Configuration/SettingsStore.cs +++ b/osu.Game/Configuration/SettingsStore.cs @@ -37,5 +37,11 @@ namespace osu.Game.Configuration SettingChanged?.Invoke(); } + + public void Delete(DatabasedSetting setting) + { + using (var usage = ContextFactory.GetForWrite()) + usage.Context.Remove(setting); + } } } diff --git a/osu.Game/Migrations/20180125143340_Settings.cs b/osu.Game/Migrations/20180125143340_Settings.cs index 2e2768dc7c..166d3c086d 100644 --- a/osu.Game/Migrations/20180125143340_Settings.cs +++ b/osu.Game/Migrations/20180125143340_Settings.cs @@ -16,7 +16,7 @@ namespace osu.Game.Migrations { ID = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), - Key = table.Column(type: "INTEGER", nullable: false), + Key = table.Column(type: "TEXT", nullable: false), RulesetID = table.Column(type: "INTEGER", nullable: true), Value = table.Column(type: "TEXT", nullable: true), Variant = table.Column(type: "INTEGER", nullable: true) diff --git a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs index 8430e00e4f..f942d357e8 100644 --- a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs +++ b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs @@ -14,7 +14,7 @@ namespace osu.Game.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.1-servicing-10028"); + .HasAnnotation("ProductVersion", "2.2.4-servicing-10062"); modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b => { @@ -198,7 +198,7 @@ namespace osu.Game.Migrations b.Property("ID") .ValueGeneratedOnAdd(); - b.Property("IntKey") + b.Property("Key") .HasColumnName("Key"); b.Property("RulesetID"); From 31e6a4fa5942a081f730e1ba2db676a045c9ccc5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 25 May 2019 15:09:31 +0900 Subject: [PATCH 198/375] Add optional skin foreign key to databased settings --- osu.Game/Configuration/DatabasedSetting.cs | 2 + .../20190525060824_SkinSettings.Designer.cs | 498 ++++++++++++++++++ .../Migrations/20190525060824_SkinSettings.cs | 45 ++ .../Migrations/OsuDbContextModelSnapshot.cs | 11 + osu.Game/Skinning/SkinInfo.cs | 3 + osu.Game/Skinning/SkinStore.cs | 6 + 6 files changed, 565 insertions(+) create mode 100644 osu.Game/Migrations/20190525060824_SkinSettings.Designer.cs create mode 100644 osu.Game/Migrations/20190525060824_SkinSettings.cs diff --git a/osu.Game/Configuration/DatabasedSetting.cs b/osu.Game/Configuration/DatabasedSetting.cs index d56ac49358..035fc73f4f 100644 --- a/osu.Game/Configuration/DatabasedSetting.cs +++ b/osu.Game/Configuration/DatabasedSetting.cs @@ -15,6 +15,8 @@ namespace osu.Game.Configuration public int? Variant { get; set; } + public int? SkinInfoID { get; set; } + [Column("Key")] public int IntKey { diff --git a/osu.Game/Migrations/20190525060824_SkinSettings.Designer.cs b/osu.Game/Migrations/20190525060824_SkinSettings.Designer.cs new file mode 100644 index 0000000000..348c42adb9 --- /dev/null +++ b/osu.Game/Migrations/20190525060824_SkinSettings.Designer.cs @@ -0,0 +1,498 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using osu.Game.Database; + +namespace osu.Game.Migrations +{ + [DbContext(typeof(OsuDbContext))] + [Migration("20190525060824_SkinSettings")] + partial class SkinSettings + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.4-servicing-10062"); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("ApproachRate"); + + b.Property("CircleSize"); + + b.Property("DrainRate"); + + b.Property("OverallDifficulty"); + + b.Property("SliderMultiplier"); + + b.Property("SliderTickRate"); + + b.HasKey("ID"); + + b.ToTable("BeatmapDifficulty"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("AudioLeadIn"); + + b.Property("BaseDifficultyID"); + + b.Property("BeatDivisor"); + + b.Property("BeatmapSetInfoID"); + + b.Property("Countdown"); + + b.Property("DistanceSpacing"); + + b.Property("GridSize"); + + b.Property("Hash"); + + b.Property("Hidden"); + + b.Property("LetterboxInBreaks"); + + b.Property("MD5Hash"); + + b.Property("MetadataID"); + + b.Property("OnlineBeatmapID"); + + b.Property("Path"); + + b.Property("RulesetID"); + + b.Property("SpecialStyle"); + + b.Property("StackLeniency"); + + b.Property("StarDifficulty"); + + b.Property("Status"); + + b.Property("StoredBookmarks"); + + b.Property("TimelineZoom"); + + b.Property("Version"); + + b.Property("WidescreenStoryboard"); + + b.HasKey("ID"); + + b.HasIndex("BaseDifficultyID"); + + b.HasIndex("BeatmapSetInfoID"); + + b.HasIndex("Hash"); + + b.HasIndex("MD5Hash"); + + b.HasIndex("MetadataID"); + + b.HasIndex("OnlineBeatmapID") + .IsUnique(); + + b.HasIndex("RulesetID"); + + b.ToTable("BeatmapInfo"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapMetadata", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Artist"); + + b.Property("ArtistUnicode"); + + b.Property("AudioFile"); + + b.Property("AuthorString") + .HasColumnName("Author"); + + b.Property("BackgroundFile"); + + b.Property("PreviewTime"); + + b.Property("Source"); + + b.Property("Tags"); + + b.Property("Title"); + + b.Property("TitleUnicode"); + + b.HasKey("ID"); + + b.ToTable("BeatmapMetadata"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("BeatmapSetInfoID"); + + b.Property("FileInfoID"); + + b.Property("Filename") + .IsRequired(); + + b.HasKey("ID"); + + b.HasIndex("BeatmapSetInfoID"); + + b.HasIndex("FileInfoID"); + + b.ToTable("BeatmapSetFileInfo"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("DeletePending"); + + b.Property("Hash"); + + b.Property("MetadataID"); + + b.Property("OnlineBeatmapSetID"); + + b.Property("Protected"); + + b.Property("Status"); + + b.HasKey("ID"); + + b.HasIndex("DeletePending"); + + b.HasIndex("Hash") + .IsUnique(); + + b.HasIndex("MetadataID"); + + b.HasIndex("OnlineBeatmapSetID") + .IsUnique(); + + b.ToTable("BeatmapSetInfo"); + }); + + modelBuilder.Entity("osu.Game.Configuration.DatabasedSetting", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Key") + .HasColumnName("Key"); + + b.Property("RulesetID"); + + b.Property("SkinInfoID"); + + b.Property("StringValue") + .HasColumnName("Value"); + + b.Property("Variant"); + + b.HasKey("ID"); + + b.HasIndex("SkinInfoID"); + + b.HasIndex("RulesetID", "Variant"); + + b.ToTable("Settings"); + }); + + modelBuilder.Entity("osu.Game.IO.FileInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Hash"); + + b.Property("ReferenceCount"); + + b.HasKey("ID"); + + b.HasIndex("Hash") + .IsUnique(); + + b.HasIndex("ReferenceCount"); + + b.ToTable("FileInfo"); + }); + + modelBuilder.Entity("osu.Game.Input.Bindings.DatabasedKeyBinding", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("IntAction") + .HasColumnName("Action"); + + b.Property("KeysString") + .HasColumnName("Keys"); + + b.Property("RulesetID"); + + b.Property("Variant"); + + b.HasKey("ID"); + + b.HasIndex("IntAction"); + + b.HasIndex("RulesetID", "Variant"); + + b.ToTable("KeyBinding"); + }); + + modelBuilder.Entity("osu.Game.Rulesets.RulesetInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Available"); + + b.Property("InstantiationInfo"); + + b.Property("Name"); + + b.Property("ShortName"); + + b.HasKey("ID"); + + b.HasIndex("Available"); + + b.HasIndex("ShortName") + .IsUnique(); + + b.ToTable("RulesetInfo"); + }); + + modelBuilder.Entity("osu.Game.Scoring.ScoreFileInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("FileInfoID"); + + b.Property("Filename") + .IsRequired(); + + b.Property("ScoreInfoID"); + + b.HasKey("ID"); + + b.HasIndex("FileInfoID"); + + b.HasIndex("ScoreInfoID"); + + b.ToTable("ScoreFileInfo"); + }); + + modelBuilder.Entity("osu.Game.Scoring.ScoreInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Accuracy") + .HasColumnType("DECIMAL(1,4)"); + + b.Property("BeatmapInfoID"); + + b.Property("Combo"); + + b.Property("Date"); + + b.Property("DeletePending"); + + b.Property("Hash"); + + b.Property("MaxCombo"); + + b.Property("ModsJson") + .HasColumnName("Mods"); + + b.Property("OnlineScoreID"); + + b.Property("PP"); + + b.Property("Rank"); + + b.Property("RulesetID"); + + b.Property("StatisticsJson") + .HasColumnName("Statistics"); + + b.Property("TotalScore"); + + b.Property("UserID") + .HasColumnName("UserID"); + + b.Property("UserString") + .HasColumnName("User"); + + b.HasKey("ID"); + + b.HasIndex("BeatmapInfoID"); + + b.HasIndex("OnlineScoreID") + .IsUnique(); + + b.HasIndex("RulesetID"); + + b.ToTable("ScoreInfo"); + }); + + modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("FileInfoID"); + + b.Property("Filename") + .IsRequired(); + + b.Property("SkinInfoID"); + + b.HasKey("ID"); + + b.HasIndex("FileInfoID"); + + b.HasIndex("SkinInfoID"); + + b.ToTable("SkinFileInfo"); + }); + + modelBuilder.Entity("osu.Game.Skinning.SkinInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Creator"); + + b.Property("DeletePending"); + + b.Property("Hash"); + + b.Property("Name"); + + b.HasKey("ID"); + + b.HasIndex("DeletePending"); + + b.HasIndex("Hash") + .IsUnique(); + + b.ToTable("SkinInfo"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapDifficulty", "BaseDifficulty") + .WithMany() + .HasForeignKey("BaseDifficultyID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo", "BeatmapSet") + .WithMany("Beatmaps") + .HasForeignKey("BeatmapSetInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata") + .WithMany("Beatmaps") + .HasForeignKey("MetadataID"); + + b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset") + .WithMany() + .HasForeignKey("RulesetID") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo") + .WithMany("Files") + .HasForeignKey("BeatmapSetInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.IO.FileInfo", "FileInfo") + .WithMany() + .HasForeignKey("FileInfoID") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata") + .WithMany("BeatmapSets") + .HasForeignKey("MetadataID"); + }); + + modelBuilder.Entity("osu.Game.Configuration.DatabasedSetting", b => + { + b.HasOne("osu.Game.Skinning.SkinInfo") + .WithMany("Settings") + .HasForeignKey("SkinInfoID"); + }); + + modelBuilder.Entity("osu.Game.Scoring.ScoreFileInfo", b => + { + b.HasOne("osu.Game.IO.FileInfo", "FileInfo") + .WithMany() + .HasForeignKey("FileInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Scoring.ScoreInfo") + .WithMany("Files") + .HasForeignKey("ScoreInfoID"); + }); + + modelBuilder.Entity("osu.Game.Scoring.ScoreInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapInfo", "Beatmap") + .WithMany("Scores") + .HasForeignKey("BeatmapInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset") + .WithMany() + .HasForeignKey("RulesetID") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b => + { + b.HasOne("osu.Game.IO.FileInfo", "FileInfo") + .WithMany() + .HasForeignKey("FileInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Skinning.SkinInfo") + .WithMany("Files") + .HasForeignKey("SkinInfoID") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/osu.Game/Migrations/20190525060824_SkinSettings.cs b/osu.Game/Migrations/20190525060824_SkinSettings.cs new file mode 100644 index 0000000000..8bd429ca5c --- /dev/null +++ b/osu.Game/Migrations/20190525060824_SkinSettings.cs @@ -0,0 +1,45 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace osu.Game.Migrations +{ + public partial class SkinSettings : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "SkinInfoID", + table: "Settings", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_Settings_SkinInfoID", + table: "Settings", + column: "SkinInfoID"); + + // unsupported by sqlite + + // migrationBuilder.AddForeignKey( + // name: "FK_Settings_SkinInfo_SkinInfoID", + // table: "Settings", + // column: "SkinInfoID", + // principalTable: "SkinInfo", + // principalColumn: "ID", + // onDelete: ReferentialAction.Restrict); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Settings_SkinInfo_SkinInfoID", + table: "Settings"); + + migrationBuilder.DropIndex( + name: "IX_Settings_SkinInfoID", + table: "Settings"); + + migrationBuilder.DropColumn( + name: "SkinInfoID", + table: "Settings"); + } + } +} diff --git a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs index 8430e00e4f..d03c2358b5 100644 --- a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs +++ b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs @@ -203,6 +203,8 @@ namespace osu.Game.Migrations b.Property("RulesetID"); + b.Property("SkinInfoID"); + b.Property("StringValue") .HasColumnName("Value"); @@ -210,6 +212,8 @@ namespace osu.Game.Migrations b.HasKey("ID"); + b.HasIndex("SkinInfoID"); + b.HasIndex("RulesetID", "Variant"); b.ToTable("Settings"); @@ -442,6 +446,13 @@ namespace osu.Game.Migrations .HasForeignKey("MetadataID"); }); + modelBuilder.Entity("osu.Game.Configuration.DatabasedSetting", b => + { + b.HasOne("osu.Game.Skinning.SkinInfo") + .WithMany("Settings") + .HasForeignKey("SkinInfoID"); + }); + modelBuilder.Entity("osu.Game.Scoring.ScoreFileInfo", b => { b.HasOne("osu.Game.IO.FileInfo", "FileInfo") diff --git a/osu.Game/Skinning/SkinInfo.cs b/osu.Game/Skinning/SkinInfo.cs index 07318b473a..187ea910a7 100644 --- a/osu.Game/Skinning/SkinInfo.cs +++ b/osu.Game/Skinning/SkinInfo.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using osu.Game.Configuration; using osu.Game.Database; namespace osu.Game.Skinning @@ -19,6 +20,8 @@ namespace osu.Game.Skinning public List Files { get; set; } + public List Settings { get; set; } + public bool DeletePending { get; set; } public string FullName => $"\"{Name}\" by {Creator}"; diff --git a/osu.Game/Skinning/SkinStore.cs b/osu.Game/Skinning/SkinStore.cs index 31cadb0a24..153eeda130 100644 --- a/osu.Game/Skinning/SkinStore.cs +++ b/osu.Game/Skinning/SkinStore.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.Linq; +using Microsoft.EntityFrameworkCore; using osu.Framework.Platform; using osu.Game.Database; @@ -12,5 +14,9 @@ namespace osu.Game.Skinning : base(contextFactory, storage) { } + + protected override IQueryable AddIncludesForDeletion(IQueryable query) => + base.AddIncludesForDeletion(query) + .Include(s => s.Settings); // don't include FileInfo. these are handled by the FileStore itself. } } From e59a00ac6eb1f30cb368392aedb299177fd8a168 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Tue, 28 May 2019 14:04:33 +0900 Subject: [PATCH 199/375] Remove excessive selection updating --- .../SongSelect/TestScenePlaySongSelect.cs | 28 ++++++++++++++++++- osu.Game/Screens/Select/SongSelect.cs | 8 +++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index 7e962dbc06..85811e3a0a 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -209,7 +209,33 @@ namespace osu.Game.Tests.Visual.SongSelect AddAssert("start not requested", () => !startRequested); } - private void importForRuleset(int id) => AddStep($"import test map for ruleset {id}", () => manager.Import(createTestBeatmapSet(getImportId(), rulesets.AvailableRulesets.Where(r => r.ID == id).ToArray()))); + [Test] + public void TestAddNewBeatmap() + { + const int test_count = 10; + int beatmapChangedCount = 0; + createSongSelect(); + AddStep("Setup counter", () => + { + beatmapChangedCount = 0; + songSelect.Carousel.BeatmapSetsChanged += () => beatmapChangedCount++; + }); + AddRepeatStep($"Create beatmaps {test_count} times", () => + { + manager.Import(createTestBeatmapSet(getImportId(), rulesets.AvailableRulesets.Where(r => r.ID == 0).ToArray())); + + Scheduler.AddDelayed(() => + { + // Wait for debounce + songSelect.Carousel.SelectNextRandom(); + }, 400); + }, test_count); + + AddAssert($"Beatmap changed {test_count} times", () => beatmapChangedCount == test_count); + } + + private void importForRuleset(int id) => AddStep($"import test map for ruleset {id}", + () => manager.Import(createTestBeatmapSet(getImportId(), rulesets.AvailableRulesets.Where(r => r.ID == id).ToArray()))); private static int importId; private int getImportId() => ++importId; diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index fed1f7a944..f30618ce3f 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -597,11 +597,17 @@ namespace osu.Game.Screens.Select { bindBindables(); + // As a selection was already obtained, do not attempt to update the selected beatmap. + if (Carousel.SelectedBeatmapSet != null) + return; + + // Attempt to select the current beatmap on the carousel, if it is valid to be selected. if (!Beatmap.IsDefault && Beatmap.Value.BeatmapSetInfo?.DeletePending == false && Beatmap.Value.BeatmapSetInfo?.Protected == false && Carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false)) return; - if (Carousel.SelectedBeatmapSet == null && !Carousel.SelectNextRandom()) + // If the current active beatmap could not be selected, select a new random beatmap. + if (!Carousel.SelectNextRandom()) { // in the case random selection failed, we want to trigger selectionChanged // to show the dummy beatmap (we have nothing else to display). From 436760de967e59400822e25356b502294bd487e3 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Tue, 28 May 2019 14:34:52 +0900 Subject: [PATCH 200/375] Change test name --- osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index 85811e3a0a..8e3fe57d92 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -210,7 +210,7 @@ namespace osu.Game.Tests.Visual.SongSelect } [Test] - public void TestAddNewBeatmap() + public void TestAddNewBeatmapWhileSelectingRandom() { const int test_count = 10; int beatmapChangedCount = 0; From 4ca34bd5e8a53752a37c1401c686757a67c943c5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 28 May 2019 17:06:01 +0900 Subject: [PATCH 201/375] Update osu! in line with audio subsystem refactor --- .../TestScenePreviewTrackManager.cs | 4 ++-- osu.Game/Audio/PreviewTrackManager.cs | 20 +++++++++---------- osu.Game/Beatmaps/BindableBeatmap.cs | 2 +- .../Containers/OsuFocusedOverlayContainer.cs | 4 ++-- osu.Game/Graphics/ScreenshotManager.cs | 2 +- .../UserInterface/HoverClickSounds.cs | 2 +- .../Graphics/UserInterface/HoverSounds.cs | 2 +- .../Graphics/UserInterface/OsuCheckbox.cs | 4 ++-- osu.Game/Graphics/UserInterface/OsuMenu.cs | 4 ++-- .../Graphics/UserInterface/OsuSliderBar.cs | 2 +- osu.Game/OsuGameBase.cs | 2 +- osu.Game/Overlays/MedalOverlay.cs | 2 +- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 4 ++-- osu.Game/Screens/Menu/Button.cs | 4 ++-- osu.Game/Screens/Menu/ButtonSystem.cs | 2 +- osu.Game/Screens/Menu/Intro.cs | 4 ++-- osu.Game/Screens/Menu/OsuLogo.cs | 4 ++-- osu.Game/Screens/Multi/Multiplayer.cs | 2 +- osu.Game/Screens/OsuScreen.cs | 2 +- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Play/SkipOverlay.cs | 2 +- .../Select/Carousel/DrawableCarouselItem.cs | 2 +- osu.Game/Screens/Select/SongSelect.cs | 8 ++++---- osu.Game/Skinning/LegacySkin.cs | 4 ++-- osu.Game/Skinning/SkinnableSound.cs | 2 +- osu.Game/osu.Game.csproj | 4 +++- osu.sln | 12 +++++++++++ 27 files changed, 61 insertions(+), 47 deletions(-) diff --git a/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.cs b/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.cs index 94412455a0..e85e879ef5 100644 --- a/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.cs +++ b/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.cs @@ -111,11 +111,11 @@ namespace osu.Game.Tests.Visual.Components private class TestPreviewTrackManager : PreviewTrackManager { - protected override TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackManager trackManager) => new TestPreviewTrack(beatmapSetInfo, trackManager); + protected override TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackStore trackStore) => new TestPreviewTrack(beatmapSetInfo, trackStore); protected class TestPreviewTrack : TrackManagerPreviewTrack { - public TestPreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackManager trackManager) + public TestPreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackStore trackManager) : base(beatmapSetInfo, trackManager) { } diff --git a/osu.Game/Audio/PreviewTrackManager.cs b/osu.Game/Audio/PreviewTrackManager.cs index 99c0d70ac9..695051f508 100644 --- a/osu.Game/Audio/PreviewTrackManager.cs +++ b/osu.Game/Audio/PreviewTrackManager.cs @@ -20,19 +20,19 @@ namespace osu.Game.Audio private readonly BindableDouble muteBindable = new BindableDouble(); private AudioManager audio; - private TrackManager trackManager; + private TrackStore trackStore; private TrackManagerPreviewTrack current; [BackgroundDependencyLoader] private void load(AudioManager audio, FrameworkConfigManager config) { - trackManager = new TrackManager(new OnlineStore()); + trackStore = new TrackStore(new OnlineStore()); this.audio = audio; - audio.AddItem(trackManager); + audio.AddItem(trackStore); - config.BindWith(FrameworkSetting.VolumeMusic, trackManager.Volume); + config.BindWith(FrameworkSetting.VolumeMusic, trackStore.Volume); } /// @@ -42,19 +42,19 @@ namespace osu.Game.Audio /// The playable . public PreviewTrack Get(BeatmapSetInfo beatmapSetInfo) { - var track = CreatePreviewTrack(beatmapSetInfo, trackManager); + var track = CreatePreviewTrack(beatmapSetInfo, trackStore); track.Started += () => { current?.Stop(); current = track; - audio.Track.AddAdjustment(AdjustableProperty.Volume, muteBindable); + audio.Tracks.AddAdjustment(AdjustableProperty.Volume, muteBindable); }; track.Stopped += () => { current = null; - audio.Track.RemoveAdjustment(AdjustableProperty.Volume, muteBindable); + audio.Tracks.RemoveAdjustment(AdjustableProperty.Volume, muteBindable); }; return track; @@ -81,16 +81,16 @@ namespace osu.Game.Audio /// /// Creates the . /// - protected virtual TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackManager trackManager) => new TrackManagerPreviewTrack(beatmapSetInfo, trackManager); + protected virtual TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackStore trackStore) => new TrackManagerPreviewTrack(beatmapSetInfo, trackStore); protected class TrackManagerPreviewTrack : PreviewTrack { public IPreviewTrackOwner Owner { get; private set; } private readonly BeatmapSetInfo beatmapSetInfo; - private readonly TrackManager trackManager; + private readonly TrackStore trackManager; - public TrackManagerPreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackManager trackManager) + public TrackManagerPreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackStore trackManager) { this.beatmapSetInfo = beatmapSetInfo; this.trackManager = trackManager; diff --git a/osu.Game/Beatmaps/BindableBeatmap.cs b/osu.Game/Beatmaps/BindableBeatmap.cs index 27bad65062..dcce18b1be 100644 --- a/osu.Game/Beatmaps/BindableBeatmap.cs +++ b/osu.Game/Beatmaps/BindableBeatmap.cs @@ -56,7 +56,7 @@ namespace osu.Game.Beatmaps lastBeatmap.RecycleTrack(); } - audioManager.Track.AddItem(beatmap.Track); + audioManager.Tracks.AddItem(beatmap.Track); } lastBeatmap = beatmap; diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index 3f84f77081..8b34459710 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -51,8 +51,8 @@ namespace osu.Game.Graphics.Containers if (osuGame != null) OverlayActivationMode.BindTo(osuGame.OverlayActivationMode); - samplePopIn = audio.Sample.Get(@"UI/overlay-pop-in"); - samplePopOut = audio.Sample.Get(@"UI/overlay-pop-out"); + samplePopIn = audio.Samples.Get(@"UI/overlay-pop-in"); + samplePopOut = audio.Samples.Get(@"UI/overlay-pop-out"); StateChanged += onStateChanged; } diff --git a/osu.Game/Graphics/ScreenshotManager.cs b/osu.Game/Graphics/ScreenshotManager.cs index 24a98e6dc9..5ad5e5569a 100644 --- a/osu.Game/Graphics/ScreenshotManager.cs +++ b/osu.Game/Graphics/ScreenshotManager.cs @@ -51,7 +51,7 @@ namespace osu.Game.Graphics screenshotFormat = config.GetBindable(OsuSetting.ScreenshotFormat); captureMenuCursor = config.GetBindable(OsuSetting.ScreenshotCaptureMenuCursor); - shutter = audio.Sample.Get("UI/shutter"); + shutter = audio.Samples.Get("UI/shutter"); } public bool OnPressed(GlobalAction action) diff --git a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs index cbbaa6d303..70d988f60e 100644 --- a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs @@ -31,7 +31,7 @@ namespace osu.Game.Graphics.UserInterface [BackgroundDependencyLoader] private void load(AudioManager audio) { - sampleClick = audio.Sample.Get($@"UI/generic-select{SampleSet.GetDescription()}"); + sampleClick = audio.Samples.Get($@"UI/generic-select{SampleSet.GetDescription()}"); } } } diff --git a/osu.Game/Graphics/UserInterface/HoverSounds.cs b/osu.Game/Graphics/UserInterface/HoverSounds.cs index b246092a7f..f1ac8ced6e 100644 --- a/osu.Game/Graphics/UserInterface/HoverSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverSounds.cs @@ -37,7 +37,7 @@ namespace osu.Game.Graphics.UserInterface [BackgroundDependencyLoader] private void load(AudioManager audio) { - sampleHover = audio.Sample.Get($@"UI/generic-hover{SampleSet.GetDescription()}"); + sampleHover = audio.Samples.Get($@"UI/generic-hover{SampleSet.GetDescription()}"); } } diff --git a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs index 2944fc87af..cd1147e3d3 100644 --- a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs +++ b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs @@ -112,8 +112,8 @@ namespace osu.Game.Graphics.UserInterface [BackgroundDependencyLoader] private void load(AudioManager audio) { - sampleChecked = audio.Sample.Get(@"UI/check-on"); - sampleUnchecked = audio.Sample.Get(@"UI/check-off"); + sampleChecked = audio.Samples.Get(@"UI/check-on"); + sampleUnchecked = audio.Samples.Get(@"UI/check-off"); } } } diff --git a/osu.Game/Graphics/UserInterface/OsuMenu.cs b/osu.Game/Graphics/UserInterface/OsuMenu.cs index 32994be78a..f8234cb81f 100644 --- a/osu.Game/Graphics/UserInterface/OsuMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuMenu.cs @@ -71,8 +71,8 @@ namespace osu.Game.Graphics.UserInterface [BackgroundDependencyLoader] private void load(AudioManager audio) { - sampleHover = audio.Sample.Get(@"UI/generic-hover"); - sampleClick = audio.Sample.Get(@"UI/generic-select"); + sampleHover = audio.Samples.Get(@"UI/generic-hover"); + sampleClick = audio.Samples.Get(@"UI/generic-select"); BackgroundColour = Color4.Transparent; BackgroundColourHover = OsuColour.FromHex(@"172023"); diff --git a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs index c3c447ef83..5c706781e6 100644 --- a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs +++ b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs @@ -86,7 +86,7 @@ namespace osu.Game.Graphics.UserInterface [BackgroundDependencyLoader] private void load(AudioManager audio, OsuColour colours) { - sample = audio.Sample.Get(@"UI/sliderbar-notch"); + sample = audio.Samples.Get(@"UI/sliderbar-notch"); AccentColour = colours.Pink; } diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 7b9aed8364..40cb26ec54 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -193,7 +193,7 @@ namespace osu.Game // tracks play so loud our samples can't keep up. // this adds a global reduction of track volume for the time being. - Audio.Track.AddAdjustment(AdjustableProperty.Volume, new BindableDouble(0.8)); + Audio.Tracks.AddAdjustment(AdjustableProperty.Volume, new BindableDouble(0.8)); beatmap = new OsuBindableBeatmap(defaultBeatmap, Audio); diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs index 6d82db5603..1f15c773f4 100644 --- a/osu.Game/Overlays/MedalOverlay.cs +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -145,7 +145,7 @@ namespace osu.Game.Overlays [BackgroundDependencyLoader] private void load(OsuColour colours, TextureStore textures, AudioManager audio) { - getSample = audio.Sample.Get(@"MedalSplash/medal-get"); + getSample = audio.Samples.Get(@"MedalSplash/medal-get"); innerSpin.Texture = outerSpin.Texture = textures.Get(@"MedalSplash/disc-spin"); disc.EdgeEffect = leftStrip.EdgeEffect = rightStrip.EdgeEffect = new EdgeEffectParameters diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 97769fe5aa..b675a35970 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -56,8 +56,8 @@ namespace osu.Game.Overlays.Mods Ruleset.BindTo(ruleset); if (mods != null) SelectedMods.BindTo(mods); - sampleOn = audio.Sample.Get(@"UI/check-on"); - sampleOff = audio.Sample.Get(@"UI/check-off"); + sampleOn = audio.Samples.Get(@"UI/check-on"); + sampleOff = audio.Samples.Get(@"UI/check-off"); } protected override void LoadComplete() diff --git a/osu.Game/Screens/Menu/Button.cs b/osu.Game/Screens/Menu/Button.cs index 7d48f619d9..badd1e0549 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -182,9 +182,9 @@ namespace osu.Game.Screens.Menu [BackgroundDependencyLoader] private void load(AudioManager audio) { - sampleHover = audio.Sample.Get(@"Menu/button-hover"); + sampleHover = audio.Samples.Get(@"Menu/button-hover"); if (!string.IsNullOrEmpty(sampleName)) - sampleClick = audio.Sample.Get($@"Menu/{sampleName}"); + sampleClick = audio.Samples.Get($@"Menu/{sampleName}"); } protected override bool OnMouseDown(MouseDownEvent e) diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index a098d42c83..11b637801a 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -150,7 +150,7 @@ namespace osu.Game.Screens.Menu if (idleTracker != null) isIdle.BindTo(idleTracker.IsIdle); - sampleBack = audio.Sample.Get(@"Menu/button-back-select"); + sampleBack = audio.Samples.Get(@"Menu/button-back-select"); } private void onMulti() diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 2392d650a0..98a2fe8f13 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -76,8 +76,8 @@ namespace osu.Game.Screens.Menu introBeatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]); track = introBeatmap.Track; - welcome = audio.Sample.Get(@"welcome"); - seeya = audio.Sample.Get(@"seeya"); + welcome = audio.Samples.Get(@"welcome"); + seeya = audio.Samples.Get(@"seeya"); } private const double delay_step_one = 2300; diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index 4631f4e222..479b3d80b6 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -255,8 +255,8 @@ namespace osu.Game.Screens.Menu [BackgroundDependencyLoader] private void load(TextureStore textures, AudioManager audio) { - sampleClick = audio.Sample.Get(@"Menu/osu-logo-select"); - sampleBeat = audio.Sample.Get(@"Menu/osu-logo-heartbeat"); + sampleClick = audio.Samples.Get(@"Menu/osu-logo-select"); + sampleBeat = audio.Samples.Get(@"Menu/osu-logo-heartbeat"); logo.Texture = textures.Get(@"Menu/logo"); ripple.Texture = textures.Get(@"Menu/logo"); diff --git a/osu.Game/Screens/Multi/Multiplayer.cs b/osu.Game/Screens/Multi/Multiplayer.cs index 155665e0d5..9e5c11e098 100644 --- a/osu.Game/Screens/Multi/Multiplayer.cs +++ b/osu.Game/Screens/Multi/Multiplayer.cs @@ -255,7 +255,7 @@ namespace osu.Game.Screens.Multi if (!track.IsRunning) { - game.Audio.AddItemToList(track); + game.Audio.AddItem(track); track.Seek(Beatmap.Value.Metadata.PreviewTime); track.Start(); } diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 9d53e43b80..f7b90e9966 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -99,7 +99,7 @@ namespace osu.Game.Screens [BackgroundDependencyLoader(true)] private void load(OsuGame osu, AudioManager audio) { - sampleExit = audio.Sample.Get(@"UI/screen-back"); + sampleExit = audio.Samples.Get(@"UI/screen-back"); } public virtual bool OnPressed(GlobalAction action) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 30214d1b9c..cf743ee4f7 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -103,7 +103,7 @@ namespace osu.Game.Screens.Play if (working == null) return; - sampleRestart = audio.Sample.Get(@"Gameplay/restart"); + sampleRestart = audio.Samples.Get(@"Gameplay/restart"); mouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); showStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); diff --git a/osu.Game/Screens/Play/SkipOverlay.cs b/osu.Game/Screens/Play/SkipOverlay.cs index e3c56e1c2c..4ecc15f22b 100644 --- a/osu.Game/Screens/Play/SkipOverlay.cs +++ b/osu.Game/Screens/Play/SkipOverlay.cs @@ -234,7 +234,7 @@ namespace osu.Game.Screens.Play colourNormal = colours.Yellow; colourHover = colours.YellowDark; - sampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection"); + sampleConfirm = audio.Samples.Get(@"SongSelect/confirm-selection"); Children = new Drawable[] { diff --git a/osu.Game/Screens/Select/Carousel/DrawableCarouselItem.cs b/osu.Game/Screens/Select/Carousel/DrawableCarouselItem.cs index f1d6343e72..b906bd935c 100644 --- a/osu.Game/Screens/Select/Carousel/DrawableCarouselItem.cs +++ b/osu.Game/Screens/Select/Carousel/DrawableCarouselItem.cs @@ -69,7 +69,7 @@ namespace osu.Game.Screens.Select.Carousel } }; - sampleHover = audio.Sample.Get($@"SongSelect/song-ping-variation-{RNG.Next(1, 5)}"); + sampleHover = audio.Samples.Get($@"SongSelect/song-ping-variation-{RNG.Next(1, 5)}"); hoverLayer.Colour = colours.Blue.Opacity(0.1f); } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index fed1f7a944..b266a73eb5 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -242,9 +242,9 @@ namespace osu.Game.Screens.Select dialogOverlay = dialog; - sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty"); - sampleChangeBeatmap = audio.Sample.Get(@"SongSelect/select-expand"); - SampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection"); + sampleChangeDifficulty = audio.Samples.Get(@"SongSelect/select-difficulty"); + sampleChangeBeatmap = audio.Samples.Get(@"SongSelect/select-expand"); + SampleConfirm = audio.Samples.Get(@"SongSelect/confirm-selection"); Carousel.LoadBeatmapSetsFromManager(this.beatmaps); @@ -582,7 +582,7 @@ namespace osu.Game.Screens.Select { // Ensure the track is added to the TrackManager, since it is removed after the player finishes the map. // Using AddItemToList rather than AddItem so that it doesn't attempt to register adjustment dependencies more than once. - Game.Audio.Track.AddItemToList(track); + Game.Audio.Tracks.AddItem(track); track.RestartPoint = Beatmap.Value.Metadata.PreviewTime; track.Restart(); } diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index ea4a777b47..9f31783a6b 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -21,7 +21,7 @@ namespace osu.Game.Skinning { protected TextureStore Textures; - protected SampleManager Samples; + protected SampleStore Samples; public LegacySkin(SkinInfo skin, IResourceStore storage, AudioManager audioManager) : this(skin, new LegacySkinResourceStore(skin, storage), audioManager, "skin.ini") @@ -38,7 +38,7 @@ namespace osu.Game.Skinning else Configuration = new SkinConfiguration(); - Samples = audioManager.GetSampleManager(storage); + Samples = audioManager.GetSampleStore(storage); Textures = new TextureStore(new TextureLoaderStore(storage)); } diff --git a/osu.Game/Skinning/SkinnableSound.cs b/osu.Game/Skinning/SkinnableSound.cs index d6f3625be8..5e8a0ea43f 100644 --- a/osu.Game/Skinning/SkinnableSound.cs +++ b/osu.Game/Skinning/SkinnableSound.cs @@ -39,7 +39,7 @@ namespace osu.Game.Skinning { var ch = loadChannel(s, skin.GetSample); if (ch == null && allowFallback) - ch = loadChannel(s, audio.Sample.Get); + ch = loadChannel(s, audio.Samples.Get); return ch; }).Where(c => c != null).ToArray(); } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index b77c724d1b..185aac4311 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -15,10 +15,12 @@ - + + + diff --git a/osu.sln b/osu.sln index 3c38309d86..3a60016bda 100644 --- a/osu.sln +++ b/osu.sln @@ -25,6 +25,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Game.Rulesets.Taiko.Tes EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Game.Rulesets.Osu.Tests", "osu.Game.Rulesets.Osu.Tests\osu.Game.Rulesets.Osu.Tests.csproj", "{DECCCC75-67AD-4C3D-BB84-FD0E01323511}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Framework", "..\osu-framework\osu.Framework\osu.Framework.csproj", "{7CCA1C51-AAC8-4153-BAC6-F0E4976602C0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Framework.NativeLibs", "..\osu-framework\osu.Framework.NativeLibs\osu.Framework.NativeLibs.csproj", "{8EFF6D45-9A38-40B6-9FDC-963DE8472576}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -79,6 +83,14 @@ Global {DECCCC75-67AD-4C3D-BB84-FD0E01323511}.Debug|Any CPU.Build.0 = Debug|Any CPU {DECCCC75-67AD-4C3D-BB84-FD0E01323511}.Release|Any CPU.ActiveCfg = Release|Any CPU {DECCCC75-67AD-4C3D-BB84-FD0E01323511}.Release|Any CPU.Build.0 = Release|Any CPU + {7CCA1C51-AAC8-4153-BAC6-F0E4976602C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7CCA1C51-AAC8-4153-BAC6-F0E4976602C0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7CCA1C51-AAC8-4153-BAC6-F0E4976602C0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7CCA1C51-AAC8-4153-BAC6-F0E4976602C0}.Release|Any CPU.Build.0 = Release|Any CPU + {8EFF6D45-9A38-40B6-9FDC-963DE8472576}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8EFF6D45-9A38-40B6-9FDC-963DE8472576}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8EFF6D45-9A38-40B6-9FDC-963DE8472576}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8EFF6D45-9A38-40B6-9FDC-963DE8472576}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 23b5d303606b5edfcea4e25837b6bed927f8ea8e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 28 May 2019 17:10:46 +0900 Subject: [PATCH 202/375] Remove csproj changes --- osu.Game/osu.Game.csproj | 4 +--- osu.sln | 12 ------------ 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 185aac4311..b77c724d1b 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -15,12 +15,10 @@ + - - - diff --git a/osu.sln b/osu.sln index 3a60016bda..3c38309d86 100644 --- a/osu.sln +++ b/osu.sln @@ -25,10 +25,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Game.Rulesets.Taiko.Tes EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Game.Rulesets.Osu.Tests", "osu.Game.Rulesets.Osu.Tests\osu.Game.Rulesets.Osu.Tests.csproj", "{DECCCC75-67AD-4C3D-BB84-FD0E01323511}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Framework", "..\osu-framework\osu.Framework\osu.Framework.csproj", "{7CCA1C51-AAC8-4153-BAC6-F0E4976602C0}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Framework.NativeLibs", "..\osu-framework\osu.Framework.NativeLibs\osu.Framework.NativeLibs.csproj", "{8EFF6D45-9A38-40B6-9FDC-963DE8472576}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -83,14 +79,6 @@ Global {DECCCC75-67AD-4C3D-BB84-FD0E01323511}.Debug|Any CPU.Build.0 = Debug|Any CPU {DECCCC75-67AD-4C3D-BB84-FD0E01323511}.Release|Any CPU.ActiveCfg = Release|Any CPU {DECCCC75-67AD-4C3D-BB84-FD0E01323511}.Release|Any CPU.Build.0 = Release|Any CPU - {7CCA1C51-AAC8-4153-BAC6-F0E4976602C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7CCA1C51-AAC8-4153-BAC6-F0E4976602C0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7CCA1C51-AAC8-4153-BAC6-F0E4976602C0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7CCA1C51-AAC8-4153-BAC6-F0E4976602C0}.Release|Any CPU.Build.0 = Release|Any CPU - {8EFF6D45-9A38-40B6-9FDC-963DE8472576}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8EFF6D45-9A38-40B6-9FDC-963DE8472576}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8EFF6D45-9A38-40B6-9FDC-963DE8472576}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8EFF6D45-9A38-40B6-9FDC-963DE8472576}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 1a871af5520113372c38d70740337dc794fe2b30 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Tue, 28 May 2019 19:15:29 +0900 Subject: [PATCH 203/375] Fix hide selection, add test --- .../Visual/SongSelect/TestScenePlaySongSelect.cs | 12 ++++++++++++ osu.Game/Screens/Select/BeatmapCarousel.cs | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index 8e3fe57d92..c33528c3bf 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -234,6 +234,18 @@ namespace osu.Game.Tests.Visual.SongSelect AddAssert($"Beatmap changed {test_count} times", () => beatmapChangedCount == test_count); } + [Test] + public void TestHideSetSelectsCorrectBeatmap() + { + int? previousID = null; + createSongSelect(); + importForRuleset(0); + AddStep("Move to last difficulty", () => songSelect.Carousel.SelectBeatmap(songSelect.Carousel.BeatmapSets.First().Beatmaps.Last())); + AddStep("Store current ID", () => previousID = songSelect.Carousel.SelectedBeatmap.ID); + AddStep("Hide first beatmap", () => manager.Hide(songSelect.Carousel.SelectedBeatmapSet.Beatmaps.First())); + AddAssert("Selected beatmap has not changed", () => songSelect.Carousel.SelectedBeatmap.ID == previousID); + } + private void importForRuleset(int id) => AddStep($"import test map for ruleset {id}", () => manager.Import(createTestBeatmapSet(getImportId(), rulesets.AvailableRulesets.Where(r => r.ID == id).ToArray()))); diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 63ad3b6ab2..0b3d0c448b 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -158,6 +158,9 @@ namespace osu.Game.Screens.Select var newSet = createCarouselSet(beatmapSet); + // Since we're about to remove the selected beatmap, store its ID so we can go back if needed. + var previouslySelectedID = selectedBeatmap?.Beatmap.ID; + if (existingSet != null) root.RemoveChild(existingSet); @@ -173,7 +176,7 @@ namespace osu.Game.Screens.Select //check if we can/need to maintain our current selection. if (hadSelection) - select((CarouselItem)newSet.Beatmaps.FirstOrDefault(b => b.Beatmap.ID == selectedBeatmap?.Beatmap.ID) ?? newSet); + select((CarouselItem)newSet.Beatmaps.FirstOrDefault(b => b.Beatmap.ID == previouslySelectedID) ?? newSet); itemsCache.Invalidate(); Schedule(() => BeatmapSetsChanged?.Invoke()); From 6ca3bd086f54894a0f02ca29ea7dfcd13bc91786 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 28 May 2019 17:04:05 +0300 Subject: [PATCH 204/375] ShowMore button update --- .../Beatmaps/PaginatedBeatmapContainer.cs | 4 +- .../PaginatedMostPlayedBeatmapContainer.cs | 4 +- .../Profile/Sections/PaginatedContainer.cs | 161 +++++++++++++++--- .../Sections/Ranks/PaginatedScoreContainer.cs | 10 +- .../PaginatedRecentActivityContainer.cs | 4 +- 5 files changed, 146 insertions(+), 37 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs index 0fc1398f5d..db291d0731 100644 --- a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs @@ -34,8 +34,8 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps request = new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++ * ItemsPerPage); request.Success += sets => Schedule(() => { - ShowMoreButton.FadeTo(sets.Count == ItemsPerPage ? 1 : 0); - ShowMoreLoading.Hide(); + MoreButton.FadeTo(sets.Count == ItemsPerPage ? 1 : 0); + MoreButton.IsLoading = false; if (!sets.Any() && VisiblePages == 1) { diff --git a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs index f2eb32c53b..0f86e0900e 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs @@ -29,8 +29,8 @@ namespace osu.Game.Overlays.Profile.Sections.Historical request = new GetUserMostPlayedBeatmapsRequest(User.Value.Id, VisiblePages++ * ItemsPerPage); request.Success += beatmaps => Schedule(() => { - ShowMoreButton.FadeTo(beatmaps.Count == ItemsPerPage ? 1 : 0); - ShowMoreLoading.Hide(); + MoreButton.FadeTo(beatmaps.Count == ItemsPerPage ? 1 : 0); + MoreButton.IsLoading = false; if (!beatmaps.Any() && VisiblePages == 1) { diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs index 46c65b9db7..1ebc51b11f 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs @@ -7,11 +7,15 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; -using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Game.Rulesets; +using osu.Framework.Input.Events; +using System; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osuTK.Graphics; using osu.Game.Users; namespace osu.Game.Overlays.Profile.Sections @@ -19,8 +23,7 @@ namespace osu.Game.Overlays.Profile.Sections public class PaginatedContainer : FillFlowContainer { protected readonly FillFlowContainer ItemsContainer; - protected readonly OsuHoverContainer ShowMoreButton; - protected readonly LoadingAnimation ShowMoreLoading; + protected readonly ShowMoreButton MoreButton; protected readonly OsuSpriteText MissingText; protected int VisiblePages; @@ -45,38 +48,25 @@ namespace osu.Game.Overlays.Profile.Sections new OsuSpriteText { Text = header, - Font = OsuFont.GetFont(size: 15, weight: FontWeight.Regular, italics: true), + Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold), Margin = new MarginPadding { Top = 10, Bottom = 10 }, }, ItemsContainer = new FillFlowContainer { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, - Margin = new MarginPadding { Bottom = 10 } + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 2), }, - ShowMoreButton = new OsuHoverContainer + MoreButton = new ShowMoreButton { Alpha = 0, + Margin = new MarginPadding { Top = 10 }, Action = ShowMore, - AutoSizeAxes = Axes.Both, - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Child = new OsuSpriteText - { - Font = OsuFont.GetFont(size: 14), - Text = "show more", - Padding = new MarginPadding { Vertical = 10, Horizontal = 15 }, - } - }, - ShowMoreLoading = new LoadingAnimation - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Size = new Vector2(14), }, MissingText = new OsuSpriteText { - Font = OsuFont.GetFont(size: 14), + Font = OsuFont.GetFont(size: 15), Text = missing, Alpha = 0, }, @@ -97,16 +87,135 @@ namespace osu.Game.Overlays.Profile.Sections { VisiblePages = 0; ItemsContainer.Clear(); - ShowMoreButton.Hide(); if (e.NewValue != null) ShowMore(); } - protected virtual void ShowMore() + protected virtual void ShowMore() => MoreButton.IsLoading = true; + + protected class ShowMoreButton : CircularContainer { - ShowMoreLoading.Show(); - ShowMoreButton.Hide(); + private const int duration = 300; + private Color4 idleColour; + private Color4 hoveredColour; + + public Action Action; + private readonly Box background; + private readonly LoadingAnimation loading; + private readonly FillFlowContainer content; + + private bool isLoading; + public bool IsLoading + { + set + { + isLoading = value; + + if (value) + { + loading.FadeIn(duration, Easing.OutQuint); + content.FadeOut(duration, Easing.OutQuint); + } + else + { + loading.FadeOut(duration, Easing.OutQuint); + content.FadeIn(duration, Easing.OutQuint); + } + } + get + { + return isLoading; + } + } + + public ShowMoreButton() + { + Anchor = Anchor.TopCentre; + Origin = Anchor.TopCentre; + Masking = true; + Size = new Vector2(140, 30); + Children = new Drawable[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both, + }, + content = new FillFlowContainer + { + Alpha = 0, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(7), + Children = new Drawable[] + { + new ChevronIcon(), + new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold), + Text = "show more".ToUpper(), + }, + new ChevronIcon(), + } + }, + loading = new LoadingAnimation + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(20) + }, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colors) + { + background.Colour = idleColour = colors.GreySeafoam; + hoveredColour = colors.GreySeafoamLight; + } + + protected override bool OnHover(HoverEvent e) + { + background.FadeColour(hoveredColour, duration, Easing.OutQuint); + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + background.FadeColour(idleColour, duration, Easing.OutQuint); + base.OnHoverLost(e); + } + + protected override bool OnClick(ClickEvent e) + { + Action.Invoke(); + return base.OnClick(e); + } + + private class ChevronIcon : SpriteIcon + { + private const int bottom_margin = 2; + private const int icon_size = 8; + + public ChevronIcon() + { + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + Margin = new MarginPadding { Bottom = bottom_margin }; + Size = new Vector2(icon_size); + Icon = FontAwesome.Solid.ChevronDown; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colors) + { + Colour = colors.Yellow; + } + } } } } diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs index 470bed2854..1d9e3d1cc1 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs @@ -1,7 +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.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Online.API.Requests; using osu.Game.Users; @@ -9,6 +8,7 @@ using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Bindables; +using osu.Framework.Graphics; namespace osu.Game.Overlays.Profile.Sections.Ranks { @@ -41,8 +41,8 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks if (!scores.Any() && VisiblePages == 1) { - ShowMoreButton.Hide(); - ShowMoreLoading.Hide(); + MoreButton.Hide(); + MoreButton.IsLoading = false; MissingText.Show(); return; } @@ -63,8 +63,8 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks LoadComponentsAsync(drawableScores, s => { MissingText.Hide(); - ShowMoreButton.FadeTo(scores.Count == ItemsPerPage ? 1 : 0); - ShowMoreLoading.Hide(); + MoreButton.FadeTo(scores.Count == ItemsPerPage ? 1 : 0); + MoreButton.IsLoading = false; ItemsContainer.AddRange(s); }); diff --git a/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs b/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs index 4b4acb8fbc..38134ad660 100644 --- a/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs @@ -27,8 +27,8 @@ namespace osu.Game.Overlays.Profile.Sections.Recent request = new GetUserRecentActivitiesRequest(User.Value.Id, VisiblePages++ * ItemsPerPage); request.Success += activities => Schedule(() => { - ShowMoreButton.FadeTo(activities.Count == ItemsPerPage ? 1 : 0); - ShowMoreLoading.Hide(); + MoreButton.FadeTo(activities.Count == ItemsPerPage ? 1 : 0); + MoreButton.IsLoading = false; if (!activities.Any() && VisiblePages == 1) { From 857eb9b83a5a5cfab6865d06807ad58af5aa1aa1 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 28 May 2019 17:21:34 +0300 Subject: [PATCH 205/375] Fix CI stuff --- osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs index 1ebc51b11f..7e13a90f25 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs @@ -106,6 +106,7 @@ namespace osu.Game.Overlays.Profile.Sections private readonly FillFlowContainer content; private bool isLoading; + public bool IsLoading { set @@ -123,10 +124,7 @@ namespace osu.Game.Overlays.Profile.Sections content.FadeIn(duration, Easing.OutQuint); } } - get - { - return isLoading; - } + get => isLoading; } public ShowMoreButton() From a20eda7b5f99eb4bd35b88c3c73bcf3e1d4dca95 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 28 May 2019 23:54:42 +0900 Subject: [PATCH 206/375] Fix remaining cases to work without things --- .../TestScenePreviewTrackManager.cs | 5 ++- osu.Game/Audio/PreviewTrackManager.cs | 11 +++--- .../Beatmaps/BeatmapManager_WorkingBeatmap.cs | 18 ++++++--- osu.Game/Beatmaps/BindableBeatmap.cs | 38 +++++++------------ osu.Game/Beatmaps/WorkingBeatmap.cs | 6 ++- osu.Game/OsuGameBase.cs | 11 +++--- osu.Game/Overlays/MusicController.cs | 2 +- osu.Game/Screens/Select/SongSelect.cs | 3 -- osu.Game/Skinning/LegacySkin.cs | 9 ++++- osu.Game/Tests/Visual/OsuTestScene.cs | 12 ++---- 10 files changed, 58 insertions(+), 57 deletions(-) diff --git a/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.cs b/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.cs index e85e879ef5..0784725ea4 100644 --- a/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.cs +++ b/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.cs @@ -5,6 +5,7 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Audio.Track; using osu.Framework.Graphics.Containers; +using osu.Framework.IO.Stores; using osu.Game.Audio; using osu.Game.Beatmaps; @@ -111,11 +112,11 @@ namespace osu.Game.Tests.Visual.Components private class TestPreviewTrackManager : PreviewTrackManager { - protected override TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackStore trackStore) => new TestPreviewTrack(beatmapSetInfo, trackStore); + protected override TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, IResourceStore trackStore) => new TestPreviewTrack(beatmapSetInfo, trackStore); protected class TestPreviewTrack : TrackManagerPreviewTrack { - public TestPreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackStore trackManager) + public TestPreviewTrack(BeatmapSetInfo beatmapSetInfo, IResourceStore trackManager) : base(beatmapSetInfo, trackManager) { } diff --git a/osu.Game/Audio/PreviewTrackManager.cs b/osu.Game/Audio/PreviewTrackManager.cs index 695051f508..4b7277c3fd 100644 --- a/osu.Game/Audio/PreviewTrackManager.cs +++ b/osu.Game/Audio/PreviewTrackManager.cs @@ -20,17 +20,16 @@ namespace osu.Game.Audio private readonly BindableDouble muteBindable = new BindableDouble(); private AudioManager audio; - private TrackStore trackStore; + private IAdjustableResourceStore trackStore; private TrackManagerPreviewTrack current; [BackgroundDependencyLoader] private void load(AudioManager audio, FrameworkConfigManager config) { - trackStore = new TrackStore(new OnlineStore()); + trackStore = audio.GetTrackStore(new OnlineStore()); this.audio = audio; - audio.AddItem(trackStore); config.BindWith(FrameworkSetting.VolumeMusic, trackStore.Volume); } @@ -81,16 +80,16 @@ namespace osu.Game.Audio /// /// Creates the . /// - protected virtual TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackStore trackStore) => new TrackManagerPreviewTrack(beatmapSetInfo, trackStore); + protected virtual TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, IResourceStore trackStore) => new TrackManagerPreviewTrack(beatmapSetInfo, trackStore); protected class TrackManagerPreviewTrack : PreviewTrack { public IPreviewTrackOwner Owner { get; private set; } private readonly BeatmapSetInfo beatmapSetInfo; - private readonly TrackStore trackManager; + private readonly IResourceStore trackManager; - public TrackManagerPreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackStore trackManager) + public TrackManagerPreviewTrack(BeatmapSetInfo beatmapSetInfo, IResourceStore trackManager) { this.beatmapSetInfo = beatmapSetInfo; this.trackManager = trackManager; diff --git a/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs b/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs index 0bdab22dd2..cfeb6b0a92 100644 --- a/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs @@ -20,14 +20,13 @@ namespace osu.Game.Beatmaps protected class BeatmapManagerWorkingBeatmap : WorkingBeatmap { private readonly IResourceStore store; - private readonly AudioManager audioManager; public BeatmapManagerWorkingBeatmap(IResourceStore store, TextureStore textureStore, BeatmapInfo beatmapInfo, AudioManager audioManager) : base(beatmapInfo) { this.store = store; this.textureStore = textureStore; - this.audioManager = audioManager; + AudioManager = audioManager; } protected override IBeatmap GetBeatmap() @@ -47,6 +46,8 @@ namespace osu.Game.Beatmaps private TextureStore textureStore; + private IAdjustableResourceStore trackStore; + protected override bool BackgroundStillValid(Texture b) => false; // bypass lazy logic. we want to return a new background each time for refcounting purposes. protected override Texture GetBackground() @@ -68,8 +69,7 @@ namespace osu.Game.Beatmaps { try { - var trackData = store.GetStream(getPathForFile(Metadata.AudioFile)); - return trackData == null ? null : new TrackBass(trackData); + return (trackStore ?? (trackStore = AudioManager.GetTrackStore(store))).Get(getPathForFile(Metadata.AudioFile)); } catch { @@ -77,6 +77,14 @@ namespace osu.Game.Beatmaps } } + public override void RecycleTrack() + { + base.RecycleTrack(); + + trackStore?.Dispose(); + trackStore = null; + } + public override void TransferTo(WorkingBeatmap other) { base.TransferTo(other); @@ -135,7 +143,7 @@ namespace osu.Game.Beatmaps try { - skin = new LegacyBeatmapSkin(BeatmapInfo, store, audioManager); + skin = new LegacyBeatmapSkin(BeatmapInfo, store, AudioManager); } catch (Exception e) { diff --git a/osu.Game/Beatmaps/BindableBeatmap.cs b/osu.Game/Beatmaps/BindableBeatmap.cs index dcce18b1be..6614a6f2fb 100644 --- a/osu.Game/Beatmaps/BindableBeatmap.cs +++ b/osu.Game/Beatmaps/BindableBeatmap.cs @@ -1,11 +1,9 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using System.Diagnostics; using JetBrains.Annotations; using osu.Framework.Audio; -using osu.Framework.Audio.Track; using osu.Framework.Bindables; namespace osu.Game.Beatmaps @@ -16,32 +14,26 @@ namespace osu.Game.Beatmaps /// public abstract class BindableBeatmap : NonNullableBindable { - private AudioManager audioManager; + protected AudioManager AudioManager; + private WorkingBeatmap lastBeatmap; - protected BindableBeatmap(WorkingBeatmap defaultValue) + protected BindableBeatmap(WorkingBeatmap defaultValue, AudioManager audioManager) : base(defaultValue) { + // we don't want to attempt to update tracks if we are a bound copy. + if (audioManager != null) + { + AudioManager = audioManager; + ValueChanged += b => updateAudioTrack(b.NewValue); + + // If the track has changed prior to this being called, let's register it + if (Value != Default) + updateAudioTrack(Value); + } } - /// - /// Registers an for s to be added to. - /// - /// The to register. - protected void RegisterAudioManager([NotNull] AudioManager audioManager) - { - if (this.audioManager != null) throw new InvalidOperationException($"Cannot register multiple {nameof(AudioManager)}s."); - - this.audioManager = audioManager; - - ValueChanged += b => registerAudioTrack(b.NewValue); - - // If the track has changed prior to this being called, let's register it - if (Value != Default) - registerAudioTrack(Value); - } - - private void registerAudioTrack(WorkingBeatmap beatmap) + private void updateAudioTrack(WorkingBeatmap beatmap) { var trackLoaded = lastBeatmap?.TrackLoaded ?? false; @@ -55,8 +47,6 @@ namespace osu.Game.Beatmaps lastBeatmap.RecycleTrack(); } - - audioManager.Tracks.AddItem(beatmap.Track); } lastBeatmap = beatmap; diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 4b0720d867..288bd0773c 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -11,6 +11,7 @@ using osu.Framework.IO.File; using System.IO; using System.Linq; using System.Threading; +using osu.Framework.Audio; using osu.Game.IO.Serialization; using osu.Game.Rulesets; using osu.Game.Rulesets.Objects; @@ -150,6 +151,9 @@ namespace osu.Game.Beatmaps public bool SkinLoaded => skin.IsResultAvailable; public Skin Skin => skin.Value; + + public AudioManager AudioManager { get; set; } + protected virtual Skin GetSkin() => new DefaultSkin(); private readonly RecyclableLazy skin; @@ -175,7 +179,7 @@ namespace osu.Game.Beatmaps /// Eagerly dispose of the audio track associated with this (if any). /// Accessing track again will load a fresh instance. /// - public void RecycleTrack() => track.Recycle(); + public virtual void RecycleTrack() => track.Recycle(); public class RecyclableLazy { diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 40cb26ec54..8e663de8c5 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -281,20 +281,19 @@ namespace osu.Game private class OsuBindableBeatmap : BindableBeatmap { - public OsuBindableBeatmap(WorkingBeatmap defaultValue, AudioManager audioManager) - : this(defaultValue) + public OsuBindableBeatmap(WorkingBeatmap defaultValue) + : base(defaultValue, null) { - RegisterAudioManager(audioManager); } - public OsuBindableBeatmap(WorkingBeatmap defaultValue) - : base(defaultValue) + public OsuBindableBeatmap(WorkingBeatmap defaultValue, AudioManager audioManager) + : base(defaultValue, audioManager) { } public override BindableBeatmap GetBoundCopy() { - var copy = new OsuBindableBeatmap(Default); + var copy = new OsuBindableBeatmap(Default, AudioManager); copy.BindTo(this); return copy; } diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index ea3e1ca00c..d7b915efe3 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -350,7 +350,7 @@ namespace osu.Game.Overlays direction = last > next ? TransformDirection.Prev : TransformDirection.Next; } - current.Track.Completed -= currentTrackCompleted; + //current.Track.Completed -= currentTrackCompleted; } current = beatmap.NewValue; diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index b266a73eb5..6d5be607f4 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -580,9 +580,6 @@ namespace osu.Game.Screens.Select if (!track.IsRunning || restart) { - // Ensure the track is added to the TrackManager, since it is removed after the player finishes the map. - // Using AddItemToList rather than AddItem so that it doesn't attempt to register adjustment dependencies more than once. - Game.Audio.Tracks.AddItem(track); track.RestartPoint = Beatmap.Value.Metadata.PreviewTime; track.Restart(); } diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 9f31783a6b..8d38f944d0 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -21,7 +21,7 @@ namespace osu.Game.Skinning { protected TextureStore Textures; - protected SampleStore Samples; + protected IResourceStore Samples; public LegacySkin(SkinInfo skin, IResourceStore storage, AudioManager audioManager) : this(skin, new LegacySkinResourceStore(skin, storage), audioManager, "skin.ini") @@ -42,6 +42,13 @@ namespace osu.Game.Skinning Textures = new TextureStore(new TextureLoaderStore(storage)); } + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + Textures?.Dispose(); + Samples?.Dispose(); + } + public override Drawable GetDrawableComponent(string componentName) { switch (componentName) diff --git a/osu.Game/Tests/Visual/OsuTestScene.cs b/osu.Game/Tests/Visual/OsuTestScene.cs index 9b775fd498..806b73b517 100644 --- a/osu.Game/Tests/Visual/OsuTestScene.cs +++ b/osu.Game/Tests/Visual/OsuTestScene.cs @@ -19,7 +19,7 @@ namespace osu.Game.Tests.Visual { [Cached(typeof(Bindable))] [Cached(typeof(IBindable))] - private readonly OsuTestBeatmap beatmap = new OsuTestBeatmap(new DummyWorkingBeatmap()); + private readonly OsuTestBeatmap beatmap = new OsuTestBeatmap(new DummyWorkingBeatmap(), null); protected BindableBeatmap Beatmap => beatmap; @@ -52,8 +52,6 @@ namespace osu.Game.Tests.Visual [BackgroundDependencyLoader] private void load(AudioManager audioManager, RulesetStore rulesets) { - beatmap.SetAudioManager(audioManager); - Ruleset.Value = rulesets.AvailableRulesets.First(); } @@ -95,16 +93,14 @@ namespace osu.Game.Tests.Visual private class OsuTestBeatmap : BindableBeatmap { - public OsuTestBeatmap(WorkingBeatmap defaultValue) - : base(defaultValue) + public OsuTestBeatmap(WorkingBeatmap defaultValue, AudioManager audioManager) + : base(defaultValue, audioManager) { } - public void SetAudioManager(AudioManager audioManager) => RegisterAudioManager(audioManager); - public override BindableBeatmap GetBoundCopy() { - var copy = new OsuTestBeatmap(Default); + var copy = new OsuTestBeatmap(Default, AudioManager); copy.BindTo(this); return copy; } From 19fbab68928128641a15681a84f1611d58cf2870 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 28 May 2019 19:39:31 +0300 Subject: [PATCH 207/375] Applied suggested changes --- .../Sections/Beatmaps/PaginatedBeatmapContainer.cs | 2 -- .../Historical/PaginatedMostPlayedBeatmapContainer.cs | 2 -- .../Overlays/Profile/Sections/PaginatedContainer.cs | 10 ++++++---- .../Profile/Sections/Ranks/PaginatedScoreContainer.cs | 2 -- .../Recent/PaginatedRecentActivityContainer.cs | 2 -- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs index db291d0731..b6b0e605d7 100644 --- a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs @@ -29,8 +29,6 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps protected override void ShowMore() { - base.ShowMore(); - request = new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++ * ItemsPerPage); request.Success += sets => Schedule(() => { diff --git a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs index 0f86e0900e..6085b0bc05 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs @@ -24,8 +24,6 @@ namespace osu.Game.Overlays.Profile.Sections.Historical protected override void ShowMore() { - base.ShowMore(); - request = new GetUserMostPlayedBeatmapsRequest(User.Value.Id, VisiblePages++ * ItemsPerPage); request.Success += beatmaps => Schedule(() => { diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs index 7e13a90f25..99229a9bce 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs @@ -20,7 +20,7 @@ using osu.Game.Users; namespace osu.Game.Overlays.Profile.Sections { - public class PaginatedContainer : FillFlowContainer + public abstract class PaginatedContainer : FillFlowContainer { protected readonly FillFlowContainer ItemsContainer; protected readonly ShowMoreButton MoreButton; @@ -92,7 +92,7 @@ namespace osu.Game.Overlays.Profile.Sections ShowMore(); } - protected virtual void ShowMore() => MoreButton.IsLoading = true; + protected abstract void ShowMore(); protected class ShowMoreButton : CircularContainer { @@ -109,8 +109,11 @@ namespace osu.Game.Overlays.Profile.Sections public bool IsLoading { + get => isLoading; set { + if (isLoading == value) + return; isLoading = value; if (value) @@ -124,7 +127,6 @@ namespace osu.Game.Overlays.Profile.Sections content.FadeIn(duration, Easing.OutQuint); } } - get => isLoading; } public ShowMoreButton() @@ -141,7 +143,6 @@ namespace osu.Game.Overlays.Profile.Sections }, content = new FillFlowContainer { - Alpha = 0, Anchor = Anchor.Centre, Origin = Anchor.Centre, AutoSizeAxes = Axes.Both, @@ -190,6 +191,7 @@ namespace osu.Game.Overlays.Profile.Sections protected override bool OnClick(ClickEvent e) { + IsLoading = true; Action.Invoke(); return base.OnClick(e); } diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs index 1d9e3d1cc1..a149cfa12e 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs @@ -31,8 +31,6 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks protected override void ShowMore() { - base.ShowMore(); - request = new GetUserScoresRequest(User.Value.Id, type, VisiblePages++ * ItemsPerPage); request.Success += scores => Schedule(() => { diff --git a/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs b/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs index 38134ad660..b72aec7a44 100644 --- a/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs @@ -22,8 +22,6 @@ namespace osu.Game.Overlays.Profile.Sections.Recent protected override void ShowMore() { - base.ShowMore(); - request = new GetUserRecentActivitiesRequest(User.Value.Id, VisiblePages++ * ItemsPerPage); request.Success += activities => Schedule(() => { From 5169e31d54ea77eeabfc4fe14333fdb91d53147e Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 28 May 2019 19:53:00 +0300 Subject: [PATCH 208/375] Fix CI issues --- osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs index 99229a9bce..6e0729c7c5 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs @@ -35,7 +35,7 @@ namespace osu.Game.Overlays.Profile.Sections protected APIRequest RetrievalRequest; protected RulesetStore Rulesets; - public PaginatedContainer(Bindable user, string header, string missing) + protected PaginatedContainer(Bindable user, string header, string missing) { User.BindTo(user); @@ -114,6 +114,7 @@ namespace osu.Game.Overlays.Profile.Sections { if (isLoading == value) return; + isLoading = value; if (value) From 4f091417189baf51bf504cf401a914fe8d568234 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 29 May 2019 12:22:34 +0900 Subject: [PATCH 209/375] remove extra bool --- osu.Game/Screens/Select/BeatmapCarousel.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 0b3d0c448b..6e3bec106f 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -152,15 +152,15 @@ namespace osu.Game.Screens.Select { Schedule(() => { + int? previouslySelectedID = null; CarouselBeatmapSet existingSet = beatmapSets.FirstOrDefault(b => b.BeatmapSet.ID == beatmapSet.ID); - bool hadSelection = existingSet?.State?.Value == CarouselItemState.Selected; + // Since we're about to remove the selected beatmap, store its ID so we can go back if needed. + if (existingSet?.State?.Value == CarouselItemState.Selected) + previouslySelectedID = selectedBeatmap?.Beatmap.ID; var newSet = createCarouselSet(beatmapSet); - // Since we're about to remove the selected beatmap, store its ID so we can go back if needed. - var previouslySelectedID = selectedBeatmap?.Beatmap.ID; - if (existingSet != null) root.RemoveChild(existingSet); @@ -175,7 +175,7 @@ namespace osu.Game.Screens.Select applyActiveCriteria(false, false); //check if we can/need to maintain our current selection. - if (hadSelection) + if (previouslySelectedID != null) select((CarouselItem)newSet.Beatmaps.FirstOrDefault(b => b.Beatmap.ID == previouslySelectedID) ?? newSet); itemsCache.Invalidate(); From 08ab1e5df7ee4fc1bd48231bbcb2f0a35f9e680a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 29 May 2019 16:43:15 +0900 Subject: [PATCH 210/375] Use new ITrackStore interface --- .../Visual/Components/TestScenePreviewTrackManager.cs | 5 +++-- osu.Game/Audio/PreviewTrackManager.cs | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.cs b/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.cs index 0784725ea4..c966eb53d7 100644 --- a/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.cs +++ b/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.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 NUnit.Framework; @@ -112,11 +112,12 @@ namespace osu.Game.Tests.Visual.Components private class TestPreviewTrackManager : PreviewTrackManager { - protected override TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, IResourceStore trackStore) => new TestPreviewTrack(beatmapSetInfo, trackStore); + protected override TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackStore) => new TestPreviewTrack(beatmapSetInfo, trackStore); protected class TestPreviewTrack : TrackManagerPreviewTrack { public TestPreviewTrack(BeatmapSetInfo beatmapSetInfo, IResourceStore trackManager) + public TestPreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackManager) : base(beatmapSetInfo, trackManager) { } diff --git a/osu.Game/Audio/PreviewTrackManager.cs b/osu.Game/Audio/PreviewTrackManager.cs index 4b7277c3fd..d479483508 100644 --- a/osu.Game/Audio/PreviewTrackManager.cs +++ b/osu.Game/Audio/PreviewTrackManager.cs @@ -20,7 +20,7 @@ namespace osu.Game.Audio private readonly BindableDouble muteBindable = new BindableDouble(); private AudioManager audio; - private IAdjustableResourceStore trackStore; + private ITrackStore trackStore; private TrackManagerPreviewTrack current; @@ -80,16 +80,16 @@ namespace osu.Game.Audio /// /// Creates the . /// - protected virtual TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, IResourceStore trackStore) => new TrackManagerPreviewTrack(beatmapSetInfo, trackStore); + protected virtual TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackStore) => new TrackManagerPreviewTrack(beatmapSetInfo, trackStore); protected class TrackManagerPreviewTrack : PreviewTrack { public IPreviewTrackOwner Owner { get; private set; } private readonly BeatmapSetInfo beatmapSetInfo; - private readonly IResourceStore trackManager; + private readonly ITrackStore trackManager; - public TrackManagerPreviewTrack(BeatmapSetInfo beatmapSetInfo, IResourceStore trackManager) + public TrackManagerPreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackManager) { this.beatmapSetInfo = beatmapSetInfo; this.trackManager = trackManager; From a1cc8c448fb197bc40c6598b023a2c1693cc4923 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 29 May 2019 16:43:27 +0900 Subject: [PATCH 211/375] Update TrackVirtual consumption --- .../TestScenePreviewTrackManager.cs | 9 ++-- osu.Game/Beatmaps/DummyWorkingBeatmap.cs | 2 +- osu.Game/Beatmaps/WorkingBeatmap.cs | 31 +++++++++++++- .../WorkingBeatmap_VirtualBeatmapTrack.cs | 41 ------------------- 4 files changed, 35 insertions(+), 48 deletions(-) delete mode 100644 osu.Game/Beatmaps/WorkingBeatmap_VirtualBeatmapTrack.cs diff --git a/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.cs b/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.cs index c966eb53d7..df6740421b 100644 --- a/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.cs +++ b/osu.Game.Tests/Visual/Components/TestScenePreviewTrackManager.cs @@ -1,11 +1,10 @@ -// 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 NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Audio.Track; using osu.Framework.Graphics.Containers; -using osu.Framework.IO.Stores; using osu.Game.Audio; using osu.Game.Beatmaps; @@ -116,13 +115,15 @@ namespace osu.Game.Tests.Visual.Components protected class TestPreviewTrack : TrackManagerPreviewTrack { - public TestPreviewTrack(BeatmapSetInfo beatmapSetInfo, IResourceStore trackManager) + private readonly ITrackStore trackManager; + public TestPreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackManager) : base(beatmapSetInfo, trackManager) { + this.trackManager = trackManager; } - protected override Track GetTrack() => new TrackVirtual { Length = 100000 }; + protected override Track GetTrack() => trackManager.GetVirtual(100000); } } } diff --git a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs index 7d25ca3ede..b35e98085a 100644 --- a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs +++ b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs @@ -43,7 +43,7 @@ namespace osu.Game.Beatmaps protected override Texture GetBackground() => game?.Textures.Get(@"Backgrounds/bg4"); - protected override Track GetTrack() => new TrackVirtual { Length = 1000 }; + protected override Track GetTrack() => game?.Audio.Tracks.GetVirtual(1000); private class DummyRulesetInfo : RulesetInfo { diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 288bd0773c..6c8f283923 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -15,12 +15,13 @@ using osu.Framework.Audio; using osu.Game.IO.Serialization; using osu.Game.Rulesets; using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.UI; using osu.Game.Skinning; namespace osu.Game.Beatmaps { - public abstract partial class WorkingBeatmap : IDisposable + public abstract class WorkingBeatmap : IDisposable { public readonly BeatmapInfo BeatmapInfo; @@ -47,13 +48,39 @@ namespace osu.Game.Beatmaps return b; }); - track = new RecyclableLazy(() => GetTrack() ?? new VirtualBeatmapTrack(Beatmap)); + track = new RecyclableLazy(() => GetTrack() ?? GetVirtualTrack(Beatmap)); background = new RecyclableLazy(GetBackground, BackgroundStillValid); waveform = new RecyclableLazy(GetWaveform); storyboard = new RecyclableLazy(GetStoryboard); skin = new RecyclableLazy(GetSkin); } + protected virtual Track GetVirtualTrack(IBeatmap beatmap) + { + const double excess_length = 1000; + + var lastObject = beatmap.HitObjects.LastOrDefault(); + + double length; + + switch (lastObject) + { + case null: + length = excess_length; + break; + + case IHasEndTime endTime: + length = endTime.EndTime + excess_length; + break; + + default: + length = lastObject.StartTime + excess_length; + break; + } + + return AudioManager.Tracks.GetVirtual(length); + } + /// /// Saves the . /// diff --git a/osu.Game/Beatmaps/WorkingBeatmap_VirtualBeatmapTrack.cs b/osu.Game/Beatmaps/WorkingBeatmap_VirtualBeatmapTrack.cs deleted file mode 100644 index 1e237a2b53..0000000000 --- a/osu.Game/Beatmaps/WorkingBeatmap_VirtualBeatmapTrack.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System.Linq; -using osu.Framework.Audio.Track; -using osu.Game.Rulesets.Objects; -using osu.Game.Rulesets.Objects.Types; - -namespace osu.Game.Beatmaps -{ - public partial class WorkingBeatmap - { - /// - /// A type of which provides a valid length based on the s of an . - /// - protected class VirtualBeatmapTrack : TrackVirtual - { - private const double excess_length = 1000; - - public VirtualBeatmapTrack(IBeatmap beatmap) - { - var lastObject = beatmap.HitObjects.LastOrDefault(); - - switch (lastObject) - { - case null: - Length = excess_length; - break; - - case IHasEndTime endTime: - Length = endTime.EndTime + excess_length; - break; - - default: - Length = lastObject.StartTime + excess_length; - break; - } - } - } - } -} From 7e9f5a0939d41a262a9d19da778b54e140032346 Mon Sep 17 00:00:00 2001 From: HoLLy Date: Wed, 29 May 2019 11:22:51 +0200 Subject: [PATCH 212/375] Add Skills to DifficultyAttributes --- .../Difficulty/CatchDifficultyCalculator.cs | 5 +++-- .../Difficulty/ManiaDifficultyCalculator.cs | 3 ++- osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyCalculator.cs | 5 +++-- .../Difficulty/TaikoDifficultyCalculator.cs | 3 ++- osu.Game/Rulesets/Difficulty/DifficultyAttributes.cs | 5 ++++- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index d6a1ed632b..44e1a8e5cc 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate) { if (beatmap.HitObjects.Count == 0) - return new CatchDifficultyAttributes { Mods = mods }; + return new CatchDifficultyAttributes { Mods = mods, Skills = skills }; // this is the same as osu!, so there's potential to share the implementation... maybe double preempt = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450) / clockRate; @@ -41,7 +41,8 @@ namespace osu.Game.Rulesets.Catch.Difficulty StarRating = Math.Sqrt(skills[0].DifficultyValue()) * star_scaling_factor, Mods = mods, ApproachRate = preempt > 1200.0 ? -(preempt - 1800.0) / 120.0 : -(preempt - 1200.0) / 150.0 + 5.0, - MaxCombo = beatmap.HitObjects.Count(h => h is Fruit) + beatmap.HitObjects.OfType().SelectMany(j => j.NestedHitObjects).Count(h => !(h is TinyDroplet)) + MaxCombo = beatmap.HitObjects.Count(h => h is Fruit) + beatmap.HitObjects.OfType().SelectMany(j => j.NestedHitObjects).Count(h => !(h is TinyDroplet)), + Skills = skills }; } diff --git a/osu.Game.Rulesets.Mania/Difficulty/ManiaDifficultyCalculator.cs b/osu.Game.Rulesets.Mania/Difficulty/ManiaDifficultyCalculator.cs index 59fed1031f..4a9c22d339 100644 --- a/osu.Game.Rulesets.Mania/Difficulty/ManiaDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Mania/Difficulty/ManiaDifficultyCalculator.cs @@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Mania.Difficulty protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate) { if (beatmap.HitObjects.Count == 0) - return new ManiaDifficultyAttributes { Mods = mods }; + return new ManiaDifficultyAttributes { Mods = mods, Skills = skills }; return new ManiaDifficultyAttributes { @@ -38,6 +38,7 @@ namespace osu.Game.Rulesets.Mania.Difficulty Mods = mods, // Todo: This int cast is temporary to achieve 1:1 results with osu!stable, and should be removed in the future GreatHitWindow = (int)(beatmap.HitObjects.First().HitWindows.Great / 2) / clockRate, + Skills = skills }; } diff --git a/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyCalculator.cs b/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyCalculator.cs index e2a1542574..c197933233 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyCalculator.cs @@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate) { if (beatmap.HitObjects.Count == 0) - return new OsuDifficultyAttributes { Mods = mods }; + return new OsuDifficultyAttributes { Mods = mods, Skills = skills }; double aimRating = Math.Sqrt(skills[0].DifficultyValue()) * difficulty_multiplier; double speedRating = Math.Sqrt(skills[1].DifficultyValue()) * difficulty_multiplier; @@ -50,7 +50,8 @@ namespace osu.Game.Rulesets.Osu.Difficulty SpeedStrain = speedRating, ApproachRate = preempt > 1200 ? (1800 - preempt) / 120 : (1200 - preempt) / 150 + 5, OverallDifficulty = (80 - hitWindowGreat) / 6, - MaxCombo = maxCombo + MaxCombo = maxCombo, + Skills = skills }; } diff --git a/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs b/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs index 685ad9949b..c8f3e18911 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs @@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate) { if (beatmap.HitObjects.Count == 0) - return new TaikoDifficultyAttributes { Mods = mods }; + return new TaikoDifficultyAttributes { Mods = mods, Skills = skills }; return new TaikoDifficultyAttributes { @@ -36,6 +36,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty // Todo: This int cast is temporary to achieve 1:1 results with osu!stable, and should be removed in the future GreatHitWindow = (int)(beatmap.HitObjects.First().HitWindows.Great / 2) / clockRate, MaxCombo = beatmap.HitObjects.Count(h => h is Hit), + Skills = skills }; } diff --git a/osu.Game/Rulesets/Difficulty/DifficultyAttributes.cs b/osu.Game/Rulesets/Difficulty/DifficultyAttributes.cs index d808ee528e..b4b4bb9cd1 100644 --- a/osu.Game/Rulesets/Difficulty/DifficultyAttributes.cs +++ b/osu.Game/Rulesets/Difficulty/DifficultyAttributes.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 osu.Game.Rulesets.Difficulty.Skills; using osu.Game.Rulesets.Mods; namespace osu.Game.Rulesets.Difficulty @@ -8,6 +9,7 @@ namespace osu.Game.Rulesets.Difficulty public class DifficultyAttributes { public Mod[] Mods; + public Skill[] Skills; public double StarRating; @@ -15,9 +17,10 @@ namespace osu.Game.Rulesets.Difficulty { } - public DifficultyAttributes(Mod[] mods, double starRating) + public DifficultyAttributes(Mod[] mods, Skill[] skills, double starRating) { Mods = mods; + Skills = skills; StarRating = starRating; } } From 2a295545a79b89c18447e0aee599eb5a6c27a04e Mon Sep 17 00:00:00 2001 From: HoLLy Date: Wed, 29 May 2019 11:25:25 +0200 Subject: [PATCH 213/375] Don't mutate strainPeaks --- osu.Game/Rulesets/Difficulty/Skills/Skill.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Rulesets/Difficulty/Skills/Skill.cs b/osu.Game/Rulesets/Difficulty/Skills/Skill.cs index e8020ed185..227f2f4018 100644 --- a/osu.Game/Rulesets/Difficulty/Skills/Skill.cs +++ b/osu.Game/Rulesets/Difficulty/Skills/Skill.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Linq; using osu.Game.Rulesets.Difficulty.Preprocessing; using osu.Game.Rulesets.Difficulty.Utils; @@ -17,7 +18,7 @@ namespace osu.Game.Rulesets.Difficulty.Skills /// /// The peak strain for each section of the beatmap. /// - public IList StrainPeaks => strainPeaks; + public IReadOnlyList StrainPeaks => strainPeaks; /// /// Strain values are multiplied by this number for the given skill. Used to balance the value of different skills between each other. @@ -84,13 +85,12 @@ namespace osu.Game.Rulesets.Difficulty.Skills /// public double DifficultyValue() { - strainPeaks.Sort((a, b) => b.CompareTo(a)); // Sort from highest to lowest strain. - double difficulty = 0; double weight = 1; // Difficulty is the weighted sum of the highest strains from every section. - foreach (double strain in strainPeaks) + // We're sorting from highest to lowest strain. + foreach (double strain in strainPeaks.OrderByDescending(d => d)) { difficulty += strain * weight; weight *= DecayWeight; From 97dbc95bc64d7a10506bdcc00f271f218ddf3853 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 29 May 2019 21:02:20 +0300 Subject: [PATCH 214/375] Kudosu section update --- .../Profile/Sections/Kudosu/KudosuInfo.cs | 75 ++++++++----------- 1 file changed, 31 insertions(+), 44 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs b/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs index aeea5118a7..87a241936a 100644 --- a/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs +++ b/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs @@ -3,53 +3,38 @@ using osu.Framework.Bindables; using osuTK; -using osuTK.Graphics; -using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Users; +using osu.Framework.Allocation; namespace osu.Game.Overlays.Profile.Sections.Kudosu { public class KudosuInfo : Container { private readonly Bindable user = new Bindable(); - public KudosuInfo(Bindable user) { this.user.BindTo(user); - CountSection total; CountSection avaliable; - RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; Masking = true; CornerRadius = 3; - EdgeEffect = new EdgeEffectParameters - { - Type = EdgeEffectType.Shadow, - Offset = new Vector2(0f, 1f), - Radius = 3f, - Colour = Color4.Black.Opacity(0.2f), - }; Children = new Drawable[] { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.Gray(0.2f) - }, new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(5, 0), Children = new[] { total = new CountSection( @@ -63,31 +48,29 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu } } }; - this.user.ValueChanged += u => { total.Count = u.NewValue?.Kudosu.Total ?? 0; avaliable.Count = u.NewValue?.Kudosu.Available ?? 0; }; } - protected override bool OnClick(ClickEvent e) => true; - private class CountSection : Container { private readonly OsuSpriteText valueText; + private readonly OsuTextFlowContainer descriptionText; + private readonly Box lineBackground; public new int Count { set => valueText.Text = value.ToString(); } - public CountSection(string header, string description) { RelativeSizeAxes = Axes.X; Width = 0.5f; AutoSizeAxes = Axes.Y; - Padding = new MarginPadding { Horizontal = 10, Top = 10, Bottom = 20 }; + Padding = new MarginPadding { Top = 10, Bottom = 20 }; Child = new FillFlowContainer { AutoSizeAxes = Axes.Y, @@ -96,31 +79,28 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu Spacing = new Vector2(0, 5), Children = new Drawable[] { - new FillFlowContainer + new CircularContainer { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(5, 0), - Children = new Drawable[] + Masking = true, + RelativeSizeAxes = Axes.X, + Height = 5, + Child = lineBackground = new Box { - new OsuSpriteText - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Text = header + ":", - Font = OsuFont.GetFont(size: 20, weight: FontWeight.Regular, italics: true) - }, - valueText = new OsuSpriteText - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Text = "0", - Font = OsuFont.GetFont(size: 40, weight: FontWeight.Regular, italics: true), - UseFullGlyphHeight = false, - } + RelativeSizeAxes = Axes.Both, } }, - new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 19)) + new OsuSpriteText + { + Text = header, + Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold) + }, + valueText = new OsuSpriteText + { + Text = "0", + Font = OsuFont.GetFont(size: 50, weight: FontWeight.Light), + UseFullGlyphHeight = false, + }, + descriptionText = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 17)) { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, @@ -129,6 +109,13 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu } }; } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + lineBackground.Colour = colours.Yellow; + descriptionText.Colour = colours.GreySeafoamLighter; + } } } } From 9a13c52ffd860e2c05289ec5fe0a2e27bf06a717 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 29 May 2019 21:19:03 +0300 Subject: [PATCH 215/375] Add missing lines --- osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs b/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs index 87a241936a..c8b803eb98 100644 --- a/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs +++ b/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs @@ -18,6 +18,7 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu public class KudosuInfo : Container { private readonly Bindable user = new Bindable(); + public KudosuInfo(Bindable user) { this.user.BindTo(user); @@ -54,7 +55,9 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu avaliable.Count = u.NewValue?.Kudosu.Available ?? 0; }; } + protected override bool OnClick(ClickEvent e) => true; + private class CountSection : Container { private readonly OsuSpriteText valueText; @@ -65,6 +68,7 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu { set => valueText.Text = value.ToString(); } + public CountSection(string header, string description) { RelativeSizeAxes = Axes.X; From e5999dd9b1daa448638ca88c5090c0b0d10b42bb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 30 May 2019 16:49:18 +0900 Subject: [PATCH 216/375] Update font sizes to match web --- osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs b/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs index c8b803eb98..a07ecc3bf3 100644 --- a/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs +++ b/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs @@ -96,15 +96,15 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu new OsuSpriteText { Text = header, - Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold) + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold) }, valueText = new OsuSpriteText { Text = "0", - Font = OsuFont.GetFont(size: 50, weight: FontWeight.Light), + Font = OsuFont.GetFont(size: 40, weight: FontWeight.Light), UseFullGlyphHeight = false, }, - descriptionText = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 17)) + descriptionText = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 14)) { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, From c950f37497da2b3bee4f65fbbb32f845ac445c32 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 30 May 2019 16:57:54 +0900 Subject: [PATCH 217/375] Ad missing link --- .../Profile/Sections/Kudosu/KudosuInfo.cs | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs b/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs index a07ecc3bf3..aabfa56ee6 100644 --- a/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs +++ b/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs @@ -38,14 +38,8 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu Spacing = new Vector2(5, 0), Children = new[] { - total = new CountSection( - "Total Kudosu Earned", - "Based on how much of a contribution the user has made to beatmap moderation. See this link for more information." - ), - avaliable = new CountSection( - "Kudosu Avaliable", - "Kudosu can be traded for kudosu stars, which will help your beatmap get more attention. This is the number of kudosu you haven't traded in yet." - ), + total = new CountTotal(), + avaliable = new CountAvailable() } } }; @@ -58,10 +52,30 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu protected override bool OnClick(ClickEvent e) => true; + private class CountAvailable : CountSection + { + public CountAvailable() + : base("Kudosu Avaliable") + { + DescriptionText.Text = "Kudosu can be traded for kudosu stars, which will help your beatmap get more attention. This is the number of kudosu you haven't traded in yet."; + } + } + + private class CountTotal : CountSection + { + public CountTotal() + : base("Total Kudosu Earned") + { + DescriptionText.AddText("Based on how much of a contribution the user has made to beatmap moderation. See "); + DescriptionText.AddLink("this link", "https://osu.ppy.sh/wiki/Kudosu"); + DescriptionText.AddText(" for more information."); + } + } + private class CountSection : Container { private readonly OsuSpriteText valueText; - private readonly OsuTextFlowContainer descriptionText; + protected readonly LinkFlowContainer DescriptionText; private readonly Box lineBackground; public new int Count @@ -69,7 +83,7 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu set => valueText.Text = value.ToString(); } - public CountSection(string header, string description) + public CountSection(string header) { RelativeSizeAxes = Axes.X; Width = 0.5f; @@ -104,11 +118,10 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu Font = OsuFont.GetFont(size: 40, weight: FontWeight.Light), UseFullGlyphHeight = false, }, - descriptionText = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 14)) + DescriptionText = new LinkFlowContainer(t => t.Font = t.Font.With(size: 14)) { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Text = description } } }; @@ -118,7 +131,7 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu private void load(OsuColour colours) { lineBackground.Colour = colours.Yellow; - descriptionText.Colour = colours.GreySeafoamLighter; + DescriptionText.Colour = colours.GreySeafoamLighter; } } } From 73fb28f9f7fbc082e2fd58b787d759c175f98b35 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 30 May 2019 22:48:27 +0300 Subject: [PATCH 218/375] Make the button inherit from OsuHoverContainer --- .../Profile/Sections/PaginatedContainer.cs | 93 +++++++++---------- 1 file changed, 42 insertions(+), 51 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs index 6e0729c7c5..504f80fc97 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs @@ -12,11 +12,11 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Game.Rulesets; using osu.Framework.Input.Events; -using System; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; -using osuTK.Graphics; using osu.Game.Users; +using osu.Game.Graphics.Containers; +using System.Collections.Generic; namespace osu.Game.Overlays.Profile.Sections { @@ -94,17 +94,14 @@ namespace osu.Game.Overlays.Profile.Sections protected abstract void ShowMore(); - protected class ShowMoreButton : CircularContainer + protected class ShowMoreButton : OsuHoverContainer { - private const int duration = 300; - private Color4 idleColour; - private Color4 hoveredColour; - - public Action Action; private readonly Box background; private readonly LoadingAnimation loading; private readonly FillFlowContainer content; + protected override IEnumerable EffectTargets => new[] { background }; + private bool isLoading; public bool IsLoading @@ -119,13 +116,13 @@ namespace osu.Game.Overlays.Profile.Sections if (value) { - loading.FadeIn(duration, Easing.OutQuint); - content.FadeOut(duration, Easing.OutQuint); + loading.FadeIn(FADE_DURATION, Easing.OutQuint); + content.FadeOut(FADE_DURATION, Easing.OutQuint); } else { - loading.FadeOut(duration, Easing.OutQuint); - content.FadeIn(duration, Easing.OutQuint); + loading.FadeOut(FADE_DURATION, Easing.OutQuint); + content.FadeIn(FADE_DURATION, Easing.OutQuint); } } } @@ -134,66 +131,60 @@ namespace osu.Game.Overlays.Profile.Sections { Anchor = Anchor.TopCentre; Origin = Anchor.TopCentre; - Masking = true; - Size = new Vector2(140, 30); + AutoSizeAxes = Axes.Both; Children = new Drawable[] { - background = new Box + new CircularContainer { - RelativeSizeAxes = Axes.Both, - }, - content = new FillFlowContainer - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(7), + Masking = true, + Size = new Vector2(140, 30), Children = new Drawable[] { - new ChevronIcon(), - new OsuSpriteText + background = new Box + { + RelativeSizeAxes = Axes.Both, + }, + content = new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold), - Text = "show more".ToUpper(), + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(7), + Children = new Drawable[] + { + new ChevronIcon(), + new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), + Text = "show more".ToUpper(), + }, + new ChevronIcon(), + } + }, + loading = new LoadingAnimation + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(12) }, - new ChevronIcon(), } - }, - loading = new LoadingAnimation - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(20) - }, + } }; } [BackgroundDependencyLoader] private void load(OsuColour colors) { - background.Colour = idleColour = colors.GreySeafoam; - hoveredColour = colors.GreySeafoamLight; - } - - protected override bool OnHover(HoverEvent e) - { - background.FadeColour(hoveredColour, duration, Easing.OutQuint); - return base.OnHover(e); - } - - protected override void OnHoverLost(HoverLostEvent e) - { - background.FadeColour(idleColour, duration, Easing.OutQuint); - base.OnHoverLost(e); + IdleColour = colors.GreySeafoam; + HoverColour = colors.GreySeafoamLight; } protected override bool OnClick(ClickEvent e) { IsLoading = true; - Action.Invoke(); return base.OnClick(e); } From 2933169614bee615d4f8e75205d3414620c00be9 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 30 May 2019 22:55:59 +0300 Subject: [PATCH 219/375] Move the button into a separate class --- .../Profile/Sections/PaginatedContainer.cs | 122 ---------------- .../Profile/Sections/ShowMoreButton.cs | 134 ++++++++++++++++++ 2 files changed, 134 insertions(+), 122 deletions(-) create mode 100644 osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs index 504f80fc97..11803b0dc1 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs @@ -8,15 +8,9 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Game.Rulesets; -using osu.Framework.Input.Events; -using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; using osu.Game.Users; -using osu.Game.Graphics.Containers; -using System.Collections.Generic; namespace osu.Game.Overlays.Profile.Sections { @@ -93,121 +87,5 @@ namespace osu.Game.Overlays.Profile.Sections } protected abstract void ShowMore(); - - protected class ShowMoreButton : OsuHoverContainer - { - private readonly Box background; - private readonly LoadingAnimation loading; - private readonly FillFlowContainer content; - - protected override IEnumerable EffectTargets => new[] { background }; - - private bool isLoading; - - public bool IsLoading - { - get => isLoading; - set - { - if (isLoading == value) - return; - - isLoading = value; - - if (value) - { - loading.FadeIn(FADE_DURATION, Easing.OutQuint); - content.FadeOut(FADE_DURATION, Easing.OutQuint); - } - else - { - loading.FadeOut(FADE_DURATION, Easing.OutQuint); - content.FadeIn(FADE_DURATION, Easing.OutQuint); - } - } - } - - public ShowMoreButton() - { - Anchor = Anchor.TopCentre; - Origin = Anchor.TopCentre; - AutoSizeAxes = Axes.Both; - Children = new Drawable[] - { - new CircularContainer - { - Masking = true, - Size = new Vector2(140, 30), - Children = new Drawable[] - { - background = new Box - { - RelativeSizeAxes = Axes.Both, - }, - content = new FillFlowContainer - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(7), - Children = new Drawable[] - { - new ChevronIcon(), - new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), - Text = "show more".ToUpper(), - }, - new ChevronIcon(), - } - }, - loading = new LoadingAnimation - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(12) - }, - } - } - }; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colors) - { - IdleColour = colors.GreySeafoam; - HoverColour = colors.GreySeafoamLight; - } - - protected override bool OnClick(ClickEvent e) - { - IsLoading = true; - return base.OnClick(e); - } - - private class ChevronIcon : SpriteIcon - { - private const int bottom_margin = 2; - private const int icon_size = 8; - - public ChevronIcon() - { - Anchor = Anchor.Centre; - Origin = Anchor.Centre; - Margin = new MarginPadding { Bottom = bottom_margin }; - Size = new Vector2(icon_size); - Icon = FontAwesome.Solid.ChevronDown; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colors) - { - Colour = colors.Yellow; - } - } - } } } diff --git a/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs b/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs new file mode 100644 index 0000000000..5979c971d1 --- /dev/null +++ b/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs @@ -0,0 +1,134 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input.Events; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; +using osuTK; +using System.Collections.Generic; + +namespace osu.Game.Overlays.Profile.Sections +{ + public class ShowMoreButton : OsuHoverContainer + { + private readonly Box background; + private readonly LoadingAnimation loading; + private readonly FillFlowContainer content; + + protected override IEnumerable EffectTargets => new[] { background }; + + private bool isLoading; + + public bool IsLoading + { + get => isLoading; + set + { + if (isLoading == value) + return; + + isLoading = value; + + if (value) + { + loading.FadeIn(FADE_DURATION, Easing.OutQuint); + content.FadeOut(FADE_DURATION, Easing.OutQuint); + } + else + { + loading.FadeOut(FADE_DURATION, Easing.OutQuint); + content.FadeIn(FADE_DURATION, Easing.OutQuint); + } + } + } + + public ShowMoreButton() + { + Anchor = Anchor.TopCentre; + Origin = Anchor.TopCentre; + AutoSizeAxes = Axes.Both; + Children = new Drawable[] + { + new CircularContainer + { + Masking = true, + Size = new Vector2(140, 30), + Children = new Drawable[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both, + }, + content = new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(7), + Children = new Drawable[] + { + new ChevronIcon(), + new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), + Text = "show more".ToUpper(), + }, + new ChevronIcon(), + } + }, + loading = new LoadingAnimation + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(12) + }, + } + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colors) + { + IdleColour = colors.GreySeafoam; + HoverColour = colors.GreySeafoamLight; + } + + protected override bool OnClick(ClickEvent e) + { + IsLoading = true; + return base.OnClick(e); + } + + private class ChevronIcon : SpriteIcon + { + private const int bottom_margin = 2; + private const int icon_size = 8; + + public ChevronIcon() + { + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + Margin = new MarginPadding { Bottom = bottom_margin }; + Size = new Vector2(icon_size); + Icon = FontAwesome.Solid.ChevronDown; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colors) + { + Colour = colors.Yellow; + } + } + } +} From fe9e53e383e5f2d35e382daffad3f5ba1b253a53 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 30 May 2019 23:07:04 +0300 Subject: [PATCH 220/375] Add a testcase --- .../Visual/Online/TestSceneShowMoreButton.cs | 31 +++++++++ .../Graphics/Containers/OsuHoverContainer.cs | 6 +- .../Profile/Sections/PaginatedContainer.cs | 2 + .../Profile/Sections/ShowMoreButton.cs | 68 +++++++++---------- 4 files changed, 70 insertions(+), 37 deletions(-) create mode 100644 osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs b/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs new file mode 100644 index 0000000000..8289e4a09c --- /dev/null +++ b/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs @@ -0,0 +1,31 @@ +// 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.Profile.Sections; +using System; +using System.Collections.Generic; +using osu.Framework.Graphics; + +namespace osu.Game.Tests.Visual.Online +{ + public class TestSceneShowMoreButton : OsuTestScene + { + private readonly ShowMoreButton button; + + public override IReadOnlyList RequiredTypes => new[] + { + typeof(ShowMoreButton), + }; + + public TestSceneShowMoreButton() + { + Add(button = new ShowMoreButton + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }); + + AddStep("switch loading state", () => button.IsLoading = !button.IsLoading); + } + } +} diff --git a/osu.Game/Graphics/Containers/OsuHoverContainer.cs b/osu.Game/Graphics/Containers/OsuHoverContainer.cs index c4f85926ee..eb2d926424 100644 --- a/osu.Game/Graphics/Containers/OsuHoverContainer.cs +++ b/osu.Game/Graphics/Containers/OsuHoverContainer.cs @@ -24,7 +24,8 @@ namespace osu.Game.Graphics.Containers { Enabled.ValueChanged += e => { - if (!e.NewValue) unhover(); + if (!e.NewValue) + unhover(); }; } @@ -49,7 +50,8 @@ namespace osu.Game.Graphics.Containers private void unhover() { - if (!isHovered) return; + if (!isHovered) + return; isHovered = false; EffectTargets.ForEach(d => d.FadeColour(IdleColour, FADE_DURATION, Easing.OutQuint)); diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs index 11803b0dc1..8639acfc94 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs @@ -54,6 +54,8 @@ namespace osu.Game.Overlays.Profile.Sections }, MoreButton = new ShowMoreButton { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, Alpha = 0, Margin = new MarginPadding { Top = 10 }, Action = ShowMore, diff --git a/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs b/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs index 5979c971d1..31c73aaa96 100644 --- a/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs +++ b/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs @@ -51,49 +51,47 @@ namespace osu.Game.Overlays.Profile.Sections public ShowMoreButton() { - Anchor = Anchor.TopCentre; - Origin = Anchor.TopCentre; AutoSizeAxes = Axes.Both; Children = new Drawable[] { - new CircularContainer + new CircularContainer + { + Masking = true, + Size = new Vector2(140, 30), + Children = new Drawable[] { - Masking = true, - Size = new Vector2(140, 30), - Children = new Drawable[] + background = new Box { - background = new Box + RelativeSizeAxes = Axes.Both, + }, + content = new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(7), + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - }, - content = new FillFlowContainer - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(7), - Children = new Drawable[] + new ChevronIcon(), + new OsuSpriteText { - new ChevronIcon(), - new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), - Text = "show more".ToUpper(), - }, - new ChevronIcon(), - } - }, - loading = new LoadingAnimation - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(12) - }, - } + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), + Text = "show more".ToUpper(), + }, + new ChevronIcon(), + } + }, + loading = new LoadingAnimation + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(12) + }, } + } }; } From cfa0ef6fd9c410cf0f2d7c32c9613daf5c179e62 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 30 May 2019 23:22:08 +0300 Subject: [PATCH 221/375] convert field to a local variable --- osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs b/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs index 8289e4a09c..0d6d378f4c 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs @@ -10,8 +10,6 @@ namespace osu.Game.Tests.Visual.Online { public class TestSceneShowMoreButton : OsuTestScene { - private readonly ShowMoreButton button; - public override IReadOnlyList RequiredTypes => new[] { typeof(ShowMoreButton), @@ -19,6 +17,8 @@ namespace osu.Game.Tests.Visual.Online public TestSceneShowMoreButton() { + ShowMoreButton button; + Add(button = new ShowMoreButton { Anchor = Anchor.Centre, From f780c80c17d406f7c6518066930072de27083727 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 31 May 2019 13:03:35 +0900 Subject: [PATCH 222/375] Fix bar not expanding/collapsing correctly --- osu.Game/Overlays/Changelog/UpdateStreamBadge.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs b/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs index c39e6a6784..4f1d95bc2c 100644 --- a/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs +++ b/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs @@ -84,7 +84,7 @@ namespace osu.Game.Overlays.Changelog } }; - SelectedTab.ValueChanged += _ => updateState(); + SelectedTab.BindValueChanged(_ => updateState(), true); } protected override void OnActivated() => updateState(); @@ -113,7 +113,13 @@ namespace osu.Game.Overlays.Changelog private void updateState() { - if (Active.Value || IsHovered || SelectedTab.Value == null) + // Expand based on the local state + bool shouldExpand = Active.Value || IsHovered; + + // Expand based on whether no build is selected and the badge area is hovered + shouldExpand |= SelectedTab.Value == null && !externalDimRequested; + + if (shouldExpand) { expandingBar.Expand(); fadeContainer.FadeTo(1, transition_duration); From 4dc77d64a32c37397e3adea7f7ea0a485af3154a Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 31 May 2019 13:23:50 +0900 Subject: [PATCH 223/375] Fix overlay group + depth --- osu.Game/OsuGame.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 2bbd0b8303..ba9abcdefc 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -435,9 +435,9 @@ namespace osu.Game loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal, true); loadComponentSingleFile(chatOverlay = new ChatOverlay(), overlayContent.Add, true); loadComponentSingleFile(settings = new SettingsOverlay { GetToolbarHeight = () => ToolbarOffset }, leftFloatingOverlayContent.Add, true); + var changelogOverlay = loadComponentSingleFile(new ChangelogOverlay(), overlayContent.Add, true); loadComponentSingleFile(userProfile = new UserProfileOverlay(), overlayContent.Add, true); loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true); - var changelogOverlay = loadComponentSingleFile(new ChangelogOverlay(), overlayContent.Add, true); loadComponentSingleFile(new LoginOverlay { @@ -479,7 +479,7 @@ namespace osu.Game } // eventually informational overlays should be displayed in a stack, but for now let's only allow one to stay open at a time. - var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile, changelogOverlay }; + var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile }; overlays.AddRange(informationalOverlays); foreach (var overlay in informationalOverlays) @@ -493,7 +493,7 @@ namespace osu.Game } // ensure only one of these overlays are open at once. - var singleDisplayOverlays = new OverlayContainer[] { chatOverlay, social, direct }; + var singleDisplayOverlays = new OverlayContainer[] { chatOverlay, social, direct, changelogOverlay }; overlays.AddRange(singleDisplayOverlays); foreach (var overlay in singleDisplayOverlays) From 57d648df6dcd0a44c63e46a19dceb264f233ad40 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 31 May 2019 13:38:48 +0900 Subject: [PATCH 224/375] Add comment + fix spinlocking --- osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs b/osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs index 81c7905e84..36ae5a756c 100644 --- a/osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs +++ b/osu.Game/Overlays/Changelog/ChangelogSingleBuild.cs @@ -43,6 +43,7 @@ namespace osu.Game.Overlays.Changelog }; req.Failure += _ => complete = true; + // This is done on a separate thread to support cancellation below Task.Run(() => req.Perform(api)); while (!complete) @@ -53,7 +54,7 @@ namespace osu.Game.Overlays.Changelog return; } - Task.Delay(1); + Thread.Sleep(10); } if (build != null) From e7ae9c249fdd7ef3fee5f0b5384986a5abd3f0de Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 31 May 2019 13:53:55 +0900 Subject: [PATCH 225/375] Fix size of release stream separator in listing --- osu.Game/Overlays/Changelog/ChangelogBuild.cs | 4 +++- osu.Game/Overlays/Changelog/ChangelogListing.cs | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogBuild.cs b/osu.Game/Overlays/Changelog/ChangelogBuild.cs index a76211a0ae..57615332da 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBuild.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBuild.cs @@ -18,6 +18,8 @@ namespace osu.Game.Overlays.Changelog { public class ChangelogBuild : FillFlowContainer { + public const float HORIZONTAL_PADDING = 70; + public Action SelectBuild; protected readonly APIChangelogBuild Build; @@ -31,7 +33,7 @@ namespace osu.Game.Overlays.Changelog RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; Direction = FillDirection.Vertical; - Padding = new MarginPadding { Horizontal = 70 }; + Padding = new MarginPadding { Horizontal = HORIZONTAL_PADDING }; Children = new Drawable[] { diff --git a/osu.Game/Overlays/Changelog/ChangelogListing.cs b/osu.Game/Overlays/Changelog/ChangelogListing.cs index 20b7a32eba..1856f93205 100644 --- a/osu.Game/Overlays/Changelog/ChangelogListing.cs +++ b/osu.Game/Overlays/Changelog/ChangelogListing.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; @@ -58,12 +59,17 @@ namespace osu.Game.Overlays.Changelog } else { - Add(new Box + Add(new Container { RelativeSizeAxes = Axes.X, Height = 1, - Colour = new Color4(32, 24, 35, 255), + Padding = new MarginPadding { Horizontal = ChangelogBuild.HORIZONTAL_PADDING }, Margin = new MarginPadding { Top = 30 }, + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = new Color4(32, 24, 35, 255), + } }); } From d7ccf939d8098483e4ab2ea5935e44c32286fdc3 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 31 May 2019 13:54:40 +0900 Subject: [PATCH 226/375] General refactoring --- osu.Game/Overlays/Changelog/ChangelogListing.cs | 6 +++--- osu.Game/Overlays/Changelog/UpdateStreamBadge.cs | 14 +++++++------- osu.Game/Overlays/ChangelogOverlay.cs | 11 ++++------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogListing.cs b/osu.Game/Overlays/Changelog/ChangelogListing.cs index 1856f93205..41d8228475 100644 --- a/osu.Game/Overlays/Changelog/ChangelogListing.cs +++ b/osu.Game/Overlays/Changelog/ChangelogListing.cs @@ -47,12 +47,12 @@ namespace osu.Game.Overlays.Changelog Add(new OsuSpriteText { - Text = build.CreatedAt.Date.ToString("dd MMM yyyy"), - Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 24), - Colour = OsuColour.FromHex(@"FD5"), Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Margin = new MarginPadding { Top = 15 }, + Text = build.CreatedAt.Date.ToString("dd MMM yyyy"), + Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 24), + Colour = OsuColour.FromHex(@"FD5"), }); currentDate = build.CreatedAt.Date; diff --git a/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs b/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs index 4f1d95bc2c..514e75c31a 100644 --- a/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs +++ b/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs @@ -87,6 +87,13 @@ namespace osu.Game.Overlays.Changelog SelectedTab.BindValueChanged(_ => updateState(), true); } + [BackgroundDependencyLoader] + private void load(AudioManager audio) + { + sampleClick = audio.Sample.Get(@"UI/generic-select-soft"); + sampleHover = audio.Sample.Get(@"UI/generic-hover-soft"); + } + protected override void OnActivated() => updateState(); protected override void OnDeactivated() => updateState(); @@ -146,12 +153,5 @@ namespace osu.Game.Overlays.Changelog externalDimRequested = false; updateState(); } - - [BackgroundDependencyLoader] - private void load(AudioManager audio) - { - sampleClick = audio.Sample.Get(@"UI/generic-select-soft"); - sampleHover = audio.Sample.Get(@"UI/generic-hover-soft"); - } } } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 552e213a45..7d791b2a88 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -120,10 +120,7 @@ namespace osu.Game.Overlays ?? streams.Find(s => s.Name == updateStream)?.LatestBuild; if (build != null) - { - Current.Value = build; - State = Visibility.Visible; - } + ShowBuild(build); }); State = Visibility.Visible; @@ -193,13 +190,13 @@ namespace osu.Game.Overlays }); } - private CancellationTokenSource loadContentTask; + private CancellationTokenSource loadContentCancellation; private void loadContent(ChangelogContent newContent) { content.FadeTo(0.2f, 300, Easing.OutQuint); - loadContentTask?.Cancel(); + loadContentCancellation?.Cancel(); LoadComponentAsync(newContent, c => { @@ -207,7 +204,7 @@ namespace osu.Game.Overlays c.BuildSelected = ShowBuild; content.Child = c; - }, (loadContentTask = new CancellationTokenSource()).Token); + }, (loadContentCancellation = new CancellationTokenSource()).Token); } } } From 465aa4e0f60db2ed81df136cf0da5c6613c4beef Mon Sep 17 00:00:00 2001 From: David Zhao Date: Fri, 31 May 2019 14:06:13 +0900 Subject: [PATCH 227/375] Prevent idle state from being updated incorrectly --- osu.Game/Screens/Menu/ButtonSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index a098d42c83..868d37d922 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -176,7 +176,7 @@ namespace osu.Game.Screens.Menu private void updateIdleState(bool isIdle) { - if (isIdle && State != ButtonSystemState.Exit) + if (isIdle && State != ButtonSystemState.Exit && State != ButtonSystemState.EnteringMode) State = ButtonSystemState.Initial; } From 1629534a0c79a3b6fae32820a17acb2f1dd3cc68 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 29 May 2019 22:07:14 +0900 Subject: [PATCH 228/375] More disposal? --- osu.Game/Skinning/SkinnableSound.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/osu.Game/Skinning/SkinnableSound.cs b/osu.Game/Skinning/SkinnableSound.cs index 5e8a0ea43f..e88e088f5e 100644 --- a/osu.Game/Skinning/SkinnableSound.cs +++ b/osu.Game/Skinning/SkinnableSound.cs @@ -58,5 +58,13 @@ namespace osu.Game.Skinning return null; } + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + foreach (var c in channels) + c.Dispose(); + } } } From 80d65f9a3ba2e3e4d6486ca92f915f9ad8da24f5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 31 May 2019 14:33:18 +0900 Subject: [PATCH 229/375] Update resource stores with GetAvailableResources --- osu.Game/IO/Archives/ArchiveReader.cs | 2 ++ osu.Game/Skinning/LegacySkin.cs | 3 +++ 2 files changed, 5 insertions(+) diff --git a/osu.Game/IO/Archives/ArchiveReader.cs b/osu.Game/IO/Archives/ArchiveReader.cs index a561523799..4ee7a19ebc 100644 --- a/osu.Game/IO/Archives/ArchiveReader.cs +++ b/osu.Game/IO/Archives/ArchiveReader.cs @@ -15,6 +15,8 @@ namespace osu.Game.IO.Archives /// public abstract Stream GetStream(string name); + public IEnumerable GetAvailableResources() => Filenames; + public abstract void Dispose(); /// diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 8d38f944d0..7b658f86d0 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; @@ -140,6 +141,8 @@ namespace osu.Game.Skinning return path == null ? null : underlyingStore.GetStream(path); } + public IEnumerable GetAvailableResources() => source.Files.Select(f => f.Filename); + byte[] IResourceStore.Get(string name) => GetAsync(name).Result; public Task GetAsync(string name) From f33a5bc54cee705bcdb8d8d77f1f1e314b2f322c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 31 May 2019 14:40:53 +0900 Subject: [PATCH 230/375] Centralise and update WorkingBeatmap creation in test cases --- .../TestSceneAutoJuiceStream.cs | 4 +- .../TestSceneBananaShower.cs | 4 +- .../TestSceneCatchStacker.cs | 4 +- .../TestSceneHyperDash.cs | 4 +- .../TestSceneHitCircleLongCombo.cs | 4 +- .../TestSceneSliderInput.cs | 5 +- .../TestSceneTaikoPlayfield.cs | 5 +- .../TestSceneBackgroundScreenBeatmap.cs | 5 +- .../Visual/Editor/TestSceneEditorCompose.cs | 3 +- .../Editor/TestSceneEditorComposeTimeline.cs | 5 +- .../Editor/TestSceneEditorSeekSnapping.cs | 5 +- .../Editor/TestSceneEditorSummaryTimeline.cs | 3 +- .../Editor/TestSceneHitObjectComposer.cs | 3 +- .../Visual/Editor/TestScenePlaybackControl.cs | 5 +- .../Visual/Editor/TestSceneWaveform.cs | 10 +- .../Visual/Gameplay/TestScenePlayerLoader.cs | 5 +- .../TestScenePlayerReferenceLeaking.cs | 5 +- .../TestSceneMatchSettingsOverlay.cs | 5 +- .../Visual/Online/TestSceneDirectPanel.cs | 3 +- .../SongSelect/TestSceneBeatmapDetailArea.cs | 14 +- .../SongSelect/TestSceneBeatmapInfoWedge.cs | 5 +- .../SongSelect/TestScenePlaySongSelect.cs | 5 +- osu.Game.Tests/WaveformTestBeatmap.cs | 13 +- osu.Game/Beatmaps/BeatmapManager.cs | 2 +- .../Beatmaps/BeatmapManager_WorkingBeatmap.cs | 3 +- osu.Game/Beatmaps/BindableBeatmap.cs | 26 +-- osu.Game/Beatmaps/DummyWorkingBeatmap.cs | 6 +- osu.Game/Beatmaps/WorkingBeatmap.cs | 7 +- osu.Game/OsuGameBase.cs | 16 +- osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs | 112 +--------- osu.Game/Tests/Visual/AllPlayersTestScene.cs | 21 +- osu.Game/Tests/Visual/EditorTestScene.cs | 5 +- osu.Game/Tests/Visual/OsuTestScene.cs | 198 ++++++++++++++++-- osu.Game/Tests/Visual/PlayerTestScene.cs | 8 +- 34 files changed, 278 insertions(+), 250 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneAutoJuiceStream.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneAutoJuiceStream.cs index 9cec0d280d..ab3c040b4e 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneAutoJuiceStream.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneAutoJuiceStream.cs @@ -20,14 +20,14 @@ namespace osu.Game.Rulesets.Catch.Tests { } - protected override IBeatmap CreateBeatmap(Ruleset ruleset) + protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) { var beatmap = new Beatmap { BeatmapInfo = new BeatmapInfo { BaseDifficulty = new BeatmapDifficulty { CircleSize = 6, SliderMultiplier = 3 }, - Ruleset = ruleset.RulesetInfo + Ruleset = ruleset } }; diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneBananaShower.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneBananaShower.cs index 035bbe4b4e..0ad72412fc 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneBananaShower.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneBananaShower.cs @@ -29,14 +29,14 @@ namespace osu.Game.Rulesets.Catch.Tests { } - protected override IBeatmap CreateBeatmap(Ruleset ruleset) + protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) { var beatmap = new Beatmap { BeatmapInfo = new BeatmapInfo { BaseDifficulty = new BeatmapDifficulty { CircleSize = 6 }, - Ruleset = ruleset.RulesetInfo + Ruleset = ruleset } }; diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneCatchStacker.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneCatchStacker.cs index 7d7528372a..9ce46ad6ba 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneCatchStacker.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneCatchStacker.cs @@ -16,14 +16,14 @@ namespace osu.Game.Rulesets.Catch.Tests { } - protected override IBeatmap CreateBeatmap(Ruleset ruleset) + protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) { var beatmap = new Beatmap { BeatmapInfo = new BeatmapInfo { BaseDifficulty = new BeatmapDifficulty { CircleSize = 6 }, - Ruleset = ruleset.RulesetInfo + Ruleset = ruleset } }; diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs index 7393f75e5a..9cbff8c5d3 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs @@ -23,13 +23,13 @@ namespace osu.Game.Rulesets.Catch.Tests AddAssert("First note is hyperdash", () => Beatmap.Value.Beatmap.HitObjects[0] is Fruit f && f.HyperDash); } - protected override IBeatmap CreateBeatmap(Ruleset ruleset) + protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) { var beatmap = new Beatmap { BeatmapInfo = { - Ruleset = ruleset.RulesetInfo, + Ruleset = ruleset, BaseDifficulty = new BeatmapDifficulty { CircleSize = 3.6f } } }; diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLongCombo.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLongCombo.cs index 921246751c..399cf22599 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLongCombo.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLongCombo.cs @@ -17,14 +17,14 @@ namespace osu.Game.Rulesets.Osu.Tests { } - protected override IBeatmap CreateBeatmap(Ruleset ruleset) + protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) { var beatmap = new Beatmap { BeatmapInfo = new BeatmapInfo { BaseDifficulty = new BeatmapDifficulty { CircleSize = 6 }, - Ruleset = ruleset.RulesetInfo + Ruleset = ruleset } }; diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs index 193cfe9c94..2eb783233a 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs @@ -20,7 +20,6 @@ using osu.Game.Rulesets.Replays; using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; using osu.Game.Screens.Play; -using osu.Game.Tests.Beatmaps; using osu.Game.Tests.Visual; using osuTK; @@ -299,7 +298,7 @@ namespace osu.Game.Rulesets.Osu.Tests { AddStep("load player", () => { - Beatmap.Value = new TestWorkingBeatmap(new Beatmap + Beatmap.Value = CreateWorkingBeatmap(new Beatmap { HitObjects = { @@ -323,7 +322,7 @@ namespace osu.Game.Rulesets.Osu.Tests BaseDifficulty = new BeatmapDifficulty { SliderTickRate = 3 }, Ruleset = new OsuRuleset().RulesetInfo }, - }, Clock); + }); var p = new ScoreAccessibleReplayPlayer(new Score { Replay = new Replay { Frames = frames } }); diff --git a/osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoPlayfield.cs b/osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoPlayfield.cs index 3634ec7d4a..6f9856df83 100644 --- a/osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoPlayfield.cs @@ -18,7 +18,6 @@ using osu.Game.Rulesets.Taiko.Judgements; using osu.Game.Rulesets.Taiko.Objects; using osu.Game.Rulesets.Taiko.Objects.Drawables; using osu.Game.Rulesets.Taiko.UI; -using osu.Game.Tests.Beatmaps; using osu.Game.Tests.Visual; using osuTK; using osu.Game.Rulesets.Scoring; @@ -64,7 +63,7 @@ namespace osu.Game.Rulesets.Taiko.Tests var controlPointInfo = new ControlPointInfo(); controlPointInfo.TimingPoints.Add(new TimingControlPoint()); - WorkingBeatmap beatmap = new TestWorkingBeatmap(new Beatmap + WorkingBeatmap beatmap = CreateWorkingBeatmap(new Beatmap { HitObjects = new List { new CentreHit() }, BeatmapInfo = new BeatmapInfo @@ -79,7 +78,7 @@ namespace osu.Game.Rulesets.Taiko.Tests Ruleset = new TaikoRuleset().RulesetInfo }, ControlPointInfo = controlPointInfo - }, Clock); + }); Add(playfieldContainer = new Container { diff --git a/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs index c9bdcf928f..7104a420a3 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Threading; using NUnit.Framework; using osu.Framework.Allocation; +using osu.Framework.Audio; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Input.Events; @@ -54,7 +55,7 @@ namespace osu.Game.Tests.Visual.Background private RulesetStore rulesets; [BackgroundDependencyLoader] - private void load(GameHost host) + private void load(GameHost host, AudioManager audio) { factory = new DatabaseContextFactory(LocalStorage); factory.ResetDatabase(); @@ -68,7 +69,7 @@ namespace osu.Game.Tests.Visual.Background usage.Migrate(); Dependencies.Cache(rulesets = new RulesetStore(factory)); - Dependencies.Cache(manager = new BeatmapManager(LocalStorage, factory, rulesets, null, null, host, Beatmap.Default)); + Dependencies.Cache(manager = new BeatmapManager(LocalStorage, factory, rulesets, null, audio, host, Beatmap.Default)); Dependencies.Cache(new OsuConfigManager(LocalStorage)); manager.Import(TestResources.GetTestBeatmapForImport()); diff --git a/osu.Game.Tests/Visual/Editor/TestSceneEditorCompose.cs b/osu.Game.Tests/Visual/Editor/TestSceneEditorCompose.cs index b537cb0beb..608df1965e 100644 --- a/osu.Game.Tests/Visual/Editor/TestSceneEditorCompose.cs +++ b/osu.Game.Tests/Visual/Editor/TestSceneEditorCompose.cs @@ -7,7 +7,6 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Game.Rulesets.Osu; using osu.Game.Screens.Edit.Compose; -using osu.Game.Tests.Beatmaps; namespace osu.Game.Tests.Visual.Editor { @@ -19,7 +18,7 @@ namespace osu.Game.Tests.Visual.Editor [BackgroundDependencyLoader] private void load() { - Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo, Clock); + Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo); Child = new ComposeScreen(); } } diff --git a/osu.Game.Tests/Visual/Editor/TestSceneEditorComposeTimeline.cs b/osu.Game.Tests/Visual/Editor/TestSceneEditorComposeTimeline.cs index 154c58dd99..a8c2362910 100644 --- a/osu.Game.Tests/Visual/Editor/TestSceneEditorComposeTimeline.cs +++ b/osu.Game.Tests/Visual/Editor/TestSceneEditorComposeTimeline.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using NUnit.Framework; using osu.Framework.Allocation; +using osu.Framework.Audio; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -30,9 +31,9 @@ namespace osu.Game.Tests.Visual.Editor }; [BackgroundDependencyLoader] - private void load() + private void load(AudioManager audio) { - Beatmap.Value = new WaveformTestBeatmap(); + Beatmap.Value = new WaveformTestBeatmap(audio); Children = new Drawable[] { diff --git a/osu.Game.Tests/Visual/Editor/TestSceneEditorSeekSnapping.cs b/osu.Game.Tests/Visual/Editor/TestSceneEditorSeekSnapping.cs index 590fa59107..b997d6aaeb 100644 --- a/osu.Game.Tests/Visual/Editor/TestSceneEditorSeekSnapping.cs +++ b/osu.Game.Tests/Visual/Editor/TestSceneEditorSeekSnapping.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 NUnit.Framework; @@ -10,7 +10,6 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Osu.Objects; -using osu.Game.Tests.Beatmaps; using osuTK; using osuTK.Graphics; @@ -48,7 +47,7 @@ namespace osu.Game.Tests.Visual.Editor } }; - Beatmap.Value = new TestWorkingBeatmap(testBeatmap, Clock); + Beatmap.Value = CreateWorkingBeatmap(testBeatmap); Child = new TimingPointVisualiser(testBeatmap, 5000) { Clock = Clock }; } diff --git a/osu.Game.Tests/Visual/Editor/TestSceneEditorSummaryTimeline.cs b/osu.Game.Tests/Visual/Editor/TestSceneEditorSummaryTimeline.cs index f20c921ff2..2e04eb50ca 100644 --- a/osu.Game.Tests/Visual/Editor/TestSceneEditorSummaryTimeline.cs +++ b/osu.Game.Tests/Visual/Editor/TestSceneEditorSummaryTimeline.cs @@ -8,7 +8,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Rulesets.Osu; using osu.Game.Screens.Edit.Components.Timelines.Summary; -using osu.Game.Tests.Beatmaps; using osuTK; namespace osu.Game.Tests.Visual.Editor @@ -21,7 +20,7 @@ namespace osu.Game.Tests.Visual.Editor [BackgroundDependencyLoader] private void load() { - Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo, null); + Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo); Add(new SummaryTimeline { diff --git a/osu.Game.Tests/Visual/Editor/TestSceneHitObjectComposer.cs b/osu.Game.Tests/Visual/Editor/TestSceneHitObjectComposer.cs index 47aa059b62..7accbe2fa8 100644 --- a/osu.Game.Tests/Visual/Editor/TestSceneHitObjectComposer.cs +++ b/osu.Game.Tests/Visual/Editor/TestSceneHitObjectComposer.cs @@ -18,7 +18,6 @@ using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Screens.Edit.Compose; using osu.Game.Screens.Edit.Compose.Components; -using osu.Game.Tests.Beatmaps; using osuTK; namespace osu.Game.Tests.Visual.Editor @@ -45,7 +44,7 @@ namespace osu.Game.Tests.Visual.Editor [BackgroundDependencyLoader] private void load() { - Beatmap.Value = new TestWorkingBeatmap(new Beatmap + Beatmap.Value = CreateWorkingBeatmap(new Beatmap { HitObjects = new List { diff --git a/osu.Game.Tests/Visual/Editor/TestScenePlaybackControl.cs b/osu.Game.Tests/Visual/Editor/TestScenePlaybackControl.cs index 126ab98291..0d4fe4366d 100644 --- a/osu.Game.Tests/Visual/Editor/TestScenePlaybackControl.cs +++ b/osu.Game.Tests/Visual/Editor/TestScenePlaybackControl.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 NUnit.Framework; @@ -7,7 +7,6 @@ using osu.Framework.Graphics; using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Screens.Edit.Components; -using osu.Game.Tests.Beatmaps; using osuTK; namespace osu.Game.Tests.Visual.Editor @@ -29,7 +28,7 @@ namespace osu.Game.Tests.Visual.Editor Size = new Vector2(200, 100) }; - Beatmap.Value = new TestWorkingBeatmap(new Beatmap(), Clock); + Beatmap.Value = CreateWorkingBeatmap(new Beatmap()); Child = playback; } diff --git a/osu.Game.Tests/Visual/Editor/TestSceneWaveform.cs b/osu.Game.Tests/Visual/Editor/TestSceneWaveform.cs index e93789b1d3..6e2500d711 100644 --- a/osu.Game.Tests/Visual/Editor/TestSceneWaveform.cs +++ b/osu.Game.Tests/Visual/Editor/TestSceneWaveform.cs @@ -3,6 +3,7 @@ using NUnit.Framework; using osu.Framework.Allocation; +using osu.Framework.Audio; using osu.Framework.Audio.Track; using osu.Framework.Graphics; using osu.Framework.Graphics.Audio; @@ -19,10 +20,13 @@ namespace osu.Game.Tests.Visual.Editor { private WorkingBeatmap waveformBeatmap; + private OsuGameBase game; + [BackgroundDependencyLoader] - private void load() + private void load(AudioManager audio, OsuGameBase game) { - waveformBeatmap = new WaveformTestBeatmap(); + waveformBeatmap = new WaveformTestBeatmap(audio); + this.game = game; } [TestCase(1f)] @@ -91,7 +95,7 @@ namespace osu.Game.Tests.Visual.Editor Child = graph = new TestWaveformGraph { RelativeSizeAxes = Axes.Both, - Waveform = new DummyWorkingBeatmap().Waveform, + Waveform = new DummyWorkingBeatmap(game).Waveform, }, }; }); diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs index 5c26f733ab..daee3a520c 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; @@ -16,7 +16,6 @@ using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; using osu.Game.Screens; using osu.Game.Screens.Play; -using osu.Game.Tests.Beatmaps; namespace osu.Game.Tests.Visual.Gameplay { @@ -29,7 +28,7 @@ namespace osu.Game.Tests.Visual.Gameplay public void Setup() => Schedule(() => { InputManager.Child = stack = new OsuScreenStack { RelativeSizeAxes = Axes.Both }; - Beatmap.Value = new TestWorkingBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo), Clock); + Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo); }); [Test] diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerReferenceLeaking.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerReferenceLeaking.cs index c75fb2567b..65b56319e8 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerReferenceLeaking.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerReferenceLeaking.cs @@ -3,7 +3,6 @@ using System; using osu.Framework.Lists; -using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Rulesets; using osu.Game.Screens.Play; @@ -43,9 +42,9 @@ namespace osu.Game.Tests.Visual.Gameplay }); } - protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, IFrameBasedClock clock) + protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap) { - var working = base.CreateWorkingBeatmap(beatmap, clock); + var working = base.CreateWorkingBeatmap(beatmap); workingWeakReferences.Add(working); return working; } diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs index 21b97fe73b..76a0604818 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs @@ -19,6 +19,9 @@ namespace osu.Game.Tests.Visual.Multiplayer { public class TestSceneMatchSettingsOverlay : MultiplayerTestScene { + [Resolved] + private OsuGameBase game { get; set; } + public override IReadOnlyList RequiredTypes => new[] { typeof(MatchSettingsOverlay) @@ -57,7 +60,7 @@ namespace osu.Game.Tests.Visual.Multiplayer AddStep("set name", () => Room.Name.Value = "Room name"); AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value); - AddStep("set beatmap", () => Room.Playlist.Add(new PlaylistItem { Beatmap = new DummyWorkingBeatmap().BeatmapInfo })); + AddStep("set beatmap", () => Room.Playlist.Add(new PlaylistItem { Beatmap = new DummyWorkingBeatmap(game).BeatmapInfo })); AddAssert("button enabled", () => settings.ApplyButton.Enabled.Value); AddStep("clear name", () => Room.Name.Value = ""); diff --git a/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs b/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs index a3d932a383..8b67892fbb 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs @@ -8,7 +8,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Overlays.Direct; using osu.Game.Rulesets.Osu; -using osu.Game.Tests.Beatmaps; using osuTK; namespace osu.Game.Tests.Visual.Online @@ -25,7 +24,7 @@ namespace osu.Game.Tests.Visual.Online [BackgroundDependencyLoader] private void load() { - var beatmap = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo, null); + var beatmap = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo); beatmap.BeatmapSetInfo.OnlineInfo.HasVideo = true; beatmap.BeatmapSetInfo.OnlineInfo.HasStoryboard = true; diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapDetailArea.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapDetailArea.cs index cf4362ba28..d398423b9a 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapDetailArea.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapDetailArea.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using NUnit.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Beatmaps; using osu.Game.Screens.Select; @@ -18,7 +19,8 @@ namespace osu.Game.Tests.Visual.SongSelect { public override IReadOnlyList RequiredTypes => new[] { typeof(BeatmapDetails) }; - public TestSceneBeatmapDetailArea() + [BackgroundDependencyLoader] + private void load(OsuGameBase game) { BeatmapDetailArea detailsArea; Add(detailsArea = new BeatmapDetailArea @@ -28,7 +30,7 @@ namespace osu.Game.Tests.Visual.SongSelect Size = new Vector2(550f, 450f), }); - AddStep("all metrics", () => detailsArea.Beatmap = new DummyWorkingBeatmap + AddStep("all metrics", () => detailsArea.Beatmap = new DummyWorkingBeatmap(game) { BeatmapInfo = { @@ -56,7 +58,7 @@ namespace osu.Game.Tests.Visual.SongSelect } ); - AddStep("all except source", () => detailsArea.Beatmap = new DummyWorkingBeatmap + AddStep("all except source", () => detailsArea.Beatmap = new DummyWorkingBeatmap(game) { BeatmapInfo = { @@ -82,7 +84,7 @@ namespace osu.Game.Tests.Visual.SongSelect } }); - AddStep("ratings", () => detailsArea.Beatmap = new DummyWorkingBeatmap + AddStep("ratings", () => detailsArea.Beatmap = new DummyWorkingBeatmap(game) { BeatmapInfo = { @@ -107,7 +109,7 @@ namespace osu.Game.Tests.Visual.SongSelect } }); - AddStep("fails+retries", () => detailsArea.Beatmap = new DummyWorkingBeatmap + AddStep("fails+retries", () => detailsArea.Beatmap = new DummyWorkingBeatmap(game) { BeatmapInfo = { @@ -133,7 +135,7 @@ namespace osu.Game.Tests.Visual.SongSelect } }); - AddStep("null metrics", () => detailsArea.Beatmap = new DummyWorkingBeatmap + AddStep("null metrics", () => detailsArea.Beatmap = new DummyWorkingBeatmap(game) { BeatmapInfo = { diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs index b1ed5c46c2..9969795ecf 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; @@ -18,7 +18,6 @@ using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Taiko; using osu.Game.Screens.Select; -using osu.Game.Tests.Beatmaps; using osuTK; namespace osu.Game.Tests.Visual.SongSelect @@ -136,7 +135,7 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep($"select {b?.Metadata.Title ?? "null"} beatmap", () => { infoBefore = infoWedge.Info; - infoWedge.Beatmap = Beatmap.Value = b == null ? Beatmap.Default : new TestWorkingBeatmap(b); + infoWedge.Beatmap = Beatmap.Value = b == null ? Beatmap.Default : CreateWorkingBeatmap(b); }); AddUntilStep("wait for async load", () => infoWedge.Info != infoBefore); diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index 7e962dbc06..ebee358730 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Text; using NUnit.Framework; using osu.Framework.Allocation; +using osu.Framework.Audio; using osu.Framework.Bindables; using osu.Framework.Extensions; using osu.Framework.MathUtils; @@ -79,7 +80,7 @@ namespace osu.Game.Tests.Visual.SongSelect } [BackgroundDependencyLoader] - private void load(GameHost host) + private void load(GameHost host, AudioManager audio) { factory = new DatabaseContextFactory(LocalStorage); factory.ResetDatabase(); @@ -93,7 +94,7 @@ namespace osu.Game.Tests.Visual.SongSelect usage.Migrate(); Dependencies.Cache(rulesets = new RulesetStore(factory)); - Dependencies.Cache(manager = new BeatmapManager(LocalStorage, factory, rulesets, null, null, host, defaultBeatmap = Beatmap.Default)); + Dependencies.Cache(manager = new BeatmapManager(LocalStorage, factory, rulesets, null, audio, host, defaultBeatmap = Beatmap.Default)); Beatmap.SetDefault(); } diff --git a/osu.Game.Tests/WaveformTestBeatmap.cs b/osu.Game.Tests/WaveformTestBeatmap.cs index f66b374cd7..36cc1e5ad2 100644 --- a/osu.Game.Tests/WaveformTestBeatmap.cs +++ b/osu.Game.Tests/WaveformTestBeatmap.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; +using osu.Framework.Audio; using osu.Framework.Audio.Track; using osu.Framework.Graphics.Textures; using osu.Game.Beatmaps; @@ -19,12 +20,14 @@ namespace osu.Game.Tests { private readonly ZipArchiveReader reader; private readonly Stream stream; + private readonly ITrackStore trackStore; - public WaveformTestBeatmap() - : base(new BeatmapInfo()) + public WaveformTestBeatmap(AudioManager audioManager) + : base(new BeatmapInfo(), audioManager) { stream = TestResources.GetTestBeatmapStream(); reader = new ZipArchiveReader(stream); + trackStore = audioManager.GetTrackStore(reader); } public override void Dispose() @@ -32,17 +35,17 @@ namespace osu.Game.Tests base.Dispose(); stream?.Dispose(); reader?.Dispose(); + trackStore?.Dispose(); } protected override IBeatmap GetBeatmap() => createTestBeatmap(); protected override Texture GetBackground() => null; - protected override Waveform GetWaveform() => new Waveform(getAudioStream()); + protected override Waveform GetWaveform() => new Waveform(trackStore.GetStream(reader.Filenames.First(f => f.EndsWith(".mp3")))); - protected override Track GetTrack() => new TrackBass(getAudioStream()); + protected override Track GetTrack() => trackStore.Get(reader.Filenames.First(f => f.EndsWith(".mp3"))); - private Stream getAudioStream() => reader.GetStream(reader.Filenames.First(f => f.EndsWith(".mp3"))); private Stream getBeatmapStream() => reader.GetStream(reader.Filenames.First(f => f.EndsWith(".osu"))); private Beatmap createTestBeatmap() diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 798bca3ada..0200dd44ac 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -429,7 +429,7 @@ namespace osu.Game.Beatmaps private readonly IBeatmap beatmap; public DummyConversionBeatmap(IBeatmap beatmap) - : base(beatmap.BeatmapInfo) + : base(beatmap.BeatmapInfo, null) { this.beatmap = beatmap; } diff --git a/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs b/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs index cfeb6b0a92..e1cc5db3ad 100644 --- a/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs @@ -22,11 +22,10 @@ namespace osu.Game.Beatmaps private readonly IResourceStore store; public BeatmapManagerWorkingBeatmap(IResourceStore store, TextureStore textureStore, BeatmapInfo beatmapInfo, AudioManager audioManager) - : base(beatmapInfo) + : base(beatmapInfo, audioManager) { this.store = store; this.textureStore = textureStore; - AudioManager = audioManager; } protected override IBeatmap GetBeatmap() diff --git a/osu.Game/Beatmaps/BindableBeatmap.cs b/osu.Game/Beatmaps/BindableBeatmap.cs index 6614a6f2fb..1e69a17ef7 100644 --- a/osu.Game/Beatmaps/BindableBeatmap.cs +++ b/osu.Game/Beatmaps/BindableBeatmap.cs @@ -2,8 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using System.Diagnostics; -using JetBrains.Annotations; -using osu.Framework.Audio; using osu.Framework.Bindables; namespace osu.Game.Beatmaps @@ -14,29 +12,20 @@ namespace osu.Game.Beatmaps /// public abstract class BindableBeatmap : NonNullableBindable { - protected AudioManager AudioManager; - private WorkingBeatmap lastBeatmap; - protected BindableBeatmap(WorkingBeatmap defaultValue, AudioManager audioManager) + protected BindableBeatmap(WorkingBeatmap defaultValue) : base(defaultValue) { - // we don't want to attempt to update tracks if we are a bound copy. - if (audioManager != null) - { - AudioManager = audioManager; - ValueChanged += b => updateAudioTrack(b.NewValue); - - // If the track has changed prior to this being called, let's register it - if (Value != Default) - updateAudioTrack(Value); - } + BindValueChanged(b => updateAudioTrack(b.NewValue), true); } private void updateAudioTrack(WorkingBeatmap beatmap) { var trackLoaded = lastBeatmap?.TrackLoaded ?? false; + //beatmap.AudioManager = AudioManager; + // compare to last beatmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo) if (!trackLoaded || lastBeatmap?.Track != beatmap.Track) { @@ -51,12 +40,5 @@ namespace osu.Game.Beatmaps lastBeatmap = beatmap; } - - /// - /// Retrieve a new instance weakly bound to this . - /// If you are further binding to events of the retrieved , ensure a local reference is held. - /// - [NotNull] - public new abstract BindableBeatmap GetBoundCopy(); } } diff --git a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs index b35e98085a..72b477713a 100644 --- a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs +++ b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs @@ -18,7 +18,7 @@ namespace osu.Game.Beatmaps { private readonly OsuGameBase game; - public DummyWorkingBeatmap(OsuGameBase game = null) + public DummyWorkingBeatmap(OsuGameBase game) : base(new BeatmapInfo { Metadata = new BeatmapMetadata @@ -34,7 +34,7 @@ namespace osu.Game.Beatmaps OverallDifficulty = 0, }, Ruleset = new DummyRulesetInfo() - }) + }, game.Audio) { this.game = game; } @@ -43,7 +43,7 @@ namespace osu.Game.Beatmaps protected override Texture GetBackground() => game?.Textures.Get(@"Backgrounds/bg4"); - protected override Track GetTrack() => game?.Audio.Tracks.GetVirtual(1000); + protected override Track GetTrack() => game?.Audio?.Tracks.GetVirtual(1000); private class DummyRulesetInfo : RulesetInfo { diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 6c8f283923..cf1acaf46b 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -29,8 +29,11 @@ namespace osu.Game.Beatmaps public readonly BeatmapMetadata Metadata; - protected WorkingBeatmap(BeatmapInfo beatmapInfo) + protected AudioManager AudioManager { get; } + + protected WorkingBeatmap(BeatmapInfo beatmapInfo, AudioManager audioManager) { + AudioManager = audioManager; BeatmapInfo = beatmapInfo; BeatmapSetInfo = beatmapInfo.BeatmapSet; Metadata = beatmapInfo.Metadata ?? BeatmapSetInfo?.Metadata ?? new BeatmapMetadata(); @@ -179,8 +182,6 @@ namespace osu.Game.Beatmaps public bool SkinLoaded => skin.IsResultAvailable; public Skin Skin => skin.Value; - public AudioManager AudioManager { get; set; } - protected virtual Skin GetSkin() => new DefaultSkin(); private readonly RecyclableLazy skin; diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 8e663de8c5..39f5144cf8 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -195,7 +195,7 @@ namespace osu.Game // this adds a global reduction of track volume for the time being. Audio.Tracks.AddAdjustment(AdjustableProperty.Volume, new BindableDouble(0.8)); - beatmap = new OsuBindableBeatmap(defaultBeatmap, Audio); + beatmap = new OsuBindableBeatmap(defaultBeatmap); dependencies.CacheAs>(beatmap); dependencies.CacheAs(beatmap); @@ -282,21 +282,9 @@ namespace osu.Game private class OsuBindableBeatmap : BindableBeatmap { public OsuBindableBeatmap(WorkingBeatmap defaultValue) - : base(defaultValue, null) + : base(defaultValue) { } - - public OsuBindableBeatmap(WorkingBeatmap defaultValue, AudioManager audioManager) - : base(defaultValue, audioManager) - { - } - - public override BindableBeatmap GetBoundCopy() - { - var copy = new OsuBindableBeatmap(Default, AudioManager); - copy.BindTo(this); - return copy; - } } private class OsuUserInputManager : UserInputManager diff --git a/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs b/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs index c558275f62..0ef35879e3 100644 --- a/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs +++ b/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs @@ -1,134 +1,30 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using osu.Framework.Audio.Track; using osu.Framework.Graphics.Textures; -using osu.Framework.Timing; using osu.Game.Beatmaps; -using osu.Game.Rulesets; -using osuTK; namespace osu.Game.Tests.Beatmaps { public class TestWorkingBeatmap : WorkingBeatmap { - private readonly TrackVirtualManual track; private readonly IBeatmap beatmap; - /// - /// Create an instance which creates a for the provided ruleset when requested. - /// - /// The target ruleset. - /// A clock which should be used instead of a stopwatch for virtual time progression. - public TestWorkingBeatmap(RulesetInfo ruleset, IFrameBasedClock referenceClock) - : this(new TestBeatmap(ruleset), referenceClock) - { - } - /// /// Create an instance which provides the when requested. /// /// The beatmap - /// An optional clock which should be used instead of a stopwatch for virtual time progression. - public TestWorkingBeatmap(IBeatmap beatmap, IFrameBasedClock referenceClock = null) - : base(beatmap.BeatmapInfo) + public TestWorkingBeatmap(IBeatmap beatmap) + : base(beatmap.BeatmapInfo, null) { this.beatmap = beatmap; - - if (referenceClock != null) - track = new TrackVirtualManual(referenceClock); } protected override IBeatmap GetBeatmap() => beatmap; + protected override Texture GetBackground() => null; - protected override Track GetTrack() => track; - /// - /// A virtual track which tracks a reference clock. - /// - public class TrackVirtualManual : Track - { - private readonly IFrameBasedClock referenceClock; - - private readonly ManualClock clock = new ManualClock(); - - private bool running; - - /// - /// Local offset added to the reference clock to resolve correct time. - /// - private double offset; - - public TrackVirtualManual(IFrameBasedClock referenceClock) - { - this.referenceClock = referenceClock; - Length = double.PositiveInfinity; - } - - public override bool Seek(double seek) - { - offset = MathHelper.Clamp(seek, 0, Length); - lastReferenceTime = null; - - return offset == seek; - } - - public override void Start() - { - running = true; - } - - public override void Reset() - { - Seek(0); - base.Reset(); - } - - public override void Stop() - { - if (running) - { - running = false; - // on stopping, the current value should be transferred out of the clock, as we can no longer rely on - // the referenceClock (which will still be counting time). - offset = clock.CurrentTime; - lastReferenceTime = null; - } - } - - public override bool IsRunning => running; - - private double? lastReferenceTime; - - public override double CurrentTime => clock.CurrentTime; - - protected override void UpdateState() - { - base.UpdateState(); - - if (running) - { - double refTime = referenceClock.CurrentTime; - - if (!lastReferenceTime.HasValue) - { - // if the clock just started running, the current value should be transferred to the offset - // (to zero the progression of time). - offset -= refTime; - } - - lastReferenceTime = refTime; - } - - clock.CurrentTime = Math.Min((lastReferenceTime ?? 0) + offset, Length); - - if (CurrentTime >= Length) - { - Stop(); - RaiseCompleted(); - } - } - } + protected override Track GetTrack() => null; } } diff --git a/osu.Game/Tests/Visual/AllPlayersTestScene.cs b/osu.Game/Tests/Visual/AllPlayersTestScene.cs index 454fbe1222..b7d1979b0d 100644 --- a/osu.Game/Tests/Visual/AllPlayersTestScene.cs +++ b/osu.Game/Tests/Visual/AllPlayersTestScene.cs @@ -4,13 +4,10 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Screens; -using osu.Framework.Timing; -using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; using osu.Game.Screens.Play; -using osu.Game.Tests.Beatmaps; namespace osu.Game.Tests.Visual { @@ -50,26 +47,20 @@ namespace osu.Game.Tests.Visual protected abstract void AddCheckSteps(); - protected virtual IBeatmap CreateBeatmap(Ruleset ruleset) => new TestBeatmap(ruleset.RulesetInfo); - - protected virtual WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, IFrameBasedClock clock) => - new TestWorkingBeatmap(beatmap, Clock); - - private Player loadPlayerFor(RulesetInfo ri) + private Player loadPlayerFor(RulesetInfo rulesetInfo) { - Ruleset.Value = ri; - var r = ri.CreateInstance(); + Ruleset.Value = rulesetInfo; + var ruleset = rulesetInfo.CreateInstance(); - var beatmap = CreateBeatmap(r); - var working = CreateWorkingBeatmap(beatmap, Clock); + var working = CreateWorkingBeatmap(rulesetInfo); Beatmap.Value = working; - Mods.Value = new[] { r.GetAllMods().First(m => m is ModNoFail) }; + Mods.Value = new[] { ruleset.GetAllMods().First(m => m is ModNoFail) }; Player?.Exit(); Player = null; - Player = CreatePlayer(r); + Player = CreatePlayer(ruleset); LoadScreen(Player); diff --git a/osu.Game/Tests/Visual/EditorTestScene.cs b/osu.Game/Tests/Visual/EditorTestScene.cs index 14c0f0950f..75bbb3e110 100644 --- a/osu.Game/Tests/Visual/EditorTestScene.cs +++ b/osu.Game/Tests/Visual/EditorTestScene.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; @@ -6,7 +6,6 @@ using System.Collections.Generic; using osu.Framework.Allocation; using osu.Game.Rulesets; using osu.Game.Screens.Edit; -using osu.Game.Tests.Beatmaps; namespace osu.Game.Tests.Visual { @@ -24,7 +23,7 @@ namespace osu.Game.Tests.Visual [BackgroundDependencyLoader] private void load() { - Beatmap.Value = new TestWorkingBeatmap(ruleset.RulesetInfo, null); + Beatmap.Value = CreateWorkingBeatmap(ruleset.RulesetInfo); LoadScreen(new Editor()); } diff --git a/osu.Game/Tests/Visual/OsuTestScene.cs b/osu.Game/Tests/Visual/OsuTestScene.cs index 806b73b517..d8a63d23e1 100644 --- a/osu.Game/Tests/Visual/OsuTestScene.cs +++ b/osu.Game/Tests/Visual/OsuTestScene.cs @@ -3,15 +3,21 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; +using osu.Framework.Audio.Track; using osu.Framework.Bindables; using osu.Framework.Platform; using osu.Framework.Testing; +using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; +using osu.Game.Tests.Beatmaps; +using osuTK; namespace osu.Game.Tests.Visual { @@ -19,7 +25,7 @@ namespace osu.Game.Tests.Visual { [Cached(typeof(Bindable))] [Cached(typeof(IBindable))] - private readonly OsuTestBeatmap beatmap = new OsuTestBeatmap(new DummyWorkingBeatmap(), null); + private OsuTestBeatmap beatmap; protected BindableBeatmap Beatmap => beatmap; @@ -39,7 +45,10 @@ namespace osu.Game.Tests.Visual protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) { // This is the earliest we can get OsuGameBase, which is used by the dummy working beatmap to find textures - beatmap.Default = new DummyWorkingBeatmap(parent.Get()); + beatmap = new OsuTestBeatmap(new DummyWorkingBeatmap(parent.Get())) + { + Default = new DummyWorkingBeatmap(parent.Get()) + }; return Dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); } @@ -49,8 +58,19 @@ namespace osu.Game.Tests.Visual localStorage = new Lazy(() => new NativeStorage($"{GetType().Name}-{Guid.NewGuid()}")); } + [Resolved] + private AudioManager audio { get; set; } + + protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset); + + protected WorkingBeatmap CreateWorkingBeatmap(RulesetInfo ruleset = null) => + CreateWorkingBeatmap(CreateBeatmap(ruleset)); + + protected virtual WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap) => + new ClockBackedTestWorkingBeatmap(beatmap, Clock, audio); + [BackgroundDependencyLoader] - private void load(AudioManager audioManager, RulesetStore rulesets) + private void load(RulesetStore rulesets) { Ruleset.Value = rulesets.AvailableRulesets.First(); } @@ -59,7 +79,8 @@ namespace osu.Game.Tests.Visual { base.Dispose(isDisposing); - beatmap?.Value.Track.Stop(); + if (beatmap?.Value.TrackLoaded == true) + beatmap.Value.Track.Stop(); if (localStorage.IsValueCreated) { @@ -76,6 +97,164 @@ namespace osu.Game.Tests.Visual protected override ITestSceneTestRunner CreateRunner() => new OsuTestSceneTestRunner(); + public class ClockBackedTestWorkingBeatmap : TestWorkingBeatmap + { + private readonly Track track; + + private readonly TrackVirtualStore store; + + /// + /// Create an instance which creates a for the provided ruleset when requested. + /// + /// The target ruleset. + /// 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) + { + } + + /// + /// Create an instance which provides the when requested. + /// + /// The beatmap + /// 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) + { + if (referenceClock != null) + { + store = new TrackVirtualStore(referenceClock); + audio.AddItem(store); + track = store.GetVirtual(length); + } + else + track = audio?.Tracks.GetVirtual(length); + } + + public override void Dispose() + { + base.Dispose(); + store?.Dispose(); + } + + protected override Track GetTrack() => track; + + public class TrackVirtualStore : AudioCollectionManager, ITrackStore + { + private readonly IFrameBasedClock referenceClock; + + public TrackVirtualStore(IFrameBasedClock referenceClock) + { + this.referenceClock = referenceClock; + } + + public Track Get(string name) => throw new NotImplementedException(); + + public Task GetAsync(string name) => throw new NotImplementedException(); + + public Stream GetStream(string name) => throw new NotImplementedException(); + + public IEnumerable GetAvailableResources() => throw new NotImplementedException(); + + public Track GetVirtual(double length = Double.PositiveInfinity) + { + var track = new TrackVirtualManual(referenceClock) { Length = length }; + AddItem(track); + return track; + } + } + + /// + /// A virtual track which tracks a reference clock. + /// + public class TrackVirtualManual : Track + { + private readonly IFrameBasedClock referenceClock; + + private readonly ManualClock clock = new ManualClock(); + + private bool running; + + /// + /// Local offset added to the reference clock to resolve correct time. + /// + private double offset; + + public TrackVirtualManual(IFrameBasedClock referenceClock) + { + this.referenceClock = referenceClock; + Length = double.PositiveInfinity; + } + + public override bool Seek(double seek) + { + offset = MathHelper.Clamp(seek, 0, Length); + lastReferenceTime = null; + + return offset == seek; + } + + public override void Start() + { + running = true; + } + + public override void Reset() + { + Seek(0); + base.Reset(); + } + + public override void Stop() + { + if (running) + { + running = false; + // on stopping, the current value should be transferred out of the clock, as we can no longer rely on + // the referenceClock (which will still be counting time). + offset = clock.CurrentTime; + lastReferenceTime = null; + } + } + + public override bool IsRunning => running; + + private double? lastReferenceTime; + + public override double CurrentTime => clock.CurrentTime; + + protected override void UpdateState() + { + base.UpdateState(); + + if (running) + { + double refTime = referenceClock.CurrentTime; + + if (!lastReferenceTime.HasValue) + { + // if the clock just started running, the current value should be transferred to the offset + // (to zero the progression of time). + offset -= refTime; + } + + lastReferenceTime = refTime; + } + + clock.CurrentTime = Math.Min((lastReferenceTime ?? 0) + offset, Length); + + if (CurrentTime >= Length) + { + Stop(); + RaiseCompleted(); + } + } + } + } + public class OsuTestSceneTestRunner : OsuGameBase, ITestSceneTestRunner { private TestSceneTestRunner.TestRunner runner; @@ -93,17 +272,10 @@ namespace osu.Game.Tests.Visual private class OsuTestBeatmap : BindableBeatmap { - public OsuTestBeatmap(WorkingBeatmap defaultValue, AudioManager audioManager) - : base(defaultValue, audioManager) + public OsuTestBeatmap(WorkingBeatmap defaultValue) + : base(defaultValue) { } - - public override BindableBeatmap GetBoundCopy() - { - var copy = new OsuTestBeatmap(Default, AudioManager); - copy.BindTo(this); - return copy; - } } } } diff --git a/osu.Game/Tests/Visual/PlayerTestScene.cs b/osu.Game/Tests/Visual/PlayerTestScene.cs index 0c39194088..03e17a819c 100644 --- a/osu.Game/Tests/Visual/PlayerTestScene.cs +++ b/osu.Game/Tests/Visual/PlayerTestScene.cs @@ -4,12 +4,10 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Testing; -using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; using osu.Game.Screens.Play; -using osu.Game.Tests.Beatmaps; namespace osu.Game.Tests.Visual { @@ -39,15 +37,13 @@ namespace osu.Game.Tests.Visual AddUntilStep("player loaded", () => Player.IsLoaded && Player.Alpha == 1); } - protected virtual IBeatmap CreateBeatmap(Ruleset ruleset) => new TestBeatmap(ruleset.RulesetInfo); - protected virtual bool AllowFail => false; private void loadPlayer() { - var beatmap = CreateBeatmap(ruleset); + var beatmap = CreateBeatmap(ruleset.RulesetInfo); - Beatmap.Value = new TestWorkingBeatmap(beatmap, Clock); + Beatmap.Value = CreateWorkingBeatmap(beatmap); if (!AllowFail) Mods.Value = new[] { ruleset.GetAllMods().First(m => m is ModNoFail) }; From b52276c4892dd0585ad81ac014ab1fe4f969eb5b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 31 May 2019 14:51:12 +0900 Subject: [PATCH 231/375] Pass individual components to DummyWorkingBeatmap, not game --- osu.Game.Tests/Visual/Editor/TestSceneWaveform.cs | 3 ++- .../Multiplayer/TestSceneMatchSettingsOverlay.cs | 3 +-- .../Visual/SongSelect/TestSceneBeatmapDetailArea.cs | 10 +++++----- osu.Game/Beatmaps/DummyWorkingBeatmap.cs | 13 +++++++------ osu.Game/OsuGameBase.cs | 2 +- osu.Game/Tests/Visual/OsuTestScene.cs | 9 ++++++--- 6 files changed, 22 insertions(+), 18 deletions(-) diff --git a/osu.Game.Tests/Visual/Editor/TestSceneWaveform.cs b/osu.Game.Tests/Visual/Editor/TestSceneWaveform.cs index 6e2500d711..7b27998d7f 100644 --- a/osu.Game.Tests/Visual/Editor/TestSceneWaveform.cs +++ b/osu.Game.Tests/Visual/Editor/TestSceneWaveform.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Graphics.Sprites; +using osu.Game.Rulesets.Osu; using osuTK.Graphics; namespace osu.Game.Tests.Visual.Editor @@ -95,7 +96,7 @@ namespace osu.Game.Tests.Visual.Editor Child = graph = new TestWaveformGraph { RelativeSizeAxes = Axes.Both, - Waveform = new DummyWorkingBeatmap(game).Waveform, + Waveform = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo).Waveform, }, }; }); diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs index 76a0604818..de4f4d9d25 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs @@ -8,7 +8,6 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Beatmaps; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Online.Multiplayer; @@ -60,7 +59,7 @@ namespace osu.Game.Tests.Visual.Multiplayer AddStep("set name", () => Room.Name.Value = "Room name"); AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value); - AddStep("set beatmap", () => Room.Playlist.Add(new PlaylistItem { Beatmap = new DummyWorkingBeatmap(game).BeatmapInfo })); + AddStep("set beatmap", () => Room.Playlist.Add(new PlaylistItem { Beatmap = CreateBeatmap(Ruleset.Value).BeatmapInfo })); AddAssert("button enabled", () => settings.ApplyButton.Enabled.Value); AddStep("clear name", () => Room.Name.Value = ""); diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapDetailArea.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapDetailArea.cs index d398423b9a..8395ece457 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapDetailArea.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapDetailArea.cs @@ -30,7 +30,7 @@ namespace osu.Game.Tests.Visual.SongSelect Size = new Vector2(550f, 450f), }); - AddStep("all metrics", () => detailsArea.Beatmap = new DummyWorkingBeatmap(game) + AddStep("all metrics", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null) { BeatmapInfo = { @@ -58,7 +58,7 @@ namespace osu.Game.Tests.Visual.SongSelect } ); - AddStep("all except source", () => detailsArea.Beatmap = new DummyWorkingBeatmap(game) + AddStep("all except source", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null) { BeatmapInfo = { @@ -84,7 +84,7 @@ namespace osu.Game.Tests.Visual.SongSelect } }); - AddStep("ratings", () => detailsArea.Beatmap = new DummyWorkingBeatmap(game) + AddStep("ratings", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null) { BeatmapInfo = { @@ -109,7 +109,7 @@ namespace osu.Game.Tests.Visual.SongSelect } }); - AddStep("fails+retries", () => detailsArea.Beatmap = new DummyWorkingBeatmap(game) + AddStep("fails+retries", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null) { BeatmapInfo = { @@ -135,7 +135,7 @@ namespace osu.Game.Tests.Visual.SongSelect } }); - AddStep("null metrics", () => detailsArea.Beatmap = new DummyWorkingBeatmap(game) + AddStep("null metrics", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null) { BeatmapInfo = { diff --git a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs index 72b477713a..9202c617bf 100644 --- a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs +++ b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using osu.Framework.Audio; using osu.Framework.Audio.Track; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics.Textures; @@ -16,9 +17,9 @@ namespace osu.Game.Beatmaps { public class DummyWorkingBeatmap : WorkingBeatmap { - private readonly OsuGameBase game; + private readonly TextureStore textures; - public DummyWorkingBeatmap(OsuGameBase game) + public DummyWorkingBeatmap(AudioManager audio, TextureStore textures) : base(new BeatmapInfo { Metadata = new BeatmapMetadata @@ -34,16 +35,16 @@ namespace osu.Game.Beatmaps OverallDifficulty = 0, }, Ruleset = new DummyRulesetInfo() - }, game.Audio) + }, audio) { - this.game = game; + this.textures = textures; } protected override IBeatmap GetBeatmap() => new Beatmap(); - protected override Texture GetBackground() => game?.Textures.Get(@"Backgrounds/bg4"); + protected override Texture GetBackground() => textures?.Get(@"Backgrounds/bg4"); - protected override Track GetTrack() => game?.Audio?.Tracks.GetVirtual(1000); + protected override Track GetTrack() => GetVirtualTrack(Beatmap); private class DummyRulesetInfo : RulesetInfo { diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 39f5144cf8..f9128687d6 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -161,7 +161,7 @@ namespace osu.Game dependencies.CacheAs(API); - var defaultBeatmap = new DummyWorkingBeatmap(this); + var defaultBeatmap = new DummyWorkingBeatmap(Audio, Textures); dependencies.Cache(RulesetStore = new RulesetStore(contextFactory)); dependencies.Cache(FileStore = new FileStore(contextFactory, Host.Storage)); diff --git a/osu.Game/Tests/Visual/OsuTestScene.cs b/osu.Game/Tests/Visual/OsuTestScene.cs index d8a63d23e1..c8798448ae 100644 --- a/osu.Game/Tests/Visual/OsuTestScene.cs +++ b/osu.Game/Tests/Visual/OsuTestScene.cs @@ -10,6 +10,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Track; using osu.Framework.Bindables; +using osu.Framework.Graphics.Textures; using osu.Framework.Platform; using osu.Framework.Testing; using osu.Framework.Timing; @@ -45,9 +46,11 @@ namespace osu.Game.Tests.Visual protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) { // This is the earliest we can get OsuGameBase, which is used by the dummy working beatmap to find textures - beatmap = new OsuTestBeatmap(new DummyWorkingBeatmap(parent.Get())) + var working = new DummyWorkingBeatmap(parent.Get(), parent.Get()); + + beatmap = new OsuTestBeatmap(working) { - Default = new DummyWorkingBeatmap(parent.Get()) + Default = working }; return Dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); @@ -63,7 +66,7 @@ namespace osu.Game.Tests.Visual protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset); - protected WorkingBeatmap CreateWorkingBeatmap(RulesetInfo ruleset = null) => + protected WorkingBeatmap CreateWorkingBeatmap(RulesetInfo ruleset) => CreateWorkingBeatmap(CreateBeatmap(ruleset)); protected virtual WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap) => From 7bed4eb23b73ec49bba20136d5aa6c257cb474f1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 31 May 2019 14:57:11 +0900 Subject: [PATCH 232/375] Tidy up WaveformTestBeatmap --- osu.Game.Tests/WaveformTestBeatmap.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/WaveformTestBeatmap.cs b/osu.Game.Tests/WaveformTestBeatmap.cs index 36cc1e5ad2..fdb91b7c5b 100644 --- a/osu.Game.Tests/WaveformTestBeatmap.cs +++ b/osu.Game.Tests/WaveformTestBeatmap.cs @@ -42,9 +42,11 @@ namespace osu.Game.Tests protected override Texture GetBackground() => null; - protected override Waveform GetWaveform() => new Waveform(trackStore.GetStream(reader.Filenames.First(f => f.EndsWith(".mp3")))); + protected override Waveform GetWaveform() => new Waveform(trackStore.GetStream(firstAudioFile)); - protected override Track GetTrack() => trackStore.Get(reader.Filenames.First(f => f.EndsWith(".mp3"))); + protected override Track GetTrack() => trackStore.Get(firstAudioFile); + + private string firstAudioFile => reader.Filenames.First(f => f.EndsWith(".mp3")); private Stream getBeatmapStream() => reader.GetStream(reader.Filenames.First(f => f.EndsWith(".osu"))); From 55c0c6a1bbffebe94d7a620689e42d3525d3f84a Mon Sep 17 00:00:00 2001 From: Lucas A Date: Fri, 31 May 2019 17:43:58 +0200 Subject: [PATCH 233/375] Show changelog for current build by clicking on settings footer in settings overlay. --- osu.Game/Overlays/Settings/SettingsFooter.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index e8c2c1ffe8..33ad5b101b 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; @@ -17,8 +18,11 @@ namespace osu.Game.Overlays.Settings { public class SettingsFooter : FillFlowContainer { + private OsuGameBase game; + private ChangelogOverlay changelog; + [BackgroundDependencyLoader] - private void load(OsuGameBase game, OsuColour colours, RulesetStore rulesets) + private void load(OsuGameBase game, OsuColour colours, RulesetStore rulesets, ChangelogOverlay changelog) { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; @@ -67,6 +71,17 @@ namespace osu.Game.Overlays.Settings Colour = DebugUtils.IsDebug ? colours.Red : Color4.White, }, }; + + this.game = game; + this.changelog = changelog; + } + + protected override bool OnClick(ClickEvent e) + { + if (!game.IsDeployedBuild) return base.OnClick(e); + + changelog?.ShowBuild("lazer", game.Version); + return base.OnClick(e); } } } From 0625f51e65447596f6f1a0a77faf130968958b84 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Fri, 31 May 2019 22:42:09 +0200 Subject: [PATCH 234/375] Allow dependencies to be null in certain cases (Unit tests) --- osu.Game/Overlays/Settings/SettingsFooter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index 33ad5b101b..317ba2f92d 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Settings private OsuGameBase game; private ChangelogOverlay changelog; - [BackgroundDependencyLoader] + [BackgroundDependencyLoader(true)] private void load(OsuGameBase game, OsuColour colours, RulesetStore rulesets, ChangelogOverlay changelog) { RelativeSizeAxes = Axes.X; From 58564579e4f679e64d470eeda0a85dfe6e70b670 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sat, 1 Jun 2019 08:46:38 +0200 Subject: [PATCH 235/375] Invert if statement --- osu.Game/Overlays/Settings/SettingsFooter.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index 317ba2f92d..3e0eb6ffde 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -78,10 +78,11 @@ namespace osu.Game.Overlays.Settings protected override bool OnClick(ClickEvent e) { - if (!game.IsDeployedBuild) return base.OnClick(e); - - changelog?.ShowBuild("lazer", game.Version); - return base.OnClick(e); + if (game.IsDeployedBuild) + { + changelog?.ShowBuild("lazer", game.Version); + } + return true; } } } From 0a867e37aff8782cdc97e1e57f41703bfa429312 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 2 Jun 2019 12:40:18 +0200 Subject: [PATCH 236/375] Resolve dependencies via Resolved Attribute --- osu.Game/Overlays/Settings/SettingsFooter.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index 3e0eb6ffde..306512802b 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -18,11 +18,14 @@ namespace osu.Game.Overlays.Settings { public class SettingsFooter : FillFlowContainer { - private OsuGameBase game; - private ChangelogOverlay changelog; + [Resolved] + private OsuGameBase game { get; set; } + + [Resolved(CanBeNull = true)] + private ChangelogOverlay changelog { get; set; } [BackgroundDependencyLoader(true)] - private void load(OsuGameBase game, OsuColour colours, RulesetStore rulesets, ChangelogOverlay changelog) + private void load(OsuGameBase game, OsuColour colours, RulesetStore rulesets) { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; @@ -71,9 +74,6 @@ namespace osu.Game.Overlays.Settings Colour = DebugUtils.IsDebug ? colours.Red : Color4.White, }, }; - - this.game = game; - this.changelog = changelog; } protected override bool OnClick(ClickEvent e) @@ -82,6 +82,7 @@ namespace osu.Game.Overlays.Settings { changelog?.ShowBuild("lazer", game.Version); } + return true; } } From d8f45f7299dd1531f7b5b485e9feaa6b7a7ba9ba Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 2 Jun 2019 15:17:03 +0200 Subject: [PATCH 237/375] Disallow null references for dependencies loaded via load() --- osu.Game/Overlays/Settings/SettingsFooter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index 306512802b..8403f70f49 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -24,7 +24,7 @@ namespace osu.Game.Overlays.Settings [Resolved(CanBeNull = true)] private ChangelogOverlay changelog { get; set; } - [BackgroundDependencyLoader(true)] + [BackgroundDependencyLoader] private void load(OsuGameBase game, OsuColour colours, RulesetStore rulesets) { RelativeSizeAxes = Axes.X; From 115a75e4c6604a214316e7e97752547b3610faff Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 3 Jun 2019 13:16:05 +0900 Subject: [PATCH 238/375] Use a constant for lazer variables --- osu.Desktop/Overlays/VersionManager.cs | 2 +- osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs | 2 +- osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs | 2 +- osu.Game/OsuGameBase.cs | 2 ++ osu.Game/Overlays/Settings/SettingsFooter.cs | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index d2aad99f41..5a8cf32f14 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -120,7 +120,7 @@ namespace osu.Desktop.Overlays Activated = delegate { - changelog.ShowBuild("lazer", version); + changelog.ShowBuild(OsuGameBase.CLIENT_STREAM_NAME, version); return true; }; } diff --git a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs index d1a7730bee..0655611230 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs @@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual.Online { Version = "2018.712.0", DisplayVersion = "2018.712.0", - UpdateStream = new APIUpdateStream { Name = "lazer" }, + UpdateStream = new APIUpdateStream { Name = OsuGameBase.CLIENT_STREAM_NAME }, ChangelogEntries = new List { new APIChangelogEntry diff --git a/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs b/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs index ef204c7687..d9e48373bb 100644 --- a/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs +++ b/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs @@ -45,7 +45,7 @@ namespace osu.Game.Online.API.Requests.Responses case "cuttingedge": return new Color4(238, 170, 0, 255); - case "lazer": + case OsuGameBase.CLIENT_STREAM_NAME: return new Color4(237, 18, 33, 255); case "web": diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 7b9aed8364..00672e82bd 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -44,6 +44,8 @@ namespace osu.Game /// public class OsuGameBase : Framework.Game, ICanAcceptFiles { + public const string CLIENT_STREAM_NAME = "lazer"; + protected OsuConfigManager LocalConfig; protected BeatmapManager BeatmapManager; diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index 8403f70f49..298991712b 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -80,7 +80,7 @@ namespace osu.Game.Overlays.Settings { if (game.IsDeployedBuild) { - changelog?.ShowBuild("lazer", game.Version); + changelog?.ShowBuild(OsuGameBase.CLIENT_STREAM_NAME, game.Version); } return true; From b249fb35446d1176a5bcdec7487fe1d949551e2e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 3 Jun 2019 13:37:29 +0900 Subject: [PATCH 239/375] Update test scene to support dynamic compilation --- ...stSceneSettings.cs => TestSceneSettingsPanel.cs} | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) rename osu.Game.Tests/Visual/Settings/{TestSceneSettings.cs => TestSceneSettingsPanel.cs} (71%) diff --git a/osu.Game.Tests/Visual/Settings/TestSceneSettings.cs b/osu.Game.Tests/Visual/Settings/TestSceneSettingsPanel.cs similarity index 71% rename from osu.Game.Tests/Visual/Settings/TestSceneSettings.cs rename to osu.Game.Tests/Visual/Settings/TestSceneSettingsPanel.cs index 964754f8d0..27e3cc1590 100644 --- a/osu.Game.Tests/Visual/Settings/TestSceneSettings.cs +++ b/osu.Game.Tests/Visual/Settings/TestSceneSettingsPanel.cs @@ -1,20 +1,29 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; +using System.Collections.Generic; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics.Containers; using osu.Game.Overlays; +using osu.Game.Overlays.Settings; namespace osu.Game.Tests.Visual.Settings { [TestFixture] - public class TestSceneSettings : OsuTestScene + public class TestSceneSettingsPanel : OsuTestScene { private readonly SettingsPanel settings; private readonly DialogOverlay dialogOverlay; - public TestSceneSettings() + public override IReadOnlyList RequiredTypes => new[] + { + typeof(SettingsFooter), + typeof(SettingsOverlay), + }; + + public TestSceneSettingsPanel() { settings = new SettingsOverlay { From 4e5788959ee6e72953e1a17a01ff20adc90e0840 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 3 Jun 2019 13:38:06 +0900 Subject: [PATCH 240/375] Make clickable text actually a button --- osu.Game/Overlays/Settings/SettingsFooter.cs | 47 ++++++++++++++------ 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index 298991712b..7a7f7bdf73 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -5,10 +5,10 @@ using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets; using osuTK; using osuTK.Graphics; @@ -18,9 +18,6 @@ namespace osu.Game.Overlays.Settings { public class SettingsFooter : FillFlowContainer { - [Resolved] - private OsuGameBase game { get; set; } - [Resolved(CanBeNull = true)] private ChangelogOverlay changelog { get; set; } @@ -65,25 +62,49 @@ namespace osu.Game.Overlays.Settings Text = game.Name, Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold), }, - new OsuSpriteText + new BuildDisplay(game.Version, DebugUtils.IsDebug) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Font = OsuFont.GetFont(size: 14), - Text = game.Version, - Colour = DebugUtils.IsDebug ? colours.Red : Color4.White, - }, + } }; } - protected override bool OnClick(ClickEvent e) + private class BuildDisplay : OsuAnimatedButton { - if (game.IsDeployedBuild) + private readonly string version; + private readonly bool isDebug; + + [Resolved] + private OsuColour colours { get; set; } + + public BuildDisplay(string version, bool isDebug) { - changelog?.ShowBuild(OsuGameBase.CLIENT_STREAM_NAME, game.Version); + this.version = version; + this.isDebug = isDebug; + + Content.RelativeSizeAxes = Axes.Y; + Content.AutoSizeAxes = AutoSizeAxes = Axes.X; + Height = 20; } - return true; + [BackgroundDependencyLoader(true)] + private void load(ChangelogOverlay changelog) + { + if (!isDebug) + Action = () => changelog?.ShowBuild(OsuGameBase.CLIENT_STREAM_NAME, version); + + Add(new OsuSpriteText + { + Font = OsuFont.GetFont(size: 16), + + Text = version, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Padding = new MarginPadding(5), + Colour = isDebug ? colours.Red : Color4.White, + }); + } } } } From 3ef17a54f671b181bdd2bd599f3be9d818abac58 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 3 Jun 2019 13:53:24 +0900 Subject: [PATCH 241/375] Fix sizing of OsuAnimatedButton and OsuClickableContainer Was incorrect under some combinations of relative and autosize usage. --- .../TestSceneOsuAnimatedButton.cs | 73 +++++++++++++++++++ .../Containers/OsuClickableContainer.cs | 2 +- .../UserInterface/OsuAnimatedButton.cs | 6 ++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Tests/Visual/UserInterface/TestSceneOsuAnimatedButton.cs diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuAnimatedButton.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuAnimatedButton.cs new file mode 100644 index 0000000000..4bee3907f5 --- /dev/null +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuAnimatedButton.cs @@ -0,0 +1,73 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using osu.Framework.Graphics; +using osu.Framework.Testing; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; +using osuTK; + +namespace osu.Game.Tests.Visual.UserInterface +{ + public class TestSceneOsuAnimatedButton : GridTestScene + { + public TestSceneOsuAnimatedButton() + : base(3, 2) + { + Cell(0).Add(new BaseContainer("relative sized") + { + RelativeSizeAxes = Axes.Both, + }); + + Cell(1).Add(new BaseContainer("auto sized") + { + AutoSizeAxes = Axes.Both + }); + + Cell(2).Add(new BaseContainer("relative Y auto X") + { + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X + }); + + Cell(3).Add(new BaseContainer("relative X auto Y") + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y + }); + + Cell(4).Add(new BaseContainer("fixed") + { + Size = new Vector2(100), + }); + + Cell(5).Add(new BaseContainer("fixed") + { + Size = new Vector2(100, 50), + }); + + AddToggleStep("toggle enabled", toggle => + { + for (int i = 0; i < 6; i++) + ((BaseContainer)Cell(i).Child).Action = toggle ? () => { } : (Action)null; + }); + } + + public class BaseContainer : OsuAnimatedButton + { + public BaseContainer(string text) + { + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + + Add(new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Text = text + }); + } + } + } +} diff --git a/osu.Game/Graphics/Containers/OsuClickableContainer.cs b/osu.Game/Graphics/Containers/OsuClickableContainer.cs index 6dbe340efb..1f31e4cdda 100644 --- a/osu.Game/Graphics/Containers/OsuClickableContainer.cs +++ b/osu.Game/Graphics/Containers/OsuClickableContainer.cs @@ -31,7 +31,7 @@ namespace osu.Game.Graphics.Containers { if (AutoSizeAxes != Axes.None) { - content.RelativeSizeAxes = RelativeSizeAxes; + content.RelativeSizeAxes = (Axes.Both & ~AutoSizeAxes); content.AutoSizeAxes = AutoSizeAxes; } diff --git a/osu.Game/Graphics/UserInterface/OsuAnimatedButton.cs b/osu.Game/Graphics/UserInterface/OsuAnimatedButton.cs index a8041c79fc..236b72766f 100644 --- a/osu.Game/Graphics/UserInterface/OsuAnimatedButton.cs +++ b/osu.Game/Graphics/UserInterface/OsuAnimatedButton.cs @@ -74,6 +74,12 @@ namespace osu.Game.Graphics.UserInterface [BackgroundDependencyLoader] private void load(OsuColour colours) { + if (AutoSizeAxes != Axes.None) + { + content.RelativeSizeAxes = (Axes.Both & ~AutoSizeAxes); + content.AutoSizeAxes = AutoSizeAxes; + } + Enabled.BindValueChanged(enabled => this.FadeColour(enabled.NewValue ? Color4.White : colours.Gray9, 200, Easing.OutQuint), true); } From 65e3b7c2ae35840c53f0bbd06c388997af9a2054 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 3 Jun 2019 13:58:55 +0900 Subject: [PATCH 242/375] Remove unused DI --- osu.Game/Overlays/Settings/SettingsFooter.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index 7a7f7bdf73..b5ee4b4f0c 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -18,9 +18,6 @@ namespace osu.Game.Overlays.Settings { public class SettingsFooter : FillFlowContainer { - [Resolved(CanBeNull = true)] - private ChangelogOverlay changelog { get; set; } - [BackgroundDependencyLoader] private void load(OsuGameBase game, OsuColour colours, RulesetStore rulesets) { From 171fc14776f193958722b24e573edefc3b493a3a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 3 Jun 2019 16:33:45 +0900 Subject: [PATCH 243/375] Fix editor regressions --- osu.Game/Graphics/UserInterface/IconButton.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Graphics/UserInterface/IconButton.cs b/osu.Game/Graphics/UserInterface/IconButton.cs index 6414e488e8..052e9194fa 100644 --- a/osu.Game/Graphics/UserInterface/IconButton.cs +++ b/osu.Game/Graphics/UserInterface/IconButton.cs @@ -66,6 +66,7 @@ namespace osu.Game.Graphics.UserInterface set { Content.RelativeSizeAxes = Axes.None; + Content.AutoSizeAxes = Axes.None; Content.Size = value; } } From 491c9e96e078004025613c05faa97a49faa89f37 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 3 Jun 2019 16:41:27 +0900 Subject: [PATCH 244/375] Fix tests not ending execution after some exceptions --- osu.Game/Tests/Visual/OsuTestScene.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Tests/Visual/OsuTestScene.cs b/osu.Game/Tests/Visual/OsuTestScene.cs index 9b775fd498..d03b490bd4 100644 --- a/osu.Game/Tests/Visual/OsuTestScene.cs +++ b/osu.Game/Tests/Visual/OsuTestScene.cs @@ -61,7 +61,8 @@ namespace osu.Game.Tests.Visual { base.Dispose(isDisposing); - beatmap?.Value.Track.Stop(); + if (beatmap?.Value.TrackLoaded == true) + beatmap.Value.Track.Stop(); if (localStorage.IsValueCreated) { From 17d04545fad1d6977fdd8a67761d46e4fb5bb059 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 3 Jun 2019 16:45:18 +0900 Subject: [PATCH 245/375] Localise GridTestScene as an OsuGridTestScene --- .../Visual/UserInterface/TestSceneLoadingAnimation.cs | 3 +-- .../Visual/UserInterface/TestSceneOsuAnimatedButton.cs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingAnimation.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingAnimation.cs index b9a6d74f19..b0233d35f9 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingAnimation.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingAnimation.cs @@ -3,13 +3,12 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; -using osu.Framework.Testing; using osu.Game.Graphics.UserInterface; using osuTK.Graphics; namespace osu.Game.Tests.Visual.UserInterface { - public class TestSceneLoadingAnimation : GridTestScene //todo: this should be an OsuTestScene + public class TestSceneLoadingAnimation : OsuGridTestScene { public TestSceneLoadingAnimation() : base(2, 2) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuAnimatedButton.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuAnimatedButton.cs index 4bee3907f5..6a41d08f01 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuAnimatedButton.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuAnimatedButton.cs @@ -3,14 +3,13 @@ using System; using osu.Framework.Graphics; -using osu.Framework.Testing; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osuTK; namespace osu.Game.Tests.Visual.UserInterface { - public class TestSceneOsuAnimatedButton : GridTestScene + public class TestSceneOsuAnimatedButton : OsuGridTestScene { public TestSceneOsuAnimatedButton() : base(3, 2) From e32f62db5bdf473579ee062a67d7c765fb95e2ae Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 3 Jun 2019 16:48:44 +0900 Subject: [PATCH 246/375] Add missing file --- .../Visual/UserInterface/OsuGridTestScene.cs | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 osu.Game.Tests/Visual/UserInterface/OsuGridTestScene.cs diff --git a/osu.Game.Tests/Visual/UserInterface/OsuGridTestScene.cs b/osu.Game.Tests/Visual/UserInterface/OsuGridTestScene.cs new file mode 100644 index 0000000000..096ac951de --- /dev/null +++ b/osu.Game.Tests/Visual/UserInterface/OsuGridTestScene.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.Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; + +namespace osu.Game.Tests.Visual.UserInterface +{ + /// + /// An abstract test case which exposes small cells arranged in a grid. + /// Useful for displaying multiple configurations of a tested component at a glance. + /// + public abstract class OsuGridTestScene : OsuTestScene + { + private readonly Drawable[,] cells; + + /// + /// The amount of rows in the grid. + /// + protected readonly int Rows; + + /// + /// The amount of columns in the grid. + /// + protected readonly int Cols; + + /// + /// Constructs a grid test case with the given dimensions. + /// + protected OsuGridTestScene(int rows, int cols) + { + Rows = rows; + Cols = cols; + + GridContainer testContainer; + Add(testContainer = new GridContainer { RelativeSizeAxes = Axes.Both }); + + cells = new Drawable[rows, cols]; + for (int r = 0; r < rows; r++) + for (int c = 0; c < cols; c++) + cells[r, c] = new Container { RelativeSizeAxes = Axes.Both }; + + testContainer.Content = cells.ToJagged(); + } + + protected Container Cell(int index) => (Container)cells[index / Cols, index % Cols]; + protected Container Cell(int row, int col) => (Container)cells[row, col]; + } +} From 1eab4e179ddb5583ded246af115edafdc41b89c1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 3 Jun 2019 17:05:35 +0900 Subject: [PATCH 247/375] Add sample action to test so hover effect is visible --- osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs b/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs index 0d6d378f4c..936842bdfa 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs @@ -23,6 +23,7 @@ namespace osu.Game.Tests.Visual.Online { Anchor = Anchor.Centre, Origin = Anchor.Centre, + Action = () => { } }); AddStep("switch loading state", () => button.IsLoading = !button.IsLoading); From c4f4f32db8a24f97922000610172e672d5e03e48 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 3 Jun 2019 17:06:07 +0900 Subject: [PATCH 248/375] Shorten fade duration --- osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs b/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs index 31c73aaa96..6b7c37b42d 100644 --- a/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs +++ b/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs @@ -18,6 +18,8 @@ namespace osu.Game.Overlays.Profile.Sections { public class ShowMoreButton : OsuHoverContainer { + private const float fade_duration = 200; + private readonly Box background; private readonly LoadingAnimation loading; private readonly FillFlowContainer content; @@ -38,13 +40,13 @@ namespace osu.Game.Overlays.Profile.Sections if (value) { - loading.FadeIn(FADE_DURATION, Easing.OutQuint); - content.FadeOut(FADE_DURATION, Easing.OutQuint); + loading.FadeIn(fade_duration, Easing.OutQuint); + content.FadeOut(fade_duration, Easing.OutQuint); } else { - loading.FadeOut(FADE_DURATION, Easing.OutQuint); - content.FadeIn(FADE_DURATION, Easing.OutQuint); + loading.FadeOut(fade_duration, Easing.OutQuint); + content.FadeIn(fade_duration, Easing.OutQuint); } } } From 633c3b74ec5b746de3565a2dfe234641cfae1bea Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 3 Jun 2019 17:10:18 +0900 Subject: [PATCH 249/375] Don't handle clicks when in a loading state --- osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs b/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs index 6b7c37b42d..328a1fa6b7 100644 --- a/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs +++ b/osu.Game/Overlays/Profile/Sections/ShowMoreButton.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.Allocation; @@ -38,6 +38,8 @@ namespace osu.Game.Overlays.Profile.Sections isLoading = value; + Enabled.Value = !isLoading; + if (value) { loading.FadeIn(fade_duration, Easing.OutQuint); From 4e6d7137aa370d89c7a8381ffb1e41c357a77c10 Mon Sep 17 00:00:00 2001 From: LeNitrous Date: Mon, 3 Jun 2019 17:25:19 +0800 Subject: [PATCH 250/375] disallow current user from opening their own private channel --- osu.Game/Online/Chat/ChannelManager.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Online/Chat/ChannelManager.cs b/osu.Game/Online/Chat/ChannelManager.cs index 2efc9f4968..3af11ff20f 100644 --- a/osu.Game/Online/Chat/ChannelManager.cs +++ b/osu.Game/Online/Chat/ChannelManager.cs @@ -81,6 +81,9 @@ namespace osu.Game.Online.Chat if (user == null) throw new ArgumentNullException(nameof(user)); + if (user.Id == api.LocalUser.Value.Id) + return; + CurrentChannel.Value = JoinedChannels.FirstOrDefault(c => c.Type == ChannelType.PM && c.Users.Count == 1 && c.Users.Any(u => u.Id == user.Id)) ?? new Channel(user); } From 516575a132fead92342b62aa02da527ebbccabe2 Mon Sep 17 00:00:00 2001 From: LeNitrous Date: Mon, 3 Jun 2019 18:54:29 +0800 Subject: [PATCH 251/375] don't create "Start Chat" option when the sender is the local user --- osu.Game/Overlays/Chat/ChatLine.cs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatLine.cs b/osu.Game/Overlays/Chat/ChatLine.cs index 66a6672ab1..86bbe91d35 100644 --- a/osu.Game/Overlays/Chat/ChatLine.cs +++ b/osu.Game/Overlays/Chat/ChatLine.cs @@ -3,6 +3,7 @@ using System; using System.Linq; +using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -14,6 +15,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; +using osu.Game.Online.API; using osu.Game.Online.Chat; using osu.Game.Users; using osuTK; @@ -201,6 +203,9 @@ namespace osu.Game.Overlays.Chat private Action startChatAction; + [Resolved] + private IAPIProvider api { get; set; } + public MessageSender(User sender) { this.sender = sender; @@ -213,11 +218,21 @@ namespace osu.Game.Overlays.Chat startChatAction = () => chatManager?.OpenPrivateChannel(sender); } - public MenuItem[] ContextMenuItems => new MenuItem[] + public MenuItem[] ContextMenuItems { - new OsuMenuItem("View Profile", MenuItemType.Highlighted, Action), - new OsuMenuItem("Start Chat", MenuItemType.Standard, startChatAction), - }; + get + { + List items = new List + { + new OsuMenuItem("View Profile", MenuItemType.Highlighted, Action) + }; + + if (sender.Id != api.LocalUser.Value.Id) + items.Add(new OsuMenuItem("Start Chat", MenuItemType.Standard, startChatAction)); + + return items.ToArray(); + } + } } private static readonly Color4[] username_colours = From 194bb80354d7f8d49ed64ba26ac493e53c092151 Mon Sep 17 00:00:00 2001 From: Welsar55 Date: Mon, 3 Jun 2019 11:09:21 -0500 Subject: [PATCH 252/375] Added close button and indictors of hotkeys to buttons --- osu.Game/Overlays/Mods/ModSection.cs | 6 +----- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 25 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSection.cs b/osu.Game/Overlays/Mods/ModSection.cs index f584eff0f9..50400e254f 100644 --- a/osu.Game/Overlays/Mods/ModSection.cs +++ b/osu.Game/Overlays/Mods/ModSection.cs @@ -57,11 +57,7 @@ namespace osu.Game.Overlays.Mods protected override bool OnKeyDown(KeyDownEvent e) { - if(e.Key == Key.Number1) - { - DeselectAll(); - } - else if (ToggleKeys != null) + if (ToggleKeys != null) { var index = Array.IndexOf(ToggleKeys, e.Key); if (index > -1 && index < buttons.Length) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 97769fe5aa..c304dc2eb3 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osuTK; +using osuTK.Input; using osuTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; @@ -23,6 +24,7 @@ using osu.Game.Rulesets; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.Mods.Sections; using osu.Game.Screens; +using osu.Framework.Input.Events; namespace osu.Game.Overlays.Mods { @@ -33,6 +35,7 @@ namespace osu.Game.Overlays.Mods protected Color4 LowMultiplierColour, HighMultiplierColour; protected readonly TriangleButton DeselectAllButton; + protected readonly TriangleButton CloseButton; protected readonly OsuSpriteText MultiplierLabel, UnrankedLabel; private readonly FillFlowContainer footerContainer; @@ -192,6 +195,16 @@ namespace osu.Game.Overlays.Mods refreshSelectedMods(); } + protected override bool OnKeyDown(KeyDownEvent e) + { + if (e.Key == Key.Number1) + DeselectAll(); + else if (e.Key == Key.Number2) + PopOut(); + + return base.OnKeyDown(e); + } + private void refreshSelectedMods() => SelectedMods.Value = ModSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray(); public ModSelectOverlay() @@ -357,13 +370,23 @@ namespace osu.Game.Overlays.Mods DeselectAllButton = new TriangleButton { Width = 180, - Text = "Deselect All", + Text = "1. Deselect All", Action = DeselectAll, Margin = new MarginPadding { Right = 20 } }, + CloseButton = new TriangleButton + { + Width = 180, + Text = "2. Close", + Action = PopOut, + Margin = new MarginPadding + { + Right = 20 + } + }, new OsuSpriteText { Text = @"Score Multiplier:", From fe6b4112c6e5244779ada7ed0eea1ca805522c50 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 4 Jun 2019 01:47:45 +0300 Subject: [PATCH 253/375] Adjust colors to match web design --- osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs b/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs index 328a1fa6b7..485595798d 100644 --- a/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs +++ b/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs @@ -102,8 +102,8 @@ namespace osu.Game.Overlays.Profile.Sections [BackgroundDependencyLoader] private void load(OsuColour colors) { - IdleColour = colors.GreySeafoam; - HoverColour = colors.GreySeafoamLight; + IdleColour = colors.GreySeafoamDark; + HoverColour = colors.GreySeafoam; } protected override bool OnClick(ClickEvent e) From 2c713712820d9f9a3152e1fc67143eb1fb730fca Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 4 Jun 2019 02:06:15 +0300 Subject: [PATCH 254/375] Fix endless loading state --- osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs b/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs index 485595798d..82554faac8 100644 --- a/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs +++ b/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs @@ -38,8 +38,6 @@ namespace osu.Game.Overlays.Profile.Sections isLoading = value; - Enabled.Value = !isLoading; - if (value) { loading.FadeIn(fade_duration, Easing.OutQuint); @@ -108,6 +106,9 @@ namespace osu.Game.Overlays.Profile.Sections protected override bool OnClick(ClickEvent e) { + if (IsLoading) + return true; + IsLoading = true; return base.OnClick(e); } From d5a2ebf79f3f4b6e7633b7faf92b4a4ce35aa9c9 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 4 Jun 2019 04:04:33 +0300 Subject: [PATCH 255/375] Fix endless loading state part 2 --- .../Overlays/Profile/Sections/ShowMoreButton.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs b/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs index 82554faac8..a1dcfc036e 100644 --- a/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs +++ b/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs @@ -38,6 +38,8 @@ namespace osu.Game.Overlays.Profile.Sections isLoading = value; + Enabled.Value = !isLoading; + if (value) { loading.FadeIn(fade_duration, Easing.OutQuint); @@ -106,11 +108,14 @@ namespace osu.Game.Overlays.Profile.Sections protected override bool OnClick(ClickEvent e) { - if (IsLoading) - return true; + var clickResult = base.OnClick(e); - IsLoading = true; - return base.OnClick(e); + if (IsLoading) + return clickResult; + + IsLoading |= clickResult; + + return clickResult; } private class ChevronIcon : SpriteIcon From e8315085c0021a1fcdd1e2fff515673915c11ddc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 4 Jun 2019 10:26:21 +0900 Subject: [PATCH 256/375] Better handle OnClick --- .../Profile/Sections/ShowMoreButton.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs b/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs index a1dcfc036e..5ed546c62b 100644 --- a/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs +++ b/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs @@ -108,14 +108,18 @@ namespace osu.Game.Overlays.Profile.Sections protected override bool OnClick(ClickEvent e) { - var clickResult = base.OnClick(e); + if (!Enabled.Value) + return false; - if (IsLoading) - return clickResult; - - IsLoading |= clickResult; - - return clickResult; + try + { + return base.OnClick(e); + } + finally + { + // run afterwards as this will disable this button. + IsLoading = true; + } } private class ChevronIcon : SpriteIcon From a5a025de6867edbfb70cf13df58353da4ea044cc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 4 Jun 2019 10:26:35 +0900 Subject: [PATCH 257/375] Add proper tests --- .../Visual/Online/TestSceneShowMoreButton.cs | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs b/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs index 936842bdfa..bccb263600 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs @@ -17,16 +17,39 @@ namespace osu.Game.Tests.Visual.Online public TestSceneShowMoreButton() { - ShowMoreButton button; + ShowMoreButton button = null; + + int fireCount = 0; Add(button = new ShowMoreButton { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Action = () => { } + Action = () => + { + fireCount++; + // ReSharper disable once AccessToModifiedClosure + // ReSharper disable once PossibleNullReferenceException + Scheduler.AddDelayed(() => button.IsLoading = false, 2000); + } }); - AddStep("switch loading state", () => button.IsLoading = !button.IsLoading); + AddStep("click button", () => button.Click()); + + AddAssert("action fired once", () => fireCount == 1); + AddAssert("is in loading state", () => button.IsLoading); + + AddStep("click button", () => button.Click()); + + AddAssert("action not fired", () => fireCount == 1); + AddAssert("is in loading state", () => button.IsLoading); + + AddUntilStep("wait for loaded", () => !button.IsLoading); + + AddStep("click button", () => button.Click()); + + AddAssert("action fired twice", () => fireCount == 2); + AddAssert("is in loading state", () => button.IsLoading); } } } From cea353975fd46ff4eeb52dd9970eb2fa6fed19f3 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 4 Jun 2019 11:04:28 +0900 Subject: [PATCH 258/375] Update with further framework-side changes --- .../Visual/Editor/TestSceneWaveform.cs | 5 +---- ...tSceneUpdateableBeatmapBackgroundSprite.cs | 2 +- .../Beatmaps/BeatmapManager_WorkingBeatmap.cs | 2 +- .../UpdateableBeatmapBackgroundSprite.cs | 21 +++---------------- .../Overlays/Changelog/UpdateStreamBadge.cs | 4 ++-- osu.Game/Overlays/ChangelogOverlay.cs | 2 +- .../Screens/Multi/Match/Components/Header.cs | 2 +- 7 files changed, 10 insertions(+), 28 deletions(-) diff --git a/osu.Game.Tests/Visual/Editor/TestSceneWaveform.cs b/osu.Game.Tests/Visual/Editor/TestSceneWaveform.cs index 7b27998d7f..e2762f3d5f 100644 --- a/osu.Game.Tests/Visual/Editor/TestSceneWaveform.cs +++ b/osu.Game.Tests/Visual/Editor/TestSceneWaveform.cs @@ -21,13 +21,10 @@ namespace osu.Game.Tests.Visual.Editor { private WorkingBeatmap waveformBeatmap; - private OsuGameBase game; - [BackgroundDependencyLoader] - private void load(AudioManager audio, OsuGameBase game) + private void load(AudioManager audio) { waveformBeatmap = new WaveformTestBeatmap(audio); - this.game = game; } [TestCase(1f)] diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs index 23065629a6..d39358a972 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs @@ -41,7 +41,7 @@ namespace osu.Game.Tests.Visual.UserInterface TestUpdateableBeatmapBackgroundSprite background = null; AddStep("load null beatmap", () => Child = background = new TestUpdateableBeatmapBackgroundSprite { RelativeSizeAxes = Axes.Both }); - AddUntilStep("wait for load", () => background.ContentLoaded); + AddAssert("no content", () => !background.ContentLoaded); } [Test] diff --git a/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs b/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs index e1cc5db3ad..4b1bddbf0d 100644 --- a/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs @@ -45,7 +45,7 @@ namespace osu.Game.Beatmaps private TextureStore textureStore; - private IAdjustableResourceStore trackStore; + private ITrackStore trackStore; protected override bool BackgroundStillValid(Texture b) => false; // bypass lazy logic. we want to return a new background each time for refcounting purposes. diff --git a/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs index 96786f5f49..1fd3502799 100644 --- a/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs +++ b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -31,24 +32,8 @@ namespace osu.Game.Beatmaps.Drawables /// protected virtual double UnloadDelay => 10000; - private BeatmapInfo lastModel; - private bool firstLoad = true; - - protected override DelayedLoadWrapper CreateDelayedLoadWrapper(Drawable content, double timeBeforeLoad) - { - return new DelayedLoadUnloadWrapper(() => - { - // If DelayedLoadUnloadWrapper is attempting to RELOAD the same content (Beatmap), that means that it was - // previously UNLOADED and thus its children have been disposed of, so we need to recreate them here. - if (!firstLoad && lastModel == Beatmap.Value) - return CreateDrawable(Beatmap.Value); - - // If the model has changed since the previous unload (or if there was no load), then we can safely use the given content - lastModel = Beatmap.Value; - firstLoad = false; - return content; - }, timeBeforeLoad, UnloadDelay); - } + protected override DelayedLoadWrapper CreateDelayedLoadWrapper(Func createContentFunc, double timeBeforeLoad) + => new DelayedLoadUnloadWrapper(createContentFunc, timeBeforeLoad, UnloadDelay); protected override Drawable CreateDrawable(BeatmapInfo model) { diff --git a/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs b/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs index 514e75c31a..52b77604d9 100644 --- a/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs +++ b/osu.Game/Overlays/Changelog/UpdateStreamBadge.cs @@ -90,8 +90,8 @@ namespace osu.Game.Overlays.Changelog [BackgroundDependencyLoader] private void load(AudioManager audio) { - sampleClick = audio.Sample.Get(@"UI/generic-select-soft"); - sampleHover = audio.Sample.Get(@"UI/generic-hover-soft"); + sampleClick = audio.Samples.Get(@"UI/generic-select-soft"); + sampleHover = audio.Samples.Get(@"UI/generic-hover-soft"); } protected override void OnActivated() => updateState(); diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 7d791b2a88..4a6d53b480 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -76,7 +76,7 @@ namespace osu.Game.Overlays }, }; - sampleBack = audio.Sample.Get(@"UI/generic-select-soft"); + sampleBack = audio.Samples.Get(@"UI/generic-select-soft"); header.Current.BindTo(Current); diff --git a/osu.Game/Screens/Multi/Match/Components/Header.cs b/osu.Game/Screens/Multi/Match/Components/Header.cs index 2a6074882d..73994fa369 100644 --- a/osu.Game/Screens/Multi/Match/Components/Header.cs +++ b/osu.Game/Screens/Multi/Match/Components/Header.cs @@ -137,7 +137,7 @@ namespace osu.Game.Screens.Multi.Match.Components private class BackgroundSprite : UpdateableBeatmapBackgroundSprite { - protected override double FadeDuration => 200; + protected override double TransformDuration => 200; } } } From 474191fcec71e49c6fb1ca95c3b5972c76dbbb2c Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 4 Jun 2019 11:13:21 +0900 Subject: [PATCH 259/375] Update framework --- osu.Game/osu.Game.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index b77c724d1b..f84bb64fbf 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -15,7 +15,7 @@ - + From 4763a41c7ed32f6920a8ac0edf357edc292017fd Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 4 Jun 2019 11:25:18 +0900 Subject: [PATCH 260/375] Cleanups --- .../Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs | 3 --- osu.Game/Beatmaps/BindableBeatmap.cs | 2 -- osu.Game/Beatmaps/DummyWorkingBeatmap.cs | 2 +- osu.Game/Beatmaps/WorkingBeatmap.cs | 6 +++--- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs index de4f4d9d25..8091e93471 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs @@ -18,9 +18,6 @@ namespace osu.Game.Tests.Visual.Multiplayer { public class TestSceneMatchSettingsOverlay : MultiplayerTestScene { - [Resolved] - private OsuGameBase game { get; set; } - public override IReadOnlyList RequiredTypes => new[] { typeof(MatchSettingsOverlay) diff --git a/osu.Game/Beatmaps/BindableBeatmap.cs b/osu.Game/Beatmaps/BindableBeatmap.cs index 1e69a17ef7..af627cc6a9 100644 --- a/osu.Game/Beatmaps/BindableBeatmap.cs +++ b/osu.Game/Beatmaps/BindableBeatmap.cs @@ -24,8 +24,6 @@ namespace osu.Game.Beatmaps { var trackLoaded = lastBeatmap?.TrackLoaded ?? false; - //beatmap.AudioManager = AudioManager; - // compare to last beatmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo) if (!trackLoaded || lastBeatmap?.Track != beatmap.Track) { diff --git a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs index 9202c617bf..3a4c677bd1 100644 --- a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs +++ b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs @@ -44,7 +44,7 @@ namespace osu.Game.Beatmaps protected override Texture GetBackground() => textures?.Get(@"Backgrounds/bg4"); - protected override Track GetTrack() => GetVirtualTrack(Beatmap); + protected override Track GetTrack() => GetVirtualTrack(); private class DummyRulesetInfo : RulesetInfo { diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index cf1acaf46b..328763fc9f 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -51,18 +51,18 @@ namespace osu.Game.Beatmaps return b; }); - track = new RecyclableLazy(() => GetTrack() ?? GetVirtualTrack(Beatmap)); + track = new RecyclableLazy(() => GetTrack() ?? GetVirtualTrack()); background = new RecyclableLazy(GetBackground, BackgroundStillValid); waveform = new RecyclableLazy(GetWaveform); storyboard = new RecyclableLazy(GetStoryboard); skin = new RecyclableLazy(GetSkin); } - protected virtual Track GetVirtualTrack(IBeatmap beatmap) + protected virtual Track GetVirtualTrack() { const double excess_length = 1000; - var lastObject = beatmap.HitObjects.LastOrDefault(); + var lastObject = Beatmap.HitObjects.LastOrDefault(); double length; From b8fc53512453ed87730c399e23ed0b5134ec7e5e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 4 Jun 2019 12:08:23 +0900 Subject: [PATCH 261/375] Fix blueprint tests crashing due to out-of-order operations --- osu.Game/Tests/Visual/PlacementBlueprintTestScene.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Tests/Visual/PlacementBlueprintTestScene.cs b/osu.Game/Tests/Visual/PlacementBlueprintTestScene.cs index c1561ffea1..2b177e264f 100644 --- a/osu.Game/Tests/Visual/PlacementBlueprintTestScene.cs +++ b/osu.Game/Tests/Visual/PlacementBlueprintTestScene.cs @@ -15,19 +15,18 @@ namespace osu.Game.Tests.Visual [Cached(Type = typeof(IPlacementHandler))] public abstract class PlacementBlueprintTestScene : OsuTestScene, IPlacementHandler { - protected readonly Container HitObjectContainer; + protected Container HitObjectContainer; private PlacementBlueprint currentBlueprint; protected PlacementBlueprintTestScene() { - Beatmap.Value.BeatmapInfo.BaseDifficulty.CircleSize = 2; - Add(HitObjectContainer = CreateHitObjectContainer()); } [BackgroundDependencyLoader] private void load() { + Beatmap.Value.BeatmapInfo.BaseDifficulty.CircleSize = 2; Add(currentBlueprint = CreateBlueprint()); } From 9c214c3f0ec9e8a09f46b2a276a043d55dd38c67 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 4 Jun 2019 16:13:16 +0900 Subject: [PATCH 262/375] Add animation on failing --- .../Visual/Gameplay/TestSceneFailAnimation.cs | 50 ++++++++ .../Visual/Gameplay/TestScenePause.cs | 2 +- osu.Game/Rulesets/UI/DrawableRuleset.cs | 7 +- osu.Game/Screens/Play/FailAnimation.cs | 113 ++++++++++++++++++ osu.Game/Screens/Play/Player.cs | 26 +++- 5 files changed, 191 insertions(+), 7 deletions(-) create mode 100644 osu.Game.Tests/Visual/Gameplay/TestSceneFailAnimation.cs create mode 100644 osu.Game/Screens/Play/FailAnimation.cs diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneFailAnimation.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneFailAnimation.cs new file mode 100644 index 0000000000..4878587dcd --- /dev/null +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneFailAnimation.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 System; +using System.Collections.Generic; +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets; +using osu.Game.Rulesets.Mods; +using osu.Game.Screens.Play; + +namespace osu.Game.Tests.Visual.Gameplay +{ + public class TestSceneFailAnimation : AllPlayersTestScene + { + protected override Player CreatePlayer(Ruleset ruleset) + { + Mods.Value = Array.Empty(); + return new FailPlayer(); + } + + public override IReadOnlyList RequiredTypes => new[] + { + typeof(AllPlayersTestScene), + typeof(TestPlayer), + typeof(Player), + }; + + protected override void AddCheckSteps() + { + AddUntilStep("wait for fail", () => Player.HasFailed); + AddUntilStep("wait for fail overlay", () => ((FailPlayer)Player).FailOverlay.State == Visibility.Visible); + } + + private class FailPlayer : TestPlayer + { + public new FailOverlay FailOverlay => base.FailOverlay; + + public FailPlayer() + : base(false, false) + { + } + + protected override void LoadComplete() + { + base.LoadComplete(); + ScoreProcessor.FailConditions += _ => true; + } + } + } +} diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs index b6f8638f4a..12e91df77c 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs @@ -113,7 +113,7 @@ namespace osu.Game.Tests.Visual.Gameplay public void TestPauseAfterFail() { AddUntilStep("wait for fail", () => Player.HasFailed); - AddAssert("fail overlay shown", () => Player.FailOverlayVisible); + AddUntilStep("fail overlay shown", () => Player.FailOverlayVisible); confirmClockRunning(false); diff --git a/osu.Game/Rulesets/UI/DrawableRuleset.cs b/osu.Game/Rulesets/UI/DrawableRuleset.cs index 7db24d36a5..52fba9cab3 100644 --- a/osu.Game/Rulesets/UI/DrawableRuleset.cs +++ b/osu.Game/Rulesets/UI/DrawableRuleset.cs @@ -53,7 +53,7 @@ namespace osu.Game.Rulesets.UI /// /// The playfield. /// - public Playfield Playfield => playfield.Value; + public override Playfield Playfield => playfield.Value; /// /// Place to put drawables above hit objects but below UI. @@ -342,6 +342,11 @@ namespace osu.Game.Rulesets.UI /// public readonly BindableBool IsPaused = new BindableBool(); + /// + /// The playfield. + /// + public abstract Playfield Playfield { get; } + /// /// The frame-stable clock which is being used for playfield display. /// diff --git a/osu.Game/Screens/Play/FailAnimation.cs b/osu.Game/Screens/Play/FailAnimation.cs new file mode 100644 index 0000000000..a3caffb620 --- /dev/null +++ b/osu.Game/Screens/Play/FailAnimation.cs @@ -0,0 +1,113 @@ +// 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.Audio; +using osu.Framework.Bindables; +using osu.Game.Rulesets.UI; +using System; +using System.Collections.Generic; +using osu.Framework.Allocation; +using osu.Framework.Audio.Sample; +using osu.Framework.Audio.Track; +using osu.Framework.Graphics; +using osu.Framework.MathUtils; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Objects.Drawables; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Screens.Play +{ + /// + /// Manage the animation to be applied when a player fails. + /// Single file; automatically disposed after use. + /// + public class FailAnimation : Component + { + public Action OnComplete; + + private readonly DrawableRuleset drawableRuleset; + + private readonly BindableDouble trackFreq = new BindableDouble(1); + + private Track track; + + private const float duration = 2500; + + private SampleChannel failSample; + + public FailAnimation(DrawableRuleset drawableRuleset) + { + this.drawableRuleset = drawableRuleset; + } + + [BackgroundDependencyLoader] + private void load(AudioManager audio, IBindable beatmap) + { + track = beatmap.Value.Track; + failSample = audio.Samples.Get(@"Gameplay/failsound"); + } + + private bool started; + + /// + /// Start the fail animation playing. + /// + /// Thrown if started more than once. + public void Start() + { + if (started) throw new InvalidOperationException("Animation cannot be started more than once."); + + started = true; + + failSample.Play(); + + this.TransformBindableTo(trackFreq, 0, duration).OnComplete(_ => + { + OnComplete?.Invoke(); + Expire(); + }); + + track.AddAdjustment(AdjustableProperty.Frequency, trackFreq); + + applyToPlayfield(drawableRuleset.Playfield); + drawableRuleset.Playfield.HitObjectContainer.FlashColour(Color4.Red, 500); + drawableRuleset.Playfield.HitObjectContainer.FadeOut(duration / 2); + } + + protected override void Update() + { + base.Update(); + + if (!started) + return; + + applyToPlayfield(drawableRuleset.Playfield); + } + + private readonly List appliedObjects = new List(); + + private void applyToPlayfield(Playfield playfield) + { + foreach (var nested in playfield.NestedPlayfields) + applyToPlayfield(nested); + + foreach (DrawableHitObject obj in playfield.HitObjectContainer.AliveObjects) + { + if (appliedObjects.Contains(obj)) + continue; + + obj.RotateTo(RNG.NextSingle(-90, 90), duration); + obj.ScaleTo(obj.Scale * 0.5f, duration); + obj.MoveToOffset(new Vector2(0, 400), duration); + appliedObjects.Add(obj); + } + } + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + track?.RemoveAdjustment(AdjustableProperty.Frequency, trackFreq); + } + } +} diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index cf743ee4f7..d8389fa6d9 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; @@ -173,7 +173,8 @@ namespace osu.Game.Screens.Play fadeOut(true); Restart(); }, - } + }, + failAnimation = new FailAnimation(DrawableRuleset) { OnComplete = onFailComplete, } }; DrawableRuleset.HasReplayLoaded.BindValueChanged(e => HUDOverlay.HoldToQuit.PauseOnFocusLost = !e.NewValue && PauseOnFocusLost, true); @@ -345,13 +346,13 @@ namespace osu.Game.Screens.Play protected FailOverlay FailOverlay { get; private set; } + private FailAnimation failAnimation; + private bool onFail() { if (Mods.Value.OfType().Any(m => !m.AllowFail)) return false; - GameplayClockContainer.Stop(); - HasFailed = true; // There is a chance that we could be in a paused state as the ruleset's internal clock (see FrameStabilityContainer) @@ -360,9 +361,17 @@ namespace osu.Game.Screens.Play if (PauseOverlay.State == Visibility.Visible) PauseOverlay.Hide(); + failAnimation.Start(); + return true; + } + + // Called back when the transform finishes + private void onFailComplete() + { + GameplayClockContainer.Stop(); + FailOverlay.Retries = RestartCount; FailOverlay.Show(); - return true; } #endregion @@ -489,6 +498,13 @@ namespace osu.Game.Screens.Play // still want to block if we are within the cooldown period and not already paused. return true; + if (HasFailed && ValidForResume && !FailOverlay.IsPresent) + // ValidForResume is false when restarting + { + failAnimation.FinishTransforms(true); + return true; + } + GameplayClockContainer.ResetLocalAdjustments(); fadeOut(); From 7d2a75b3502702aa035a7200fbd30b5885534199 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 4 Jun 2019 18:37:26 +0900 Subject: [PATCH 263/375] Dim music volume when holding to confirm --- osu.Game/Overlays/HoldToConfirmOverlay.cs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/HoldToConfirmOverlay.cs b/osu.Game/Overlays/HoldToConfirmOverlay.cs index fb38ddcbd1..fdc6f096bc 100644 --- a/osu.Game/Overlays/HoldToConfirmOverlay.cs +++ b/osu.Game/Overlays/HoldToConfirmOverlay.cs @@ -2,6 +2,8 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics.Containers; @@ -17,6 +19,11 @@ namespace osu.Game.Overlays { private Box overlay; + private readonly BindableDouble audioVolume = new BindableDouble(1); + + [Resolved] + private AudioManager audio { get; set; } + [BackgroundDependencyLoader] private void load() { @@ -33,7 +40,19 @@ namespace osu.Game.Overlays } }; - Progress.ValueChanged += p => overlay.Alpha = (float)p.NewValue; + Progress.ValueChanged += p => + { + audioVolume.Value = 1 - p.NewValue; + overlay.Alpha = (float)p.NewValue; + }; + + audio.Tracks.AddAdjustment(AdjustableProperty.Volume, audioVolume); + } + + protected override void Dispose(bool isDisposing) + { + audio.Tracks.RemoveAdjustment(AdjustableProperty.Volume, audioVolume); + base.Dispose(isDisposing); } } } From ff647940ca09fd7b0107edb198d44c1d481087e7 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 4 Jun 2019 19:25:34 +0900 Subject: [PATCH 264/375] Fix incorrect assertion --- .../UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs index d39358a972..f59458ef8d 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs @@ -41,7 +41,7 @@ namespace osu.Game.Tests.Visual.UserInterface TestUpdateableBeatmapBackgroundSprite background = null; AddStep("load null beatmap", () => Child = background = new TestUpdateableBeatmapBackgroundSprite { RelativeSizeAxes = Axes.Both }); - AddAssert("no content", () => !background.ContentLoaded); + AddUntilStep("content loaded", () => background.ContentLoaded); } [Test] From 2e3d392a9f66470b6fe7fb3194c92f7b196d8243 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 4 Jun 2019 22:12:55 +0900 Subject: [PATCH 265/375] Mark OsuButton as abstract Not being used directly, so we probably shouldn't support it for now. --- osu.Game/Graphics/UserInterface/OsuButton.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuButton.cs b/osu.Game/Graphics/UserInterface/OsuButton.cs index 7a27f825f6..494d4e4262 100644 --- a/osu.Game/Graphics/UserInterface/OsuButton.cs +++ b/osu.Game/Graphics/UserInterface/OsuButton.cs @@ -17,11 +17,11 @@ namespace osu.Game.Graphics.UserInterface /// /// A button with added default sound effects. /// - public class OsuButton : Button + public abstract class OsuButton : Button { private Box hover; - public OsuButton() + protected OsuButton() { Height = 40; From e9c4b521afe76f4b0ec5af79fb0607eb1c1e51e5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 4 Jun 2019 22:26:11 +0900 Subject: [PATCH 266/375] Test github "funding" button --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000000..0c6b80e97e --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: https://osu.ppy.sh/home/support From 5f4d7437bcdafc03434d62446683b5d1692940ae Mon Sep 17 00:00:00 2001 From: Arphox Date: Tue, 4 Jun 2019 21:30:49 +0200 Subject: [PATCH 267/375] Fix the issue When Enabled's value has been changed to true, it will now check if it is currently howered, and if yes, it will fade in correctly. --- osu.Game/Graphics/Containers/OsuHoverContainer.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/Containers/OsuHoverContainer.cs b/osu.Game/Graphics/Containers/OsuHoverContainer.cs index eb2d926424..d7dcd5b699 100644 --- a/osu.Game/Graphics/Containers/OsuHoverContainer.cs +++ b/osu.Game/Graphics/Containers/OsuHoverContainer.cs @@ -24,6 +24,9 @@ namespace osu.Game.Graphics.Containers { Enabled.ValueChanged += e => { + if (e.NewValue && isHovered) + fadeIn(); + if (!e.NewValue) unhover(); }; @@ -33,11 +36,12 @@ namespace osu.Game.Graphics.Containers protected override bool OnHover(HoverEvent e) { + isHovered = true; + if (!Enabled.Value) return false; - EffectTargets.ForEach(d => d.FadeColour(HoverColour, FADE_DURATION, Easing.OutQuint)); - isHovered = true; + fadeIn(); return base.OnHover(e); } @@ -69,5 +73,10 @@ namespace osu.Game.Graphics.Containers base.LoadComplete(); EffectTargets.ForEach(d => d.FadeColour(IdleColour)); } + + private void fadeIn() + { + EffectTargets.ForEach(d => d.FadeColour(Color4.Black, FADE_DURATION * 10, Easing.OutQuint)); + } } } From 900cd5c4847c91a3bf0b1e20612505db343755d5 Mon Sep 17 00:00:00 2001 From: Arphox Date: Tue, 4 Jun 2019 21:37:10 +0200 Subject: [PATCH 268/375] Restore original values in FadeColour method call --- osu.Game/Graphics/Containers/OsuHoverContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/OsuHoverContainer.cs b/osu.Game/Graphics/Containers/OsuHoverContainer.cs index d7dcd5b699..0e4a5ae5c0 100644 --- a/osu.Game/Graphics/Containers/OsuHoverContainer.cs +++ b/osu.Game/Graphics/Containers/OsuHoverContainer.cs @@ -76,7 +76,7 @@ namespace osu.Game.Graphics.Containers private void fadeIn() { - EffectTargets.ForEach(d => d.FadeColour(Color4.Black, FADE_DURATION * 10, Easing.OutQuint)); + EffectTargets.ForEach(d => d.FadeColour(HoverColour, FADE_DURATION, Easing.OutQuint)); } } } From a6dc5606bc588a52e03b13e9e62916617d95ecc2 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 5 Jun 2019 18:17:43 +0900 Subject: [PATCH 269/375] Allow beatmapsets to be sorted by date added --- osu.Game/Beatmaps/BeatmapManager.cs | 1 + osu.Game/Beatmaps/BeatmapSetInfo.cs | 3 + ...AddDateAddedColumnToBeatmapSet.Designer.cs | 489 ++++++++++++++++++ ...05091246_AddDateAddedColumnToBeatmapSet.cs | 24 + .../Migrations/OsuDbContextModelSnapshot.cs | 2 + .../Select/Carousel/CarouselBeatmapSet.cs | 3 + 6 files changed, 522 insertions(+) create mode 100644 osu.Game/Migrations/20190605091246_AddDateAddedColumnToBeatmapSet.Designer.cs create mode 100644 osu.Game/Migrations/20190605091246_AddDateAddedColumnToBeatmapSet.cs diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 0200dd44ac..b6fe7f88fa 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -342,6 +342,7 @@ namespace osu.Game.Beatmaps OnlineBeatmapSetID = beatmap.BeatmapInfo.BeatmapSet?.OnlineBeatmapSetID, Beatmaps = new List(), Metadata = beatmap.Metadata, + DateAdded = DateTimeOffset.UtcNow }; } diff --git a/osu.Game/Beatmaps/BeatmapSetInfo.cs b/osu.Game/Beatmaps/BeatmapSetInfo.cs index e111f77ba1..390236e053 100644 --- a/osu.Game/Beatmaps/BeatmapSetInfo.cs +++ b/osu.Game/Beatmaps/BeatmapSetInfo.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; @@ -20,6 +21,8 @@ namespace osu.Game.Beatmaps set => onlineBeatmapSetID = value > 0 ? value : null; } + public DateTimeOffset DateAdded { get; set; } + public BeatmapSetOnlineStatus Status { get; set; } = BeatmapSetOnlineStatus.None; public BeatmapMetadata Metadata { get; set; } diff --git a/osu.Game/Migrations/20190605091246_AddDateAddedColumnToBeatmapSet.Designer.cs b/osu.Game/Migrations/20190605091246_AddDateAddedColumnToBeatmapSet.Designer.cs new file mode 100644 index 0000000000..9477369aa0 --- /dev/null +++ b/osu.Game/Migrations/20190605091246_AddDateAddedColumnToBeatmapSet.Designer.cs @@ -0,0 +1,489 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using osu.Game.Database; + +namespace osu.Game.Migrations +{ + [DbContext(typeof(OsuDbContext))] + [Migration("20190605091246_AddDateAddedColumnToBeatmapSet")] + partial class AddDateAddedColumnToBeatmapSet + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.4-servicing-10062"); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("ApproachRate"); + + b.Property("CircleSize"); + + b.Property("DrainRate"); + + b.Property("OverallDifficulty"); + + b.Property("SliderMultiplier"); + + b.Property("SliderTickRate"); + + b.HasKey("ID"); + + b.ToTable("BeatmapDifficulty"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("AudioLeadIn"); + + b.Property("BaseDifficultyID"); + + b.Property("BeatDivisor"); + + b.Property("BeatmapSetInfoID"); + + b.Property("Countdown"); + + b.Property("DistanceSpacing"); + + b.Property("GridSize"); + + b.Property("Hash"); + + b.Property("Hidden"); + + b.Property("LetterboxInBreaks"); + + b.Property("MD5Hash"); + + b.Property("MetadataID"); + + b.Property("OnlineBeatmapID"); + + b.Property("Path"); + + b.Property("RulesetID"); + + b.Property("SpecialStyle"); + + b.Property("StackLeniency"); + + b.Property("StarDifficulty"); + + b.Property("Status"); + + b.Property("StoredBookmarks"); + + b.Property("TimelineZoom"); + + b.Property("Version"); + + b.Property("WidescreenStoryboard"); + + b.HasKey("ID"); + + b.HasIndex("BaseDifficultyID"); + + b.HasIndex("BeatmapSetInfoID"); + + b.HasIndex("Hash"); + + b.HasIndex("MD5Hash"); + + b.HasIndex("MetadataID"); + + b.HasIndex("OnlineBeatmapID") + .IsUnique(); + + b.HasIndex("RulesetID"); + + b.ToTable("BeatmapInfo"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapMetadata", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Artist"); + + b.Property("ArtistUnicode"); + + b.Property("AudioFile"); + + b.Property("AuthorString") + .HasColumnName("Author"); + + b.Property("BackgroundFile"); + + b.Property("PreviewTime"); + + b.Property("Source"); + + b.Property("Tags"); + + b.Property("Title"); + + b.Property("TitleUnicode"); + + b.HasKey("ID"); + + b.ToTable("BeatmapMetadata"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("BeatmapSetInfoID"); + + b.Property("FileInfoID"); + + b.Property("Filename") + .IsRequired(); + + b.HasKey("ID"); + + b.HasIndex("BeatmapSetInfoID"); + + b.HasIndex("FileInfoID"); + + b.ToTable("BeatmapSetFileInfo"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("DateAdded"); + + b.Property("DeletePending"); + + b.Property("Hash"); + + b.Property("MetadataID"); + + b.Property("OnlineBeatmapSetID"); + + b.Property("Protected"); + + b.Property("Status"); + + b.HasKey("ID"); + + b.HasIndex("DeletePending"); + + b.HasIndex("Hash") + .IsUnique(); + + b.HasIndex("MetadataID"); + + b.HasIndex("OnlineBeatmapSetID") + .IsUnique(); + + b.ToTable("BeatmapSetInfo"); + }); + + modelBuilder.Entity("osu.Game.Configuration.DatabasedSetting", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Key") + .HasColumnName("Key"); + + b.Property("RulesetID"); + + b.Property("StringValue") + .HasColumnName("Value"); + + b.Property("Variant"); + + b.HasKey("ID"); + + b.HasIndex("RulesetID", "Variant"); + + b.ToTable("Settings"); + }); + + modelBuilder.Entity("osu.Game.IO.FileInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Hash"); + + b.Property("ReferenceCount"); + + b.HasKey("ID"); + + b.HasIndex("Hash") + .IsUnique(); + + b.HasIndex("ReferenceCount"); + + b.ToTable("FileInfo"); + }); + + modelBuilder.Entity("osu.Game.Input.Bindings.DatabasedKeyBinding", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("IntAction") + .HasColumnName("Action"); + + b.Property("KeysString") + .HasColumnName("Keys"); + + b.Property("RulesetID"); + + b.Property("Variant"); + + b.HasKey("ID"); + + b.HasIndex("IntAction"); + + b.HasIndex("RulesetID", "Variant"); + + b.ToTable("KeyBinding"); + }); + + modelBuilder.Entity("osu.Game.Rulesets.RulesetInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Available"); + + b.Property("InstantiationInfo"); + + b.Property("Name"); + + b.Property("ShortName"); + + b.HasKey("ID"); + + b.HasIndex("Available"); + + b.HasIndex("ShortName") + .IsUnique(); + + b.ToTable("RulesetInfo"); + }); + + modelBuilder.Entity("osu.Game.Scoring.ScoreFileInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("FileInfoID"); + + b.Property("Filename") + .IsRequired(); + + b.Property("ScoreInfoID"); + + b.HasKey("ID"); + + b.HasIndex("FileInfoID"); + + b.HasIndex("ScoreInfoID"); + + b.ToTable("ScoreFileInfo"); + }); + + modelBuilder.Entity("osu.Game.Scoring.ScoreInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Accuracy") + .HasColumnType("DECIMAL(1,4)"); + + b.Property("BeatmapInfoID"); + + b.Property("Combo"); + + b.Property("Date"); + + b.Property("DeletePending"); + + b.Property("Hash"); + + b.Property("MaxCombo"); + + b.Property("ModsJson") + .HasColumnName("Mods"); + + b.Property("OnlineScoreID"); + + b.Property("PP"); + + b.Property("Rank"); + + b.Property("RulesetID"); + + b.Property("StatisticsJson") + .HasColumnName("Statistics"); + + b.Property("TotalScore"); + + b.Property("UserID") + .HasColumnName("UserID"); + + b.Property("UserString") + .HasColumnName("User"); + + b.HasKey("ID"); + + b.HasIndex("BeatmapInfoID"); + + b.HasIndex("OnlineScoreID") + .IsUnique(); + + b.HasIndex("RulesetID"); + + b.ToTable("ScoreInfo"); + }); + + modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("FileInfoID"); + + b.Property("Filename") + .IsRequired(); + + b.Property("SkinInfoID"); + + b.HasKey("ID"); + + b.HasIndex("FileInfoID"); + + b.HasIndex("SkinInfoID"); + + b.ToTable("SkinFileInfo"); + }); + + modelBuilder.Entity("osu.Game.Skinning.SkinInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Creator"); + + b.Property("DeletePending"); + + b.Property("Hash"); + + b.Property("Name"); + + b.HasKey("ID"); + + b.HasIndex("DeletePending"); + + b.HasIndex("Hash") + .IsUnique(); + + b.ToTable("SkinInfo"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapDifficulty", "BaseDifficulty") + .WithMany() + .HasForeignKey("BaseDifficultyID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo", "BeatmapSet") + .WithMany("Beatmaps") + .HasForeignKey("BeatmapSetInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata") + .WithMany("Beatmaps") + .HasForeignKey("MetadataID"); + + b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset") + .WithMany() + .HasForeignKey("RulesetID") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo") + .WithMany("Files") + .HasForeignKey("BeatmapSetInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.IO.FileInfo", "FileInfo") + .WithMany() + .HasForeignKey("FileInfoID") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata") + .WithMany("BeatmapSets") + .HasForeignKey("MetadataID"); + }); + + modelBuilder.Entity("osu.Game.Scoring.ScoreFileInfo", b => + { + b.HasOne("osu.Game.IO.FileInfo", "FileInfo") + .WithMany() + .HasForeignKey("FileInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Scoring.ScoreInfo") + .WithMany("Files") + .HasForeignKey("ScoreInfoID"); + }); + + modelBuilder.Entity("osu.Game.Scoring.ScoreInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapInfo", "Beatmap") + .WithMany("Scores") + .HasForeignKey("BeatmapInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset") + .WithMany() + .HasForeignKey("RulesetID") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b => + { + b.HasOne("osu.Game.IO.FileInfo", "FileInfo") + .WithMany() + .HasForeignKey("FileInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Skinning.SkinInfo") + .WithMany("Files") + .HasForeignKey("SkinInfoID") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/osu.Game/Migrations/20190605091246_AddDateAddedColumnToBeatmapSet.cs b/osu.Game/Migrations/20190605091246_AddDateAddedColumnToBeatmapSet.cs new file mode 100644 index 0000000000..55dc18b6a3 --- /dev/null +++ b/osu.Game/Migrations/20190605091246_AddDateAddedColumnToBeatmapSet.cs @@ -0,0 +1,24 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace osu.Game.Migrations +{ + public partial class AddDateAddedColumnToBeatmapSet : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "DateAdded", + table: "BeatmapSetInfo", + nullable: false, + defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0))); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "DateAdded", + table: "BeatmapSetInfo"); + } + } +} diff --git a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs index f942d357e8..a94b6df33a 100644 --- a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs +++ b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs @@ -166,6 +166,8 @@ namespace osu.Game.Migrations b.Property("ID") .ValueGeneratedOnAdd(); + b.Property("DateAdded"); + b.Property("DeletePending"); b.Property("Hash"); diff --git a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs index 5c334b126c..f1951e27ab 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs @@ -45,6 +45,9 @@ namespace osu.Game.Screens.Select.Carousel case SortMode.Author: return string.Compare(BeatmapSet.Metadata.Author.Username, otherSet.BeatmapSet.Metadata.Author.Username, StringComparison.InvariantCultureIgnoreCase); + case SortMode.DateAdded: + return otherSet.BeatmapSet.DateAdded.CompareTo(BeatmapSet.DateAdded); + case SortMode.Difficulty: return BeatmapSet.MaxStarDifficulty.CompareTo(otherSet.BeatmapSet.MaxStarDifficulty); } From da20be9a4be511ffaf1a194d4bcb7ce72eb888d7 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Wed, 5 Jun 2019 16:59:08 +0200 Subject: [PATCH 270/375] Fetch IAPIProvider via Resolved attribute --- osu.Game/Screens/OsuScreen.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 1402aa1cce..c08d66ce10 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -114,7 +114,8 @@ namespace osu.Game.Screens [Resolved(canBeNull: true)] private OsuLogo logo { get; set; } - private IAPIProvider api; + [Resolved(canBeNull: true)] + private IAPIProvider api { get; set; } protected OsuScreen() { @@ -128,7 +129,6 @@ namespace osu.Game.Screens private void load(OsuGame osu, AudioManager audio, IAPIProvider provider) { sampleExit = audio.Sample.Get(@"UI/screen-back"); - api = provider; } public virtual bool OnPressed(GlobalAction action) From c04c6693c271020409596b796c5c00e8f8a6c3ed Mon Sep 17 00:00:00 2001 From: Welsar55 Date: Wed, 5 Jun 2019 13:01:21 -0500 Subject: [PATCH 271/375] Change close action from PopOut to Hide and switched to TriangleButton.Click() --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index c304dc2eb3..a7ba87e72a 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -198,9 +198,9 @@ namespace osu.Game.Overlays.Mods protected override bool OnKeyDown(KeyDownEvent e) { if (e.Key == Key.Number1) - DeselectAll(); + DeselectAllButton.Click(); else if (e.Key == Key.Number2) - PopOut(); + CloseButton.Click(); return base.OnKeyDown(e); } @@ -381,7 +381,7 @@ namespace osu.Game.Overlays.Mods { Width = 180, Text = "2. Close", - Action = PopOut, + Action = Hide, Margin = new MarginPadding { Right = 20 From 02283380c4b6ee648a741d695a35fa4cc5d6acf4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 6 Jun 2019 13:33:30 +0900 Subject: [PATCH 272/375] Use manual migration --- .../Migrations/20190525060824_SkinSettings.cs | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/osu.Game/Migrations/20190525060824_SkinSettings.cs b/osu.Game/Migrations/20190525060824_SkinSettings.cs index 8bd429ca5c..99237419b7 100644 --- a/osu.Game/Migrations/20190525060824_SkinSettings.cs +++ b/osu.Game/Migrations/20190525060824_SkinSettings.cs @@ -6,25 +6,34 @@ namespace osu.Game.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { - migrationBuilder.AddColumn( - name: "SkinInfoID", - table: "Settings", - nullable: true); + migrationBuilder.Sql(@"create table Settings_dg_tmp + ( + ID INTEGER not null + constraint PK_Settings + primary key autoincrement, + Key TEXT not null, + RulesetID INTEGER, + Value TEXT, + Variant INTEGER, + SkinInfoID int + constraint Settings_SkinInfo_ID_fk + references SkinInfo + on delete restrict + ); - migrationBuilder.CreateIndex( - name: "IX_Settings_SkinInfoID", - table: "Settings", - column: "SkinInfoID"); + insert into Settings_dg_tmp(ID, Key, RulesetID, Value, Variant) select ID, Key, RulesetID, Value, Variant from Settings; - // unsupported by sqlite + drop table Settings; - // migrationBuilder.AddForeignKey( - // name: "FK_Settings_SkinInfo_SkinInfoID", - // table: "Settings", - // column: "SkinInfoID", - // principalTable: "SkinInfo", - // principalColumn: "ID", - // onDelete: ReferentialAction.Restrict); + alter table Settings_dg_tmp rename to Settings; + + create index IX_Settings_RulesetID_Variant + on Settings (RulesetID, Variant); + + create index Settings_SkinInfoID_index + on Settings (SkinInfoID); + + "); } protected override void Down(MigrationBuilder migrationBuilder) From ae438213a52d2a51586e7cd16e131cffa46bd052 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 6 Jun 2019 16:32:43 +0900 Subject: [PATCH 273/375] Remove secondary buffered container from slider body --- .../Objects/Drawables/Pieces/SliderBody.cs | 28 ++----------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs index 25e1aebd18..33b3667c4f 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs @@ -2,13 +2,10 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; -using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Lines; -using osu.Framework.Graphics.Primitives; using osuTK; using osuTK.Graphics; -using osuTK.Graphics.ES30; namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { @@ -19,8 +16,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces private readonly SliderPath path; protected Path Path => path; - private readonly BufferedContainer container; - public float PathRadius { get => path.PathRadius; @@ -44,8 +39,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces return; path.AccentColour = value; - - container.ForceRedraw(); } } @@ -61,8 +54,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces return; path.BorderColour = value; - - container.ForceRedraw(); } } @@ -78,23 +69,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces return; path.BorderSize = value; - - container.ForceRedraw(); } } - public Quad PathDrawQuad => container.ScreenSpaceDrawQuad; - protected SliderBody() { - InternalChild = container = new BufferedContainer - { - RelativeSizeAxes = Axes.Both, - CacheDrawnFrameBuffer = true, - Child = path = new SliderPath { Blending = BlendingMode.None } - }; - - container.Attach(RenderbufferInternalFormat.DepthComponent16); + InternalChild = path = new SliderPath(); } public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => path.ReceivePositionalInputAt(screenSpacePos); @@ -103,11 +83,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces /// Sets the vertices of the path which should be drawn by this . /// /// The vertices - protected void SetVertices(IReadOnlyList vertices) - { - path.Vertices = vertices; - container.ForceRedraw(); - } + protected void SetVertices(IReadOnlyList vertices) => path.Vertices = vertices; private class SliderPath : SmoothPath { From c7d0fcd42ad4b171b0f7b5e1c273fb1bcc08607a Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 6 Jun 2019 16:33:14 +0900 Subject: [PATCH 274/375] Update drawnodes --- osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs | 3 ++- osu.Game/Graphics/Backgrounds/Triangles.cs | 4 ++-- osu.Game/Rulesets/Mods/ModFlashlight.cs | 2 +- osu.Game/Screens/Menu/LogoVisualisation.cs | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs index 1b8fa0de01..1bc22da8ac 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs @@ -210,7 +210,8 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor Vector2 pos = parts[i].Position; float localTime = parts[i].Time; - texture.DrawQuad( + DrawQuad( + texture, new Quad(pos.X - size.X / 2, pos.Y - size.Y / 2, size.X, size.Y), DrawColourInfo.Colour, null, diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index e2c7693700..29113e0e2f 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -214,7 +214,6 @@ namespace osu.Game.Graphics.Backgrounds base.Draw(vertexAction); shader.Bind(); - texture.TextureGL.Bind(); Vector2 localInflationAmount = edge_smoothness * DrawInfo.MatrixInverse.ExtractScale().Xy; @@ -231,7 +230,8 @@ namespace osu.Game.Graphics.Backgrounds ColourInfo colourInfo = DrawColourInfo.Colour; colourInfo.ApplyChild(particle.Colour); - texture.DrawTriangle( + DrawTriangle( + texture, triangle, colourInfo, null, diff --git a/osu.Game/Rulesets/Mods/ModFlashlight.cs b/osu.Game/Rulesets/Mods/ModFlashlight.cs index e174a25df3..405d21c711 100644 --- a/osu.Game/Rulesets/Mods/ModFlashlight.cs +++ b/osu.Game/Rulesets/Mods/ModFlashlight.cs @@ -179,7 +179,7 @@ namespace osu.Game.Rulesets.Mods shader.GetUniform("flashlightSize").UpdateValue(ref flashlightSize); shader.GetUniform("flashlightDim").UpdateValue(ref flashlightDim); - Texture.WhitePixel.DrawQuad(screenSpaceDrawQuad, DrawColourInfo.Colour, vertexAction: vertexAction); + DrawQuad(Texture.WhitePixel, screenSpaceDrawQuad, DrawColourInfo.Colour, vertexAction: vertexAction); shader.Unbind(); } diff --git a/osu.Game/Screens/Menu/LogoVisualisation.cs b/osu.Game/Screens/Menu/LogoVisualisation.cs index 2925689d20..c6de5857c2 100644 --- a/osu.Game/Screens/Menu/LogoVisualisation.cs +++ b/osu.Game/Screens/Menu/LogoVisualisation.cs @@ -189,7 +189,6 @@ namespace osu.Game.Screens.Menu base.Draw(vertexAction); shader.Bind(); - texture.TextureGL.Bind(); Vector2 inflation = DrawInfo.MatrixInverse.ExtractScale().Xy; @@ -224,7 +223,8 @@ namespace osu.Game.Screens.Menu Vector2Extensions.Transform(barPosition + bottomOffset + amplitudeOffset, DrawInfo.Matrix) ); - texture.DrawQuad( + DrawQuad( + texture, rectangle, colourInfo, null, From 4d035afcc6f93d808c28f4ebec36b26be2f1aee5 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 6 Jun 2019 16:49:42 +0900 Subject: [PATCH 275/375] Add setting to bypass front-to-back --- osu.Game/Overlays/Settings/Sections/Debug/GeneralSettings.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Game/Overlays/Settings/Sections/Debug/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Debug/GeneralSettings.cs index b671d0e0fd..f063898a9f 100644 --- a/osu.Game/Overlays/Settings/Sections/Debug/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Debug/GeneralSettings.cs @@ -31,6 +31,11 @@ namespace osu.Game.Overlays.Settings.Sections.Debug LabelText = "Bypass caching (slow)", Bindable = config.GetBindable(DebugSetting.BypassCaching) }, + new SettingsCheckbox + { + LabelText = "Bypass front-to-back render pass", + Bindable = config.GetBindable(DebugSetting.BypassFrontToBackPass) + } }; } } From ac9a3e54a60bf1e97977fb9a9fad2f6c4e5be28b Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 6 Jun 2019 18:07:19 +0900 Subject: [PATCH 276/375] Fix cursor issue with stopped gameplay clock --- osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs index 1b8fa0de01..341975c167 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs @@ -54,7 +54,8 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor for (int i = 0; i < max_sprites; i++) { - parts[i].InvalidationID = 0; + // InvalidationID 1 forces an update of each part of the cursor trail the first time ApplyState is ran on the draw node + parts[i].InvalidationID = 1; parts[i].WasUpdated = true; } } From 2a90af1d4e785e2d5cdf37c93243ed027257dbcf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 6 Jun 2019 19:15:51 +0900 Subject: [PATCH 277/375] Update readme with direct download links --- README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index abddb1faa1..91ea34e999 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ This project is still heavily under development, but is in a state where users a We are accepting bug reports (please report with as much detail as possible). Feature requests are welcome as long as you read and understand the contribution guidelines listed below. +Detailed changelogs are published on the [official osu! site](https://osu.ppy.sh/home/changelog). + ## Requirements - A desktop platform with the [.NET Core SDK 2.2](https://www.microsoft.com/net/learn/get-started) or higher installed. @@ -20,17 +22,24 @@ We are accepting bug reports (please report with as much detail as possible). Fe ### Releases -If you are not interested in developing the game, please head over to the [releases](https://github.com/ppy/osu/releases) to download a precompiled build with automatic updating enabled. +![](https://puu.sh/DCmvA/f6a74f5fbb.png) -- Windows (x64) users should download and run `install.exe`. -- macOS users (10.12 "Sierra" and higher) should download and run `osu.app.zip`. -- iOS users can join the [TestFlight beta program](https://t.co/xQJmHkfC18). +If you are not interested in developing the game, you can consume our [binary releases](https://github.com/ppy/osu/releases). + +**Latest build:*** + +| [Windows (x64)](https://github.com/ppy/osu/releases/latest/download/install.exe) | [macOS 10.12+](https://github.com/ppy/osu/releases/latest/download/osu.app.zip) | +| ------------- | ------------- | + +- **Linux** users are recommended to self-compile until we have official deployment in place. +- **iOS** users can join the [TestFlight beta program](https://t.co/xQJmHkfC18) (note that due to high demand this is reulgarly full). +- **Android** users can self-compile, and expect a public beta soon. If your platform is not listed above, there is still a chance you can manually build it by following the instructions below. ### Downloading the source code -Clone the repository **including submodules**: +Clone the repository: ```shell git clone https://github.com/ppy/osu @@ -45,7 +54,7 @@ git pull ### Building -Build configurations for the recommended IDEs (listed above) are included. You should use the provided Build/Run functionality of your IDE to get things going. When testing or building new components, it's highly encouraged you use the `VisualTests` project/configuration. More information on this provided below. +Build configurations for the recommended IDEs (listed above) are included. You should use the provided Build/Run functionality of your IDE to get things going. When testing or building new components, it's highly encouraged you use the `VisualTests` project/configuration. More information on this provided [below](#contributing). > Visual Studio Code users must run the `Restore` task before any build attempt. From 6bf6e221491f95b1bb0b44e87cb22e0530ff948f Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 6 Jun 2019 20:33:03 +0900 Subject: [PATCH 278/375] Update framework --- osu.Game/osu.Game.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index f84bb64fbf..55fa20188c 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -15,7 +15,7 @@ - + From 8c1a62536cb15a559befbff2383259b687b39454 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 6 Jun 2019 21:13:01 +0900 Subject: [PATCH 279/375] Update framework --- osu.iOS.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.iOS.props b/osu.iOS.props index fc047aa5f0..68f21df8ba 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -105,8 +105,8 @@ - - + + From 210437042fa0b7ee8613f52059c3c4c94f353706 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 7 Jun 2019 02:39:36 +0300 Subject: [PATCH 280/375] Remove useless update calls in ToolbarRulesetSelector --- osu.Game/Overlays/Toolbar/ToolbarRulesetSelector.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarRulesetSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarRulesetSelector.cs index 84a41b6547..90412ec1d1 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarRulesetSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarRulesetSelector.cs @@ -31,6 +31,7 @@ namespace osu.Game.Overlays.Toolbar public ToolbarRulesetSelector() { RelativeSizeAxes = Axes.Y; + AutoSizeAxes = Axes.X; Children = new[] { @@ -111,12 +112,6 @@ namespace osu.Game.Overlays.Toolbar private void disabledChanged(bool isDisabled) => this.FadeColour(isDisabled ? Color4.Gray : Color4.White, 300); - protected override void Update() - { - base.Update(); - Size = new Vector2(modeButtons.DrawSize.X, 1); - } - private void rulesetChanged(ValueChangedEvent e) { foreach (ToolbarRulesetButton m in modeButtons.Children.Cast()) From e2118299e93ac4e657c1994d09a7617ca262bbe5 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Fri, 7 Jun 2019 10:36:36 +0900 Subject: [PATCH 281/375] update comment --- osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs index 341975c167..888c77442f 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs @@ -54,7 +54,8 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor for (int i = 0; i < max_sprites; i++) { - // InvalidationID 1 forces an update of each part of the cursor trail the first time ApplyState is ran on the draw node + // InvalidationID 1 forces an update of each part of the cursor trail the first time ApplyState is run on the draw node + // This is to prevent garbage data from being sent to the vertex shader, resulting in visual issues on some platforms parts[i].InvalidationID = 1; parts[i].WasUpdated = true; } From 9f740f69bb8ab61459dc72bd7c6dce4062e78759 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Jun 2019 11:20:39 +0900 Subject: [PATCH 282/375] Fix preview tracks muting themselves Closes #4937 --- osu.Game/Audio/PreviewTrackManager.cs | 57 ++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/osu.Game/Audio/PreviewTrackManager.cs b/osu.Game/Audio/PreviewTrackManager.cs index d479483508..6e162ca95e 100644 --- a/osu.Game/Audio/PreviewTrackManager.cs +++ b/osu.Game/Audio/PreviewTrackManager.cs @@ -1,6 +1,10 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Track; @@ -12,22 +16,24 @@ using osu.Game.Beatmaps; namespace osu.Game.Audio { - /// - /// A central store for the retrieval of s. - /// public class PreviewTrackManager : Component { private readonly BindableDouble muteBindable = new BindableDouble(); private AudioManager audio; - private ITrackStore trackStore; + private PreviewTrackStore trackStore; private TrackManagerPreviewTrack current; [BackgroundDependencyLoader] private void load(AudioManager audio, FrameworkConfigManager config) { - trackStore = audio.GetTrackStore(new OnlineStore()); + // this is a temporary solution to get around muting ourselves. + // todo: update this once we have a BackgroundTrackManager or similar. + trackStore = new PreviewTrackStore(new OnlineStore()); + + audio.AddItem(trackStore); + trackStore.AddAdjustment(AdjustableProperty.Volume, audio.VolumeTrack); this.audio = audio; @@ -103,5 +109,46 @@ namespace osu.Game.Audio protected override Track GetTrack() => trackManager.Get($"https://b.ppy.sh/preview/{beatmapSetInfo?.OnlineBeatmapSetID}.mp3"); } + + private class PreviewTrackStore : AudioCollectionManager, ITrackStore + { + private readonly IResourceStore store; + + internal PreviewTrackStore(IResourceStore store) + { + this.store = store; + } + + public Track GetVirtual(double length = double.PositiveInfinity) + { + if (IsDisposed) throw new ObjectDisposedException($"Cannot retrieve items for an already disposed {nameof(PreviewTrackStore)}"); + + var track = new TrackVirtual(length); + AddItem(track); + return track; + } + + public Track Get(string name) + { + if (IsDisposed) throw new ObjectDisposedException($"Cannot retrieve items for an already disposed {nameof(PreviewTrackStore)}"); + + if (string.IsNullOrEmpty(name)) return null; + + var dataStream = store.GetStream(name); + + if (dataStream == null) + return null; + + Track track = new TrackBass(dataStream); + AddItem(track); + return track; + } + + public Task GetAsync(string name) => Task.Run(() => Get(name)); + + public Stream GetStream(string name) => store.GetStream(name); + + public IEnumerable GetAvailableResources() => store.GetAvailableResources(); + } } } From 64d5aa318fd7baa6c5610e849cd9f7568ab7ae09 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Jun 2019 11:45:58 +0900 Subject: [PATCH 283/375] Apply rebased changes --- .../TestSceneOsuHoverContainer.cs | 216 ++++++++++++++++++ .../Graphics/Containers/OsuHoverContainer.cs | 30 ++- 2 files changed, 234 insertions(+), 12 deletions(-) create mode 100644 osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs new file mode 100644 index 0000000000..9fe1a4cd89 --- /dev/null +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs @@ -0,0 +1,216 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Tests.Visual.UserInterface +{ + [TestFixture] + public class TestSceneOsuHoverContainer : ManualInputManagerTestScene + { + private OsuHoverTestContainer hoverContainer; + private OsuSpriteText textContainer; + private ColourInfo currentColour => textContainer.DrawColourInfo.Colour; + private ColourInfo idleColour => hoverContainer.IdleColourPublic; + private ColourInfo hoverColour => hoverContainer.HoverColourPublic; + + public TestSceneOsuHoverContainer() + { + setupUI(); + } + + [SetUp] + public void TestSceneOsuHoverContainer_SetUp() => Schedule(() => setupUI()); + + private void setupUI() + { + Child = hoverContainer = new OsuHoverTestContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Child = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Children = new[] + { + textContainer = new OsuSpriteText + { + Text = "Test", + Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 20), + }, + } + } + }; + } + + [Description("Checks IsHovered property value on a container when it is hovered/unhovered.")] + [TestCase(true, TestName = "Enabled_Check_IsHovered")] + [TestCase(false, TestName = "Disabled_Check_IsHovered")] + public void Check_IsHovered_HasProperValue(bool isEnabled) + { + moveOut(); + setContainerEnabledTo(isEnabled); + + checkNotHovered(); + + moveToText(); + checkHovered(); + + moveOut(); + checkNotHovered(); + + moveToText(); + checkHovered(); + + moveOut(); + checkNotHovered(); + + ReturnUserInput(); + } + + [Test] + [Description("Checks colour fading on an enabled container when it is hovered/unhovered.")] + public void WhenEnabled_Fades() + { + moveOut(); + enableContainer(); + + checkColour(idleColour); + + moveToText(); + waitUntilColourIs(hoverColour); + + moveOut(); + waitUntilColourIs(idleColour); + + moveToText(); + waitUntilColourIs(hoverColour); + + moveOut(); + waitUntilColourIs(idleColour); + + ReturnUserInput(); + } + + [Test] + [Description("Checks colour fading on a disabled container when it is hovered/unhovered.")] + public void WhenDisabled_DoesNotFade() + { + moveOut(); + disableContainer(); + + checkColour(idleColour); + + moveToText(); + checkColour(idleColour); + + moveOut(); + checkColour(idleColour); + + moveToText(); + checkColour(idleColour); + + moveOut(); + checkColour(idleColour); + + ReturnUserInput(); + } + + [Test] + [Description("Checks that when a disabled & hovered container gets enabled, colour fading happens")] + public void WhileHovering_WhenGetsEnabled_Fades() + { + moveOut(); + disableContainer(); + checkColour(idleColour); + + moveToText(); + checkColour(idleColour); + + enableContainer(); + waitUntilColourIs(hoverColour); + } + + [Test] + [Description("Checks that when an enabled & hovered container gets disabled, colour fading happens")] + public void WhileHovering_WhenGetsDisabled_Fades() + { + moveOut(); + enableContainer(); + checkColour(idleColour); + + moveToText(); + waitUntilColourIs(hoverColour); + + disableContainer(); + waitUntilColourIs(idleColour); + } + + [Test] + [Description("Checks that when a hovered container gets enabled and disabled multiple times, colour fading happens")] + public void WhileHovering_WhenEnabledChangesMultipleTimes_Fades() + { + moveOut(); + enableContainer(); + checkColour(idleColour); + + moveToText(); + waitUntilColourIs(hoverColour); + + disableContainer(); + waitUntilColourIs(idleColour); + + enableContainer(); + waitUntilColourIs(hoverColour); + + disableContainer(); + waitUntilColourIs(idleColour); + } + + private void enableContainer() => setContainerEnabledTo(true); + + private void disableContainer() => setContainerEnabledTo(false); + + private void setContainerEnabledTo(bool newValue) + { + string word = newValue ? "Enable" : "Disable"; + AddStep($"{word} container", () => hoverContainer.Enabled.Value = newValue); + } + + private void moveToText() => AddStep("Move mouse to text", () => InputManager.MoveMouseTo(hoverContainer)); + + private void moveOut() => AddStep("Move out", doMoveOut); + + private void checkHovered() => AddAssert("Check hovered", () => hoverContainer.IsHovered); + + private void checkNotHovered() => AddAssert("Check not hovered", () => !hoverContainer.IsHovered); + + private void checkColour(ColourInfo expectedColour) + => AddAssert($"Check colour to be '{expectedColour}'", () => currentColour.Equals(expectedColour)); + + private void waitUntilColourIs(ColourInfo expectedColour) + => AddUntilStep($"Wait until hover colour is {expectedColour}", () => currentColour.Equals(expectedColour)); + + /// + /// Moves the cursor to top left corner of the screen + /// + private void doMoveOut() + => InputManager.MoveMouseTo(new Vector2(InputManager.ScreenSpaceDrawQuad.TopLeft.X, InputManager.ScreenSpaceDrawQuad.TopLeft.Y)); + + private sealed class OsuHoverTestContainer : OsuHoverContainer + { + public Color4 HoverColourPublic => HoverColour; + public Color4 IdleColourPublic => IdleColour; + } + } +} diff --git a/osu.Game/Graphics/Containers/OsuHoverContainer.cs b/osu.Game/Graphics/Containers/OsuHoverContainer.cs index 0e4a5ae5c0..4ea28f74b9 100644 --- a/osu.Game/Graphics/Containers/OsuHoverContainer.cs +++ b/osu.Game/Graphics/Containers/OsuHoverContainer.cs @@ -24,11 +24,13 @@ namespace osu.Game.Graphics.Containers { Enabled.ValueChanged += e => { - if (e.NewValue && isHovered) - fadeIn(); - - if (!e.NewValue) - unhover(); + if (isHovered) + { + if (e.NewValue) + fadeIn(); + else + fadeOut(); + } }; } @@ -36,6 +38,9 @@ namespace osu.Game.Graphics.Containers protected override bool OnHover(HoverEvent e) { + if (isHovered) + return false; + isHovered = true; if (!Enabled.Value) @@ -47,18 +52,14 @@ namespace osu.Game.Graphics.Containers } protected override void OnHoverLost(HoverLostEvent e) - { - unhover(); - base.OnHoverLost(e); - } - - private void unhover() { if (!isHovered) return; isHovered = false; - EffectTargets.ForEach(d => d.FadeColour(IdleColour, FADE_DURATION, Easing.OutQuint)); + fadeOut(); + + base.OnHoverLost(e); } [BackgroundDependencyLoader] @@ -78,5 +79,10 @@ namespace osu.Game.Graphics.Containers { EffectTargets.ForEach(d => d.FadeColour(HoverColour, FADE_DURATION, Easing.OutQuint)); } + + private void fadeOut() + { + EffectTargets.ForEach(d => d.FadeColour(IdleColour, FADE_DURATION, Easing.OutQuint)); + } } } From 694f2e3a4f9e5902d685b9d7cac0de42d5546384 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Jun 2019 11:59:07 +0900 Subject: [PATCH 284/375] Tidy up test scene's setup usage --- .../TestSceneOsuHoverContainer.cs | 77 +++++++++---------- 1 file changed, 37 insertions(+), 40 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs index 9fe1a4cd89..79aa6189af 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs @@ -20,18 +20,9 @@ namespace osu.Game.Tests.Visual.UserInterface private OsuHoverTestContainer hoverContainer; private OsuSpriteText textContainer; private ColourInfo currentColour => textContainer.DrawColourInfo.Colour; - private ColourInfo idleColour => hoverContainer.IdleColourPublic; - private ColourInfo hoverColour => hoverContainer.HoverColourPublic; - - public TestSceneOsuHoverContainer() - { - setupUI(); - } [SetUp] - public void TestSceneOsuHoverContainer_SetUp() => Schedule(() => setupUI()); - - private void setupUI() + public void SetUp() => Schedule(() => { Child = hoverContainer = new OsuHoverTestContainer { @@ -51,12 +42,12 @@ namespace osu.Game.Tests.Visual.UserInterface } } }; - } + }); [Description("Checks IsHovered property value on a container when it is hovered/unhovered.")] [TestCase(true, TestName = "Enabled_Check_IsHovered")] [TestCase(false, TestName = "Disabled_Check_IsHovered")] - public void Check_IsHovered_HasProperValue(bool isEnabled) + public void TestIsHoveredHasProperValue(bool isEnabled) { moveOut(); setContainerEnabledTo(isEnabled); @@ -80,101 +71,101 @@ namespace osu.Game.Tests.Visual.UserInterface [Test] [Description("Checks colour fading on an enabled container when it is hovered/unhovered.")] - public void WhenEnabled_Fades() + public void TestTransitionWhileEnabled() { moveOut(); enableContainer(); - checkColour(idleColour); + checkColour(OsuHoverTestContainer.IDLE_COLOUR); moveToText(); - waitUntilColourIs(hoverColour); + waitUntilColourIs(OsuHoverTestContainer.HOVER_COLOUR); moveOut(); - waitUntilColourIs(idleColour); + waitUntilColourIs(OsuHoverTestContainer.IDLE_COLOUR); moveToText(); - waitUntilColourIs(hoverColour); + waitUntilColourIs(OsuHoverTestContainer.HOVER_COLOUR); moveOut(); - waitUntilColourIs(idleColour); + waitUntilColourIs(OsuHoverTestContainer.IDLE_COLOUR); ReturnUserInput(); } [Test] [Description("Checks colour fading on a disabled container when it is hovered/unhovered.")] - public void WhenDisabled_DoesNotFade() + public void TestNoTransitionWhileDisabled() { moveOut(); disableContainer(); - checkColour(idleColour); + checkColour(OsuHoverTestContainer.IDLE_COLOUR); moveToText(); - checkColour(idleColour); + checkColour(OsuHoverTestContainer.IDLE_COLOUR); moveOut(); - checkColour(idleColour); + checkColour(OsuHoverTestContainer.IDLE_COLOUR); moveToText(); - checkColour(idleColour); + checkColour(OsuHoverTestContainer.IDLE_COLOUR); moveOut(); - checkColour(idleColour); + checkColour(OsuHoverTestContainer.IDLE_COLOUR); ReturnUserInput(); } [Test] [Description("Checks that when a disabled & hovered container gets enabled, colour fading happens")] - public void WhileHovering_WhenGetsEnabled_Fades() + public void TestBecomesEnabledTransition() { moveOut(); disableContainer(); - checkColour(idleColour); + checkColour(OsuHoverTestContainer.IDLE_COLOUR); moveToText(); - checkColour(idleColour); + checkColour(OsuHoverTestContainer.IDLE_COLOUR); enableContainer(); - waitUntilColourIs(hoverColour); + waitUntilColourIs(OsuHoverTestContainer.HOVER_COLOUR); } [Test] [Description("Checks that when an enabled & hovered container gets disabled, colour fading happens")] - public void WhileHovering_WhenGetsDisabled_Fades() + public void TestBecomesDisabledTransition() { moveOut(); enableContainer(); - checkColour(idleColour); + checkColour(OsuHoverTestContainer.IDLE_COLOUR); moveToText(); - waitUntilColourIs(hoverColour); + waitUntilColourIs(OsuHoverTestContainer.HOVER_COLOUR); disableContainer(); - waitUntilColourIs(idleColour); + waitUntilColourIs(OsuHoverTestContainer.IDLE_COLOUR); } [Test] [Description("Checks that when a hovered container gets enabled and disabled multiple times, colour fading happens")] - public void WhileHovering_WhenEnabledChangesMultipleTimes_Fades() + public void TestDisabledChangesMultipleTimes() { moveOut(); enableContainer(); - checkColour(idleColour); + checkColour(OsuHoverTestContainer.IDLE_COLOUR); moveToText(); - waitUntilColourIs(hoverColour); + waitUntilColourIs(OsuHoverTestContainer.HOVER_COLOUR); disableContainer(); - waitUntilColourIs(idleColour); + waitUntilColourIs(OsuHoverTestContainer.IDLE_COLOUR); enableContainer(); - waitUntilColourIs(hoverColour); + waitUntilColourIs(OsuHoverTestContainer.HOVER_COLOUR); disableContainer(); - waitUntilColourIs(idleColour); + waitUntilColourIs(OsuHoverTestContainer.IDLE_COLOUR); } private void enableContainer() => setContainerEnabledTo(true); @@ -209,8 +200,14 @@ namespace osu.Game.Tests.Visual.UserInterface private sealed class OsuHoverTestContainer : OsuHoverContainer { - public Color4 HoverColourPublic => HoverColour; - public Color4 IdleColourPublic => IdleColour; + public static readonly Color4 HOVER_COLOUR = Color4.Red; + public static readonly Color4 IDLE_COLOUR = Color4.Green; + + public OsuHoverTestContainer() + { + HoverColour = HOVER_COLOUR; + IdleColour = IDLE_COLOUR; + } } } } From 58174425eda10e15e64f39f5ce4f6165ea8d4045 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Jun 2019 12:37:10 +0900 Subject: [PATCH 285/375] Make visual test more visible --- .../TestSceneOsuHoverContainer.cs | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs index 79aa6189af..6b2bca9b83 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs @@ -4,11 +4,8 @@ using NUnit.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Game.Graphics; +using osu.Framework.Graphics.Shapes; using osu.Game.Graphics.Containers; -using osu.Game.Graphics.Sprites; using osuTK; using osuTK.Graphics; @@ -18,8 +15,7 @@ namespace osu.Game.Tests.Visual.UserInterface public class TestSceneOsuHoverContainer : ManualInputManagerTestScene { private OsuHoverTestContainer hoverContainer; - private OsuSpriteText textContainer; - private ColourInfo currentColour => textContainer.DrawColourInfo.Colour; + private Box colourContainer; [SetUp] public void SetUp() => Schedule(() => @@ -28,19 +24,11 @@ namespace osu.Game.Tests.Visual.UserInterface { Anchor = Anchor.Centre, Origin = Anchor.Centre, - AutoSizeAxes = Axes.Both, - Child = new FillFlowContainer + Size = new Vector2(100), + Child = colourContainer = new Box { - AutoSizeAxes = Axes.Both, - Children = new[] - { - textContainer = new OsuSpriteText - { - Text = "Test", - Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 20), - }, - } - } + RelativeSizeAxes = Axes.Both, + }, }; }); @@ -192,6 +180,8 @@ namespace osu.Game.Tests.Visual.UserInterface private void waitUntilColourIs(ColourInfo expectedColour) => AddUntilStep($"Wait until hover colour is {expectedColour}", () => currentColour.Equals(expectedColour)); + private ColourInfo currentColour => colourContainer.DrawColourInfo.Colour; + /// /// Moves the cursor to top left corner of the screen /// From 748c0e5c012e266dd4ca15f1c786de6654c3aefd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Jun 2019 12:42:01 +0900 Subject: [PATCH 286/375] Set default state of test to enabled --- .../Visual/UserInterface/TestSceneOsuHoverContainer.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs index 6b2bca9b83..3613122165 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs @@ -22,6 +22,7 @@ namespace osu.Game.Tests.Visual.UserInterface { Child = hoverContainer = new OsuHoverTestContainer { + Enabled = { Value = true }, Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(100), @@ -30,6 +31,8 @@ namespace osu.Game.Tests.Visual.UserInterface RelativeSizeAxes = Axes.Both, }, }; + + doMoveOut(); }); [Description("Checks IsHovered property value on a container when it is hovered/unhovered.")] @@ -37,7 +40,6 @@ namespace osu.Game.Tests.Visual.UserInterface [TestCase(false, TestName = "Disabled_Check_IsHovered")] public void TestIsHoveredHasProperValue(bool isEnabled) { - moveOut(); setContainerEnabledTo(isEnabled); checkNotHovered(); @@ -61,7 +63,6 @@ namespace osu.Game.Tests.Visual.UserInterface [Description("Checks colour fading on an enabled container when it is hovered/unhovered.")] public void TestTransitionWhileEnabled() { - moveOut(); enableContainer(); checkColour(OsuHoverTestContainer.IDLE_COLOUR); @@ -85,7 +86,6 @@ namespace osu.Game.Tests.Visual.UserInterface [Description("Checks colour fading on a disabled container when it is hovered/unhovered.")] public void TestNoTransitionWhileDisabled() { - moveOut(); disableContainer(); checkColour(OsuHoverTestContainer.IDLE_COLOUR); @@ -109,7 +109,6 @@ namespace osu.Game.Tests.Visual.UserInterface [Description("Checks that when a disabled & hovered container gets enabled, colour fading happens")] public void TestBecomesEnabledTransition() { - moveOut(); disableContainer(); checkColour(OsuHoverTestContainer.IDLE_COLOUR); @@ -124,7 +123,6 @@ namespace osu.Game.Tests.Visual.UserInterface [Description("Checks that when an enabled & hovered container gets disabled, colour fading happens")] public void TestBecomesDisabledTransition() { - moveOut(); enableContainer(); checkColour(OsuHoverTestContainer.IDLE_COLOUR); @@ -139,7 +137,6 @@ namespace osu.Game.Tests.Visual.UserInterface [Description("Checks that when a hovered container gets enabled and disabled multiple times, colour fading happens")] public void TestDisabledChangesMultipleTimes() { - moveOut(); enableContainer(); checkColour(OsuHoverTestContainer.IDLE_COLOUR); From 6f6b134ec8266c2d7ea5931052261d29ea7ad9c0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Jun 2019 12:52:49 +0900 Subject: [PATCH 287/375] Remove return user input calls --- .../Visual/UserInterface/TestSceneOsuHoverContainer.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs index 3613122165..dbef7d1686 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs @@ -55,8 +55,6 @@ namespace osu.Game.Tests.Visual.UserInterface moveOut(); checkNotHovered(); - - ReturnUserInput(); } [Test] @@ -78,8 +76,6 @@ namespace osu.Game.Tests.Visual.UserInterface moveOut(); waitUntilColourIs(OsuHoverTestContainer.IDLE_COLOUR); - - ReturnUserInput(); } [Test] @@ -101,8 +97,6 @@ namespace osu.Game.Tests.Visual.UserInterface moveOut(); checkColour(OsuHoverTestContainer.IDLE_COLOUR); - - ReturnUserInput(); } [Test] From 0fc2c596b650bedc892695e46926c47691810f4c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Jun 2019 12:53:51 +0900 Subject: [PATCH 288/375] Add toggle for input priority in manual input tests --- .../Visual/ManualInputManagerTestScene.cs | 92 ++++++++++++++++++- 1 file changed, 88 insertions(+), 4 deletions(-) diff --git a/osu.Game/Tests/Visual/ManualInputManagerTestScene.cs b/osu.Game/Tests/Visual/ManualInputManagerTestScene.cs index a7a7f88ff7..460df8b84c 100644 --- a/osu.Game/Tests/Visual/ManualInputManagerTestScene.cs +++ b/osu.Game/Tests/Visual/ManualInputManagerTestScene.cs @@ -3,8 +3,13 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; using osu.Framework.Testing.Input; using osu.Game.Graphics.Cursor; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; +using osuTK; +using osuTK.Graphics; namespace osu.Game.Tests.Visual { @@ -15,12 +20,77 @@ namespace osu.Game.Tests.Visual protected readonly ManualInputManager InputManager; + private readonly TriangleButton buttonTest; + private readonly TriangleButton buttonLocal; + protected ManualInputManagerTestScene() { - base.Content.Add(InputManager = new ManualInputManager + base.Content.AddRange(new Drawable[] { - UseParentInput = true, - Child = content = new MenuCursorContainer { RelativeSizeAxes = Axes.Both }, + InputManager = new ManualInputManager + { + UseParentInput = true, + Child = content = new MenuCursorContainer { RelativeSizeAxes = Axes.Both }, + }, + new Container + { + AutoSizeAxes = Axes.Both, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Margin = new MarginPadding(5), + CornerRadius = 5, + Masking = true, + Children = new Drawable[] + { + new Box + { + Colour = Color4.Black, + RelativeSizeAxes = Axes.Both, + Alpha = 0.5f, + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Margin = new MarginPadding(5), + Spacing = new Vector2(5), + Children = new Drawable[] + { + new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Text = "Input Priority" + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Margin = new MarginPadding(5), + Spacing = new Vector2(5), + Direction = FillDirection.Horizontal, + + Children = new Drawable[] + { + buttonLocal = new TriangleButton + { + Text = "local", + Size = new Vector2(50, 30), + Action = returnUserInput + }, + buttonTest = new TriangleButton + { + Text = "test", + Size = new Vector2(50, 30), + Action = returnTestInput + }, + } + }, + } + }, + } + }, }); } @@ -29,7 +99,21 @@ namespace osu.Game.Tests.Visual /// protected void ReturnUserInput() { - AddStep("Return user input", () => InputManager.UseParentInput = true); + AddStep("Return user input", returnUserInput); } + + protected override void Update() + { + base.Update(); + + buttonTest.Enabled.Value = InputManager.UseParentInput; + buttonLocal.Enabled.Value = !InputManager.UseParentInput; + } + + private void returnUserInput() => + InputManager.UseParentInput = true; + + private void returnTestInput() => + InputManager.UseParentInput = false; } } From 1374da7c41b1f364b4012d047d6df7e2ed18de07 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Jun 2019 12:54:57 +0900 Subject: [PATCH 289/375] Remove all calls to return user input --- osu.Game.Tests/Visual/UserInterface/TestSceneCursors.cs | 1 - osu.Game/Tests/Visual/ManualInputManagerTestScene.cs | 8 -------- 2 files changed, 9 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneCursors.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneCursors.cs index 590ee4e720..8fe31b7ad6 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneCursors.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneCursors.cs @@ -84,7 +84,6 @@ namespace osu.Game.Tests.Visual.UserInterface testLocalCursor(); testUserCursorOverride(); testMultipleLocalCursors(); - ReturnUserInput(); } /// diff --git a/osu.Game/Tests/Visual/ManualInputManagerTestScene.cs b/osu.Game/Tests/Visual/ManualInputManagerTestScene.cs index 460df8b84c..86191609a4 100644 --- a/osu.Game/Tests/Visual/ManualInputManagerTestScene.cs +++ b/osu.Game/Tests/Visual/ManualInputManagerTestScene.cs @@ -94,14 +94,6 @@ namespace osu.Game.Tests.Visual }); } - /// - /// Returns input back to the user. - /// - protected void ReturnUserInput() - { - AddStep("Return user input", returnUserInput); - } - protected override void Update() { base.Update(); From 60b70c0f45e11d7114d1769b62f8ef4f1e06c40a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Jun 2019 14:11:21 +0900 Subject: [PATCH 290/375] Use lambda for simple functions --- osu.Game/Graphics/Containers/OsuHoverContainer.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/osu.Game/Graphics/Containers/OsuHoverContainer.cs b/osu.Game/Graphics/Containers/OsuHoverContainer.cs index 4ea28f74b9..67af79c763 100644 --- a/osu.Game/Graphics/Containers/OsuHoverContainer.cs +++ b/osu.Game/Graphics/Containers/OsuHoverContainer.cs @@ -75,14 +75,8 @@ namespace osu.Game.Graphics.Containers EffectTargets.ForEach(d => d.FadeColour(IdleColour)); } - private void fadeIn() - { - EffectTargets.ForEach(d => d.FadeColour(HoverColour, FADE_DURATION, Easing.OutQuint)); - } + private void fadeIn() => EffectTargets.ForEach(d => d.FadeColour(HoverColour, FADE_DURATION, Easing.OutQuint)); - private void fadeOut() - { - EffectTargets.ForEach(d => d.FadeColour(IdleColour, FADE_DURATION, Easing.OutQuint)); - } + private void fadeOut() => EffectTargets.ForEach(d => d.FadeColour(IdleColour, FADE_DURATION, Easing.OutQuint)); } } From 2531250f890245d4df9b8f70b666304027b3faea Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Jun 2019 14:58:04 +0900 Subject: [PATCH 291/375] Fix paginated layouts only showing one column even if enough space is available for more --- osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs index 8639acfc94..b459afcb49 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs @@ -49,7 +49,6 @@ namespace osu.Game.Overlays.Profile.Sections { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, - Direction = FillDirection.Vertical, Spacing = new Vector2(0, 2), }, MoreButton = new ShowMoreButton From 0ce5c7468fcf155dea67469182fae578abecdaf7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Jun 2019 15:31:23 +0900 Subject: [PATCH 292/375] Use switch and consume/block input --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index a7ba87e72a..501679af03 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -197,10 +197,16 @@ namespace osu.Game.Overlays.Mods protected override bool OnKeyDown(KeyDownEvent e) { - if (e.Key == Key.Number1) - DeselectAllButton.Click(); - else if (e.Key == Key.Number2) - CloseButton.Click(); + switch (e.Key) + { + case Key.Number1: + DeselectAllButton.Click(); + return true; + + case Key.Number2: + CloseButton.Click(); + return true; + } return base.OnKeyDown(e); } From b914bb1e2eb9aa0c451addd8d60d076d15e64f9d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Jun 2019 15:32:48 +0900 Subject: [PATCH 293/375] Remove key hints for now A proper design for this will come in the future. --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 501679af03..0e37e800ca 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -376,7 +376,7 @@ namespace osu.Game.Overlays.Mods DeselectAllButton = new TriangleButton { Width = 180, - Text = "1. Deselect All", + Text = "Deselect All", Action = DeselectAll, Margin = new MarginPadding { @@ -386,7 +386,7 @@ namespace osu.Game.Overlays.Mods CloseButton = new TriangleButton { Width = 180, - Text = "2. Close", + Text = "Close", Action = Hide, Margin = new MarginPadding { From 8f30c9b0a3ec210f6af2cd4e3f8353adda90a740 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Jun 2019 15:58:24 +0900 Subject: [PATCH 294/375] Fix file layout of ModSelectOverlay --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 365 +++++++++++---------- 1 file changed, 186 insertions(+), 179 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index b57e98d09e..dec58f4c9e 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -1,43 +1,40 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osuTK; -using osuTK.Input; -using osuTK.Graphics; -using osu.Framework.Allocation; -using osu.Framework.Extensions.Color4Extensions; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Game.Graphics; -using osu.Game.Graphics.Backgrounds; -using osu.Game.Graphics.Sprites; -using osu.Game.Rulesets.Mods; using System; using System.Collections.Generic; using System.Linq; +using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Bindables; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input.Events; +using osu.Game.Graphics; +using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Containers; -using osu.Game.Rulesets; +using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.Mods.Sections; +using osu.Game.Rulesets; +using osu.Game.Rulesets.Mods; using osu.Game.Screens; -using osu.Framework.Input.Events; +using osuTK; +using osuTK.Graphics; +using osuTK.Input; namespace osu.Game.Overlays.Mods { public class ModSelectOverlay : WaveOverlayContainer { - private const float content_width = 0.8f; - - protected Color4 LowMultiplierColour, HighMultiplierColour; - protected readonly TriangleButton DeselectAllButton; protected readonly TriangleButton CloseButton; - protected readonly OsuSpriteText MultiplierLabel, UnrankedLabel; - private readonly FillFlowContainer footerContainer; + + protected readonly OsuSpriteText MultiplierLabel; + protected readonly OsuSpriteText UnrankedLabel; protected override bool BlockNonPositionalInput => false; @@ -49,170 +46,14 @@ namespace osu.Game.Overlays.Mods protected readonly IBindable Ruleset = new Bindable(); - [BackgroundDependencyLoader(true)] - private void load(OsuColour colours, IBindable ruleset, AudioManager audio, Bindable> mods) - { - LowMultiplierColour = colours.Red; - HighMultiplierColour = colours.Green; - UnrankedLabel.Colour = colours.Blue; + protected Color4 LowMultiplierColour; + protected Color4 HighMultiplierColour; - Ruleset.BindTo(ruleset); - if (mods != null) SelectedMods.BindTo(mods); - - sampleOn = audio.Samples.Get(@"UI/check-on"); - sampleOff = audio.Samples.Get(@"UI/check-off"); - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - Ruleset.BindValueChanged(rulesetChanged, true); - SelectedMods.BindValueChanged(selectedModsChanged, true); - } - - protected override void Dispose(bool isDisposing) - { - base.Dispose(isDisposing); - - Ruleset.UnbindAll(); - SelectedMods.UnbindAll(); - } - - private void rulesetChanged(ValueChangedEvent e) - { - if (e.NewValue == null) return; - - var instance = e.NewValue.CreateInstance(); - - foreach (ModSection section in ModSectionsContainer.Children) - section.Mods = instance.GetModsFor(section.ModType); - - // attempt to re-select any already selected mods. - // this may be the first time we are receiving the ruleset, in which case they will still match. - selectedModsChanged(new ValueChangedEvent>(SelectedMods.Value, SelectedMods.Value)); - - // write the mods back to the SelectedMods bindable in the case a change was not applicable. - // this generally isn't required as the previous line will perform deselection; just here for safety. - refreshSelectedMods(); - } - - private void selectedModsChanged(ValueChangedEvent> e) - { - foreach (ModSection section in ModSectionsContainer.Children) - section.SelectTypes(e.NewValue.Select(m => m.GetType()).ToList()); - - updateMods(); - } - - private void updateMods() - { - double multiplier = 1.0; - bool ranked = true; - - foreach (Mod mod in SelectedMods.Value) - { - multiplier *= mod.ScoreMultiplier; - ranked &= mod.Ranked; - } - - MultiplierLabel.Text = $"{multiplier:N2}x"; - if (multiplier > 1.0) - MultiplierLabel.FadeColour(HighMultiplierColour, 200); - else if (multiplier < 1.0) - MultiplierLabel.FadeColour(LowMultiplierColour, 200); - else - MultiplierLabel.FadeColour(Color4.White, 200); - - UnrankedLabel.FadeTo(ranked ? 0 : 1, 200); - } - - protected override void PopOut() - { - base.PopOut(); - - footerContainer.MoveToX(footerContainer.DrawSize.X, WaveContainer.DISAPPEAR_DURATION, Easing.InSine); - footerContainer.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.InSine); - - foreach (ModSection section in ModSectionsContainer.Children) - { - section.ButtonsContainer.TransformSpacingTo(new Vector2(100f, 0f), WaveContainer.DISAPPEAR_DURATION, Easing.InSine); - section.ButtonsContainer.MoveToX(100f, WaveContainer.DISAPPEAR_DURATION, Easing.InSine); - section.ButtonsContainer.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.InSine); - } - } - - protected override void PopIn() - { - base.PopIn(); - - footerContainer.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint); - footerContainer.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint); - - foreach (ModSection section in ModSectionsContainer.Children) - { - section.ButtonsContainer.TransformSpacingTo(new Vector2(50f, 0f), WaveContainer.APPEAR_DURATION, Easing.OutQuint); - section.ButtonsContainer.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint); - section.ButtonsContainer.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint); - } - } - - public void DeselectAll() - { - foreach (ModSection section in ModSectionsContainer.Children) - section.DeselectAll(); - - refreshSelectedMods(); - } - - /// - /// Deselect one or more mods. - /// - /// The types of s which should be deselected. - /// Set to true to bypass animations and update selections immediately. - public void DeselectTypes(Type[] modTypes, bool immediate = false) - { - if (modTypes.Length == 0) return; - - foreach (ModSection section in ModSectionsContainer.Children) - section.DeselectTypes(modTypes, immediate); - } + private const float content_width = 0.8f; + private readonly FillFlowContainer footerContainer; private SampleChannel sampleOn, sampleOff; - private void modButtonPressed(Mod selectedMod) - { - if (selectedMod != null) - { - if (State == Visibility.Visible) sampleOn?.Play(); - DeselectTypes(selectedMod.IncompatibleMods, true); - } - else - { - if (State == Visibility.Visible) sampleOff?.Play(); - } - - refreshSelectedMods(); - } - - protected override bool OnKeyDown(KeyDownEvent e) - { - switch (e.Key) - { - case Key.Number1: - DeselectAllButton.Click(); - return true; - - case Key.Number2: - CloseButton.Click(); - return true; - } - - return base.OnKeyDown(e); - } - - private void refreshSelectedMods() => SelectedMods.Value = ModSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray(); - public ModSelectOverlay() { Waves.FirstWaveColour = OsuColour.FromHex(@"19b0e2"); @@ -430,5 +271,171 @@ namespace osu.Game.Overlays.Mods }, }; } + + [BackgroundDependencyLoader(true)] + private void load(OsuColour colours, IBindable ruleset, AudioManager audio, Bindable> mods) + { + LowMultiplierColour = colours.Red; + HighMultiplierColour = colours.Green; + UnrankedLabel.Colour = colours.Blue; + + Ruleset.BindTo(ruleset); + if (mods != null) SelectedMods.BindTo(mods); + + sampleOn = audio.Samples.Get(@"UI/check-on"); + sampleOff = audio.Samples.Get(@"UI/check-off"); + } + + public void DeselectAll() + { + foreach (var section in ModSectionsContainer.Children) + section.DeselectAll(); + + refreshSelectedMods(); + } + + /// + /// Deselect one or more mods. + /// + /// The types of s which should be deselected. + /// Set to true to bypass animations and update selections immediately. + public void DeselectTypes(Type[] modTypes, bool immediate = false) + { + if (modTypes.Length == 0) return; + + foreach (var section in ModSectionsContainer.Children) + section.DeselectTypes(modTypes, immediate); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + Ruleset.BindValueChanged(rulesetChanged, true); + SelectedMods.BindValueChanged(selectedModsChanged, true); + } + + protected override void PopOut() + { + base.PopOut(); + + footerContainer.MoveToX(footerContainer.DrawSize.X, WaveContainer.DISAPPEAR_DURATION, Easing.InSine); + footerContainer.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.InSine); + + foreach (var section in ModSectionsContainer.Children) + { + section.ButtonsContainer.TransformSpacingTo(new Vector2(100f, 0f), WaveContainer.DISAPPEAR_DURATION, Easing.InSine); + section.ButtonsContainer.MoveToX(100f, WaveContainer.DISAPPEAR_DURATION, Easing.InSine); + section.ButtonsContainer.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.InSine); + } + } + + protected override void PopIn() + { + base.PopIn(); + + footerContainer.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint); + footerContainer.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint); + + foreach (var section in ModSectionsContainer.Children) + { + section.ButtonsContainer.TransformSpacingTo(new Vector2(50f, 0f), WaveContainer.APPEAR_DURATION, Easing.OutQuint); + section.ButtonsContainer.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint); + section.ButtonsContainer.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint); + } + } + + protected override bool OnKeyDown(KeyDownEvent e) + { + switch (e.Key) + { + case Key.Number1: + DeselectAllButton.Click(); + return true; + + case Key.Number2: + CloseButton.Click(); + return true; + } + + return base.OnKeyDown(e); + } + + private void rulesetChanged(ValueChangedEvent e) + { + if (e.NewValue == null) return; + + var instance = e.NewValue.CreateInstance(); + + foreach (var section in ModSectionsContainer.Children) + section.Mods = instance.GetModsFor(section.ModType); + + // attempt to re-select any already selected mods. + // this may be the first time we are receiving the ruleset, in which case they will still match. + selectedModsChanged(new ValueChangedEvent>(SelectedMods.Value, SelectedMods.Value)); + + // write the mods back to the SelectedMods bindable in the case a change was not applicable. + // this generally isn't required as the previous line will perform deselection; just here for safety. + refreshSelectedMods(); + } + + private void selectedModsChanged(ValueChangedEvent> e) + { + foreach (var section in ModSectionsContainer.Children) + section.SelectTypes(e.NewValue.Select(m => m.GetType()).ToList()); + + updateMods(); + } + + private void updateMods() + { + var multiplier = 1.0; + var ranked = true; + + foreach (var mod in SelectedMods.Value) + { + multiplier *= mod.ScoreMultiplier; + ranked &= mod.Ranked; + } + + MultiplierLabel.Text = $"{multiplier:N2}x"; + if (multiplier > 1.0) + MultiplierLabel.FadeColour(HighMultiplierColour, 200); + else if (multiplier < 1.0) + MultiplierLabel.FadeColour(LowMultiplierColour, 200); + else + MultiplierLabel.FadeColour(Color4.White, 200); + + UnrankedLabel.FadeTo(ranked ? 0 : 1, 200); + } + + private void modButtonPressed(Mod selectedMod) + { + if (selectedMod != null) + { + if (State == Visibility.Visible) sampleOn?.Play(); + DeselectTypes(selectedMod.IncompatibleMods, true); + } + else + { + if (State == Visibility.Visible) sampleOff?.Play(); + } + + refreshSelectedMods(); + } + + private void refreshSelectedMods() => SelectedMods.Value = ModSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray(); + + #region Disposal + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + Ruleset.UnbindAll(); + SelectedMods.UnbindAll(); + } + + #endregion } } From cd4648a64729383356dcf0a26538126c902241ef Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Jun 2019 21:09:59 +0900 Subject: [PATCH 295/375] Update framework --- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 55fa20188c..654c62e1d8 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -15,7 +15,7 @@ - + diff --git a/osu.iOS.props b/osu.iOS.props index 68f21df8ba..8886184a2e 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -105,8 +105,8 @@ - - + + From e5b64bfa39df31f0db308655c943272e6c7b9348 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Fri, 7 Jun 2019 18:51:43 +0200 Subject: [PATCH 296/375] Highlight major changes in changelog overlay --- osu.Game/Overlays/Changelog/ChangelogBuild.cs | 51 ++++++++++++++++--- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogBuild.cs b/osu.Game/Overlays/Changelog/ChangelogBuild.cs index 57615332da..627eb10426 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBuild.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBuild.cs @@ -69,34 +69,69 @@ namespace osu.Game.Overlays.Changelog Margin = new MarginPadding { Vertical = 5 }, }; + var entryColor = entry.Major != null && (bool)entry.Major ? OsuColour.FromHex("#fd5") : Color4.White; + title.AddIcon(FontAwesome.Solid.Check, t => { t.Font = fontSmall; + t.Colour = entryColor; t.Padding = new MarginPadding { Left = -17, Right = 5 }; }); - title.AddText(entry.Title, t => { t.Font = fontLarge; }); + title.AddText(entry.Title, t => + { + t.Font = fontLarge; + t.Colour = entryColor; + }); if (!string.IsNullOrEmpty(entry.Repository)) { - title.AddText(" (", t => t.Font = fontLarge); + title.AddText(" (", t => + { + t.Font = fontLarge; + t.Colour = entryColor; + }); title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}", entry.GithubUrl, Online.Chat.LinkAction.External, - creationParameters: t => { t.Font = fontLarge; }); - title.AddText(")", t => t.Font = fontLarge); + creationParameters: t => + { + t.Font = fontLarge; + t.Colour = entryColor; + }); + title.AddText(")", t => + { + t.Font = fontLarge; + t.Colour = entryColor; + }); } - title.AddText(" by ", t => t.Font = fontMedium); + title.AddText(" by ", t => + { + t.Font = fontMedium; + t.Colour = entryColor; + }); if (entry.GithubUser.UserId != null) title.AddUserLink(new User { Username = entry.GithubUser.OsuUsername, Id = entry.GithubUser.UserId.Value - }, t => t.Font = fontMedium); + }, t => + { + t.Font = fontMedium; + t.Colour = entryColor; + }); else if (entry.GithubUser.GithubUrl != null) - title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, Online.Chat.LinkAction.External, null, null, t => t.Font = fontMedium); + title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, Online.Chat.LinkAction.External, null, null, t => + { + t.Font = fontMedium; + t.Colour = entryColor; + }); else - title.AddText(entry.GithubUser.DisplayName, t => t.Font = fontSmall); + title.AddText(entry.GithubUser.DisplayName, t => + { + t.Font = fontSmall; + t.Colour = entryColor; + }); ChangelogEntries.Add(title); From f326264a85abacef478d45cf71fc28867b3554e2 Mon Sep 17 00:00:00 2001 From: Ganendra Afrasya Date: Sat, 8 Jun 2019 00:42:57 +0700 Subject: [PATCH 297/375] Adding increase first object grow mod visibility setting --- osu.Game/Configuration/OsuConfigManager.cs | 3 +++ osu.Game/Overlays/Settings/Sections/Gameplay/ModsSettings.cs | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 795f0b43f7..b5a099aa3b 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -85,6 +85,8 @@ namespace osu.Game.Configuration Set(OsuSetting.IncreaseFirstObjectVisibility, true); + Set(OsuSetting.IncreaseFirstObjectGrowVisibility, true); + // Update Set(OsuSetting.ReleaseStream, ReleaseStream.Lazer); @@ -158,6 +160,7 @@ namespace osu.Game.Configuration BeatmapSkins, BeatmapHitsounds, IncreaseFirstObjectVisibility, + IncreaseFirstObjectGrowVisibility, ScoreDisplayMode, ExternalLinkWarning, Scaling, diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/ModsSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/ModsSettings.cs index 2cf14f5aff..538b2b2761 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/ModsSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/ModsSettings.cs @@ -20,6 +20,11 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay LabelText = "Increase visibility of first object with \"Hidden\" mod", Bindable = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility) }, + new SettingsCheckbox + { + LabelText = "Increase visibility of first object with \"Grow\" mod", + Bindable = config.GetBindable(OsuSetting.IncreaseFirstObjectGrowVisibility) + }, }; } } From 8ac64b5c16c0d8fe05f680a2226bc1dc37e15a6f Mon Sep 17 00:00:00 2001 From: Ganendra Afrasya Date: Sat, 8 Jun 2019 01:46:05 +0700 Subject: [PATCH 298/375] Make first object not applying custom state --- osu.Game.Rulesets.Osu/Mods/OsuModGrow.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModGrow.cs b/osu.Game.Rulesets.Osu/Mods/OsuModGrow.cs index a2da2bbf53..a5df36e9ff 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModGrow.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModGrow.cs @@ -2,8 +2,11 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; +using System.Linq; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; +using osu.Game.Configuration; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects; @@ -11,7 +14,7 @@ using osu.Game.Rulesets.Osu.Objects.Drawables; namespace osu.Game.Rulesets.Osu.Mods { - internal class OsuModGrow : Mod, IApplicableToDrawableHitObjects + internal class OsuModGrow : Mod, IReadFromConfig, IApplicableToDrawableHitObjects { public override string Name => "Grow"; @@ -25,9 +28,16 @@ namespace osu.Game.Rulesets.Osu.Mods public override double ScoreMultiplier => 1; + protected Bindable IncreaseFirstObjectGrowVisibility = new Bindable(); + + public void ReadFromConfig(OsuConfigManager config) + { + IncreaseFirstObjectGrowVisibility = config.GetBindable(OsuSetting.IncreaseFirstObjectGrowVisibility); + } + public void ApplyToDrawableHitObjects(IEnumerable drawables) { - foreach (var drawable in drawables) + foreach (var drawable in drawables.Skip(IncreaseFirstObjectGrowVisibility.Value ? 1 : 0)) { switch (drawable) { From 342e39776aaa5559401e86d2b6d656f01476acab Mon Sep 17 00:00:00 2001 From: Lucas A Date: Fri, 7 Jun 2019 20:59:56 +0200 Subject: [PATCH 299/375] Move ChangelogEntries populating logic from constructor to BDL load() to use OsuColour palette +apply review suggestions. --- osu.Game/Overlays/Changelog/ChangelogBuild.cs | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogBuild.cs b/osu.Game/Overlays/Changelog/ChangelogBuild.cs index 627eb10426..ae5ba3fa4e 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBuild.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBuild.cs @@ -13,6 +13,7 @@ using System.Text.RegularExpressions; using osu.Game.Graphics.Sprites; using osu.Game.Users; using osuTK.Graphics; +using osu.Framework.Allocation; namespace osu.Game.Overlays.Changelog { @@ -45,8 +46,12 @@ namespace osu.Game.Overlays.Changelog Direction = FillDirection.Vertical, }, }; + } - foreach (var categoryEntries in build.ChangelogEntries.GroupBy(b => b.Category).OrderBy(c => c.Key)) + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + foreach (var categoryEntries in Build.ChangelogEntries.GroupBy(b => b.Category).OrderBy(c => c.Key)) { ChangelogEntries.Add(new OsuSpriteText { @@ -69,19 +74,19 @@ namespace osu.Game.Overlays.Changelog Margin = new MarginPadding { Vertical = 5 }, }; - var entryColor = entry.Major != null && (bool)entry.Major ? OsuColour.FromHex("#fd5") : Color4.White; + var entryColour = entry.Major != null && (bool)entry.Major ? colours.YellowLight : Color4.White; title.AddIcon(FontAwesome.Solid.Check, t => { t.Font = fontSmall; - t.Colour = entryColor; + t.Colour = entryColour; t.Padding = new MarginPadding { Left = -17, Right = 5 }; }); title.AddText(entry.Title, t => { t.Font = fontLarge; - t.Colour = entryColor; + t.Colour = entryColour; }); if (!string.IsNullOrEmpty(entry.Repository)) @@ -89,25 +94,25 @@ namespace osu.Game.Overlays.Changelog title.AddText(" (", t => { t.Font = fontLarge; - t.Colour = entryColor; + t.Colour = entryColour; }); title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}", entry.GithubUrl, Online.Chat.LinkAction.External, creationParameters: t => { t.Font = fontLarge; - t.Colour = entryColor; + t.Colour = entryColour; }); title.AddText(")", t => { t.Font = fontLarge; - t.Colour = entryColor; + t.Colour = entryColour; }); } title.AddText(" by ", t => { t.Font = fontMedium; - t.Colour = entryColor; + t.Colour = entryColour; }); if (entry.GithubUser.UserId != null) @@ -118,19 +123,19 @@ namespace osu.Game.Overlays.Changelog }, t => { t.Font = fontMedium; - t.Colour = entryColor; + t.Colour = entryColour; }); else if (entry.GithubUser.GithubUrl != null) title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, Online.Chat.LinkAction.External, null, null, t => { t.Font = fontMedium; - t.Colour = entryColor; + t.Colour = entryColour; }); else title.AddText(entry.GithubUser.DisplayName, t => { t.Font = fontSmall; - t.Colour = entryColor; + t.Colour = entryColour; }); ChangelogEntries.Add(title); From d058f7779308c20c667b796fd490c01317a3aad2 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Sat, 8 Jun 2019 16:36:48 +0900 Subject: [PATCH 300/375] Update resources for iOS --- osu.iOS.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.iOS.props b/osu.iOS.props index 8886184a2e..3a5090d968 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -104,7 +104,7 @@ - + From e8c73f3127d953a0ca188f0e53b79066e847eb07 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sat, 8 Jun 2019 09:45:34 +0200 Subject: [PATCH 301/375] Make APIChangelogEntry.Major a non-nullable property --- osu.Game/Online/API/Requests/Responses/APIChangelogEntry.cs | 2 +- osu.Game/Overlays/Changelog/ChangelogBuild.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Online/API/Requests/Responses/APIChangelogEntry.cs b/osu.Game/Online/API/Requests/Responses/APIChangelogEntry.cs index abaff9b7ae..140e228acd 100644 --- a/osu.Game/Online/API/Requests/Responses/APIChangelogEntry.cs +++ b/osu.Game/Online/API/Requests/Responses/APIChangelogEntry.cs @@ -36,7 +36,7 @@ namespace osu.Game.Online.API.Requests.Responses public string MessageHtml { get; set; } [JsonProperty("major")] - public bool? Major { get; set; } + public bool Major { get; set; } [JsonProperty("created_at")] public DateTimeOffset? CreatedAt { get; set; } diff --git a/osu.Game/Overlays/Changelog/ChangelogBuild.cs b/osu.Game/Overlays/Changelog/ChangelogBuild.cs index ae5ba3fa4e..3d145af562 100644 --- a/osu.Game/Overlays/Changelog/ChangelogBuild.cs +++ b/osu.Game/Overlays/Changelog/ChangelogBuild.cs @@ -74,7 +74,7 @@ namespace osu.Game.Overlays.Changelog Margin = new MarginPadding { Vertical = 5 }, }; - var entryColour = entry.Major != null && (bool)entry.Major ? colours.YellowLight : Color4.White; + var entryColour = entry.Major ? colours.YellowLight : Color4.White; title.AddIcon(FontAwesome.Solid.Check, t => { From 383b937a7e44b2eac1f20ba7b1b1a6cfce0bfae2 Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Sat, 8 Jun 2019 19:10:00 +0300 Subject: [PATCH 302/375] Rename F grade to D --- osu.Game/Scoring/ScoreRank.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Scoring/ScoreRank.cs b/osu.Game/Scoring/ScoreRank.cs index a93d015f1b..d3479e21aa 100644 --- a/osu.Game/Scoring/ScoreRank.cs +++ b/osu.Game/Scoring/ScoreRank.cs @@ -7,10 +7,10 @@ namespace osu.Game.Scoring { public enum ScoreRank { - [Description(@"F")] + [Description(@"D")] F, - [Description(@"F")] + [Description(@"D")] D, [Description(@"C")] From 17362a368e2ab792c43e05cc992d6b729247b62e Mon Sep 17 00:00:00 2001 From: Ludde <48018938+yousef157@users.noreply.github.com> Date: Sat, 8 Jun 2019 20:10:52 +0400 Subject: [PATCH 303/375] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 91ea34e999..04f133fd56 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ If you are not interested in developing the game, you can consume our [binary re | ------------- | ------------- | - **Linux** users are recommended to self-compile until we have official deployment in place. -- **iOS** users can join the [TestFlight beta program](https://t.co/xQJmHkfC18) (note that due to high demand this is reulgarly full). +- **iOS** users can join the [TestFlight beta program](https://t.co/xQJmHkfC18) (note that due to high demand this is regularly full). - **Android** users can self-compile, and expect a public beta soon. If your platform is not listed above, there is still a chance you can manually build it by following the instructions below. From dfbc6528031fc340a9a718699db236172aeac207 Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Sat, 8 Jun 2019 19:32:26 +0300 Subject: [PATCH 304/375] Use ScoreRank.D instead of F --- osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs index 89da0fc254..cbcf3e6160 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs @@ -46,7 +46,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Text = "#1", Font = OsuFont.GetFont(size: 30, weight: FontWeight.Bold, italics: true) }, - rank = new DrawableRank(ScoreRank.F) + rank = new DrawableRank(ScoreRank.D) { Anchor = Anchor.Centre, Origin = Anchor.Centre, From d3ff2c6dd5bbc9a14653e9fa6a72bb0093f6d519 Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Sat, 8 Jun 2019 19:34:03 +0300 Subject: [PATCH 305/375] Use ScoreRank.D instead of F --- osu.Game.Tests/Visual/SongSelect/TestSceneLeaderboard.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneLeaderboard.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneLeaderboard.cs index 3d75470328..9365e2c5b1 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneLeaderboard.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneLeaderboard.cs @@ -188,7 +188,7 @@ namespace osu.Game.Tests.Visual.SongSelect }, new ScoreInfo { - Rank = ScoreRank.F, + Rank = ScoreRank.D, Accuracy = 0.6025, MaxCombo = 244, TotalScore = 1707827, @@ -206,7 +206,7 @@ namespace osu.Game.Tests.Visual.SongSelect }, new ScoreInfo { - Rank = ScoreRank.F, + Rank = ScoreRank.D, Accuracy = 0.5140, MaxCombo = 244, TotalScore = 1707827, @@ -224,7 +224,7 @@ namespace osu.Game.Tests.Visual.SongSelect }, new ScoreInfo { - Rank = ScoreRank.F, + Rank = ScoreRank.D, Accuracy = 0.4222, MaxCombo = 244, TotalScore = 1707827, From fc8644a73e0a8cf37e90ec199f2c4b5ac2b785c5 Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Sat, 8 Jun 2019 19:34:52 +0300 Subject: [PATCH 306/375] Use ScoreRank.D instead of F --- osu.Game.Tests/Visual/Online/TestSceneScoresContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneScoresContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneScoresContainer.cs index 6815018be6..2f88a4b01d 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneScoresContainer.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneScoresContainer.cs @@ -157,7 +157,7 @@ namespace osu.Game.Tests.Visual.Online FlagName = @"TH", }, }, - Rank = ScoreRank.F, + Rank = ScoreRank.D, PP = 160, MaxCombo = 1234, TotalScore = 123456, From a2b9dba92cce57e04a956efd1f4baa7906488373 Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Sat, 8 Jun 2019 19:35:29 +0300 Subject: [PATCH 307/375] Remove ScoreRank.F --- osu.Game/Scoring/ScoreRank.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Game/Scoring/ScoreRank.cs b/osu.Game/Scoring/ScoreRank.cs index d3479e21aa..696d493830 100644 --- a/osu.Game/Scoring/ScoreRank.cs +++ b/osu.Game/Scoring/ScoreRank.cs @@ -7,9 +7,6 @@ namespace osu.Game.Scoring { public enum ScoreRank { - [Description(@"D")] - F, - [Description(@"D")] D, From afc3a089536d72fe7f0b357866caa31dafb3c8fc Mon Sep 17 00:00:00 2001 From: Ganendra Afrasya Date: Sun, 9 Jun 2019 13:11:40 +0700 Subject: [PATCH 308/375] Use existing setting instead Now it read IncreaseFirstObjectVisibility bindable instead --- osu.Game.Rulesets.Osu/Mods/OsuModGrow.cs | 6 +++--- osu.Game/Configuration/OsuConfigManager.cs | 3 --- .../Overlays/Settings/Sections/Gameplay/ModsSettings.cs | 5 ----- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModGrow.cs b/osu.Game.Rulesets.Osu/Mods/OsuModGrow.cs index a5df36e9ff..3d64bb4ce8 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModGrow.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModGrow.cs @@ -28,16 +28,16 @@ namespace osu.Game.Rulesets.Osu.Mods public override double ScoreMultiplier => 1; - protected Bindable IncreaseFirstObjectGrowVisibility = new Bindable(); + protected Bindable IncreaseFirstObjectVisibility = new Bindable(); public void ReadFromConfig(OsuConfigManager config) { - IncreaseFirstObjectGrowVisibility = config.GetBindable(OsuSetting.IncreaseFirstObjectGrowVisibility); + IncreaseFirstObjectVisibility = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility); } public void ApplyToDrawableHitObjects(IEnumerable drawables) { - foreach (var drawable in drawables.Skip(IncreaseFirstObjectGrowVisibility.Value ? 1 : 0)) + foreach (var drawable in drawables.Skip(IncreaseFirstObjectVisibility.Value ? 1 : 0)) { switch (drawable) { diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index b5a099aa3b..795f0b43f7 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -85,8 +85,6 @@ namespace osu.Game.Configuration Set(OsuSetting.IncreaseFirstObjectVisibility, true); - Set(OsuSetting.IncreaseFirstObjectGrowVisibility, true); - // Update Set(OsuSetting.ReleaseStream, ReleaseStream.Lazer); @@ -160,7 +158,6 @@ namespace osu.Game.Configuration BeatmapSkins, BeatmapHitsounds, IncreaseFirstObjectVisibility, - IncreaseFirstObjectGrowVisibility, ScoreDisplayMode, ExternalLinkWarning, Scaling, diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/ModsSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/ModsSettings.cs index 538b2b2761..2cf14f5aff 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/ModsSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/ModsSettings.cs @@ -20,11 +20,6 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay LabelText = "Increase visibility of first object with \"Hidden\" mod", Bindable = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility) }, - new SettingsCheckbox - { - LabelText = "Increase visibility of first object with \"Grow\" mod", - Bindable = config.GetBindable(OsuSetting.IncreaseFirstObjectGrowVisibility) - }, }; } } From 49193a2703edb7c5d35b04d0c206031e2a2708f9 Mon Sep 17 00:00:00 2001 From: Ganendra Afrasya Date: Sun, 9 Jun 2019 13:12:41 +0700 Subject: [PATCH 309/375] Rename the setting label --- osu.Game/Overlays/Settings/Sections/Gameplay/ModsSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/ModsSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/ModsSettings.cs index 2cf14f5aff..2c6b2663c6 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/ModsSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/ModsSettings.cs @@ -17,7 +17,7 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay { new SettingsCheckbox { - LabelText = "Increase visibility of first object with \"Hidden\" mod", + LabelText = "Increase visibility of first object when visual impairment mods are enabled", Bindable = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility) }, }; From 8cdcf251b5aca691d3af18b459cbb12f5c1704b7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 9 Jun 2019 16:30:04 +0900 Subject: [PATCH 310/375] Make local bindable private --- osu.Game.Rulesets.Osu/Mods/OsuModGrow.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModGrow.cs b/osu.Game.Rulesets.Osu/Mods/OsuModGrow.cs index 3d64bb4ce8..8072dc09c1 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModGrow.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModGrow.cs @@ -28,16 +28,16 @@ namespace osu.Game.Rulesets.Osu.Mods public override double ScoreMultiplier => 1; - protected Bindable IncreaseFirstObjectVisibility = new Bindable(); + private Bindable increaseFirstObjectVisibility = new Bindable(); public void ReadFromConfig(OsuConfigManager config) { - IncreaseFirstObjectVisibility = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility); + increaseFirstObjectVisibility = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility); } public void ApplyToDrawableHitObjects(IEnumerable drawables) { - foreach (var drawable in drawables.Skip(IncreaseFirstObjectVisibility.Value ? 1 : 0)) + foreach (var drawable in drawables.Skip(increaseFirstObjectVisibility.Value ? 1 : 0)) { switch (drawable) { From d500f3605ef8c71f6a40256b86fe6a5a618d0558 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 9 Jun 2019 16:47:48 +0900 Subject: [PATCH 311/375] Fix checkboxes with long labels overlapping nub --- .../Graphics/UserInterface/OsuCheckbox.cs | 22 ++++++++++--------- .../Overlays/Settings/SettingsCheckbox.cs | 1 - 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs index cd1147e3d3..dd126d8518 100644 --- a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs +++ b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs @@ -6,10 +6,9 @@ using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Bindables; using osu.Framework.Graphics; -using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input.Events; -using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.Containers; using osuTK.Graphics; namespace osu.Game.Graphics.UserInterface @@ -33,7 +32,6 @@ namespace osu.Game.Graphics.UserInterface public string LabelText { - get => labelSpriteText?.Text; set { if (labelSpriteText != null) @@ -53,7 +51,7 @@ namespace osu.Game.Graphics.UserInterface protected readonly Nub Nub; - private readonly SpriteText labelSpriteText; + private readonly OsuTextFlowContainer labelSpriteText; private SampleChannel sampleChecked; private SampleChannel sampleUnchecked; @@ -62,24 +60,28 @@ namespace osu.Game.Graphics.UserInterface AutoSizeAxes = Axes.Y; RelativeSizeAxes = Axes.X; + const float nub_padding = 5; + Children = new Drawable[] { - labelSpriteText = new OsuSpriteText(), + labelSpriteText = new OsuTextFlowContainer + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Padding = new MarginPadding { Right = Nub.EXPANDED_SIZE + nub_padding } + }, Nub = new Nub { Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, - Margin = new MarginPadding { Right = 5 }, + Margin = new MarginPadding { Right = nub_padding }, }, new HoverClickSounds() }; Nub.Current.BindTo(Current); - Current.DisabledChanged += disabled => - { - labelSpriteText.Alpha = Nub.Alpha = disabled ? 0.3f : 1; - }; + Current.DisabledChanged += disabled => { labelSpriteText.Alpha = Nub.Alpha = disabled ? 0.3f : 1; }; } protected override void LoadComplete() diff --git a/osu.Game/Overlays/Settings/SettingsCheckbox.cs b/osu.Game/Overlays/Settings/SettingsCheckbox.cs index 46c23c3bbf..a1501d8015 100644 --- a/osu.Game/Overlays/Settings/SettingsCheckbox.cs +++ b/osu.Game/Overlays/Settings/SettingsCheckbox.cs @@ -14,7 +14,6 @@ namespace osu.Game.Overlays.Settings public override string LabelText { - get => checkbox.LabelText; set => checkbox.LabelText = value; } } From cd89633dee31f80d9181a00467b00159ae20cf76 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 9 Jun 2019 17:07:23 +0900 Subject: [PATCH 312/375] Rename variable to match --- osu.Game/Graphics/UserInterface/OsuCheckbox.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs index dd126d8518..5d41075725 100644 --- a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs +++ b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs @@ -34,24 +34,24 @@ namespace osu.Game.Graphics.UserInterface { set { - if (labelSpriteText != null) - labelSpriteText.Text = value; + if (labelText != null) + labelText.Text = value; } } public MarginPadding LabelPadding { - get => labelSpriteText?.Padding ?? new MarginPadding(); + get => labelText?.Padding ?? new MarginPadding(); set { - if (labelSpriteText != null) - labelSpriteText.Padding = value; + if (labelText != null) + labelText.Padding = value; } } protected readonly Nub Nub; - private readonly OsuTextFlowContainer labelSpriteText; + private readonly OsuTextFlowContainer labelText; private SampleChannel sampleChecked; private SampleChannel sampleUnchecked; @@ -64,7 +64,7 @@ namespace osu.Game.Graphics.UserInterface Children = new Drawable[] { - labelSpriteText = new OsuTextFlowContainer + labelText = new OsuTextFlowContainer { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, @@ -81,7 +81,7 @@ namespace osu.Game.Graphics.UserInterface Nub.Current.BindTo(Current); - Current.DisabledChanged += disabled => { labelSpriteText.Alpha = Nub.Alpha = disabled ? 0.3f : 1; }; + Current.DisabledChanged += disabled => { labelText.Alpha = Nub.Alpha = disabled ? 0.3f : 1; }; } protected override void LoadComplete() From 807d434be03898334671c6fd382cda252633d6c8 Mon Sep 17 00:00:00 2001 From: Shane Woolcock Date: Sun, 9 Jun 2019 17:52:02 +0930 Subject: [PATCH 313/375] Access WindowModes via IBindableList --- osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs b/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs index 58d2eb1f1e..36c4fb5252 100644 --- a/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs @@ -27,7 +27,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics private Bindable scalingMode; private Bindable sizeFullscreen; - private readonly BindableList windowModes = new BindableList(); + private readonly IBindableList windowModes = new BindableList(); private OsuGameBase game; private SettingsDropdown resolutionDropdown; From a5007b94dbd1b66d97d461c830fb11ef6f784764 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 9 Jun 2019 22:29:00 +0900 Subject: [PATCH 314/375] Update resources --- osu.Game/osu.Game.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 654c62e1d8..eeb1f2bee3 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -14,7 +14,7 @@ - + From d964f6ba9e0e166255fdedb1726472ef2e1bbd24 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 00:56:35 +0900 Subject: [PATCH 315/375] Tween track frequency on pause --- osu.Game/Screens/Play/GameplayClockContainer.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/GameplayClockContainer.cs b/osu.Game/Screens/Play/GameplayClockContainer.cs index c151e598f7..4b35e90f68 100644 --- a/osu.Game/Screens/Play/GameplayClockContainer.cs +++ b/osu.Game/Screens/Play/GameplayClockContainer.cs @@ -69,6 +69,7 @@ namespace osu.Game.Screens.Play RelativeSizeAxes = Axes.Both; sourceClock = (IAdjustableClock)beatmap.Track ?? new StopwatchClock(); + (sourceClock as IAdjustableAudioComponent)?.AddAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust); adjustableClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; @@ -85,8 +86,16 @@ namespace osu.Game.Screens.Play GameplayClock.IsPaused.BindTo(IsPaused); } + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + (sourceClock as IAdjustableAudioComponent)?.RemoveAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust); + } + private double totalOffset => userOffsetClock.Offset + platformOffsetClock.Offset; + private readonly BindableDouble pauseFreqAdjust = new BindableDouble(1); + [BackgroundDependencyLoader] private void load(OsuConfigManager config) { @@ -122,6 +131,8 @@ namespace osu.Game.Screens.Play Seek(GameplayClock.CurrentTime); adjustableClock.Start(); IsPaused.Value = false; + + this.TransformBindableTo(pauseFreqAdjust, 1, 200, Easing.In); } /// @@ -143,7 +154,8 @@ namespace osu.Game.Screens.Play public void Stop() { - adjustableClock.Stop(); + this.TransformBindableTo(pauseFreqAdjust, 0, 200, Easing.Out).OnComplete(_ => { adjustableClock.Stop(); }); + IsPaused.Value = true; } From 59b624d4ba4a8cf89b068e5abcf4cec2a38a02b9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 01:08:39 +0900 Subject: [PATCH 316/375] Fix test regression --- osu.Game.Tests/Visual/Gameplay/TestScenePause.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs index 12e91df77c..0f5ee66f50 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs @@ -189,7 +189,7 @@ namespace osu.Game.Tests.Visual.Gameplay AddAssert("pause overlay " + (isShown ? "shown" : "hidden"), () => Player.PauseOverlayVisible == isShown); private void confirmClockRunning(bool isRunning) => - AddAssert("clock " + (isRunning ? "running" : "stopped"), () => Player.GameplayClockContainer.GameplayClock.IsRunning == isRunning); + AddUntilStep("clock " + (isRunning ? "running" : "stopped"), () => Player.GameplayClockContainer.GameplayClock.IsRunning == isRunning); protected override bool AllowFail => true; From 5c2ea0b1a719348b5a1ae0bd251d3aecb45fa250 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 01:14:46 +0900 Subject: [PATCH 317/375] Move dispose to end of file --- osu.Game/Screens/Play/GameplayClockContainer.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Play/GameplayClockContainer.cs b/osu.Game/Screens/Play/GameplayClockContainer.cs index 4b35e90f68..6a03271b86 100644 --- a/osu.Game/Screens/Play/GameplayClockContainer.cs +++ b/osu.Game/Screens/Play/GameplayClockContainer.cs @@ -86,12 +86,6 @@ namespace osu.Game.Screens.Play GameplayClock.IsPaused.BindTo(IsPaused); } - protected override void Dispose(bool isDisposing) - { - base.Dispose(isDisposing); - (sourceClock as IAdjustableAudioComponent)?.RemoveAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust); - } - private double totalOffset => userOffsetClock.Offset + platformOffsetClock.Offset; private readonly BindableDouble pauseFreqAdjust = new BindableDouble(1); @@ -154,7 +148,7 @@ namespace osu.Game.Screens.Play public void Stop() { - this.TransformBindableTo(pauseFreqAdjust, 0, 200, Easing.Out).OnComplete(_ => { adjustableClock.Stop(); }); + this.TransformBindableTo(pauseFreqAdjust, 0, 200, Easing.Out).OnComplete(_ => adjustableClock.Stop()); IsPaused.Value = true; } @@ -187,5 +181,11 @@ namespace osu.Game.Screens.Play foreach (var mod in mods.OfType()) mod.ApplyToClock(sourceClock); } + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + (sourceClock as IAdjustableAudioComponent)?.RemoveAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust); + } } } From 4f6978f2aa59c7a95c9b7706ad42f6fe6c258643 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 9 Jun 2019 20:01:19 +0200 Subject: [PATCH 318/375] Apply review suggestions. --- osu.Game/Screens/OsuScreen.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 3f98595d0e..3b5e0fd0d6 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -64,17 +64,17 @@ namespace osu.Game.Screens /// protected UserActivity ScreenActivity { - get => activity; + get => screenActivity; set { - if (value == activity) return; + if (value == screenActivity) return; - activity = value; - setUserActivity(activity); + screenActivity = value; + setUserActivity(screenActivity); } } - private UserActivity activity; + private UserActivity screenActivity; /// /// Whether to disallow changes to game-wise Beatmap/Ruleset bindables for this screen (and all children). @@ -122,11 +122,11 @@ namespace osu.Game.Screens Anchor = Anchor.Centre; Origin = Anchor.Centre; - activity = null; + screenActivity = null; } [BackgroundDependencyLoader(true)] - private void load(OsuGame osu, AudioManager audio, IAPIProvider provider) + private void load(OsuGame osu, AudioManager audio) { sampleExit = audio.Samples.Get(@"UI/screen-back"); } @@ -152,7 +152,7 @@ namespace osu.Game.Screens sampleExit?.Play(); applyArrivingDefaults(true); - setUserActivity(activity); + setUserActivity(screenActivity); base.OnResuming(last); } From f090e292c974c2147f7f34b3cc79a5461e7df817 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 28 May 2019 18:59:21 +0900 Subject: [PATCH 319/375] Move ArchiveModelManager import process to async flow --- .../Beatmaps/IO/ImportBeatmapTest.cs | 50 +++--- osu.Game.Tests/Scores/IO/ImportScoreTest.cs | 30 ++-- .../TestSceneBackgroundScreenBeatmap.cs | 2 +- ...tSceneUpdateableBeatmapBackgroundSprite.cs | 2 +- osu.Game.Tests/osu.Game.Tests.csproj | 5 + osu.Game/Beatmaps/BeatmapManager.cs | 163 +++++++++++++----- osu.Game/Database/ArchiveModelManager.cs | 158 +++++++++-------- osu.Game/Database/ICanAcceptFiles.cs | 4 +- osu.Game/IPC/ArchiveImportIPCChannel.cs | 2 +- osu.Game/OsuGameBase.cs | 5 +- .../Notifications/ProgressNotification.cs | 7 + osu.Game/Screens/Menu/Intro.cs | 2 +- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Skinning/SkinManager.cs | 6 +- 14 files changed, 273 insertions(+), 165 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index f020c2a805..4c9260f640 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -21,14 +21,14 @@ namespace osu.Game.Tests.Beatmaps.IO public class ImportBeatmapTest { [Test] - public void TestImportWhenClosed() + public async Task TestImportWhenClosed() { //unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here. using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportWhenClosed")) { try { - LoadOszIntoOsu(loadOsu(host)); + await LoadOszIntoOsu(loadOsu(host)); } finally { @@ -38,7 +38,7 @@ namespace osu.Game.Tests.Beatmaps.IO } [Test] - public void TestImportThenDelete() + public async Task TestImportThenDelete() { //unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here. using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportThenDelete")) @@ -47,7 +47,7 @@ namespace osu.Game.Tests.Beatmaps.IO { var osu = loadOsu(host); - var imported = LoadOszIntoOsu(osu); + var imported = await LoadOszIntoOsu(osu); deleteBeatmapSet(imported, osu); } @@ -59,7 +59,7 @@ namespace osu.Game.Tests.Beatmaps.IO } [Test] - public void TestImportThenImport() + public async Task TestImportThenImport() { //unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here. using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportThenImport")) @@ -68,8 +68,8 @@ namespace osu.Game.Tests.Beatmaps.IO { var osu = loadOsu(host); - var imported = LoadOszIntoOsu(osu); - var importedSecondTime = LoadOszIntoOsu(osu); + var imported = await LoadOszIntoOsu(osu); + var importedSecondTime = await LoadOszIntoOsu(osu); // check the newly "imported" beatmap is actually just the restored previous import. since it matches hash. Assert.IsTrue(imported.ID == importedSecondTime.ID); @@ -88,7 +88,7 @@ namespace osu.Game.Tests.Beatmaps.IO } [Test] - public void TestRollbackOnFailure() + public async Task TestRollbackOnFailure() { //unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here. using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestRollbackOnFailure")) @@ -104,7 +104,7 @@ namespace osu.Game.Tests.Beatmaps.IO manager.ItemAdded += (_, __) => fireCount++; manager.ItemRemoved += _ => fireCount++; - var imported = LoadOszIntoOsu(osu); + var imported = await LoadOszIntoOsu(osu); Assert.AreEqual(0, fireCount -= 1); @@ -132,7 +132,7 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.AreEqual(12, manager.QueryBeatmaps(_ => true).ToList().Count); // this will trigger purging of the existing beatmap (online set id match) but should rollback due to broken osu. - manager.Import(breakTemp); + await manager.Import(breakTemp); // no events should be fired in the case of a rollback. Assert.AreEqual(0, fireCount); @@ -149,7 +149,7 @@ namespace osu.Game.Tests.Beatmaps.IO } [Test] - public void TestImportThenImportDifferentHash() + public async Task TestImportThenImportDifferentHash() { //unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here. using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportThenImportDifferentHash")) @@ -159,12 +159,12 @@ namespace osu.Game.Tests.Beatmaps.IO var osu = loadOsu(host); var manager = osu.Dependencies.Get(); - var imported = LoadOszIntoOsu(osu); + var imported = await LoadOszIntoOsu(osu); imported.Hash += "-changed"; manager.Update(imported); - var importedSecondTime = LoadOszIntoOsu(osu); + var importedSecondTime = await LoadOszIntoOsu(osu); Assert.IsTrue(imported.ID != importedSecondTime.ID); Assert.IsTrue(imported.Beatmaps.First().ID < importedSecondTime.Beatmaps.First().ID); @@ -181,7 +181,7 @@ namespace osu.Game.Tests.Beatmaps.IO } [Test] - public void TestImportThenDeleteThenImport() + public async Task TestImportThenDeleteThenImport() { //unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here. using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportThenDeleteThenImport")) @@ -190,11 +190,11 @@ namespace osu.Game.Tests.Beatmaps.IO { var osu = loadOsu(host); - var imported = LoadOszIntoOsu(osu); + var imported = await LoadOszIntoOsu(osu); deleteBeatmapSet(imported, osu); - var importedSecondTime = LoadOszIntoOsu(osu); + var importedSecondTime = await LoadOszIntoOsu(osu); // check the newly "imported" beatmap is actually just the restored previous import. since it matches hash. Assert.IsTrue(imported.ID == importedSecondTime.ID); @@ -209,7 +209,7 @@ namespace osu.Game.Tests.Beatmaps.IO [TestCase(true)] [TestCase(false)] - public void TestImportThenDeleteThenImportWithOnlineIDMismatch(bool set) + public async Task TestImportThenDeleteThenImportWithOnlineIDMismatch(bool set) { //unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here. using (HeadlessGameHost host = new CleanRunHeadlessGameHost($"TestImportThenDeleteThenImport-{set}")) @@ -218,7 +218,7 @@ namespace osu.Game.Tests.Beatmaps.IO { var osu = loadOsu(host); - var imported = LoadOszIntoOsu(osu); + var imported = await LoadOszIntoOsu(osu); if (set) imported.OnlineBeatmapSetID = 1234; @@ -229,7 +229,7 @@ namespace osu.Game.Tests.Beatmaps.IO deleteBeatmapSet(imported, osu); - var importedSecondTime = LoadOszIntoOsu(osu); + var importedSecondTime = await LoadOszIntoOsu(osu); // check the newly "imported" beatmap has been reimported due to mismatch (even though hashes matched) Assert.IsTrue(imported.ID != importedSecondTime.ID); @@ -243,7 +243,7 @@ namespace osu.Game.Tests.Beatmaps.IO } [Test] - public void TestImportWithDuplicateBeatmapIDs() + public async Task TestImportWithDuplicateBeatmapIDs() { //unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here. using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportWithDuplicateBeatmapID")) @@ -284,7 +284,7 @@ namespace osu.Game.Tests.Beatmaps.IO var manager = osu.Dependencies.Get(); - var imported = manager.Import(toImport); + var imported = await manager.Import(toImport); Assert.NotNull(imported); Assert.AreEqual(null, imported.Beatmaps[0].OnlineBeatmapID); @@ -330,7 +330,7 @@ namespace osu.Game.Tests.Beatmaps.IO } [Test] - public void TestImportWhenFileOpen() + public async Task TestImportWhenFileOpen() { using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportWhenFileOpen")) { @@ -339,7 +339,7 @@ namespace osu.Game.Tests.Beatmaps.IO var osu = loadOsu(host); var temp = TestResources.GetTestBeatmapForImport(); using (File.OpenRead(temp)) - osu.Dependencies.Get().Import(temp); + await osu.Dependencies.Get().Import(temp); ensureLoaded(osu); File.Delete(temp); Assert.IsFalse(File.Exists(temp), "We likely held a read lock on the file when we shouldn't"); @@ -351,13 +351,13 @@ namespace osu.Game.Tests.Beatmaps.IO } } - public static BeatmapSetInfo LoadOszIntoOsu(OsuGameBase osu, string path = null) + public static async Task LoadOszIntoOsu(OsuGameBase osu, string path = null) { var temp = path ?? TestResources.GetTestBeatmapForImport(); var manager = osu.Dependencies.Get(); - manager.Import(temp); + await manager.Import(temp); var imported = manager.GetAllUsableBeatmapSets(); diff --git a/osu.Game.Tests/Scores/IO/ImportScoreTest.cs b/osu.Game.Tests/Scores/IO/ImportScoreTest.cs index e39f18c3cd..4babb07213 100644 --- a/osu.Game.Tests/Scores/IO/ImportScoreTest.cs +++ b/osu.Game.Tests/Scores/IO/ImportScoreTest.cs @@ -23,13 +23,13 @@ namespace osu.Game.Tests.Scores.IO public class ImportScoreTest { [Test] - public void TestBasicImport() + public async Task TestBasicImport() { using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestBasicImport")) { try { - var osu = loadOsu(host); + var osu = await loadOsu(host); var toImport = new ScoreInfo { @@ -43,7 +43,7 @@ namespace osu.Game.Tests.Scores.IO OnlineScoreID = 12345, }; - var imported = loadIntoOsu(osu, toImport); + var imported = await loadIntoOsu(osu, toImport); Assert.AreEqual(toImport.Rank, imported.Rank); Assert.AreEqual(toImport.TotalScore, imported.TotalScore); @@ -62,20 +62,20 @@ namespace osu.Game.Tests.Scores.IO } [Test] - public void TestImportMods() + public async Task TestImportMods() { using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportMods")) { try { - var osu = loadOsu(host); + var osu = await loadOsu(host); var toImport = new ScoreInfo { Mods = new Mod[] { new OsuModHardRock(), new OsuModDoubleTime() }, }; - var imported = loadIntoOsu(osu, toImport); + var imported = await loadIntoOsu(osu, toImport); Assert.IsTrue(imported.Mods.Any(m => m is OsuModHardRock)); Assert.IsTrue(imported.Mods.Any(m => m is OsuModDoubleTime)); @@ -88,13 +88,13 @@ namespace osu.Game.Tests.Scores.IO } [Test] - public void TestImportStatistics() + public async Task TestImportStatistics() { using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportStatistics")) { try { - var osu = loadOsu(host); + var osu = await loadOsu(host); var toImport = new ScoreInfo { @@ -105,7 +105,7 @@ namespace osu.Game.Tests.Scores.IO } }; - var imported = loadIntoOsu(osu, toImport); + var imported = await loadIntoOsu(osu, toImport); Assert.AreEqual(toImport.Statistics[HitResult.Perfect], imported.Statistics[HitResult.Perfect]); Assert.AreEqual(toImport.Statistics[HitResult.Miss], imported.Statistics[HitResult.Miss]); @@ -117,7 +117,7 @@ namespace osu.Game.Tests.Scores.IO } } - private ScoreInfo loadIntoOsu(OsuGameBase osu, ScoreInfo score) + private async Task loadIntoOsu(OsuGameBase osu, ScoreInfo score) { var beatmapManager = osu.Dependencies.Get(); @@ -125,20 +125,24 @@ namespace osu.Game.Tests.Scores.IO score.Ruleset = new OsuRuleset().RulesetInfo; var scoreManager = osu.Dependencies.Get(); - scoreManager.Import(score); + await scoreManager.Import(score); return scoreManager.GetAllUsableScores().First(); } - private OsuGameBase loadOsu(GameHost host) + private async Task loadOsu(GameHost host) { var osu = new OsuGameBase(); + +#pragma warning disable 4014 Task.Run(() => host.Run(osu)); +#pragma warning restore 4014 + waitForOrAssert(() => osu.IsLoaded, @"osu! failed to start in a reasonable amount of time"); var beatmapFile = TestResources.GetTestBeatmapForImport(); var beatmapManager = osu.Dependencies.Get(); - beatmapManager.Import(beatmapFile); + await beatmapManager.Import(beatmapFile); return osu; } diff --git a/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs index 7104a420a3..8b941e4633 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs @@ -72,7 +72,7 @@ namespace osu.Game.Tests.Visual.Background Dependencies.Cache(manager = new BeatmapManager(LocalStorage, factory, rulesets, null, audio, host, Beatmap.Default)); Dependencies.Cache(new OsuConfigManager(LocalStorage)); - manager.Import(TestResources.GetTestBeatmapForImport()); + manager.Import(TestResources.GetTestBeatmapForImport()).Wait(); Beatmap.SetDefault(); } diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs index f59458ef8d..c361598354 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs @@ -32,7 +32,7 @@ namespace osu.Game.Tests.Visual.UserInterface this.api = api; this.rulesets = rulesets; - testBeatmap = ImportBeatmapTest.LoadOszIntoOsu(osu); + testBeatmap = ImportBeatmapTest.LoadOszIntoOsu(osu).Result; } [Test] diff --git a/osu.Game.Tests/osu.Game.Tests.csproj b/osu.Game.Tests/osu.Game.Tests.csproj index 11d70ee7be..403ae16885 100644 --- a/osu.Game.Tests/osu.Game.Tests.csproj +++ b/osu.Game.Tests/osu.Game.Tests.csproj @@ -18,4 +18,9 @@ + + + ..\..\..\..\..\usr\local\share\dotnet\sdk\NuGetFallbackFolder\microsoft.win32.registry\4.5.0\ref\netstandard2.0\Microsoft.Win32.Registry.dll + + \ No newline at end of file diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index b6fe7f88fa..f5ef52a93b 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -2,10 +2,12 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; using System.Linq.Expressions; +using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using osu.Framework.Audio; @@ -14,6 +16,7 @@ using osu.Framework.Extensions; using osu.Framework.Graphics.Textures; using osu.Framework.Logging; using osu.Framework.Platform; +using osu.Framework.Threading; using osu.Game.Beatmaps.Formats; using osu.Game.Database; using osu.Game.IO.Archives; @@ -72,6 +75,8 @@ namespace osu.Game.Beatmaps private readonly List currentDownloads = new List(); + private readonly BeatmapUpdateQueue updateQueue; + public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, AudioManager audioManager, GameHost host = null, WorkingBeatmap defaultBeatmap = null) : base(storage, contextFactory, new BeatmapStore(contextFactory), host) @@ -86,9 +91,11 @@ namespace osu.Game.Beatmaps beatmaps = (BeatmapStore)ModelStore; beatmaps.BeatmapHidden += b => BeatmapHidden?.Invoke(b); beatmaps.BeatmapRestored += b => BeatmapRestored?.Invoke(b); + + updateQueue = new BeatmapUpdateQueue(api); } - protected override void Populate(BeatmapSetInfo beatmapSet, ArchiveReader archive) + protected override async Task Populate(BeatmapSetInfo beatmapSet, ArchiveReader archive, CancellationToken cancellationToken = default) { if (archive != null) beatmapSet.Beatmaps = createBeatmapDifficulties(archive); @@ -104,8 +111,7 @@ namespace osu.Game.Beatmaps validateOnlineIds(beatmapSet); - foreach (BeatmapInfo b in beatmapSet.Beatmaps) - fetchAndPopulateOnlineValues(b); + await Task.WhenAll(beatmapSet.Beatmaps.Select(b => updateQueue.Enqueue(new UpdateItem(b, cancellationToken)).Task).ToArray()); } protected override void PreImport(BeatmapSetInfo beatmapSet) @@ -181,10 +187,10 @@ namespace osu.Game.Beatmaps request.Success += filename => { - Task.Factory.StartNew(() => + Task.Factory.StartNew(async () => { // This gets scheduled back to the update thread, but we want the import to run in the background. - Import(downloadNotification, filename); + await Import(downloadNotification, filename); currentDownloads.Remove(request); }, TaskCreationOptions.LongRunning); }; @@ -381,47 +387,6 @@ namespace osu.Game.Beatmaps return beatmapInfos; } - /// - /// Query the API to populate missing values like OnlineBeatmapID / OnlineBeatmapSetID or (Rank-)Status. - /// - /// The beatmap to populate. - /// Whether to re-query if the provided beatmap already has populated values. - /// True if population was successful. - private bool fetchAndPopulateOnlineValues(BeatmapInfo beatmap, bool force = false) - { - if (api?.State != APIState.Online) - return false; - - if (!force && beatmap.OnlineBeatmapID != null && beatmap.BeatmapSet.OnlineBeatmapSetID != null - && beatmap.Status != BeatmapSetOnlineStatus.None && beatmap.BeatmapSet.Status != BeatmapSetOnlineStatus.None) - return true; - - Logger.Log("Attempting online lookup for the missing values...", LoggingTarget.Database); - - try - { - var req = new GetBeatmapRequest(beatmap); - - req.Perform(api); - - var res = req.Result; - - Logger.Log($"Successfully mapped to {res.OnlineBeatmapSetID} / {res.OnlineBeatmapID}.", LoggingTarget.Database); - - beatmap.Status = res.Status; - beatmap.BeatmapSet.Status = res.BeatmapSet.Status; - beatmap.BeatmapSet.OnlineBeatmapSetID = res.OnlineBeatmapSetID; - beatmap.OnlineBeatmapID = res.OnlineBeatmapID; - - return true; - } - catch (Exception e) - { - Logger.Log($"Failed ({e})", LoggingTarget.Database); - return false; - } - } - /// /// A dummy WorkingBeatmap for the purpose of retrieving a beatmap for star difficulty calculation. /// @@ -455,5 +420,111 @@ namespace osu.Game.Beatmaps public override bool IsImportant => false; } } + + private class BeatmapUpdateQueue + { + private readonly IAPIProvider api; + private readonly Queue queue = new Queue(); + + private int activeThreads; + + public BeatmapUpdateQueue(IAPIProvider api) + { + this.api = api; + } + + public UpdateItem Enqueue(UpdateItem item) + { + lock (queue) + { + queue.Enqueue(item); + + if (activeThreads >= 16) + return item; + + new Thread(runWork) { IsBackground = true }.Start(); + activeThreads++; + } + + return item; + } + + private void runWork() + { + while (true) + { + UpdateItem toProcess; + + lock (queue) + { + if (queue.Count == 0) + break; + + toProcess = queue.Dequeue(); + } + + toProcess.PerformUpdate(api); + } + + lock (queue) + activeThreads--; + } + } + + private class UpdateItem + { + public Task Task => tcs.Task; + + private readonly BeatmapInfo beatmap; + private readonly CancellationToken cancellationToken; + + private readonly TaskCompletionSource tcs = new TaskCompletionSource(); + + public UpdateItem(BeatmapInfo beatmap, CancellationToken cancellationToken) + { + this.beatmap = beatmap; + this.cancellationToken = cancellationToken; + } + + public void PerformUpdate(IAPIProvider api) + { + if (cancellationToken.IsCancellationRequested) + { + tcs.SetCanceled(); + return; + } + + if (api?.State != APIState.Online) + { + tcs.SetResult(false); + return; + } + + Logger.Log("Attempting online lookup for the missing values...", LoggingTarget.Database); + + var req = new GetBeatmapRequest(beatmap); + + req.Success += res => + { + Logger.Log($"Successfully mapped to {res.OnlineBeatmapSetID} / {res.OnlineBeatmapID}.", LoggingTarget.Database); + + beatmap.Status = res.Status; + beatmap.BeatmapSet.Status = res.BeatmapSet.Status; + beatmap.BeatmapSet.OnlineBeatmapSetID = res.OnlineBeatmapSetID; + beatmap.OnlineBeatmapID = res.OnlineBeatmapID; + + tcs.SetResult(true); + }; + + req.Failure += e => + { + Logger.Log($"Failed ({e})", LoggingTarget.Database); + + tcs.SetResult(false); + }; + + req.Perform(api); + } + } } } diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 54dbae9ddc..afc614772e 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -5,14 +5,17 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Threading; using System.Threading.Tasks; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore; using osu.Framework; using osu.Framework.Extensions; +using osu.Framework.Extensions.TypeExtensions; using osu.Framework.IO.File; using osu.Framework.Logging; using osu.Framework.Platform; +using osu.Framework.Threading; using osu.Game.IO; using osu.Game.IO.Archives; using osu.Game.IPC; @@ -109,8 +112,11 @@ namespace osu.Game.Database a.Invoke(); } + private readonly ThreadedTaskScheduler importScheduler; + protected ArchiveModelManager(Storage storage, IDatabaseContextFactory contextFactory, MutableDatabaseBackedStoreWithFileIncludes modelStore, IIpcHost importHost = null) { + importScheduler = new ThreadedTaskScheduler(16, $"{GetType().ReadableName()}.Import"); ContextFactory = contextFactory; ModelStore = modelStore; @@ -130,92 +136,84 @@ namespace osu.Game.Database /// This will post notifications tracking progress. /// /// One or more archive locations on disk. - public void Import(params string[] paths) + public async Task Import(params string[] paths) { var notification = new ProgressNotification { State = ProgressNotificationState.Active }; PostNotification?.Invoke(notification); - Import(notification, paths); + + await Import(notification, paths); } - protected void Import(ProgressNotification notification, params string[] paths) + protected async Task Import(ProgressNotification notification, params string[] paths) { notification.Progress = 0; notification.Text = "Import is initialising..."; var term = $"{typeof(TModel).Name.Replace("Info", "").ToLower()}"; - List imported = new List(); + var tasks = new List(); int current = 0; foreach (string path in paths) { - if (notification.State == ProgressNotificationState.Cancelled) - // user requested abort - return; - - try + tasks.Add(Import(path, notification.CancellationToken).ContinueWith(t => { - var text = "Importing "; - - if (path.Length > 1) - text += $"{++current} of {paths.Length} {term}s.."; - else - text += $"{term}.."; - - // only show the filename if it isn't a temporary one (as those look ugly). - if (!path.Contains(Path.GetTempPath())) - text += $"\n{Path.GetFileName(path)}"; - - notification.Text = text; - - imported.Add(Import(path)); - - notification.Progress = (float)current / paths.Length; - } - catch (Exception e) - { - e = e.InnerException ?? e; - Logger.Error(e, $@"Could not import ({Path.GetFileName(path)})"); - } - } - - if (imported.Count == 0) - { - notification.Text = "Import failed!"; - notification.State = ProgressNotificationState.Cancelled; - } - else - { - notification.CompletionText = imported.Count == 1 - ? $"Imported {imported.First()}!" - : $"Imported {current} {term}s!"; - - if (imported.Count > 0 && PresentImport != null) - { - notification.CompletionText += " Click to view."; - notification.CompletionClickAction = () => + lock (notification) { - PresentImport?.Invoke(imported); - return true; - }; - } + current++; - notification.State = ProgressNotificationState.Completed; + notification.Text = $"Imported {current} of {paths.Length} {term}s"; + notification.Progress = (float)current / paths.Length; + } + + if (t.Exception != null) + { + var e = t.Exception.InnerException ?? t.Exception; + Logger.Error(e, $@"Could not import ({Path.GetFileName(path)})"); + } + })); } + + await Task.WhenAll(tasks); + + // if (imported.Count == 0) + // { + // notification.Text = "Import failed!"; + // notification.State = ProgressNotificationState.Cancelled; + // } + // else + // { + // notification.CompletionText = imported.Count == 1 + // ? $"Imported {imported.First()}!" + // : $"Imported {current} {term}s!"; + // + // if (imported.Count > 0 && PresentImport != null) + // { + // notification.CompletionText += " Click to view."; + // notification.CompletionClickAction = () => + // { + // PresentImport?.Invoke(imported); + // return true; + // }; + // } + // + // notification.State = ProgressNotificationState.Completed; + // } } /// /// Import one from the filesystem and delete the file on success. /// /// The archive location on disk. + /// An optional cancellation token. /// The imported model, if successful. - public TModel Import(string path) + public async Task Import(string path, CancellationToken cancellationToken = default) { TModel import; using (ArchiveReader reader = getReaderFrom(path)) - import = Import(reader); + import = await Import(reader, cancellationToken); // We may or may not want to delete the file depending on where it is stored. // e.g. reconstructing/repairing database with items from default storage. @@ -243,7 +241,8 @@ namespace osu.Game.Database /// Import an item from an . /// /// The archive to be imported. - public TModel Import(ArchiveReader archive) + /// An optional cancellation token. + public async Task Import(ArchiveReader archive, CancellationToken cancellationToken = default) { try { @@ -253,7 +252,7 @@ namespace osu.Game.Database model.Hash = computeHash(archive); - return Import(model, archive); + return await Import(model, archive, cancellationToken); } catch (Exception e) { @@ -288,7 +287,8 @@ namespace osu.Game.Database /// /// The model to be imported. /// An optional archive to use for model population. - public TModel Import(TModel item, ArchiveReader archive = null) + /// An optional cancellation token. + public async Task Import(TModel item, ArchiveReader archive = null, CancellationToken cancellationToken = default) => await Task.Factory.StartNew(async () => { delayEvents(); @@ -296,17 +296,31 @@ namespace osu.Game.Database { Logger.Log($"Importing {item}...", LoggingTarget.Database); + if (archive != null) + item.Files = createFileInfos(archive, Files); + + var localItem = item; + + try + { + await Populate(item, archive, cancellationToken); + } + catch (TaskCanceledException) + { + return item = null; + } + finally + { + if (!Delete(localItem)) + Files.Dereference(localItem.Files.Select(f => f.FileInfo).ToArray()); + } + using (var write = ContextFactory.GetForWrite()) // used to share a context for full import. keep in mind this will block all writes. { try { if (!write.IsTransactionLeader) throw new InvalidOperationException($"Ensure there is no parent transaction so errors can correctly be handled by {this}"); - if (archive != null) - item.Files = createFileInfos(archive, Files); - - Populate(item, archive); - var existing = CheckForExisting(item); if (existing != null) @@ -332,6 +346,9 @@ namespace osu.Game.Database } catch (Exception e) { + if (!Delete(item)) + Files.Dereference(item.Files.Select(f => f.FileInfo).ToArray()); + write.Errors.Add(e); throw; } @@ -351,7 +368,7 @@ namespace osu.Game.Database } return item; - } + }, CancellationToken.None, TaskCreationOptions.None, importScheduler).Unwrap(); /// /// Perform an update of the specified item. @@ -516,24 +533,24 @@ namespace osu.Game.Database /// /// This is a temporary method and will likely be replaced by a full-fledged (and more correctly placed) migration process in the future. /// - public Task ImportFromStableAsync() + public async Task ImportFromStableAsync() { var stable = GetStableStorage?.Invoke(); if (stable == null) { Logger.Log("No osu!stable installation available!", LoggingTarget.Information, LogLevel.Error); - return Task.CompletedTask; + return; } if (!stable.ExistsDirectory(ImportFromStablePath)) { // This handles situations like when the user does not have a Skins folder Logger.Log($"No {ImportFromStablePath} folder available in osu!stable installation", LoggingTarget.Information, LogLevel.Error); - return Task.CompletedTask; + return; } - return Task.Factory.StartNew(() => Import(stable.GetDirectories(ImportFromStablePath).Select(f => stable.GetFullPath(f)).ToArray()), TaskCreationOptions.LongRunning); + await Task.Run(async () => await Import(stable.GetDirectories(ImportFromStablePath).Select(f => stable.GetFullPath(f)).ToArray())); } #endregion @@ -552,9 +569,8 @@ namespace osu.Game.Database /// /// The model to populate. /// The archive to use as a reference for population. May be null. - protected virtual void Populate(TModel model, [CanBeNull] ArchiveReader archive) - { - } + /// An optional cancellation token. + protected virtual async Task Populate(TModel model, [CanBeNull] ArchiveReader archive, CancellationToken cancellationToken = default) => await Task.CompletedTask; /// /// Perform any final actions before the import to database executes. diff --git a/osu.Game/Database/ICanAcceptFiles.cs b/osu.Game/Database/ICanAcceptFiles.cs index f55d0c389e..b9f882468d 100644 --- a/osu.Game/Database/ICanAcceptFiles.cs +++ b/osu.Game/Database/ICanAcceptFiles.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.Threading.Tasks; + namespace osu.Game.Database { /// @@ -12,7 +14,7 @@ namespace osu.Game.Database /// Import the specified paths. /// /// The files which should be imported. - void Import(params string[] paths); + Task Import(params string[] paths); /// /// An array of accepted file extensions (in the standard format of ".abc"). diff --git a/osu.Game/IPC/ArchiveImportIPCChannel.cs b/osu.Game/IPC/ArchiveImportIPCChannel.cs index fc747cd446..484db932f8 100644 --- a/osu.Game/IPC/ArchiveImportIPCChannel.cs +++ b/osu.Game/IPC/ArchiveImportIPCChannel.cs @@ -38,7 +38,7 @@ namespace osu.Game.IPC } if (importer.HandledExtensions.Contains(Path.GetExtension(path)?.ToLowerInvariant())) - importer.Import(path); + await importer.Import(path); } } diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index f9128687d6..d6b8caaf5b 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Bindables; @@ -268,13 +269,13 @@ namespace osu.Game private readonly List fileImporters = new List(); - public void Import(params string[] paths) + public async Task Import(params string[] paths) { var extension = Path.GetExtension(paths.First())?.ToLowerInvariant(); foreach (var importer in fileImporters) if (importer.HandledExtensions.Contains(extension)) - importer.Import(paths); + await importer.Import(paths); } public string[] HandledExtensions => fileImporters.SelectMany(i => i.HandledExtensions).ToArray(); diff --git a/osu.Game/Overlays/Notifications/ProgressNotification.cs b/osu.Game/Overlays/Notifications/ProgressNotification.cs index 857a0bda9e..c8e081d29f 100644 --- a/osu.Game/Overlays/Notifications/ProgressNotification.cs +++ b/osu.Game/Overlays/Notifications/ProgressNotification.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Threading; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -36,6 +37,10 @@ namespace osu.Game.Overlays.Notifications State = state; } + private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); + + public CancellationToken CancellationToken => cancellationTokenSource.Token; + public virtual ProgressNotificationState State { get => state; @@ -62,6 +67,8 @@ namespace osu.Game.Overlays.Notifications break; case ProgressNotificationState.Cancelled: + cancellationTokenSource.Cancel(); + Light.Colour = colourCancelled; Light.Pulsate = false; progressBar.Active = false; diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 98a2fe8f13..cf5d247482 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -66,7 +66,7 @@ namespace osu.Game.Screens.Menu if (setInfo == null) { // we need to import the default menu background beatmap - setInfo = beatmaps.Import(new ZipArchiveReader(game.Resources.GetStream(@"Tracks/circles.osz"), "circles.osz")); + setInfo = beatmaps.Import(new ZipArchiveReader(game.Resources.GetStream(@"Tracks/circles.osz"), "circles.osz")).Result; setInfo.Protected = true; beatmaps.Update(setInfo); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index d8389fa6d9..949f9e5ff2 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -279,7 +279,7 @@ namespace osu.Game.Screens.Play var score = CreateScore(); if (DrawableRuleset.ReplayScore == null) - scoreManager.Import(score); + scoreManager.Import(score).Wait(); this.Push(CreateResults(score)); diff --git a/osu.Game/Skinning/SkinManager.cs b/osu.Game/Skinning/SkinManager.cs index 3a4d44f608..73cc47ea47 100644 --- a/osu.Game/Skinning/SkinManager.cs +++ b/osu.Game/Skinning/SkinManager.cs @@ -5,6 +5,8 @@ using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; +using System.Threading; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -71,9 +73,9 @@ namespace osu.Game.Skinning protected override SkinInfo CreateModel(ArchiveReader archive) => new SkinInfo { Name = archive.Name }; - protected override void Populate(SkinInfo model, ArchiveReader archive) + protected override async Task Populate(SkinInfo model, ArchiveReader archive, CancellationToken cancellationToken = default) { - base.Populate(model, archive); + await base.Populate(model, archive, cancellationToken); Skin reference = getSkin(model); From 600503ec8ebdb6233beab64b0faa53f02b91af4e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 12:46:21 +0900 Subject: [PATCH 320/375] Use Task.Run/Wait to avoid warnings --- osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs | 4 ++-- osu.Game/Screens/Select/SongSelect.cs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index ebee358730..c2e8078bd6 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -210,7 +210,7 @@ namespace osu.Game.Tests.Visual.SongSelect AddAssert("start not requested", () => !startRequested); } - private void importForRuleset(int id) => AddStep($"import test map for ruleset {id}", () => manager.Import(createTestBeatmapSet(getImportId(), rulesets.AvailableRulesets.Where(r => r.ID == id).ToArray()))); + private void importForRuleset(int id) => AddStep($"import test map for ruleset {id}", () => manager.Import(createTestBeatmapSet(getImportId(), rulesets.AvailableRulesets.Where(r => r.ID == id).ToArray())).Wait()); private static int importId; private int getImportId() => ++importId; @@ -232,7 +232,7 @@ namespace osu.Game.Tests.Visual.SongSelect var usableRulesets = rulesets.AvailableRulesets.Where(r => r.ID != 2).ToArray(); for (int i = 0; i < 100; i += 10) - manager.Import(createTestBeatmapSet(i, usableRulesets)); + manager.Import(createTestBeatmapSet(i, usableRulesets)).Wait(); }); } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 6d5be607f4..196d655851 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -32,6 +32,7 @@ using osuTK.Input; using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using osu.Framework.Graphics.Sprites; namespace osu.Game.Screens.Select @@ -256,8 +257,8 @@ namespace osu.Game.Screens.Select if (!beatmaps.GetAllUsableBeatmapSets().Any() && beatmaps.StableInstallationAvailable) dialogOverlay.Push(new ImportFromStablePopup(() => { - beatmaps.ImportFromStableAsync(); - skins.ImportFromStableAsync(); + Task.Run(beatmaps.ImportFromStableAsync); + Task.Run(skins.ImportFromStableAsync); })); }); } From b4d2d0bd0b245cba425d9e5d981e3831d9269931 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 13:19:58 +0900 Subject: [PATCH 321/375] Simplify and combine concurrency of ArchiveModelManager --- osu.Game/Beatmaps/BeatmapManager.cs | 77 ++----------------- osu.Game/Database/ArchiveModelManager.cs | 96 ++++++++++++------------ 2 files changed, 57 insertions(+), 116 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index f5ef52a93b..9e7b6d7971 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; @@ -111,7 +110,7 @@ namespace osu.Game.Beatmaps validateOnlineIds(beatmapSet); - await Task.WhenAll(beatmapSet.Beatmaps.Select(b => updateQueue.Enqueue(new UpdateItem(b, cancellationToken)).Task).ToArray()); + await Task.WhenAll(beatmapSet.Beatmaps.Select(b => updateQueue.Perform(b, cancellationToken)).ToArray()); } protected override void PreImport(BeatmapSetInfo beatmapSet) @@ -424,81 +423,24 @@ namespace osu.Game.Beatmaps private class BeatmapUpdateQueue { private readonly IAPIProvider api; - private readonly Queue queue = new Queue(); - private int activeThreads; + private readonly ThreadedTaskScheduler updateScheduler = new ThreadedTaskScheduler(4); public BeatmapUpdateQueue(IAPIProvider api) { this.api = api; } - public UpdateItem Enqueue(UpdateItem item) + public Task Perform(BeatmapInfo beatmap, CancellationToken cancellationToken) + => Task.Factory.StartNew(() => perform(beatmap, cancellationToken), cancellationToken, TaskCreationOptions.HideScheduler, updateScheduler); + + private void perform(BeatmapInfo beatmap, CancellationToken cancellation) { - lock (queue) - { - queue.Enqueue(item); - - if (activeThreads >= 16) - return item; - - new Thread(runWork) { IsBackground = true }.Start(); - activeThreads++; - } - - return item; - } - - private void runWork() - { - while (true) - { - UpdateItem toProcess; - - lock (queue) - { - if (queue.Count == 0) - break; - - toProcess = queue.Dequeue(); - } - - toProcess.PerformUpdate(api); - } - - lock (queue) - activeThreads--; - } - } - - private class UpdateItem - { - public Task Task => tcs.Task; - - private readonly BeatmapInfo beatmap; - private readonly CancellationToken cancellationToken; - - private readonly TaskCompletionSource tcs = new TaskCompletionSource(); - - public UpdateItem(BeatmapInfo beatmap, CancellationToken cancellationToken) - { - this.beatmap = beatmap; - this.cancellationToken = cancellationToken; - } - - public void PerformUpdate(IAPIProvider api) - { - if (cancellationToken.IsCancellationRequested) - { - tcs.SetCanceled(); + if (cancellation.IsCancellationRequested) return; - } if (api?.State != APIState.Online) - { - tcs.SetResult(false); return; - } Logger.Log("Attempting online lookup for the missing values...", LoggingTarget.Database); @@ -512,17 +454,14 @@ namespace osu.Game.Beatmaps beatmap.BeatmapSet.Status = res.BeatmapSet.Status; beatmap.BeatmapSet.OnlineBeatmapSetID = res.OnlineBeatmapSetID; beatmap.OnlineBeatmapID = res.OnlineBeatmapID; - - tcs.SetResult(true); }; req.Failure += e => { Logger.Log($"Failed ({e})", LoggingTarget.Database); - - tcs.SetResult(false); }; + // intentionally blocking to limit web request concurrency req.Perform(api); } } diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index afc614772e..e30e1cd3ee 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; @@ -11,7 +11,6 @@ using JetBrains.Annotations; using Microsoft.EntityFrameworkCore; using osu.Framework; using osu.Framework.Extensions; -using osu.Framework.Extensions.TypeExtensions; using osu.Framework.IO.File; using osu.Framework.Logging; using osu.Framework.Platform; @@ -32,7 +31,7 @@ namespace osu.Game.Database /// /// The model type. /// The associated file join type. - public abstract class ArchiveModelManager : ICanAcceptFiles + public abstract class ArchiveModelManager : ArchiveModelManager, ICanAcceptFiles where TModel : class, IHasFiles, IHasPrimaryKey, ISoftDelete where TFileModel : INamedFileInfo, new() { @@ -112,11 +111,8 @@ namespace osu.Game.Database a.Invoke(); } - private readonly ThreadedTaskScheduler importScheduler; - protected ArchiveModelManager(Storage storage, IDatabaseContextFactory contextFactory, MutableDatabaseBackedStoreWithFileIncludes modelStore, IIpcHost importHost = null) { - importScheduler = new ThreadedTaskScheduler(16, $"{GetType().ReadableName()}.Import"); ContextFactory = contextFactory; ModelStore = modelStore; @@ -152,55 +148,55 @@ namespace osu.Game.Database var term = $"{typeof(TModel).Name.Replace("Info", "").ToLower()}"; - var tasks = new List(); - int current = 0; - foreach (string path in paths) + var imported = new List(); + + await Task.WhenAll(paths.Select(path => Import(path, notification.CancellationToken).ContinueWith(t => { - tasks.Add(Import(path, notification.CancellationToken).ContinueWith(t => + lock (notification) { - lock (notification) - { - current++; + current++; - notification.Text = $"Imported {current} of {paths.Length} {term}s"; - notification.Progress = (float)current / paths.Length; - } + notification.Text = $"Imported {current} of {paths.Length} {term}s"; + notification.Progress = (float)current / paths.Length; + } - if (t.Exception != null) - { - var e = t.Exception.InnerException ?? t.Exception; - Logger.Error(e, $@"Could not import ({Path.GetFileName(path)})"); - } - })); + if (t.Exception == null) + { + lock (imported) + imported.Add(t.Result); + } + else + { + var e = t.Exception.InnerException ?? t.Exception; + Logger.Error(e, $@"Could not import ({Path.GetFileName(path)})"); + } + }))); + + if (imported.Count == 0) + { + notification.Text = "Import failed!"; + notification.State = ProgressNotificationState.Cancelled; } + else + { + notification.CompletionText = imported.Count == 1 + ? $"Imported {imported.First()}!" + : $"Imported {current} {term}s!"; - await Task.WhenAll(tasks); + if (imported.Count > 0 && PresentImport != null) + { + notification.CompletionText += " Click to view."; + notification.CompletionClickAction = () => + { + PresentImport?.Invoke(imported); + return true; + }; + } - // if (imported.Count == 0) - // { - // notification.Text = "Import failed!"; - // notification.State = ProgressNotificationState.Cancelled; - // } - // else - // { - // notification.CompletionText = imported.Count == 1 - // ? $"Imported {imported.First()}!" - // : $"Imported {current} {term}s!"; - // - // if (imported.Count > 0 && PresentImport != null) - // { - // notification.CompletionText += " Click to view."; - // notification.CompletionClickAction = () => - // { - // PresentImport?.Invoke(imported); - // return true; - // }; - // } - // - // notification.State = ProgressNotificationState.Completed; - // } + notification.State = ProgressNotificationState.Completed; + } } /// @@ -368,7 +364,7 @@ namespace osu.Game.Database } return item; - }, CancellationToken.None, TaskCreationOptions.None, importScheduler).Unwrap(); + }, CancellationToken.None, TaskCreationOptions.HideScheduler, IMPORT_SCHEDULER).Unwrap(); /// /// Perform an update of the specified item. @@ -615,4 +611,10 @@ namespace osu.Game.Database throw new InvalidFormatException($"{path} is not a valid archive"); } } + + public abstract class ArchiveModelManager + { + // allow sharing static across all generic types + protected static readonly ThreadedTaskScheduler IMPORT_SCHEDULER = new ThreadedTaskScheduler(1); + } } From 2d1a54e63489b36cfb4fa5261abd0ed95c092051 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 13:37:20 +0900 Subject: [PATCH 322/375] Properly implement cancellation --- osu.Game/Database/ArchiveModelManager.cs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index e30e1cd3ee..1d576ff82f 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -154,6 +154,9 @@ namespace osu.Game.Database await Task.WhenAll(paths.Select(path => Import(path, notification.CancellationToken).ContinueWith(t => { + if (notification.CancellationToken.IsCancellationRequested) + return; + lock (notification) { current++; @@ -172,7 +175,7 @@ namespace osu.Game.Database var e = t.Exception.InnerException ?? t.Exception; Logger.Error(e, $@"Could not import ({Path.GetFileName(path)})"); } - }))); + }, TaskContinuationOptions.NotOnCanceled))); if (imported.Count == 0) { @@ -207,6 +210,8 @@ namespace osu.Game.Database /// The imported model, if successful. public async Task Import(string path, CancellationToken cancellationToken = default) { + cancellationToken.ThrowIfCancellationRequested(); + TModel import; using (ArchiveReader reader = getReaderFrom(path)) import = await Import(reader, cancellationToken); @@ -240,6 +245,8 @@ namespace osu.Game.Database /// An optional cancellation token. public async Task Import(ArchiveReader archive, CancellationToken cancellationToken = default) { + cancellationToken.ThrowIfCancellationRequested(); + try { var model = CreateModel(archive); @@ -250,6 +257,10 @@ namespace osu.Game.Database return await Import(model, archive, cancellationToken); } + catch (TaskCanceledException) + { + throw; + } catch (Exception e) { Logger.Error(e, $"Model creation of {archive.Name} failed.", LoggingTarget.Database); @@ -286,6 +297,8 @@ namespace osu.Game.Database /// An optional cancellation token. public async Task Import(TModel item, ArchiveReader archive = null, CancellationToken cancellationToken = default) => await Task.Factory.StartNew(async () => { + cancellationToken.ThrowIfCancellationRequested(); + delayEvents(); try @@ -301,10 +314,6 @@ namespace osu.Game.Database { await Populate(item, archive, cancellationToken); } - catch (TaskCanceledException) - { - return item = null; - } finally { if (!Delete(localItem)) @@ -364,7 +373,7 @@ namespace osu.Game.Database } return item; - }, CancellationToken.None, TaskCreationOptions.HideScheduler, IMPORT_SCHEDULER).Unwrap(); + }, cancellationToken, TaskCreationOptions.HideScheduler, IMPORT_SCHEDULER).Unwrap(); /// /// Perform an update of the specified item. From e12b03e275c40de2b3629b92da24da45545be619 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 13:46:31 +0900 Subject: [PATCH 323/375] Remove unnecessary reference --- osu.Game.Tests/osu.Game.Tests.csproj | 5 ----- 1 file changed, 5 deletions(-) diff --git a/osu.Game.Tests/osu.Game.Tests.csproj b/osu.Game.Tests/osu.Game.Tests.csproj index 403ae16885..11d70ee7be 100644 --- a/osu.Game.Tests/osu.Game.Tests.csproj +++ b/osu.Game.Tests/osu.Game.Tests.csproj @@ -18,9 +18,4 @@ - - - ..\..\..\..\..\usr\local\share\dotnet\sdk\NuGetFallbackFolder\microsoft.win32.registry\4.5.0\ref\netstandard2.0\Microsoft.Win32.Registry.dll - - \ No newline at end of file From b79fdfc12f2d65da2f0fd80b68fa58aa2aa11882 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 13:48:58 +0900 Subject: [PATCH 324/375] Fix one more instance of improperly handled cancellation --- osu.Game/Beatmaps/BeatmapManager.cs | 3 +-- osu.Game/Database/ArchiveModelManager.cs | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 9e7b6d7971..cfc6a0be28 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -436,8 +436,7 @@ namespace osu.Game.Beatmaps private void perform(BeatmapInfo beatmap, CancellationToken cancellation) { - if (cancellation.IsCancellationRequested) - return; + cancellation.ThrowIfCancellationRequested(); if (api?.State != APIState.Online) return; diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 1d576ff82f..df96d9984a 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -361,6 +361,10 @@ namespace osu.Game.Database Logger.Log($"Import of {item} successfully completed!", LoggingTarget.Database); } + catch (TaskCanceledException) + { + throw; + } catch (Exception e) { Logger.Error(e, $"Import of {item} failed and has been rolled back.", LoggingTarget.Database); From e4bad93b6668868079dad7227b868b43736e6336 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 13:52:09 +0900 Subject: [PATCH 325/375] Use variable for web request concurrency for clarity --- osu.Game/Beatmaps/BeatmapManager.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index cfc6a0be28..435edcf722 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -424,7 +424,9 @@ namespace osu.Game.Beatmaps { private readonly IAPIProvider api; - private readonly ThreadedTaskScheduler updateScheduler = new ThreadedTaskScheduler(4); + private const int update_queue_request_concurrency = 4; + + private readonly ThreadedTaskScheduler updateScheduler = new ThreadedTaskScheduler(update_queue_request_concurrency); public BeatmapUpdateQueue(IAPIProvider api) { @@ -455,10 +457,7 @@ namespace osu.Game.Beatmaps beatmap.OnlineBeatmapID = res.OnlineBeatmapID; }; - req.Failure += e => - { - Logger.Log($"Failed ({e})", LoggingTarget.Database); - }; + req.Failure += e => { Logger.Log($"Failed ({e})", LoggingTarget.Database); }; // intentionally blocking to limit web request concurrency req.Perform(api); From e19f4935c3cbdd6d037d093d6b41e2f7cb1bf719 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 14:13:36 +0900 Subject: [PATCH 326/375] Fix incorrect undo logic on exception --- osu.Game/Database/ArchiveModelManager.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index df96d9984a..83c51e2abf 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -305,8 +305,7 @@ namespace osu.Game.Database { Logger.Log($"Importing {item}...", LoggingTarget.Database); - if (archive != null) - item.Files = createFileInfos(archive, Files); + item.Files = archive != null ? createFileInfos(archive, Files) : new List(); var localItem = item; @@ -314,7 +313,7 @@ namespace osu.Game.Database { await Populate(item, archive, cancellationToken); } - finally + catch (Exception) { if (!Delete(localItem)) Files.Dereference(localItem.Files.Select(f => f.FileInfo).ToArray()); From f31b19e0d7b2837bfaa1c26fa381d6ab1df43e41 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 16:02:49 +0900 Subject: [PATCH 327/375] Don't unwrap exception manually --- osu.Game/Database/ArchiveModelManager.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 83c51e2abf..4c4878edee 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -172,8 +172,7 @@ namespace osu.Game.Database } else { - var e = t.Exception.InnerException ?? t.Exception; - Logger.Error(e, $@"Could not import ({Path.GetFileName(path)})"); + Logger.Error(t.Exception, $@"Could not import ({Path.GetFileName(path)})"); } }, TaskContinuationOptions.NotOnCanceled))); From 9bdc8b47bb1e1c8ab8e57b48d0d8604d94ae5d3e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 16:13:51 +0900 Subject: [PATCH 328/375] Remove unnecessary async-await pair --- osu.Game/Database/ArchiveModelManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 4c4878edee..fb7f0ffe5d 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -577,7 +577,7 @@ namespace osu.Game.Database /// The model to populate. /// The archive to use as a reference for population. May be null. /// An optional cancellation token. - protected virtual async Task Populate(TModel model, [CanBeNull] ArchiveReader archive, CancellationToken cancellationToken = default) => await Task.CompletedTask; + protected virtual Task Populate(TModel model, [CanBeNull] ArchiveReader archive, CancellationToken cancellationToken = default) => Task.CompletedTask; /// /// Perform any final actions before the import to database executes. From fae32b390171738feed00336df54db7046c9ecd8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 16:14:11 +0900 Subject: [PATCH 329/375] Return shorter class name in error messages --- osu.Game/Database/ArchiveModelManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index fb7f0ffe5d..e2a07a860f 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -331,7 +331,7 @@ namespace osu.Game.Database if (CanUndelete(existing, item)) { Undelete(existing); - Logger.Log($"Found existing {typeof(TModel)} for {item} (ID {existing.ID}). Skipping import.", LoggingTarget.Database); + Logger.Log($"Found existing {nameof(TModel)} for {item} (ID {existing.ID}). Skipping import.", LoggingTarget.Database); handleEvent(() => ItemAdded?.Invoke(existing, true)); return existing; } From 02b376d962d364f7b2525e8478dd4c4e3dd7cf04 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 16:14:42 +0900 Subject: [PATCH 330/375] Fix rollback logic not necessrily cleaning up file store --- osu.Game/Database/ArchiveModelManager.cs | 63 +++++++++++------------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index e2a07a860f..45460dd11c 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -154,25 +154,22 @@ namespace osu.Game.Database await Task.WhenAll(paths.Select(path => Import(path, notification.CancellationToken).ContinueWith(t => { - if (notification.CancellationToken.IsCancellationRequested) - return; + notification.CancellationToken.ThrowIfCancellationRequested(); - lock (notification) + lock (imported) { - current++; + Interlocked.Increment(ref current); - notification.Text = $"Imported {current} of {paths.Length} {term}s"; - notification.Progress = (float)current / paths.Length; - } - - if (t.Exception == null) - { - lock (imported) + if (t.Exception == null) + { imported.Add(t.Result); - } - else - { - Logger.Error(t.Exception, $@"Could not import ({Path.GetFileName(path)})"); + notification.Text = $"Imported {current} of {paths.Length} {term}s"; + notification.Progress = (float)current / paths.Length; + } + else + { + Logger.Error(t.Exception, $@"Could not import ({Path.GetFileName(path)})"); + } } }, TaskContinuationOptions.NotOnCanceled))); @@ -300,23 +297,23 @@ namespace osu.Game.Database delayEvents(); + void rollback() + { + if (!Delete(item)) + { + // We may have not yet added the model to the underlying table, but should still clean up files. + Logger.Log($"Dereferencing files for incomplete import of {item}.", LoggingTarget.Database); + Files.Dereference(item.Files.Select(f => f.FileInfo).ToArray()); + } + } + try { Logger.Log($"Importing {item}...", LoggingTarget.Database); item.Files = archive != null ? createFileInfos(archive, Files) : new List(); - var localItem = item; - - try - { - await Populate(item, archive, cancellationToken); - } - catch (Exception) - { - if (!Delete(localItem)) - Files.Dereference(localItem.Files.Select(f => f.FileInfo).ToArray()); - } + await Populate(item, archive, cancellationToken); using (var write = ContextFactory.GetForWrite()) // used to share a context for full import. keep in mind this will block all writes. { @@ -333,6 +330,8 @@ namespace osu.Game.Database Undelete(existing); Logger.Log($"Found existing {nameof(TModel)} for {item} (ID {existing.ID}). Skipping import.", LoggingTarget.Database); handleEvent(() => ItemAdded?.Invoke(existing, true)); + + rollback(); return existing; } else @@ -349,9 +348,6 @@ namespace osu.Game.Database } catch (Exception e) { - if (!Delete(item)) - Files.Dereference(item.Files.Select(f => f.FileInfo).ToArray()); - write.Errors.Add(e); throw; } @@ -359,13 +355,12 @@ namespace osu.Game.Database Logger.Log($"Import of {item} successfully completed!", LoggingTarget.Database); } - catch (TaskCanceledException) - { - throw; - } catch (Exception e) { - Logger.Error(e, $"Import of {item} failed and has been rolled back.", LoggingTarget.Database); + if (!(e is TaskCanceledException)) + Logger.Error(e, $"Import of {item} failed and has been rolled back.", LoggingTarget.Database); + + rollback(); item = null; } finally From 5b75060b94999e3a50a665a4e40cee3994162fa2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 16:45:45 +0900 Subject: [PATCH 331/375] Add test for rollback logic correctly dereferencing files --- osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs | 13 +++++++++++++ osu.Game/IO/FileStore.cs | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index 4c9260f640..3f4f40781c 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -12,6 +12,7 @@ using osu.Framework.Platform; using osu.Game.IPC; using osu.Framework.Allocation; using osu.Game.Beatmaps; +using osu.Game.IO; using osu.Game.Tests.Resources; using SharpCompress.Archives.Zip; @@ -97,6 +98,7 @@ namespace osu.Game.Tests.Beatmaps.IO { var osu = loadOsu(host); var manager = osu.Dependencies.Get(); + var files = osu.Dependencies.Get(); int fireCount = 0; @@ -113,6 +115,12 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.AreEqual(0, fireCount -= 2); + Assert.AreEqual(1, manager.GetAllUsableBeatmapSets().Count); + Assert.AreEqual(1, manager.QueryBeatmapSets(_ => true).ToList().Count); + Assert.AreEqual(12, manager.QueryBeatmaps(_ => true).ToList().Count); + + Assert.AreEqual(18, files.QueryFiles(_ => true).Count()); + var breakTemp = TestResources.GetTestBeatmapForImport(); MemoryStream brokenOsu = new MemoryStream(new byte[] { 1, 3, 3, 7 }); @@ -131,6 +139,8 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.AreEqual(1, manager.QueryBeatmapSets(_ => true).ToList().Count); Assert.AreEqual(12, manager.QueryBeatmaps(_ => true).ToList().Count); + Assert.AreEqual(18, files.QueryFiles(_ => true).Count()); + // this will trigger purging of the existing beatmap (online set id match) but should rollback due to broken osu. await manager.Import(breakTemp); @@ -140,6 +150,9 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.AreEqual(1, manager.GetAllUsableBeatmapSets().Count); Assert.AreEqual(1, manager.QueryBeatmapSets(_ => true).ToList().Count); Assert.AreEqual(12, manager.QueryBeatmaps(_ => true).ToList().Count); + + Assert.AreEqual(18, files.QueryFiles(_ => true).Count()); + Assert.AreEqual(18, files.QueryFiles(f => f.ReferenceCount == 1).Count()); } finally { diff --git a/osu.Game/IO/FileStore.cs b/osu.Game/IO/FileStore.cs index 458f8964f9..370d6786f5 100644 --- a/osu.Game/IO/FileStore.cs +++ b/osu.Game/IO/FileStore.cs @@ -2,8 +2,11 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; using System.IO; using System.Linq; +using System.Linq.Expressions; +using Microsoft.EntityFrameworkCore; using osu.Framework.Extensions; using osu.Framework.IO.Stores; using osu.Framework.Logging; @@ -27,6 +30,13 @@ namespace osu.Game.IO Store = new StorageBackedResourceStore(Storage); } + /// + /// Perform a lookup query on available s. + /// + /// The query. + /// Results from the provided query. + public IEnumerable QueryFiles(Expression> query) => ContextFactory.Get().Set().AsNoTracking().Where(f => f.ReferenceCount > 0).Where(query); + public FileInfo Add(Stream data, bool reference = true) { using (var usage = ContextFactory.GetForWrite()) From 559413f766fef4fef2f8c16e59e61a39f100d785 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 17:12:25 +0900 Subject: [PATCH 332/375] Avoid using ContinueWith in already async context --- osu.Game/Database/ArchiveModelManager.cs | 29 ++++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 45460dd11c..d09aa37d7e 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -152,26 +152,35 @@ namespace osu.Game.Database var imported = new List(); - await Task.WhenAll(paths.Select(path => Import(path, notification.CancellationToken).ContinueWith(t => + await Task.WhenAll(paths.Select(async path => { notification.CancellationToken.ThrowIfCancellationRequested(); - lock (imported) + try { - Interlocked.Increment(ref current); + var model = await Import(path, notification.CancellationToken); - if (t.Exception == null) + lock (imported) { - imported.Add(t.Result); + imported.Add(model); + notification.Text = $"Imported {current} of {paths.Length} {term}s"; notification.Progress = (float)current / paths.Length; } - else - { - Logger.Error(t.Exception, $@"Could not import ({Path.GetFileName(path)})"); - } } - }, TaskContinuationOptions.NotOnCanceled))); + catch (TaskCanceledException) + { + throw; + } + catch (Exception e) + { + Logger.Error(e, $@"Could not import ({Path.GetFileName(path)})"); + } + finally + { + Interlocked.Increment(ref current); + } + })); if (imported.Count == 0) { From c8bd92659bab551a36e0c40dc1b604deca0e4fdb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 17:12:37 +0900 Subject: [PATCH 333/375] Clean up exception and null handling in Import process --- osu.Game/Database/ArchiveModelManager.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index d09aa37d7e..fa8301bb2e 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -252,15 +252,15 @@ namespace osu.Game.Database { cancellationToken.ThrowIfCancellationRequested(); + TModel model; + try { - var model = CreateModel(archive); + model = CreateModel(archive); if (model == null) return null; model.Hash = computeHash(archive); - - return await Import(model, archive, cancellationToken); } catch (TaskCanceledException) { @@ -271,6 +271,8 @@ namespace osu.Game.Database Logger.Error(e, $"Model creation of {archive.Name} failed.", LoggingTarget.Database); return null; } + + return await Import(model, archive, cancellationToken); } /// @@ -340,7 +342,9 @@ namespace osu.Game.Database Logger.Log($"Found existing {nameof(TModel)} for {item} (ID {existing.ID}). Skipping import.", LoggingTarget.Database); handleEvent(() => ItemAdded?.Invoke(existing, true)); + // existing item will be used; rollback new import and exit early. rollback(); + flushEvents(true); return existing; } else @@ -370,14 +374,11 @@ namespace osu.Game.Database Logger.Error(e, $"Import of {item} failed and has been rolled back.", LoggingTarget.Database); rollback(); - item = null; - } - finally - { - // we only want to flush events after we've confirmed the write context didn't have any errors. - flushEvents(item != null); + flushEvents(false); + throw; } + flushEvents(true); return item; }, cancellationToken, TaskCreationOptions.HideScheduler, IMPORT_SCHEDULER).Unwrap(); From dcdb806120c6b581af4be341b60bd84cba5ea9c3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 17:26:56 +0900 Subject: [PATCH 334/375] Catch newly thrown exception in test --- osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index 3f4f40781c..7f08674a95 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -135,14 +135,14 @@ namespace osu.Game.Tests.Beatmaps.IO zip.SaveTo(outStream, SharpCompress.Common.CompressionType.Deflate); } - Assert.AreEqual(1, manager.GetAllUsableBeatmapSets().Count); - Assert.AreEqual(1, manager.QueryBeatmapSets(_ => true).ToList().Count); - Assert.AreEqual(12, manager.QueryBeatmaps(_ => true).ToList().Count); - - Assert.AreEqual(18, files.QueryFiles(_ => true).Count()); - // this will trigger purging of the existing beatmap (online set id match) but should rollback due to broken osu. - await manager.Import(breakTemp); + try + { + await manager.Import(breakTemp); + } + catch + { + } // no events should be fired in the case of a rollback. Assert.AreEqual(0, fireCount); From 28b2a516e34354eb0f2d958c2f55da91dd8d4f78 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 18:13:33 +0900 Subject: [PATCH 335/375] Ensure exception is only thrown once on rollback --- .../Beatmaps/IO/ImportBeatmapTest.cs | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index 7f08674a95..f3680e3c1e 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -11,6 +11,7 @@ using NUnit.Framework; using osu.Framework.Platform; using osu.Game.IPC; using osu.Framework.Allocation; +using osu.Framework.Logging; using osu.Game.Beatmaps; using osu.Game.IO; using osu.Game.Tests.Resources; @@ -96,24 +97,31 @@ namespace osu.Game.Tests.Beatmaps.IO { try { + int itemAddRemoveFireCount = 0; + int loggedExceptionCount = 0; + + Logger.NewEntry += l => + { + if (l.Target == LoggingTarget.Database && l.Exception != null) + Interlocked.Increment(ref loggedExceptionCount); + }; + var osu = loadOsu(host); var manager = osu.Dependencies.Get(); var files = osu.Dependencies.Get(); - int fireCount = 0; - // ReSharper disable once AccessToModifiedClosure - manager.ItemAdded += (_, __) => fireCount++; - manager.ItemRemoved += _ => fireCount++; + manager.ItemAdded += (_, __) => Interlocked.Increment(ref itemAddRemoveFireCount); + manager.ItemRemoved += _ => Interlocked.Increment(ref itemAddRemoveFireCount); var imported = await LoadOszIntoOsu(osu); - Assert.AreEqual(0, fireCount -= 1); + Assert.AreEqual(0, itemAddRemoveFireCount -= 1); imported.Hash += "-changed"; manager.Update(imported); - Assert.AreEqual(0, fireCount -= 2); + Assert.AreEqual(0, itemAddRemoveFireCount -= 2); Assert.AreEqual(1, manager.GetAllUsableBeatmapSets().Count); Assert.AreEqual(1, manager.QueryBeatmapSets(_ => true).ToList().Count); @@ -145,7 +153,7 @@ namespace osu.Game.Tests.Beatmaps.IO } // no events should be fired in the case of a rollback. - Assert.AreEqual(0, fireCount); + Assert.AreEqual(0, itemAddRemoveFireCount); Assert.AreEqual(1, manager.GetAllUsableBeatmapSets().Count); Assert.AreEqual(1, manager.QueryBeatmapSets(_ => true).ToList().Count); @@ -153,6 +161,8 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.AreEqual(18, files.QueryFiles(_ => true).Count()); Assert.AreEqual(18, files.QueryFiles(f => f.ReferenceCount == 1).Count()); + + Assert.AreEqual(1, loggedExceptionCount); } finally { From 1aa865c3fb154d0ce88321f38cbef309c7799c22 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 10 Jun 2019 18:34:24 +0900 Subject: [PATCH 336/375] split out method for reuse --- .../Visual/SongSelect/TestScenePlaySongSelect.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index 8636890081..d6b5e0175f 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -138,7 +138,7 @@ namespace osu.Game.Tests.Visual.SongSelect { createSongSelect(); changeRuleset(2); - importForRuleset(0); + addRulesetImportStep(0); AddUntilStep("no selection", () => songSelect.Carousel.SelectedBeatmap == null); } @@ -147,8 +147,8 @@ namespace osu.Game.Tests.Visual.SongSelect { createSongSelect(); changeRuleset(2); - importForRuleset(2); - importForRuleset(1); + addRulesetImportStep(2); + addRulesetImportStep(1); AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap.RulesetID == 2); changeRuleset(1); @@ -223,7 +223,7 @@ namespace osu.Game.Tests.Visual.SongSelect }); AddRepeatStep($"Create beatmaps {test_count} times", () => { - manager.Import(createTestBeatmapSet(getImportId(), rulesets.AvailableRulesets.Where(r => r.ID == 0).ToArray())); + importForRuleset(0); Scheduler.AddDelayed(() => { @@ -240,15 +240,16 @@ namespace osu.Game.Tests.Visual.SongSelect { int? previousID = null; createSongSelect(); - importForRuleset(0); + addRulesetImportStep(0); AddStep("Move to last difficulty", () => songSelect.Carousel.SelectBeatmap(songSelect.Carousel.BeatmapSets.First().Beatmaps.Last())); AddStep("Store current ID", () => previousID = songSelect.Carousel.SelectedBeatmap.ID); AddStep("Hide first beatmap", () => manager.Hide(songSelect.Carousel.SelectedBeatmapSet.Beatmaps.First())); AddAssert("Selected beatmap has not changed", () => songSelect.Carousel.SelectedBeatmap.ID == previousID); } - private void importForRuleset(int id) => AddStep($"import test map for ruleset {id}", - () => manager.Import(createTestBeatmapSet(getImportId(), rulesets.AvailableRulesets.Where(r => r.ID == id).ToArray()))); + private void addRulesetImportStep(int id) => AddStep($"import test map for ruleset {id}", () => importForRuleset(id)); + + private void importForRuleset(int id) => manager.Import(createTestBeatmapSet(getImportId(), rulesets.AvailableRulesets.Where(r => r.ID == id).ToArray())); private static int importId; private int getImportId() => ++importId; From 12aa264657061f456405a65c0eaaf781f3461304 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 18:35:23 +0900 Subject: [PATCH 337/375] Consolidate tests and check for file reference counts --- .../Beatmaps/IO/ImportBeatmapTest.cs | 51 ++++++++++++------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index f3680e3c1e..5fc05a4b2f 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -77,10 +77,8 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.IsTrue(imported.ID == importedSecondTime.ID); Assert.IsTrue(imported.Beatmaps.First().ID == importedSecondTime.Beatmaps.First().ID); - var manager = osu.Dependencies.Get(); - - Assert.AreEqual(1, manager.GetAllUsableBeatmapSets().Count); - Assert.AreEqual(1, manager.QueryBeatmapSets(_ => true).ToList().Count); + checkBeatmapSetCount(osu, 1); + checkSingleReferencedFileCount(osu, 18); } finally { @@ -108,7 +106,6 @@ namespace osu.Game.Tests.Beatmaps.IO var osu = loadOsu(host); var manager = osu.Dependencies.Get(); - var files = osu.Dependencies.Get(); // ReSharper disable once AccessToModifiedClosure manager.ItemAdded += (_, __) => Interlocked.Increment(ref itemAddRemoveFireCount); @@ -123,11 +120,9 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.AreEqual(0, itemAddRemoveFireCount -= 2); - Assert.AreEqual(1, manager.GetAllUsableBeatmapSets().Count); - Assert.AreEqual(1, manager.QueryBeatmapSets(_ => true).ToList().Count); - Assert.AreEqual(12, manager.QueryBeatmaps(_ => true).ToList().Count); - - Assert.AreEqual(18, files.QueryFiles(_ => true).Count()); + checkBeatmapSetCount(osu, 1); + checkBeatmapCount(osu, 12); + checkSingleReferencedFileCount(osu, 18); var breakTemp = TestResources.GetTestBeatmapForImport(); @@ -155,12 +150,10 @@ namespace osu.Game.Tests.Beatmaps.IO // no events should be fired in the case of a rollback. Assert.AreEqual(0, itemAddRemoveFireCount); - Assert.AreEqual(1, manager.GetAllUsableBeatmapSets().Count); - Assert.AreEqual(1, manager.QueryBeatmapSets(_ => true).ToList().Count); - Assert.AreEqual(12, manager.QueryBeatmaps(_ => true).ToList().Count); + checkBeatmapSetCount(osu, 1); + checkBeatmapCount(osu, 12); - Assert.AreEqual(18, files.QueryFiles(_ => true).Count()); - Assert.AreEqual(18, files.QueryFiles(f => f.ReferenceCount == 1).Count()); + checkSingleReferencedFileCount(osu, 18); Assert.AreEqual(1, loggedExceptionCount); } @@ -193,8 +186,7 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.IsTrue(imported.Beatmaps.First().ID < importedSecondTime.Beatmaps.First().ID); // only one beatmap will exist as the online set ID matched, causing purging of the first import. - Assert.AreEqual(1, manager.GetAllUsableBeatmapSets().Count); - Assert.AreEqual(1, manager.QueryBeatmapSets(_ => true).ToList().Count); + checkBeatmapSetCount(osu, 1); } finally { @@ -396,11 +388,32 @@ namespace osu.Game.Tests.Beatmaps.IO var manager = osu.Dependencies.Get(); manager.Delete(imported); - Assert.IsTrue(manager.GetAllUsableBeatmapSets().Count == 0); - Assert.AreEqual(1, manager.QueryBeatmapSets(_ => true).ToList().Count); + checkBeatmapSetCount(osu, 0); + checkBeatmapSetCount(osu, 1, true); + checkSingleReferencedFileCount(osu, 0); + Assert.IsTrue(manager.QueryBeatmapSets(_ => true).First().DeletePending); } + private void checkBeatmapSetCount(OsuGameBase osu, int expected, bool includeDeletePending = false) + { + var manager = osu.Dependencies.Get(); + + Assert.AreEqual(expected, includeDeletePending + ? manager.QueryBeatmapSets(_ => true).ToList().Count + : manager.GetAllUsableBeatmapSets().Count); + } + + private void checkBeatmapCount(OsuGameBase osu, int expected) + { + Assert.AreEqual(expected, osu.Dependencies.Get().QueryBeatmaps(_ => true).ToList().Count); + } + + private void checkSingleReferencedFileCount(OsuGameBase osu, int expected) + { + Assert.AreEqual(expected, osu.Dependencies.Get().QueryFiles(f => f.ReferenceCount == 1).Count()); + } + private OsuGameBase loadOsu(GameHost host) { var osu = new OsuGameBase(); From f7a699e4a2e0031224661370ba840d7d9327df3f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 18:38:03 +0900 Subject: [PATCH 338/375] Better documentation for import scheduler singleton --- osu.Game/Database/ArchiveModelManager.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index fa8301bb2e..afc2690106 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -630,7 +630,15 @@ namespace osu.Game.Database public abstract class ArchiveModelManager { - // allow sharing static across all generic types - protected static readonly ThreadedTaskScheduler IMPORT_SCHEDULER = new ThreadedTaskScheduler(1); + private const int import_queue_request_concurrency = 1; + + /// + /// A singleton scheduler shared by all . + /// + /// + /// This scheduler generally performs IO and CPU intensive work so concurrency is limited harshly. + /// It is mainly being used as a queue mechanism for large imports. + /// + protected static readonly ThreadedTaskScheduler IMPORT_SCHEDULER = new ThreadedTaskScheduler(import_queue_request_concurrency); } } From 41e3e2222bc7d9c75e44a1340144c2d52e1f7acb Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 10 Jun 2019 18:40:49 +0900 Subject: [PATCH 339/375] fix test --- osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index d6b5e0175f..bc15bc6b6d 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -219,7 +219,7 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("Setup counter", () => { beatmapChangedCount = 0; - songSelect.Carousel.BeatmapSetsChanged += () => beatmapChangedCount++; + songSelect.Carousel.SelectionChanged += _ => beatmapChangedCount++; }); AddRepeatStep($"Create beatmaps {test_count} times", () => { From 6cda2cdb8225000f1a7de5e8c842a8d3f0a02aaf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 18:41:56 +0900 Subject: [PATCH 340/375] Fix exception output to use humanised model name --- osu.Game/Database/ArchiveModelManager.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index afc2690106..93e924fab5 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -146,8 +146,6 @@ namespace osu.Game.Database notification.Progress = 0; notification.Text = "Import is initialising..."; - var term = $"{typeof(TModel).Name.Replace("Info", "").ToLower()}"; - int current = 0; var imported = new List(); @@ -164,7 +162,7 @@ namespace osu.Game.Database { imported.Add(model); - notification.Text = $"Imported {current} of {paths.Length} {term}s"; + notification.Text = $"Imported {current} of {paths.Length} {humanisedModelName}s"; notification.Progress = (float)current / paths.Length; } } @@ -191,7 +189,7 @@ namespace osu.Game.Database { notification.CompletionText = imported.Count == 1 ? $"Imported {imported.First()}!" - : $"Imported {current} {term}s!"; + : $"Imported {current} {humanisedModelName}s!"; if (imported.Count > 0 && PresentImport != null) { @@ -339,7 +337,7 @@ namespace osu.Game.Database if (CanUndelete(existing, item)) { Undelete(existing); - Logger.Log($"Found existing {nameof(TModel)} for {item} (ID {existing.ID}). Skipping import.", LoggingTarget.Database); + Logger.Log($"Found existing {humanisedModelName} for {item} (ID {existing.ID}). Skipping import.", LoggingTarget.Database); handleEvent(() => ItemAdded?.Invoke(existing, true)); // existing item will be used; rollback new import and exit early. @@ -610,6 +608,8 @@ namespace osu.Game.Database private DbSet queryModel() => ContextFactory.Get().Set(); + private string humanisedModelName => $"{typeof(TModel).Name.Replace("Info", "").ToLower()}"; + /// /// Creates an from a valid storage path. /// From 54497fb1e78dd5447111cd256067f3959c1a61dd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 19:33:23 +0900 Subject: [PATCH 341/375] Fix prefixing spaces in BeatmapInfo's ToString when metadata is not populated yet --- osu.Game/Beatmaps/BeatmapInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/BeatmapInfo.cs b/osu.Game/Beatmaps/BeatmapInfo.cs index 52238c26fe..3c082bb71e 100644 --- a/osu.Game/Beatmaps/BeatmapInfo.cs +++ b/osu.Game/Beatmaps/BeatmapInfo.cs @@ -119,7 +119,7 @@ namespace osu.Game.Beatmaps /// public List Scores { get; set; } - public override string ToString() => $"{Metadata} [{Version}]"; + public override string ToString() => $"{Metadata} [{Version}]".Trim(); public bool Equals(BeatmapInfo other) { From 29945f27c5f22bcbb36ed693d813fd34707053ee Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 19:33:55 +0900 Subject: [PATCH 342/375] Fix imported count incrementing on failures --- osu.Game/Database/ArchiveModelManager.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 93e924fab5..4e9478dc10 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -162,6 +162,7 @@ namespace osu.Game.Database { imported.Add(model); + Interlocked.Increment(ref current); notification.Text = $"Imported {current} of {paths.Length} {humanisedModelName}s"; notification.Progress = (float)current / paths.Length; } @@ -174,10 +175,6 @@ namespace osu.Game.Database { Logger.Error(e, $@"Could not import ({Path.GetFileName(path)})"); } - finally - { - Interlocked.Increment(ref current); - } })); if (imported.Count == 0) From 6ca2fcebfce6467398d12fc69911ffb3f1c03eff Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 19:34:32 +0900 Subject: [PATCH 343/375] Centalise and prefix all ArchiveModelManager database logging --- osu.Game/Beatmaps/BeatmapManager.cs | 28 ++++++++++-------- osu.Game/Database/ArchiveModelManager.cs | 36 +++++++++++++++--------- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 435edcf722..47411c69ec 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -110,7 +110,7 @@ namespace osu.Game.Beatmaps validateOnlineIds(beatmapSet); - await Task.WhenAll(beatmapSet.Beatmaps.Select(b => updateQueue.Perform(b, cancellationToken)).ToArray()); + await updateQueue.Perform(beatmapSet, cancellationToken); } protected override void PreImport(BeatmapSetInfo beatmapSet) @@ -127,7 +127,7 @@ namespace osu.Game.Beatmaps { Delete(existingOnlineId); beatmaps.PurgeDeletable(s => s.ID == existingOnlineId.ID); - Logger.Log($"Found existing beatmap set with same OnlineBeatmapSetID ({beatmapSet.OnlineBeatmapSetID}). It has been purged.", LoggingTarget.Database); + LogForModel(beatmapSet, $"Found existing beatmap set with same OnlineBeatmapSetID ({beatmapSet.OnlineBeatmapSetID}). It has been purged."); } } } @@ -433,23 +433,29 @@ namespace osu.Game.Beatmaps this.api = api; } - public Task Perform(BeatmapInfo beatmap, CancellationToken cancellationToken) - => Task.Factory.StartNew(() => perform(beatmap, cancellationToken), cancellationToken, TaskCreationOptions.HideScheduler, updateScheduler); - - private void perform(BeatmapInfo beatmap, CancellationToken cancellation) + public async Task Perform(BeatmapSetInfo beatmapSet, CancellationToken cancellationToken) { - cancellation.ThrowIfCancellationRequested(); - if (api?.State != APIState.Online) return; - Logger.Log("Attempting online lookup for the missing values...", LoggingTarget.Database); + LogForModel(beatmapSet, "Performing online lookups..."); + await Task.WhenAll(beatmapSet.Beatmaps.Select(b => Perform(beatmapSet, b, cancellationToken)).ToArray()); + } + + // todo: expose this when we need to do individual difficulty lookups. + protected Task Perform(BeatmapSetInfo beatmapSet, BeatmapInfo beatmap, CancellationToken cancellationToken) + => Task.Factory.StartNew(() => perform(beatmapSet, beatmap), cancellationToken, TaskCreationOptions.HideScheduler, updateScheduler); + + private void perform(BeatmapSetInfo set, BeatmapInfo beatmap) + { + if (api?.State != APIState.Online) + return; var req = new GetBeatmapRequest(beatmap); req.Success += res => { - Logger.Log($"Successfully mapped to {res.OnlineBeatmapSetID} / {res.OnlineBeatmapID}.", LoggingTarget.Database); + LogForModel(set, $"Online retrieval mapped {beatmap} to {res.OnlineBeatmapSetID} / {res.OnlineBeatmapID}."); beatmap.Status = res.Status; beatmap.BeatmapSet.Status = res.BeatmapSet.Status; @@ -457,7 +463,7 @@ namespace osu.Game.Beatmaps beatmap.OnlineBeatmapID = res.OnlineBeatmapID; }; - req.Failure += e => { Logger.Log($"Failed ({e})", LoggingTarget.Database); }; + req.Failure += e => { LogForModel(set, $"Online retrieval failed for {beatmap}", e); }; // intentionally blocking to limit web request concurrency req.Perform(api); diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 4e9478dc10..844ae622a5 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -173,7 +173,7 @@ namespace osu.Game.Database } catch (Exception e) { - Logger.Error(e, $@"Could not import ({Path.GetFileName(path)})"); + Logger.Error(e, $@"Could not import ({Path.GetFileName(path)})", LoggingTarget.Database); } })); @@ -227,7 +227,7 @@ namespace osu.Game.Database } catch (Exception e) { - Logger.Error(e, $@"Could not delete original file after import ({Path.GetFileName(path)})"); + LogForModel(import, $@"Could not delete original file after import ({Path.GetFileName(path)})", e); } return import; @@ -247,7 +247,7 @@ namespace osu.Game.Database { cancellationToken.ThrowIfCancellationRequested(); - TModel model; + TModel model = null; try { @@ -263,7 +263,7 @@ namespace osu.Game.Database } catch (Exception e) { - Logger.Error(e, $"Model creation of {archive.Name} failed.", LoggingTarget.Database); + LogForModel(model, $"Model creation of {archive.Name} failed.", e); return null; } @@ -277,6 +277,16 @@ namespace osu.Game.Database /// protected abstract string[] HashableFileTypes { get; } + protected static void LogForModel(TModel model, string message, Exception e = null) + { + string prefix = $"[{(model?.Hash ?? "?????").Substring(0, 5)}]"; + + if (e != null) + Logger.Error(e, $"{prefix} {message}", LoggingTarget.Database); + else + Logger.Log($"{prefix} {message}", LoggingTarget.Database); + } + /// /// Create a SHA-2 hash from the provided archive based on file content of all files matching . /// @@ -308,14 +318,14 @@ namespace osu.Game.Database if (!Delete(item)) { // We may have not yet added the model to the underlying table, but should still clean up files. - Logger.Log($"Dereferencing files for incomplete import of {item}.", LoggingTarget.Database); + LogForModel(item, "Dereferencing files for incomplete import."); Files.Dereference(item.Files.Select(f => f.FileInfo).ToArray()); } } try { - Logger.Log($"Importing {item}...", LoggingTarget.Database); + LogForModel(item, "Beginning import..."); item.Files = archive != null ? createFileInfos(archive, Files) : new List(); @@ -334,7 +344,7 @@ namespace osu.Game.Database if (CanUndelete(existing, item)) { Undelete(existing); - Logger.Log($"Found existing {humanisedModelName} for {item} (ID {existing.ID}). Skipping import.", LoggingTarget.Database); + LogForModel(item, $"Found existing {humanisedModelName} for {item} (ID {existing.ID}) – skipping import."); handleEvent(() => ItemAdded?.Invoke(existing, true)); // existing item will be used; rollback new import and exit early. @@ -342,11 +352,9 @@ namespace osu.Game.Database flushEvents(true); return existing; } - else - { - Delete(existing); - ModelStore.PurgeDeletable(s => s.ID == existing.ID); - } + + Delete(existing); + ModelStore.PurgeDeletable(s => s.ID == existing.ID); } PreImport(item); @@ -361,12 +369,12 @@ namespace osu.Game.Database } } - Logger.Log($"Import of {item} successfully completed!", LoggingTarget.Database); + LogForModel(item, "Import successfully completed!"); } catch (Exception e) { if (!(e is TaskCanceledException)) - Logger.Error(e, $"Import of {item} failed and has been rolled back.", LoggingTarget.Database); + LogForModel(item, "Database import or population failed and has been rolled back.", e); rollback(); flushEvents(false); From 2b768bef96e28f438116f9458ce61130e76c17a5 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 10 Jun 2019 20:29:01 +0900 Subject: [PATCH 344/375] Make CursorTrail use VertexBatch --- .../UI/Cursor/CursorTrail.cs | 76 ++++++------------- 1 file changed, 22 insertions(+), 54 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs index 2276b9f9f4..b986076593 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs @@ -6,7 +6,7 @@ using System.Diagnostics; using System.Runtime.InteropServices; using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.OpenGL.Buffers; +using osu.Framework.Graphics.Batches; using osu.Framework.Graphics.OpenGL.Vertices; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Shaders; @@ -57,7 +57,6 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor // InvalidationID 1 forces an update of each part of the cursor trail the first time ApplyState is run on the draw node // This is to prevent garbage data from being sent to the vertex shader, resulting in visual issues on some platforms parts[i].InvalidationID = 1; - parts[i].WasUpdated = true; } } @@ -149,7 +148,6 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor public Vector2 Position; public float Time; public long InvalidationID; - public bool WasUpdated; } private class TrailDrawNode : DrawNode @@ -164,16 +162,13 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor private readonly TrailPart[] parts = new TrailPart[max_sprites]; private Vector2 size; - private readonly VertexBuffer vertexBuffer = new QuadVertexBuffer(max_sprites, BufferUsageHint.DynamicDraw); + private readonly VertexBatch vertexBatch = new QuadBatch(max_sprites, 1); public TrailDrawNode(CursorTrail source) : base(source) { for (int i = 0; i < max_sprites; i++) - { parts[i].InvalidationID = 0; - parts[i].WasUpdated = false; - } } public override void ApplyState() @@ -194,56 +189,29 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor public override void Draw(Action vertexAction) { - shader.GetUniform("g_FadeClock").UpdateValue(ref time); - - int updateStart = -1, updateEnd = 0; - - for (int i = 0; i < parts.Length; ++i) - { - if (parts[i].WasUpdated) - { - if (updateStart == -1) - updateStart = i; - updateEnd = i + 1; - - int start = i * 4; - int end = start; - - Vector2 pos = parts[i].Position; - float localTime = parts[i].Time; - - DrawQuad( - texture, - new Quad(pos.X - size.X / 2, pos.Y - size.Y / 2, size.X, size.Y), - DrawColourInfo.Colour, - null, - v => vertexBuffer.Vertices[end++] = new TexturedTrailVertex - { - Position = v.Position, - TexturePosition = v.TexturePosition, - Time = localTime + 1, - Colour = v.Colour, - }); - - parts[i].WasUpdated = false; - } - else if (updateStart != -1) - { - vertexBuffer.UpdateRange(updateStart * 4, updateEnd * 4); - updateStart = -1; - } - } - - // Update all remaining vertices that have been changed. - if (updateStart != -1) - vertexBuffer.UpdateRange(updateStart * 4, updateEnd * 4); - base.Draw(vertexAction); shader.Bind(); + shader.GetUniform("g_FadeClock").UpdateValue(ref time); - texture.TextureGL.Bind(); - vertexBuffer.Draw(); + for (int i = 0; i < parts.Length; ++i) + { + Vector2 pos = parts[i].Position; + float localTime = parts[i].Time; + + DrawQuad( + texture, + new Quad(pos.X - size.X / 2, pos.Y - size.Y / 2, size.X, size.Y), + DrawColourInfo.Colour, + null, + v => vertexBatch.Add(new TexturedTrailVertex + { + Position = v.Position, + TexturePosition = v.TexturePosition, + Time = localTime + 1, + Colour = v.Colour, + })); + } shader.Unbind(); } @@ -252,7 +220,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor { base.Dispose(isDisposing); - vertexBuffer.Dispose(); + vertexBatch.Dispose(); } } From e87123342cab2004c7baea09310a1ddf83b6b547 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jun 2019 23:50:44 +0900 Subject: [PATCH 345/375] Load results pages asynchronously Reduces performance burden when first displaying pages. Closes #4977. --- osu.Game/Screens/Ranking/Results.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index bebeaee00a..370c856d1d 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -275,7 +275,7 @@ namespace osu.Game.Screens.Ranking currentPage = page.NewValue?.CreatePage(); if (currentPage != null) - circleInner.Add(currentPage); + LoadComponentAsync(currentPage, circleInner.Add); }, true); } From 71e15fe0f112aa6fb693c54536bb486ad97eedef Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 11 Jun 2019 01:18:49 +0900 Subject: [PATCH 346/375] Fix incorrect xmldoc in OsuAnimatedButton --- osu.Game/Graphics/UserInterface/OsuAnimatedButton.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuAnimatedButton.cs b/osu.Game/Graphics/UserInterface/OsuAnimatedButton.cs index 236b72766f..1a8fea4ff9 100644 --- a/osu.Game/Graphics/UserInterface/OsuAnimatedButton.cs +++ b/osu.Game/Graphics/UserInterface/OsuAnimatedButton.cs @@ -19,14 +19,14 @@ namespace osu.Game.Graphics.UserInterface public class OsuAnimatedButton : OsuClickableContainer { /// - /// The colour that should be flashed when the is clicked. + /// The colour that should be flashed when the is clicked. /// protected Color4 FlashColour = Color4.White.Opacity(0.3f); private Color4 hoverColour = Color4.White.Opacity(0.1f); /// - /// The background colour of the while it is hovered. + /// The background colour of the while it is hovered. /// protected Color4 HoverColour { From d4ba67747b37f4db9a0a482a5fef54470a6bcbfc Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 10 Jun 2019 18:58:03 +0900 Subject: [PATCH 347/375] fix test count --- .idea/.idea.osu/.idea/.name | 1 + .../Visual/SongSelect/TestScenePlaySongSelect.cs | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 .idea/.idea.osu/.idea/.name diff --git a/.idea/.idea.osu/.idea/.name b/.idea/.idea.osu/.idea/.name new file mode 100644 index 0000000000..21cb4db60e --- /dev/null +++ b/.idea/.idea.osu/.idea/.name @@ -0,0 +1 @@ +osu \ No newline at end of file diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index bc15bc6b6d..fa73a14252 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -11,6 +11,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Bindables; using osu.Framework.Extensions; +using osu.Framework.Logging; using osu.Framework.MathUtils; using osu.Framework.Platform; using osu.Framework.Screens; @@ -215,11 +216,13 @@ namespace osu.Game.Tests.Visual.SongSelect { const int test_count = 10; int beatmapChangedCount = 0; + int debounceCount = 0; createSongSelect(); - AddStep("Setup counter", () => + AddStep("Setup counters", () => { beatmapChangedCount = 0; - songSelect.Carousel.SelectionChanged += _ => beatmapChangedCount++; + debounceCount = 0; + songSelect.Carousel.SelectionChanged += _ => beatmapChangedCount += 1; }); AddRepeatStep($"Create beatmaps {test_count} times", () => { @@ -229,10 +232,14 @@ namespace osu.Game.Tests.Visual.SongSelect { // Wait for debounce songSelect.Carousel.SelectNextRandom(); + ++debounceCount; }, 400); }, test_count); - AddAssert($"Beatmap changed {test_count} times", () => beatmapChangedCount == test_count); + AddUntilStep("Debounce limit reached", () => debounceCount == test_count); + + // The selected beatmap should have changed an additional 2 times since both initially loading songselect and the first import also triggers selectionChanged + AddAssert($"Beatmap changed {test_count + 2} times", () => beatmapChangedCount == test_count + 2); } [Test] From 609a82bc948dc14f8e604aa932d71b470e8657a7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 11 Jun 2019 14:28:52 +0900 Subject: [PATCH 348/375] Update VisibilityContainer usage in line with framework --- osu.Desktop/OsuGameDesktop.cs | 9 ++---- .../TestSceneResumeOverlay.cs | 4 +-- osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs | 2 +- .../Visual/Gameplay/TestSceneFailAnimation.cs | 2 +- .../Gameplay/TestSceneGameplayMenuOverlay.cs | 6 ++-- .../Visual/Gameplay/TestScenePause.cs | 4 +-- .../Visual/Gameplay/TestSceneStoryboard.cs | 2 +- .../Visual/Menus/TestSceneToolbar.cs | 2 +- .../TestSceneMatchSettingsOverlay.cs | 2 +- .../Online/TestSceneAccountCreationOverlay.cs | 2 +- .../Visual/Online/TestSceneChatDisplay.cs | 2 +- .../Visual/Settings/TestSceneSettings.cs | 2 +- .../SongSelect/TestSceneBeatmapInfoWedge.cs | 9 +++--- .../Visual/UserInterface/TestSceneCursors.cs | 4 +-- .../UserInterface/TestSceneMusicController.cs | 4 +-- .../TestSceneNotificationOverlay.cs | 2 +- .../UserInterface/TestScenePopupDialog.cs | 2 +- .../Containers/OsuFocusedOverlayContainer.cs | 12 ++++---- osu.Game/Graphics/Containers/WaveContainer.cs | 4 +-- .../Graphics/Cursor/MenuCursorContainer.cs | 2 +- .../UserInterface/BreadcrumbControl.cs | 4 +++ .../UserInterface/ProcessingOverlay.cs | 2 +- osu.Game/OsuGame.cs | 28 +++++++++---------- osu.Game/Overlays/AccountCreationOverlay.cs | 2 +- osu.Game/Overlays/BeatmapSetOverlay.cs | 2 +- osu.Game/Overlays/ChangelogOverlay.cs | 8 +++--- osu.Game/Overlays/ChatOverlay.cs | 24 ++++++++-------- osu.Game/Overlays/DialogOverlay.cs | 8 +++--- osu.Game/Overlays/DirectOverlay.cs | 2 +- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 4 +-- osu.Game/Overlays/Music/PlaylistOverlay.cs | 2 +- osu.Game/Overlays/MusicController.cs | 4 +-- osu.Game/Overlays/NotificationOverlay.cs | 8 +++--- .../Sections/General/LoginSettings.cs | 2 +- osu.Game/Overlays/SettingsOverlay.cs | 11 ++++---- osu.Game/Overlays/Toolbar/Toolbar.cs | 4 +-- .../Toolbar/ToolbarOverlayToggleButton.cs | 20 ++++++------- osu.Game/Overlays/VolumeOverlay.cs | 6 ++-- .../Rulesets/UI/GameplayCursorContainer.cs | 2 +- osu.Game/Screens/Menu/ButtonArea.cs | 8 ++++-- osu.Game/Screens/Play/GameplayMenuOverlay.cs | 2 +- .../Screens/Play/HUD/PlayerSettingsOverlay.cs | 2 +- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Play/SkipOverlay.cs | 14 ++++++---- osu.Game/Screens/Play/SongProgress.cs | 2 +- osu.Game/Screens/Select/BeatmapDetails.cs | 4 +-- osu.Game/Screens/Select/BeatmapInfoWedge.cs | 2 +- osu.Game/Screens/Select/SongSelect.cs | 4 +-- osu.Game/osu.Game.csproj | 4 ++- osu.sln | 12 ++++++++ 50 files changed, 150 insertions(+), 127 deletions(-) diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index 00cabbadf7..975b7f9f5a 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -7,7 +7,6 @@ using System.Linq; using System.Reflection; using System.Threading.Tasks; using osu.Desktop.Overlays; -using osu.Framework.Graphics.Containers; using osu.Framework.Platform; using osu.Game; using osuTK.Input; @@ -56,7 +55,7 @@ namespace osu.Desktop LoadComponentAsync(versionManager = new VersionManager { Depth = int.MinValue }, v => { Add(v); - v.State = Visibility.Visible; + v.Show(); }); if (RuntimeInfo.OS == RuntimeInfo.Platform.Windows) @@ -74,13 +73,11 @@ namespace osu.Desktop { case Intro _: case MainMenu _: - if (versionManager != null) - versionManager.State = Visibility.Visible; + versionManager?.Show(); break; default: - if (versionManager != null) - versionManager.State = Visibility.Hidden; + versionManager?.Hide(); break; } } diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs index 12a3a8d27e..8e73d6152f 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs @@ -46,11 +46,11 @@ namespace osu.Game.Rulesets.Osu.Tests AddStep("move mouse away", () => InputManager.MoveMouseTo(ScreenSpaceDrawQuad.TopLeft)); AddStep("click", () => osuInputManager.GameClick()); - AddAssert("not dismissed", () => !resumeFired && resume.State == Visibility.Visible); + AddAssert("not dismissed", () => !resumeFired && resume.State.Value == Visibility.Visible); AddStep("move mouse back", () => InputManager.MoveMouseTo(ScreenSpaceDrawQuad.Centre)); AddStep("click", () => osuInputManager.GameClick()); - AddAssert("dismissed", () => resumeFired && resume.State == Visibility.Hidden); + AddAssert("dismissed", () => resumeFired && resume.State.Value == Visibility.Hidden); } private class ManualOsuInputManager : OsuInputManager diff --git a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs index 0d4e7edb7b..9e5df0d6b1 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs @@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Osu.UI private GameplayCursorContainer localCursorContainer; - public override CursorContainer LocalCursor => State == Visibility.Visible ? localCursorContainer : null; + public override CursorContainer LocalCursor => State.Value == Visibility.Visible ? localCursorContainer : null; protected override string Message => "Click the orange cursor to resume"; diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneFailAnimation.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneFailAnimation.cs index 4878587dcd..f06f72615b 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneFailAnimation.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneFailAnimation.cs @@ -28,7 +28,7 @@ namespace osu.Game.Tests.Visual.Gameplay protected override void AddCheckSteps() { AddUntilStep("wait for fail", () => Player.HasFailed); - AddUntilStep("wait for fail overlay", () => ((FailPlayer)Player).FailOverlay.State == Visibility.Visible); + AddUntilStep("wait for fail overlay", () => ((FailPlayer)Player).FailOverlay.State.Value == Visibility.Visible); } private class FailPlayer : TestPlayer diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs index ba9c583b08..4727140d99 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs @@ -97,7 +97,7 @@ namespace osu.Game.Tests.Visual.Gameplay AddStep("Show overlay", () => pauseOverlay.Show()); AddStep("Press select", () => press(GlobalAction.Select)); - AddAssert("Overlay still open", () => pauseOverlay.State == Visibility.Visible); + AddAssert("Overlay still open", () => pauseOverlay.State.Value == Visibility.Visible); AddStep("Hide overlay", () => pauseOverlay.Hide()); } @@ -237,7 +237,7 @@ namespace osu.Game.Tests.Visual.Gameplay }); AddAssert("Action was triggered", () => triggered); - AddAssert("Overlay is closed", () => pauseOverlay.State == Visibility.Hidden); + AddAssert("Overlay is closed", () => pauseOverlay.State.Value == Visibility.Hidden); } /// @@ -272,7 +272,7 @@ namespace osu.Game.Tests.Visual.Gameplay return triggered; }); - AddAssert("Overlay is closed", () => pauseOverlay.State == Visibility.Hidden); + AddAssert("Overlay is closed", () => pauseOverlay.State.Value == Visibility.Hidden); } private void press(Key key) diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs index 12e91df77c..0de0fcfc38 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs @@ -203,9 +203,9 @@ namespace osu.Game.Tests.Visual.Gameplay public new HUDOverlay HUDOverlay => base.HUDOverlay; - public bool FailOverlayVisible => FailOverlay.State == Visibility.Visible; + public bool FailOverlayVisible => FailOverlay.State.Value == Visibility.Visible; - public bool PauseOverlayVisible => PauseOverlay.State == Visibility.Visible; + public bool PauseOverlayVisible => PauseOverlay.State.Value == Visibility.Visible; public override void OnEntering(IScreen last) { diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneStoryboard.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneStoryboard.cs index 213cdf5e48..ead7a4b7fc 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneStoryboard.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneStoryboard.cs @@ -46,7 +46,7 @@ namespace osu.Game.Tests.Visual.Gameplay { Origin = Anchor.TopRight, Anchor = Anchor.TopRight, - State = Visibility.Visible, + State = { Value = Visibility.Visible }, }); AddStep("Restart", restart); diff --git a/osu.Game.Tests/Visual/Menus/TestSceneToolbar.cs b/osu.Game.Tests/Visual/Menus/TestSceneToolbar.cs index 0c789d8cb7..0df6605cdd 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneToolbar.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneToolbar.cs @@ -23,7 +23,7 @@ namespace osu.Game.Tests.Visual.Menus public TestSceneToolbar() { - var toolbar = new Toolbar { State = Visibility.Visible }; + var toolbar = new Toolbar { State = { Value = Visibility.Visible } }; ToolbarNotificationButton notificationButton = null; AddStep("create toolbar", () => diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs index 8091e93471..8d842fc865 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs @@ -36,7 +36,7 @@ namespace osu.Game.Tests.Visual.Multiplayer settings = new TestRoomSettings { RelativeSizeAxes = Axes.Both, - State = Visibility.Visible + State = { Value = Visibility.Visible } }; Child = settings; diff --git a/osu.Game.Tests/Visual/Online/TestSceneAccountCreationOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneAccountCreationOverlay.cs index a7e725ec3f..35449f5687 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneAccountCreationOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneAccountCreationOverlay.cs @@ -49,7 +49,7 @@ namespace osu.Game.Tests.Visual.Online api.Logout(); api.LocalUser.BindValueChanged(user => { userPanelArea.Child = new UserPanel(user.NewValue) { Width = 200 }; }, true); - AddStep("show", () => accountCreation.State = Visibility.Visible); + AddStep("show", () => accountCreation.Show()); AddStep("logout", () => api.Logout()); } } diff --git a/osu.Game.Tests/Visual/Online/TestSceneChatDisplay.cs b/osu.Game.Tests/Visual/Online/TestSceneChatDisplay.cs index 634176e65f..2789feef3d 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChatDisplay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChatDisplay.cs @@ -38,7 +38,7 @@ namespace osu.Game.Tests.Visual.Online Children = new Drawable[] { channelManager, - new ChatOverlay { State = Visibility.Visible } + new ChatOverlay { State = { Value = Visibility.Visible } } }; } } diff --git a/osu.Game.Tests/Visual/Settings/TestSceneSettings.cs b/osu.Game.Tests/Visual/Settings/TestSceneSettings.cs index 964754f8d0..f97ce8c69e 100644 --- a/osu.Game.Tests/Visual/Settings/TestSceneSettings.cs +++ b/osu.Game.Tests/Visual/Settings/TestSceneSettings.cs @@ -18,7 +18,7 @@ namespace osu.Game.Tests.Visual.Settings { settings = new SettingsOverlay { - State = Visibility.Visible + State = { Value = Visibility.Visible } }; Add(dialogOverlay = new DialogOverlay { diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs index 9969795ecf..932e114580 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; @@ -7,7 +7,6 @@ using JetBrains.Annotations; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; using osu.Game.Graphics.Sprites; using osu.Game.Rulesets; @@ -48,7 +47,7 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("show", () => { - infoWedge.State = Visibility.Visible; + infoWedge.Show(); infoWedge.Beatmap = Beatmap.Value; }); @@ -57,11 +56,11 @@ namespace osu.Game.Tests.Visual.SongSelect AddWaitStep("wait for select", 3); - AddStep("hide", () => { infoWedge.State = Visibility.Hidden; }); + AddStep("hide", () => { infoWedge.Hide(); }); AddWaitStep("wait for hide", 3); - AddStep("show", () => { infoWedge.State = Visibility.Visible; }); + AddStep("show", () => { infoWedge.Show(); }); foreach (var rulesetInfo in rulesets.AvailableRulesets) { diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneCursors.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneCursors.cs index 8fe31b7ad6..e7dbbc8bc4 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneCursors.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneCursors.cs @@ -176,7 +176,7 @@ namespace osu.Game.Tests.Visual.UserInterface /// Checks if a cursor is visible. /// /// The cursor to check. - private bool checkVisible(CursorContainer cursorContainer) => cursorContainer.State == Visibility.Visible; + private bool checkVisible(CursorContainer cursorContainer) => cursorContainer.State.Value == Visibility.Visible; /// /// Checks if a cursor is at the current inputmanager screen position. @@ -218,7 +218,7 @@ namespace osu.Game.Tests.Visual.UserInterface }, Cursor = new TestCursorContainer { - State = providesUserCursor ? Visibility.Hidden : Visibility.Visible, + State = { Value = providesUserCursor ? Visibility.Hidden : Visibility.Visible }, } }; } diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneMusicController.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneMusicController.cs index a62fd6467b..2f2a40925f 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneMusicController.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneMusicController.cs @@ -23,8 +23,8 @@ namespace osu.Game.Tests.Visual.UserInterface }; Add(mc); - AddToggleStep(@"toggle visibility", state => mc.State = state ? Visibility.Visible : Visibility.Hidden); - AddStep(@"show", () => mc.State = Visibility.Visible); + AddToggleStep(@"toggle visibility", state => mc.State.Value = state ? Visibility.Visible : Visibility.Hidden); + AddStep(@"show", () => mc.Show()); AddToggleStep(@"toggle beatmap lock", state => Beatmap.Disabled = state); } } diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneNotificationOverlay.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneNotificationOverlay.cs index 71033fcd2f..6b7427cef5 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneNotificationOverlay.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneNotificationOverlay.cs @@ -45,7 +45,7 @@ namespace osu.Game.Tests.Visual.UserInterface Content.Add(displayedCount); - void setState(Visibility state) => AddStep(state.ToString(), () => manager.State = state); + void setState(Visibility state) => AddStep(state.ToString(), () => manager.State.Value = state); void checkProgressingCount(int expected) => AddAssert($"progressing count is {expected}", () => progressingNotifications.Count == expected); manager.UnreadCount.ValueChanged += count => { displayedCount.Text = $"displayed count: {count.NewValue}"; }; diff --git a/osu.Game.Tests/Visual/UserInterface/TestScenePopupDialog.cs b/osu.Game.Tests/Visual/UserInterface/TestScenePopupDialog.cs index 24140125e0..9ddd8f4038 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestScenePopupDialog.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestScenePopupDialog.cs @@ -16,7 +16,7 @@ namespace osu.Game.Tests.Visual.UserInterface var popup = new PopupDialog { RelativeSizeAxes = Axes.Both, - State = Framework.Graphics.Containers.Visibility.Visible, + State = { Value = Framework.Graphics.Containers.Visibility.Visible }, Icon = FontAwesome.Solid.AssistiveListeningSystems, HeaderText = @"This is a test popup", BodyText = "I can say lots of stuff and even wrap my words!", diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index 8b34459710..f6db3102f2 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -54,7 +54,7 @@ namespace osu.Game.Graphics.Containers samplePopIn = audio.Samples.Get(@"UI/overlay-pop-in"); samplePopOut = audio.Samples.Get(@"UI/overlay-pop-out"); - StateChanged += onStateChanged; + State.ValueChanged += onStateChanged; } /// @@ -70,7 +70,7 @@ namespace osu.Game.Graphics.Containers { if (!base.ReceivePositionalInputAt(e.ScreenSpaceMousePosition)) { - State = Visibility.Hidden; + Hide(); return true; } @@ -82,7 +82,7 @@ namespace osu.Game.Graphics.Containers switch (action) { case GlobalAction.Back: - State = Visibility.Hidden; + Hide(); return true; case GlobalAction.Select: @@ -94,9 +94,9 @@ namespace osu.Game.Graphics.Containers public bool OnReleased(GlobalAction action) => false; - private void onStateChanged(Visibility visibility) + private void onStateChanged(ValueChangedEvent state) { - switch (visibility) + switch (state.NewValue) { case Visibility.Visible: if (OverlayActivationMode.Value != OverlayActivation.Disabled) @@ -105,7 +105,7 @@ namespace osu.Game.Graphics.Containers if (BlockScreenWideMouse && DimMainContent) osuGame?.AddBlockingOverlay(this); } else - State = Visibility.Hidden; + Hide(); break; diff --git a/osu.Game/Graphics/Containers/WaveContainer.cs b/osu.Game/Graphics/Containers/WaveContainer.cs index 464682a0ad..f87909ab17 100644 --- a/osu.Game/Graphics/Containers/WaveContainer.cs +++ b/osu.Game/Graphics/Containers/WaveContainer.cs @@ -103,7 +103,7 @@ namespace osu.Game.Graphics.Containers protected override void PopIn() { foreach (var w in wavesContainer.Children) - w.State = Visibility.Visible; + w.Show(); this.FadeIn(100, Easing.OutQuint); contentContainer.MoveToY(0, APPEAR_DURATION, Easing.OutQuint); @@ -117,7 +117,7 @@ namespace osu.Game.Graphics.Containers contentContainer.MoveToY(DrawHeight * 2f, DISAPPEAR_DURATION, Easing.In); foreach (var w in wavesContainer.Children) - w.State = Visibility.Hidden; + w.Hide(); this.FadeOut(DISAPPEAR_DURATION, Easing.InQuint); } diff --git a/osu.Game/Graphics/Cursor/MenuCursorContainer.cs b/osu.Game/Graphics/Cursor/MenuCursorContainer.cs index 92e5ba6195..b7ea1ba56a 100644 --- a/osu.Game/Graphics/Cursor/MenuCursorContainer.cs +++ b/osu.Game/Graphics/Cursor/MenuCursorContainer.cs @@ -29,7 +29,7 @@ namespace osu.Game.Graphics.Cursor { AddRangeInternal(new Drawable[] { - Cursor = new MenuCursor { State = Visibility.Hidden }, + Cursor = new MenuCursor { State = { Value = Visibility.Hidden } }, content = new Container { RelativeSizeAxes = Axes.Both } }); } diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index f5e57e5f27..d1e55fee24 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -82,6 +82,10 @@ namespace osu.Game.Graphics.UserInterface } } + public override void Hide() => State = Visibility.Hidden; + + public override void Show() => State = Visibility.Visible; + public BreadcrumbTabItem(T value) : base(value) { diff --git a/osu.Game/Graphics/UserInterface/ProcessingOverlay.cs b/osu.Game/Graphics/UserInterface/ProcessingOverlay.cs index 8b50f4a97a..d75e78e2d9 100644 --- a/osu.Game/Graphics/UserInterface/ProcessingOverlay.cs +++ b/osu.Game/Graphics/UserInterface/ProcessingOverlay.cs @@ -34,7 +34,7 @@ namespace osu.Game.Graphics.UserInterface RelativeSizeAxes = Axes.Both, Alpha = 0.9f, }, - new LoadingAnimation { State = Visibility.Visible } + new LoadingAnimation { State = { Value = Visibility.Visible } } }; } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index ba9abcdefc..d5fbcdfee3 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -132,12 +132,12 @@ namespace osu.Game public void CloseAllOverlays(bool hideToolbarElements = true) { foreach (var overlay in overlays) - overlay.State = Visibility.Hidden; + overlay.Hide(); if (hideToolbarElements) { foreach (var overlay in toolbarElements) - overlay.State = Visibility.Hidden; + overlay.Hide(); } } @@ -461,7 +461,7 @@ namespace osu.Game loadComponentSingleFile(new DialogOverlay(), topMostOverlayContent.Add, true); loadComponentSingleFile(externalLinkOpener = new ExternalLinkOpener(), topMostOverlayContent.Add); - chatOverlay.StateChanged += state => channelManager.HighPollRate.Value = state == Visibility.Visible; + chatOverlay.State.ValueChanged += state => channelManager.HighPollRate.Value = state.NewValue == Visibility.Visible; Add(externalLinkOpener = new ExternalLinkOpener()); @@ -470,9 +470,9 @@ namespace osu.Game foreach (var overlay in singleDisplaySideOverlays) { - overlay.StateChanged += state => + overlay.State.ValueChanged += state => { - if (state == Visibility.Hidden) return; + if (state.NewValue == Visibility.Hidden) return; singleDisplaySideOverlays.Where(o => o != overlay).ForEach(o => o.Hide()); }; @@ -484,9 +484,9 @@ namespace osu.Game foreach (var overlay in informationalOverlays) { - overlay.StateChanged += state => + overlay.State.ValueChanged += state => { - if (state == Visibility.Hidden) return; + if (state.NewValue == Visibility.Hidden) return; informationalOverlays.Where(o => o != overlay).ForEach(o => o.Hide()); }; @@ -498,12 +498,12 @@ namespace osu.Game foreach (var overlay in singleDisplayOverlays) { - overlay.StateChanged += state => + overlay.State.ValueChanged += state => { // informational overlays should be dismissed on a show or hide of a full overlay. informationalOverlays.ForEach(o => o.Hide()); - if (state == Visibility.Hidden) return; + if (state.NewValue == Visibility.Hidden) return; singleDisplayOverlays.Where(o => o != overlay).ForEach(o => o.Hide()); }; @@ -518,16 +518,16 @@ namespace osu.Game { float offset = 0; - if (settings.State == Visibility.Visible) + if (settings.State.Value == Visibility.Visible) offset += ToolbarButton.WIDTH / 2; - if (notifications.State == Visibility.Visible) + if (notifications.State.Value == Visibility.Visible) offset -= ToolbarButton.WIDTH / 2; screenContainer.MoveToX(offset, SettingsPanel.TRANSITION_LENGTH, Easing.OutQuint); } - settings.StateChanged += _ => updateScreenOffset(); - notifications.StateChanged += _ => updateScreenOffset(); + settings.State.ValueChanged += _ => updateScreenOffset(); + notifications.State.ValueChanged += _ => updateScreenOffset(); } public class GameIdleTracker : IdleTracker @@ -768,7 +768,7 @@ namespace osu.Game if (newOsuScreen.HideOverlaysOnEnter) CloseAllOverlays(); else - Toolbar.State = Visibility.Visible; + Toolbar.Show(); } } diff --git a/osu.Game/Overlays/AccountCreationOverlay.cs b/osu.Game/Overlays/AccountCreationOverlay.cs index 52d2917677..89d8cbde11 100644 --- a/osu.Game/Overlays/AccountCreationOverlay.cs +++ b/osu.Game/Overlays/AccountCreationOverlay.cs @@ -109,7 +109,7 @@ namespace osu.Game.Overlays break; case APIState.Online: - State = Visibility.Hidden; + Hide(); break; } } diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index 3ed398d31a..e0852a890c 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -92,7 +92,7 @@ namespace osu.Game.Overlays protected override bool OnClick(ClickEvent e) { - State = Visibility.Hidden; + Hide(); return true; } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 4a6d53b480..67f195580e 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -92,7 +92,7 @@ namespace osu.Game.Overlays public void ShowListing() { Current.Value = null; - State = Visibility.Visible; + Show(); } /// @@ -106,7 +106,7 @@ namespace osu.Game.Overlays if (build == null) throw new ArgumentNullException(nameof(build)); Current.Value = build; - State = Visibility.Visible; + Show(); } public void ShowBuild([NotNull] string updateStream, [NotNull] string version) @@ -123,7 +123,7 @@ namespace osu.Game.Overlays ShowBuild(build); }); - State = Visibility.Visible; + Show(); } public override bool OnPressed(GlobalAction action) @@ -133,7 +133,7 @@ namespace osu.Game.Overlays case GlobalAction.Back: if (Current.Value == null) { - State = Visibility.Hidden; + Hide(); } else { diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index eb95fabe02..0c1cca3d49 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -56,7 +56,7 @@ namespace osu.Game.Overlays private readonly Container channelSelectionContainer; private readonly ChannelSelectionOverlay channelSelectionOverlay; - public override bool Contains(Vector2 screenSpacePos) => chatContainer.ReceivePositionalInputAt(screenSpacePos) || channelSelectionOverlay.State == Visibility.Visible && channelSelectionOverlay.ReceivePositionalInputAt(screenSpacePos); + public override bool Contains(Vector2 screenSpacePos) => chatContainer.ReceivePositionalInputAt(screenSpacePos) || channelSelectionOverlay.State.Value == Visibility.Visible && channelSelectionOverlay.ReceivePositionalInputAt(screenSpacePos); public ChatOverlay() { @@ -130,7 +130,7 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.Both, Height = 1, PlaceholderText = "type your message", - Exit = () => State = Visibility.Hidden, + Exit = Hide, OnCommit = postMessage, ReleaseFocusOnCommit = false, HoldFocus = true, @@ -163,19 +163,19 @@ namespace osu.Game.Overlays }; channelTabControl.Current.ValueChanged += current => channelManager.CurrentChannel.Value = current.NewValue; - channelTabControl.ChannelSelectorActive.ValueChanged += active => channelSelectionOverlay.State = active.NewValue ? Visibility.Visible : Visibility.Hidden; - channelSelectionOverlay.StateChanged += state => + channelTabControl.ChannelSelectorActive.ValueChanged += active => channelSelectionOverlay.State.Value = active.NewValue ? Visibility.Visible : Visibility.Hidden; + channelSelectionOverlay.State.ValueChanged += state => { - if (state == Visibility.Hidden && channelManager.CurrentChannel.Value == null) + if (state.NewValue == Visibility.Hidden && channelManager.CurrentChannel.Value == null) { - channelSelectionOverlay.State = Visibility.Visible; - State = Visibility.Hidden; + channelSelectionOverlay.Show(); + Hide(); return; } - channelTabControl.ChannelSelectorActive.Value = state == Visibility.Visible; + channelTabControl.ChannelSelectorActive.Value = state.NewValue == Visibility.Visible; - if (state == Visibility.Visible) + if (state.NewValue == Visibility.Visible) { textbox.HoldFocus = false; if (1f - ChatHeight.Value < channel_selection_min_height) @@ -195,7 +195,7 @@ namespace osu.Game.Overlays { textbox.Current.Disabled = true; currentChannelContainer.Clear(false); - channelSelectionOverlay.State = Visibility.Visible; + channelSelectionOverlay.Show(); return; } @@ -253,7 +253,7 @@ namespace osu.Game.Overlays double targetChatHeight = startDragChatHeight - (e.MousePosition.Y - e.MouseDownPosition.Y) / Parent.DrawSize.Y; // If the channel selection screen is shown, mind its minimum height - if (channelSelectionOverlay.State == Visibility.Visible && targetChatHeight > 1f - channel_selection_min_height) + if (channelSelectionOverlay.State.Value == Visibility.Visible && targetChatHeight > 1f - channel_selection_min_height) targetChatHeight = 1f - channel_selection_min_height; ChatHeight.Value = targetChatHeight; @@ -325,7 +325,7 @@ namespace osu.Game.Overlays this.MoveToY(Height, transition_length, Easing.InSine); this.FadeOut(transition_length, Easing.InSine); - channelSelectionOverlay.State = Visibility.Hidden; + channelSelectionOverlay.Hide(); textbox.HoldFocus = false; base.PopOut(); diff --git a/osu.Game/Overlays/DialogOverlay.cs b/osu.Game/Overlays/DialogOverlay.cs index 2cc1c20a10..aaae7bcf5c 100644 --- a/osu.Game/Overlays/DialogOverlay.cs +++ b/osu.Game/Overlays/DialogOverlay.cs @@ -37,8 +37,8 @@ namespace osu.Game.Overlays dialogContainer.Add(currentDialog); currentDialog.Show(); - currentDialog.StateChanged += state => onDialogOnStateChanged(dialog, state); - State = Visibility.Visible; + currentDialog.State.ValueChanged += state => onDialogOnStateChanged(dialog, state.NewValue); + Show(); } protected override bool PlaySamplesOnStateChange => false; @@ -53,7 +53,7 @@ namespace osu.Game.Overlays dialog.Delay(PopupDialog.EXIT_DURATION).Expire(); if (dialog == currentDialog) - State = Visibility.Hidden; + Hide(); } protected override void PopIn() @@ -66,7 +66,7 @@ namespace osu.Game.Overlays { base.PopOut(); - if (currentDialog?.State == Visibility.Visible) + if (currentDialog?.State.Value == Visibility.Visible) { currentDialog.Hide(); return; diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 975bf4e3ca..7dcf76e41f 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -252,7 +252,7 @@ namespace osu.Game.Overlays if (!IsLoaded) return; - if (State == Visibility.Hidden) + if (State.Value == Visibility.Hidden) return; if (API == null) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index dec58f4c9e..8e5c9588ce 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -413,12 +413,12 @@ namespace osu.Game.Overlays.Mods { if (selectedMod != null) { - if (State == Visibility.Visible) sampleOn?.Play(); + if (State.Value == Visibility.Visible) sampleOn?.Play(); DeselectTypes(selectedMod.IncompatibleMods, true); } else { - if (State == Visibility.Visible) sampleOff?.Play(); + if (State.Value == Visibility.Visible) sampleOff?.Play(); } refreshSelectedMods(); diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 4431288a1a..ec3d708645 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -71,7 +71,7 @@ namespace osu.Game.Overlays.Music { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - ExitRequested = () => State = Visibility.Hidden, + ExitRequested = Hide, FilterChanged = search => list.Filter(search), Padding = new MarginPadding(10), }, diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index d7b915efe3..85524e992c 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -200,7 +200,7 @@ namespace osu.Game.Overlays beatmaps.ItemAdded += handleBeatmapAdded; beatmaps.ItemRemoved += handleBeatmapRemoved; - playlist.StateChanged += s => playlistButton.FadeColour(s == Visibility.Visible ? colours.Yellow : Color4.White, 200, Easing.OutQuint); + playlist.State.ValueChanged += s => playlistButton.FadeColour(s.NewValue == Visibility.Visible ? colours.Yellow : Color4.White, 200, Easing.OutQuint); } private ScheduledDelegate seekDelegate; @@ -449,7 +449,7 @@ namespace osu.Game.Overlays // This is here mostly as a performance fix. // If the playlist is not hidden it will update children even when the music controller is hidden (due to AlwaysPresent). - playlist.State = Visibility.Hidden; + playlist.Hide(); this.FadeOut(transition_length, Easing.OutQuint); dragContainer.ScaleTo(0.9f, transition_length, Easing.OutQuint); diff --git a/osu.Game/Overlays/NotificationOverlay.cs b/osu.Game/Overlays/NotificationOverlay.cs index 8f75d3ebf0..2e4c504645 100644 --- a/osu.Game/Overlays/NotificationOverlay.cs +++ b/osu.Game/Overlays/NotificationOverlay.cs @@ -81,13 +81,13 @@ namespace osu.Game.Overlays private void updateProcessingMode() { - bool enabled = OverlayActivationMode.Value == OverlayActivation.All || State == Visibility.Visible; + bool enabled = OverlayActivationMode.Value == OverlayActivation.All || State.Value == Visibility.Visible; notificationsEnabler?.Cancel(); if (enabled) // we want a slight delay before toggling notifications on to avoid the user becoming overwhelmed. - notificationsEnabler = Scheduler.AddDelayed(() => processingPosts = true, State == Visibility.Visible ? 0 : 1000); + notificationsEnabler = Scheduler.AddDelayed(() => processingPosts = true, State.Value == Visibility.Visible ? 0 : 1000); else processingPosts = false; } @@ -96,7 +96,7 @@ namespace osu.Game.Overlays { base.LoadComplete(); - StateChanged += _ => updateProcessingMode(); + State.ValueChanged += _ => updateProcessingMode(); OverlayActivationMode.BindValueChanged(_ => updateProcessingMode(), true); } @@ -128,7 +128,7 @@ namespace osu.Game.Overlays section?.Add(notification, notification.DisplayOnTop ? -runningDepth : runningDepth); if (notification.IsImportant) - State = Visibility.Visible; + Show(); updateCounts(); }); diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 2f56ace24d..36d6a22165 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -97,7 +97,7 @@ namespace osu.Game.Overlays.Settings.Sections.General { new LoadingAnimation { - State = Visibility.Visible, + State = { Value = Visibility.Visible }, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, diff --git a/osu.Game/Overlays/SettingsOverlay.cs b/osu.Game/Overlays/SettingsOverlay.cs index 6e3eaae0a1..bb84de5d3a 100644 --- a/osu.Game/Overlays/SettingsOverlay.cs +++ b/osu.Game/Overlays/SettingsOverlay.cs @@ -9,6 +9,7 @@ using osu.Game.Overlays.Settings.Sections; using osuTK.Graphics; using System.Collections.Generic; using System.Linq; +using osu.Framework.Bindables; namespace osu.Game.Overlays { @@ -37,23 +38,23 @@ namespace osu.Game.Overlays { } - public override bool AcceptsFocus => subPanels.All(s => s.State != Visibility.Visible); + public override bool AcceptsFocus => subPanels.All(s => s.State.Value != Visibility.Visible); private T createSubPanel(T subPanel) where T : SettingsSubPanel { subPanel.Depth = 1; subPanel.Anchor = Anchor.TopRight; - subPanel.StateChanged += subPanelStateChanged; + subPanel.State.ValueChanged += subPanelStateChanged; subPanels.Add(subPanel); return subPanel; } - private void subPanelStateChanged(Visibility visibility) + private void subPanelStateChanged(ValueChangedEvent state) { - switch (visibility) + switch (state.NewValue) { case Visibility.Visible: Background.FadeTo(0.9f, 300, Easing.OutQuint); @@ -73,7 +74,7 @@ namespace osu.Game.Overlays } } - protected override float ExpandedPosition => subPanels.Any(s => s.State == Visibility.Visible) ? -WIDTH : base.ExpandedPosition; + protected override float ExpandedPosition => subPanels.Any(s => s.State.Value == Visibility.Visible) ? -WIDTH : base.ExpandedPosition; [BackgroundDependencyLoader] private void load() diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index 3c8b96fe8a..982fb26b6b 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -84,10 +84,10 @@ namespace osu.Game.Overlays.Toolbar } }; - StateChanged += visibility => + State.ValueChanged += visibility => { if (overlayActivationMode.Value == OverlayActivation.Disabled) - State = Visibility.Hidden; + Hide(); }; if (osuGame != null) diff --git a/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs b/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs index b2ae273e31..b286cbfb1d 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.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 osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -15,6 +16,8 @@ namespace osu.Game.Overlays.Toolbar private OverlayContainer stateContainer; + private readonly Bindable overlayState = new Bindable(); + public OverlayContainer StateContainer { get => stateContainer; @@ -22,10 +25,12 @@ namespace osu.Game.Overlays.Toolbar { stateContainer = value; + overlayState.UnbindBindings(); + if (stateContainer != null) { Action = stateContainer.ToggleVisibility; - stateContainer.StateChanged += stateChanged; + overlayState.BindTo(stateContainer.State); } } } @@ -40,18 +45,13 @@ namespace osu.Game.Overlays.Toolbar Depth = 2, Alpha = 0, }); + + overlayState.ValueChanged += stateChanged; } - protected override void Dispose(bool isDisposing) + private void stateChanged(ValueChangedEvent state) { - base.Dispose(isDisposing); - if (stateContainer != null) - stateContainer.StateChanged -= stateChanged; - } - - private void stateChanged(Visibility state) - { - switch (state) + switch (state.NewValue) { case Visibility.Hidden: stateBackground.FadeOut(200); diff --git a/osu.Game/Overlays/VolumeOverlay.cs b/osu.Game/Overlays/VolumeOverlay.cs index 34b15d958d..02e0f59f26 100644 --- a/osu.Game/Overlays/VolumeOverlay.cs +++ b/osu.Game/Overlays/VolumeOverlay.cs @@ -100,14 +100,14 @@ namespace osu.Game.Overlays switch (action) { case GlobalAction.DecreaseVolume: - if (State == Visibility.Hidden) + if (State.Value == Visibility.Hidden) Show(); else volumeMeterMaster.Decrease(amount, isPrecise); return true; case GlobalAction.IncreaseVolume: - if (State == Visibility.Hidden) + if (State.Value == Visibility.Hidden) Show(); else volumeMeterMaster.Increase(amount, isPrecise); @@ -126,7 +126,7 @@ namespace osu.Game.Overlays public override void Show() { - if (State == Visibility.Visible) + if (State.Value == Visibility.Visible) schedulePopOut(); base.Show(); diff --git a/osu.Game/Rulesets/UI/GameplayCursorContainer.cs b/osu.Game/Rulesets/UI/GameplayCursorContainer.cs index 41edfa0b68..ae5f9c6111 100644 --- a/osu.Game/Rulesets/UI/GameplayCursorContainer.cs +++ b/osu.Game/Rulesets/UI/GameplayCursorContainer.cs @@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.UI protected override void Update() { base.Update(); - LastFrameState = State; + LastFrameState = State.Value; } } } diff --git a/osu.Game/Screens/Menu/ButtonArea.cs b/osu.Game/Screens/Menu/ButtonArea.cs index c7650a08fa..d59996a4eb 100644 --- a/osu.Game/Screens/Menu/ButtonArea.cs +++ b/osu.Game/Screens/Menu/ButtonArea.cs @@ -56,12 +56,12 @@ namespace osu.Game.Screens.Menu case ButtonSystemState.Exit: case ButtonSystemState.Initial: case ButtonSystemState.EnteringMode: - State = Visibility.Hidden; + Hide(); break; case ButtonSystemState.TopLevel: case ButtonSystemState.Play: - State = Visibility.Visible; + Show(); break; } @@ -82,6 +82,10 @@ namespace osu.Game.Screens.Menu } } + public override void Hide() => State = Visibility.Hidden; + + public override void Show() => State = Visibility.Visible; + public event Action StateChanged; private class ButtonAreaBackground : Box, IStateful diff --git a/osu.Game/Screens/Play/GameplayMenuOverlay.cs b/osu.Game/Screens/Play/GameplayMenuOverlay.cs index 456fb4faf9..c7e762714c 100644 --- a/osu.Game/Screens/Play/GameplayMenuOverlay.cs +++ b/osu.Game/Screens/Play/GameplayMenuOverlay.cs @@ -59,7 +59,7 @@ namespace osu.Game.Screens.Play { RelativeSizeAxes = Axes.Both; - StateChanged += s => selectionIndex = -1; + State.ValueChanged += s => selectionIndex = -1; } [BackgroundDependencyLoader] diff --git a/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs b/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs index e99f6d836e..b2c3952f38 100644 --- a/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs +++ b/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs @@ -46,7 +46,7 @@ namespace osu.Game.Screens.Play.HUD } }; - State = Visibility.Visible; + Show(); } protected override void PopIn() => this.FadeIn(fade_duration); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index d8389fa6d9..35ef7b3200 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -358,7 +358,7 @@ namespace osu.Game.Screens.Play // There is a chance that we could be in a paused state as the ruleset's internal clock (see FrameStabilityContainer) // could process an extra frame after the GameplayClock is stopped. // In such cases we want the fail state to precede a user triggered pause. - if (PauseOverlay.State == Visibility.Visible) + if (PauseOverlay.State.Value == Visibility.Visible) PauseOverlay.Hide(); failAnimation.Start(); diff --git a/osu.Game/Screens/Play/SkipOverlay.cs b/osu.Game/Screens/Play/SkipOverlay.cs index 4ecc15f22b..38dd179f25 100644 --- a/osu.Game/Screens/Play/SkipOverlay.cs +++ b/osu.Game/Screens/Play/SkipOverlay.cs @@ -46,7 +46,7 @@ namespace osu.Game.Screens.Play { this.startTime = startTime; - State = Visibility.Visible; + Show(); RelativePositionAxes = Axes.Both; RelativeSizeAxes = Axes.X; @@ -136,7 +136,7 @@ namespace osu.Game.Screens.Play protected override bool OnMouseMove(MouseMoveEvent e) { if (!e.HasAnyButtonPressed) - fadeContainer.State = Visibility.Visible; + fadeContainer.Show(); return base.OnMouseMove(e); } @@ -181,7 +181,7 @@ namespace osu.Game.Screens.Play if (!IsHovered && !IsDragged) using (BeginDelayedSequence(1000)) - scheduledHide = Schedule(() => State = Visibility.Hidden); + scheduledHide = Schedule(Hide); break; case Visibility.Hidden: @@ -196,7 +196,7 @@ namespace osu.Game.Screens.Play protected override void LoadComplete() { base.LoadComplete(); - State = Visibility.Visible; + Show(); } protected override bool OnMouseDown(MouseDownEvent e) @@ -207,9 +207,13 @@ namespace osu.Game.Screens.Play protected override bool OnMouseUp(MouseUpEvent e) { - State = Visibility.Visible; + Show(); return base.OnMouseUp(e); } + + public override void Hide() => State = Visibility.Hidden; + + public override void Show() => State = Visibility.Visible; } private class Button : OsuClickableContainer diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index d478454f00..6642efdf8b 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -106,7 +106,7 @@ namespace osu.Game.Screens.Play protected override void LoadComplete() { - State = Visibility.Visible; + Show(); replayLoaded.ValueChanged += loaded => AllowSeeking = loaded.NewValue; replayLoaded.TriggerChange(); diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index a78ab97960..378b1b1dc6 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -360,13 +360,13 @@ namespace osu.Game.Screens.Select protected override void PopIn() { this.FadeIn(transition_duration, Easing.OutQuint); - loading.State = Visibility.Visible; + loading.Show(); } protected override void PopOut() { this.FadeOut(transition_duration, Easing.OutQuint); - loading.State = Visibility.Hidden; + loading.Hide(); } } } diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index 1508de2730..fa9ffd0706 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -100,7 +100,7 @@ namespace osu.Game.Screens.Select { void removeOldInfo() { - State = beatmap == null ? Visibility.Hidden : Visibility.Visible; + State.Value = beatmap == null ? Visibility.Hidden : Visibility.Visible; Info?.FadeOut(250); Info?.Expire(); diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 6d5be607f4..5390d24892 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -278,7 +278,7 @@ namespace osu.Game.Screens.Select protected virtual void ExitFromBack() { - if (ModSelect.State == Visibility.Visible) + if (ModSelect.State.Value == Visibility.Visible) { ModSelect.Hide(); return; @@ -520,7 +520,7 @@ namespace osu.Game.Screens.Select if (base.OnExiting(next)) return true; - beatmapInfoWedge.State = Visibility.Hidden; + beatmapInfoWedge.Hide(); this.FadeOut(100); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index eeb1f2bee3..fb27caca11 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -15,10 +15,12 @@ - + + + diff --git a/osu.sln b/osu.sln index 3c38309d86..a106ab2800 100644 --- a/osu.sln +++ b/osu.sln @@ -25,6 +25,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Game.Rulesets.Taiko.Tes EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Game.Rulesets.Osu.Tests", "osu.Game.Rulesets.Osu.Tests\osu.Game.Rulesets.Osu.Tests.csproj", "{DECCCC75-67AD-4C3D-BB84-FD0E01323511}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Framework", "..\osu-framework\osu.Framework\osu.Framework.csproj", "{C7D2DA3C-97BF-403C-9F75-115C8A64DAC1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu.Framework.NativeLibs", "..\osu-framework\osu.Framework.NativeLibs\osu.Framework.NativeLibs.csproj", "{35AD7F4C-81DC-4060-BFD1-C376DC4C4801}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -79,6 +83,14 @@ Global {DECCCC75-67AD-4C3D-BB84-FD0E01323511}.Debug|Any CPU.Build.0 = Debug|Any CPU {DECCCC75-67AD-4C3D-BB84-FD0E01323511}.Release|Any CPU.ActiveCfg = Release|Any CPU {DECCCC75-67AD-4C3D-BB84-FD0E01323511}.Release|Any CPU.Build.0 = Release|Any CPU + {C7D2DA3C-97BF-403C-9F75-115C8A64DAC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C7D2DA3C-97BF-403C-9F75-115C8A64DAC1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C7D2DA3C-97BF-403C-9F75-115C8A64DAC1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C7D2DA3C-97BF-403C-9F75-115C8A64DAC1}.Release|Any CPU.Build.0 = Release|Any CPU + {35AD7F4C-81DC-4060-BFD1-C376DC4C4801}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {35AD7F4C-81DC-4060-BFD1-C376DC4C4801}.Debug|Any CPU.Build.0 = Debug|Any CPU + {35AD7F4C-81DC-4060-BFD1-C376DC4C4801}.Release|Any CPU.ActiveCfg = Release|Any CPU + {35AD7F4C-81DC-4060-BFD1-C376DC4C4801}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 8de62b608e76e268fea5d03551c0ba6a9fc10949 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 11 Jun 2019 15:22:27 +0900 Subject: [PATCH 349/375] Allow FullscreenOverlay to surface to front on subsequent Show requests --- osu.Game/Overlays/FullscreenOverlay.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/osu.Game/Overlays/FullscreenOverlay.cs b/osu.Game/Overlays/FullscreenOverlay.cs index 9706f75087..0911ee84de 100644 --- a/osu.Game/Overlays/FullscreenOverlay.cs +++ b/osu.Game/Overlays/FullscreenOverlay.cs @@ -4,6 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Effects; using osu.Game.Graphics; using osu.Game.Graphics.Containers; @@ -40,6 +41,19 @@ namespace osu.Game.Overlays }; } + public override void Show() + { + if (State.Value == Visibility.Visible) + { + // re-trigger the state changed so we can potentially surface to front + State.TriggerChange(); + } + else + { + base.Show(); + } + } + protected override void PopIn() { base.PopIn(); From 620c2311ac887eebf82c8c31583661bfe0aba517 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 11 Jun 2019 15:39:12 +0900 Subject: [PATCH 350/375] Add test --- .../Online/TestSceneFullscreenOverlay.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneFullscreenOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneFullscreenOverlay.cs index 6dc3428bff..fe8437be17 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneFullscreenOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneFullscreenOverlay.cs @@ -18,8 +18,24 @@ namespace osu.Game.Tests.Visual.Online { base.LoadComplete(); + int fireCount = 0; + Add(overlay = new TestFullscreenOverlay()); - AddStep(@"toggle", overlay.ToggleVisibility); + + overlay.State.ValueChanged += _ => fireCount++; + + AddStep(@"show", overlay.Show); + + AddAssert("fire count 1", () => fireCount == 1); + + AddStep(@"show again", overlay.Show); + + // this logic is specific to FullscreenOverlay + AddAssert("fire count 2", () => fireCount == 2); + + AddStep(@"hide", overlay.Hide); + + AddAssert("fire count 3", () => fireCount == 3); } private class TestFullscreenOverlay : FullscreenOverlay From 975bb3db8a2aba107858543eb12b419f363cad44 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Tue, 11 Jun 2019 15:51:14 +0900 Subject: [PATCH 351/375] cleanup --- .idea/.idea.osu/.idea/.name | 1 - osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 .idea/.idea.osu/.idea/.name diff --git a/.idea/.idea.osu/.idea/.name b/.idea/.idea.osu/.idea/.name deleted file mode 100644 index 21cb4db60e..0000000000 --- a/.idea/.idea.osu/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -osu \ No newline at end of file diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index fa73a14252..198da2c5b1 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -222,7 +222,7 @@ namespace osu.Game.Tests.Visual.SongSelect { beatmapChangedCount = 0; debounceCount = 0; - songSelect.Carousel.SelectionChanged += _ => beatmapChangedCount += 1; + songSelect.Carousel.SelectionChanged += _ => beatmapChangedCount++; }); AddRepeatStep($"Create beatmaps {test_count} times", () => { From a53ade07a5ea39046b5b90d240435664010021a3 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Tue, 11 Jun 2019 15:51:57 +0900 Subject: [PATCH 352/375] remove unused using --- osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index 198da2c5b1..2664c7a42c 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -11,7 +11,6 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Bindables; using osu.Framework.Extensions; -using osu.Framework.Logging; using osu.Framework.MathUtils; using osu.Framework.Platform; using osu.Framework.Screens; From 07e17518e93cc81d64e9215a9b1465a0e8859be4 Mon Sep 17 00:00:00 2001 From: Arphox Date: Tue, 11 Jun 2019 10:28:16 +0200 Subject: [PATCH 353/375] Fix all "Maintainability" CodeFactor issues --- osu.Game.Rulesets.Catch/UI/CatcherArea.cs | 4 ++-- osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs | 2 +- osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs | 4 ++-- osu.Game.Tests/Visual/UserInterface/TestSceneCursors.cs | 2 +- osu.Game/Graphics/Containers/HoldToConfirmContainer.cs | 2 +- osu.Game/Online/API/APIAccess.cs | 2 +- osu.Game/Online/Chat/MessageFormatter.cs | 2 +- osu.Game/Overlays/ChatOverlay.cs | 2 +- osu.Game/Rulesets/Edit/SelectionBlueprint.cs | 2 +- osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs | 2 +- osu.Game/Scoring/Legacy/LegacyScoreParser.cs | 8 ++++---- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs index e7c7fd77df..90052d9b11 100644 --- a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs +++ b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs @@ -379,8 +379,8 @@ namespace osu.Game.Rulesets.Catch.UI X = (float)MathHelper.Clamp(X + direction * Clock.ElapsedFrameTime * speed, 0, 1); // Correct overshooting. - if (hyperDashDirection > 0 && hyperDashTargetPosition < X || - hyperDashDirection < 0 && hyperDashTargetPosition > X) + if ((hyperDashDirection > 0 && hyperDashTargetPosition < X) || + (hyperDashDirection < 0 && hyperDashTargetPosition > X)) { X = hyperDashTargetPosition; SetHyperDashState(); diff --git a/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs b/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs index b2beda18f4..7bb1f42802 100644 --- a/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs +++ b/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs @@ -69,7 +69,7 @@ namespace osu.Game.Rulesets.Osu.Beatmaps break; if (Vector2Extensions.Distance(stackBaseObject.Position, objectN.Position) < stack_distance - || stackBaseObject is Slider && Vector2Extensions.Distance(stackBaseObject.EndPosition, objectN.Position) < stack_distance) + || (stackBaseObject is Slider && Vector2Extensions.Distance(stackBaseObject.EndPosition, objectN.Position) < stack_distance)) { stackBaseIndex = n; diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs b/osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs index ec23570f54..bc5d02258f 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs @@ -37,11 +37,11 @@ namespace osu.Game.Rulesets.Osu.Mods if (time < osuHit.HitObject.StartTime - relax_leniency) continue; - if (osuHit.HitObject is IHasEndTime hasEnd && time > hasEnd.EndTime || osuHit.IsHit) + if ((osuHit.HitObject is IHasEndTime hasEnd && time > hasEnd.EndTime) || osuHit.IsHit) continue; requiresHit |= osuHit is DrawableHitCircle && osuHit.IsHovered && osuHit.HitObject.HitWindows.CanBeHit(relativetime); - requiresHold |= osuHit is DrawableSlider slider && (slider.Ball.IsHovered || osuHit.IsHovered) || osuHit is DrawableSpinner; + requiresHold |= (osuHit is DrawableSlider slider && (slider.Ball.IsHovered || osuHit.IsHovered)) || osuHit is DrawableSpinner; } if (requiresHit) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneCursors.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneCursors.cs index 8fe31b7ad6..f59cb75a46 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneCursors.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneCursors.cs @@ -192,7 +192,7 @@ namespace osu.Game.Tests.Visual.UserInterface public CursorContainer Cursor { get; } public bool ProvidingUserCursor { get; } - public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => base.ReceivePositionalInputAt(screenSpacePos) || SmoothTransition && !ProvidingUserCursor; + public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => base.ReceivePositionalInputAt(screenSpacePos) || (SmoothTransition && !ProvidingUserCursor); private readonly Box background; diff --git a/osu.Game/Graphics/Containers/HoldToConfirmContainer.cs b/osu.Game/Graphics/Containers/HoldToConfirmContainer.cs index a5b5b7af42..cda5e150de 100644 --- a/osu.Game/Graphics/Containers/HoldToConfirmContainer.cs +++ b/osu.Game/Graphics/Containers/HoldToConfirmContainer.cs @@ -27,7 +27,7 @@ namespace osu.Game.Graphics.Containers protected void BeginConfirm() { - if (confirming || !AllowMultipleFires && fired) return; + if (confirming || (!AllowMultipleFires && fired)) return; confirming = true; diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index 594bc1e3ca..343d6a67b7 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -37,7 +37,7 @@ namespace osu.Game.Online.API public Bindable LocalUser { get; } = new Bindable(createGuestUser()); - protected bool HasLogin => authentication.Token.Value != null || !string.IsNullOrEmpty(ProvidedUsername) && !string.IsNullOrEmpty(password); + protected bool HasLogin => authentication.Token.Value != null || (!string.IsNullOrEmpty(ProvidedUsername) && !string.IsNullOrEmpty(password)); private readonly CancellationTokenSource cancellationToken = new CancellationTokenSource(); diff --git a/osu.Game/Online/Chat/MessageFormatter.cs b/osu.Game/Online/Chat/MessageFormatter.cs index e1fc65da6c..4aaffdd161 100644 --- a/osu.Game/Online/Chat/MessageFormatter.cs +++ b/osu.Game/Online/Chat/MessageFormatter.cs @@ -69,7 +69,7 @@ namespace osu.Game.Online.Chat if (displayText.Length == 0 || linkText.Length == 0) continue; // Check for encapsulated links - if (result.Links.Find(l => l.Index <= index && l.Index + l.Length >= index + m.Length || index <= l.Index && index + m.Length >= l.Index + l.Length) == null) + if (result.Links.Find(l => (l.Index <= index && l.Index + l.Length >= index + m.Length) || (index <= l.Index && index + m.Length >= l.Index + l.Length)) == null) { result.Text = result.Text.Remove(index, m.Length).Insert(index, displayText); diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index eb95fabe02..978848d9fc 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -56,7 +56,7 @@ namespace osu.Game.Overlays private readonly Container channelSelectionContainer; private readonly ChannelSelectionOverlay channelSelectionOverlay; - public override bool Contains(Vector2 screenSpacePos) => chatContainer.ReceivePositionalInputAt(screenSpacePos) || channelSelectionOverlay.State == Visibility.Visible && channelSelectionOverlay.ReceivePositionalInputAt(screenSpacePos); + public override bool Contains(Vector2 screenSpacePos) => chatContainer.ReceivePositionalInputAt(screenSpacePos) || (channelSelectionOverlay.State == Visibility.Visible && channelSelectionOverlay.ReceivePositionalInputAt(screenSpacePos)); public ChatOverlay() { diff --git a/osu.Game/Rulesets/Edit/SelectionBlueprint.cs b/osu.Game/Rulesets/Edit/SelectionBlueprint.cs index e94604554c..0f77b8d584 100644 --- a/osu.Game/Rulesets/Edit/SelectionBlueprint.cs +++ b/osu.Game/Rulesets/Edit/SelectionBlueprint.cs @@ -45,7 +45,7 @@ namespace osu.Game.Rulesets.Edit /// public readonly DrawableHitObject HitObject; - protected override bool ShouldBeAlive => HitObject.IsAlive && HitObject.IsPresent || State == SelectionState.Selected; + protected override bool ShouldBeAlive => (HitObject.IsAlive && HitObject.IsPresent) || State == SelectionState.Selected; public override bool HandlePositionalInput => ShouldBeAlive; public override bool RemoveWhenNotAlive => false; diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index e91100608b..ec7e6dc303 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -85,7 +85,7 @@ namespace osu.Game.Rulesets.Objects.Drawables public override bool RemoveCompletedTransforms => false; protected override bool RequiresChildrenUpdate => true; - public override bool IsPresent => base.IsPresent || State.Value == ArmedState.Idle && Clock?.CurrentTime >= LifetimeStart; + public override bool IsPresent => base.IsPresent || (State.Value == ArmedState.Idle && Clock?.CurrentTime >= LifetimeStart); public readonly Bindable State = new Bindable(); diff --git a/osu.Game/Scoring/Legacy/LegacyScoreParser.cs b/osu.Game/Scoring/Legacy/LegacyScoreParser.cs index d2c9ce81c3..0fdbd56c92 100644 --- a/osu.Game/Scoring/Legacy/LegacyScoreParser.cs +++ b/osu.Game/Scoring/Legacy/LegacyScoreParser.cs @@ -136,9 +136,9 @@ namespace osu.Game.Scoring.Legacy score.Rank = score.Mods.Any(m => m is ModHidden || m is ModFlashlight) ? ScoreRank.XH : ScoreRank.X; else if (ratio300 > 0.9 && ratio50 <= 0.01 && countMiss == 0) score.Rank = score.Mods.Any(m => m is ModHidden || m is ModFlashlight) ? ScoreRank.SH : ScoreRank.S; - else if (ratio300 > 0.8 && countMiss == 0 || ratio300 > 0.9) + else if ((ratio300 > 0.8 && countMiss == 0) || ratio300 > 0.9) score.Rank = ScoreRank.A; - else if (ratio300 > 0.7 && countMiss == 0 || ratio300 > 0.8) + else if ((ratio300 > 0.7 && countMiss == 0) || ratio300 > 0.8) score.Rank = ScoreRank.B; else if (ratio300 > 0.6) score.Rank = ScoreRank.C; @@ -159,9 +159,9 @@ namespace osu.Game.Scoring.Legacy score.Rank = score.Mods.Any(m => m is ModHidden || m is ModFlashlight) ? ScoreRank.XH : ScoreRank.X; else if (ratio300 > 0.9 && ratio50 <= 0.01 && countMiss == 0) score.Rank = score.Mods.Any(m => m is ModHidden || m is ModFlashlight) ? ScoreRank.SH : ScoreRank.S; - else if (ratio300 > 0.8 && countMiss == 0 || ratio300 > 0.9) + else if ((ratio300 > 0.8 && countMiss == 0) || ratio300 > 0.9) score.Rank = ScoreRank.A; - else if (ratio300 > 0.7 && countMiss == 0 || ratio300 > 0.8) + else if ((ratio300 > 0.7 && countMiss == 0) || ratio300 > 0.8) score.Rank = ScoreRank.B; else if (ratio300 > 0.6) score.Rank = ScoreRank.C; From e5417416a23a0ef743a53589ee42e5362f0f6937 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 11 Jun 2019 18:24:50 +0900 Subject: [PATCH 354/375] Remove braces --- osu.Game/Graphics/UserInterface/OsuCheckbox.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs index 5d41075725..5ead5987a1 100644 --- a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs +++ b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs @@ -81,7 +81,7 @@ namespace osu.Game.Graphics.UserInterface Nub.Current.BindTo(Current); - Current.DisabledChanged += disabled => { labelText.Alpha = Nub.Alpha = disabled ? 0.3f : 1; }; + Current.DisabledChanged += disabled => labelText.Alpha = Nub.Alpha = disabled ? 0.3f : 1; } protected override void LoadComplete() From 261badc770330dd1e086bb30880bb73f6bb90bb9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 11 Jun 2019 19:24:54 +0900 Subject: [PATCH 355/375] Update framework --- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index eeb1f2bee3..140d0c7f0e 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -15,7 +15,7 @@ - + diff --git a/osu.iOS.props b/osu.iOS.props index 3a5090d968..39be738a5c 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -105,8 +105,8 @@ - - + + From 6a34d5575bd69b28393ab7dfb8f00448d03553ed Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 11 Jun 2019 20:44:11 +0900 Subject: [PATCH 356/375] Bump framework version --- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 140d0c7f0e..75a464d0b8 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -15,7 +15,7 @@ - + diff --git a/osu.iOS.props b/osu.iOS.props index 39be738a5c..2c25498b89 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -105,8 +105,8 @@ - - + + From 27054a744ed316fd623b33f4a8cfeeec9c787dc8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Jun 2019 00:35:13 +0900 Subject: [PATCH 357/375] Fill in thread pool names --- osu.Game/Beatmaps/BeatmapManager.cs | 2 +- osu.Game/Database/ArchiveModelManager.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 47411c69ec..67d3382e01 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -426,7 +426,7 @@ namespace osu.Game.Beatmaps private const int update_queue_request_concurrency = 4; - private readonly ThreadedTaskScheduler updateScheduler = new ThreadedTaskScheduler(update_queue_request_concurrency); + private readonly ThreadedTaskScheduler updateScheduler = new ThreadedTaskScheduler(update_queue_request_concurrency, nameof(BeatmapUpdateQueue)); public BeatmapUpdateQueue(IAPIProvider api) { diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 844ae622a5..d764601b32 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -644,6 +644,6 @@ namespace osu.Game.Database /// This scheduler generally performs IO and CPU intensive work so concurrency is limited harshly. /// It is mainly being used as a queue mechanism for large imports. /// - protected static readonly ThreadedTaskScheduler IMPORT_SCHEDULER = new ThreadedTaskScheduler(import_queue_request_concurrency); + protected static readonly ThreadedTaskScheduler IMPORT_SCHEDULER = new ThreadedTaskScheduler(import_queue_request_concurrency, nameof(ArchiveModelManager)); } } From 6c74998487166c9723e191a33c74f97dfe36164a Mon Sep 17 00:00:00 2001 From: Lucas A Date: Tue, 11 Jun 2019 19:24:36 +0200 Subject: [PATCH 358/375] Set ScreenActivity to InitialScreenActivity only when ScreenActivity hasn't been set manually before. --- osu.Game/Screens/OsuScreen.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 3b5e0fd0d6..582f97d46a 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -56,9 +56,13 @@ namespace osu.Game.Screens /// /// The to set the user's activity automatically to when this screen is entered + /// This will be automatically set to for this screen on entering unless + /// is manually set before. /// protected virtual UserActivity InitialScreenActivity => null; + private UserActivity screenActivity; + /// /// The for this screen. /// @@ -74,8 +78,6 @@ namespace osu.Game.Screens } } - private UserActivity screenActivity; - /// /// Whether to disallow changes to game-wise Beatmap/Ruleset bindables for this screen (and all children). /// @@ -170,7 +172,8 @@ namespace osu.Game.Screens backgroundStack?.Push(localBackground = CreateBackground()); - ScreenActivity = InitialScreenActivity; + if (screenActivity == null) + ScreenActivity = InitialScreenActivity; base.OnEntering(last); } From 15893bbb754fa73003f578a385b9cb7fa98a3b7d Mon Sep 17 00:00:00 2001 From: Lucas A Date: Tue, 11 Jun 2019 19:41:48 +0200 Subject: [PATCH 359/375] Drop UserActivity prefix for subclasses nested in UserActivity + Change status messages. --- .../Visual/Online/TestSceneUserPanel.cs | 10 ++++---- osu.Game/Screens/Edit/Editor.cs | 2 +- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Select/PlaySongSelect.cs | 2 +- osu.Game/Users/UserActivity.cs | 24 +++++++++---------- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs b/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs index 2c20ea98a3..18541e7637 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs @@ -61,11 +61,11 @@ namespace osu.Game.Tests.Visual.Online public void UserActivitiesTests() { AddStep("idle", () => { flyte.Activity.Value = null; }); - AddStep("spectating", () => { flyte.Activity.Value = new UserActivity.UserActivitySpectating(); }); - AddStep("solo", () => { flyte.Activity.Value = new UserActivity.UserActivitySoloGame(null, null); }); - AddStep("choosing", () => { flyte.Activity.Value = new UserActivity.UserActivityChoosingBeatmap(); }); - AddStep("editing", () => { flyte.Activity.Value = new UserActivity.UserActivityEditing(null); }); - AddStep("modding", () => { flyte.Activity.Value = new UserActivity.UserActivityModding(); }); + AddStep("spectating", () => { flyte.Activity.Value = new UserActivity.Spectating(); }); + AddStep("solo", () => { flyte.Activity.Value = new UserActivity.SoloGame(null, null); }); + AddStep("choosing", () => { flyte.Activity.Value = new UserActivity.ChoosingBeatmap(); }); + AddStep("editing", () => { flyte.Activity.Value = new UserActivity.Editing(null); }); + AddStep("modding", () => { flyte.Activity.Value = new UserActivity.Modding(); }); } } } diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index a4cb659183..c6e1850af1 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -48,7 +48,7 @@ namespace osu.Game.Screens.Edit private DependencyContainer dependencies; private GameHost host; - protected override UserActivity InitialScreenActivity => new UserActivity.UserActivityEditing(Beatmap.Value.BeatmapInfo); + protected override UserActivity InitialScreenActivity => new UserActivity.Editing(Beatmap.Value.BeatmapInfo); protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 22a0e65f91..e8fa99b397 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -35,7 +35,7 @@ namespace osu.Game.Screens.Play { protected override bool AllowBackButton => false; // handled by HoldForMenuButton - protected override UserActivity InitialScreenActivity => new UserActivity.UserActivitySoloGame(Beatmap.Value.BeatmapInfo, Ruleset.Value); + protected override UserActivity InitialScreenActivity => new UserActivity.SoloGame(Beatmap.Value.BeatmapInfo, Ruleset.Value); public override float BackgroundParallaxAmount => 0.1f; diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index aba3343d69..f81bad6693 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -19,7 +19,7 @@ namespace osu.Game.Screens.Select public override bool AllowExternalScreenChange => true; - protected override UserActivity InitialScreenActivity => new UserActivity.UserActivityChoosingBeatmap(); + protected override UserActivity InitialScreenActivity => new UserActivity.ChoosingBeatmap(); [BackgroundDependencyLoader] private void load(OsuColour colours) diff --git a/osu.Game/Users/UserActivity.cs b/osu.Game/Users/UserActivity.cs index fe72f116ee..b088e8036d 100644 --- a/osu.Game/Users/UserActivity.cs +++ b/osu.Game/Users/UserActivity.cs @@ -12,25 +12,25 @@ namespace osu.Game.Users public abstract string Status { get; } public virtual Color4 GetAppropriateColour(OsuColour colours) => colours.GreenDarker; - public class UserActivityModding : UserActivity + public class Modding : UserActivity { public override string Status => "Modding a map"; public override Color4 GetAppropriateColour(OsuColour colours) => colours.PurpleDark; } - public class UserActivityChoosingBeatmap : UserActivity + public class ChoosingBeatmap : UserActivity { public override string Status => "Choosing a beatmap"; } - public class UserActivityMultiplayerGame : UserActivity + public class MultiplayerGame : UserActivity { - public override string Status => "Multiplaying"; + public override string Status => "Playing with others"; } - public class UserActivityEditing : UserActivity + public class Editing : UserActivity { - public UserActivityEditing(BeatmapInfo info) + public Editing(BeatmapInfo info) { Beatmap = info; } @@ -40,29 +40,29 @@ namespace osu.Game.Users public BeatmapInfo Beatmap { get; } } - public class UserActivitySoloGame : UserActivity + public class SoloGame : UserActivity { - public UserActivitySoloGame(BeatmapInfo info, Rulesets.RulesetInfo ruleset) + public SoloGame(BeatmapInfo info, Rulesets.RulesetInfo ruleset) { Beatmap = info; Ruleset = ruleset; } - public override string Status => @"Solo Game"; + public override string Status => @"Playing alone"; public BeatmapInfo Beatmap { get; } public Rulesets.RulesetInfo Ruleset { get; } } - public class UserActivitySpectating : UserActivity + public class Spectating : UserActivity { public override string Status => @"Spectating a game"; } - public class UserActivityInLobby : UserActivity + public class InLobby : UserActivity { - public override string Status => @"in Multiplayer Lobby"; + public override string Status => @"In a Multiplayer Lobby"; } } } From 51d428ef949f68e02803339fa2c32cfc4888495b Mon Sep 17 00:00:00 2001 From: Lucas A Date: Tue, 11 Jun 2019 20:00:14 +0200 Subject: [PATCH 360/375] Refactor UserPanel status display logic --- osu.Game/Users/UserPanel.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index 1f31ead1e7..04f5a0a3fb 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -231,17 +231,18 @@ namespace osu.Game.Users statusBar.ResizeHeightTo(status_height, transition_duration, Easing.OutQuint); statusBar.FadeIn(transition_duration, Easing.OutQuint); this.ResizeHeightTo(height, transition_duration, Easing.OutQuint); - - if (status is UserStatusOnline && activity != null) - { - statusMessage.Text = activity.Status; - statusBg.FadeColour(activity.GetAppropriateColour(colours), 500, Easing.OutQuint); - return; - } } - statusMessage.Text = status?.Message; - statusBg.FadeColour(status?.GetAppropriateColour(colours) ?? colours.Gray5, 500, Easing.OutQuint); + if (status is UserStatusOnline && activity != null) + { + statusMessage.Text = activity.Status; + statusBg.FadeColour(activity.GetAppropriateColour(colours), 500, Easing.OutQuint); + } + else + { + statusMessage.Text = status?.Message; + statusBg.FadeColour(status?.GetAppropriateColour(colours) ?? colours.Gray5, 500, Easing.OutQuint); + } } public MenuItem[] ContextMenuItems => new MenuItem[] From 94e65a324456172971e1b387f039ec1fd7343c0d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Jun 2019 15:16:59 +0900 Subject: [PATCH 361/375] Fix settings checkboxes not being searchable --- osu.Game/Overlays/Settings/SettingsCheckbox.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/SettingsCheckbox.cs b/osu.Game/Overlays/Settings/SettingsCheckbox.cs index a1501d8015..a554159fd7 100644 --- a/osu.Game/Overlays/Settings/SettingsCheckbox.cs +++ b/osu.Game/Overlays/Settings/SettingsCheckbox.cs @@ -10,11 +10,14 @@ namespace osu.Game.Overlays.Settings { private OsuCheckbox checkbox; + private string labelText; + protected override Drawable CreateControl() => checkbox = new OsuCheckbox(); public override string LabelText { - set => checkbox.LabelText = value; + get => labelText; + set => checkbox.LabelText = labelText = value; } } } From fc1f778b82edc316d7c0d01eb8526ff247ea97c1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Jun 2019 15:53:53 +0900 Subject: [PATCH 362/375] Remove implicit null --- osu.Game/Screens/OsuScreen.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 582f97d46a..874ac35e39 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -123,8 +123,6 @@ namespace osu.Game.Screens { Anchor = Anchor.Centre; Origin = Anchor.Centre; - - screenActivity = null; } [BackgroundDependencyLoader(true)] From bb8a77d27d7a671f4a5c1b065d3cf1d2e7a3618e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Jun 2019 15:59:52 +0900 Subject: [PATCH 363/375] Apply all steps to same user panel so interactions can be observed --- .../Visual/Online/TestSceneUserPanel.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs b/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs index 18541e7637..30814ad9c7 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs @@ -12,11 +12,12 @@ namespace osu.Game.Tests.Visual.Online [TestFixture] public class TestSceneUserPanel : OsuTestScene { - private readonly UserPanel flyte; private readonly UserPanel peppy; public TestSceneUserPanel() { + UserPanel flyte; + Add(new FillFlowContainer { Anchor = Anchor.Centre, @@ -60,12 +61,12 @@ namespace osu.Game.Tests.Visual.Online [Test] public void UserActivitiesTests() { - AddStep("idle", () => { flyte.Activity.Value = null; }); - AddStep("spectating", () => { flyte.Activity.Value = new UserActivity.Spectating(); }); - AddStep("solo", () => { flyte.Activity.Value = new UserActivity.SoloGame(null, null); }); - AddStep("choosing", () => { flyte.Activity.Value = new UserActivity.ChoosingBeatmap(); }); - AddStep("editing", () => { flyte.Activity.Value = new UserActivity.Editing(null); }); - AddStep("modding", () => { flyte.Activity.Value = new UserActivity.Modding(); }); + AddStep("idle", () => { peppy.Activity.Value = null; }); + AddStep("spectating", () => { peppy.Activity.Value = new UserActivity.Spectating(); }); + AddStep("solo", () => { peppy.Activity.Value = new UserActivity.SoloGame(null, null); }); + AddStep("choosing", () => { peppy.Activity.Value = new UserActivity.ChoosingBeatmap(); }); + AddStep("editing", () => { peppy.Activity.Value = new UserActivity.Editing(null); }); + AddStep("modding", () => { peppy.Activity.Value = new UserActivity.Modding(); }); } } } From 13234fb4a4b5e9a26a3480c3ac3c960fd7f56c60 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 12 Jun 2019 16:07:35 +0900 Subject: [PATCH 364/375] Adjust comments a bit --- osu.Game/Screens/Select/BeatmapCarousel.cs | 2 +- osu.Game/Screens/Select/SongSelect.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 6e3bec106f..cf21c78c7f 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -155,7 +155,7 @@ namespace osu.Game.Screens.Select int? previouslySelectedID = null; CarouselBeatmapSet existingSet = beatmapSets.FirstOrDefault(b => b.BeatmapSet.ID == beatmapSet.ID); - // Since we're about to remove the selected beatmap, store its ID so we can go back if needed. + // If the selected beatmap is about to be removed, store its ID so it can be re-selected if required if (existingSet?.State?.Value == CarouselItemState.Selected) previouslySelectedID = selectedBeatmap?.Beatmap.ID; diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index dcfe1de8f2..d0645dbab6 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -594,7 +594,7 @@ namespace osu.Game.Screens.Select { bindBindables(); - // As a selection was already obtained, do not attempt to update the selected beatmap. + // If a selection was already obtained, do not attempt to update the selected beatmap. if (Carousel.SelectedBeatmapSet != null) return; From 20b43c20c8f35147f5517f0e50e9730ed20fe9ae Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Jun 2019 16:33:15 +0900 Subject: [PATCH 365/375] Rename variables to remove redundant "screen" terminology --- osu.Game/Screens/Edit/Editor.cs | 2 +- osu.Game/Screens/OsuScreen.cs | 33 +++++++++++------------ osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Play/PlayerLoader.cs | 2 +- osu.Game/Screens/Select/PlaySongSelect.cs | 2 +- osu.Game/Users/UserActivity.cs | 12 ++++----- 6 files changed, 26 insertions(+), 27 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index c6e1850af1..de0f3870c6 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -48,7 +48,7 @@ namespace osu.Game.Screens.Edit private DependencyContainer dependencies; private GameHost host; - protected override UserActivity InitialScreenActivity => new UserActivity.Editing(Beatmap.Value.BeatmapInfo); + protected override UserActivity InitialActivity => new UserActivity.Editing(Beatmap.Value.BeatmapInfo); protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 874ac35e39..fe53ad17c3 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -56,25 +56,25 @@ namespace osu.Game.Screens /// /// The to set the user's activity automatically to when this screen is entered - /// This will be automatically set to for this screen on entering unless - /// is manually set before. + /// This will be automatically set to for this screen on entering unless + /// is manually set before. /// - protected virtual UserActivity InitialScreenActivity => null; + protected virtual UserActivity InitialActivity => null; - private UserActivity screenActivity; + private UserActivity activity; /// - /// The for this screen. + /// The current for this screen. /// - protected UserActivity ScreenActivity + protected UserActivity Activity { - get => screenActivity; + get => activity; set { - if (value == screenActivity) return; + if (value == activity) return; - screenActivity = value; - setUserActivity(screenActivity); + activity = value; + updateActivity(); } } @@ -152,7 +152,7 @@ namespace osu.Game.Screens sampleExit?.Play(); applyArrivingDefaults(true); - setUserActivity(screenActivity); + updateActivity(); base.OnResuming(last); } @@ -170,8 +170,8 @@ namespace osu.Game.Screens backgroundStack?.Push(localBackground = CreateBackground()); - if (screenActivity == null) - ScreenActivity = InitialScreenActivity; + if (activity == null) + Activity = InitialActivity; base.OnEntering(last); } @@ -190,11 +190,10 @@ namespace osu.Game.Screens return false; } - private void setUserActivity(UserActivity activity) + private void updateActivity() { - if (api == null) return; - - api.LocalUser.Value.Activity.Value = activity; + if (api != null) + api.LocalUser.Value.Activity.Value = activity; } /// diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index a545d77184..a25b8a1de7 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -35,7 +35,7 @@ namespace osu.Game.Screens.Play { protected override bool AllowBackButton => false; // handled by HoldForMenuButton - protected override UserActivity InitialScreenActivity => new UserActivity.SoloGame(Beatmap.Value.BeatmapInfo, Ruleset.Value); + protected override UserActivity InitialActivity => new UserActivity.SoloGame(Beatmap.Value.BeatmapInfo, Ruleset.Value); public override float BackgroundParallaxAmount => 0.1f; diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 33d100c871..9de9f5cec8 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -43,7 +43,7 @@ namespace osu.Game.Screens.Play private bool hideOverlays; public override bool HideOverlaysOnEnter => hideOverlays; - protected override UserActivity InitialScreenActivity => null; //shows the previous screen status + protected override UserActivity InitialActivity => null; //shows the previous screen status public override bool DisallowExternalBeatmapRulesetChanges => true; diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index f81bad6693..4df6e6a3f3 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -19,7 +19,7 @@ namespace osu.Game.Screens.Select public override bool AllowExternalScreenChange => true; - protected override UserActivity InitialScreenActivity => new UserActivity.ChoosingBeatmap(); + protected override UserActivity InitialActivity => new UserActivity.ChoosingBeatmap(); [BackgroundDependencyLoader] private void load(OsuColour colours) diff --git a/osu.Game/Users/UserActivity.cs b/osu.Game/Users/UserActivity.cs index b088e8036d..918c547978 100644 --- a/osu.Game/Users/UserActivity.cs +++ b/osu.Game/Users/UserActivity.cs @@ -30,18 +30,22 @@ namespace osu.Game.Users public class Editing : UserActivity { + public BeatmapInfo Beatmap { get; } + public Editing(BeatmapInfo info) { Beatmap = info; } public override string Status => @"Editing a beatmap"; - - public BeatmapInfo Beatmap { get; } } public class SoloGame : UserActivity { + public BeatmapInfo Beatmap { get; } + + public Rulesets.RulesetInfo Ruleset { get; } + public SoloGame(BeatmapInfo info, Rulesets.RulesetInfo ruleset) { Beatmap = info; @@ -49,10 +53,6 @@ namespace osu.Game.Users } public override string Status => @"Playing alone"; - - public BeatmapInfo Beatmap { get; } - - public Rulesets.RulesetInfo Ruleset { get; } } public class Spectating : UserActivity From c4f54d94bc5e8aa9d52b7e17c0dd3508693cc6bc Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 12 Jun 2019 17:00:27 +0900 Subject: [PATCH 366/375] Rename methods --- osu.Game/Beatmaps/BeatmapManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 67d3382e01..5204bda353 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -110,7 +110,7 @@ namespace osu.Game.Beatmaps validateOnlineIds(beatmapSet); - await updateQueue.Perform(beatmapSet, cancellationToken); + await updateQueue.UpdateAsync(beatmapSet, cancellationToken); } protected override void PreImport(BeatmapSetInfo beatmapSet) @@ -433,20 +433,20 @@ namespace osu.Game.Beatmaps this.api = api; } - public async Task Perform(BeatmapSetInfo beatmapSet, CancellationToken cancellationToken) + public async Task UpdateAsync(BeatmapSetInfo beatmapSet, CancellationToken cancellationToken) { if (api?.State != APIState.Online) return; LogForModel(beatmapSet, "Performing online lookups..."); - await Task.WhenAll(beatmapSet.Beatmaps.Select(b => Perform(beatmapSet, b, cancellationToken)).ToArray()); + await Task.WhenAll(beatmapSet.Beatmaps.Select(b => UpdateAsync(beatmapSet, b, cancellationToken)).ToArray()); } // todo: expose this when we need to do individual difficulty lookups. - protected Task Perform(BeatmapSetInfo beatmapSet, BeatmapInfo beatmap, CancellationToken cancellationToken) - => Task.Factory.StartNew(() => perform(beatmapSet, beatmap), cancellationToken, TaskCreationOptions.HideScheduler, updateScheduler); + protected Task UpdateAsync(BeatmapSetInfo beatmapSet, BeatmapInfo beatmap, CancellationToken cancellationToken) + => Task.Factory.StartNew(() => update(beatmapSet, beatmap), cancellationToken, TaskCreationOptions.HideScheduler, updateScheduler); - private void perform(BeatmapSetInfo set, BeatmapInfo beatmap) + private void update(BeatmapSetInfo set, BeatmapInfo beatmap) { if (api?.State != APIState.Online) return; From fd7dc9504e6c91b9502c5e389d28677be49b81d5 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 12 Jun 2019 17:08:50 +0900 Subject: [PATCH 367/375] Remove async when not required --- osu.Game/Beatmaps/BeatmapManager.cs | 10 +++++----- osu.Game/Database/ArchiveModelManager.cs | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 5204bda353..d90657bff5 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -94,7 +94,7 @@ namespace osu.Game.Beatmaps updateQueue = new BeatmapUpdateQueue(api); } - protected override async Task Populate(BeatmapSetInfo beatmapSet, ArchiveReader archive, CancellationToken cancellationToken = default) + protected override Task Populate(BeatmapSetInfo beatmapSet, ArchiveReader archive, CancellationToken cancellationToken = default) { if (archive != null) beatmapSet.Beatmaps = createBeatmapDifficulties(archive); @@ -110,7 +110,7 @@ namespace osu.Game.Beatmaps validateOnlineIds(beatmapSet); - await updateQueue.UpdateAsync(beatmapSet, cancellationToken); + return updateQueue.UpdateAsync(beatmapSet, cancellationToken); } protected override void PreImport(BeatmapSetInfo beatmapSet) @@ -433,13 +433,13 @@ namespace osu.Game.Beatmaps this.api = api; } - public async Task UpdateAsync(BeatmapSetInfo beatmapSet, CancellationToken cancellationToken) + public Task UpdateAsync(BeatmapSetInfo beatmapSet, CancellationToken cancellationToken) { if (api?.State != APIState.Online) - return; + return Task.CompletedTask; LogForModel(beatmapSet, "Performing online lookups..."); - await Task.WhenAll(beatmapSet.Beatmaps.Select(b => UpdateAsync(beatmapSet, b, cancellationToken)).ToArray()); + return Task.WhenAll(beatmapSet.Beatmaps.Select(b => UpdateAsync(beatmapSet, b, cancellationToken)).ToArray()); } // todo: expose this when we need to do individual difficulty lookups. diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index d764601b32..0cf7816250 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; @@ -132,13 +132,13 @@ namespace osu.Game.Database /// This will post notifications tracking progress. /// /// One or more archive locations on disk. - public async Task Import(params string[] paths) + public Task Import(params string[] paths) { var notification = new ProgressNotification { State = ProgressNotificationState.Active }; PostNotification?.Invoke(notification); - await Import(notification, paths); + return Import(notification, paths); } protected async Task Import(ProgressNotification notification, params string[] paths) @@ -243,7 +243,7 @@ namespace osu.Game.Database /// /// The archive to be imported. /// An optional cancellation token. - public async Task Import(ArchiveReader archive, CancellationToken cancellationToken = default) + public Task Import(ArchiveReader archive, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); @@ -267,7 +267,7 @@ namespace osu.Game.Database return null; } - return await Import(model, archive, cancellationToken); + return Import(model, archive, cancellationToken); } /// @@ -548,24 +548,24 @@ namespace osu.Game.Database /// /// This is a temporary method and will likely be replaced by a full-fledged (and more correctly placed) migration process in the future. /// - public async Task ImportFromStableAsync() + public Task ImportFromStableAsync() { var stable = GetStableStorage?.Invoke(); if (stable == null) { Logger.Log("No osu!stable installation available!", LoggingTarget.Information, LogLevel.Error); - return; + return Task.CompletedTask; } if (!stable.ExistsDirectory(ImportFromStablePath)) { // This handles situations like when the user does not have a Skins folder Logger.Log($"No {ImportFromStablePath} folder available in osu!stable installation", LoggingTarget.Information, LogLevel.Error); - return; + return Task.CompletedTask; } - await Task.Run(async () => await Import(stable.GetDirectories(ImportFromStablePath).Select(f => stable.GetFullPath(f)).ToArray())); + return Task.Run(async () => await Import(stable.GetDirectories(ImportFromStablePath).Select(f => stable.GetFullPath(f)).ToArray())); } #endregion From 2a67944889c302fe69a87838f70d835c63b50740 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 12 Jun 2019 17:10:55 +0900 Subject: [PATCH 368/375] Remove interlocked within a lock --- osu.Game/Database/ArchiveModelManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 0cf7816250..1c17adf7b7 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -161,8 +161,8 @@ namespace osu.Game.Database lock (imported) { imported.Add(model); + current++; - Interlocked.Increment(ref current); notification.Text = $"Imported {current} of {paths.Length} {humanisedModelName}s"; notification.Progress = (float)current / paths.Length; } From d4deac48ee78e025f14bace79fc2388923a4eef9 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 12 Jun 2019 17:27:15 +0900 Subject: [PATCH 369/375] Improve model deletion notification text --- osu.Game/Database/ArchiveModelManager.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 54dbae9ddc..b5a9c70e47 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -392,7 +392,8 @@ namespace osu.Game.Database var notification = new ProgressNotification { Progress = 0, - CompletionText = $"Deleted all {typeof(TModel).Name.Replace("Info", "").ToLower()}s!", + Text = $"Preparing to delete all {humanisedModelName}s...", + CompletionText = $"Deleted all {humanisedModelName}s!", State = ProgressNotificationState.Active, }; @@ -409,7 +410,7 @@ namespace osu.Game.Database // user requested abort return; - notification.Text = $"Deleting ({++i} of {items.Count})"; + notification.Text = $"Deleting {humanisedModelName}s ({++i} of {items.Count})"; Delete(b); From f358fce9abe950fa0f60e69bea2776196ef64ccc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Jun 2019 18:04:57 +0900 Subject: [PATCH 370/375] Move activity (writable) bindable to APIAccess so it correctly transfers between users --- .../Visual/Online/TestSceneUserPanel.cs | 17 +++++++++++------ osu.Game/Online/API/APIAccess.cs | 8 ++++++++ osu.Game/Online/API/DummyAPIAccess.cs | 11 +++++++++++ osu.Game/Online/API/IAPIProvider.cs | 5 +++++ .../Settings/Sections/General/LoginSettings.cs | 6 ++---- osu.Game/Screens/OsuScreen.cs | 2 +- osu.Game/Users/User.cs | 2 +- osu.Game/Users/UserPanel.cs | 2 +- 8 files changed, 40 insertions(+), 13 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs b/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs index 30814ad9c7..54f06d6ad2 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using NUnit.Framework; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Users; @@ -61,12 +62,16 @@ namespace osu.Game.Tests.Visual.Online [Test] public void UserActivitiesTests() { - AddStep("idle", () => { peppy.Activity.Value = null; }); - AddStep("spectating", () => { peppy.Activity.Value = new UserActivity.Spectating(); }); - AddStep("solo", () => { peppy.Activity.Value = new UserActivity.SoloGame(null, null); }); - AddStep("choosing", () => { peppy.Activity.Value = new UserActivity.ChoosingBeatmap(); }); - AddStep("editing", () => { peppy.Activity.Value = new UserActivity.Editing(null); }); - AddStep("modding", () => { peppy.Activity.Value = new UserActivity.Modding(); }); + Bindable activity = new Bindable(); + + peppy.Activity.BindTo(activity); + + AddStep("idle", () => { activity.Value = null; }); + AddStep("spectating", () => { activity.Value = new UserActivity.Spectating(); }); + AddStep("solo", () => { activity.Value = new UserActivity.SoloGame(null, null); }); + AddStep("choosing", () => { activity.Value = new UserActivity.ChoosingBeatmap(); }); + AddStep("editing", () => { activity.Value = new UserActivity.Editing(null); }); + AddStep("modding", () => { activity.Value = new UserActivity.Modding(); }); } } } diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index 343d6a67b7..12b38fab1e 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -37,6 +37,8 @@ namespace osu.Game.Online.API public Bindable LocalUser { get; } = new Bindable(createGuestUser()); + public Bindable Activity { get; } = new Bindable(); + protected bool HasLogin => authentication.Token.Value != null || (!string.IsNullOrEmpty(ProvidedUsername) && !string.IsNullOrEmpty(password)); private readonly CancellationTokenSource cancellationToken = new CancellationTokenSource(); @@ -55,6 +57,12 @@ namespace osu.Game.Online.API authentication.TokenString = config.Get(OsuSetting.Token); authentication.Token.ValueChanged += onTokenChanged; + LocalUser.BindValueChanged(u => + { + u.OldValue?.Activity.UnbindFrom(Activity); + u.NewValue.Activity.BindTo(Activity); + }, true); + var thread = new Thread(run) { Name = "APIAccess", diff --git a/osu.Game/Online/API/DummyAPIAccess.cs b/osu.Game/Online/API/DummyAPIAccess.cs index 99fde10309..6c04c77dc0 100644 --- a/osu.Game/Online/API/DummyAPIAccess.cs +++ b/osu.Game/Online/API/DummyAPIAccess.cs @@ -17,6 +17,8 @@ namespace osu.Game.Online.API Id = 1001, }); + public Bindable Activity { get; } = new Bindable(); + public bool IsLoggedIn => true; public string ProvidedUsername => LocalUser.Value.Username; @@ -41,6 +43,15 @@ namespace osu.Game.Online.API } } + public DummyAPIAccess() + { + LocalUser.BindValueChanged(u => + { + u.OldValue?.Activity.UnbindFrom(Activity); + u.NewValue.Activity.BindTo(Activity); + }, true); + } + public virtual void Queue(APIRequest request) { } diff --git a/osu.Game/Online/API/IAPIProvider.cs b/osu.Game/Online/API/IAPIProvider.cs index 7c1f850943..0cd41aee26 100644 --- a/osu.Game/Online/API/IAPIProvider.cs +++ b/osu.Game/Online/API/IAPIProvider.cs @@ -13,6 +13,11 @@ namespace osu.Game.Online.API /// Bindable LocalUser { get; } + /// + /// The current user's activity. + /// + Bindable Activity { get; } + /// /// Returns whether the local user is logged in. /// diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 223c2aaf13..1454b6592d 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -156,7 +156,7 @@ namespace osu.Game.Overlays.Settings.Sections.General panel.Status.BindTo(api.LocalUser.Value.Status); panel.Activity.BindTo(api.LocalUser.Value.Activity); - dropdown.Current.ValueChanged += action => + dropdown.Current.BindValueChanged(action => { switch (action.NewValue) { @@ -179,9 +179,7 @@ namespace osu.Game.Overlays.Settings.Sections.General api.Logout(); break; } - }; - dropdown.Current.TriggerChange(); - + }, true); break; } diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index fe53ad17c3..e2aeb41de1 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -193,7 +193,7 @@ namespace osu.Game.Screens private void updateActivity() { if (api != null) - api.LocalUser.Value.Activity.Value = activity; + api.Activity.Value = activity; } /// diff --git a/osu.Game/Users/User.cs b/osu.Game/Users/User.cs index cf67af7bb8..c3ecd62e10 100644 --- a/osu.Game/Users/User.cs +++ b/osu.Game/Users/User.cs @@ -25,7 +25,7 @@ namespace osu.Game.Users public Bindable Status = new Bindable(); - public Bindable Activity = new Bindable(); + public IBindable Activity = new Bindable(); //public Team Team; diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index 04f5a0a3fb..833c62013b 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -42,7 +42,7 @@ namespace osu.Game.Users public readonly Bindable Status = new Bindable(); - public readonly Bindable Activity = new Bindable(); + public readonly IBindable Activity = new Bindable(); public new Action Action; From 0f000fcc1402fababafc3df53eacffff17b918e8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Jun 2019 19:58:26 +0900 Subject: [PATCH 371/375] Fix abysmal load performance when showing the social overlay --- osu.Game/Users/UserCoverBackground.cs | 52 +++++++++++++++++---------- osu.Game/Users/UserPanel.cs | 11 +++--- 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/osu.Game/Users/UserCoverBackground.cs b/osu.Game/Users/UserCoverBackground.cs index dbc132995a..e583acac9f 100644 --- a/osu.Game/Users/UserCoverBackground.cs +++ b/osu.Game/Users/UserCoverBackground.cs @@ -21,31 +21,45 @@ namespace osu.Game.Users set => Model = value; } - [Resolved] - private LargeTextureStore textures { get; set; } + protected override Drawable CreateDrawable(User user) => new Cover(user); - protected override Drawable CreateDrawable(User user) + private class Cover : CompositeDrawable { - if (user == null) + private readonly User user; + + public Cover(User user) { - return new Box - { - RelativeSizeAxes = Axes.Both, - Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.1f), Color4.Black.Opacity(0.75f)) - }; + this.user = user; + + RelativeSizeAxes = Axes.Both; } - else + + [BackgroundDependencyLoader] + private void load(LargeTextureStore textures) { - var sprite = new Sprite + if (user == null) { - RelativeSizeAxes = Axes.Both, - Texture = textures.Get(user.CoverUrl), - FillMode = FillMode.Fill, - Anchor = Anchor.Centre, - Origin = Anchor.Centre - }; - sprite.OnLoadComplete += d => d.FadeInFromZero(400); - return sprite; + InternalChild = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.1f), Color4.Black.Opacity(0.75f)) + }; + } + else + InternalChild = new Sprite + { + RelativeSizeAxes = Axes.Both, + Texture = textures.Get(user.CoverUrl), + FillMode = FillMode.Fill, + Anchor = Anchor.Centre, + Origin = Anchor.Centre + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + this.FadeInFromZero(400); } } } diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index 47571b673d..3f6fce98f7 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -61,8 +61,6 @@ namespace osu.Game.Users FillFlowContainer infoContainer; - UserCoverBackground coverBackground; - AddInternal(content = new Container { RelativeSizeAxes = Axes.Both, @@ -77,13 +75,16 @@ namespace osu.Game.Users Children = new Drawable[] { - new DelayedLoadWrapper(coverBackground = new UserCoverBackground + new DelayedLoadUnloadWrapper(() => new UserCoverBackground { RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, User = user, - }, 300) { RelativeSizeAxes = Axes.Both }, + }, 300, 5000) + { + RelativeSizeAxes = Axes.Both, + }, new Box { RelativeSizeAxes = Axes.Both, @@ -184,8 +185,6 @@ namespace osu.Game.Users } }); - coverBackground.OnLoadComplete += d => d.FadeInFromZero(400, Easing.Out); - if (user.IsSupporter) { infoContainer.Add(new SupporterIcon From a17d480f51b099ed88994bce1ebf5e613c0a6881 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 12 Jun 2019 20:41:02 +0900 Subject: [PATCH 372/375] Use "beatmap" as the model name --- osu.Game/Beatmaps/BeatmapManager.cs | 2 ++ osu.Game/Database/ArchiveModelManager.cs | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index d90657bff5..3734c8d05c 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -327,6 +327,8 @@ namespace osu.Game.Beatmaps /// Results from the provided query. public IQueryable QueryBeatmaps(Expression> query) => beatmaps.Beatmaps.AsNoTracking().Where(query); + protected override string HumanisedModelName => "beatmap"; + protected override BeatmapSetInfo CreateModel(ArchiveReader reader) { // let's make sure there are actually .osu files to import. diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 20919f0899..1c8e722589 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -163,7 +163,7 @@ namespace osu.Game.Database imported.Add(model); current++; - notification.Text = $"Imported {current} of {paths.Length} {humanisedModelName}s"; + notification.Text = $"Imported {current} of {paths.Length} {HumanisedModelName}s"; notification.Progress = (float)current / paths.Length; } } @@ -186,7 +186,7 @@ namespace osu.Game.Database { notification.CompletionText = imported.Count == 1 ? $"Imported {imported.First()}!" - : $"Imported {current} {humanisedModelName}s!"; + : $"Imported {current} {HumanisedModelName}s!"; if (imported.Count > 0 && PresentImport != null) { @@ -344,7 +344,7 @@ namespace osu.Game.Database if (CanUndelete(existing, item)) { Undelete(existing); - LogForModel(item, $"Found existing {humanisedModelName} for {item} (ID {existing.ID}) – skipping import."); + LogForModel(item, $"Found existing {HumanisedModelName} for {item} (ID {existing.ID}) – skipping import."); handleEvent(() => ItemAdded?.Invoke(existing, true)); // existing item will be used; rollback new import and exit early. @@ -424,8 +424,8 @@ namespace osu.Game.Database var notification = new ProgressNotification { Progress = 0, - Text = $"Preparing to delete all {humanisedModelName}s...", - CompletionText = $"Deleted all {humanisedModelName}s!", + Text = $"Preparing to delete all {HumanisedModelName}s...", + CompletionText = $"Deleted all {HumanisedModelName}s!", State = ProgressNotificationState.Active, }; @@ -442,7 +442,7 @@ namespace osu.Game.Database // user requested abort return; - notification.Text = $"Deleting {humanisedModelName}s ({++i} of {items.Count})"; + notification.Text = $"Deleting {HumanisedModelName}s ({++i} of {items.Count})"; Delete(b); @@ -614,7 +614,7 @@ namespace osu.Game.Database private DbSet queryModel() => ContextFactory.Get().Set(); - private string humanisedModelName => $"{typeof(TModel).Name.Replace("Info", "").ToLower()}"; + protected virtual string HumanisedModelName => $"{typeof(TModel).Name.Replace("Info", "").ToLower()}"; /// /// Creates an from a valid storage path. From 03c98ff57b7f8dcb1da9e96ed476ba6196031ad5 Mon Sep 17 00:00:00 2001 From: Ludde <48018938+yousef157@users.noreply.github.com> Date: Wed, 12 Jun 2019 15:55:06 +0400 Subject: [PATCH 373/375] Update TestFlight --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 04f133fd56..9c63d31e15 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ If you are not interested in developing the game, you can consume our [binary re | ------------- | ------------- | - **Linux** users are recommended to self-compile until we have official deployment in place. -- **iOS** users can join the [TestFlight beta program](https://t.co/xQJmHkfC18) (note that due to high demand this is regularly full). +- **iOS** users can join the [TestFlight beta program](https://t.co/PasE1zrHhw) (new link added, please only install if you use it on a regular daily basis). - **Android** users can self-compile, and expect a public beta soon. If your platform is not listed above, there is still a chance you can manually build it by following the instructions below. From d868280b2dab9a2acd16065ad9d4044bd987ece0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 12 Jun 2019 23:51:01 +0900 Subject: [PATCH 374/375] Update outdated game resources in iOS project --- osu.iOS.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.iOS.props b/osu.iOS.props index 2c25498b89..5e151f916b 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -104,7 +104,7 @@ - + From 50999c36771a620f2a76d8327e54feea4ffe001e Mon Sep 17 00:00:00 2001 From: Ludde <48018938+yousef157@users.noreply.github.com> Date: Wed, 12 Jun 2019 18:53:39 +0400 Subject: [PATCH 375/375] revert change in paranthesses --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9c63d31e15..0df99f7d6b 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ If you are not interested in developing the game, you can consume our [binary re | ------------- | ------------- | - **Linux** users are recommended to self-compile until we have official deployment in place. -- **iOS** users can join the [TestFlight beta program](https://t.co/PasE1zrHhw) (new link added, please only install if you use it on a regular daily basis). +- **iOS** users can join the [TestFlight beta program](https://t.co/PasE1zrHhw) (note that due to high demand this is regularly full). - **Android** users can self-compile, and expect a public beta soon. If your platform is not listed above, there is still a chance you can manually build it by following the instructions below.