1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:52:53 +08:00

Delete unused components

This commit is contained in:
Andrei Zavatski 2020-02-03 20:59:08 +03:00
parent 3b6ed3fb27
commit 2a802307e7
11 changed files with 9 additions and 573 deletions

View File

@ -1,66 +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 System;
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays.Rankings;
using osu.Game.Users;
using osuTK;
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneRankingsDismissableFlag : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(DismissableFlag),
};
public TestSceneRankingsDismissableFlag()
{
DismissableFlag flag;
SpriteText text;
var countryA = new Country
{
FlagName = "BY",
FullName = "Belarus"
};
var countryB = new Country
{
FlagName = "US",
FullName = "United States"
};
AddRange(new Drawable[]
{
flag = new DismissableFlag
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(30, 20),
Country = countryA,
},
text = new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = "Invoked",
Font = OsuFont.GetFont(size: 30),
Alpha = 0,
}
});
flag.Action += () => text.FadeIn().Then().FadeOut(1000, Easing.OutQuint);
AddStep("Trigger click", () => flag.Click());
AddStep("Change to country 2", () => flag.Country = countryB);
AddStep("Change to country 1", () => flag.Country = countryA);
}
}
}

View File

@ -18,6 +18,7 @@ namespace osu.Game.Tests.Visual.Online
{
typeof(RankingsOverlayHeader),
typeof(CountryFilter),
typeof(CountryPill)
};
[Cached]

View File

@ -1,55 +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 System;
using System.Collections.Generic;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Overlays.Rankings;
using osu.Game.Users;
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneRankingsHeaderTitle : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(DismissableFlag),
typeof(HeaderTitle),
};
public TestSceneRankingsHeaderTitle()
{
var countryBindable = new Bindable<Country>();
var scope = new Bindable<RankingsScope>();
Add(new HeaderTitle
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Country = { BindTarget = countryBindable },
Scope = { BindTarget = scope },
});
var countryA = new Country
{
FlagName = "BY",
FullName = "Belarus"
};
var countryB = new Country
{
FlagName = "US",
FullName = "United States"
};
AddStep("Set country 1", () => countryBindable.Value = countryA);
AddStep("Set country 2", () => countryBindable.Value = countryB);
AddStep("Set null country", () => countryBindable.Value = null);
AddStep("Set scope to Performance", () => scope.Value = RankingsScope.Performance);
AddStep("Set scope to Spotlights", () => scope.Value = RankingsScope.Spotlights);
AddStep("Set scope to Score", () => scope.Value = RankingsScope.Score);
AddStep("Set scope to Country", () => scope.Value = RankingsScope.Country);
}
}
}

View File

@ -1,41 +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 System;
using System.Collections.Generic;
using osu.Game.Overlays.Rankings;
using osu.Framework.Graphics;
using osu.Game.Rulesets;
using osu.Framework.Bindables;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Mania;
using osu.Game.Rulesets.Taiko;
using osu.Game.Rulesets.Catch;
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneRankingsRulesetSelector : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(RankingsRulesetSelector),
};
public TestSceneRankingsRulesetSelector()
{
var current = new Bindable<RulesetInfo>();
Add(new RankingsRulesetSelector
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Current = { BindTarget = current }
});
AddStep("Select osu!", () => current.Value = new OsuRuleset().RulesetInfo);
AddStep("Select mania", () => current.Value = new ManiaRuleset().RulesetInfo);
AddStep("Select taiko", () => current.Value = new TaikoRuleset().RulesetInfo);
AddStep("Select catch", () => current.Value = new CatchRuleset().RulesetInfo);
}
}
}

View File

@ -1,54 +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 System;
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Allocation;
using osu.Game.Graphics;
using osu.Game.Overlays.Rankings;
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneRankingsScopeSelector : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(RankingsScopeSelector),
};
private readonly Box background;
public TestSceneRankingsScopeSelector()
{
var scope = new Bindable<RankingsScope>();
AddRange(new Drawable[]
{
background = new Box
{
RelativeSizeAxes = Axes.Both
},
new RankingsScopeSelector
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Current = scope,
}
});
AddStep(@"Select country", () => scope.Value = RankingsScope.Country);
AddStep(@"Select performance", () => scope.Value = RankingsScope.Performance);
AddStep(@"Select score", () => scope.Value = RankingsScope.Score);
AddStep(@"Select spotlights", () => scope.Value = RankingsScope.Spotlights);
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
background.Colour = colours.GreySeafoam;
}
}
}

View File

@ -1,55 +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 osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Users.Drawables;
using osuTK.Graphics;
using osuTK;
using osu.Framework.Input.Events;
using System;
namespace osu.Game.Overlays.Rankings
{
public class DismissableFlag : UpdateableFlag
{
private const int duration = 200;
public Action Action;
private readonly SpriteIcon hoverIcon;
public DismissableFlag()
{
AddInternal(hoverIcon = new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Depth = -1,
Alpha = 0,
Size = new Vector2(10),
Icon = FontAwesome.Solid.Times,
});
}
protected override bool OnHover(HoverEvent e)
{
hoverIcon.FadeIn(duration, Easing.OutQuint);
this.FadeColour(Color4.Gray, duration, Easing.OutQuint);
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
base.OnHoverLost(e);
hoverIcon.FadeOut(duration, Easing.OutQuint);
this.FadeColour(Color4.White, duration, Easing.OutQuint);
}
protected override bool OnClick(ClickEvent e)
{
Action?.Invoke();
return true;
}
}
}

View File

@ -1,91 +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 osu.Framework.Bindables;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Users;
using osu.Framework.Graphics;
using osuTK;
using osu.Game.Graphics;
using osu.Framework.Allocation;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.Rankings
{
public class HeaderTitle : CompositeDrawable
{
private const int spacing = 10;
private const int flag_margin = 5;
private const int text_size = 40;
public readonly Bindable<RankingsScope> Scope = new Bindable<RankingsScope>();
public readonly Bindable<Country> Country = new Bindable<Country>();
private readonly SpriteText scopeText;
private readonly DismissableFlag flag;
public HeaderTitle()
{
AutoSizeAxes = Axes.Both;
InternalChild = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(spacing, 0),
Children = new Drawable[]
{
flag = new DismissableFlag
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Margin = new MarginPadding { Bottom = flag_margin },
Size = new Vector2(30, 20),
},
scopeText = new OsuSpriteText
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Light)
},
new OsuSpriteText
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Light),
Text = @"Ranking"
}
}
};
flag.Action += () => Country.Value = null;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
scopeText.Colour = colours.Lime;
}
protected override void LoadComplete()
{
Scope.BindValueChanged(onScopeChanged, true);
Country.BindValueChanged(onCountryChanged, true);
base.LoadComplete();
}
private void onScopeChanged(ValueChangedEvent<RankingsScope> scope) => scopeText.Text = scope.NewValue.ToString();
private void onCountryChanged(ValueChangedEvent<Country> country)
{
if (country.NewValue == null)
{
flag.Hide();
return;
}
flag.Country = country.NewValue;
flag.Show();
}
}
}

View File

@ -1,129 +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 osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Rulesets;
using osu.Game.Users;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osuTK;
using osu.Game.Graphics.UserInterface;
using System.Collections.Generic;
namespace osu.Game.Overlays.Rankings
{
public class RankingsHeader : CompositeDrawable
{
private const int content_height = 250;
public IEnumerable<Spotlight> Spotlights
{
get => dropdown.Items;
set => dropdown.Items = value;
}
public readonly Bindable<RankingsScope> Scope = new Bindable<RankingsScope>();
public readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
public readonly Bindable<Country> Country = new Bindable<Country>();
public readonly Bindable<Spotlight> Spotlight = new Bindable<Spotlight>();
private readonly OsuDropdown<Spotlight> dropdown;
public RankingsHeader()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
AddInternal(new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
new RankingsRulesetSelector
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Current = Ruleset
},
new Container
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
Height = content_height,
Children = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
Child = new HeaderBackground(),
},
new FillFlowContainer
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 20),
Children = new Drawable[]
{
new RankingsScopeSelector
{
Margin = new MarginPadding { Top = 10 },
Current = Scope
},
new HeaderTitle
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Margin = new MarginPadding { Top = 10 },
Scope = { BindTarget = Scope },
Country = { BindTarget = Country },
},
dropdown = new OsuDropdown<Spotlight>
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
Width = 0.8f,
Current = Spotlight,
}
}
},
}
}
}
});
}
protected override void LoadComplete()
{
Scope.BindValueChanged(onScopeChanged, true);
base.LoadComplete();
}
private void onScopeChanged(ValueChangedEvent<RankingsScope> scope) =>
dropdown.FadeTo(scope.NewValue == RankingsScope.Spotlights ? 1 : 0, 200, Easing.OutQuint);
private class HeaderBackground : Sprite
{
public HeaderBackground()
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
RelativeSizeAxes = Axes.Both;
FillMode = FillMode.Fill;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Texture = textures.Get(@"Headers/rankings");
}
}
}
}

View File

@ -124,4 +124,12 @@ namespace osu.Game.Overlays.Rankings
}
}
}
public enum RankingsScope
{
Performance,
Spotlights,
Score,
Country
}
}

View File

@ -1,56 +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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets;
using osuTK;
using System.Linq;
namespace osu.Game.Overlays.Rankings
{
public class RankingsRulesetSelector : PageTabControl<RulesetInfo>
{
protected override TabItem<RulesetInfo> CreateTabItem(RulesetInfo value) => new RankingsTabItem(value);
protected override Dropdown<RulesetInfo> CreateDropdown() => null;
public RankingsRulesetSelector()
{
AutoSizeAxes = Axes.X;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, RulesetStore rulesets)
{
foreach (var r in rulesets.AvailableRulesets)
AddItem(r);
AccentColour = colours.Lime;
SelectTab(TabContainer.FirstOrDefault());
}
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
{
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(20, 0),
};
private class RankingsTabItem : PageTabItem
{
public RankingsTabItem(RulesetInfo value)
: base(value)
{
}
protected override string CreateText() => $"{Value.Name}";
}
}
}

View File

@ -1,26 +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 osu.Game.Graphics.UserInterface;
using osu.Framework.Allocation;
using osuTK.Graphics;
namespace osu.Game.Overlays.Rankings
{
public class RankingsScopeSelector : GradientLineTabControl<RankingsScope>
{
[BackgroundDependencyLoader]
private void load()
{
AccentColour = LineColour = Color4.Black;
}
}
public enum RankingsScope
{
Performance,
Spotlights,
Score,
Country
}
}