Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It's time to say goodbye with the old method.
Browse files Browse the repository at this point in the history
andy840119 committed May 7, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 204424d commit d27d039
Showing 2 changed files with 0 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Karaoke.Objects;
using osu.Game.Rulesets.Karaoke.Objects.Types;
using osuTK;
@@ -24,10 +23,4 @@ public interface IPreviewLyricPositionProvider
TimeTag? GetTimeTagByPosition(float position);

Vector2 GetPositionByTimeTag(TimeTag timeTag);

// todo: will remove this method eventually.
TextIndex GetHoverIndex(float position);

// todo: will remove this method eventually.
Vector2 GetTextIndexPosition(TextIndex index);
}
Original file line number Diff line number Diff line change
@@ -188,38 +188,6 @@ static float extraSpacing(IList<TimeTag> timeTagsInLyric, TimeTag timeTag)

#endregion

// todo: will remove this method eventually.
public TextIndex GetHoverIndex(float position)
{
string text = Text;
if (string.IsNullOrEmpty(text))
return new TextIndex();

for (int i = 0; i < text.Length; i++)
{
if (getTriggerPositionByTimeIndex(new TextIndex(i)) > position)
return new TextIndex(i);

if (getTriggerPositionByTimeIndex(new TextIndex(i, TextIndex.IndexState.End)) > position)
return new TextIndex(i, TextIndex.IndexState.End);
}

return new TextIndex(text.Length - 1, TextIndex.IndexState.End);

// todo : might have a better way to call spriteText.GetTimeTagPosition just once.
float getTriggerPositionByTimeIndex(TextIndex textIndex)
{
int charIndex = textIndex.Index;
float startPosition = spriteText.GetTimeTagPosition(new TextIndex(charIndex)).X;
float endPosition = spriteText.GetTimeTagPosition(new TextIndex(charIndex, TextIndex.IndexState.End)).X;

return TextIndexUtils.GetValueByState(textIndex, () => startPosition + (endPosition - startPosition) / 2, () => endPosition);
}
}

// todo: will remove this method eventually.
public Vector2 GetTextIndexPosition(TextIndex index) => spriteText.GetTimeTagPosition(index);

[BackgroundDependencyLoader(true)]
private void load(ISkinSource skin, ShaderManager shaderManager)
{

0 comments on commit d27d039

Please sign in to comment.