Skip to content

Commit

Permalink
Lyric position provider should consider about the lyric's own position.
Browse files Browse the repository at this point in the history
  • Loading branch information
andy840119 committed Jul 20, 2024
1 parent 0095970 commit 950b3a3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ private void load(OsuColour colour)
RelativeSizeAxes = Axes.Both,
Colour = colour.BlueDarker,
},
karaokeSpriteText = new PreviewKaraokeSpriteText(lyric),
karaokeSpriteText = new PreviewKaraokeSpriteText(lyric)
{
Position = new Vector2(24, 8),
},
mask = new Container
{
Masking = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ private void triggerSizeChangedEvent()
#region Text char index

public int? GetCharIndexByPosition(float position)
=> getCharIndexByPosition(position - Position.X);

private int? getCharIndexByPosition(float position)
{
for (int i = 0; i < Text.Length; i++)
{
Expand All @@ -84,6 +87,9 @@ Tuple<double, double> getTriggerPositionByTimeIndex(int charIndex)
}

public RectangleF GetRectByCharIndex(int charIndex)
=> getRectByCharIndex(charIndex).Offset(Position);

private RectangleF getRectByCharIndex(int charIndex)
{
if (charIndex < 0 || charIndex >= Text.Length)
throw new ArgumentOutOfRangeException(nameof(charIndex));
Expand All @@ -96,6 +102,9 @@ public RectangleF GetRectByCharIndex(int charIndex)
#region Text indicator

public int GetCharIndicatorByPosition(float position)
=> getCharIndicatorByPosition(position - Position.X);

private int getCharIndicatorByPosition(float position)
{
for (int i = 0; i < Text.Length; i++)
{
Expand All @@ -114,6 +123,9 @@ float getTriggerPositionByTimeIndex(int charIndex)
}

public RectangleF GetRectByCharIndicator(int charIndex)
=> getRectByCharIndicator(charIndex).Offset(Position);

private RectangleF getRectByCharIndicator(int charIndex)
{
if (charIndex < 0 || charIndex > Text.Length)
throw new ArgumentOutOfRangeException(nameof(charIndex));
Expand Down Expand Up @@ -142,13 +154,19 @@ public RectangleF GetRectByCharIndicator(int charIndex)
#region Ruby tag

public RectangleF? GetRubyTagByPosition(RubyTag rubyTag) =>
getRubyTagByPosition(rubyTag)?.Offset(Position);

private RectangleF? getRubyTagByPosition(RubyTag rubyTag) =>
spriteText.GetRubyTagPosition(rubyTag);

#endregion

#region Time tag

public TimeTag? GetTimeTagByPosition(float position)
=> getTimeTagByPosition(position - Position.X);

private TimeTag? getTimeTagByPosition(float position)
{
var hoverIndex = getHoverIndex();
if (hoverIndex == null)
Expand Down Expand Up @@ -184,6 +202,9 @@ Tuple<float, float> getTriggerRange(TextIndex textIndex)
}

public Vector2 GetPositionByTimeTag(TimeTag timeTag)
=> getPositionByTimeTag(timeTag) + Position;

private Vector2 getPositionByTimeTag(TimeTag timeTag)
{
var basePosition = spriteText.GetTimeTagPosition(timeTag.Index);
float extraPosition = extraSpacing(HitObject.TimeTags, timeTag);
Expand Down

0 comments on commit 950b3a3

Please sign in to comment.