mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 16:16:07 +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,
|
Anchor = Anchor.TopCentre,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
Country = { BindTarget = countryBindable }
|
Current = { BindTarget = countryBindable }
|
||||||
},
|
},
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,7 @@ 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;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
@ -13,12 +14,18 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Rankings
|
namespace osu.Game.Overlays.Rankings
|
||||||
{
|
{
|
||||||
public class CountryFilter : Container
|
public class CountryFilter : CompositeDrawable, IHasCurrentValue<Country>
|
||||||
{
|
{
|
||||||
private const int duration = 200;
|
private const int duration = 200;
|
||||||
private const int height = 50;
|
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 Box background;
|
||||||
private readonly CountryPill countryPill;
|
private readonly CountryPill countryPill;
|
||||||
@ -27,7 +34,8 @@ namespace osu.Game.Overlays.Rankings
|
|||||||
public CountryFilter()
|
public CountryFilter()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
Child = content = new Container
|
|
||||||
|
InternalChild = content = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = height,
|
Height = height,
|
||||||
@ -59,7 +67,7 @@ namespace osu.Game.Overlays.Rankings
|
|||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
Country = { BindTarget = Country }
|
Current = Current
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,7 +84,7 @@ namespace osu.Game.Overlays.Rankings
|
|||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
Country.BindValueChanged(onCountryChanged, true);
|
Current.BindValueChanged(onCountryChanged, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onCountryChanged(ValueChangedEvent<Country> country)
|
private void onCountryChanged(ValueChangedEvent<Country> country)
|
||||||
|
@ -8,6 +8,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
@ -18,22 +19,33 @@ using osuTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Rankings
|
namespace osu.Game.Overlays.Rankings
|
||||||
{
|
{
|
||||||
public class CountryPill : CircularContainer
|
public class CountryPill : CompositeDrawable, IHasCurrentValue<Country>
|
||||||
{
|
{
|
||||||
private const int duration = 200;
|
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 Box background;
|
||||||
private readonly UpdateableFlag flag;
|
private readonly UpdateableFlag flag;
|
||||||
private readonly OsuSpriteText countryName;
|
private readonly OsuSpriteText countryName;
|
||||||
|
|
||||||
public readonly Bindable<Country> Country = new Bindable<Country>();
|
|
||||||
|
|
||||||
public CountryPill()
|
public CountryPill()
|
||||||
{
|
{
|
||||||
AutoSizeDuration = duration;
|
AutoSizeAxes = Axes.Both;
|
||||||
AutoSizeEasing = Easing.OutQuint;
|
|
||||||
Height = 25;
|
InternalChild = content = new CircularContainer
|
||||||
Masking = true;
|
{
|
||||||
|
Height = 25,
|
||||||
|
AutoSizeDuration = duration,
|
||||||
|
AutoSizeEasing = Easing.OutQuint,
|
||||||
|
Masking = true,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
background = new Box
|
background = new Box
|
||||||
@ -79,7 +91,8 @@ namespace osu.Game.Overlays.Rankings
|
|||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = 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()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
Country.BindValueChanged(onCountryChanged, true);
|
Current.BindValueChanged(onCountryChanged, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Expand()
|
public void Expand()
|
||||||
{
|
{
|
||||||
ClearTransforms();
|
content.ClearTransforms();
|
||||||
AutoSizeAxes = Axes.X;
|
content.AutoSizeAxes = Axes.X;
|
||||||
|
|
||||||
this.FadeIn(duration, Easing.OutQuint);
|
this.FadeIn(duration, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Collapse()
|
public void Collapse()
|
||||||
{
|
{
|
||||||
ClearTransforms();
|
content.ClearTransforms();
|
||||||
AutoSizeAxes = Axes.None;
|
content.AutoSizeAxes = Axes.None;
|
||||||
this.ResizeWidthTo(0, duration, Easing.OutQuint);
|
content.ResizeWidthTo(0, duration, Easing.OutQuint);
|
||||||
|
|
||||||
this.FadeOut(duration, Easing.OutQuint);
|
this.FadeOut(duration, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user