mirror of
https://github.com/ppy/osu.git
synced 2024-12-16 06:23:20 +08:00
d7c09e7dbd
# Conflicts: # osu.Game.Rulesets.Catch/Judgements/CatchDropletJudgement.cs # osu.Game.Rulesets.Catch/Judgements/CatchJudgement.cs # osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs # osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs # osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs # osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs # osu.Game/Graphics/OsuFont.cs # osu.Game/Online/API/Requests/Responses/APILegacyScoreInfo.cs # osu.Game/Overlays/Profile/Header/BadgeContainer.cs # osu.Game/Overlays/Profile/ProfileHeader.cs # osu.Game/Screens/Select/PlaySongSelect.cs # osu.Game/Skinning/LegacySkinDecoder.cs
107 lines
3.2 KiB
C#
107 lines
3.2 KiB
C#
// 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 osuTK;
|
|
using osuTK.Graphics;
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Cursor;
|
|
using osu.Framework.Graphics.Effects;
|
|
using osu.Framework.Graphics.Shapes;
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
namespace osu.Game.Graphics.Cursor
|
|
{
|
|
public class OsuTooltipContainer : TooltipContainer
|
|
{
|
|
protected override ITooltip CreateTooltip() => new OsuTooltip();
|
|
|
|
public OsuTooltipContainer(CursorContainer cursor)
|
|
: base(cursor)
|
|
{
|
|
}
|
|
|
|
protected override double AppearDelay => (1 - CurrentTooltip.Alpha) * base.AppearDelay; // reduce appear delay if the tooltip is already partly visible.
|
|
|
|
public class OsuTooltip : Tooltip
|
|
{
|
|
private readonly Box background;
|
|
private readonly OsuSpriteText text;
|
|
private bool instantMovement = true;
|
|
|
|
public override string TooltipText
|
|
{
|
|
set
|
|
{
|
|
if (value == text.Text) return;
|
|
|
|
text.Text = value;
|
|
|
|
if (IsPresent)
|
|
{
|
|
AutoSizeDuration = 250;
|
|
background.FlashColour(OsuColour.Gray(0.4f), 1000, Easing.OutQuint);
|
|
}
|
|
else
|
|
AutoSizeDuration = 0;
|
|
}
|
|
}
|
|
|
|
public OsuTooltip()
|
|
{
|
|
AutoSizeEasing = Easing.OutQuint;
|
|
|
|
CornerRadius = 5;
|
|
Masking = true;
|
|
EdgeEffect = new EdgeEffectParameters
|
|
{
|
|
Type = EdgeEffectType.Shadow,
|
|
Colour = Color4.Black.Opacity(40),
|
|
Radius = 5,
|
|
};
|
|
Children = new Drawable[]
|
|
{
|
|
background = new Box
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
Alpha = 0.9f,
|
|
},
|
|
text = new OsuSpriteText
|
|
{
|
|
Padding = new MarginPadding(5),
|
|
Font = OsuFont.GetFont(weight: FontWeight.Regular)
|
|
}
|
|
};
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load(OsuColour colour)
|
|
{
|
|
background.Colour = colour.Gray3;
|
|
}
|
|
|
|
protected override void PopIn()
|
|
{
|
|
instantMovement |= !IsPresent;
|
|
this.FadeIn(500, Easing.OutQuint);
|
|
}
|
|
|
|
protected override void PopOut() => this.Delay(150).FadeOut(500, Easing.OutQuint);
|
|
|
|
public override void Move(Vector2 pos)
|
|
{
|
|
if (instantMovement)
|
|
{
|
|
Position = pos;
|
|
instantMovement = false;
|
|
}
|
|
else
|
|
{
|
|
this.MoveTo(pos, 200, Easing.OutQuint);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|