1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 20:07:29 +08:00

Merge pull request #28831 from peppy/tooltips

Add tooltips to summary timeline display
This commit is contained in:
Bartłomiej Dach 2024-07-12 12:54:03 +02:00 committed by GitHub
commit 152e2d0d60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 67 additions and 15 deletions

View File

@ -2,6 +2,9 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Localisation;
using osu.Game.Extensions;
using osu.Game.Graphics;
using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations;
@ -19,16 +22,17 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
Add(new BookmarkVisualisation(bookmark));
}
private partial class BookmarkVisualisation : PointVisualisation
private partial class BookmarkVisualisation : PointVisualisation, IHasTooltip
{
public BookmarkVisualisation(double startTime)
: base(startTime)
{
Width = 2;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours) => Colour = colours.Blue;
public LocalisableString TooltipText => $"{StartTime.ToEditorFormattedString()} bookmark";
}
}
}

View File

@ -4,9 +4,12 @@
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Pooling;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation;
using osu.Game.Beatmaps.Timing;
using osu.Game.Extensions;
using osu.Game.Graphics;
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
@ -46,12 +49,15 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
}, true);
}
private partial class BreakVisualisation : PoolableDrawable
private partial class BreakVisualisation : PoolableDrawable, IHasTooltip
{
private BreakPeriod breakPeriod = null!;
public BreakPeriod BreakPeriod
{
set
{
breakPeriod = value;
X = (float)value.StartTime;
Width = (float)value.Duration;
}
@ -66,6 +72,8 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
InternalChild = new Circle { RelativeSizeAxes = Axes.Both };
Colour = colours.Gray6;
}
public LocalisableString TooltipText => $"{breakPeriod.StartTime.ToEditorFormattedString()} - {breakPeriod.EndTime.ToEditorFormattedString()} break time";
}
}
}

View File

@ -2,18 +2,23 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Localisation;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Extensions;
using osu.Game.Graphics;
using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations;
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
{
public partial class ControlPointVisualisation : PointVisualisation, IControlPointVisualisation
public partial class ControlPointVisualisation : PointVisualisation, IControlPointVisualisation, IHasTooltip
{
protected readonly ControlPoint Point;
public ControlPointVisualisation(ControlPoint point)
: base(point.Time)
{
Point = point;
Alpha = 0.3f;
@ -27,5 +32,22 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
}
public bool IsVisuallyRedundant(ControlPoint other) => other.GetType() == Point.GetType();
public LocalisableString TooltipText
{
get
{
switch (Point)
{
case EffectControlPoint effect:
return $"{StartTime.ToEditorFormattedString()} effect [{effect.ScrollSpeed:N2}x scroll{(effect.KiaiMode ? " kiai" : "")}]";
case TimingControlPoint timing:
return $"{StartTime.ToEditorFormattedString()} timing [{timing.BPM:N2} bpm {timing.TimeSignature.GetDescription()}]";
}
return string.Empty;
}
}
}
}

View File

@ -5,8 +5,11 @@ 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.Shapes;
using osu.Framework.Localisation;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Extensions;
using osu.Game.Graphics;
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
@ -90,7 +93,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
Width = (float)(nextControlPoint.Time - effect.Time);
AddInternal(new Circle
AddInternal(new KiaiVisualisation(effect.Time, nextControlPoint.Time)
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.BottomLeft,
@ -102,6 +105,20 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
}
}
private partial class KiaiVisualisation : Circle, IHasTooltip
{
private readonly double startTime;
private readonly double endTime;
public KiaiVisualisation(double startTime, double endTime)
{
this.startTime = startTime;
this.endTime = endTime;
}
public LocalisableString TooltipText => $"{startTime.ToEditorFormattedString()} - {endTime.ToEditorFormattedString()} kiai time";
}
// kiai sections display duration, so are required to be visualised.
public bool IsVisuallyRedundant(ControlPoint other) => other is EffectControlPoint otherEffect && effect.KiaiMode == otherEffect.KiaiMode;
}

View File

@ -3,6 +3,9 @@
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Localisation;
using osu.Game.Extensions;
using osu.Game.Graphics;
using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations;
@ -27,7 +30,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
}, true);
}
private partial class PreviewTimeVisualisation : PointVisualisation
private partial class PreviewTimeVisualisation : PointVisualisation, IHasTooltip
{
public PreviewTimeVisualisation(double time)
: base(time)
@ -37,6 +40,8 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
[BackgroundDependencyLoader]
private void load(OsuColour colours) => Colour = colours.Green1;
public LocalisableString TooltipText => $"{StartTime.ToEditorFormattedString()} preview time";
}
}
}

View File

@ -71,7 +71,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary
Anchor = Anchor.Centre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.Both,
Height = 0.35f
Height = 0.4f
},
new BreakPart
{

View File

@ -16,13 +16,6 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations
public const float MAX_WIDTH = 4;
public PointVisualisation(double startTime)
: this()
{
X = (float)startTime;
StartTime = startTime;
}
public PointVisualisation()
{
RelativePositionAxes = Axes.Both;
RelativeSizeAxes = Axes.Y;
@ -32,6 +25,9 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations
Width = MAX_WIDTH;
Height = 0.4f;
X = (float)startTime;
StartTime = startTime;
}
}
}

View File

@ -191,7 +191,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
{
PointVisualisation point;
if (drawableIndex >= Count)
Add(point = new PointVisualisation());
Add(point = new PointVisualisation(0));
else
point = Children[drawableIndex];