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 more cases for handle the ruby text in the time-tag tag helper. #2076

Merged
merged 1 commit into from
Jul 22, 2023
Merged
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
12 changes: 11 additions & 1 deletion osu.Game.Rulesets.Karaoke.Tests/Helper/TestCaseTagHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ public static RomajiTag ParseRomajiTag(string? str)
/// [0,start]:1000 -> has time-tag index with time.<br/>
/// [0,start] -> has time-tag index with no time.<br/>
/// [0,start]: -> has time-tag index with no time.<br/>
/// [0,start]#karaoke -> has time-tag index with romaji.<br/>
/// [0,start]#^karaoke -> has time-tag index with romaji, and it's initial romaji.<br/>
/// [0,start]:1000#karaoke -> has time-tag index with time and romaji.<br/>
/// </example>
/// <param name="str">Time tag string format</param>
/// <returns><see cref="TimeTag"/>Time tag object</returns>
Expand All @@ -137,6 +140,7 @@ public static TimeTag ParseTimeTag(string? str)
string regex = generateRegex(time_index_regex, new[]
{
getNumberPropertyRegex(':', "time"),
getStringPropertyRegex('#', "text"),
});

return getMatchByStatement<TimeTag>(str, regex, result =>
Expand All @@ -147,8 +151,14 @@ public static TimeTag ParseTimeTag(string? str)
int index = result.GetGroupValue<int>("index");
var state = result.GetGroupValue<string>("state") == "start" ? TextIndex.IndexState.Start : TextIndex.IndexState.End;
int? time = result.GetGroupValue<int?>("time");
string? text = result.GetGroupValue<string?>("text");
bool? initialRomaji = text?.StartsWith("^");

return new TimeTag(new TextIndex(index, state), time);
return new TimeTag(new TextIndex(index, state), time)
{
RomajiText = text?.Replace("^", ""),
InitialRomaji = initialRomaji ?? default,
};
});
}

Expand Down