diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 4165a180da..8663ec586b 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -14,7 +14,7 @@ namespace osu.Game.Overlays.Changelog { public class ChangelogHeader : BreadcrumbControlOverlayHeader { - public readonly Bindable Current = new Bindable(); + public readonly Bindable Build = new Bindable(); public Action ListingSelected; @@ -25,18 +25,18 @@ namespace osu.Game.Overlays.Changelog public ChangelogHeader() { TabControl.AddItem(listing_string); - TabControl.Current.ValueChanged += e => + Current.ValueChanged += e => { if (e.NewValue == listing_string) ListingSelected?.Invoke(); }; - Current.ValueChanged += showBuild; + Build.ValueChanged += showBuild; Streams.Current.ValueChanged += e => { - if (e.NewValue?.LatestBuild != null && !e.NewValue.Equals(Current.Value?.UpdateStream)) - Current.Value = e.NewValue.LatestBuild; + if (e.NewValue?.LatestBuild != null && !e.NewValue.Equals(Build.Value?.UpdateStream)) + Build.Value = e.NewValue.LatestBuild; }; } @@ -50,7 +50,7 @@ namespace osu.Game.Overlays.Changelog if (e.NewValue != null) { TabControl.AddItem(e.NewValue.ToString()); - TabControl.Current.Value = e.NewValue.ToString(); + Current.Value = e.NewValue.ToString(); updateCurrentStream(); @@ -58,7 +58,7 @@ namespace osu.Game.Overlays.Changelog } else { - TabControl.Current.Value = listing_string; + Current.Value = listing_string; Streams.Current.Value = null; title.Version = null; } @@ -86,10 +86,10 @@ namespace osu.Game.Overlays.Changelog private void updateCurrentStream() { - if (Current.Value == null) + if (Build.Value == null) return; - Streams.Current.Value = Streams.Items.FirstOrDefault(s => s.Name == Current.Value.UpdateStream.Name); + Streams.Current.Value = Streams.Items.FirstOrDefault(s => s.Name == Build.Value.UpdateStream.Name); } private class ChangelogHeaderTitle : ScreenTitle diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 90ba206077..6a8cb29d3e 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -78,7 +78,7 @@ namespace osu.Game.Overlays sampleBack = audio.Samples.Get(@"UI/generic-select-soft"); - Header.Current.BindTo(Current); + Header.Build.BindTo(Current); Current.BindValueChanged(e => { diff --git a/osu.Game/Overlays/News/NewsHeader.cs b/osu.Game/Overlays/News/NewsHeader.cs index b525ba7a82..b55e3ffba0 100644 --- a/osu.Game/Overlays/News/NewsHeader.cs +++ b/osu.Game/Overlays/News/NewsHeader.cs @@ -14,7 +14,7 @@ namespace osu.Game.Overlays.News private NewsHeaderTitle title; - public readonly Bindable Current = new Bindable(null); + public readonly Bindable Post = new Bindable(null); public Action ShowFrontPage; @@ -22,13 +22,13 @@ namespace osu.Game.Overlays.News { TabControl.AddItem(front_page_string); - TabControl.Current.ValueChanged += e => + Current.ValueChanged += e => { if (e.NewValue == front_page_string) ShowFrontPage?.Invoke(); }; - Current.ValueChanged += showPost; + Post.ValueChanged += showPost; } private void showPost(ValueChangedEvent e) @@ -39,13 +39,13 @@ namespace osu.Game.Overlays.News if (e.NewValue != null) { TabControl.AddItem(e.NewValue); - TabControl.Current.Value = e.NewValue; + Current.Value = e.NewValue; title.IsReadingPost = true; } else { - TabControl.Current.Value = front_page_string; + Current.Value = front_page_string; title.IsReadingPost = false; } } diff --git a/osu.Game/Overlays/NewsOverlay.cs b/osu.Game/Overlays/NewsOverlay.cs index 6dde300556..71c205ff63 100644 --- a/osu.Game/Overlays/NewsOverlay.cs +++ b/osu.Game/Overlays/NewsOverlay.cs @@ -60,7 +60,7 @@ namespace osu.Game.Overlays }, }; - header.Current.BindTo(Current); + header.Post.BindTo(Current); Current.TriggerChange(); } diff --git a/osu.Game/Overlays/TabControlOverlayHeader.cs b/osu.Game/Overlays/TabControlOverlayHeader.cs index b410739b25..dff5a17bd8 100644 --- a/osu.Game/Overlays/TabControlOverlayHeader.cs +++ b/osu.Game/Overlays/TabControlOverlayHeader.cs @@ -3,6 +3,7 @@ using JetBrains.Annotations; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -17,10 +18,18 @@ namespace osu.Game.Overlays /// An overlay header which contains a . /// /// The type of item to be represented by tabs. - public abstract class TabControlOverlayHeader : OverlayHeader + public abstract class TabControlOverlayHeader : OverlayHeader, IHasCurrentValue { protected OsuTabControl TabControl; + private readonly BindableWithCurrent current = new BindableWithCurrent(); + + public Bindable Current + { + get => current.Current; + set => current.Current = value; + } + private readonly Box controlBackground; protected TabControlOverlayHeader() @@ -35,7 +44,11 @@ namespace osu.Game.Overlays { RelativeSizeAxes = Axes.Both, }, - TabControl = CreateTabControl().With(control => control.Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN }) + TabControl = CreateTabControl().With(control => + { + control.Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN }; + control.Current = current; + }) } }); }