mirror of https://github.com/ppy/osu
Use new SpotlightSelector in RankingsHeader
This commit is contained in:
parent
e119040d5d
commit
a3fd952f74
|
@ -5,6 +5,7 @@
|
|||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Rankings;
|
||||
using osu.Game.Rulesets;
|
||||
|
@ -37,20 +38,20 @@ public TestSceneRankingsHeader()
|
|||
Ruleset = { BindTarget = ruleset },
|
||||
Spotlights = new[]
|
||||
{
|
||||
new Spotlight
|
||||
new APISpotlight
|
||||
{
|
||||
Id = 1,
|
||||
Text = "Spotlight 1"
|
||||
Name = "Spotlight 1"
|
||||
},
|
||||
new Spotlight
|
||||
new APISpotlight
|
||||
{
|
||||
Id = 2,
|
||||
Text = "Spotlight 2"
|
||||
Name = "Spotlight 2"
|
||||
},
|
||||
new Spotlight
|
||||
new APISpotlight
|
||||
{
|
||||
Id = 3,
|
||||
Text = "Spotlight 3"
|
||||
Name = "Spotlight 3"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -8,21 +8,20 @@
|
|||
using osu.Game.Users;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Overlays.Rankings
|
||||
{
|
||||
public class RankingsOverlayHeader : TabControlOverlayHeader<RankingsScope>
|
||||
{
|
||||
public readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||
public readonly Bindable<Spotlight> Spotlight = new Bindable<Spotlight>();
|
||||
public readonly Bindable<APISpotlight> Spotlight = new Bindable<APISpotlight>();
|
||||
public readonly Bindable<Country> Country = new Bindable<Country>();
|
||||
|
||||
public IEnumerable<Spotlight> Spotlights
|
||||
public IEnumerable<APISpotlight> Spotlights
|
||||
{
|
||||
get => spotlightsContainer.Spotlights;
|
||||
set => spotlightsContainer.Spotlights = value;
|
||||
get => spotlightSelector.Spotlights;
|
||||
set => spotlightSelector.Spotlights = value;
|
||||
}
|
||||
|
||||
protected override ScreenTitle CreateTitle() => new RankingsTitle
|
||||
|
@ -35,7 +34,7 @@ public IEnumerable<Spotlight> Spotlights
|
|||
Current = Ruleset
|
||||
};
|
||||
|
||||
private SpotlightsContainer spotlightsContainer;
|
||||
private SpotlightSelector spotlightSelector;
|
||||
|
||||
protected override Drawable CreateContent() => new FillFlowContainer
|
||||
{
|
||||
|
@ -48,9 +47,9 @@ public IEnumerable<Spotlight> Spotlights
|
|||
{
|
||||
Current = Country
|
||||
},
|
||||
spotlightsContainer = new SpotlightsContainer
|
||||
spotlightSelector = new SpotlightSelector
|
||||
{
|
||||
Spotlight = { BindTarget = Spotlight }
|
||||
Current = { BindTarget = Spotlight }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -62,7 +61,7 @@ protected override void LoadComplete()
|
|||
}
|
||||
|
||||
private void onCurrentChanged(ValueChangedEvent<RankingsScope> scope) =>
|
||||
spotlightsContainer.FadeTo(scope.NewValue == RankingsScope.Spotlights ? 1 : 0, 200, Easing.OutQuint);
|
||||
spotlightSelector.FadeTo(scope.NewValue == RankingsScope.Spotlights ? 1 : 0, 200, Easing.OutQuint);
|
||||
|
||||
private class RankingsTitle : ScreenTitle
|
||||
{
|
||||
|
@ -81,48 +80,6 @@ protected override void LoadComplete()
|
|||
|
||||
protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/rankings");
|
||||
}
|
||||
|
||||
private class SpotlightsContainer : CompositeDrawable
|
||||
{
|
||||
public readonly Bindable<Spotlight> Spotlight = new Bindable<Spotlight>();
|
||||
|
||||
public IEnumerable<Spotlight> Spotlights
|
||||
{
|
||||
get => dropdown.Items;
|
||||
set => dropdown.Items = value;
|
||||
}
|
||||
|
||||
private readonly OsuDropdown<Spotlight> dropdown;
|
||||
private readonly Box background;
|
||||
|
||||
public SpotlightsContainer()
|
||||
{
|
||||
Height = 100;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
dropdown = new OsuDropdown<Spotlight>
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = 0.8f,
|
||||
Current = Spotlight,
|
||||
Y = 20,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
background.Colour = colourProvider.Dark3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum RankingsScope
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
// 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 Newtonsoft.Json;
|
||||
|
||||
namespace osu.Game.Overlays.Rankings
|
||||
{
|
||||
public class Spotlight
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public int Id;
|
||||
|
||||
[JsonProperty("text")]
|
||||
public string Text;
|
||||
|
||||
public override string ToString() => Text;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue