1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 16:07:24 +08:00
This commit is contained in:
jorolf 2018-12-22 16:51:24 +01:00
parent a54951b72d
commit b4fa2d9049
11 changed files with 981 additions and 269 deletions

View File

@ -38,6 +38,7 @@ namespace osu.Game.Tests.Visual
Country = new Country { FlagName = @"AU" },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
IsSupporter = true,
SupportLevel = 3,
}) { Width = 300 },
},
});

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Overlays;
@ -27,7 +28,9 @@ namespace osu.Game.Tests.Visual
typeof(UserProfileOverlay),
typeof(RankGraph),
typeof(LineGraph),
typeof(BadgeContainer)
typeof(BadgeContainer),
typeof(SectionsContainer<>),
typeof(SupporterIcon)
};
public TestCaseUserProfile()
@ -58,6 +61,11 @@ namespace osu.Game.Tests.Visual
{
Ranks = new UserStatistics.UserRanks { Global = 2148, Country = 1 },
PP = 4567.89m,
Level = new UserStatistics.LevelInfo
{
Current = 727,
Progress = 69,
}
},
RankHistory = new User.RankHistoryData
{
@ -72,7 +80,10 @@ namespace osu.Game.Tests.Visual
Description = "Outstanding help by being a voluntary test subject.",
ImageUrl = "https://assets.ppy.sh/profile-badges/contributor.jpg"
}
}
},
Title = "osu!volunteer",
Colour = "ff0000",
Achievements = new User.UserAchievement[0],
}, false));
checkSupporterTag(false);

View File

@ -33,7 +33,8 @@ namespace osu.Game.Graphics.Containers
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
HoverColour = colours.Yellow;
if(HoverColour == default)
HoverColour = colours.Yellow;
}
protected override void LoadComplete()

View File

@ -92,5 +92,15 @@ namespace osu.Game.Graphics
public readonly Color4 ChatBlue = FromHex(@"17292e");
public readonly Color4 ContextMenuGray = FromHex(@"223034");
public readonly Color4 CommunityUserGreenLight = FromHex(@"deff87");
public readonly Color4 CommunityUserGreen = FromHex(@"05ffa2");
public readonly Color4 CommunityUserGreenDark = FromHex(@"a6cc00");
public readonly Color4 CommunityUserGrayGreenLighter = FromHex(@"9ebab1");
public readonly Color4 CommunityUserGrayGreenLight = FromHex(@"77998e");
public readonly Color4 CommunityUserGrayGreen = FromHex(@"4e7466");
public readonly Color4 CommunityUserGrayGreenDark = FromHex(@"33413c");
public readonly Color4 CommunityUserGrayGreenDarker = FromHex(@"2c3532");
public readonly Color4 CommunityUserGrayGreenDarkest = FromHex(@"1e2422");
}
}

View File

@ -7,7 +7,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds;
using osuTK;
namespace osu.Game.Overlays.Profile.Header
@ -15,50 +14,73 @@ namespace osu.Game.Overlays.Profile.Header
public class SupporterIcon : CircularContainer, IHasTooltip
{
private readonly Box background;
private readonly FillFlowContainer iconContainer;
public string TooltipText => "osu!supporter";
public int SupporterLevel
{
set
{
if (value == 0)
{
Hide();
}
else
{
Show();
iconContainer.Clear();
for (int i = 0; i < value; i++)
{
iconContainer.Add(new SpriteIcon
{
Width = 12,
RelativeSizeAxes = Axes.Y,
Icon = FontAwesome.fa_heart,
});
}
}
}
}
public SupporterIcon()
{
Masking = true;
AutoSizeAxes = Axes.X;
Hide();
Children = new Drawable[]
{
new Box { RelativeSizeAxes = Axes.Both },
new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Scale = new Vector2(0.8f),
Masking = true,
Children = new Drawable[]
{
background = new Box { RelativeSizeAxes = Axes.Both },
new Triangles
{
TriangleScale = 0.2f,
ColourLight = OsuColour.FromHex(@"ff7db7"),
ColourDark = OsuColour.FromHex(@"de5b95"),
RelativeSizeAxes = Axes.Both,
Velocity = 0.3f,
},
}
},
new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Icon = FontAwesome.fa_heart,
Scale = new Vector2(0.45f),
}
background = new Box { RelativeSizeAxes = Axes.Both },
iconContainer = new FillFlowContainer
{
Direction = FillDirection.Horizontal,
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Height = 0.6f,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}
};
}
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
{
bool invalid = base.Invalidate(invalidation, source, shallPropagate);
if ((invalidation & Invalidation.DrawSize) != 0)
{
iconContainer.Padding = new MarginPadding { Horizontal = DrawHeight / 2 };
}
return invalid;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
background.Colour = colours.Pink;
iconContainer.Colour = colours.CommunityUserGrayGreenDark;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@ namespace osu.Game.Overlays
private SectionsContainer<ProfileSection> sectionsContainer;
private ProfileTabControl tabs;
public const float CONTENT_X_MARGIN = 50;
public const float CONTENT_X_MARGIN = 70;
public UserProfileOverlay()
{
@ -113,12 +113,10 @@ namespace osu.Game.Overlays
Colour = OsuColour.Gray(0.2f)
});
Header = new ProfileHeader(user);
Add(sectionsContainer = new SectionsContainer<ProfileSection>
{
RelativeSizeAxes = Axes.Both,
ExpandableHeader = Header,
ExpandableHeader = Header = new ProfileHeader(),
FixedHeader = tabs,
HeaderBackground = new Box
{

View File

@ -59,6 +59,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 +74,9 @@ namespace osu.Game.Users
[JsonProperty(@"is_active")]
public bool Active;
[JsonProperty(@"pm_friends_only")]
public bool PMFriendsOnly;
[JsonProperty(@"interests")]
public string Interests;
@ -104,6 +110,9 @@ namespace osu.Game.Users
[JsonProperty(@"post_count")]
public int PostCount;
[JsonProperty(@"follower_count")]
public int[] FollowerCount;
[JsonProperty(@"playstyle")]
public string[] PlayStyle;
@ -143,6 +152,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>

View File

@ -185,8 +185,8 @@ namespace osu.Game.Users
{
infoContainer.Add(new SupporterIcon
{
RelativeSizeAxes = Axes.Y,
Width = 20f,
Height = 20f,
SupporterLevel = user.SupportLevel
});
}

View File

@ -1,7 +1,9 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using Newtonsoft.Json;
using osu.Game.Scoring;
namespace osu.Game.Users
{
@ -37,6 +39,9 @@ namespace osu.Game.Users
[JsonProperty(@"play_count")]
public int PlayCount;
[JsonProperty(@"play_time")]
public int? PlayTime;
[JsonProperty(@"total_score")]
public long TotalScore;
@ -68,6 +73,19 @@ namespace osu.Game.Users
[JsonProperty(@"a")]
public int A;
public int GetForScoreRank(ScoreRank rank)
{
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

View File

@ -208,6 +208,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MD/@EntryIndexedValue">MD5</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NS/@EntryIndexedValue">NS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OS/@EntryIndexedValue">OS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PM/@EntryIndexedValue">PM</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RGB/@EntryIndexedValue">RGB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RNG/@EntryIndexedValue">RNG</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SHA/@EntryIndexedValue">SHA</s:String>