mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 19:22:54 +08:00
Basic implementation of score UI
This commit is contained in:
parent
3c714fe056
commit
a112b354f0
29
osu.Desktop.VisualTests/Tests/TestCaseLeaderboard.cs
Normal file
29
osu.Desktop.VisualTests/Tests/TestCaseLeaderboard.cs
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Screens.Testing;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Screens.Select.Leaderboards;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Desktop.VisualTests
|
||||
{
|
||||
public class TestCaseLeaderboard : TestCase
|
||||
{
|
||||
public override string Name => @"Leaderboard";
|
||||
public override string Description => @"From song select";
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
|
||||
Add(new Leaderboard
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Size = new Vector2(550f, 450f),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -198,6 +198,7 @@
|
||||
<Compile Include="Tests\TestCaseModSelectOverlay.cs" />
|
||||
<Compile Include="Tests\TestCaseDialogOverlay.cs" />
|
||||
<Compile Include="Tests\TestCaseBeatmapOptionsOverlay.cs" />
|
||||
<Compile Include="Tests\TestCaseLeaderboard.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
|
@ -97,6 +97,8 @@ namespace osu.Game.Overlays
|
||||
if (!string.IsNullOrEmpty(postText))
|
||||
{
|
||||
//todo: actually send to server
|
||||
|
||||
|
||||
careChannels.FirstOrDefault()?.AddNewMessages(new[]
|
||||
{
|
||||
new Message
|
||||
|
71
osu.Game/Screens/Select/Leaderboards/Leaderboard.cs
Normal file
71
osu.Game/Screens/Select/Leaderboards/Leaderboard.cs
Normal file
@ -0,0 +1,71 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Modes;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.MathUtils;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Screens.Select.Leaderboards
|
||||
{
|
||||
public class Leaderboard : Container
|
||||
{
|
||||
private FillFlowContainer scrollFlow;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
scrollFlow.Add(new LeaderboardScoreDisplay(new LeaderboardScore
|
||||
{
|
||||
Avatar = textures.Get(@"Online/avatar-guest"),
|
||||
Flag = textures.Get(@"Flags/__"),
|
||||
Name = @"ultralaserxx",
|
||||
MaxCombo = RNG.Next(0, 3000),
|
||||
Accuracy = Math.Round(RNG.NextDouble(0, 100), 2),
|
||||
Score = RNG.Next(0, 1000000),
|
||||
Mods = new Mod[] { },
|
||||
}, i + 1));
|
||||
}
|
||||
}
|
||||
|
||||
public Leaderboard()
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ScrollDraggerVisible = false,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
scrollFlow = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Spacing = new Vector2(0f, 5f),
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class LeaderboardScore
|
||||
{
|
||||
public Texture Avatar;
|
||||
public Texture Flag;
|
||||
public Texture Badge;
|
||||
public string Name;
|
||||
public int MaxCombo;
|
||||
public double Accuracy;
|
||||
public int Score;
|
||||
public IEnumerable<Mod> Mods;
|
||||
}
|
||||
}
|
271
osu.Game/Screens/Select/Leaderboards/LeaderboardScoreDisplay.cs
Normal file
271
osu.Game/Screens/Select/Leaderboards/LeaderboardScoreDisplay.cs
Normal file
@ -0,0 +1,271 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Screens.Select.Leaderboards
|
||||
{
|
||||
public class LeaderboardScoreDisplay : Container
|
||||
{
|
||||
private const float height = 70;
|
||||
private const float corner_radius = 5;
|
||||
private const float edge_margin = 10;
|
||||
private const float background_opacity = 0.25f;
|
||||
private const float score_letter_size = 20f;
|
||||
|
||||
private Box background;
|
||||
|
||||
public readonly LeaderboardScore Score;
|
||||
|
||||
protected override bool OnHover(Framework.Input.InputState state)
|
||||
{
|
||||
background.FadeColour(Color4.Black.Opacity(0.5f), 300, EasingTypes.OutQuint);
|
||||
return base.OnHover(state);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(Framework.Input.InputState state)
|
||||
{
|
||||
background.FadeColour(Color4.Black.Opacity(background_opacity), 200, EasingTypes.OutQuint);
|
||||
base.OnHoverLost(state);
|
||||
}
|
||||
|
||||
public LeaderboardScoreDisplay(LeaderboardScore score, int index)
|
||||
{
|
||||
Score = score;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = height;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 40,
|
||||
Children = new[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Font = @"Exo2.0-MediumItalic",
|
||||
TextSize = 22,
|
||||
Text = index.ToString(),
|
||||
},
|
||||
},
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Left = 40, },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
CornerRadius = corner_radius,
|
||||
Masking = true,
|
||||
Children = new[]
|
||||
{
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black.Opacity(background_opacity),
|
||||
},
|
||||
},
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(edge_margin),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
Size = new Vector2(height - edge_margin * 2, height - edge_margin * 2),
|
||||
CornerRadius = corner_radius,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Sprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
FillMode = FillMode.Fill,
|
||||
Texture = Score.Avatar,
|
||||
},
|
||||
},
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
Position = new Vector2(height - edge_margin, 0f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = Score.Name,
|
||||
Font = @"Exo2.0-BoldItalic",
|
||||
TextSize = 23,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Right,
|
||||
Spacing = new Vector2(10f, 0f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Size = new Vector2(87f, 20f),
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Sprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 30f,
|
||||
Texture = Score.Flag,
|
||||
},
|
||||
new Sprite
|
||||
{
|
||||
Origin = Anchor.BottomRight,
|
||||
Anchor = Anchor.BottomRight,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 50f,
|
||||
Texture = Score.Badge,
|
||||
},
|
||||
},
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Right,
|
||||
Spacing = new Vector2(10f, 0f),
|
||||
Margin = new MarginPadding { Left = 10, },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ScoreComponentLabel(FontAwesome.fa_circle_o, Score.MaxCombo.ToString()),
|
||||
new ScoreComponentLabel(FontAwesome.fa_circle_o, Score.Accuracy.ToString()),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
new Sprite
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Size = new Vector2(score_letter_size),
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Position = new Vector2(-score_letter_size - 5f, 0f),
|
||||
Font = @"Venera",
|
||||
Text = Score.Score.ToString(),
|
||||
TextSize = 23,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
// TODO: Probably remove? Seems like others don't like this kind of thing
|
||||
Position = new Vector2(0f, 4f), //properly align the mod icons
|
||||
Direction = FillDirection.Left,
|
||||
Children = new[]
|
||||
{
|
||||
new ScoreModIcon(FontAwesome.fa_osu_mod_doubletime, OsuColour.FromHex(@"ffcc22")),
|
||||
new ScoreModIcon(FontAwesome.fa_osu_mod_flashlight, OsuColour.FromHex(@"ffcc22")),
|
||||
new ScoreModIcon(FontAwesome.fa_osu_mod_hidden, OsuColour.FromHex(@"ffcc22")),
|
||||
new ScoreModIcon(FontAwesome.fa_osu_mod_hardrock, OsuColour.FromHex(@"ffcc22")),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
class ScoreModIcon : Container
|
||||
{
|
||||
public ScoreModIcon(FontAwesome icon, Color4 colour)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
Children = new[]
|
||||
{
|
||||
new TextAwesome
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Icon = FontAwesome.fa_osu_mod_bg,
|
||||
Colour = colour,
|
||||
Shadow = true,
|
||||
TextSize = 30,
|
||||
},
|
||||
new TextAwesome
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Icon = icon,
|
||||
Colour = OsuColour.Gray(84),
|
||||
TextSize = 18,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class ScoreComponentLabel : Container
|
||||
{
|
||||
public ScoreComponentLabel(FontAwesome icon, string value)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft;
|
||||
Origin = Anchor.CentreLeft;
|
||||
Size = new Vector2(60f, 20f);
|
||||
Padding = new MarginPadding { Top = 10f, };
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new TextAwesome
|
||||
{
|
||||
Icon = FontAwesome.fa_square,
|
||||
Colour = OsuColour.FromHex(@"3087ac"),
|
||||
Rotation = 45,
|
||||
Shadow = true,
|
||||
},
|
||||
new TextAwesome
|
||||
{
|
||||
Icon = icon,
|
||||
Colour = OsuColour.FromHex(@"a4edff"),
|
||||
Scale = new Vector2(0.8f),
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Origin = Anchor.CentreLeft,
|
||||
Margin = new MarginPadding { Left = 15, },
|
||||
Font = @"Exo2.0-Bold",
|
||||
Text = value,
|
||||
TextSize = 17,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -310,6 +310,8 @@
|
||||
<Compile Include="Screens\Select\Options\BeatmapOptionsEditButton.cs" />
|
||||
<Compile Include="Screens\Select\Options\BeatmapOptionsOverlay.cs" />
|
||||
<Compile Include="Screens\Select\Options\BeatmapOptionsRemoveFromUnplayedButton.cs" />
|
||||
<Compile Include="Screens\Select\Leaderboards\Leaderboard.cs" />
|
||||
<Compile Include="Screens\Select\Leaderboards\LeaderboardScoreDisplay.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||
@ -331,6 +333,9 @@
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<Folder Include="Screens\Select\Leaderboards\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
Loading…
Reference in New Issue
Block a user