Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tooltips to summary timeline display #28831

Merged
merged 5 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -19,16 +22,17 @@ protected override void LoadBeatmap(EditorBeatmap beatmap)
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";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -46,12 +49,15 @@ protected override void LoadComplete()
}, 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;
}
Expand All @@ -66,6 +72,8 @@ private void load(OsuColour colours)
InternalChild = new Circle { RelativeSizeAxes = Axes.Both };
Colour = colours.Gray6;
}

public LocalisableString TooltipText => $"{breakPeriod.StartTime.ToEditorFormattedString()} - {breakPeriod.EndTime.ToEditorFormattedString()} break time";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,5 +32,22 @@ private void load(OsuColour colours)
}

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;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
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
Expand Down Expand Up @@ -90,7 +93,7 @@ private void refreshDisplay()

Width = (float)(nextControlPoint.Time - effect.Time);

AddInternal(new Circle
AddInternal(new KiaiVisualisation(effect.Time, nextControlPoint.Time)
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.BottomLeft,
Expand All @@ -102,6 +105,20 @@ private void refreshDisplay()
}
}

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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -27,7 +30,7 @@ protected override void LoadBeatmap(EditorBeatmap beatmap)
}, true);
}

private partial class PreviewTimeVisualisation : PointVisualisation
private partial class PreviewTimeVisualisation : PointVisualisation, IHasTooltip
{
public PreviewTimeVisualisation(double time)
: base(time)
Expand All @@ -37,6 +40,8 @@ public PreviewTimeVisualisation(double time)

[BackgroundDependencyLoader]
private void load(OsuColour colours) => Colour = colours.Green1;

public LocalisableString TooltipText => $"{StartTime.ToEditorFormattedString()} preview time";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void load(OverlayColourProvider colourProvider)
Anchor = Anchor.Centre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.Both,
Height = 0.35f
Height = 0.4f
},
new BreakPart
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ public partial class PointVisualisation : Circle
public const float MAX_WIDTH = 4;

public PointVisualisation(double startTime)
: this()
{
X = (float)startTime;
StartTime = startTime;
}

public PointVisualisation()
{
RelativePositionAxes = Axes.Both;
RelativeSizeAxes = Axes.Y;
Expand All @@ -32,6 +25,9 @@ public PointVisualisation()

Width = MAX_WIDTH;
Height = 0.4f;

X = (float)startTime;
StartTime = startTime;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Drawable getNextUsableLine()
{
PointVisualisation point;
if (drawableIndex >= Count)
Add(point = new PointVisualisation());
Add(point = new PointVisualisation(0));
else
point = Children[drawableIndex];

Expand Down
Loading