Skip to content

Commit

Permalink
Add with lyric editor screen to collect generate lyric editor and inj…
Browse files Browse the repository at this point in the history
…ection logic.
  • Loading branch information
andy840119 committed Dec 19, 2020
1 parent dbc9a02 commit 0f6a397
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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<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 @@ -70,15 +58,15 @@ protected void AskForAutoAssignLanguage()
}));
}

public class AssignLanguageNavigation : TopNavigation
public class AssignLanguageNavigation : TopNavigation<AssignLanguageSubScreen>
{
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)
{
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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<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 @@ -60,15 +48,15 @@ public override void Complete()
ScreenStack.Push(ImportLyricStep.AssignLanguage);
}

public class EditLyricNavigation : TopNavigation
public class EditLyricNavigation : TopNavigation<EditLyricSubScreen>
{
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)
{
Expand All @@ -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);
}
Expand Down
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.GenerateTimeTag
{
public class GenerateTimeTagSubScreen : ImportLyricSubScreenWithTopNavigation
public class GenerateTimeTagSubScreen : ImportLyricSubScreenWithLyricEditor
{
public override string Title => "Generate time tag";

Expand All @@ -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<IAdjustableClock>(clock);
dependencies.CacheAs<IFrameBasedClock>(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()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) andy840119 <[email protected]>. 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<IAdjustableClock>(clock);
dependencies.CacheAs<IFrameBasedClock>(clock);

return dependencies;
}

protected override Drawable CreateContent()
=> LyricEditor = new LyricEditor
{
RelativeSizeAxes = Axes.Both,
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ protected ImportLyricSubScreenWithTopNavigation()

protected abstract Drawable CreateContent();

public abstract class TopNavigation<T> : TopNavigation where T : ImportLyricSubScreenWithTopNavigation
{
protected new T Screen => base.Screen as T;

protected TopNavigation(T screen)
: base(screen)
{
}
}

public abstract class TopNavigation : Container
{
[Resolved]
Expand All @@ -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;
Expand All @@ -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
{
Expand Down

0 comments on commit 0f6a397

Please sign in to comment.