From 0f6a3975928b0e6d320b2e663a4cf15319ee7d6d Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 19 Dec 2020 20:41:12 +0900 Subject: [PATCH] Add with lyric editor screen to collect generate lyric editor and injection logic. --- .../AssignLanguage/AssignLanguageSubScreen.cs | 32 ++++++------------- .../EditLyric/EditLyricSubScreen.cs | 30 ++++++----------- .../GenerateTimeTagSubScreen.cs | 22 +++---------- .../ImportLyricSubScreenWithLyricEditor.cs | 31 ++++++++++++++++++ .../ImportLyricSubScreenWithTopNavigation.cs | 14 ++++++-- 5 files changed, 67 insertions(+), 62 deletions(-) create mode 100644 osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithLyricEditor.cs diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs index c0bffc1da..114cb4f95 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs @@ -5,12 +5,11 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Timing; using osu.Game.Rulesets.Karaoke.Edit.Lyrics; namespace osu.Game.Rulesets.Karaoke.Edit.ImportLyric.AssignLanguage { - public class AssignLanguageSubScreen : ImportLyricSubScreenWithTopNavigation + public class AssignLanguageSubScreen : ImportLyricSubScreenWithLyricEditor { public override string Title => "Language"; @@ -28,26 +27,15 @@ public AssignLanguageSubScreen() AddInternal(LyricManager = new LyricManager()); } - protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) - { - var dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); - var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; - dependencies.CacheAs(clock); - dependencies.CacheAs(clock); - - return dependencies; - } - protected override TopNavigation CreateNavigation() => new AssignLanguageNavigation(this); protected override Drawable CreateContent() - => new LyricEditor + => base.CreateContent().With(x => { - RelativeSizeAxes = Axes.Both, - Mode = Mode.ViewMode, - LyricFastEditMode = LyricFastEditMode.Language, - }; + LyricEditor.Mode = Mode.ViewMode; + LyricEditor.LyricFastEditMode = LyricFastEditMode.Language; + }); protected override void LoadComplete() { @@ -70,15 +58,15 @@ protected void AskForAutoAssignLanguage() })); } - public class AssignLanguageNavigation : TopNavigation + public class AssignLanguageNavigation : TopNavigation { - public AssignLanguageNavigation(ImportLyricSubScreen screen) + public AssignLanguageNavigation(AssignLanguageSubScreen screen) : base(screen) { } - protected override TextFlowContainer CreateTextContainer(ImportLyricSubScreen screen) - => new AssignLanguageTextFlowContainer(screen); + protected override TextFlowContainer CreateTextContainer() + => new AssignLanguageTextFlowContainer(Screen); protected override void UpdateState(NavigationState value) { @@ -106,7 +94,7 @@ protected override void UpdateState(NavigationState value) private class AssignLanguageTextFlowContainer : CustomizableTextContainer { - public AssignLanguageTextFlowContainer(ImportLyricSubScreen screen) + public AssignLanguageTextFlowContainer(AssignLanguageSubScreen screen) { AddIconFactory("Hello", () => null); } diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/EditLyric/EditLyricSubScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/EditLyric/EditLyricSubScreen.cs index 9d6f5615e..6f3e35463 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/EditLyric/EditLyricSubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/EditLyric/EditLyricSubScreen.cs @@ -5,12 +5,11 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Timing; using osu.Game.Rulesets.Karaoke.Edit.Lyrics; namespace osu.Game.Rulesets.Karaoke.Edit.ImportLyric.EditLyric { - public class EditLyricSubScreen : ImportLyricSubScreenWithTopNavigation + public class EditLyricSubScreen : ImportLyricSubScreenWithLyricEditor { public override string Title => "Edit lyric"; @@ -28,26 +27,15 @@ public EditLyricSubScreen() AddInternal(LyricManager = new LyricManager()); } - protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) - { - var dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); - var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; - dependencies.CacheAs(clock); - dependencies.CacheAs(clock); - - return dependencies; - } - protected override TopNavigation CreateNavigation() => new EditLyricNavigation(this); protected override Drawable CreateContent() - => new LyricEditor + => base.CreateContent().With(x => { - RelativeSizeAxes = Axes.Both, - Mode = Mode.EditMode, - LyricFastEditMode = LyricFastEditMode.None, - }; + LyricEditor.Mode = Mode.EditMode; + LyricEditor.LyricFastEditMode = LyricFastEditMode.None; + }); protected override void LoadComplete() { @@ -60,15 +48,15 @@ public override void Complete() ScreenStack.Push(ImportLyricStep.AssignLanguage); } - public class EditLyricNavigation : TopNavigation + public class EditLyricNavigation : TopNavigation { public EditLyricNavigation(EditLyricSubScreen screen) : base(screen) { } - protected override TextFlowContainer CreateTextContainer(ImportLyricSubScreen screen) - => new EditLyricTextFlowContainer(screen); + protected override TextFlowContainer CreateTextContainer() + => new EditLyricTextFlowContainer(Screen); protected override void UpdateState(NavigationState value) { @@ -93,7 +81,7 @@ protected override void UpdateState(NavigationState value) private class EditLyricTextFlowContainer : CustomizableTextContainer { - public EditLyricTextFlowContainer(ImportLyricSubScreen screen) + public EditLyricTextFlowContainer(EditLyricSubScreen screen) { AddIconFactory("Hello", () => null); } diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs index 737424a5e..687a2d95d 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs @@ -4,12 +4,11 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; -using osu.Framework.Timing; using osu.Game.Rulesets.Karaoke.Edit.Lyrics; namespace osu.Game.Rulesets.Karaoke.Edit.ImportLyric.GenerateTimeTag { - public class GenerateTimeTagSubScreen : ImportLyricSubScreenWithTopNavigation + public class GenerateTimeTagSubScreen : ImportLyricSubScreenWithLyricEditor { public override string Title => "Generate time tag"; @@ -27,26 +26,15 @@ public GenerateTimeTagSubScreen() AddInternal(timeTagManager = new TimeTagManager()); } - protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) - { - var dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); - var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; - dependencies.CacheAs(clock); - dependencies.CacheAs(clock); - - return dependencies; - } - protected override TopNavigation CreateNavigation() => new GenerateTimeTagNavigation(this); protected override Drawable CreateContent() - => new LyricEditor + => base.CreateContent().With(x => { - RelativeSizeAxes = Axes.Both, - Mode = Mode.TimeTagEditMode, - LyricFastEditMode = LyricFastEditMode.Language, - }; + LyricEditor.Mode = Mode.TimeTagEditMode; + LyricEditor.LyricFastEditMode = LyricFastEditMode.Language; + }); protected override void LoadComplete() { diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithLyricEditor.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithLyricEditor.cs new file mode 100644 index 000000000..5df111770 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithLyricEditor.cs @@ -0,0 +1,31 @@ +// 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.Timing; +using osu.Game.Rulesets.Karaoke.Edit.Lyrics; + +namespace osu.Game.Rulesets.Karaoke.Edit.ImportLyric +{ + public abstract class ImportLyricSubScreenWithLyricEditor : ImportLyricSubScreenWithTopNavigation + { + protected LyricEditor LyricEditor { get; private set; } + + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) + { + var dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); + var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; + dependencies.CacheAs(clock); + dependencies.CacheAs(clock); + + return dependencies; + } + + protected override Drawable CreateContent() + => LyricEditor = new LyricEditor + { + RelativeSizeAxes = Axes.Both, + }; + } +} diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithTopNavigation.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithTopNavigation.cs index 6cfdd0dc9..d502262e2 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithTopNavigation.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithTopNavigation.cs @@ -47,6 +47,16 @@ protected ImportLyricSubScreenWithTopNavigation() protected abstract Drawable CreateContent(); + public abstract class TopNavigation : TopNavigation where T : ImportLyricSubScreenWithTopNavigation + { + protected new T Screen => base.Screen as T; + + protected TopNavigation(T screen) + : base(screen) + { + } + } + public abstract class TopNavigation : Container { [Resolved] @@ -69,7 +79,7 @@ protected TopNavigation(ImportLyricSubScreen screen) { RelativeSizeAxes = Axes.Both, }, - text = CreateTextContainer(screen).With(t => { + text = CreateTextContainer().With(t => { t.Anchor = Anchor.CentreLeft; t.Origin = Anchor.CentreLeft; t.RelativeSizeAxes = Axes.X; @@ -92,7 +102,7 @@ protected TopNavigation(ImportLyricSubScreen screen) }; } - protected virtual TextFlowContainer CreateTextContainer(ImportLyricSubScreen screen) => new TextFlowContainer(); + protected virtual TextFlowContainer CreateTextContainer() => new TextFlowContainer(); protected string NavigationText {