From 6683d4cabeac6446c1b402129716f2ece6bafe8c Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Sun, 22 Jul 2018 20:14:58 +0200 Subject: [PATCH] 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