mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 20:53:04 +08:00
Implement score panel list
This commit is contained in:
parent
e3c1112b5a
commit
1b8d657ead
69
osu.Game.Tests/Visual/Ranking/TestSceneScorePanelList.cs
Normal file
69
osu.Game.Tests/Visual/Ranking/TestSceneScorePanelList.cs
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
// 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 osu.Framework.Graphics;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Screens.Ranking;
|
||||||
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
using osu.Game.Users;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Ranking
|
||||||
|
{
|
||||||
|
public class TestSceneScorePanelList : OsuTestScene
|
||||||
|
{
|
||||||
|
public TestSceneScorePanelList()
|
||||||
|
{
|
||||||
|
var list = new ScorePanelList
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
};
|
||||||
|
|
||||||
|
Add(list);
|
||||||
|
|
||||||
|
list.AddScore(createScore());
|
||||||
|
list.AddScore(createScore());
|
||||||
|
list.AddScore(createScore());
|
||||||
|
list.AddScore(createScore());
|
||||||
|
list.AddScore(createScore());
|
||||||
|
list.AddScore(createScore());
|
||||||
|
list.AddScore(createScore());
|
||||||
|
list.AddScore(createScore());
|
||||||
|
list.AddScore(createScore());
|
||||||
|
list.AddScore(createScore());
|
||||||
|
list.AddScore(createScore());
|
||||||
|
list.AddScore(createScore());
|
||||||
|
list.AddScore(createScore());
|
||||||
|
list.AddScore(createScore());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ScoreInfo createScore() => new ScoreInfo
|
||||||
|
{
|
||||||
|
User = new User
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
Username = "peppy",
|
||||||
|
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||||
|
},
|
||||||
|
Beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo,
|
||||||
|
Mods = new Mod[] { new OsuModHardRock(), new OsuModDoubleTime() },
|
||||||
|
TotalScore = 2845370,
|
||||||
|
Accuracy = 0.95,
|
||||||
|
MaxCombo = 999,
|
||||||
|
Rank = ScoreRank.S,
|
||||||
|
Date = DateTimeOffset.Now,
|
||||||
|
Statistics =
|
||||||
|
{
|
||||||
|
{ HitResult.Miss, 1 },
|
||||||
|
{ HitResult.Meh, 50 },
|
||||||
|
{ HitResult.Good, 100 },
|
||||||
|
{ HitResult.Great, 300 },
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens.Ranking.Contracted;
|
using osu.Game.Screens.Ranking.Contracted;
|
||||||
using osu.Game.Screens.Ranking.Expanded;
|
using osu.Game.Screens.Ranking.Expanded;
|
||||||
@ -75,8 +76,7 @@ namespace osu.Game.Screens.Ranking
|
|||||||
private static readonly Color4 contracted_middle_layer_colour = Color4Extensions.FromHex("#353535");
|
private static readonly Color4 contracted_middle_layer_colour = Color4Extensions.FromHex("#353535");
|
||||||
|
|
||||||
public event Action<PanelState> StateChanged;
|
public event Action<PanelState> StateChanged;
|
||||||
|
public readonly ScoreInfo Score;
|
||||||
private readonly ScoreInfo score;
|
|
||||||
|
|
||||||
private Container topLayerContainer;
|
private Container topLayerContainer;
|
||||||
private Drawable topLayerBackground;
|
private Drawable topLayerBackground;
|
||||||
@ -90,7 +90,7 @@ namespace osu.Game.Screens.Ranking
|
|||||||
|
|
||||||
public ScorePanel(ScoreInfo score)
|
public ScorePanel(ScoreInfo score)
|
||||||
{
|
{
|
||||||
this.score = score;
|
Score = score;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -189,8 +189,8 @@ namespace osu.Game.Screens.Ranking
|
|||||||
topLayerBackground.FadeColour(expanded_top_layer_colour, resize_duration, Easing.OutQuint);
|
topLayerBackground.FadeColour(expanded_top_layer_colour, resize_duration, Easing.OutQuint);
|
||||||
middleLayerBackground.FadeColour(expanded_middle_layer_colour, resize_duration, Easing.OutQuint);
|
middleLayerBackground.FadeColour(expanded_middle_layer_colour, resize_duration, Easing.OutQuint);
|
||||||
|
|
||||||
topLayerContentContainer.Add(middleLayerContent = new ExpandedPanelTopContent(score.User).With(d => d.Alpha = 0));
|
topLayerContentContainer.Add(middleLayerContent = new ExpandedPanelTopContent(Score.User).With(d => d.Alpha = 0));
|
||||||
middleLayerContentContainer.Add(topLayerContent = new ExpandedPanelMiddleContent(score).With(d => d.Alpha = 0));
|
middleLayerContentContainer.Add(topLayerContent = new ExpandedPanelMiddleContent(Score).With(d => d.Alpha = 0));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PanelState.Contracted:
|
case PanelState.Contracted:
|
||||||
@ -199,7 +199,7 @@ namespace osu.Game.Screens.Ranking
|
|||||||
topLayerBackground.FadeColour(contracted_top_layer_colour, resize_duration, Easing.OutQuint);
|
topLayerBackground.FadeColour(contracted_top_layer_colour, resize_duration, Easing.OutQuint);
|
||||||
middleLayerBackground.FadeColour(contracted_middle_layer_colour, resize_duration, Easing.OutQuint);
|
middleLayerBackground.FadeColour(contracted_middle_layer_colour, resize_duration, Easing.OutQuint);
|
||||||
|
|
||||||
middleLayerContentContainer.Add(topLayerContent = new ContractedPanelMiddleContent(score).With(d => d.Alpha = 0));
|
middleLayerContentContainer.Add(topLayerContent = new ContractedPanelMiddleContent(Score).With(d => d.Alpha = 0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,5 +222,13 @@ namespace osu.Game.Screens.Ranking
|
|||||||
middleLayerContent?.FadeIn(content_fade_duration);
|
middleLayerContent?.FadeIn(content_fade_duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnClick(ClickEvent e)
|
||||||
|
{
|
||||||
|
if (State == PanelState.Contracted)
|
||||||
|
State = PanelState.Expanded;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
80
osu.Game/Screens/Ranking/ScorePanelList.cs
Normal file
80
osu.Game/Screens/Ranking/ScorePanelList.cs
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
// 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 System.Linq;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Ranking
|
||||||
|
{
|
||||||
|
public class ScorePanelList : CompositeDrawable
|
||||||
|
{
|
||||||
|
private readonly Flow panels;
|
||||||
|
private ScorePanel expandedPanel;
|
||||||
|
|
||||||
|
public ScorePanelList()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
InternalChild = panels = new Flow
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Custom,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddScore(ScoreInfo score)
|
||||||
|
{
|
||||||
|
var panel = new ScorePanel(score)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
};
|
||||||
|
|
||||||
|
panel.StateChanged += s => onPanelStateChanged(panel, s);
|
||||||
|
|
||||||
|
// Todo: Temporary
|
||||||
|
panel.State = expandedPanel == null ? PanelState.Expanded : PanelState.Contracted;
|
||||||
|
|
||||||
|
panels.Add(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveScore(ScoreInfo score) => panels.RemoveAll(p => p.Score == score);
|
||||||
|
|
||||||
|
protected override void UpdateAfterChildren()
|
||||||
|
{
|
||||||
|
base.UpdateAfterChildren();
|
||||||
|
|
||||||
|
if (expandedPanel != null)
|
||||||
|
{
|
||||||
|
var firstPanel = panels.FlowingChildren.First();
|
||||||
|
var target = expandedPanel.DrawPosition.X - firstPanel.DrawPosition.X + expandedPanel.DrawSize.X / 2;
|
||||||
|
|
||||||
|
panels.OriginPosition = new Vector2((float)Interpolation.Lerp(panels.OriginPosition.X, target, Math.Clamp(Math.Abs(Time.Elapsed) / 80, 0, 1)), panels.DrawHeight / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onPanelStateChanged(ScorePanel panel, PanelState state)
|
||||||
|
{
|
||||||
|
if (state == PanelState.Contracted)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (expandedPanel != null)
|
||||||
|
expandedPanel.State = PanelState.Contracted;
|
||||||
|
expandedPanel = panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Flow : FillFlowContainer<ScorePanel>
|
||||||
|
{
|
||||||
|
// Todo: Order is wrong.
|
||||||
|
public override IEnumerable<Drawable> FlowingChildren => AliveInternalChildren.OfType<ScorePanel>().OrderBy(s => s.Score.TotalScore);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user