mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 13:37:25 +08:00
Expose TabControlOverlayHeader.Current value
This commit is contained in:
parent
9c16fdca97
commit
fe078c244d
@ -14,7 +14,7 @@ namespace osu.Game.Overlays.Changelog
|
||||
{
|
||||
public class ChangelogHeader : BreadcrumbControlOverlayHeader
|
||||
{
|
||||
public readonly Bindable<APIChangelogBuild> Current = new Bindable<APIChangelogBuild>();
|
||||
public readonly Bindable<APIChangelogBuild> Build = new Bindable<APIChangelogBuild>();
|
||||
|
||||
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
|
||||
|
@ -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 =>
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Overlays.News
|
||||
|
||||
private NewsHeaderTitle title;
|
||||
|
||||
public readonly Bindable<string> Current = new Bindable<string>(null);
|
||||
public readonly Bindable<string> Post = new Bindable<string>(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<string> 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;
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ namespace osu.Game.Overlays
|
||||
},
|
||||
};
|
||||
|
||||
header.Current.BindTo(Current);
|
||||
header.Post.BindTo(Current);
|
||||
Current.TriggerChange();
|
||||
}
|
||||
|
||||
|
@ -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 <see cref="OsuTabControl{T}"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of item to be represented by tabs.</typeparam>
|
||||
public abstract class TabControlOverlayHeader<T> : OverlayHeader
|
||||
public abstract class TabControlOverlayHeader<T> : OverlayHeader, IHasCurrentValue<T>
|
||||
{
|
||||
protected OsuTabControl<T> TabControl;
|
||||
|
||||
private readonly BindableWithCurrent<T> current = new BindableWithCurrent<T>();
|
||||
|
||||
public Bindable<T> 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;
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user