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);