From dbc9a02e1a3c1d9b751e26b9071f4a67219e9b67 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 19 Dec 2020 20:31:56 +0900 Subject: [PATCH 1/5] Change from sprite text to text flow container. --- .../AssignLanguage/AssignLanguageSubScreen.cs | 12 ++++++++++++ .../EditLyric/EditLyricSubScreen.cs | 12 ++++++++++++ .../ImportLyricSubScreenWithTopNavigation.cs | 18 ++++++++++-------- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs index 7197d355b..c0bffc1da 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs @@ -3,6 +3,7 @@ using osu.Framework.Allocation; 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; @@ -76,6 +77,9 @@ public AssignLanguageNavigation(ImportLyricSubScreen screen) { } + protected override TextFlowContainer CreateTextContainer(ImportLyricSubScreen screen) + => new AssignLanguageTextFlowContainer(screen); + protected override void UpdateState(NavigationState value) { base.UpdateState(value); @@ -99,6 +103,14 @@ protected override void UpdateState(NavigationState value) break; } } + + private class AssignLanguageTextFlowContainer : CustomizableTextContainer + { + public AssignLanguageTextFlowContainer(ImportLyricSubScreen 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 bdcab00ea..9d6f5615e 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/EditLyric/EditLyricSubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/EditLyric/EditLyricSubScreen.cs @@ -3,6 +3,7 @@ using osu.Framework.Allocation; 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; @@ -66,6 +67,9 @@ public EditLyricNavigation(EditLyricSubScreen screen) { } + protected override TextFlowContainer CreateTextContainer(ImportLyricSubScreen screen) + => new EditLyricTextFlowContainer(screen); + protected override void UpdateState(NavigationState value) { base.UpdateState(value); @@ -86,6 +90,14 @@ protected override void UpdateState(NavigationState value) break; } } + + private class EditLyricTextFlowContainer : CustomizableTextContainer + { + public EditLyricTextFlowContainer(ImportLyricSubScreen screen) + { + AddIconFactory("Hello", () => null); + } + } } } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithTopNavigation.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithTopNavigation.cs index 75c0d338a..6cfdd0dc9 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithTopNavigation.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithTopNavigation.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets.Karaoke.Graphics.Shapes; @@ -56,7 +55,7 @@ public abstract class TopNavigation : Container protected ImportLyricSubScreen Screen { get; } private readonly CornerBackground background; - private readonly OsuSpriteText text; + private readonly TextFlowContainer text; private readonly IconButton button; protected TopNavigation(ImportLyricSubScreen screen) @@ -70,12 +69,13 @@ protected TopNavigation(ImportLyricSubScreen screen) { RelativeSizeAxes = Axes.Both, }, - text = new OsuSpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Margin = new MarginPadding { Left = 15 } - }, + text = CreateTextContainer(screen).With(t => { + t.Anchor = Anchor.CentreLeft; + t.Origin = Anchor.CentreLeft; + t.RelativeSizeAxes = Axes.X; + t.AutoSizeAxes = Axes.Y; + t.Margin = new MarginPadding { Left = 15 }; + }), button = new IconButton { Anchor = Anchor.CentreRight, @@ -92,6 +92,8 @@ protected TopNavigation(ImportLyricSubScreen screen) }; } + protected virtual TextFlowContainer CreateTextContainer(ImportLyricSubScreen screen) => new TextFlowContainer(); + protected string NavigationText { set => text.Text = value; From 0f6a3975928b0e6d320b2e663a4cf15319ee7d6d Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 19 Dec 2020 20:41:12 +0900 Subject: [PATCH 2/5] 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 { From bc26d17bcc8ea56ab2b25f0442c24fac2d9d0b50 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 19 Dec 2020 20:41:33 +0900 Subject: [PATCH 3/5] Use template. --- .../Edit/ImportLyric/GenerateRuby/GenerateRubySubScreen.cs | 4 ++-- .../ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRuby/GenerateRubySubScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRuby/GenerateRubySubScreen.cs index c7247f401..ced149b10 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRuby/GenerateRubySubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRuby/GenerateRubySubScreen.cs @@ -56,9 +56,9 @@ protected void AskForAutoGenerateRuby() })); } - public class GenerateRubyNavigation : TopNavigation + public class GenerateRubyNavigation : TopNavigation { - public GenerateRubyNavigation(ImportLyricSubScreen screen) + public GenerateRubyNavigation(GenerateRubySubScreen screen) : base(screen) { } diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs index 687a2d95d..7f98eebdc 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs @@ -61,9 +61,9 @@ protected void AskForAutoGenerateTimeTag() })); } - public class GenerateTimeTagNavigation : TopNavigation + public class GenerateTimeTagNavigation : TopNavigation { - public GenerateTimeTagNavigation(ImportLyricSubScreen screen) + public GenerateTimeTagNavigation(GenerateTimeTagSubScreen screen) : base(screen) { } From 343db24f137ffe5426bbe8e57f13d2319a6d9778 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 19 Dec 2020 21:38:23 +0900 Subject: [PATCH 4/5] Almost fucking there/ --- .../AssignLanguage/AssignLanguageSubScreen.cs | 17 +++++---- .../EditLyric/EditLyricSubScreen.cs | 30 +++++++++++++--- .../GenerateRuby/GenerateRubySubScreen.cs | 22 ++++++++++-- .../GenerateTimeTagSubScreen.cs | 22 +++++++++--- .../ImportLyricSubScreenWithTopNavigation.cs | 36 +++++++++++++++++-- 5 files changed, 106 insertions(+), 21 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs index 114cb4f95..0f52bd5a3 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs @@ -49,23 +49,28 @@ public override void Complete() ScreenStack.Push(ImportLyricStep.GenerateRuby); } - protected void AskForAutoAssignLanguage() + internal void AskForAutoAssignLanguage() { DialogOverlay.Push(new UseLanguageDetectorPopupDialog(ok => { if (ok) + { LyricManager.AutoDetectLyricLanguage(); + Navigation.State = NavigationState.Done; + } })); } public class AssignLanguageNavigation : TopNavigation { + private const string auto_assign_language = "AUTO_ASSIGN_LANGUAGE"; + public AssignLanguageNavigation(AssignLanguageSubScreen screen) : base(screen) { } - protected override TextFlowContainer CreateTextContainer() + protected override NavigationTextContainer CreateTextContainer() => new AssignLanguageTextFlowContainer(Screen); protected override void UpdateState(NavigationState value) @@ -75,11 +80,11 @@ protected override void UpdateState(NavigationState value) switch (value) { case NavigationState.Initial: - NavigationText = "Try to select left side to mark lyric's language."; + NavigationText = $"Try to select left side to mark lyric's language, or click [{auto_assign_language}] to let system auto detect lyric language."; break; case NavigationState.Working: - NavigationText = "Almost there/"; + NavigationText = $"Almost there, you can still click [{auto_assign_language}] to re-detect each lyric's language."; break; case NavigationState.Done: @@ -92,11 +97,11 @@ protected override void UpdateState(NavigationState value) } } - private class AssignLanguageTextFlowContainer : CustomizableTextContainer + private class AssignLanguageTextFlowContainer : NavigationTextContainer { public AssignLanguageTextFlowContainer(AssignLanguageSubScreen screen) { - AddIconFactory("Hello", () => null); + AddLinkFactory(auto_assign_language, "language detector", () => screen.AskForAutoAssignLanguage()); } } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/EditLyric/EditLyricSubScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/EditLyric/EditLyricSubScreen.cs index 6f3e35463..6a2d0c964 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/EditLyric/EditLyricSubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/EditLyric/EditLyricSubScreen.cs @@ -48,14 +48,23 @@ public override void Complete() ScreenStack.Push(ImportLyricStep.AssignLanguage); } + internal void SwitchLyricEditorMode(Mode mode) + { + LyricEditor.Mode = mode; + Navigation.State = NavigationState.Working; + } + public class EditLyricNavigation : TopNavigation { + private const string cutting_mode = "CUTTING_MODE"; + private const string edit_mode = "EDIT_MODE"; + public EditLyricNavigation(EditLyricSubScreen screen) : base(screen) { } - protected override TextFlowContainer CreateTextContainer() + protected override NavigationTextContainer CreateTextContainer() => new EditLyricTextFlowContainer(Screen); protected override void UpdateState(NavigationState value) @@ -65,12 +74,19 @@ protected override void UpdateState(NavigationState value) switch (value) { case NavigationState.Initial: - NavigationText = "Check and edit lyric if needed."; + NavigationText = $"Does something looks weird? Try switching [{cutting_mode}] or [{edit_mode}] to edit your lyric."; break; case NavigationState.Working: case NavigationState.Done: - NavigationText = "Cool!"; + var mode = Screen.LyricEditor.Mode; + switch (mode) + { + case Mode.EditMode: + NavigationText = $"Cool! Try switching to [{cutting_mode}] if you wants to cut or combine lyric."; + break; + // todo : edit mode. + } break; case NavigationState.Error: @@ -79,11 +95,15 @@ protected override void UpdateState(NavigationState value) } } - private class EditLyricTextFlowContainer : CustomizableTextContainer + protected override bool AbleToNextStep(NavigationState value) + => true; + + private class EditLyricTextFlowContainer : NavigationTextContainer { public EditLyricTextFlowContainer(EditLyricSubScreen screen) { - AddIconFactory("Hello", () => null); + AddLinkFactory(cutting_mode, "cutting mode", () => screen.SwitchLyricEditorMode(Mode.EditMode)); + AddLinkFactory(edit_mode, "edit mode", () => screen.SwitchLyricEditorMode(Mode.EditMode)); } } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRuby/GenerateRubySubScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRuby/GenerateRubySubScreen.cs index ced149b10..cdc5ba76c 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRuby/GenerateRubySubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRuby/GenerateRubySubScreen.cs @@ -47,22 +47,30 @@ public override void Complete() ScreenStack.Push(ImportLyricStep.GenerateTimeTag); } - protected void AskForAutoGenerateRuby() + internal void AskForAutoGenerateRuby() { DialogOverlay.Push(new UseAutoGenerateRubyPopupDialog(ok => { if (ok) + { RubyRomajiManager.AutoGenerateRubyTags(); + Navigation.State = NavigationState.Done; + } })); } public class GenerateRubyNavigation : TopNavigation { + private const string auto_generate_ruby = "AUTO_GENERATE_RUBY"; + public GenerateRubyNavigation(GenerateRubySubScreen screen) : base(screen) { } + protected override NavigationTextContainer CreateTextContainer() + => new GenerateRubyTextFlowContainer(Screen); + protected override void UpdateState(NavigationState value) { base.UpdateState(value); @@ -70,12 +78,12 @@ protected override void UpdateState(NavigationState value) switch (value) { case NavigationState.Initial: - NavigationText = "Press button to auto-generate ruby and romaji. It's very easy."; + NavigationText = $"Lazy to typing ruby? Press [{auto_generate_ruby}] to auto-generate ruby and romaji. It's very easy."; break; case NavigationState.Working: case NavigationState.Done: - NavigationText = "Go to next step to generate time-tag. Don't worry, it's auto also."; + NavigationText = $"Go to next step to generate time-tag. Messing around? Press [{auto_generate_ruby}] again."; break; case NavigationState.Error: @@ -86,6 +94,14 @@ protected override void UpdateState(NavigationState value) protected override bool AbleToNextStep(NavigationState value) => value == NavigationState.Initial || value == NavigationState.Working || value == NavigationState.Done; + + private class GenerateRubyTextFlowContainer : NavigationTextContainer + { + public GenerateRubyTextFlowContainer(GenerateRubySubScreen screen) + { + AddLinkFactory(auto_generate_ruby, "auto generate ruby", () => screen.AskForAutoGenerateRuby()); + } + } } } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs index 7f98eebdc..fe1ad7f7a 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs @@ -48,26 +48,30 @@ public override void Complete() ScreenStack.Push(ImportLyricStep.Success); } - protected void AskForAutoGenerateTimeTag() + internal void AskForAutoGenerateTimeTag() { DialogOverlay.Push(new UseAutoGenerateTimeTagPopupDialog(ok => { if (ok) { timeTagManager.AutoGenerateTimeTags(); - // todo : should moving cursor to first - // timeTagManager.MoveCursor(CursorAction.First); + Navigation.State = NavigationState.Done; } })); } public class GenerateTimeTagNavigation : TopNavigation { + private const string auto_generate_time_tag = "AUTO_GENERATE_TIME_TAG"; + public GenerateTimeTagNavigation(GenerateTimeTagSubScreen screen) : base(screen) { } + protected override NavigationTextContainer CreateTextContainer() + => new GenerateTimeTagTextFlowContainer(Screen); + protected override void UpdateState(NavigationState value) { base.UpdateState(value); @@ -75,12 +79,12 @@ protected override void UpdateState(NavigationState value) switch (value) { case NavigationState.Initial: - NavigationText = "Press button to auto-generate time tag. It's very easy."; + NavigationText = $"Press [{auto_generate_time_tag}] to autu-generate time tag. It's very easy."; break; case NavigationState.Working: case NavigationState.Done: - NavigationText = "Cool"; + NavigationText = $"Cool, you can reset yout time-tag by pressing [{auto_generate_time_tag}]"; break; case NavigationState.Error: @@ -91,6 +95,14 @@ protected override void UpdateState(NavigationState value) protected override bool AbleToNextStep(NavigationState value) => value == NavigationState.Working || value == NavigationState.Done; + + private class GenerateTimeTagTextFlowContainer : NavigationTextContainer + { + public GenerateTimeTagTextFlowContainer(GenerateTimeTagSubScreen screen) + { + AddLinkFactory(auto_generate_time_tag, "auto generate time tag", () => screen.AskForAutoGenerateTimeTag()); + } + } } } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithTopNavigation.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithTopNavigation.cs index d502262e2..c56a83589 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithTopNavigation.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithTopNavigation.cs @@ -6,7 +6,9 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Framework.Input.Events; using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets.Karaoke.Graphics.Shapes; @@ -65,7 +67,7 @@ public abstract class TopNavigation : Container protected ImportLyricSubScreen Screen { get; } private readonly CornerBackground background; - private readonly TextFlowContainer text; + private readonly NavigationTextContainer text; private readonly IconButton button; protected TopNavigation(ImportLyricSubScreen screen) @@ -102,7 +104,7 @@ protected TopNavigation(ImportLyricSubScreen screen) }; } - protected virtual TextFlowContainer CreateTextContainer() => new TextFlowContainer(); + protected abstract NavigationTextContainer CreateTextContainer(); protected string NavigationText { @@ -173,6 +175,36 @@ protected virtual void UpdateState(NavigationState value) protected virtual bool AbleToNextStep(NavigationState value) => value == NavigationState.Done; protected virtual void CompleteClicked() => Screen.Complete(); + + public class NavigationTextContainer : CustomizableTextContainer + { + protected void AddLinkFactory(string name, string text, Action action) + { + AddIconFactory(name, () => new ClickableSpriteText + { + Font = new FontUsage(size: 20), + Text = text, + Action = action + }); + } + + internal class ClickableSpriteText : OsuSpriteText + { + public Action Action { get; set; } + + protected override bool OnClick(ClickEvent e) + { + Action?.Invoke(); + return base.OnClick(e); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Colour = colours.Yellow; + } + } + } } public enum NavigationState From eba0a8395addb4fb3d6e4b9fe9c4a29bd47bb08b Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 19 Dec 2020 21:41:27 +0900 Subject: [PATCH 5/5] Post clean-up. --- .../AssignLanguage/AssignLanguageSubScreen.cs | 13 ++++++------- .../ImportLyric/EditLyric/EditLyricSubScreen.cs | 3 ++- .../GenerateRuby/GenerateRubySubScreen.cs | 12 ++++++------ .../GenerateTimeTag/GenerateTimeTagSubScreen.cs | 16 ++++++++-------- .../ImportLyricSubScreenWithTopNavigation.cs | 3 ++- .../Edit/Lyrics/Lyrics/LyricControl.cs | 1 - 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs index 0f52bd5a3..4560f172e 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs @@ -3,7 +3,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets.Karaoke.Edit.Lyrics; @@ -53,11 +52,11 @@ internal void AskForAutoAssignLanguage() { DialogOverlay.Push(new UseLanguageDetectorPopupDialog(ok => { - if (ok) - { - LyricManager.AutoDetectLyricLanguage(); - Navigation.State = NavigationState.Done; - } + if (!ok) + return; + + LyricManager.AutoDetectLyricLanguage(); + Navigation.State = NavigationState.Done; })); } @@ -101,7 +100,7 @@ private class AssignLanguageTextFlowContainer : NavigationTextContainer { public AssignLanguageTextFlowContainer(AssignLanguageSubScreen screen) { - AddLinkFactory(auto_assign_language, "language detector", () => screen.AskForAutoAssignLanguage()); + AddLinkFactory(auto_assign_language, "language detector", screen.AskForAutoAssignLanguage); } } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/EditLyric/EditLyricSubScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/EditLyric/EditLyricSubScreen.cs index 6a2d0c964..d1bf34e53 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/EditLyric/EditLyricSubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/EditLyric/EditLyricSubScreen.cs @@ -3,7 +3,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets.Karaoke.Edit.Lyrics; @@ -80,6 +79,7 @@ protected override void UpdateState(NavigationState value) case NavigationState.Working: case NavigationState.Done: var mode = Screen.LyricEditor.Mode; + switch (mode) { case Mode.EditMode: @@ -87,6 +87,7 @@ protected override void UpdateState(NavigationState value) break; // todo : edit mode. } + break; case NavigationState.Error: diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRuby/GenerateRubySubScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRuby/GenerateRubySubScreen.cs index cdc5ba76c..795ee5e3f 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRuby/GenerateRubySubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRuby/GenerateRubySubScreen.cs @@ -51,11 +51,11 @@ internal void AskForAutoGenerateRuby() { DialogOverlay.Push(new UseAutoGenerateRubyPopupDialog(ok => { - if (ok) - { - RubyRomajiManager.AutoGenerateRubyTags(); - Navigation.State = NavigationState.Done; - } + if (!ok) + return; + + RubyRomajiManager.AutoGenerateRubyTags(); + Navigation.State = NavigationState.Done; })); } @@ -99,7 +99,7 @@ private class GenerateRubyTextFlowContainer : NavigationTextContainer { public GenerateRubyTextFlowContainer(GenerateRubySubScreen screen) { - AddLinkFactory(auto_generate_ruby, "auto generate ruby", () => screen.AskForAutoGenerateRuby()); + AddLinkFactory(auto_generate_ruby, "auto generate ruby", screen.AskForAutoGenerateRuby); } } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs index fe1ad7f7a..b201357f0 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagSubScreen.cs @@ -52,11 +52,11 @@ internal void AskForAutoGenerateTimeTag() { DialogOverlay.Push(new UseAutoGenerateTimeTagPopupDialog(ok => { - if (ok) - { - timeTagManager.AutoGenerateTimeTags(); - Navigation.State = NavigationState.Done; - } + if (!ok) + return; + + timeTagManager.AutoGenerateTimeTags(); + Navigation.State = NavigationState.Done; })); } @@ -79,12 +79,12 @@ protected override void UpdateState(NavigationState value) switch (value) { case NavigationState.Initial: - NavigationText = $"Press [{auto_generate_time_tag}] to autu-generate time tag. It's very easy."; + NavigationText = $"Press [{auto_generate_time_tag}] to auto-generate time tag. It's very easy."; break; case NavigationState.Working: case NavigationState.Done: - NavigationText = $"Cool, you can reset yout time-tag by pressing [{auto_generate_time_tag}]"; + NavigationText = $"Cool, you can reset your time-tag by pressing [{auto_generate_time_tag}]"; break; case NavigationState.Error: @@ -100,7 +100,7 @@ private class GenerateTimeTagTextFlowContainer : NavigationTextContainer { public GenerateTimeTagTextFlowContainer(GenerateTimeTagSubScreen screen) { - AddLinkFactory(auto_generate_time_tag, "auto generate time tag", () => screen.AskForAutoGenerateTimeTag()); + AddLinkFactory(auto_generate_time_tag, "auto generate time tag", screen.AskForAutoGenerateTimeTag); } } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithTopNavigation.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithTopNavigation.cs index c56a83589..0cff5d753 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithTopNavigation.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithTopNavigation.cs @@ -81,7 +81,8 @@ protected TopNavigation(ImportLyricSubScreen screen) { RelativeSizeAxes = Axes.Both, }, - text = CreateTextContainer().With(t => { + text = CreateTextContainer().With(t => + { t.Anchor = Anchor.CentreLeft; t.Origin = Anchor.CentreLeft; t.RelativeSizeAxes = Axes.X; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Lyrics/LyricControl.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Lyrics/LyricControl.cs index bb9bdfa88..f00593272 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Lyrics/LyricControl.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Lyrics/LyricControl.cs @@ -12,7 +12,6 @@ using osu.Game.Rulesets.Karaoke.Edit.Lyrics.Lyrics.Components; using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Utils; -using osuTK.Input; namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.Lyrics {