From be977e25414cbd443f51f079347528d64b83de2d Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Mon, 16 Jul 2018 23:50:22 +0200 Subject: [PATCH 001/178] 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/178] 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/178] Header3 --- .../Visual/TestCaseTextBadgePair.cs | 16 +- .../Overlays/Changelog/ChangelogHeader.cs | 197 +++++++++--------- .../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, 129 insertions(+), 141 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, - Size = new Vector2(7), - Colour = OsuColour.FromHex(@"bf04ff"), - Icon = FontAwesome.fa_chevron_right, - Margin = new MarginPadding() - { - Top = 8, - Left = 5, - Right = 5, - Bottom = 15, - }, + 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, + }, } } }; @@ -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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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/178] 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 34f54aa94599f9e07ba7ee7391eea2a65d9d5c40 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 13 May 2019 00:36:05 +0900 Subject: [PATCH 104/178] 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 31b72f168d4851a59b64afb640be3e5e112fc639 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 13 May 2019 00:46:22 +0900 Subject: [PATCH 105/178] 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 219c590b8ab11b1a3fd4c2b81c9aedb8657ff121 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 13 May 2019 16:24:32 +0900 Subject: [PATCH 106/178] 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 107/178] 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 108/178] 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 109/178] 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 110/178] 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 111/178] 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 112/178] 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 113/178] 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 114/178] 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 115/178] 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 116/178] 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 117/178] 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 118/178] 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 119/178] 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 120/178] 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 121/178] 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 122/178] 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 123/178] 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 124/178] 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 125/178] 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 126/178] 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 127/178] 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 128/178] 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 129/178] 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 130/178] 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 131/178] 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 132/178] 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 133/178] 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 134/178] 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 135/178] 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 136/178] 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 137/178] 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 138/178] 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 139/178] 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 140/178] 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 141/178] 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 142/178] 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 143/178] 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 144/178] 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 145/178] 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 146/178] 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 147/178] 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 148/178] 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 149/178] 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 150/178] 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 151/178] 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 152/178] 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 153/178] 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 154/178] 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 155/178] 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 555822a68da554b9f3e63e4436f6b6e3d8189ab7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 22 May 2019 13:28:41 +0900 Subject: [PATCH 156/178] 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 157/178] 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 158/178] 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 159/178] 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 160/178] 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 161/178] 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 162/178] 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 163/178] 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 164/178] 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 165/178] 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 166/178] 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 167/178] 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 168/178] 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 169/178] 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 170/178] 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 171/178] 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 172/178] 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 f780c80c17d406f7c6518066930072de27083727 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 31 May 2019 13:03:35 +0900 Subject: [PATCH 173/178] 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 174/178] 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 175/178] 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 176/178] 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 177/178] 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 178/178] 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; }