Skip to content

Commit

Permalink
Rename the methods.
Browse files Browse the repository at this point in the history
Should use GetXXXDrawRectangle() instead.
  • Loading branch information
andy840119 committed May 20, 2022
1 parent 5c8b5d6 commit 6a7b2ac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ public TestSceneLyricSpriteTextCharacterPosition()
[TestCase(6, TextIndex.IndexState.End, true)]
[TestCase(-1, TextIndex.IndexState.End, false)]
[TestCase(7, TextIndex.IndexState.Start, false)]
public void TestGetTextIndexPosition(int index, TextIndex.IndexState state, bool valid)
public void TestGetTextIndexXPosition(int index, TextIndex.IndexState state, bool valid)
{
prepareTestCase(() =>
{
var position = lyricSpriteText.GetTextIndexPosition(new TextIndex(index, state));
var position = lyricSpriteText.GetTextIndexXPosition(new TextIndex(index, state));
return new RectangleF(position, 20, 1, 64);
}, valid);
}
Expand All @@ -106,9 +106,9 @@ public void TestGetTextIndexPosition(int index, TextIndex.IndexState state, bool
[TestCase(6, true)]
[TestCase(-1, false)]
[TestCase(7, false)]
public void TestGetCharacterRectangle(int index, bool valid)
public void TestGetCharacterDrawRectangle(int index, bool valid)
{
prepareTestCase(() => lyricSpriteText.GetCharacterRectangle(index), valid);
prepareTestCase(() => lyricSpriteText.GetCharacterDrawRectangle(index), valid);
}

[TestCase("[0,1]:か", true)]
Expand All @@ -119,9 +119,9 @@ public void TestGetCharacterRectangle(int index, bool valid)
[TestCase("[-1,1]:か", false)]
[TestCase("[0,2]:か", false)]
[TestCase("[0,1]:?", false)]
public void TestGetRubyTagPosition(string rubyTag, bool valid)
public void TestGetRubyTagDrawRectangle(string rubyTag, bool valid)
{
prepareTestCase(() => lyricSpriteText.GetRubyTagPosition(TestCaseTagHelper.ParsePositionText(rubyTag)), valid);
prepareTestCase(() => lyricSpriteText.GetRubyTagDrawRectangle(TestCaseTagHelper.ParsePositionText(rubyTag)), valid);
}

[TestCase("[0,1]:ka", true)]
Expand All @@ -132,9 +132,9 @@ public void TestGetRubyTagPosition(string rubyTag, bool valid)
[TestCase("[-1,1]:ka", false)]
[TestCase("[0,2]:ka", false)]
[TestCase("[0,1]:?", false)]
public void TestGetRomajiTagPosition(string rubyTag, bool valid)
public void TestGetRomajiTagDrawRectangle(string rubyTag, bool valid)
{
prepareTestCase(() => lyricSpriteText.GetRomajiTagPosition(TestCaseTagHelper.ParsePositionText(rubyTag)), valid);
prepareTestCase(() => lyricSpriteText.GetRomajiTagDrawRectangle(TestCaseTagHelper.ParsePositionText(rubyTag)), valid);
}

private void prepareTestCase(Func<RectangleF> func, bool valid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ IEnumerable<KeyValuePair<double, TextIndex>> getInterpolatedTimeTagBetweenTwoTim

private float getTextIndexPosition(TextIndex index)
{
var leftTextIndexPosition = leftLyricText.GetTextIndexPosition(index);
var rightTextIndexPosition = rightLyricText.GetTextIndexPosition(index);
var leftTextIndexPosition = leftLyricText.GetTextIndexXPosition(index);
var rightTextIndexPosition = rightLyricText.GetTextIndexXPosition(index);
return index.State == TextIndex.IndexState.Start
? Math.Min(leftTextIndexPosition, rightTextIndexPosition)
: Math.Max(leftTextIndexPosition, rightTextIndexPosition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,13 @@ private void computeScreenSpaceCharacters()

#region Character position

public float GetTextIndexPosition(TextIndex index)
public float GetTextIndexXPosition(TextIndex index)
{
var computedRectangle = GetCharacterRectangle(index.Index);
var computedRectangle = GetCharacterDrawRectangle(index.Index);
return index.State == TextIndex.IndexState.Start ? computedRectangle.Left : computedRectangle.Right;
}

public RectangleF GetCharacterRectangle(int index, bool drawSizeOnly = false)
public RectangleF GetCharacterDrawRectangle(int index, bool drawSizeOnly = false)
{
int charIndex = Math.Clamp(index, 0, Text.Length - 1);
if (charIndex != index)
Expand All @@ -275,7 +275,7 @@ public RectangleF GetCharacterRectangle(int index, bool drawSizeOnly = false)
return getComputeCharacterDrawRectangle(drawRectangle);
}

public RectangleF GetRubyTagPosition(PositionText rubyTag, bool drawSizeOnly = false)
public RectangleF GetRubyTagDrawRectangle(PositionText rubyTag, bool drawSizeOnly = false)
{
int rubyIndex = Rubies.ToList().IndexOf(rubyTag);
if (rubyIndex < 0)
Expand All @@ -290,7 +290,7 @@ public RectangleF GetRubyTagPosition(PositionText rubyTag, bool drawSizeOnly = f
return getComputeCharacterDrawRectangle(drawRectangle);
}

public RectangleF GetRomajiTagPosition(PositionText romajiTag, bool drawSizeOnly = false)
public RectangleF GetRomajiTagDrawRectangle(PositionText romajiTag, bool drawSizeOnly = false)
{
int romajiIndex = Romajies.ToList().IndexOf(romajiTag);
if (romajiIndex < 0)
Expand Down

0 comments on commit 6a7b2ac

Please sign in to comment.