mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 04:42:58 +08:00
Add tooltips to all buttons
This commit is contained in:
parent
4adf590036
commit
7047303b0f
@ -3,14 +3,11 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
|
||||
@ -21,7 +18,6 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
public readonly BindableBool DetailsVisible = new BindableBool(true);
|
||||
public readonly Bindable<User> User = new Bindable<User>();
|
||||
|
||||
private OsuSpriteText followerText;
|
||||
private OverlinedInfoContainer hiddenDetailGlobal;
|
||||
private OverlinedInfoContainer hiddenDetailCountry;
|
||||
|
||||
@ -35,7 +31,6 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
{
|
||||
Container<Drawable> hiddenDetailContainer;
|
||||
Container<Drawable> expandedDetailContainer;
|
||||
SpriteIcon expandButtonIcon;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
@ -54,37 +49,10 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
Spacing = new Vector2(10, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ProfileHeaderButton
|
||||
new FriendButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Padding = new MarginPadding { Right = 10 },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Icon = FontAwesome.Solid.User,
|
||||
FillMode = FillMode.Fit,
|
||||
Size = new Vector2(50, 14)
|
||||
},
|
||||
followerText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
User = { BindTarget = User }
|
||||
},
|
||||
new ProfileMessageButton
|
||||
{
|
||||
@ -99,22 +67,12 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Padding = new MarginPadding { Vertical = 10 },
|
||||
Width = UserProfileOverlay.CONTENT_X_MARGIN,
|
||||
Child = new ExpandButton
|
||||
Child = new ExpandDetailsButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Action = () => DetailsVisible.Toggle(),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
expandButtonIcon = new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(20, 12),
|
||||
Icon = FontAwesome.Solid.ChevronUp,
|
||||
},
|
||||
}
|
||||
DetailsVisible = { BindTarget = DetailsVisible }
|
||||
},
|
||||
},
|
||||
new Container
|
||||
@ -175,7 +133,6 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
|
||||
DetailsVisible.BindValueChanged(visible =>
|
||||
{
|
||||
expandButtonIcon.Icon = visible.NewValue ? FontAwesome.Solid.ChevronUp : FontAwesome.Solid.ChevronDown;
|
||||
hiddenDetailContainer.Alpha = visible.NewValue ? 1 : 0;
|
||||
expandedDetailContainer.Alpha = visible.NewValue ? 0 : 1;
|
||||
}, true);
|
||||
@ -185,20 +142,8 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
|
||||
private void updateDisplay(User user)
|
||||
{
|
||||
followerText.Text = user?.FollowerCount?.Length > 0 ? user.FollowerCount[0].ToString("#,##0") : "0";
|
||||
|
||||
hiddenDetailGlobal.Content = user?.Statistics?.Ranks.Global?.ToString("#,##0") ?? "-";
|
||||
hiddenDetailCountry.Content = user?.Statistics?.Ranks.Country?.ToString("#,##0") ?? "-";
|
||||
}
|
||||
|
||||
private class ExpandButton : ProfileHeaderButton
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
IdleColour = colours.CommunityUserGrayGreen;
|
||||
HoverColour = colours.CommunityUserGrayGreen.Darken(0.2f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
45
osu.Game/Overlays/Profile/Header/ExpandDetailsButton.cs
Normal file
45
osu.Game/Overlays/Profile/Header/ExpandDetailsButton.cs
Normal file
@ -0,0 +1,45 @@
|
||||
// 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.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header
|
||||
{
|
||||
public class ExpandDetailsButton : ProfileHeaderButton
|
||||
{
|
||||
public readonly BindableBool DetailsVisible = new BindableBool();
|
||||
|
||||
public override string TooltipText => DetailsVisible.Value ? "collapse" : "expand";
|
||||
|
||||
private SpriteIcon icon;
|
||||
|
||||
public ExpandDetailsButton()
|
||||
{
|
||||
Action = () => DetailsVisible.Toggle();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
IdleColour = colours.CommunityUserGrayGreen;
|
||||
HoverColour = colours.CommunityUserGrayGreen.Darken(0.2f);
|
||||
|
||||
Child = icon = new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(20, 12)
|
||||
};
|
||||
|
||||
DetailsVisible.BindValueChanged(visible => updateState(visible.NewValue), true);
|
||||
}
|
||||
|
||||
private void updateState(bool detailsVisible) => icon.Icon = detailsVisible ? FontAwesome.Solid.ChevronUp : FontAwesome.Solid.ChevronDown;
|
||||
}
|
||||
}
|
58
osu.Game/Overlays/Profile/Header/FriendButton.cs
Normal file
58
osu.Game/Overlays/Profile/Header/FriendButton.cs
Normal file
@ -0,0 +1,58 @@
|
||||
// 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.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header
|
||||
{
|
||||
public class FriendButton : ProfileHeaderButton
|
||||
{
|
||||
public readonly Bindable<User> User = new Bindable<User>();
|
||||
|
||||
public override string TooltipText => "friends";
|
||||
|
||||
private OsuSpriteText followerText;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Padding = new MarginPadding { Right = 10 },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Icon = FontAwesome.Solid.User,
|
||||
FillMode = FillMode.Fit,
|
||||
Size = new Vector2(50, 14)
|
||||
},
|
||||
followerText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
User.BindValueChanged(user => updateFollowers(user.NewValue), true);
|
||||
}
|
||||
|
||||
private void updateFollowers(User user) => followerText.Text = user?.FollowerCount?.Length > 0 ? user.FollowerCount[0].ToString("#,##0") : "0";
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
@ -11,8 +12,10 @@ using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header
|
||||
{
|
||||
public class ProfileHeaderButton : OsuHoverContainer
|
||||
public abstract class ProfileHeaderButton : OsuHoverContainer, IHasTooltip
|
||||
{
|
||||
public abstract string TooltipText { get; }
|
||||
|
||||
private readonly Box background;
|
||||
private readonly Container content;
|
||||
|
||||
@ -20,7 +23,7 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
|
||||
protected override IEnumerable<Drawable> EffectTargets => new[] { background };
|
||||
|
||||
public ProfileHeaderButton()
|
||||
protected ProfileHeaderButton()
|
||||
{
|
||||
AutoSizeAxes = Axes.X;
|
||||
|
||||
|
@ -16,6 +16,8 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
{
|
||||
public readonly Bindable<User> User = new Bindable<User>();
|
||||
|
||||
public override string TooltipText => "send message";
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private ChannelManager channelManager { get; set; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user