-
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.
Merge pull request #287 from andy840119/import/implement-language-cal…
…culation Implement auto-generate in import screen.
- Loading branch information
Showing
23 changed files
with
306 additions
and
33 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
34 changes: 34 additions & 0 deletions
34
osu.Game.Rulesets.Karaoke.Tests/Resources/Testing/Lrc/light.lrc
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
枯れた世界に輝く 名もない永遠の華 | ||
強く生きていけるよう 私を変えていく | ||
|
||
あぁ、わかっていたの 本当は | ||
光なんて求めちゃいけないってこと | ||
|
||
あぁ、それでもきっと人は | ||
輝く未来なんてものを求めてさまよう | ||
|
||
女神なんて 信じてるわけじゃない | ||
未来をこの 手で切り開く勇気が 強さがほしい | ||
あなたを守りたい | ||
|
||
枯れた世界に輝く 名もない永遠の華 | ||
強く生きていけるよう 私を変えていく | ||
|
||
あぁ、例えこの世が暗く | ||
絶望に飲み込まれても 私は大丈夫 | ||
|
||
あなたがいればそこは | ||
灰色(いろ)(いろ)の景色(いろ)(いろ)さえ色づき始める | ||
|
||
華もきっと 咲き誇るときを終え | ||
いつかきっと また蕾をつけるだろう | ||
終わることない | ||
生命(いのち)が続くまでは | ||
|
||
あなたの手を離さない 瞳に誓う 永遠の恋 | ||
強く儚い思いを 守り続けていたい | ||
|
||
枯れた世界に輝く 名もない永遠の華 | ||
強く生き抜きけるように 私を変えていく | ||
あなたの手を離さない 瞳に誓う 永遠の恋 | ||
強く儚い思いを 守り続けていたい |
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
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
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,7 @@ | ||
// 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.Allocation; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Sprites; | ||
using osu.Game.Rulesets.Karaoke.Edit.RubyRomaji; | ||
|
@@ -17,6 +18,14 @@ public class GenerateRubySubScreen : ImportLyricSubScreenWithTopNavigation | |
|
||
public override IconUsage Icon => FontAwesome.Solid.Gem; | ||
|
||
[Cached] | ||
protected readonly RubyRomajiManager RubyRomajiManager; | ||
|
||
public GenerateRubySubScreen() | ||
{ | ||
AddInternal(RubyRomajiManager = new RubyRomajiManager()); | ||
} | ||
|
||
protected override TopNavigation CreateNavigation() | ||
=> new GenerateRubyNavigation(this); | ||
|
||
|
@@ -42,7 +51,8 @@ protected void AskForAutoGenerateRuby() | |
{ | ||
DialogOverlay.Push(new UseAutoGenerateRubyPopupDialog(ok => | ||
{ | ||
// todo : call manager to do that. | ||
if (ok) | ||
RubyRomajiManager.AutoGenerateRubyTags(); | ||
})); | ||
} | ||
|
||
|
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// 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.Allocation; | ||
using osu.Framework.Graphics; | ||
using osu.Game.Rulesets.Karaoke.Edit.Generator.Languages; | ||
using osu.Game.Rulesets.Karaoke.Objects; | ||
using osu.Game.Screens.Edit; | ||
using System.Linq; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics | ||
{ | ||
public class LyricManager : Component | ||
{ | ||
[Resolved] | ||
private EditorBeatmap beatmap { get; set; } | ||
|
||
[Resolved(CanBeNull = true)] | ||
private IEditorChangeHandler changeHandler { get; set; } | ||
|
||
/// <summary> | ||
/// Will auto-detect each <see cref="Lyric"/> 's <see cref="Lyric.Language"/> and apply on them. | ||
/// </summary> | ||
public void AutoDetectLyricLanguage() | ||
{ | ||
var lyrics = beatmap.HitObjects.OfType<Lyric>().ToList(); | ||
if (!lyrics.Any()) | ||
return; | ||
|
||
// todo : should get the config from setting. | ||
var config = new LanguageDetectorConfig(); | ||
var detector = new LanguageDetector(config); | ||
|
||
changeHandler?.BeginChange(); | ||
|
||
foreach (var lyric in lyrics) | ||
{ | ||
var detectedLanguage = detector.DetectLanguage(lyric); | ||
lyric.Language = detectedLanguage; | ||
} | ||
|
||
changeHandler?.EndChange(); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// 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.Allocation; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Sprites; | ||
using osu.Game.Rulesets.Karaoke.Edit.Generator.TimeTags.Ja; | ||
using osu.Game.Rulesets.Karaoke.Edit.Generator.TimeTags.Zh; | ||
using osu.Game.Rulesets.Karaoke.Objects; | ||
using osu.Game.Screens.Edit; | ||
using System; | ||
using System.Linq; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics | ||
{ | ||
public class TimeTagManager : Component | ||
{ | ||
[Resolved] | ||
private EditorBeatmap beatmap { get; set; } | ||
|
||
[Resolved(CanBeNull = true)] | ||
private IEditorChangeHandler changeHandler { get; set; } | ||
|
||
/// <summary> | ||
/// Will auto-detect each <see cref="Lyric"/> 's <see cref="Lyric.TimeTags"/> and apply on them. | ||
/// </summary> | ||
public void AutoGenerateTimeTags() | ||
{ | ||
var lyrics = beatmap.HitObjects.OfType<Lyric>().ToList(); | ||
if (!lyrics.Any()) | ||
return; | ||
|
||
changeHandler?.BeginChange(); | ||
|
||
var selector = new TimeTagGeneratorSelector(); | ||
|
||
foreach (var lyric in lyrics) | ||
{ | ||
var timeTags = selector.GenerateTimeTags(lyric); | ||
lyric.TimeTags = timeTags; | ||
} | ||
|
||
changeHandler?.EndChange(); | ||
} | ||
|
||
public class TimeTagGeneratorSelector | ||
{ | ||
private readonly Lazy<JaTimeTagGenerator> jaTimeTagGenerator; | ||
private readonly Lazy<ZhTimeTagGenerator> zhTimeTagGenerator; | ||
|
||
public TimeTagGeneratorSelector() | ||
{ | ||
jaTimeTagGenerator = new Lazy<JaTimeTagGenerator>(() => | ||
{ | ||
// todo : get config from setting. | ||
var config = new JaTimeTagGeneratorConfig(); | ||
return new JaTimeTagGenerator(config); | ||
}); | ||
zhTimeTagGenerator = new Lazy<ZhTimeTagGenerator>(() => | ||
{ | ||
// todo : get config from setting. | ||
var config = new ZhTimeTagGeneratorConfig(); | ||
return new ZhTimeTagGenerator(config); | ||
}); | ||
} | ||
|
||
public Tuple<TimeTagIndex, double?>[] GenerateTimeTags(Lyric lyric) | ||
{ | ||
// lazy to generate language detector and apply it's setting | ||
switch (lyric.Language.LCID) | ||
{ | ||
case 17: | ||
case 1041: | ||
return jaTimeTagGenerator.Value.CreateTimeTags(lyric); | ||
|
||
case 1028: | ||
return zhTimeTagGenerator.Value.CreateTimeTags(lyric); | ||
|
||
default: | ||
return null; | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.