Skip to content

Commit

Permalink
Almost fucking there/
Browse files Browse the repository at this point in the history
  • Loading branch information
andy840119 committed Dec 19, 2020
1 parent bc26d17 commit 343db24
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<AssignLanguageSubScreen>
{
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)
Expand All @@ -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:
Expand All @@ -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());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<EditLyricSubScreen>
{
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)
Expand All @@ -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:
Expand All @@ -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));
}
}
}
Expand Down
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();
Navigation.State = NavigationState.Done;
}
}));
}

public class GenerateRubyNavigation : TopNavigation<GenerateRubySubScreen>
{
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());
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,39 +48,43 @@ 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<GenerateTimeTagSubScreen>
{
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);

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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -102,7 +104,7 @@ protected TopNavigation(ImportLyricSubScreen screen)
};
}

protected virtual TextFlowContainer CreateTextContainer() => new TextFlowContainer();
protected abstract NavigationTextContainer CreateTextContainer();

protected string NavigationText
{
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 343db24

Please sign in to comment.