mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 13:22:55 +08:00
Implement Spotlights logic
This commit is contained in:
parent
0c6c8fdcd0
commit
acdd26422d
@ -35,6 +35,24 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
Scope = { BindTarget = scope },
|
Scope = { BindTarget = scope },
|
||||||
Country = { BindTarget = countryBindable },
|
Country = { BindTarget = countryBindable },
|
||||||
Ruleset = { BindTarget = ruleset },
|
Ruleset = { BindTarget = ruleset },
|
||||||
|
Spotlights = new[]
|
||||||
|
{
|
||||||
|
new Spotlight
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
Text = "Spotlight 1"
|
||||||
|
},
|
||||||
|
new Spotlight
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
Text = "Spotlight 2"
|
||||||
|
},
|
||||||
|
new Spotlight
|
||||||
|
{
|
||||||
|
Id = 3,
|
||||||
|
Text = "Spotlight 4"
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var country = new Country
|
var country = new Country
|
||||||
|
@ -4,23 +4,38 @@
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osuTK;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Rankings
|
namespace osu.Game.Overlays.Rankings
|
||||||
{
|
{
|
||||||
public class RankingsHeader : CompositeDrawable
|
public class RankingsHeader : CompositeDrawable
|
||||||
{
|
{
|
||||||
private const int content_height = 250;
|
private const int content_height = 250;
|
||||||
|
private const int dropdown_height = 50;
|
||||||
|
private const int spacing = 20;
|
||||||
|
private const int title_offset = 30;
|
||||||
|
private const int duration = 200;
|
||||||
|
|
||||||
|
public IEnumerable<Spotlight> Spotlights
|
||||||
|
{
|
||||||
|
get => dropdown.Items;
|
||||||
|
set => dropdown.Items = value;
|
||||||
|
}
|
||||||
|
|
||||||
public readonly Bindable<RankingsScope> Scope = new Bindable<RankingsScope>();
|
public readonly Bindable<RankingsScope> Scope = new Bindable<RankingsScope>();
|
||||||
public readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
public readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||||
public readonly Bindable<Country> Country = new Bindable<Country>();
|
public readonly Bindable<Country> Country = new Bindable<Country>();
|
||||||
|
public readonly Bindable<Spotlight> Spotlight = new Bindable<Spotlight>();
|
||||||
|
|
||||||
|
private readonly Container dropdownPlaceholder;
|
||||||
|
private readonly OsuDropdown<Spotlight> dropdown;
|
||||||
|
|
||||||
public RankingsHeader()
|
public RankingsHeader()
|
||||||
{
|
{
|
||||||
@ -47,29 +62,72 @@ namespace osu.Game.Overlays.Rankings
|
|||||||
Height = content_height,
|
Height = content_height,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new HeaderBackground(),
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Masking = true,
|
||||||
|
Child = new HeaderBackground(),
|
||||||
|
},
|
||||||
new RankingsScopeSelector
|
new RankingsScopeSelector
|
||||||
{
|
{
|
||||||
Margin = new MarginPadding { Top = 10 },
|
Margin = new MarginPadding { Top = 10 },
|
||||||
Current = { BindTarget = Scope }
|
Current = { BindTarget = Scope }
|
||||||
},
|
},
|
||||||
new HeaderTitle
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Scope = { BindTarget = Scope },
|
Y = title_offset,
|
||||||
Country = { BindTarget = Country },
|
AutoSizeAxes = Axes.Y,
|
||||||
}
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Spacing = new Vector2(0, spacing),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new HeaderTitle
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Scope = { BindTarget = Scope },
|
||||||
|
Country = { BindTarget = Country },
|
||||||
|
},
|
||||||
|
dropdownPlaceholder = new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = dropdown_height,
|
||||||
|
Width = 0.8f,
|
||||||
|
AlwaysPresent = true,
|
||||||
|
Child = dropdown = new OsuDropdown<Spotlight>
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Current = { BindTarget = Spotlight },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HeaderBackground : Sprite
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
Scope.BindValueChanged(scope => onScopeChanged(scope.NewValue), true);
|
||||||
|
base.LoadComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onScopeChanged(RankingsScope scope) =>
|
||||||
|
dropdownPlaceholder.FadeTo(scope == RankingsScope.Spotlights ? 1 : 0, duration, Easing.OutQuint);
|
||||||
|
|
||||||
|
private class HeaderBackground : Sprite
|
||||||
{
|
{
|
||||||
public HeaderBackground()
|
public HeaderBackground()
|
||||||
{
|
{
|
||||||
|
Anchor = Anchor.Centre;
|
||||||
|
Origin = Anchor.Centre;
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
FillMode = FillMode.Fill;
|
FillMode = FillMode.Fill;
|
||||||
}
|
}
|
||||||
|
18
osu.Game/Overlays/Rankings/Spotlight.cs
Normal file
18
osu.Game/Overlays/Rankings/Spotlight.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// 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
Block a user