-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement time creator with not much setting.
Also move isChinses method to CharUtils.
- Loading branch information
1 parent
0a53398
commit 8af76b3
Showing
6 changed files
with
114 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
osu.Game.Rulesets.Karaoke.Tests/Utils/ZhStringUtilsTest.cs
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
osu.Game.Rulesets.Karaoke/Edit/Generator/TimeTags/Zh/ZhTimeTagGenerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,31 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Framework.Graphics.Sprites; | ||
using osu.Game.Rulesets.Karaoke.Objects; | ||
using osu.Game.Rulesets.Karaoke.Utils; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Edit.Generator.TimeTags.Zh | ||
{ | ||
public class ZhTimeTagGenerator : TimeTagGenerator<ZhTimeTagGeneratorConfig> | ||
{ | ||
public ZhTimeTagGenerator(ZhTimeTagGeneratorConfig config) | ||
: base(config) | ||
{ | ||
} | ||
|
||
protected override void TimeTagLogic(Lyric lyric, List<Tuple<TimeTagIndex, double?>> timeTags) | ||
{ | ||
var text = lyric.Text; | ||
for (var i = 1; i < text.Length; i++) | ||
{ | ||
if (CharUtils.IsChinese(text[i])) | ||
{ | ||
timeTags.Add(TimeTagsUtils.Create(new TimeTagIndex(i, TimeTagIndex.IndexState.Start), null)); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Text.Unicode; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Utils | ||
{ | ||
public static class CharUtils | ||
|
@@ -43,5 +45,18 @@ public static bool IsAsciiSymbol(char c) | |
c >= '[' && c <= '`' || | ||
c >= '{' && c <= '~'; | ||
} | ||
|
||
/// <summary> | ||
/// Check this char is chinese character | ||
/// </summary> | ||
/// <param name="character"></param> | ||
/// <returns></returns> | ||
public static bool IsChinese(char character) | ||
{ | ||
// From : https://stackoverflow.com/a/61738863/4105113 | ||
var minValue = UnicodeRanges.CjkUnifiedIdeographs.FirstCodePoint; | ||
var maxValue = minValue + UnicodeRanges.CjkUnifiedIdeographs.Length; | ||
return character >= minValue && character < maxValue; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.