From 343db24f137ffe5426bbe8e57f13d2319a6d9778 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 19 Dec 2020 21:38:23 +0900 Subject: [PATCH] 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