mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 01:43:20 +08:00
Basic implementation of new RankingsOverlayHeader
This commit is contained in:
parent
9c16fdca97
commit
b284170437
@ -3,8 +3,9 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.Rankings;
|
using osu.Game.Overlays.Rankings;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
@ -15,24 +16,21 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
typeof(DismissableFlag),
|
typeof(RankingsOverlayHeader),
|
||||||
typeof(HeaderTitle),
|
|
||||||
typeof(RankingsRulesetSelector),
|
|
||||||
typeof(RankingsScopeSelector),
|
|
||||||
typeof(RankingsHeader),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[Cached]
|
||||||
|
private readonly OverlayColourProvider overlayColour = new OverlayColourProvider(OverlayColourScheme.Green);
|
||||||
|
|
||||||
public TestSceneRankingsHeader()
|
public TestSceneRankingsHeader()
|
||||||
{
|
{
|
||||||
var countryBindable = new Bindable<Country>();
|
var countryBindable = new Bindable<Country>();
|
||||||
var ruleset = new Bindable<RulesetInfo>();
|
var ruleset = new Bindable<RulesetInfo>();
|
||||||
var scope = new Bindable<RankingsScope>();
|
var scope = new Bindable<RankingsScope>();
|
||||||
|
|
||||||
Add(new RankingsHeader
|
Add(new RankingsOverlayHeader
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Current = { BindTarget = scope },
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Scope = { BindTarget = scope },
|
|
||||||
Country = { BindTarget = countryBindable },
|
Country = { BindTarget = countryBindable },
|
||||||
Ruleset = { BindTarget = ruleset },
|
Ruleset = { BindTarget = ruleset },
|
||||||
Spotlights = new[]
|
Spotlights = new[]
|
||||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
{
|
{
|
||||||
public class ChangelogHeader : BreadcrumbControlOverlayHeader
|
public class ChangelogHeader : BreadcrumbControlOverlayHeader
|
||||||
{
|
{
|
||||||
public readonly Bindable<APIChangelogBuild> Current = new Bindable<APIChangelogBuild>();
|
public readonly Bindable<APIChangelogBuild> Build = new Bindable<APIChangelogBuild>();
|
||||||
|
|
||||||
public Action ListingSelected;
|
public Action ListingSelected;
|
||||||
|
|
||||||
@ -25,18 +25,18 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
public ChangelogHeader()
|
public ChangelogHeader()
|
||||||
{
|
{
|
||||||
TabControl.AddItem(listing_string);
|
TabControl.AddItem(listing_string);
|
||||||
TabControl.Current.ValueChanged += e =>
|
Current.ValueChanged += e =>
|
||||||
{
|
{
|
||||||
if (e.NewValue == listing_string)
|
if (e.NewValue == listing_string)
|
||||||
ListingSelected?.Invoke();
|
ListingSelected?.Invoke();
|
||||||
};
|
};
|
||||||
|
|
||||||
Current.ValueChanged += showBuild;
|
Build.ValueChanged += showBuild;
|
||||||
|
|
||||||
Streams.Current.ValueChanged += e =>
|
Streams.Current.ValueChanged += e =>
|
||||||
{
|
{
|
||||||
if (e.NewValue?.LatestBuild != null && !e.NewValue.Equals(Current.Value?.UpdateStream))
|
if (e.NewValue?.LatestBuild != null && !e.NewValue.Equals(Build.Value?.UpdateStream))
|
||||||
Current.Value = e.NewValue.LatestBuild;
|
Build.Value = e.NewValue.LatestBuild;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
if (e.NewValue != null)
|
if (e.NewValue != null)
|
||||||
{
|
{
|
||||||
TabControl.AddItem(e.NewValue.ToString());
|
TabControl.AddItem(e.NewValue.ToString());
|
||||||
TabControl.Current.Value = e.NewValue.ToString();
|
Current.Value = e.NewValue.ToString();
|
||||||
|
|
||||||
updateCurrentStream();
|
updateCurrentStream();
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TabControl.Current.Value = listing_string;
|
Current.Value = listing_string;
|
||||||
Streams.Current.Value = null;
|
Streams.Current.Value = null;
|
||||||
title.Version = null;
|
title.Version = null;
|
||||||
}
|
}
|
||||||
@ -86,10 +86,10 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
|
|
||||||
private void updateCurrentStream()
|
private void updateCurrentStream()
|
||||||
{
|
{
|
||||||
if (Current.Value == null)
|
if (Build.Value == null)
|
||||||
return;
|
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
|
private class ChangelogHeaderTitle : ScreenTitle
|
||||||
|
@ -78,7 +78,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
sampleBack = audio.Samples.Get(@"UI/generic-select-soft");
|
sampleBack = audio.Samples.Get(@"UI/generic-select-soft");
|
||||||
|
|
||||||
Header.Current.BindTo(Current);
|
Header.Build.BindTo(Current);
|
||||||
|
|
||||||
Current.BindValueChanged(e =>
|
Current.BindValueChanged(e =>
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Overlays.News
|
|||||||
|
|
||||||
private NewsHeaderTitle title;
|
private NewsHeaderTitle title;
|
||||||
|
|
||||||
public readonly Bindable<string> Current = new Bindable<string>(null);
|
public readonly Bindable<string> Post = new Bindable<string>(null);
|
||||||
|
|
||||||
public Action ShowFrontPage;
|
public Action ShowFrontPage;
|
||||||
|
|
||||||
@ -22,13 +22,13 @@ namespace osu.Game.Overlays.News
|
|||||||
{
|
{
|
||||||
TabControl.AddItem(front_page_string);
|
TabControl.AddItem(front_page_string);
|
||||||
|
|
||||||
TabControl.Current.ValueChanged += e =>
|
Current.ValueChanged += e =>
|
||||||
{
|
{
|
||||||
if (e.NewValue == front_page_string)
|
if (e.NewValue == front_page_string)
|
||||||
ShowFrontPage?.Invoke();
|
ShowFrontPage?.Invoke();
|
||||||
};
|
};
|
||||||
|
|
||||||
Current.ValueChanged += showPost;
|
Post.ValueChanged += showPost;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showPost(ValueChangedEvent<string> e)
|
private void showPost(ValueChangedEvent<string> e)
|
||||||
@ -39,13 +39,13 @@ namespace osu.Game.Overlays.News
|
|||||||
if (e.NewValue != null)
|
if (e.NewValue != null)
|
||||||
{
|
{
|
||||||
TabControl.AddItem(e.NewValue);
|
TabControl.AddItem(e.NewValue);
|
||||||
TabControl.Current.Value = e.NewValue;
|
Current.Value = e.NewValue;
|
||||||
|
|
||||||
title.IsReadingPost = true;
|
title.IsReadingPost = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TabControl.Current.Value = front_page_string;
|
Current.Value = front_page_string;
|
||||||
title.IsReadingPost = false;
|
title.IsReadingPost = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
48
osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs
Normal file
48
osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Users;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Rankings
|
||||||
|
{
|
||||||
|
public class RankingsOverlayHeader : TabControlOverlayHeader<RankingsScope>
|
||||||
|
{
|
||||||
|
public readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||||
|
public readonly Bindable<Country> Country = new Bindable<Country>();
|
||||||
|
|
||||||
|
public IEnumerable<Spotlight> Spotlights { get; set; }
|
||||||
|
|
||||||
|
protected override ScreenTitle CreateTitle() => new RankingsTitle
|
||||||
|
{
|
||||||
|
Scope = { BindTarget = Current }
|
||||||
|
};
|
||||||
|
|
||||||
|
protected override Drawable CreateTitleContent() => new OverlayRulesetSelector
|
||||||
|
{
|
||||||
|
Current = Ruleset
|
||||||
|
};
|
||||||
|
|
||||||
|
private class RankingsTitle : ScreenTitle
|
||||||
|
{
|
||||||
|
public readonly Bindable<RankingsScope> Scope = new Bindable<RankingsScope>();
|
||||||
|
|
||||||
|
public RankingsTitle()
|
||||||
|
{
|
||||||
|
Title = "ranking";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
Scope.BindValueChanged(scope => Section = scope.NewValue.ToString().ToLowerInvariant(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/rankings");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
@ -19,6 +20,8 @@ namespace osu.Game.Overlays
|
|||||||
/// <typeparam name="T">The type of item to be represented by tabs.</typeparam>
|
/// <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
|
||||||
{
|
{
|
||||||
|
public readonly Bindable<T> Current = new Bindable<T>();
|
||||||
|
|
||||||
protected OsuTabControl<T> TabControl;
|
protected OsuTabControl<T> TabControl;
|
||||||
|
|
||||||
private readonly Box controlBackground;
|
private readonly Box controlBackground;
|
||||||
@ -35,7 +38,11 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
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