mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 00:43:25 +08:00
General refactorings
This commit is contained in:
parent
45dad5a9c7
commit
1367c18d3f
@ -44,7 +44,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Country = { BindTarget = countryBindable }
|
||||
Current = { BindTarget = countryBindable }
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Users;
|
||||
@ -13,12 +14,18 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Rankings
|
||||
{
|
||||
public class CountryFilter : Container
|
||||
public class CountryFilter : CompositeDrawable, IHasCurrentValue<Country>
|
||||
{
|
||||
private const int duration = 200;
|
||||
private const int height = 50;
|
||||
|
||||
public readonly Bindable<Country> Country = new Bindable<Country>();
|
||||
private readonly BindableWithCurrent<Country> current = new BindableWithCurrent<Country>();
|
||||
|
||||
public Bindable<Country> Current
|
||||
{
|
||||
get => current.Current;
|
||||
set => current.Current = value;
|
||||
}
|
||||
|
||||
private readonly Box background;
|
||||
private readonly CountryPill countryPill;
|
||||
@ -27,7 +34,8 @@ namespace osu.Game.Overlays.Rankings
|
||||
public CountryFilter()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Child = content = new Container
|
||||
|
||||
InternalChild = content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = height,
|
||||
@ -59,7 +67,7 @@ namespace osu.Game.Overlays.Rankings
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Alpha = 0,
|
||||
Country = { BindTarget = Country }
|
||||
Current = Current
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -76,7 +84,7 @@ namespace osu.Game.Overlays.Rankings
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
Country.BindValueChanged(onCountryChanged, true);
|
||||
Current.BindValueChanged(onCountryChanged, true);
|
||||
}
|
||||
|
||||
private void onCountryChanged(ValueChangedEvent<Country> country)
|
||||
|
@ -8,6 +8,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
@ -18,22 +19,33 @@ using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Rankings
|
||||
{
|
||||
public class CountryPill : CircularContainer
|
||||
public class CountryPill : CompositeDrawable, IHasCurrentValue<Country>
|
||||
{
|
||||
private const int duration = 200;
|
||||
|
||||
private readonly BindableWithCurrent<Country> current = new BindableWithCurrent<Country>();
|
||||
|
||||
public Bindable<Country> Current
|
||||
{
|
||||
get => current.Current;
|
||||
set => current.Current = value;
|
||||
}
|
||||
|
||||
private readonly Container content;
|
||||
private readonly Box background;
|
||||
private readonly UpdateableFlag flag;
|
||||
private readonly OsuSpriteText countryName;
|
||||
|
||||
public readonly Bindable<Country> Country = new Bindable<Country>();
|
||||
|
||||
public CountryPill()
|
||||
{
|
||||
AutoSizeDuration = duration;
|
||||
AutoSizeEasing = Easing.OutQuint;
|
||||
Height = 25;
|
||||
Masking = true;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
InternalChild = content = new CircularContainer
|
||||
{
|
||||
Height = 25,
|
||||
AutoSizeDuration = duration,
|
||||
AutoSizeEasing = Easing.OutQuint,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
@ -79,7 +91,8 @@ namespace osu.Game.Overlays.Rankings
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Action = () => Country.Value = null
|
||||
Action = () => Current.Value = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -95,21 +108,23 @@ namespace osu.Game.Overlays.Rankings
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
Country.BindValueChanged(onCountryChanged, true);
|
||||
Current.BindValueChanged(onCountryChanged, true);
|
||||
}
|
||||
|
||||
public void Expand()
|
||||
{
|
||||
ClearTransforms();
|
||||
AutoSizeAxes = Axes.X;
|
||||
content.ClearTransforms();
|
||||
content.AutoSizeAxes = Axes.X;
|
||||
|
||||
this.FadeIn(duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
public void Collapse()
|
||||
{
|
||||
ClearTransforms();
|
||||
AutoSizeAxes = Axes.None;
|
||||
this.ResizeWidthTo(0, duration, Easing.OutQuint);
|
||||
content.ClearTransforms();
|
||||
content.AutoSizeAxes = Axes.None;
|
||||
content.ResizeWidthTo(0, duration, Easing.OutQuint);
|
||||
|
||||
this.FadeOut(duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user