Skip to content

Commit

Permalink
Merge pull request #964 from andy840119/remove-old-manager
Browse files Browse the repository at this point in the history
Remove lyric manager.
  • Loading branch information
andy840119 authored Dec 11, 2021
2 parents 21dd020 + e742067 commit d471fda
Show file tree
Hide file tree
Showing 28 changed files with 282 additions and 753 deletions.
152 changes: 0 additions & 152 deletions osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneLyricEditor.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Overlays;
using osu.Game.Rulesets.Karaoke.Configuration;
using osu.Game.Rulesets.Karaoke.Edit.Checker;
using osu.Game.Rulesets.Karaoke.Edit.Lyrics;
using osu.Game.Rulesets.Karaoke.Graphics.UserInterface;

namespace osu.Game.Rulesets.Karaoke.Tests.Editor
{
public class TestSceneLyricEditorScreen : KaraokeEditorScreenTestScene<LyricEditorScreen>
{
protected override Container<Drawable> Content { get; } = new Container { RelativeSizeAxes = Axes.Both };

protected override LyricEditorScreen CreateEditorScreen() => new();

private DialogOverlay dialogOverlay;
private LanguageSelectionDialog languageSelectionDialog;
private LyricCheckerManager lyricCheckManager;
private KaraokeRulesetLyricEditorConfigManager lyricEditorConfigManager;

[BackgroundDependencyLoader]
private void load()
{
base.Content.AddRange(new Drawable[]
{
Content,
dialogOverlay = new DialogOverlay(),
languageSelectionDialog = new LanguageSelectionDialog(),
lyricCheckManager = new LyricCheckerManager(),
});

Dependencies.Cache(dialogOverlay);
Dependencies.Cache(languageSelectionDialog);
Dependencies.Cache(lyricCheckManager);
Dependencies.Cache(lyricEditorConfigManager = new KaraokeRulesetLyricEditorConfigManager());
}

[TestCase(LyricEditorMode.View)]
[TestCase(LyricEditorMode.Manage)]
[TestCase(LyricEditorMode.Typing)]
[TestCase(LyricEditorMode.Language)]
[TestCase(LyricEditorMode.EditRuby)]
[TestCase(LyricEditorMode.EditRomaji)]
[TestCase(LyricEditorMode.CreateTimeTag)]
[TestCase(LyricEditorMode.EditNote)]
[TestCase(LyricEditorMode.Layout)]
[TestCase(LyricEditorMode.Singer)]
public void TestSwitchMode(LyricEditorMode mode)
{
AddStep($"switch to mode {Enum.GetName(typeof(LyricEditorMode), mode)}", () =>
{
lyricEditorConfigManager.SetValue(KaraokeRulesetLyricEditorSetting.LyricEditorMode, mode);
});
AddWaitStep("wait for switch to new mode", 5);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void ChangeOrder(int newOrder)

protected override void Add(Lyric hitObject)
{
var index = HitObjects.ToList().FindIndex(x => x.Order == hitObject.Order - 1);
var index = HitObjects.ToList().FindIndex(x => x.Order == hitObject.Order - 1) + 1;
Insert(index, hitObject);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Karaoke.Edit.Lyrics;
using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers;
using osu.Game.Rulesets.Karaoke.Objects;
using osu.Game.Rulesets.Karaoke.Objects.Types;
using osu.Game.Rulesets.Karaoke.Utils;
Expand All @@ -13,18 +13,18 @@ namespace osu.Game.Rulesets.Karaoke.Edit.Components.ContextMenu
{
public class LyricLockContextMenu : OsuMenuItem
{
public LyricLockContextMenu(LyricManager manager, Lyric lyric, string name)
: this(manager, new List<Lyric> { lyric }, name)
public LyricLockContextMenu(ILockChangeHandler lockChangeHandler, Lyric lyric, string name)
: this(lockChangeHandler, new List<Lyric> { lyric }, name)
{
}

public LyricLockContextMenu(LyricManager manager, List<Lyric> lyrics, string name)
public LyricLockContextMenu(ILockChangeHandler lockChangeHandler, List<Lyric> lyrics, string name)
: base(name)
{
Items = EnumUtils.GetValues<LockState>().Select(l => new OsuMenuItem(l.ToString(), anyLyricInLockState(l) ? MenuItemType.Highlighted : MenuItemType.Standard, () =>
{
// change all selected lyric state.
manager.LockLyrics(lyrics, l);
// todo: how to make lyric as selected?
lockChangeHandler.Lock(l);
})).ToList();

bool anyLyricInLockState(LockState lockState) => lyrics.Any(lyric => lyric.Lock == lockState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,35 @@
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Karaoke.Beatmaps;
using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas;
using osu.Game.Rulesets.Karaoke.Edit.Lyrics;
using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics;
using osu.Game.Rulesets.Karaoke.Objects;
using osu.Game.Rulesets.Karaoke.Utils;
using osu.Game.Screens.Edit;

namespace osu.Game.Rulesets.Karaoke.Edit.Components.ContextMenu
{
public class SingerContextMenu : OsuMenuItem
{
public SingerContextMenu(LyricManager manager, List<Lyric> lyrics, string name, Action postProcess = null)
public SingerContextMenu(EditorBeatmap beatmap, ILyricSingerChangeHandler lyricSingerChangeHandler, string name, Action postProcess = null)
: base(name)
{
Items = manager.Singers?.Select(singer => new OsuMenuItem(singer.Name, anySingerInLyric(singer) ? MenuItemType.Highlighted : MenuItemType.Standard, () =>
var lyrics = beatmap.SelectedHitObjects.OfType<Lyric>();
var singers = (beatmap.PlayableBeatmap as KaraokeBeatmap)?.Singers;

Items = singers?.Select(singer => new OsuMenuItem(singer.Name, anySingerInLyric(singer) ? MenuItemType.Highlighted : MenuItemType.Standard, () =>
{
// if only one lyric
if (allSingerInLyric(singer))
{
lyrics.ForEach(lyric => manager.RemoveSingerToLyric(singer, lyric));
lyricSingerChangeHandler.Remove(singer);
}
else
{
lyrics.ForEach(lyric => manager.AddSingerToLyric(singer, lyric));
lyricSingerChangeHandler.Add(singer);
}

postProcess?.Invoke();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics;
using osu.Game.Rulesets.Karaoke.Edit.Lyrics;
using osu.Game.Screens.Edit;

namespace osu.Game.Rulesets.Karaoke.Edit.ImportLyric.AssignLanguage
{
Expand All @@ -21,17 +20,18 @@ public class AssignLanguageStepScreen : LyricImporterStepScreenWithLyricEditor

public override IconUsage Icon => FontAwesome.Solid.Globe;

[Cached(typeof(ILyricLanguageChangeHandler))]
private readonly LyricLanguageChangeHandler lyricLanguageChangeHandler;

[Cached(typeof(ILyricRubyChangeHandler))]
private readonly LyricRubyChangeHandler lyricRubyChangeHandler;

[Cached(typeof(ILyricRomajiChangeHandler))]
private readonly LyricRomajiChangeHandler lyricRomajiChangeHandler;

[Resolved]
private EditorBeatmap beatmap { get; set; }

public AssignLanguageStepScreen()
{
AddInternal(lyricLanguageChangeHandler = new LyricLanguageChangeHandler());
AddInternal(lyricRubyChangeHandler = new LyricRubyChangeHandler());
AddInternal(lyricRomajiChangeHandler = new LyricRomajiChangeHandler());
}
Expand Down Expand Up @@ -72,7 +72,7 @@ internal void AskForAutoAssignLanguage()
if (!ok)
return;

LyricManager.AutoDetectLyricLanguage();
lyricLanguageChangeHandler.AutoGenerate();
Navigation.State = NavigationState.Done;
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
// See the LICENCE file in the repository root for full licence text.

using System.ComponentModel;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics;
using osu.Game.Rulesets.Karaoke.Edit.Lyrics;

namespace osu.Game.Rulesets.Karaoke.Edit.ImportLyric.EditLyric
Expand All @@ -18,6 +20,14 @@ public class EditLyricStepScreen : LyricImporterStepScreenWithLyricEditor

public override IconUsage Icon => FontAwesome.Solid.Globe;

[Cached(Type = typeof(ILyricsChangeHandler))]
private readonly LyricsChangeHandler lyricsChangeHandler;

public EditLyricStepScreen()
{
AddInternal(lyricsChangeHandler = new LyricsChangeHandler());
}

protected override TopNavigation CreateNavigation()
=> new EditLyricNavigation(this);

Expand Down
Loading

0 comments on commit d471fda

Please sign in to comment.