mirror of
https://github.com/osukey/osukey.git
synced 2025-05-21 21:47:31 +09:00
Merge dependent changes
This commit is contained in:
parent
f9c6a8c5b7
commit
b657e31f93
65
osu.Game.Tests/Visual/Online/TestSceneRankingsHeaderFlag.cs
Normal file
65
osu.Game.Tests/Visual/Online/TestSceneRankingsHeaderFlag.cs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
// 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.Overlays.Rankings;
|
||||||
|
using osu.Game.Users;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Online
|
||||||
|
{
|
||||||
|
public class TestSceneRankingsHeaderFlag : OsuTestScene
|
||||||
|
{
|
||||||
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
|
{
|
||||||
|
typeof(HeaderFlag),
|
||||||
|
};
|
||||||
|
|
||||||
|
public TestSceneRankingsHeaderFlag()
|
||||||
|
{
|
||||||
|
HeaderFlag 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 HeaderFlag
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(30, 20),
|
||||||
|
Country = countryA,
|
||||||
|
},
|
||||||
|
text = new SpriteText
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
osu.Game.Tests/Visual/Online/TestSceneRankingsHeaderTitle.cs
Normal file
60
osu.Game.Tests/Visual/Online/TestSceneRankingsHeaderTitle.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
// 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(HeaderFlag),
|
||||||
|
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", () => countryBindable.Value = countryA);
|
||||||
|
AddAssert("Check scope is Performance", () => scope.Value == RankingsScope.Performance);
|
||||||
|
AddStep("Set scope to Score", () => scope.Value = RankingsScope.Score);
|
||||||
|
AddAssert("Check country is Null", () => countryBindable.Value == null);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
// 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 = { BindTarget = 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
103
osu.Game/Graphics/UserInterface/GradientLineTabControl.cs
Normal file
103
osu.Game/Graphics/UserInterface/GradientLineTabControl.cs
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
// 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.UserInterface;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osuTK;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
using osu.Framework.Graphics.Colour;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
|
||||||
|
namespace osu.Game.Graphics.UserInterface
|
||||||
|
{
|
||||||
|
public class GradientLineTabControl<TModel> : PageTabControl<TModel>
|
||||||
|
{
|
||||||
|
protected override Dropdown<TModel> CreateDropdown() => null;
|
||||||
|
|
||||||
|
protected Color4 LineColour
|
||||||
|
{
|
||||||
|
get => line.MainColour.Value;
|
||||||
|
set => line.MainColour.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly GradientLine line;
|
||||||
|
|
||||||
|
public GradientLineTabControl()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
|
||||||
|
AddInternal(line = new GradientLine
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
AutoSizeAxes = Axes.X,
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Spacing = new Vector2(20, 0),
|
||||||
|
};
|
||||||
|
|
||||||
|
private class GradientLine : GridContainer
|
||||||
|
{
|
||||||
|
public readonly Bindable<Color4> MainColour = new Bindable<Color4>();
|
||||||
|
|
||||||
|
private readonly Box left;
|
||||||
|
private readonly Box middle;
|
||||||
|
private readonly Box right;
|
||||||
|
|
||||||
|
public GradientLine()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
Size = new Vector2(0.8f, 1.5f);
|
||||||
|
|
||||||
|
ColumnDimensions = new[]
|
||||||
|
{
|
||||||
|
new Dimension(),
|
||||||
|
new Dimension(mode: GridSizeMode.Relative, size: 0.4f),
|
||||||
|
new Dimension(),
|
||||||
|
};
|
||||||
|
|
||||||
|
Content = new[]
|
||||||
|
{
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
left = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
middle = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
right = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
MainColour.BindValueChanged(onColourChanged, true);
|
||||||
|
base.LoadComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onColourChanged(ValueChangedEvent<Color4> colour)
|
||||||
|
{
|
||||||
|
left.Colour = ColourInfo.GradientHorizontal(colour.NewValue.Opacity(0), colour.NewValue);
|
||||||
|
middle.Colour = colour.NewValue;
|
||||||
|
right.Colour = ColourInfo.GradientHorizontal(colour.NewValue, colour.NewValue.Opacity(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -63,7 +63,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Margin = new MarginPadding { Top = 8, Bottom = 8 },
|
Margin = new MarginPadding { Top = 8, Bottom = 8 },
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Text = (value as Enum)?.GetDescription() ?? value.ToString(),
|
Text = CreateText(),
|
||||||
Font = OsuFont.GetFont(size: 14)
|
Font = OsuFont.GetFont(size: 14)
|
||||||
},
|
},
|
||||||
box = new Box
|
box = new Box
|
||||||
@ -81,6 +81,8 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Active.BindValueChanged(active => Text.Font = Text.Font.With(Typeface.Exo, weight: active.NewValue ? FontWeight.Bold : FontWeight.Medium), true);
|
Active.BindValueChanged(active => Text.Font = Text.Font.With(Typeface.Exo, weight: active.NewValue ? FontWeight.Bold : FontWeight.Medium), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual string CreateText() => (Value as Enum)?.GetDescription() ?? Value.ToString();
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
if (!Active.Value)
|
if (!Active.Value)
|
||||||
|
@ -1,60 +1,37 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Graphics.UserInterface;
|
|
||||||
using osu.Game.Screens.Select.Leaderboards;
|
using osu.Game.Screens.Select.Leaderboards;
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osuTK;
|
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.BeatmapSet
|
namespace osu.Game.Overlays.BeatmapSet
|
||||||
{
|
{
|
||||||
public class LeaderboardScopeSelector : PageTabControl<BeatmapLeaderboardScope>
|
public class LeaderboardScopeSelector : GradientLineTabControl<BeatmapLeaderboardScope>
|
||||||
{
|
{
|
||||||
protected override bool AddEnumEntriesAutomatically => false;
|
protected override bool AddEnumEntriesAutomatically => false;
|
||||||
|
|
||||||
protected override Dropdown<BeatmapLeaderboardScope> CreateDropdown() => null;
|
|
||||||
|
|
||||||
protected override TabItem<BeatmapLeaderboardScope> CreateTabItem(BeatmapLeaderboardScope value) => new ScopeSelectorTabItem(value);
|
protected override TabItem<BeatmapLeaderboardScope> CreateTabItem(BeatmapLeaderboardScope value) => new ScopeSelectorTabItem(value);
|
||||||
|
|
||||||
public LeaderboardScopeSelector()
|
public LeaderboardScopeSelector()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
|
||||||
|
|
||||||
AddItem(BeatmapLeaderboardScope.Global);
|
AddItem(BeatmapLeaderboardScope.Global);
|
||||||
AddItem(BeatmapLeaderboardScope.Country);
|
AddItem(BeatmapLeaderboardScope.Country);
|
||||||
AddItem(BeatmapLeaderboardScope.Friend);
|
AddItem(BeatmapLeaderboardScope.Friend);
|
||||||
|
|
||||||
AddInternal(new GradientLine
|
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
AccentColour = colours.Blue;
|
AccentColour = colours.Blue;
|
||||||
|
LineColour = Color4.Gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
|
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
AutoSizeAxes = Axes.X,
|
|
||||||
RelativeSizeAxes = Axes.Y,
|
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
Spacing = new Vector2(20, 0),
|
|
||||||
};
|
|
||||||
|
|
||||||
private class ScopeSelectorTabItem : PageTabItem
|
private class ScopeSelectorTabItem : PageTabItem
|
||||||
{
|
{
|
||||||
public ScopeSelectorTabItem(BeatmapLeaderboardScope value)
|
public ScopeSelectorTabItem(BeatmapLeaderboardScope value)
|
||||||
@ -77,43 +54,5 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
Text.FadeColour(Color4.White);
|
Text.FadeColour(Color4.White);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class GradientLine : GridContainer
|
|
||||||
{
|
|
||||||
public GradientLine()
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X;
|
|
||||||
Size = new Vector2(0.8f, 1.5f);
|
|
||||||
|
|
||||||
ColumnDimensions = new[]
|
|
||||||
{
|
|
||||||
new Dimension(),
|
|
||||||
new Dimension(mode: GridSizeMode.Relative, size: 0.4f),
|
|
||||||
new Dimension(),
|
|
||||||
};
|
|
||||||
|
|
||||||
Content = new[]
|
|
||||||
{
|
|
||||||
new Drawable[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = ColourInfo.GradientHorizontal(Color4.Transparent, Color4.Gray),
|
|
||||||
},
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = Color4.Gray,
|
|
||||||
},
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = ColourInfo.GradientHorizontal(Color4.Gray, Color4.Transparent),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
55
osu.Game/Overlays/Rankings/HeaderFlag.cs
Normal file
55
osu.Game/Overlays/Rankings/HeaderFlag.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// 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 HeaderFlag : UpdateableFlag
|
||||||
|
{
|
||||||
|
private const int duration = 200;
|
||||||
|
|
||||||
|
public Action Action;
|
||||||
|
|
||||||
|
private readonly SpriteIcon hoverIcon;
|
||||||
|
|
||||||
|
public HeaderFlag()
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
105
osu.Game/Overlays/Rankings/HeaderTitle.cs
Normal file
105
osu.Game/Overlays/Rankings/HeaderTitle.cs
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
// 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;
|
||||||
|
|
||||||
|
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 Container flagPlaceholder;
|
||||||
|
private readonly HeaderFlag flag;
|
||||||
|
|
||||||
|
public HeaderTitle()
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
InternalChild = new FillFlowContainer
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Spacing = new Vector2(spacing, 0),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
flagPlaceholder = new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Margin = new MarginPadding { Bottom = flag_margin },
|
||||||
|
Child = flag = new HeaderFlag
|
||||||
|
{
|
||||||
|
Size = new Vector2(30, 20),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
scopeText = new SpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Light)
|
||||||
|
},
|
||||||
|
new SpriteText
|
||||||
|
{
|
||||||
|
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(scope => onScopeChanged(scope.NewValue), true);
|
||||||
|
Country.BindValueChanged(onCountryChanged, true);
|
||||||
|
base.LoadComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onScopeChanged(RankingsScope scope)
|
||||||
|
{
|
||||||
|
scopeText.Text = scope.ToString();
|
||||||
|
|
||||||
|
if (scope != RankingsScope.Performance)
|
||||||
|
Country.Value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onCountryChanged(ValueChangedEvent<Country> country)
|
||||||
|
{
|
||||||
|
if (country.NewValue == null)
|
||||||
|
{
|
||||||
|
flagPlaceholder.Hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Scope.Value = RankingsScope.Performance;
|
||||||
|
|
||||||
|
if (country.OldValue == null)
|
||||||
|
flagPlaceholder.Show();
|
||||||
|
|
||||||
|
flag.Country = country.NewValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
56
osu.Game/Overlays/Rankings/RankingsRulesetSelector.cs
Normal file
56
osu.Game/Overlays/Rankings/RankingsRulesetSelector.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// 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}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
26
osu.Game/Overlays/Rankings/RankingsScopeSelector.cs
Normal file
26
osu.Game/Overlays/Rankings/RankingsScopeSelector.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// 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
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user