diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs index 7197d355b..4560f172e 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/AssignLanguage/AssignLanguageSubScreen.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.AssignLanguage { - public class AssignLanguageSubScreen : ImportLyricSubScreenWithTopNavigation + public class AssignLanguageSubScreen : ImportLyricSubScreenWithLyricEditor { public override string Title => "Language"; @@ -27,26 +26,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() { @@ -60,22 +48,30 @@ public override void Complete() ScreenStack.Push(ImportLyricStep.GenerateRuby); } - protected void AskForAutoAssignLanguage() + internal void AskForAutoAssignLanguage() { DialogOverlay.Push(new UseLanguageDetectorPopupDialog(ok => { - if (ok) - LyricManager.AutoDetectLyricLanguage(); + if (!ok) + return; + + LyricManager.AutoDetectLyricLanguage(); + Navigation.State = NavigationState.Done; })); } - public class AssignLanguageNavigation : TopNavigation + public class AssignLanguageNavigation : TopNavigation { - public AssignLanguageNavigation(ImportLyricSubScreen screen) + private const string auto_assign_language = "AUTO_ASSIGN_LANGUAGE"; + + public AssignLanguageNavigation(AssignLanguageSubScreen screen) : base(screen) { } + protected override NavigationTextContainer CreateTextContainer() + => new AssignLanguageTextFlowContainer(Screen); + protected override void UpdateState(NavigationState value) { base.UpdateState(value); @@ -83,11 +79,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: @@ -99,6 +95,14 @@ protected override void UpdateState(NavigationState value) break; } } + + private class AssignLanguageTextFlowContainer : NavigationTextContainer + { + public AssignLanguageTextFlowContainer(AssignLanguageSubScreen screen) + { + 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 bdcab00ea..d1bf34e53 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/EditLyric/EditLyricSubScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/EditLyric/EditLyricSubScreen.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.EditLyric { - public class EditLyricSubScreen : ImportLyricSubScreenWithTopNavigation + public class EditLyricSubScreen : ImportLyricSubScreenWithLyricEditor { public override string Title => "Edit lyric"; @@ -27,26 +26,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() { @@ -59,13 +47,25 @@ public override void Complete() ScreenStack.Push(ImportLyricStep.AssignLanguage); } - public class EditLyricNavigation : TopNavigation + 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 NavigationTextContainer CreateTextContainer() + => new EditLyricTextFlowContainer(Screen); + protected override void UpdateState(NavigationState value) { base.UpdateState(value); @@ -73,12 +73,21 @@ 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: @@ -86,6 +95,18 @@ protected override void UpdateState(NavigationState value) break; } } + + protected override bool AbleToNextStep(NavigationState value) + => true; + + private class EditLyricTextFlowContainer : NavigationTextContainer + { + public EditLyricTextFlowContainer(EditLyricSubScreen screen) + { + 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 c7247f401..795ee5e3f 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(); + if (!ok) + return; + + RubyRomajiManager.AutoGenerateRubyTags(); + Navigation.State = NavigationState.Done; })); } - public class GenerateRubyNavigation : TopNavigation + public class GenerateRubyNavigation : TopNavigation { - public GenerateRubyNavigation(ImportLyricSubScreen screen) + 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 737424a5e..b201357f0 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() { @@ -60,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); - } + if (!ok) + return; + + timeTagManager.AutoGenerateTimeTags(); + Navigation.State = NavigationState.Done; })); } - public class GenerateTimeTagNavigation : TopNavigation + public class GenerateTimeTagNavigation : TopNavigation { - public GenerateTimeTagNavigation(ImportLyricSubScreen screen) + 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); @@ -87,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 auto-generate time tag. It's very easy."; break; case NavigationState.Working: case NavigationState.Done: - NavigationText = "Cool"; + NavigationText = $"Cool, you can reset your time-tag by pressing [{auto_generate_time_tag}]"; break; case NavigationState.Error: @@ -103,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/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 75c0d338a..0cff5d753 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithTopNavigation.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/ImportLyricSubScreenWithTopNavigation.cs @@ -6,6 +6,7 @@ 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; @@ -48,6 +49,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] @@ -56,7 +67,7 @@ public abstract class TopNavigation : Container protected ImportLyricSubScreen Screen { get; } private readonly CornerBackground background; - private readonly OsuSpriteText text; + private readonly NavigationTextContainer text; private readonly IconButton button; protected TopNavigation(ImportLyricSubScreen screen) @@ -70,12 +81,14 @@ protected TopNavigation(ImportLyricSubScreen screen) { RelativeSizeAxes = Axes.Both, }, - text = new OsuSpriteText + text = CreateTextContainer().With(t => { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Margin = new MarginPadding { Left = 15 } - }, + 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 +105,8 @@ protected TopNavigation(ImportLyricSubScreen screen) }; } + protected abstract NavigationTextContainer CreateTextContainer(); + protected string NavigationText { set => text.Text = value; @@ -161,6 +176,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 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 {