mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
Apply most suggestions
This commit is contained in:
parent
bb6e57169f
commit
2525f5bcb7
@ -87,8 +87,6 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
AddStep("Show offline dummy", () => profile.ShowUser(TEST_USER, false));
|
AddStep("Show offline dummy", () => profile.ShowUser(TEST_USER, false));
|
||||||
|
|
||||||
checkSupporterTag(false);
|
|
||||||
|
|
||||||
AddStep("Show null dummy", () => profile.ShowUser(new User
|
AddStep("Show null dummy", () => profile.ShowUser(new User
|
||||||
{
|
{
|
||||||
Username = @"Null",
|
Username = @"Null",
|
||||||
@ -104,8 +102,6 @@ namespace osu.Game.Tests.Visual
|
|||||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg"
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg"
|
||||||
}, api.IsLoggedIn));
|
}, api.IsLoggedIn));
|
||||||
|
|
||||||
checkSupporterTag(true);
|
|
||||||
|
|
||||||
AddStep("Show flyte", () => profile.ShowUser(new User
|
AddStep("Show flyte", () => profile.ShowUser(new User
|
||||||
{
|
{
|
||||||
Username = @"flyte",
|
Username = @"flyte",
|
||||||
@ -118,15 +114,6 @@ namespace osu.Game.Tests.Visual
|
|||||||
AddStep("Show without reload", profile.Show);
|
AddStep("Show without reload", profile.Show);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkSupporterTag(bool isSupporter)
|
|
||||||
{
|
|
||||||
AddUntilStep(() => profile.Header.User != null, "wait for load");
|
|
||||||
if (isSupporter)
|
|
||||||
AddAssert("is supporter", () => profile.Header.SupporterTag.Alpha == 1);
|
|
||||||
else
|
|
||||||
AddAssert("no supporter", () => profile.Header.SupporterTag.Alpha == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TestUserProfileOverlay : UserProfileOverlay
|
private class TestUserProfileOverlay : UserProfileOverlay
|
||||||
{
|
{
|
||||||
public new ProfileHeader Header => base.Header;
|
public new ProfileHeader Header => base.Header;
|
||||||
|
@ -33,9 +33,9 @@ namespace osu.Game.Tests.Visual
|
|||||||
header = new ProfileHeader();
|
header = new ProfileHeader();
|
||||||
Add(header);
|
Add(header);
|
||||||
|
|
||||||
AddStep("Show offline dummy", () => header.User = TestCaseUserProfile.TEST_USER);
|
AddStep("Show offline dummy", () => header.User.Value = TestCaseUserProfile.TEST_USER);
|
||||||
|
|
||||||
AddStep("Show null dummy", () => header.User = new User
|
AddStep("Show null dummy", () => header.User.Value = new User
|
||||||
{
|
{
|
||||||
Username = "Null"
|
Username = "Null"
|
||||||
});
|
});
|
||||||
@ -65,11 +65,11 @@ namespace osu.Game.Tests.Visual
|
|||||||
if (api.IsLoggedIn)
|
if (api.IsLoggedIn)
|
||||||
{
|
{
|
||||||
var request = new GetUserRequest(fallback.Id);
|
var request = new GetUserRequest(fallback.Id);
|
||||||
request.Success += user => header.User = user;
|
request.Success += user => header.User.Value = user;
|
||||||
api.Queue(request);
|
api.Queue(request);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
header.User = fallback;
|
header.User.Value = fallback;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -17,32 +18,21 @@ using osuTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Profile.Header
|
namespace osu.Game.Overlays.Profile.Header
|
||||||
{
|
{
|
||||||
public class BottomHeaderContainer : Container
|
public class BottomHeaderContainer : CompositeDrawable
|
||||||
{
|
{
|
||||||
private LinkFlowContainer bottomTopLinkContainer;
|
private LinkFlowContainer bottomTopLinkContainer;
|
||||||
private LinkFlowContainer bottomLinkContainer;
|
private LinkFlowContainer bottomLinkContainer;
|
||||||
private Color4 linkBlue, communityUserGrayGreenLighter;
|
private Color4 linkBlue, communityUserGrayGreenLighter;
|
||||||
|
|
||||||
private User user;
|
public readonly Bindable<User> User = new Bindable<User>();
|
||||||
|
|
||||||
public User User
|
|
||||||
{
|
|
||||||
get => user;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (user == value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
user = value;
|
|
||||||
|
|
||||||
updateDisplay();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
Children = new Drawable[]
|
AutoSizeAxes = Axes.Y;
|
||||||
|
User.ValueChanged += e => updateDisplay(e.NewValue);
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
@ -76,7 +66,7 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
communityUserGrayGreenLighter = colours.CommunityUserGrayGreenLighter;
|
communityUserGrayGreenLighter = colours.CommunityUserGrayGreenLighter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDisplay()
|
private void updateDisplay(User user)
|
||||||
{
|
{
|
||||||
void bold(SpriteText t) => t.Font = @"Exo2.0-Bold";
|
void bold(SpriteText t) => t.Font = @"Exo2.0-Bold";
|
||||||
void addSpacer(OsuTextFlowContainer textFlow) => textFlow.AddArbitraryDrawable(new Container { Width = 15 });
|
void addSpacer(OsuTextFlowContainer textFlow) => textFlow.AddArbitraryDrawable(new Container { Width = 15 });
|
||||||
|
@ -1,75 +1,48 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.API;
|
|
||||||
using osu.Game.Online.Chat;
|
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Profile.Header
|
namespace osu.Game.Overlays.Profile.Header
|
||||||
{
|
{
|
||||||
public class CenterHeaderContainer : Container
|
public class CenterHeaderContainer : CompositeDrawable
|
||||||
{
|
{
|
||||||
public readonly BindableBool DetailsVisible = new BindableBool();
|
public Action<bool> DetailsVisibilityAction;
|
||||||
|
private bool detailsVisible;
|
||||||
|
|
||||||
private OsuSpriteText followerText;
|
private OsuSpriteText followerText;
|
||||||
private ProfileHeaderButton messageButton;
|
|
||||||
private OsuSpriteText levelBadgeText;
|
private OsuSpriteText levelBadgeText;
|
||||||
|
|
||||||
private Bar levelProgressBar;
|
private Bar levelProgressBar;
|
||||||
private OsuSpriteText levelProgressText;
|
private OsuSpriteText levelProgressText;
|
||||||
|
|
||||||
private ProfileHeader.OverlinedInfoContainer hiddenDetailGlobal, hiddenDetailCountry;
|
private OverlinedInfoContainer hiddenDetailGlobal, hiddenDetailCountry;
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
public readonly Bindable<User> User = new Bindable<User>();
|
||||||
private ChannelManager channelManager { get; set; }
|
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
|
||||||
private UserProfileOverlay userOverlay { get; set; }
|
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
|
||||||
private ChatOverlay chatOverlay { get; set; }
|
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private APIAccess apiAccess { get; set; }
|
|
||||||
|
|
||||||
private User user;
|
|
||||||
|
|
||||||
public User User
|
|
||||||
{
|
|
||||||
get => user;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (user == value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
user = value;
|
|
||||||
|
|
||||||
updateDisplay();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, TextureStore textures)
|
private void load(OsuColour colours, TextureStore textures)
|
||||||
{
|
{
|
||||||
Container<Drawable> hiddenDetailContainer, expandedDetailContainer;
|
Container<Drawable> hiddenDetailContainer, expandedDetailContainer;
|
||||||
SpriteIcon expandButtonIcon;
|
SpriteIcon expandButtonIcon;
|
||||||
|
ProfileHeaderButton detailsToggleButton;
|
||||||
|
Height = 60;
|
||||||
|
User.ValueChanged += e => updateDisplay(e.NewValue);
|
||||||
|
|
||||||
Children = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
@ -118,21 +91,9 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
messageButton = new ProfileHeaderButton
|
new ProfileMessageButton
|
||||||
{
|
{
|
||||||
Alpha = 0,
|
User = { BindTarget = User }
|
||||||
RelativeSizeAxes = Axes.Y,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new SpriteIcon
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
Icon = FontAwesome.fa_envelope,
|
|
||||||
FillMode = FillMode.Fit,
|
|
||||||
Size = new Vector2(50, 14)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -143,12 +104,11 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Padding = new MarginPadding { Vertical = 10 },
|
Padding = new MarginPadding { Vertical = 10 },
|
||||||
Width = UserProfileOverlay.CONTENT_X_MARGIN,
|
Width = UserProfileOverlay.CONTENT_X_MARGIN,
|
||||||
Child = new ProfileHeaderButton
|
Child = detailsToggleButton = new ProfileHeaderButton
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Action = DetailsVisible.Toggle,
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
expandButtonIcon = new SpriteIcon
|
expandButtonIcon = new SpriteIcon
|
||||||
@ -233,12 +193,12 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
Margin = new MarginPadding { Right = 50 },
|
Margin = new MarginPadding { Right = 50 },
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
hiddenDetailGlobal = new ProfileHeader.OverlinedInfoContainer
|
hiddenDetailGlobal = new OverlinedInfoContainer
|
||||||
{
|
{
|
||||||
Title = "Global Ranking",
|
Title = "Global Ranking",
|
||||||
LineColour = colours.Yellow
|
LineColour = colours.Yellow
|
||||||
},
|
},
|
||||||
hiddenDetailCountry = new ProfileHeader.OverlinedInfoContainer
|
hiddenDetailCountry = new OverlinedInfoContainer
|
||||||
{
|
{
|
||||||
Title = "Country Ranking",
|
Title = "Country Ranking",
|
||||||
LineColour = colours.Yellow
|
LineColour = colours.Yellow
|
||||||
@ -249,76 +209,26 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
DetailsVisible.ValueChanged += visible =>
|
detailsToggleButton.Action = () =>
|
||||||
{
|
{
|
||||||
expandButtonIcon.Icon = visible.NewValue ? FontAwesome.fa_chevron_down : FontAwesome.fa_chevron_up;
|
detailsVisible = !detailsVisible;
|
||||||
hiddenDetailContainer.Alpha = visible.NewValue ? 1 : 0;
|
expandButtonIcon.Icon = detailsVisible ? FontAwesome.fa_chevron_down : FontAwesome.fa_chevron_up;
|
||||||
expandedDetailContainer.Alpha = visible.NewValue ? 0 : 1;
|
hiddenDetailContainer.Alpha = detailsVisible ? 1 : 0;
|
||||||
|
expandedDetailContainer.Alpha = detailsVisible ? 0 : 1;
|
||||||
|
DetailsVisibilityAction(detailsVisible);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDisplay()
|
private void updateDisplay(User user)
|
||||||
{
|
{
|
||||||
followerText.Text = user.FollowerCount?.Length > 0 ? user.FollowerCount[0].ToString("#,##0") : "0";
|
followerText.Text = user.FollowerCount?.Length > 0 ? user.FollowerCount[0].ToString("#,##0") : "0";
|
||||||
|
|
||||||
if (!user.PMFriendsOnly && apiAccess.LocalUser.Value.Id != user.Id)
|
|
||||||
{
|
|
||||||
messageButton.Show();
|
|
||||||
messageButton.Action = () =>
|
|
||||||
{
|
|
||||||
channelManager?.OpenPrivateChannel(user);
|
|
||||||
userOverlay?.Hide();
|
|
||||||
chatOverlay?.Show();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
messageButton.Hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
levelBadgeText.Text = user.Statistics?.Level.Current.ToString() ?? "0";
|
levelBadgeText.Text = user.Statistics?.Level.Current.ToString() ?? "0";
|
||||||
levelProgressBar.Length = user.Statistics?.Level.Progress / 100f ?? 0;
|
levelProgressBar.Length = user.Statistics?.Level.Progress / 100f ?? 0;
|
||||||
levelProgressText.Text = user.Statistics?.Level.Progress.ToString("0'%'");
|
levelProgressText.Text = user.Statistics?.Level.Progress.ToString("0'%'");
|
||||||
|
|
||||||
hiddenDetailGlobal.Content = user?.Statistics?.Ranks.Global?.ToString("#,##0") ?? "-";
|
hiddenDetailGlobal.Content = user.Statistics?.Ranks.Global?.ToString("#,##0") ?? "-";
|
||||||
hiddenDetailCountry.Content = user?.Statistics?.Ranks.Country?.ToString("#,##0") ?? "-";
|
hiddenDetailCountry.Content = user.Statistics?.Ranks.Country?.ToString("#,##0") ?? "-";
|
||||||
}
|
|
||||||
|
|
||||||
private class ProfileHeaderButton : OsuHoverContainer
|
|
||||||
{
|
|
||||||
private readonly Box background;
|
|
||||||
private readonly Container content;
|
|
||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
|
||||||
|
|
||||||
protected override IEnumerable<Drawable> EffectTargets => new[] { background };
|
|
||||||
|
|
||||||
public ProfileHeaderButton()
|
|
||||||
{
|
|
||||||
HoverColour = Color4.Black.Opacity(0.75f);
|
|
||||||
IdleColour = Color4.Black.Opacity(0.7f);
|
|
||||||
AutoSizeAxes = Axes.X;
|
|
||||||
|
|
||||||
base.Content.Add(new CircularContainer
|
|
||||||
{
|
|
||||||
Masking = true,
|
|
||||||
AutoSizeAxes = Axes.X,
|
|
||||||
RelativeSizeAxes = Axes.Y,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
background = new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
},
|
|
||||||
content = new Container
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.X,
|
|
||||||
RelativeSizeAxes = Axes.Y,
|
|
||||||
Padding = new MarginPadding { Horizontal = 10 },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -17,34 +18,23 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Profile.Header
|
namespace osu.Game.Overlays.Profile.Header
|
||||||
{
|
{
|
||||||
public class DetailHeaderContainer : Container
|
public class DetailHeaderContainer : CompositeDrawable
|
||||||
{
|
{
|
||||||
private ProfileHeader.HasTooltipContainer totalPlayTimeTooltip;
|
private ProfileHeader.HasTooltipContainer totalPlayTimeTooltip;
|
||||||
private ProfileHeader.OverlinedInfoContainer totalPlayTimeInfo, medalInfo, ppInfo;
|
private OverlinedInfoContainer totalPlayTimeInfo, medalInfo, ppInfo;
|
||||||
private readonly Dictionary<ScoreRank, ScoreRankInfo> scoreRankInfos = new Dictionary<ScoreRank, ScoreRankInfo>();
|
private readonly Dictionary<ScoreRank, ScoreRankInfo> scoreRankInfos = new Dictionary<ScoreRank, ScoreRankInfo>();
|
||||||
private ProfileHeader.OverlinedInfoContainer detailGlobalRank, detailCountryRank;
|
private OverlinedInfoContainer detailGlobalRank, detailCountryRank;
|
||||||
private RankGraph rankGraph;
|
private RankGraph rankGraph;
|
||||||
|
|
||||||
private User user;
|
public readonly Bindable<User> User = new Bindable<User>();
|
||||||
|
|
||||||
public User User
|
|
||||||
{
|
|
||||||
get => user;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (user == value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
user = value;
|
|
||||||
|
|
||||||
updateDisplay();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
Children = new Drawable[]
|
AutoSizeAxes = Axes.Y;
|
||||||
|
User.ValueChanged += e => updateDisplay(e.NewValue);
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
@ -79,18 +69,18 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
TooltipText = "0 hours",
|
TooltipText = "0 hours",
|
||||||
Child = totalPlayTimeInfo = new ProfileHeader.OverlinedInfoContainer
|
Child = totalPlayTimeInfo = new OverlinedInfoContainer
|
||||||
{
|
{
|
||||||
Title = "Total Play Time",
|
Title = "Total Play Time",
|
||||||
LineColour = colours.Yellow,
|
LineColour = colours.Yellow,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
medalInfo = new ProfileHeader.OverlinedInfoContainer
|
medalInfo = new OverlinedInfoContainer
|
||||||
{
|
{
|
||||||
Title = "Medals",
|
Title = "Medals",
|
||||||
LineColour = colours.GreenLight,
|
LineColour = colours.GreenLight,
|
||||||
},
|
},
|
||||||
ppInfo = new ProfileHeader.OverlinedInfoContainer
|
ppInfo = new OverlinedInfoContainer
|
||||||
{
|
{
|
||||||
Title = "pp",
|
Title = "pp",
|
||||||
LineColour = colours.Red,
|
LineColour = colours.Red,
|
||||||
@ -135,12 +125,12 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
Spacing = new Vector2(0, 20),
|
Spacing = new Vector2(0, 20),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
detailGlobalRank = new ProfileHeader.OverlinedInfoContainer(true, 110)
|
detailGlobalRank = new OverlinedInfoContainer(true, 110)
|
||||||
{
|
{
|
||||||
Title = "Global Ranking",
|
Title = "Global Ranking",
|
||||||
LineColour = colours.Yellow,
|
LineColour = colours.Yellow,
|
||||||
},
|
},
|
||||||
detailCountryRank = new ProfileHeader.OverlinedInfoContainer(false, 110)
|
detailCountryRank = new OverlinedInfoContainer(false, 110)
|
||||||
{
|
{
|
||||||
Title = "Country Ranking",
|
Title = "Country Ranking",
|
||||||
LineColour = colours.Yellow,
|
LineColour = colours.Yellow,
|
||||||
@ -154,7 +144,7 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDisplay()
|
private void updateDisplay(User user)
|
||||||
{
|
{
|
||||||
medalInfo.Content = user?.Achievements?.Length.ToString() ?? "0";
|
medalInfo.Content = user?.Achievements?.Length.ToString() ?? "0";
|
||||||
ppInfo.Content = user?.Statistics?.PP?.ToString("#,##0") ?? "0";
|
ppInfo.Content = user?.Statistics?.PP?.ToString("#,##0") ?? "0";
|
||||||
|
46
osu.Game/Overlays/Profile/Header/DrawableBadge.cs
Normal file
46
osu.Game/Overlays/Profile/Header/DrawableBadge.cs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// 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 osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Game.Users;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Profile.Header
|
||||||
|
{
|
||||||
|
public class DrawableBadge : CompositeDrawable, IHasTooltip
|
||||||
|
{
|
||||||
|
public static readonly Vector2 DRAWABLE_BADGE_SIZE = new Vector2(86, 40);
|
||||||
|
|
||||||
|
private readonly Badge badge;
|
||||||
|
|
||||||
|
public DrawableBadge(Badge badge)
|
||||||
|
{
|
||||||
|
this.badge = badge;
|
||||||
|
Size = DRAWABLE_BADGE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(LargeTextureStore textures)
|
||||||
|
{
|
||||||
|
InternalChild = new Sprite
|
||||||
|
{
|
||||||
|
FillMode = FillMode.Fit,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Texture = textures.Get(badge.ImageUrl),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
InternalChild.FadeInFromZero(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string TooltipText => badge.Description;
|
||||||
|
}
|
||||||
|
}
|
@ -2,14 +2,12 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Cursor;
|
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Framework.Graphics.Textures;
|
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -17,31 +15,20 @@ using osuTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Profile.Header
|
namespace osu.Game.Overlays.Profile.Header
|
||||||
{
|
{
|
||||||
public class MedalHeaderContainer : Container
|
public class MedalHeaderContainer : CompositeDrawable
|
||||||
{
|
{
|
||||||
private FillFlowContainer badgeFlowContainer;
|
private FillFlowContainer badgeFlowContainer;
|
||||||
|
|
||||||
private User user;
|
public readonly Bindable<User> User = new Bindable<User>();
|
||||||
|
|
||||||
public User User
|
|
||||||
{
|
|
||||||
get => user;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (user == value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
user = value;
|
|
||||||
|
|
||||||
updateDisplay();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
Alpha = 0;
|
Alpha = 0;
|
||||||
Children = new Drawable[]
|
AutoSizeAxes = Axes.Y;
|
||||||
|
User.ValueChanged += e => updateDisplay(e.NewValue);
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
@ -76,9 +63,9 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDisplay()
|
private void updateDisplay(User user)
|
||||||
{
|
{
|
||||||
var badges = User.Badges;
|
var badges = user.Badges;
|
||||||
badgeFlowContainer.Clear();
|
badgeFlowContainer.Clear();
|
||||||
if (badges?.Length > 0)
|
if (badges?.Length > 0)
|
||||||
{
|
{
|
||||||
@ -100,37 +87,5 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
Hide();
|
Hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DrawableBadge : CompositeDrawable, IHasTooltip
|
|
||||||
{
|
|
||||||
public static readonly Vector2 DRAWABLE_BADGE_SIZE = new Vector2(86, 40);
|
|
||||||
|
|
||||||
private readonly Badge badge;
|
|
||||||
|
|
||||||
public DrawableBadge(Badge badge)
|
|
||||||
{
|
|
||||||
this.badge = badge;
|
|
||||||
Size = DRAWABLE_BADGE_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(LargeTextureStore textures)
|
|
||||||
{
|
|
||||||
InternalChild = new Sprite
|
|
||||||
{
|
|
||||||
FillMode = FillMode.Fit,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Texture = textures.Get(badge.ImageUrl),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
InternalChild.FadeInFromZero(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string TooltipText => badge.Description;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
63
osu.Game/Overlays/Profile/Header/OverlinedInfoContainer.cs
Normal file
63
osu.Game/Overlays/Profile/Header/OverlinedInfoContainer.cs
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
// 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 osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Profile.Header
|
||||||
|
{
|
||||||
|
public class OverlinedInfoContainer : CompositeDrawable
|
||||||
|
{
|
||||||
|
private readonly Circle line;
|
||||||
|
private readonly OsuSpriteText title, content;
|
||||||
|
|
||||||
|
public string Title
|
||||||
|
{
|
||||||
|
set => title.Text = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Content
|
||||||
|
{
|
||||||
|
set => content.Text = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color4 LineColour
|
||||||
|
{
|
||||||
|
set => line.Colour = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OverlinedInfoContainer(bool big = false, int minimumWidth = 60)
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
InternalChild = new FillFlowContainer
|
||||||
|
{
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
line = new Circle
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = 4,
|
||||||
|
},
|
||||||
|
title = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = OsuFont.GetFont(size: big ? 14 : 12, weight: FontWeight.Bold)
|
||||||
|
},
|
||||||
|
content = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = OsuFont.GetFont(size: big ? 40 : 18, weight: FontWeight.Light)
|
||||||
|
},
|
||||||
|
new Container //Add a minimum size to the FillFlowContainer
|
||||||
|
{
|
||||||
|
Width = minimumWidth,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
50
osu.Game/Overlays/Profile/Header/ProfileHeaderButton.cs
Normal file
50
osu.Game/Overlays/Profile/Header/ProfileHeaderButton.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
// 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.Collections.Generic;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Profile.Header
|
||||||
|
{
|
||||||
|
public class ProfileHeaderButton : OsuHoverContainer
|
||||||
|
{
|
||||||
|
private readonly Box background;
|
||||||
|
private readonly Container content;
|
||||||
|
|
||||||
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
|
protected override IEnumerable<Drawable> EffectTargets => new[] { background };
|
||||||
|
|
||||||
|
public ProfileHeaderButton()
|
||||||
|
{
|
||||||
|
HoverColour = Color4.Black.Opacity(0.75f);
|
||||||
|
IdleColour = Color4.Black.Opacity(0.7f);
|
||||||
|
AutoSizeAxes = Axes.X;
|
||||||
|
|
||||||
|
base.Content.Add(new CircularContainer
|
||||||
|
{
|
||||||
|
Masking = true,
|
||||||
|
AutoSizeAxes = Axes.X,
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
background = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
content = new Container
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.X,
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
Padding = new MarginPadding { Horizontal = 10 },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -93,11 +93,11 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
{
|
{
|
||||||
text = new OsuSpriteText
|
text = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Margin = new MarginPadding { Bottom = 15 },
|
Margin = new MarginPadding { Bottom = 10 },
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Text = value,
|
Text = value,
|
||||||
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold)
|
Font = OsuFont.GetFont()
|
||||||
},
|
},
|
||||||
bar = new Circle
|
bar = new Circle
|
||||||
{
|
{
|
||||||
@ -134,7 +134,7 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
{
|
{
|
||||||
text.FadeColour(AccentColour, 120, Easing.InQuad);
|
text.FadeColour(AccentColour, 120, Easing.InQuad);
|
||||||
bar.ResizeHeightTo(0, 120, Easing.InQuad);
|
bar.ResizeHeightTo(0, 120, Easing.InQuad);
|
||||||
text.Font = text.Font.With(Typeface.Exo, weight: FontWeight.Medium);
|
text.Font = text.Font.With(weight: FontWeight.Medium);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onActivated(bool fake = false)
|
private void onActivated(bool fake = false)
|
||||||
@ -142,7 +142,7 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
text.FadeColour(Color4.White, 120, Easing.InQuad);
|
text.FadeColour(Color4.White, 120, Easing.InQuad);
|
||||||
bar.ResizeHeightTo(7.5f, 120, Easing.InQuad);
|
bar.ResizeHeightTo(7.5f, 120, Easing.InQuad);
|
||||||
if (!fake)
|
if (!fake)
|
||||||
text.Font = text.Font.With(Typeface.Exo, weight: FontWeight.Bold);
|
text.Font = text.Font.With(weight: FontWeight.Bold);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
57
osu.Game/Overlays/Profile/Header/ProfileMessageButton.cs
Normal file
57
osu.Game/Overlays/Profile/Header/ProfileMessageButton.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
// 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 osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Online.Chat;
|
||||||
|
using osu.Game.Users;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Profile.Header
|
||||||
|
{
|
||||||
|
public class ProfileMessageButton : ProfileHeaderButton
|
||||||
|
{
|
||||||
|
public readonly Bindable<User> User = new Bindable<User>();
|
||||||
|
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
private ChannelManager channelManager { get; set; }
|
||||||
|
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
private UserProfileOverlay userOverlay { get; set; }
|
||||||
|
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
private ChatOverlay chatOverlay { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private APIAccess apiAccess { get; set; }
|
||||||
|
|
||||||
|
public ProfileMessageButton()
|
||||||
|
{
|
||||||
|
Content.Alpha = 0;
|
||||||
|
RelativeSizeAxes = Axes.Y;
|
||||||
|
|
||||||
|
Child = new SpriteIcon
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
Icon = FontAwesome.fa_envelope,
|
||||||
|
FillMode = FillMode.Fit,
|
||||||
|
Size = new Vector2(50, 14)
|
||||||
|
};
|
||||||
|
|
||||||
|
Action = () =>
|
||||||
|
{
|
||||||
|
if (!Content.IsPresent) return;
|
||||||
|
|
||||||
|
channelManager?.OpenPrivateChannel(User.Value);
|
||||||
|
userOverlay?.Hide();
|
||||||
|
chatOverlay?.Show();
|
||||||
|
};
|
||||||
|
|
||||||
|
User.ValueChanged += e => Content.Alpha = !e.NewValue.PMFriendsOnly && apiAccess.LocalUser.Value.Id != e.NewValue.Id ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,10 +10,11 @@ using osu.Game.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Profile.Header
|
namespace osu.Game.Overlays.Profile.Header
|
||||||
{
|
{
|
||||||
public class SupporterIcon : CircularContainer, IHasTooltip
|
public class SupporterIcon : CompositeDrawable, IHasTooltip
|
||||||
{
|
{
|
||||||
private readonly Box background;
|
private readonly Box background;
|
||||||
private readonly FillFlowContainer iconContainer;
|
private readonly FillFlowContainer iconContainer;
|
||||||
|
private readonly CircularContainer content;
|
||||||
|
|
||||||
public string TooltipText => "osu!supporter";
|
public string TooltipText => "osu!supporter";
|
||||||
|
|
||||||
@ -23,11 +24,11 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
{
|
{
|
||||||
Hide();
|
content.Hide();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Show();
|
content.Show();
|
||||||
iconContainer.Clear();
|
iconContainer.Clear();
|
||||||
for (int i = 0; i < value; i++)
|
for (int i = 0; i < value; i++)
|
||||||
{
|
{
|
||||||
@ -38,43 +39,38 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
Icon = FontAwesome.fa_heart,
|
Icon = FontAwesome.fa_heart,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iconContainer.Padding = new MarginPadding { Horizontal = DrawHeight / 2 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SupporterIcon()
|
public SupporterIcon()
|
||||||
{
|
{
|
||||||
Masking = true;
|
|
||||||
AutoSizeAxes = Axes.X;
|
AutoSizeAxes = Axes.X;
|
||||||
Hide();
|
|
||||||
|
|
||||||
Children = new Drawable[]
|
InternalChild = content = new CircularContainer
|
||||||
{
|
{
|
||||||
background = new Box { RelativeSizeAxes = Axes.Both },
|
RelativeSizeAxes = Axes.Y,
|
||||||
iconContainer = new FillFlowContainer
|
AutoSizeAxes = Axes.X,
|
||||||
|
Masking = true,
|
||||||
|
Alpha = 0,
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
Direction = FillDirection.Horizontal,
|
background = new Box { RelativeSizeAxes = Axes.Both },
|
||||||
RelativeSizeAxes = Axes.Y,
|
iconContainer = new FillFlowContainer
|
||||||
AutoSizeAxes = Axes.X,
|
{
|
||||||
Height = 0.6f,
|
Direction = FillDirection.Horizontal,
|
||||||
Anchor = Anchor.Centre,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Origin = Anchor.Centre,
|
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]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
@ -14,9 +15,9 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Profile.Header
|
namespace osu.Game.Overlays.Profile.Header
|
||||||
{
|
{
|
||||||
public class TopHeaderContainer : Container
|
public class TopHeaderContainer : CompositeDrawable
|
||||||
{
|
{
|
||||||
public SupporterIcon SupporterTag;
|
private SupporterIcon supporterTag;
|
||||||
private UpdateableAvatar avatar;
|
private UpdateableAvatar avatar;
|
||||||
private OsuSpriteText usernameText;
|
private OsuSpriteText usernameText;
|
||||||
private ExternalLinkButton openUserExternally;
|
private ExternalLinkButton openUserExternally;
|
||||||
@ -27,26 +28,15 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
|
|
||||||
private const float avatar_size = 110;
|
private const float avatar_size = 110;
|
||||||
|
|
||||||
private User user;
|
public readonly Bindable<User> User = new Bindable<User>();
|
||||||
|
|
||||||
public User User
|
|
||||||
{
|
|
||||||
get => user;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (user == value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
user = value;
|
|
||||||
|
|
||||||
updateDisplay();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
Children = new Drawable[]
|
Height = 150;
|
||||||
|
User.ValueChanged += e => updateDisplay(e.NewValue);
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
@ -109,7 +99,7 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
TextSize = 18,
|
TextSize = 18,
|
||||||
Font = "Exo2.0-Regular"
|
Font = "Exo2.0-Regular"
|
||||||
},
|
},
|
||||||
SupporterTag = new SupporterIcon
|
supporterTag = new SupporterIcon
|
||||||
{
|
{
|
||||||
Height = 20,
|
Height = 20,
|
||||||
Margin = new MarginPadding { Top = 5 }
|
Margin = new MarginPadding { Top = 5 }
|
||||||
@ -161,14 +151,14 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDisplay()
|
private void updateDisplay(User user)
|
||||||
{
|
{
|
||||||
avatar.User = User;
|
avatar.User = user;
|
||||||
usernameText.Text = user.Username;
|
usernameText.Text = user.Username;
|
||||||
openUserExternally.Link = $@"https://osu.ppy.sh/users/{user.Id}";
|
openUserExternally.Link = $@"https://osu.ppy.sh/users/{user.Id}";
|
||||||
userFlag.Country = user.Country;
|
userFlag.Country = user.Country;
|
||||||
userCountryText.Text = user.Country?.FullName ?? "Alien";
|
userCountryText.Text = user.Country?.FullName ?? "Alien";
|
||||||
SupporterTag.SupporterLevel = user.SupportLevel;
|
supporterTag.SupporterLevel = user.SupportLevel;
|
||||||
titleText.Text = user.Title;
|
titleText.Text = user.Title;
|
||||||
titleText.Colour = OsuColour.FromHex(user.Colour ?? "fff");
|
titleText.Colour = OsuColour.FromHex(user.Colour ?? "fff");
|
||||||
|
|
||||||
|
@ -2,43 +2,31 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osuTK.Graphics;
|
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Cursor;
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
|
||||||
using osu.Game.Overlays.Profile.Header;
|
using osu.Game.Overlays.Profile.Header;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Profile
|
namespace osu.Game.Overlays.Profile
|
||||||
{
|
{
|
||||||
public class ProfileHeader : Container
|
public class ProfileHeader : Container
|
||||||
{
|
{
|
||||||
private readonly Container coverContainer;
|
private readonly UserCoverBackground coverContainer;
|
||||||
private readonly OsuSpriteText coverInfoText;
|
private readonly ScreenTitle coverTitle;
|
||||||
private readonly ProfileHeaderTabControl infoTabControl;
|
private readonly ProfileHeaderTabControl infoTabControl;
|
||||||
|
|
||||||
private readonly TopHeaderContainer topHeaderContainer;
|
|
||||||
public SupporterIcon SupporterTag => topHeaderContainer.SupporterTag;
|
|
||||||
|
|
||||||
private readonly CenterHeaderContainer centerHeaderContainer;
|
|
||||||
public readonly BindableBool DetailsVisible = new BindableBool();
|
|
||||||
|
|
||||||
private readonly DetailHeaderContainer detailHeaderContainer;
|
|
||||||
private readonly MedalHeaderContainer medalHeaderContainer;
|
|
||||||
private readonly BottomHeaderContainer bottomHeaderContainer;
|
|
||||||
|
|
||||||
private const float cover_height = 150;
|
private const float cover_height = 150;
|
||||||
private const float cover_info_height = 75;
|
private const float cover_info_height = 75;
|
||||||
|
|
||||||
public ProfileHeader()
|
public ProfileHeader()
|
||||||
{
|
{
|
||||||
|
CenterHeaderContainer centerHeaderContainer;
|
||||||
|
DetailHeaderContainer detailHeaderContainer;
|
||||||
Container expandedDetailContainer;
|
Container expandedDetailContainer;
|
||||||
FillFlowContainer hiddenDetailContainer, headerDetailContainer;
|
FillFlowContainer hiddenDetailContainer, headerDetailContainer;
|
||||||
SpriteIcon expandButtonIcon;
|
SpriteIcon expandButtonIcon;
|
||||||
@ -48,19 +36,10 @@ namespace osu.Game.Overlays.Profile
|
|||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
coverContainer = new Container
|
coverContainer = new UserCoverBackground
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = cover_height,
|
Height = cover_height,
|
||||||
Masking = true,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.1f), Color4.Black.Opacity(0.75f))
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
@ -73,25 +52,10 @@ namespace osu.Game.Overlays.Profile
|
|||||||
Depth = -float.MaxValue,
|
Depth = -float.MaxValue,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new FillFlowContainer
|
coverTitle = new ScreenTitle
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
Title = "Player ",
|
||||||
Direction = FillDirection.Horizontal,
|
Page = "Info"
|
||||||
Children = new[]
|
|
||||||
{
|
|
||||||
new OsuSpriteText
|
|
||||||
{
|
|
||||||
Text = "Player ",
|
|
||||||
Font = "Exo2.0-Regular",
|
|
||||||
TextSize = 30
|
|
||||||
},
|
|
||||||
coverInfoText = new OsuSpriteText
|
|
||||||
{
|
|
||||||
Text = "Info",
|
|
||||||
Font = "Exo2.0-Regular",
|
|
||||||
TextSize = 30
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
infoTabControl = new ProfileHeaderTabControl
|
infoTabControl = new ProfileHeaderTabControl
|
||||||
{
|
{
|
||||||
@ -112,30 +76,30 @@ namespace osu.Game.Overlays.Profile
|
|||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Vertical,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
topHeaderContainer = new TopHeaderContainer
|
new TopHeaderContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = 150,
|
User = { BindTarget = User },
|
||||||
},
|
},
|
||||||
centerHeaderContainer = new CenterHeaderContainer
|
centerHeaderContainer = new CenterHeaderContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = 60,
|
User = { BindTarget = User },
|
||||||
},
|
},
|
||||||
detailHeaderContainer = new DetailHeaderContainer
|
detailHeaderContainer = new DetailHeaderContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
User = { BindTarget = User },
|
||||||
},
|
},
|
||||||
medalHeaderContainer = new MedalHeaderContainer
|
new MedalHeaderContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
User = { BindTarget = User },
|
||||||
},
|
},
|
||||||
bottomHeaderContainer = new BottomHeaderContainer
|
new BottomHeaderContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
User = { BindTarget = User },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,99 +108,28 @@ namespace osu.Game.Overlays.Profile
|
|||||||
infoTabControl.AddItem("Info");
|
infoTabControl.AddItem("Info");
|
||||||
infoTabControl.AddItem("Modding");
|
infoTabControl.AddItem("Modding");
|
||||||
|
|
||||||
centerHeaderContainer.DetailsVisible.BindTo(DetailsVisible);
|
centerHeaderContainer.DetailsVisibilityAction = visible => detailHeaderContainer.Alpha = visible ? 0 : 1;
|
||||||
DetailsVisible.ValueChanged += visible => detailHeaderContainer.Alpha = visible.NewValue ? 0 : 1;
|
User.ValueChanged += e => updateDisplay(e.NewValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, TextureStore textures)
|
private void load(OsuColour colours, TextureStore textures)
|
||||||
{
|
{
|
||||||
coverInfoText.Colour = colours.CommunityUserGreen;
|
coverTitle.AccentColour = colours.CommunityUserGreen;
|
||||||
|
|
||||||
infoTabControl.AccentColour = colours.CommunityUserGreen;
|
infoTabControl.AccentColour = colours.CommunityUserGreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
private User user;
|
public Bindable<User> User = new Bindable<User>();
|
||||||
|
|
||||||
public User User
|
private void updateDisplay(User user)
|
||||||
{
|
{
|
||||||
get => user;
|
coverContainer.User = user;
|
||||||
set
|
|
||||||
{
|
|
||||||
medalHeaderContainer.User = detailHeaderContainer.User = bottomHeaderContainer.User =
|
|
||||||
centerHeaderContainer.User = topHeaderContainer.User = user = value;
|
|
||||||
updateDisplay();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateDisplay()
|
|
||||||
{
|
|
||||||
coverContainer.RemoveAll(d => d is UserCoverBackground);
|
|
||||||
LoadComponentAsync(new UserCoverBackground(user)
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
FillMode = FillMode.Fill,
|
|
||||||
OnLoadComplete = d => d.FadeInFromZero(200),
|
|
||||||
Depth = float.MaxValue,
|
|
||||||
}, coverContainer.Add);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HasTooltipContainer : Container, IHasTooltip
|
public class HasTooltipContainer : Container, IHasTooltip
|
||||||
{
|
{
|
||||||
public string TooltipText { get; set; }
|
public string TooltipText { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OverlinedInfoContainer : CompositeDrawable
|
|
||||||
{
|
|
||||||
private readonly Circle line;
|
|
||||||
private readonly OsuSpriteText title, content;
|
|
||||||
|
|
||||||
public string Title
|
|
||||||
{
|
|
||||||
set => title.Text = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Content
|
|
||||||
{
|
|
||||||
set => content.Text = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color4 LineColour
|
|
||||||
{
|
|
||||||
set => line.Colour = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OverlinedInfoContainer(bool big = false, int minimumWidth = 60)
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Both;
|
|
||||||
InternalChild = new FillFlowContainer
|
|
||||||
{
|
|
||||||
Direction = FillDirection.Vertical,
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
line = new Circle
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Height = 4,
|
|
||||||
},
|
|
||||||
title = new OsuSpriteText
|
|
||||||
{
|
|
||||||
Font = OsuFont.GetFont(size: big ? 14 : 12, weight: FontWeight.Bold)
|
|
||||||
},
|
|
||||||
content = new OsuSpriteText
|
|
||||||
{
|
|
||||||
Font = OsuFont.GetFont(size: big ? 40 : 18, weight: FontWeight.Light)
|
|
||||||
},
|
|
||||||
new Container //Add a minimum size to the FillFlowContainer
|
|
||||||
{
|
|
||||||
Width = minimumWidth,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
Show();
|
Show();
|
||||||
|
|
||||||
if (user.Id == Header?.User?.Id)
|
if (user.Id == Header?.User.Value?.Id)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
userReq?.Cancel();
|
userReq?.Cancel();
|
||||||
@ -167,7 +167,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private void userLoadComplete(User user)
|
private void userLoadComplete(User user)
|
||||||
{
|
{
|
||||||
Header.User = user;
|
Header.User.Value = user;
|
||||||
|
|
||||||
if (user.ProfileOrder != null)
|
if (user.ProfileOrder != null)
|
||||||
{
|
{
|
||||||
|
@ -1,30 +1,51 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using osu.Framework.Allocation;
|
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.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Users
|
namespace osu.Game.Users
|
||||||
{
|
{
|
||||||
public class UserCoverBackground : Sprite
|
public class UserCoverBackground : ModelBackedDrawable<User>
|
||||||
{
|
{
|
||||||
private readonly User user;
|
public User User
|
||||||
|
|
||||||
public UserCoverBackground(User user)
|
|
||||||
{
|
{
|
||||||
this.user = user;
|
get => Model;
|
||||||
|
set => Model = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[Resolved]
|
||||||
private void load(LargeTextureStore textures)
|
private LargeTextureStore textures { get; set; }
|
||||||
{
|
|
||||||
if (textures == null)
|
|
||||||
throw new ArgumentNullException(nameof(textures));
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(user.CoverUrl))
|
protected override Drawable CreateDrawable(User user)
|
||||||
Texture = textures.Get(user.CoverUrl);
|
{
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.1f), Color4.Black.Opacity(0.75f))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new Sprite
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Texture = textures.Get(user.CoverUrl),
|
||||||
|
FillMode = FillMode.Fill,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
OnLoadComplete = d => d.FadeInFromZero(400),
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,12 +73,12 @@ namespace osu.Game.Users
|
|||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new DelayedLoadWrapper(new UserCoverBackground(user)
|
new DelayedLoadWrapper(new UserCoverBackground
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
FillMode = FillMode.Fill,
|
User = user,
|
||||||
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out)
|
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out)
|
||||||
}, 300) { RelativeSizeAxes = Axes.Both },
|
}, 300) { RelativeSizeAxes = Axes.Both },
|
||||||
new Box
|
new Box
|
||||||
|
Loading…
Reference in New Issue
Block a user