mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Flags(redoing later), glowing text, proper Score and User usage
This commit is contained in:
parent
d1bad34434
commit
269c139d2a
@ -1,17 +1,18 @@
|
||||
// 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 System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Screens.Testing;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Screens.Select.Leaderboards;
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Allocation;
|
||||
using System;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Screens.Select.Leaderboards;
|
||||
using osu.Game.Modes;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Desktop.VisualTests
|
||||
{
|
||||
@ -21,28 +22,24 @@ namespace osu.Desktop.VisualTests
|
||||
public override string Description => @"From song select";
|
||||
|
||||
private Leaderboard leaderboard;
|
||||
private TextureStore ts;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
ts = textures;
|
||||
}
|
||||
|
||||
private void newScores()
|
||||
{
|
||||
var scores = new List<LeaderboardScore>();
|
||||
var scores = new List<Score>();
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
scores.Add(new LeaderboardScore
|
||||
scores.Add(new Score
|
||||
{
|
||||
Name = @"ultralaserxx",
|
||||
Avatar = ts.Get(@"Online/avatar-guest"),
|
||||
Flag = ts.Get(@"Flags/__"),
|
||||
Score = RNG.Next(0, 1000000),
|
||||
Accuracy = Math.Round(RNG.NextDouble(0, 100), 2),
|
||||
MaxCombo = RNG.Next(0, 3000),
|
||||
Mods = new Mod[] { },
|
||||
TotalScore = RNG.Next(1, 1000000),
|
||||
Mods = Ruleset.GetRuleset(PlayMode.Osu).GetModsFor(ModType.DifficultyIncrease).ToArray(),
|
||||
User = new Game.Users.User
|
||||
{
|
||||
Id = 2,
|
||||
Username = @"peppy",
|
||||
FlagName = @"AU",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
// 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.Game.Users;
|
||||
|
||||
namespace osu.Game.Modes
|
||||
{
|
||||
public class Score
|
||||
@ -10,5 +12,7 @@ namespace osu.Game.Modes
|
||||
public double Combo { get; set; }
|
||||
public double MaxCombo { get; set; }
|
||||
public double Health { get; set; }
|
||||
public Mod[] Mods { get; set; }
|
||||
public User User { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,28 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Modes;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
|
||||
namespace osu.Game.Screens.Select.Leaderboards
|
||||
{
|
||||
public class Leaderboard : Container
|
||||
{
|
||||
private ScrollContainer scrollContainer;
|
||||
private FillFlowContainer<LeaderboardScoreDisplay> scrollFlow;
|
||||
|
||||
private LeaderboardScore[] scores;
|
||||
public LeaderboardScore[] Scores
|
||||
private Score[] scores;
|
||||
public Score[] Scores
|
||||
{
|
||||
get { return scores; }
|
||||
set
|
||||
@ -30,6 +37,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
}
|
||||
|
||||
scrollFlow.Children = scoreDisplays;
|
||||
scrollContainer.ScrollTo(0f, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +45,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ScrollContainer
|
||||
scrollContainer = new ScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ScrollDraggerVisible = false,
|
||||
@ -55,15 +63,28 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
}
|
||||
}
|
||||
|
||||
public class LeaderboardScore
|
||||
class LeaderboardFade : Container
|
||||
{
|
||||
public string Name;
|
||||
public Texture Avatar;
|
||||
public Texture Flag;
|
||||
public Texture Badge;
|
||||
public int Score;
|
||||
public double Accuracy;
|
||||
public int MaxCombo;
|
||||
public IEnumerable<Mod> Mods;
|
||||
private Box gradient;
|
||||
|
||||
protected override bool OnMouseDown(Framework.Input.InputState state, Framework.Input.MouseDownEventArgs args)
|
||||
{
|
||||
if (state.Keyboard.ShiftPressed)
|
||||
FadeIn();
|
||||
else
|
||||
FadeOut();
|
||||
|
||||
return base.OnMouseDown(state, args);
|
||||
}
|
||||
|
||||
public void FadeIn()
|
||||
{
|
||||
gradient.FadeColour(Color4.White, 300, EasingTypes.OutQuint);
|
||||
}
|
||||
|
||||
public void FadeOut()
|
||||
{
|
||||
gradient.FadeColour(Color4.White.Opacity(0), 300, EasingTypes.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ using osu.Framework.Graphics.Transforms;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Modes;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Allocation;
|
||||
|
||||
namespace osu.Game.Screens.Select.Leaderboards
|
||||
{
|
||||
@ -22,12 +24,27 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
private const float background_opacity = 0.25f;
|
||||
private const float score_letter_size = 20f;
|
||||
|
||||
private readonly EdgeEffect imageShadow = new EdgeEffect
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Radius = 1,
|
||||
Colour = Color4.Black.Opacity(0.2f),
|
||||
};
|
||||
|
||||
private Box background;
|
||||
private Container content;
|
||||
private Sprite avatar, flag;
|
||||
private FillFlowContainer<ScoreModIcon> modsContainer;
|
||||
|
||||
private readonly int index;
|
||||
public readonly LeaderboardScore Score;
|
||||
public readonly Score Score;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
avatar.Texture = textures.Get($@"https://a.ppy.sh/{Score.User.Id}") ?? textures.Get(@"Online/avatar-guest");
|
||||
flag.Texture = textures.Get($@"Flags/{Score.User.FlagName}");
|
||||
}
|
||||
|
||||
protected override bool OnHover(Framework.Input.InputState state)
|
||||
{
|
||||
@ -45,17 +62,18 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
FadeTo(0.01f); // TODO: This is hacky, find a better way
|
||||
// TODO: This is hacky, find a better way
|
||||
FadeTo(0.01f);
|
||||
content.MoveToX(DrawSize.X);
|
||||
Delay(index * 50);
|
||||
Schedule(() =>
|
||||
{
|
||||
FadeInFromZero(200);
|
||||
content.MoveToX(DrawSize.X);
|
||||
content.MoveToX(0, 500, EasingTypes.OutQuint);
|
||||
});
|
||||
}
|
||||
|
||||
public LeaderboardScoreDisplay(LeaderboardScore score, int i)
|
||||
public LeaderboardScoreDisplay(Score score, int i)
|
||||
{
|
||||
Score = score;
|
||||
index = i;
|
||||
@ -112,13 +130,12 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
Size = new Vector2(height - edge_margin * 2, height - edge_margin * 2),
|
||||
CornerRadius = corner_radius,
|
||||
Masking = true,
|
||||
EdgeEffect = imageShadow,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Sprite
|
||||
avatar = new Sprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
FillMode = FillMode.Fill,
|
||||
Texture = Score.Avatar,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -131,7 +148,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = Score.Name,
|
||||
Text = Score.User?.Username,
|
||||
Font = @"Exo2.0-BoldItalic",
|
||||
TextSize = 23,
|
||||
},
|
||||
@ -152,11 +169,10 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Sprite
|
||||
flag = new Sprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 30f,
|
||||
Texture = Score.Flag,
|
||||
},
|
||||
new Sprite
|
||||
{
|
||||
@ -164,7 +180,6 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
Anchor = Anchor.BottomRight,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 50f,
|
||||
Texture = Score.Badge,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -190,14 +205,11 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
Origin = Anchor.TopRight,
|
||||
Size = new Vector2(score_letter_size),
|
||||
},
|
||||
new OsuSpriteText
|
||||
new GlowingSpriteText(string.Format("{0:n0}", Score.TotalScore), @"Venera", 23, Color4.White, OsuColour.FromHex(@"83ccfa"))
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Position = new Vector2(-score_letter_size - 5f, 0f),
|
||||
Font = @"Venera",
|
||||
Text = Score.Score.ToString(),
|
||||
TextSize = 23,
|
||||
},
|
||||
modsContainer = new FillFlowContainer<ScoreModIcon>
|
||||
{
|
||||
@ -221,6 +233,51 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
}
|
||||
}
|
||||
|
||||
class GlowingSpriteText : Container
|
||||
{
|
||||
public GlowingSpriteText(string text, string font, int textSize, Color4 textColour, Color4 glowColour)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new BufferedContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
BlurSigma = new Vector2(4),
|
||||
CacheDrawnFrameBuffer = true,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
BlendingMode = BlendingMode.Additive,
|
||||
Size = new Vector2(3f),
|
||||
Children = new[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = font,
|
||||
TextSize = textSize,
|
||||
Text = text,
|
||||
Colour = glowColour,
|
||||
Shadow = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = font,
|
||||
TextSize = textSize,
|
||||
Text = text,
|
||||
Colour = textColour,
|
||||
Shadow = false,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class ScoreModIcon : Container
|
||||
{
|
||||
public ScoreModIcon(FontAwesome icon, Color4 colour)
|
||||
@ -274,13 +331,10 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
Colour = OsuColour.FromHex(@"a4edff"),
|
||||
Scale = new Vector2(0.8f),
|
||||
},
|
||||
new OsuSpriteText
|
||||
new GlowingSpriteText(value, @"Exo2.0-Bold", 17, Color4.White, OsuColour.FromHex(@"83ccfa"))
|
||||
{
|
||||
Origin = Anchor.CentreLeft,
|
||||
Margin = new MarginPadding { Left = 15, },
|
||||
Font = @"Exo2.0-Bold",
|
||||
Text = value,
|
||||
TextSize = 17,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ using osu.Framework.Threading;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Screens.Select.Options;
|
||||
using osu.Game.Screens.Select.Leaderboards;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
|
@ -7,5 +7,10 @@ namespace osu.Game.Users
|
||||
{
|
||||
public int Id;
|
||||
public string Username;
|
||||
|
||||
/// <summary>
|
||||
/// Two-letter flag acronym (ISO 3166 standard)
|
||||
/// </summary>
|
||||
public string FlagName;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user