mirror of
https://github.com/ppy/osu
synced 2025-01-02 20:32:10 +00:00
ScoreRank, Avatar to own files, +DrawableRank
This commit is contained in:
parent
8176b4ef77
commit
650fc7563d
@ -3,7 +3,6 @@
|
||||
|
||||
using osu.Game.Users;
|
||||
using osu.Game.Database;
|
||||
using System.ComponentModel;
|
||||
using osu.Game.Modes.Mods;
|
||||
|
||||
namespace osu.Game.Modes
|
||||
@ -22,34 +21,4 @@ namespace osu.Game.Modes
|
||||
public Replay Replay;
|
||||
public BeatmapInfo Beatmap;
|
||||
}
|
||||
|
||||
public enum ScoreRank
|
||||
{
|
||||
[Description(@"F")]
|
||||
F,
|
||||
|
||||
[Description(@"F")]
|
||||
D,
|
||||
|
||||
[Description(@"C")]
|
||||
C,
|
||||
|
||||
[Description(@"B")]
|
||||
B,
|
||||
|
||||
[Description(@"A")]
|
||||
A,
|
||||
|
||||
[Description(@"S")]
|
||||
S,
|
||||
|
||||
[Description(@"SPlus")]
|
||||
SPlus,
|
||||
|
||||
[Description(@"SS")]
|
||||
SS,
|
||||
|
||||
[Description(@"SSPlus")]
|
||||
SSPlus,
|
||||
}
|
||||
}
|
||||
|
37
osu.Game/Modes/ScoreRank.cs
Normal file
37
osu.Game/Modes/ScoreRank.cs
Normal file
@ -0,0 +1,37 @@
|
||||
// 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.ComponentModel;
|
||||
|
||||
namespace osu.Game.Modes
|
||||
{
|
||||
public enum ScoreRank
|
||||
{
|
||||
[Description(@"F")]
|
||||
F,
|
||||
|
||||
[Description(@"F")]
|
||||
D,
|
||||
|
||||
[Description(@"C")]
|
||||
C,
|
||||
|
||||
[Description(@"B")]
|
||||
B,
|
||||
|
||||
[Description(@"A")]
|
||||
A,
|
||||
|
||||
[Description(@"S")]
|
||||
S,
|
||||
|
||||
[Description(@"SPlus")]
|
||||
SPlus,
|
||||
|
||||
[Description(@"SS")]
|
||||
SS,
|
||||
|
||||
[Description(@"SSPlus")]
|
||||
SSPlus,
|
||||
}
|
||||
}
|
@ -1,16 +1,10 @@
|
||||
// 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.Diagnostics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Online.API;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
@ -49,89 +43,5 @@ namespace osu.Game.Overlays.Toolbar
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public class Avatar : Container
|
||||
{
|
||||
public Drawable Sprite;
|
||||
|
||||
private int userId;
|
||||
private OsuGame game;
|
||||
private Texture guestTexture;
|
||||
|
||||
public Avatar()
|
||||
{
|
||||
Size = new Vector2(32);
|
||||
Anchor = Anchor.CentreLeft;
|
||||
Origin = Anchor.CentreLeft;
|
||||
|
||||
CornerRadius = Size.X / 8;
|
||||
|
||||
EdgeEffect = new EdgeEffect
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Radius = 4,
|
||||
Colour = Color4.Black.Opacity(0.1f),
|
||||
};
|
||||
|
||||
Masking = true;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls:true)]
|
||||
private void load(OsuGame game, TextureStore textures)
|
||||
{
|
||||
this.game = game;
|
||||
|
||||
guestTexture = textures.Get(@"Online/avatar-guest");
|
||||
}
|
||||
|
||||
public int UserId
|
||||
{
|
||||
get { return userId; }
|
||||
set
|
||||
{
|
||||
if (userId == value)
|
||||
return;
|
||||
|
||||
userId = value;
|
||||
|
||||
var newSprite = userId > 1 ? new OnlineSprite($@"https://a.ppy.sh/{userId}") : new Sprite { Texture = guestTexture };
|
||||
|
||||
newSprite.FillMode = FillMode.Fit;
|
||||
|
||||
if (game != null)
|
||||
{
|
||||
newSprite.LoadAsync(game, s =>
|
||||
{
|
||||
Sprite?.FadeOut();
|
||||
Sprite?.Expire();
|
||||
Sprite = s;
|
||||
|
||||
Add(s);
|
||||
|
||||
//todo: fix this... clock dependencies are a pain
|
||||
if (s.Clock != null)
|
||||
s.FadeInFromZero(200);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class OnlineSprite : Sprite
|
||||
{
|
||||
private readonly string url;
|
||||
|
||||
public OnlineSprite(string url)
|
||||
{
|
||||
Debug.Assert(url != null);
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
Texture = textures.Get(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
51
osu.Game/Screens/Select/Leaderboards/DrawableRank.cs
Normal file
51
osu.Game/Screens/Select/Leaderboards/DrawableRank.cs
Normal file
@ -0,0 +1,51 @@
|
||||
// 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.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Game.Modes;
|
||||
|
||||
namespace osu.Game.Screens.Select.Leaderboards
|
||||
{
|
||||
public class DrawableRank : Container
|
||||
{
|
||||
private Sprite sprite;
|
||||
private TextureStore textures;
|
||||
|
||||
private ScoreRank rank;
|
||||
public ScoreRank Rank
|
||||
{
|
||||
get { return rank; }
|
||||
set
|
||||
{
|
||||
if (value == rank) return;
|
||||
rank = value;
|
||||
sprite.Texture = textures.Get($@"Badges/ScoreRanks/{rank.GetDescription()}");
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore ts)
|
||||
{
|
||||
textures = ts;
|
||||
sprite.Texture = textures.Get($@"Badges/ScoreRanks/{rank.GetDescription()}");
|
||||
}
|
||||
|
||||
public DrawableRank(ScoreRank rank)
|
||||
{
|
||||
this.rank = rank;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
sprite = new Sprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -13,10 +13,10 @@ using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Modes;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Allocation;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Game.Modes.Mods;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Screens.Select.Leaderboards
|
||||
{
|
||||
@ -37,7 +37,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
|
||||
private Box background;
|
||||
private Container content, avatarContainer;
|
||||
private Sprite scoreRank;
|
||||
private DrawableRank scoreRank;
|
||||
private OsuSpriteText nameLabel;
|
||||
private GlowingSpriteText scoreLabel;
|
||||
private ScoreComponentLabel maxCombo, accuracy;
|
||||
@ -59,12 +59,6 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
base.OnHoverLost(state);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
scoreRank.Texture = textures.Get($@"Badges/ScoreRanks/{Score.Rank.GetDescription()}");
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
@ -182,7 +176,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
EdgeEffect = imageShadow,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Overlays.Toolbar.ToolbarUserButton.Avatar
|
||||
new Avatar
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
UserId = Score.User.Id,
|
||||
@ -237,7 +231,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
},
|
||||
},
|
||||
},
|
||||
scoreRank = new Sprite
|
||||
scoreRank = new DrawableRank(Score.Rank)
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
|
99
osu.Game/Users/Avatar.cs
Normal file
99
osu.Game/Users/Avatar.cs
Normal file
@ -0,0 +1,99 @@
|
||||
// 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.Diagnostics;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
|
||||
namespace osu.Game.Users
|
||||
{
|
||||
public class Avatar : Container
|
||||
{
|
||||
public Drawable Sprite;
|
||||
|
||||
private int userId;
|
||||
private OsuGame game;
|
||||
private Texture guestTexture;
|
||||
|
||||
public Avatar()
|
||||
{
|
||||
Size = new Vector2(32);
|
||||
Anchor = Anchor.CentreLeft;
|
||||
Origin = Anchor.CentreLeft;
|
||||
|
||||
CornerRadius = Size.X / 8;
|
||||
|
||||
EdgeEffect = new EdgeEffect
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Radius = 4,
|
||||
Colour = Color4.Black.Opacity(0.1f),
|
||||
};
|
||||
|
||||
Masking = true;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(OsuGame game, TextureStore textures)
|
||||
{
|
||||
this.game = game;
|
||||
|
||||
guestTexture = textures.Get(@"Online/avatar-guest");
|
||||
}
|
||||
|
||||
public int UserId
|
||||
{
|
||||
get { return userId; }
|
||||
set
|
||||
{
|
||||
if (userId == value)
|
||||
return;
|
||||
|
||||
userId = value;
|
||||
|
||||
var newSprite = userId > 1 ? new OnlineSprite($@"https://a.ppy.sh/{userId}") : new Sprite { Texture = guestTexture };
|
||||
|
||||
newSprite.FillMode = FillMode.Fit;
|
||||
|
||||
if (game != null)
|
||||
{
|
||||
newSprite.LoadAsync(game, s =>
|
||||
{
|
||||
Sprite?.FadeOut();
|
||||
Sprite?.Expire();
|
||||
Sprite = s;
|
||||
|
||||
Add(s);
|
||||
|
||||
//todo: fix this... clock dependencies are a pain
|
||||
if (s.Clock != null)
|
||||
s.FadeInFromZero(200);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class OnlineSprite : Sprite
|
||||
{
|
||||
private readonly string url;
|
||||
|
||||
public OnlineSprite(string url)
|
||||
{
|
||||
Debug.Assert(url != null);
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
Texture = textures.Get(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -333,6 +333,9 @@
|
||||
<Compile Include="Graphics\UserInterface\IHasDrawableRepresentation.cs" />
|
||||
<Compile Include="Users\Region.cs" />
|
||||
<Compile Include="Users\Badge.cs" />
|
||||
<Compile Include="Modes\ScoreRank.cs" />
|
||||
<Compile Include="Users\Avatar.cs" />
|
||||
<Compile Include="Screens\Select\Leaderboards\DrawableRank.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||
|
Loading…
Reference in New Issue
Block a user