Skip to content

Commit

Permalink
Merge pull request #328 from andy840119/lyric-import/use-text-flow-on…
Browse files Browse the repository at this point in the history
…-navigation

Let import navigation be clickable.
  • Loading branch information
andy840119 authored Dec 19, 2020
2 parents b3656f5 + eba0a83 commit 0e840b0
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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<IAdjustableClock>(clock);
dependencies.CacheAs<IFrameBasedClock>(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()
{
Expand All @@ -60,34 +48,42 @@ 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<AssignLanguageSubScreen>
{
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);

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:
Expand All @@ -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);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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<IAdjustableClock>(clock);
dependencies.CacheAs<IFrameBasedClock>(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()
{
Expand All @@ -59,33 +47,66 @@ 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<EditLyricSubScreen>
{
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);

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:
NavigationText = "Oops, seems cause some error in here.";
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));
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,43 @@ 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<GenerateRubySubScreen>
{
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);

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:
Expand All @@ -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);
}
}
}
}
}
Loading

0 comments on commit 0e840b0

Please sign in to comment.