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

Basic implementation

This commit is contained in:
Andrei Zavatski 2019-07-14 12:34:12 +03:00
parent 80f7d5a0a3
commit 0584ee9ce5
2 changed files with 176 additions and 0 deletions

View File

@ -0,0 +1,97 @@
// 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.Screens.Select.Details;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osuTK.Graphics;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Scoring;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Users;
namespace osu.Game.Tests.Visual.SongSelect
{
public class TestSceneUserTopScore : OsuTestScene
{
private readonly UserTopScoreContainer topScoreContainer;
private readonly APILegacyUserTopScoreInfo[] scores;
public TestSceneUserTopScore()
{
Add(new Container
{
Origin = Anchor.BottomCentre,
Anchor = Anchor.Centre,
AutoSizeAxes = Axes.Y,
Width = 500,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.DarkGreen,
},
topScoreContainer = new UserTopScoreContainer
{
Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre,
}
}
});
AddStep(@"Trigger visibility", topScoreContainer.ToggleVisibility);
AddStep(@"Add score", () => topScoreContainer.TopScore = scores[0]);
AddStep(@"Add another score", () => topScoreContainer.TopScore = scores[1]);
scores = new APILegacyUserTopScoreInfo[]
{
new APILegacyUserTopScoreInfo
{
Position = 999,
Score = new APILegacyScoreInfo
{
Rank = ScoreRank.XH,
Accuracy = 1,
MaxCombo = 244,
TotalScore = 1707827,
Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
User = new User
{
Id = 6602580,
Username = @"waaiiru",
Country = new Country
{
FullName = @"Spain",
FlagName = @"ES",
},
},
}
},
new APILegacyUserTopScoreInfo
{
Position = 110000,
Score = new APILegacyScoreInfo
{
Rank = ScoreRank.X,
Accuracy = 1,
MaxCombo = 244,
TotalScore = 1707827,
User = new User
{
Id = 4608074,
Username = @"Skycries",
Country = new Country
{
FullName = @"Brazil",
FlagName = @"BR",
},
},
}
}
};
}
}
}

View File

@ -0,0 +1,79 @@
// 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.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Leaderboards;
namespace osu.Game.Screens.Select.Details
{
public class UserTopScoreContainer : VisibilityContainer
{
private const int height = 150;
private const int duration = 300;
private readonly Container contentContainer;
private readonly Container scoreContainer;
public APILegacyUserTopScoreInfo TopScore
{
set
{
scoreContainer.Clear();
scoreContainer.Add(new LeaderboardScore(value.Score, value.Position));
}
}
protected override bool StartHidden => true;
public UserTopScoreContainer()
{
RelativeSizeAxes = Axes.X;
Height = height;
Anchor = Anchor.BottomCentre;
Origin = Anchor.BottomCentre;
Children = new Drawable[]
{
contentContainer = new Container
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Height = height,
RelativeSizeAxes = Axes.X,
Children = new Drawable[]
{
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = @"your personal best".ToUpper(),
Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold),
},
scoreContainer = new Container
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
}
}
}
};
}
protected override void PopIn()
{
this.ResizeHeightTo(height, duration, Easing.OutQuint);
contentContainer.FadeIn(duration, Easing.OutQuint);
}
protected override void PopOut()
{
this.ResizeHeightTo(0, duration, Easing.OutQuint);
contentContainer.FadeOut(duration, Easing.OutQuint);
}
}
}