Skip to content

Commit

Permalink
IPreviewLyricPositionProvider should only provide the ruby tag positi…
Browse files Browse the repository at this point in the history
…on now.
  • Loading branch information
andy840119 committed Sep 29, 2023
1 parent 8a7bcee commit dff6246
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,24 +184,7 @@ public void TestGetRubyPosition()
{
AddStep($"Show ruby-tag position: {TextTagUtils.PositionFormattedString(rubyTag)}", () =>
{
var position = karaokeSpriteText.GetTextTagByPosition(rubyTag);
showPosition(position);
});
}
}

#endregion

#region Romaji tag

[Test]
public void TestGetRomajiTagPosition()
{
foreach (var romajiTag in lyric.RomajiTags)
{
AddStep($"Show romaji-tag position: {TextTagUtils.PositionFormattedString(romajiTag)}", () =>
{
var position = karaokeSpriteText.GetTextTagByPosition(romajiTag);
var position = karaokeSpriteText.GetRubyTagByPosition(rubyTag);
showPosition(position);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void setRubyTagIndex(RubyTag rubyTag, int? startPosition, int? endPosition)
private int? calculateNewIndex(RubyTag rubyTag, float offset, Anchor anchor)
{
// get real left-side and right-side position
var rect = previewLyricPositionProvider.GetTextTagByPosition(rubyTag);
var rect = previewLyricPositionProvider.GetRubyTagByPosition(rubyTag);

// todo: need to think about how to handle the case if the text-tag already out of the range of the text.
if (rect == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected void UpdatePositionAndSize()
// wait until lyric update ruby position.
ScheduleAfterChildren(() =>
{
var rubyTagRect = previewLyricPositionProvider.GetTextTagByPosition(Item);
var rubyTagRect = previewLyricPositionProvider.GetRubyTagByPosition(Item);

if (rubyTagRect == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using osu.Framework.Graphics.Primitives;
using osu.Game.Rulesets.Karaoke.Objects;
using osu.Game.Rulesets.Karaoke.Objects.Types;
using osuTK;

namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Components.Lyrics;
Expand All @@ -18,7 +17,7 @@ public interface IPreviewLyricPositionProvider

RectangleF GetRectByCharIndicator(int charIndex);

RectangleF? GetTextTagByPosition(ITextTag textTag);
RectangleF? GetRubyTagByPosition(RubyTag rubyTag);

TimeTag? GetTimeTagByPosition(float position);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Karaoke.Graphics.Sprites;
using osu.Game.Rulesets.Karaoke.Objects;
using osu.Game.Rulesets.Karaoke.Objects.Types;
using osu.Game.Rulesets.Karaoke.Objects.Utils;
using osu.Game.Rulesets.Karaoke.Skinning.Elements;
using osu.Game.Rulesets.Karaoke.Skinning.Tools;
Expand Down Expand Up @@ -126,15 +125,10 @@ public RectangleF GetRectByCharIndicator(int charIndex)

#endregion

#region Ruby/Romaji tag
#region Ruby tag

public RectangleF? GetTextTagByPosition(ITextTag textTag) =>
textTag switch
{
RubyTag rubyTag => spriteText.GetRubyTagPosition(rubyTag),
RomajiTag romajiTag => spriteText.GetRomajiTagPosition(romajiTag),
_ => throw new ArgumentOutOfRangeException(nameof(textTag)),
};
public RectangleF? GetRubyTagByPosition(RubyTag rubyTag) =>
spriteText.GetRubyTagPosition(rubyTag);

#endregion

Expand Down

0 comments on commit dff6246

Please sign in to comment.