diff --git a/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneImportLyric.cs b/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneImportLyric.cs index 11deda5f6..7a1e81634 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneImportLyric.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneImportLyric.cs @@ -58,7 +58,7 @@ private void load() [Test] public void TestGoToStep() => Schedule(() => { - var temp = TestResources.GetTestLrcForImport("default"); + var temp = TestResources.GetTestLrcForImport("light"); Child = screen = new TestImportLyricScreen(new FileInfo(temp)); var steps = (ImportLyricStep[])Enum.GetValues(typeof(ImportLyricStep)); diff --git a/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneManageLanguagesDialog.cs b/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneManageLanguagesDialog.cs index 952fa69cc..f8579ab34 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneManageLanguagesDialog.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneManageLanguagesDialog.cs @@ -21,7 +21,7 @@ public class TestSceneManageLanguagesDialog : OsuManualInputManagerTestScene protected override Container Content { get; } = new Container { RelativeSizeAxes = Axes.Both }; private DialogOverlay dialogOverlay; - private LanguageManager manager; + private TranslateManager manager; private ManageLanguagesDialog dialog; @@ -35,7 +35,7 @@ private void load() base.Content.AddRange(new Drawable[] { - manager = new LanguageManager(), + manager = new TranslateManager(), Content, dialogOverlay = new DialogOverlay() }); diff --git a/osu.Game.Rulesets.Karaoke.Tests/Resources/Testing/Lrc/light.lrc b/osu.Game.Rulesets.Karaoke.Tests/Resources/Testing/Lrc/light.lrc new file mode 100644 index 000000000..41d51fe78 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke.Tests/Resources/Testing/Lrc/light.lrc @@ -0,0 +1,34 @@ +枯れた世界に輝く 名もない永遠の華 +強く生きていけるよう 私を変えていく + +あぁ、わかっていたの 本当は +光なんて求めちゃいけないってこと + +あぁ、それでもきっと人は +輝く未来なんてものを求めてさまよう + +女神なんて 信じてるわけじゃない +未来をこの 手で切り開く勇気が 強さがほしい +あなたを守りたい + +枯れた世界に輝く 名もない永遠の華 +強く生きていけるよう 私を変えていく + +あぁ、例えこの世が暗く +絶望に飲み込まれても 私は大丈夫 + +あなたがいればそこは +灰色(いろ)(いろ)の景色(いろ)(いろ)さえ色づき始める + +華もきっと 咲き誇るときを終え +いつかきっと また蕾をつけるだろう  +終わることない +生命(いのち)が続くまでは + +あなたの手を離さない 瞳に誓う 永遠の恋 +強く儚い思いを 守り続けていたい + +枯れた世界に輝く 名もない永遠の華 +強く生き抜きけるように 私を変えていく +あなたの手を離さない 瞳に誓う 永遠の恋 +強く儚い思いを 守り続けていたい \ No newline at end of file diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/LrcEncoder.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/LrcEncoder.cs index 9ee473c2d..44d7b65e1 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/LrcEncoder.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/LrcEncoder.cs @@ -35,9 +35,6 @@ private LyricLine encodeLyric(Objects.Lyric lyric) => private IEnumerable convertTimeTag(string text, IReadOnlyDictionary tags) { - if (tags == null || !tags.Any()) - throw new ArgumentNullException($"{nameof(tags)} cannot be null."); - var totalTags = text.Length * 2 + 2; for (int i = 0; i < totalTags; i++) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Generator/TimeTags/Ja/JaTimeTagGenerator.cs b/osu.Game.Rulesets.Karaoke/Edit/Generator/TimeTags/Ja/JaTimeTagGenerator.cs index c9735aa78..9d2e8dab0 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Generator/TimeTags/Ja/JaTimeTagGenerator.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Generator/TimeTags/Ja/JaTimeTagGenerator.cs @@ -139,6 +139,7 @@ protected override void TimeTagLogic(Lyric lyric, List> timeTags) { var text = lyric.Text; + for (var i = 1; i < text.Length; i++) { if (CharUtils.IsChinese(text[i])) diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs index e552ae248..8b5ce3522 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs @@ -19,6 +19,14 @@ public class AssignLanguageSubScreen : ImportLyricSubScreenWithTopNavigation public override IconUsage Icon => FontAwesome.Solid.Globe; + [Cached] + protected readonly LyricManager LyricManager; + + public AssignLanguageSubScreen() + { + AddInternal(LyricManager = new LyricManager()); + } + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) { var dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); @@ -56,7 +64,8 @@ protected void AskForAutoAssignLanguage() { DialogOverlay.Push(new UseLanguageDetectorPopupDialog(ok => { - // todo : call manager to do that. + if (ok) + LyricManager.AutoDetectLyricLanguage(); })); } diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRuby/GenerateRubySubScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRuby/GenerateRubySubScreen.cs index f0a84d24c..c7247f401 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRuby/GenerateRubySubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRuby/GenerateRubySubScreen.cs @@ -1,6 +1,7 @@ // Copyright (c) andy840119 . 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(); })); } diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs index 591fe470d..fdadbabec 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs @@ -19,6 +19,14 @@ public class GenerateTimeTagSubScreen : ImportLyricSubScreenWithTopNavigation public override IconUsage Icon => FontAwesome.Solid.Tag; + [Cached] + protected readonly TimeTagManager TimeTagManager; + + public GenerateTimeTagSubScreen() + { + AddInternal(TimeTagManager = new TimeTagManager()); + } + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) { var dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); @@ -56,7 +64,8 @@ protected void AskForAutoGenerateTimeTag() { DialogOverlay.Push(new UseAutoGenerateTimeTagPopupDialog(ok => { - // todo : call manager to do that. + if (ok) + TimeTagManager.AutoGenerateTimeTags(); })); } diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricManager.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricManager.cs index ac1c90a27..943d7101c 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricManager.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricManager.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics; using osu.Game.Beatmaps; using osu.Game.Rulesets.Karaoke.Beatmaps.Formats; +using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Screens.Edit; namespace osu.Game.Rulesets.Karaoke.Edit.ImportLyric @@ -52,10 +53,12 @@ public void ImportLrcFile(FileInfo info) var decoder = new LrcDecoder(); var lrcBeatmap = decoder.Decode(reader); - // todo : remove all notes and lyric - // or just clear all beatmap because not really sure is singer should be removed also? + // remove all hit objects (note and lyric) from beatmap + editorBeatmap.Clear(); // then re-add the lyric. + var lyrics = lrcBeatmap.HitObjects.OfType(); + editorBeatmap.AddRange(lyrics); } } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Components/Badges/LanguageInfoBadge.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Components/Badges/LanguageInfoBadge.cs index 1cbb890ac..ef98df15c 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Components/Badges/LanguageInfoBadge.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Components/Badges/LanguageInfoBadge.cs @@ -16,10 +16,7 @@ public LanguageInfoBadge(Lyric lyric) { var language = value.NewValue; - if (language == null) - BadgeText = "None"; - else - BadgeText = language.DisplayName; + BadgeText = language == null ? "None" : language.DisplayName; }, true); } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Components/LyricControl.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Components/LyricControl.cs index f18c5a540..81bdc5034 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Components/LyricControl.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Components/LyricControl.cs @@ -72,7 +72,7 @@ protected override void ApplyFont(KaraokeFont font) return; // todo : need to delay until karaoke text has been calculated. - ScheduleAfterChildren(() => UpdateTimeTags()); + ScheduleAfterChildren(UpdateTimeTags); } protected override void ApplyLayout(KaraokeLayout layout) @@ -101,7 +101,11 @@ public override double LifetimeEnd protected void UpdateTimeTags() { timeTagContainer.Clear(); - foreach (var timeTag in TimeTagsBindable.Value) + var timeTags = TimeTagsBindable.Value; + if (timeTags == null) + return; + + foreach (var timeTag in timeTags) { var index = Math.Min(timeTag.Item1.Index, HitObject.Text.Length - 1); var percentage = timeTag.Item1.State == TimeTagIndex.IndexState.Start ? 0 : 1; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/DrawableLyricEditListItem.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/DrawableLyricEditListItem.cs index 055f88b12..a02a0c3a6 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/DrawableLyricEditListItem.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/DrawableLyricEditListItem.cs @@ -108,7 +108,7 @@ protected override Drawable CreateContent() // in larger size should use real icon. new LanguageInfoBadge(Model) { - Margin = new MarginPadding{ Right = 5 } + Margin = new MarginPadding { Right = 5 } } } }, diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/LyricManager.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/LyricManager.cs new file mode 100644 index 000000000..4645a6d97 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/LyricManager.cs @@ -0,0 +1,45 @@ +// Copyright (c) andy840119 . 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; } + + /// + /// Will auto-detect each 's and apply on them. + /// + public void AutoDetectLyricLanguage() + { + var lyrics = beatmap.HitObjects.OfType().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(); + } + } +} diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/TimeTagManager.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/TimeTagManager.cs new file mode 100644 index 000000000..5a016325c --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/TimeTagManager.cs @@ -0,0 +1,85 @@ +// Copyright (c) andy840119 . 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; } + + /// + /// Will auto-detect each 's and apply on them. + /// + public void AutoGenerateTimeTags() + { + var lyrics = beatmap.HitObjects.OfType().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; + private readonly Lazy zhTimeTagGenerator; + + public TimeTagGeneratorSelector() + { + jaTimeTagGenerator = new Lazy(() => + { + // todo : get config from setting. + var config = new JaTimeTagGeneratorConfig(); + return new JaTimeTagGenerator(config); + }); + zhTimeTagGenerator = new Lazy(() => + { + // todo : get config from setting. + var config = new ZhTimeTagGeneratorConfig(); + return new ZhTimeTagGenerator(config); + }); + } + + public Tuple[] 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; + } + } + } + } +} diff --git a/osu.Game.Rulesets.Karaoke/Edit/RubyRomaji/RubyRomajiManager.cs b/osu.Game.Rulesets.Karaoke/Edit/RubyRomaji/RubyRomajiManager.cs new file mode 100644 index 000000000..fd83ca9dc --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Edit/RubyRomaji/RubyRomajiManager.cs @@ -0,0 +1,73 @@ +// Copyright (c) andy840119 . 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.RubyTags.Ja; +using osu.Game.Rulesets.Karaoke.Objects; +using osu.Game.Screens.Edit; +using System; +using System.Linq; + +namespace osu.Game.Rulesets.Karaoke.Edit.RubyRomaji +{ + public class RubyRomajiManager : Component + { + [Resolved] + private EditorBeatmap beatmap { get; set; } + + [Resolved(CanBeNull = true)] + private IEditorChangeHandler changeHandler { get; set; } + + /// + /// Will auto-detect each 's and apply on them. + /// + public void AutoGenerateRubyTags() + { + var lyrics = beatmap.HitObjects.OfType().ToList(); + if (!lyrics.Any()) + return; + + changeHandler?.BeginChange(); + + var selector = new RubyTagGeneratorSelector(); + + foreach (var lyric in lyrics) + { + var rubyTags = selector.GenerateRubyTags(lyric); + lyric.RubyTags = rubyTags; + } + + changeHandler?.EndChange(); + } + + public class RubyTagGeneratorSelector + { + private readonly Lazy jaRubyTagGenerator; + + public RubyTagGeneratorSelector() + { + jaRubyTagGenerator = new Lazy(() => + { + // todo : get config from setting. + var config = new JaRubyTagGeneratorConfig(); + return new JaRubyTagGenerator(config); + }); + } + + public RubyTag[] GenerateRubyTags(Lyric lyric) + { + // lazy to generate language detector and apply it's setting + switch (lyric.Language.LCID) + { + case 17: + case 1041: + return jaRubyTagGenerator.Value.CreateRubyTags(lyric); + + default: + return null; + } + } + } + } +} diff --git a/osu.Game.Rulesets.Karaoke/Edit/Style/NoteStylePreview.cs b/osu.Game.Rulesets.Karaoke/Edit/Style/NoteStylePreview.cs index c939e63bb..3b3733142 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Style/NoteStylePreview.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Style/NoteStylePreview.cs @@ -71,7 +71,7 @@ public class PreviewScrollingInfo : IScrollingInfo public IBindable TimeRange { get; } = new BindableDouble(); - public IScrollAlgorithm Algorithm { get; set; } = new ZeroScrollAlgorithm(); + public IScrollAlgorithm Algorithm { get; } = new ZeroScrollAlgorithm(); private class ZeroScrollAlgorithm : IScrollAlgorithm { diff --git a/osu.Game.Rulesets.Karaoke/Edit/Translate/Components/DrawableLanguageListItem.cs b/osu.Game.Rulesets.Karaoke/Edit/Translate/Components/DrawableLanguageListItem.cs index 96804dd4b..29160b459 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Translate/Components/DrawableLanguageListItem.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Translate/Components/DrawableLanguageListItem.cs @@ -26,7 +26,7 @@ public class DrawableLanguageListItem : OsuRearrangeableListItem - /// Whether the currently exists inside the . + /// Whether the currently exists inside the . /// public IBindable IsCreated => isCreated; @@ -36,7 +36,7 @@ public class DrawableLanguageListItem : OsuRearrangeableListItem. /// /// The . - /// Whether currently exists inside the . + /// Whether currently exists inside the . public DrawableLanguageListItem(BeatmapSetOnlineLanguage item, bool isCreated) : base(item) { @@ -60,7 +60,7 @@ private class ItemContent : CircularContainer private readonly BeatmapSetOnlineLanguage language; [Resolved(CanBeNull = true)] - private LanguageManager languageManager { get; set; } + private TranslateManager languageManager { get; set; } private Container textBoxPaddingContainer; private ItemTextBox textBox; @@ -160,7 +160,7 @@ public class DeleteButton : CompositeDrawable private DialogOverlay dialogOverlay { get; set; } [Resolved(CanBeNull = true)] - private LanguageManager languageManager { get; set; } + private TranslateManager translateManager { get; set; } private readonly BeatmapSetOnlineLanguage language; @@ -224,7 +224,7 @@ protected override bool OnClick(ClickEvent e) { background.FlashColour(Color4.White, 150); - if (!languageManager?.IsLanguageContainsTranslate(language) ?? false) + if (!translateManager?.IsLanguageContainsTranslate(language) ?? false) deleteLanguage(); else dialogOverlay?.Push(new DeleteLanguageDialog(language, deleteLanguage)); @@ -232,7 +232,7 @@ protected override bool OnClick(ClickEvent e) return true; } - private void deleteLanguage() => languageManager?.RemoveLanguage(language); + private void deleteLanguage() => translateManager?.RemoveLanguage(language); } } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Translate/Components/ManageLanguagesDialog.cs b/osu.Game.Rulesets.Karaoke/Edit/Translate/Components/ManageLanguagesDialog.cs index 8b04d6453..30c06880a 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Translate/Components/ManageLanguagesDialog.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Translate/Components/ManageLanguagesDialog.cs @@ -21,14 +21,14 @@ public ManageLanguagesDialog() } [BackgroundDependencyLoader] - private void load(LanguageManager languageManager) + private void load(TranslateManager translateManager) { Children = new Drawable[] { new DrawableLanguageList { RelativeSizeAxes = Axes.Both, - Items = { BindTarget = languageManager?.Languages ?? new BindableList() } + Items = { BindTarget = translateManager?.Languages ?? new BindableList() } } }; } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Translate/TranslateEditSection.cs b/osu.Game.Rulesets.Karaoke/Edit/Translate/TranslateEditSection.cs index 6be984596..af34356c5 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Translate/TranslateEditSection.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Translate/TranslateEditSection.cs @@ -1,7 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; @@ -141,9 +140,9 @@ Dimension[] createRowDimension() => editorBeatmap.HitObjects.OfType() } [BackgroundDependencyLoader] - private void load(LanguageManager languageManager, OsuColour colours) + private void load(TranslateManager translateManager, OsuColour colours) { - languageDropdown.ItemSource = languageManager?.Languages ?? new BindableList(); + languageDropdown.ItemSource = translateManager?.Languages ?? new BindableList(); timeSectionBackground.Colour = colours.ContextMenuGray; lyricSectionBackground.Colour = colours.Gray9; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Translate/LanguageManager.cs b/osu.Game.Rulesets.Karaoke/Edit/Translate/TranslateManager.cs similarity index 97% rename from osu.Game.Rulesets.Karaoke/Edit/Translate/LanguageManager.cs rename to osu.Game.Rulesets.Karaoke/Edit/Translate/TranslateManager.cs index 5e9dd68c7..71a6ffda1 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Translate/LanguageManager.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Translate/TranslateManager.cs @@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Karaoke.Edit.Translate /// /// Handle create or delete language. /// - public class LanguageManager : Component + public class TranslateManager : Component { public readonly BindableList Languages = new BindableList(); diff --git a/osu.Game.Rulesets.Karaoke/Edit/Translate/TranslateScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/Translate/TranslateScreen.cs index bfe5761ad..5b1866f41 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Translate/TranslateScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Translate/TranslateScreen.cs @@ -18,13 +18,13 @@ public class TranslateScreen : EditorScreen protected readonly OverlayColourProvider ColourProvider; [Cached] - protected readonly LanguageManager LanguageManager; + protected readonly TranslateManager TranslateManager; public TranslateScreen() : base(EditorScreenMode.SongSetup) { ColourProvider = new OverlayColourProvider(OverlayColourScheme.Green); - Content.Add(LanguageManager = new LanguageManager()); + Content.Add(TranslateManager = new TranslateManager()); } [BackgroundDependencyLoader] diff --git a/osu.Game.Rulesets.Karaoke/Utils/TimeTagsUtils.cs b/osu.Game.Rulesets.Karaoke/Utils/TimeTagsUtils.cs index e398db2c0..e045ecc35 100644 --- a/osu.Game.Rulesets.Karaoke/Utils/TimeTagsUtils.cs +++ b/osu.Game.Rulesets.Karaoke/Utils/TimeTagsUtils.cs @@ -112,6 +112,9 @@ public static class TimeTagsUtils /// Fixed time tags. public static Tuple[] FixInvalid(Tuple[] timeTags, GroupCheck other = GroupCheck.Asc, SelfCheck self = SelfCheck.BasedOnStart) { + if (timeTags == null || timeTags.Length == 0) + return timeTags; + var sortedTimeTags = Sort(timeTags); var groupedTimeTags = sortedTimeTags.GroupBy(x => x.Item1.Index); @@ -184,6 +187,9 @@ public static class TimeTagsUtils public static IReadOnlyDictionary ToDictionary(Tuple[] timeTags, bool applyFix = true, GroupCheck other = GroupCheck.Asc, SelfCheck self = SelfCheck.BasedOnStart) { + if (timeTags == null) + return new Dictionary(); + // sorted value var sortedTimeTags = applyFix ? FixInvalid(timeTags, other, self) : Sort(timeTags);