mirror of
https://github.com/ppy/osu.git
synced 2025-03-23 00:37:18 +08:00
Remove HasTooltipContainer, use separate composites
This commit is contained in:
parent
f8c5ee457b
commit
838325fed4
@ -23,6 +23,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
typeof(ProfileHeaderTabControl),
|
||||
typeof(CentreHeaderContainer),
|
||||
typeof(BottomHeaderContainer),
|
||||
typeof(DetailHeaderContainer),
|
||||
typeof(ProfileHeaderButton)
|
||||
};
|
||||
|
||||
|
@ -11,10 +11,8 @@ using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header
|
||||
{
|
||||
@ -24,11 +22,6 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
public readonly Bindable<User> User = new Bindable<User>();
|
||||
|
||||
private OsuSpriteText followerText;
|
||||
private OsuSpriteText levelBadgeText;
|
||||
|
||||
private Bar levelProgressBar;
|
||||
private OsuSpriteText levelProgressText;
|
||||
|
||||
private OverlinedInfoContainer hiddenDetailGlobal;
|
||||
private OverlinedInfoContainer hiddenDetailCountry;
|
||||
|
||||
@ -132,56 +125,24 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
Margin = new MarginPadding { Right = UserProfileOverlay.CONTENT_X_MARGIN },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ProfileHeader.HasTooltipContainer
|
||||
new LevelBadge
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Size = new Vector2(40),
|
||||
TooltipText = "Level",
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Sprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Texture = textures.Get("Profile/levelbadge"),
|
||||
Colour = colours.Yellow,
|
||||
},
|
||||
levelBadgeText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.GetFont(size: 20)
|
||||
}
|
||||
}
|
||||
User = { BindTarget = User }
|
||||
},
|
||||
expandedDetailContainer = new ProfileHeader.HasTooltipContainer
|
||||
expandedDetailContainer = new Container
|
||||
{
|
||||
TooltipText = "Progress to next level",
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Width = 200,
|
||||
Height = 6,
|
||||
Margin = new MarginPadding { Right = 50 },
|
||||
Children = new Drawable[]
|
||||
Child = new LevelProgressBar
|
||||
{
|
||||
new CircularContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
Child = levelProgressBar = new Bar
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
BackgroundColour = Color4.Black,
|
||||
Direction = BarDirection.LeftToRight,
|
||||
AccentColour = colours.Yellow
|
||||
}
|
||||
},
|
||||
levelProgressText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold)
|
||||
}
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
User = { BindTarget = User }
|
||||
}
|
||||
},
|
||||
hiddenDetailContainer = new FillFlowContainer
|
||||
@ -226,10 +187,6 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
{
|
||||
followerText.Text = user.FollowerCount?.Length > 0 ? user.FollowerCount[0].ToString("#,##0") : "0";
|
||||
|
||||
levelBadgeText.Text = user.Statistics?.Level.Current.ToString() ?? "0";
|
||||
levelProgressBar.Length = user.Statistics?.Level.Progress / 100f ?? 0;
|
||||
levelProgressText.Text = user.Statistics?.Level.Progress.ToString("0'%'");
|
||||
|
||||
hiddenDetailGlobal.Content = user.Statistics?.Ranks.Global?.ToString("#,##0") ?? "-";
|
||||
hiddenDetailCountry.Content = user.Statistics?.Ranks.Country?.ToString("#,##0") ?? "-";
|
||||
}
|
||||
|
@ -20,8 +20,7 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
{
|
||||
public class DetailHeaderContainer : CompositeDrawable
|
||||
{
|
||||
private ProfileHeader.HasTooltipContainer totalPlayTimeTooltip;
|
||||
private OverlinedInfoContainer totalPlayTimeInfo, medalInfo, ppInfo;
|
||||
private OverlinedInfoContainer medalInfo, ppInfo;
|
||||
private readonly Dictionary<ScoreRank, ScoreRankInfo> scoreRankInfos = new Dictionary<ScoreRank, ScoreRankInfo>();
|
||||
private OverlinedInfoContainer detailGlobalRank, detailCountryRank;
|
||||
private RankGraph rankGraph;
|
||||
@ -65,15 +64,9 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
Spacing = new Vector2(10, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
totalPlayTimeTooltip = new ProfileHeader.HasTooltipContainer
|
||||
new OverlinedTotalPlayTime
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
TooltipText = "0 hours",
|
||||
Child = totalPlayTimeInfo = new OverlinedInfoContainer
|
||||
{
|
||||
Title = "Total Play Time",
|
||||
LineColour = colours.Yellow,
|
||||
},
|
||||
User = { BindTarget = User }
|
||||
},
|
||||
medalInfo = new OverlinedInfoContainer
|
||||
{
|
||||
@ -149,31 +142,6 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
medalInfo.Content = user?.Achievements?.Length.ToString() ?? "0";
|
||||
ppInfo.Content = user?.Statistics?.PP?.ToString("#,##0") ?? "0";
|
||||
|
||||
string formatTime(int? secondsNull)
|
||||
{
|
||||
if (secondsNull == null) return "0h 0m";
|
||||
|
||||
int seconds = secondsNull.Value;
|
||||
string time = "";
|
||||
|
||||
int days = seconds / 86400;
|
||||
seconds -= days * 86400;
|
||||
if (days > 0)
|
||||
time += days + "d ";
|
||||
|
||||
int hours = seconds / 3600;
|
||||
seconds -= hours * 3600;
|
||||
time += hours + "h ";
|
||||
|
||||
int minutes = seconds / 60;
|
||||
time += minutes + "m";
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
totalPlayTimeInfo.Content = formatTime(user?.Statistics?.PlayTime);
|
||||
totalPlayTimeTooltip.TooltipText = (user?.Statistics?.PlayTime ?? 0) / 3600 + " hours";
|
||||
|
||||
foreach (var scoreRankInfo in scoreRankInfos)
|
||||
scoreRankInfo.Value.RankCount = user?.Statistics?.GradesCount[scoreRankInfo.Key] ?? 0;
|
||||
|
||||
|
57
osu.Game/Overlays/Profile/Header/LevelBadge.cs
Normal file
57
osu.Game/Overlays/Profile/Header/LevelBadge.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.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header
|
||||
{
|
||||
public class LevelBadge : CompositeDrawable, IHasTooltip
|
||||
{
|
||||
public readonly Bindable<User> User = new Bindable<User>();
|
||||
|
||||
public string TooltipText { get; }
|
||||
|
||||
private OsuSpriteText levelText;
|
||||
|
||||
public LevelBadge()
|
||||
{
|
||||
TooltipText = "Level";
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, TextureStore textures)
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Sprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Texture = textures.Get("Profile/levelbadge"),
|
||||
Colour = colours.Yellow,
|
||||
},
|
||||
levelText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.GetFont(size: 20)
|
||||
}
|
||||
};
|
||||
|
||||
User.BindValueChanged(updateLevel);
|
||||
}
|
||||
|
||||
private void updateLevel(ValueChangedEvent<User> user)
|
||||
{
|
||||
levelText.Text = user.NewValue?.Statistics?.Level.Current.ToString() ?? "0";
|
||||
}
|
||||
}
|
||||
}
|
65
osu.Game/Overlays/Profile/Header/LevelProgressBar.cs
Normal file
65
osu.Game/Overlays/Profile/Header/LevelProgressBar.cs
Normal file
@ -0,0 +1,65 @@
|
||||
// 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.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Users;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header
|
||||
{
|
||||
public class LevelProgressBar : CompositeDrawable, IHasTooltip
|
||||
{
|
||||
public readonly Bindable<User> User = new Bindable<User>();
|
||||
|
||||
public string TooltipText { get; }
|
||||
|
||||
private Bar levelProgressBar;
|
||||
private OsuSpriteText levelProgressText;
|
||||
|
||||
public LevelProgressBar()
|
||||
{
|
||||
TooltipText = "Progress to next level";
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new CircularContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
Child = levelProgressBar = new Bar
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
BackgroundColour = Color4.Black,
|
||||
Direction = BarDirection.LeftToRight,
|
||||
AccentColour = colours.Yellow
|
||||
}
|
||||
},
|
||||
levelProgressText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold)
|
||||
}
|
||||
};
|
||||
|
||||
User.BindValueChanged(updateProgress);
|
||||
}
|
||||
|
||||
private void updateProgress(ValueChangedEvent<User> user)
|
||||
{
|
||||
levelProgressBar.Length = user.NewValue?.Statistics?.Level.Progress / 100f ?? 0;
|
||||
levelProgressText.Text = user.NewValue?.Statistics?.Level.Progress.ToString("0'%'");
|
||||
}
|
||||
}
|
||||
}
|
69
osu.Game/Overlays/Profile/Header/OverlinedTotalPlayTime.cs
Normal file
69
osu.Game/Overlays/Profile/Header/OverlinedTotalPlayTime.cs
Normal file
@ -0,0 +1,69 @@
|
||||
// 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.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header
|
||||
{
|
||||
public class OverlinedTotalPlayTime : CompositeDrawable, IHasTooltip
|
||||
{
|
||||
public readonly Bindable<User> User = new Bindable<User>();
|
||||
|
||||
public string TooltipText { get; set; }
|
||||
|
||||
private OverlinedInfoContainer info;
|
||||
|
||||
public OverlinedTotalPlayTime()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
TooltipText = "0 hours";
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
InternalChild = info = new OverlinedInfoContainer
|
||||
{
|
||||
Title = "Total Play Time",
|
||||
LineColour = colours.Yellow,
|
||||
};
|
||||
|
||||
User.BindValueChanged(updateTime, true);
|
||||
}
|
||||
|
||||
private void updateTime(ValueChangedEvent<User> user)
|
||||
{
|
||||
TooltipText = (user.NewValue?.Statistics?.PlayTime ?? 0) / 3600 + " hours";
|
||||
info.Content = formatTime(user.NewValue?.Statistics?.PlayTime);
|
||||
}
|
||||
|
||||
private string formatTime(int? secondsNull)
|
||||
{
|
||||
if (secondsNull == null) return "0h 0m";
|
||||
|
||||
int seconds = secondsNull.Value;
|
||||
string time = "";
|
||||
|
||||
int days = seconds / 86400;
|
||||
seconds -= days * 86400;
|
||||
if (days > 0)
|
||||
time += days + "d ";
|
||||
|
||||
int hours = seconds / 3600;
|
||||
seconds -= hours * 3600;
|
||||
time += hours + "h ";
|
||||
|
||||
int minutes = seconds / 60;
|
||||
time += minutes + "m";
|
||||
|
||||
return time;
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Overlays.Profile.Header;
|
||||
using osu.Game.Users;
|
||||
@ -135,11 +134,6 @@ namespace osu.Game.Overlays.Profile
|
||||
coverContainer.User = user;
|
||||
}
|
||||
|
||||
public class HasTooltipContainer : Container, IHasTooltip
|
||||
{
|
||||
public string TooltipText { get; set; }
|
||||
}
|
||||
|
||||
private class ProfileHeaderTitle : ScreenTitle
|
||||
{
|
||||
public ProfileHeaderTitle()
|
||||
|
Loading…
x
Reference in New Issue
Block a user