mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 23:53:51 +09:00
Merge remote-tracking branch 'upstream/master' into user-status-wiring
This commit is contained in:
@ -2,6 +2,8 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Bindables;
|
||||
|
||||
@ -59,6 +61,9 @@ namespace osu.Game.Users
|
||||
[JsonProperty(@"is_supporter")]
|
||||
public bool IsSupporter;
|
||||
|
||||
[JsonProperty(@"support_level")]
|
||||
public int SupportLevel;
|
||||
|
||||
[JsonProperty(@"is_gmt")]
|
||||
public bool IsGMT;
|
||||
|
||||
@ -71,6 +76,9 @@ namespace osu.Game.Users
|
||||
[JsonProperty(@"is_active")]
|
||||
public bool Active;
|
||||
|
||||
[JsonProperty(@"pm_friends_only")]
|
||||
public bool PMFriendsOnly;
|
||||
|
||||
[JsonProperty(@"interests")]
|
||||
public string Interests;
|
||||
|
||||
@ -104,8 +112,16 @@ namespace osu.Game.Users
|
||||
[JsonProperty(@"post_count")]
|
||||
public int PostCount;
|
||||
|
||||
[JsonProperty(@"playstyle")]
|
||||
public string[] PlayStyle;
|
||||
[JsonProperty(@"follower_count")]
|
||||
public int[] FollowerCount;
|
||||
|
||||
[JsonProperty]
|
||||
private string[] playstyle
|
||||
{
|
||||
set { PlayStyles = value?.Select(str => Enum.Parse(typeof(PlayStyle), str, true)).Cast<PlayStyle>().ToArray(); }
|
||||
}
|
||||
|
||||
public PlayStyle[] PlayStyles;
|
||||
|
||||
[JsonProperty(@"playmode")]
|
||||
public string PlayMode;
|
||||
@ -143,6 +159,18 @@ namespace osu.Game.Users
|
||||
[JsonProperty("badges")]
|
||||
public Badge[] Badges;
|
||||
|
||||
[JsonProperty("user_achievements")]
|
||||
public UserAchievement[] Achievements;
|
||||
|
||||
public class UserAchievement
|
||||
{
|
||||
[JsonProperty("achieved_at")]
|
||||
public DateTimeOffset AchievedAt;
|
||||
|
||||
[JsonProperty("achievement_id")]
|
||||
public int ID;
|
||||
}
|
||||
|
||||
public override string ToString() => Username;
|
||||
|
||||
/// <summary>
|
||||
@ -153,5 +181,20 @@ namespace osu.Game.Users
|
||||
Username = "system",
|
||||
Id = 0
|
||||
};
|
||||
|
||||
public enum PlayStyle
|
||||
{
|
||||
[Description("Keyboard")]
|
||||
Keyboard,
|
||||
|
||||
[Description("Mouse")]
|
||||
Mouse,
|
||||
|
||||
[Description("Tablet")]
|
||||
Tablet,
|
||||
|
||||
[Description("Touch Screen")]
|
||||
Touch,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +1,52 @@
|
||||
// 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.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Users
|
||||
{
|
||||
public class UserCoverBackground : Sprite
|
||||
public class UserCoverBackground : ModelBackedDrawable<User>
|
||||
{
|
||||
private readonly User user;
|
||||
|
||||
public UserCoverBackground(User user)
|
||||
public User User
|
||||
{
|
||||
this.user = user;
|
||||
get => Model;
|
||||
set => Model = value;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(LargeTextureStore textures)
|
||||
{
|
||||
if (textures == null)
|
||||
throw new ArgumentNullException(nameof(textures));
|
||||
[Resolved]
|
||||
private LargeTextureStore textures { get; set; }
|
||||
|
||||
if (!string.IsNullOrEmpty(user.CoverUrl))
|
||||
Texture = textures.Get(user.CoverUrl);
|
||||
protected override Drawable CreateDrawable(User user)
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
return new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.1f), Color4.Black.Opacity(0.75f))
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var sprite = new Sprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Texture = textures.Get(user.CoverUrl),
|
||||
FillMode = FillMode.Fill,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
};
|
||||
sprite.OnLoadComplete += d => d.FadeInFromZero(400);
|
||||
return sprite;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,9 +16,10 @@ using osu.Game.Overlays;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Overlays.Profile.Header;
|
||||
using osu.Game.Overlays.Profile.Header.Components;
|
||||
|
||||
namespace osu.Game.Users
|
||||
{
|
||||
@ -76,12 +77,12 @@ namespace osu.Game.Users
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new DelayedLoadWrapper(coverBackground = new UserCoverBackground(user)
|
||||
new DelayedLoadWrapper(coverBackground = new UserCoverBackground
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
FillMode = FillMode.Fill,
|
||||
User = user,
|
||||
}, 300) { RelativeSizeAxes = Axes.Both },
|
||||
new Box
|
||||
{
|
||||
@ -189,8 +190,8 @@ namespace osu.Game.Users
|
||||
{
|
||||
infoContainer.Add(new SupporterIcon
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 20f,
|
||||
Height = 20f,
|
||||
SupportLevel = user.SupportLevel
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
// 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 Newtonsoft.Json;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Users
|
||||
{
|
||||
@ -40,6 +42,9 @@ namespace osu.Game.Users
|
||||
[JsonProperty(@"play_count")]
|
||||
public int PlayCount;
|
||||
|
||||
[JsonProperty(@"play_time")]
|
||||
public int? PlayTime;
|
||||
|
||||
[JsonProperty(@"total_score")]
|
||||
public long TotalScore;
|
||||
|
||||
@ -71,6 +76,28 @@ namespace osu.Game.Users
|
||||
|
||||
[JsonProperty(@"a")]
|
||||
public int A;
|
||||
|
||||
public int this[ScoreRank rank]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (rank)
|
||||
{
|
||||
case ScoreRank.XH:
|
||||
return SSPlus;
|
||||
case ScoreRank.X:
|
||||
return SS;
|
||||
case ScoreRank.SH:
|
||||
return SPlus;
|
||||
case ScoreRank.S:
|
||||
return S;
|
||||
case ScoreRank.A:
|
||||
return A;
|
||||
default:
|
||||
throw new ArgumentException($"API does not return {rank.ToString()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct UserRanks
|
||||
|
Reference in New Issue
Block a user