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