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 method for able to change time-tag romaji text and the initial state in the change handler. #2079

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 @@ -84,6 +84,55 @@ public void TestSetTimeTagTime()
});
}

[Test]
public void TestSetTimeTagInitialRomaji()
{
var timeTag = new TimeTag(new TextIndex(), 1000);
PrepareHitObject(() => new Lyric
{
Text = "カラオケ",
TimeTags = new[]
{
timeTag,
},
});

TriggerHandlerChanged(c => c.SetTimeTagInitialRomaji(timeTag, true));

AssertSelectedHitObject(_ =>
{
Assert.AreEqual(true, timeTag.InitialRomaji);
});
}

[Test]
public void TestSetTimeTagRomajiText()
{
var timeTag = new TimeTag(new TextIndex(), 1000);
PrepareHitObject(() => new Lyric
{
Text = "カラオケ",
TimeTags = new[]
{
timeTag,
},
});

TriggerHandlerChanged(c => c.SetTimeTagRomajiText(timeTag, "karaoke"));

AssertSelectedHitObject(_ =>
{
Assert.AreEqual("karaoke", timeTag.RomajiText);
});

TriggerHandlerChanged(c => c.SetTimeTagRomajiText(timeTag, " "));

AssertSelectedHitObject(_ =>
{
Assert.AreEqual(string.Empty, timeTag.RomajiText);
});
}

[Test]
public void TestShiftingTimeTagTime()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ public interface ILyricTimeTagsChangeHandler : ILyricListPropertyChangeHandler<T
{
void SetTimeTagTime(TimeTag timeTag, double time);

void SetTimeTagInitialRomaji(TimeTag timeTag, bool initialRomaji);

void SetTimeTagRomajiText(TimeTag timeTag, string romaji);

void ShiftingTimeTagTime(IEnumerable<TimeTag> timeTags, double offset);

void ClearTimeTagTime(TimeTag timeTag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,40 @@ public void SetTimeTagTime(TimeTag timeTag, double time)
});
}

public void SetTimeTagInitialRomaji(TimeTag timeTag, bool initialRomaji)
{
CheckExactlySelectedOneHitObject();

PerformOnSelection(lyric =>
{
bool containsInLyric = lyric.TimeTags.Contains(timeTag);
if (!containsInLyric)
throw new InvalidOperationException($"{nameof(timeTag)} is not in the lyric");

timeTag.InitialRomaji = initialRomaji;
});
}

public void SetTimeTagRomajiText(TimeTag timeTag, string romaji)
{
CheckExactlySelectedOneHitObject();

PerformOnSelection(lyric =>
{
bool containsInLyric = lyric.TimeTags.Contains(timeTag);
if (!containsInLyric)
throw new InvalidOperationException($"{nameof(timeTag)} is not in the lyric");

timeTag.RomajiText = romaji;

if (!string.IsNullOrWhiteSpace(romaji))
return;

timeTag.RomajiText = string.Empty;
timeTag.InitialRomaji = false;
});
}

public void ShiftingTimeTagTime(IEnumerable<TimeTag> timeTags, double offset)
{
CheckExactlySelectedOneHitObject();
Expand Down