diff --git a/osu.Game.Rulesets.Karaoke.Tests/Beatmaps/TestElementId.cs b/osu.Game.Rulesets.Karaoke.Tests/Beatmaps/TestElementId.cs index 2c80e63f9..e79d8c312 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Beatmaps/TestElementId.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Beatmaps/TestElementId.cs @@ -35,11 +35,17 @@ public void TestCreateElementId(string id, bool created) { if (created) { - Assert.DoesNotThrow(() => new ElementId(id)); + Assert.DoesNotThrow(() => + { + var _ = new ElementId(id); + }); } else { - Assert.Throws(() => new ElementId(id)); + Assert.Throws(() => + { + var _ = new ElementId(id); + }); } } diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneSetupScreen.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneSetupScreen.cs index e0573f5b2..8561c7b7f 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneSetupScreen.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneSetupScreen.cs @@ -18,22 +18,17 @@ public partial class TestSceneSetupScreen : EditorClockTestScene { [Cached(typeof(EditorBeatmap))] [Cached(typeof(IBeatSnapProvider))] - private readonly EditorBeatmap editorBeatmap; + private readonly EditorBeatmap editorBeatmap = new(new KaraokeBeatmap + { + BeatmapInfo = + { + Ruleset = new KaraokeRuleset().RulesetInfo, + }, + }); [Cached] private readonly OverlayColourProvider colourProvider = new(OverlayColourScheme.Blue); - public TestSceneSetupScreen() - { - editorBeatmap = new EditorBeatmap(new KaraokeBeatmap - { - BeatmapInfo = - { - Ruleset = new KaraokeRuleset().RulesetInfo, - }, - }); - } - [Test] public void TestKaraoke() => runForRuleset(new KaraokeRuleset().RulesetInfo); diff --git a/osu.Game.Rulesets.Karaoke.Tests/Replays/TestSceneAutoGenerationBySinger.cs b/osu.Game.Rulesets.Karaoke.Tests/Replays/TestSceneAutoGenerationBySinger.cs index abfb7d49f..7d45607b0 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Replays/TestSceneAutoGenerationBySinger.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Replays/TestSceneAutoGenerationBySinger.cs @@ -56,10 +56,13 @@ private static IReadOnlyList getCompareResultFromName(st private struct TestKaraokeReplayFrame { + [JsonProperty] public double Time { get; set; } + [JsonProperty] public float Pitch { get; set; } + [JsonProperty] public bool Sound { get; set; } } } diff --git a/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/CaretPosition/Algorithms/BaseCaretPositionAlgorithmTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/CaretPosition/Algorithms/BaseCaretPositionAlgorithmTest.cs index 37af52bb0..0d37d92ed 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/CaretPosition/Algorithms/BaseCaretPositionAlgorithmTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/CaretPosition/Algorithms/BaseCaretPositionAlgorithmTest.cs @@ -106,15 +106,17 @@ protected Lyric[] GetLyricsByMethodName(string methodName) private static PropertyInfo? getMethod(Type type, string methodName) { - var theMethod = type.GetProperty(methodName, BindingFlags.NonPublic | BindingFlags.Static); + Type? targetType = type; - if (theMethod != null) - return theMethod; + while (targetType != null) + { + var theMethod = targetType.GetProperty(methodName, BindingFlags.NonPublic | BindingFlags.Static); + if (theMethod != null) + return theMethod; - var baseType = type.BaseType; - if (baseType == null) - return null; + targetType = targetType.BaseType; + } - return getMethod(baseType, methodName); + return null; } } diff --git a/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/Components/TestScenePreviewKaraokeSpriteText.cs b/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/Components/TestScenePreviewKaraokeSpriteText.cs index 6ce3c7855..16923d804 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/Components/TestScenePreviewKaraokeSpriteText.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/Components/TestScenePreviewKaraokeSpriteText.cs @@ -27,18 +27,13 @@ public partial class TestScenePreviewKaraokeSpriteText : OsuTestScene private Action? updateAction; - private readonly Lyric lyric; - - public TestScenePreviewKaraokeSpriteText() + private readonly Lyric lyric = new() { - lyric = new Lyric - { - Text = "カラオケ", - TimeTags = TestCaseTagHelper.ParseTimeTags(new[] { "[0,start]:1000", "[1,start]:2000", "[2,start]:3000", "[3,start]:4000", "[3,end]:5000" }), - RubyTags = TestCaseTagHelper.ParseRubyTags(new[] { "[0]:か", "[1]:ら", "[2]:お", "[3]:け" }), - RomajiTags = TestCaseTagHelper.ParseRomajiTags(new[] { "[0]:ka", "[1]:ra", "[2]:o", "[3]:ke" }), - }; - } + Text = "カラオケ", + TimeTags = TestCaseTagHelper.ParseTimeTags(new[] { "[0,start]:1000", "[1,start]:2000", "[2,start]:3000", "[3,start]:4000", "[3,end]:5000" }), + RubyTags = TestCaseTagHelper.ParseRubyTags(new[] { "[0]:か", "[1]:ら", "[2]:お", "[3]:け" }), + RomajiTags = TestCaseTagHelper.ParseRomajiTags(new[] { "[0]:ka", "[1]:ra", "[2]:o", "[3]:ke" }), + }; protected override void Update() { diff --git a/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Import/TestSceneLyricImporter.cs b/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Import/TestSceneLyricImporter.cs index e182d3d87..59b0d42d2 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Import/TestSceneLyricImporter.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Import/TestSceneLyricImporter.cs @@ -25,7 +25,7 @@ public partial class TestSceneLyricImporter : ScreenTestScene Content { get; } = new Container { RelativeSizeAxes = Axes.Both }; @@ -37,11 +37,6 @@ protected override TestLyricImporter CreateScreen() private DialogOverlay dialogOverlay = null!; - public TestSceneLyricImporter() - { - lyricEditorConfigManager = new KaraokeRulesetLyricEditorConfigManager(); - } - [BackgroundDependencyLoader] private void load() { diff --git a/osu.Game.Rulesets.Karaoke.Tests/Stages/Classic/ClassicStageInfoTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Stages/Classic/ClassicStageInfoTest.cs deleted file mode 100644 index 7e8d885ca..000000000 --- a/osu.Game.Rulesets.Karaoke.Tests/Stages/Classic/ClassicStageInfoTest.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -namespace osu.Game.Rulesets.Karaoke.Tests.Stages.Classic; - -public class ClassicStageInfoTest -{ - #region Stage element - - #endregion -} diff --git a/osu.Game.Rulesets.Karaoke.Tests/Utils/ComparableUtilsTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Utils/ComparableUtilsTest.cs index dbab86816..c657dbb77 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Utils/ComparableUtilsTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Utils/ComparableUtilsTest.cs @@ -50,10 +50,13 @@ public void TestCompareByProperty(string leftObjectProperty, string rightObjectP private class TestObject { - public int A { get; set; } = 0; + [JsonProperty] + public int A { get; set; } - public double B { get; set; } = 0; + [JsonProperty] + public double B { get; set; } + [JsonProperty] public string C { get; set; } = string.Empty; } } diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeJsonBeatmapDecoder.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeJsonBeatmapDecoder.cs index 52c572a31..4f43fe52d 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeJsonBeatmapDecoder.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeJsonBeatmapDecoder.cs @@ -48,12 +48,9 @@ protected override IList CreateProperties(Type type, MemberSeriali { var props = base.CreateProperties(type, memberSerialization); - if (type == typeof(BeatmapInfo)) - { - return props.Where(p => p.PropertyName != "ruleset_id").ToList(); - } - - return props; + return type == typeof(BeatmapInfo) + ? props.Where(p => p.PropertyName != "ruleset_id").ToList() + : props; } } } diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeLegacyBeatmapEncoder.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeLegacyBeatmapEncoder.cs index 0605d9694..c9277f66e 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeLegacyBeatmapEncoder.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeLegacyBeatmapEncoder.cs @@ -52,11 +52,9 @@ private IEnumerable encodeNote(Beatmap output) // Convert single note static string convertNote(Note note) { - if (!note.Display) - return "-"; - - // TODO : Fill if customize ruby and percentage - return convertTone(note.Tone); + return !note.Display + ? "-" + : convertTone(note.Tone); // Convert tone to string static string convertTone(Tone tone) => tone.Scale + (tone.Half ? "#" : string.Empty); diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapExtension.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapExtension.cs index f17ae952f..c581c44aa 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapExtension.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapExtension.cs @@ -12,14 +12,9 @@ public static class KaraokeBeatmapExtension { public static bool IsScorable(this IBeatmap beatmap) { - if (beatmap is not KaraokeBeatmap karaokeBeatmap) - { - // we should throw invalidate exception here but it will cause test case failed. - // because beatmap in the working beatmap in test case not always be karaoke beatmap class. - return false; - } - - return karaokeBeatmap.Scorable; + // we should throw invalidate exception here but it will cause test case failed. + // because beatmap in the working beatmap in test case not always be karaoke beatmap class. + return beatmap is KaraokeBeatmap karaokeBeatmap && karaokeBeatmap.Scorable; } public static IList AvailableTranslates(this IBeatmap beatmap) => (beatmap as KaraokeBeatmap)?.AvailableTranslates ?? new List(); diff --git a/osu.Game.Rulesets.Karaoke/Difficulty/KaraokeDifficultyCalculator.cs b/osu.Game.Rulesets.Karaoke/Difficulty/KaraokeDifficultyCalculator.cs index 7a12863cf..f620409f7 100644 --- a/osu.Game.Rulesets.Karaoke/Difficulty/KaraokeDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Karaoke/Difficulty/KaraokeDifficultyCalculator.cs @@ -79,16 +79,11 @@ protected override IEnumerable CreateDifficultyHitObjects(I private int getHitWindow300(Mod[] mods) { - if (isForCurrentRuleset) - { - double od = Math.Min(10.0, Math.Max(0, 10.0 - originalOverallDifficulty)); - return applyModAdjustments(34 + 3 * od, mods); - } - - if (Math.Round(originalOverallDifficulty) > 4) - return applyModAdjustments(34, mods); + if (!isForCurrentRuleset) + return applyModAdjustments(Math.Round(originalOverallDifficulty) > 4 ? 34 : 47, mods); - return applyModAdjustments(47, mods); + double od = Math.Min(10.0, Math.Max(0, 10.0 - originalOverallDifficulty)); + return applyModAdjustments(34 + 3 * od, mods); static int applyModAdjustments(double value, Mod[] mods) { diff --git a/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckBeatmapClassicStageInfo.cs b/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckBeatmapClassicStageInfo.cs index 9668b27cd..59fffaa3a 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckBeatmapClassicStageInfo.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckBeatmapClassicStageInfo.cs @@ -143,10 +143,6 @@ public IssueTemplateInvalidRowHeight(ICheck check) public Issue Create() => new(this); } - #region stage definition - - #endregion - #region timing info public class IssueTemplateLessThanTwoTimingPoints : IssueTemplate diff --git a/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs b/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs index df9664bf8..604008c9d 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs @@ -126,7 +126,7 @@ public override SnapResult FindSnappedPositionAndTime(Vector2 screenSpacePositio : result; } - protected override DrawableRuleset CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList? mods = null) + protected override DrawableRuleset CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList mods) { drawableRuleset = new DrawableKaraokeEditorRuleset(ruleset, beatmap, mods); diff --git a/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/SingerDisplay.cs b/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/SingerDisplay.cs index 73d621667..1f205ede5 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/SingerDisplay.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/SingerDisplay.cs @@ -8,7 +8,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.UserInterface; -using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; @@ -79,9 +78,6 @@ private partial class SingerCircle : OsuClickableContainer, IHasContextMenu, IHa private readonly DrawableSingerAvatar singerAvatar; - [Resolved] - private OsuColour colours { get; set; } = null!; - public SingerCircle() { RelativeSizeAxes = Axes.X; diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/CaretPosition/Algorithms/TimeTagCaretPositionAlgorithm.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/CaretPosition/Algorithms/TimeTagCaretPositionAlgorithm.cs index 272db68cc..fe81965b4 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/CaretPosition/Algorithms/TimeTagCaretPositionAlgorithm.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/CaretPosition/Algorithms/TimeTagCaretPositionAlgorithm.cs @@ -81,11 +81,8 @@ protected override bool PositionMovable(TimeTagCaretPosition position) protected override TimeTagCaretPosition? MoveToFirstLyric() { var firstLyric = Lyrics.FirstOrDefault(x => x.TimeTags.Any(timeTagMovable)); - if (firstLyric == null) - return null; - - var firstTimeTag = firstLyric.TimeTags.FirstOrDefault(timeTagMovable); - if (firstTimeTag == null) + var firstTimeTag = firstLyric?.TimeTags.FirstOrDefault(timeTagMovable); + if (firstLyric == null || firstTimeTag == null) return null; return CreateCaretPosition(firstLyric, firstTimeTag); @@ -94,11 +91,8 @@ protected override bool PositionMovable(TimeTagCaretPosition position) protected override TimeTagCaretPosition? MoveToLastLyric() { var lastLyric = Lyrics.LastOrDefault(x => x.TimeTags.Any(timeTagMovable)); - if (lastLyric == null) - return null; - - var lastTimeTag = lastLyric.TimeTags.LastOrDefault(timeTagMovable); - if (lastTimeTag == null) + var lastTimeTag = lastLyric?.TimeTags.LastOrDefault(timeTagMovable); + if (lastLyric == null || lastTimeTag == null) return null; return CreateCaretPosition(lastLyric, lastTimeTag); diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/PreviewKaraokeSpriteText.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/PreviewKaraokeSpriteText.cs index 155d4d701..3aa6224a2 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/PreviewKaraokeSpriteText.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/PreviewKaraokeSpriteText.cs @@ -26,7 +26,7 @@ public partial class PreviewKaraokeSpriteText : DrawableKaraokeSpriteText x.Index == textIndex); + return HitObject.TimeTags.FirstOrDefault(x => x.Index == hoverIndex); - TextIndex getHoverIndex() + TextIndex? getHoverIndex() { for (int i = 0; i < Text.Length; i++) { - if (getTriggerPositionByTimeIndex(new TextIndex(i)) > position) - return new TextIndex(i); - - if (getTriggerPositionByTimeIndex(new TextIndex(i, TextIndex.IndexState.End)) > position) - return new TextIndex(i, TextIndex.IndexState.End); + foreach (var indexState in Enum.GetValues()) + { + var textIndex = new TextIndex(i, indexState); + var triggerRange = getTriggerRange(textIndex); + if (position >= triggerRange.Item1 && position <= triggerRange.Item2) + return textIndex; + } } - return new TextIndex(Text.Length - 1, TextIndex.IndexState.End); + // hover the last time-tag if exceed the range. + return null; - // todo : might have a better way to call spriteText.GetTimeTagPosition just once. - float getTriggerPositionByTimeIndex(TextIndex textIndex) + Tuple getTriggerRange(TextIndex textIndex) { - int charIndex = textIndex.Index; - float startPosition = spriteText.GetTimeTagPosition(new TextIndex(charIndex)).X; - float endPosition = spriteText.GetTimeTagPosition(new TextIndex(charIndex, TextIndex.IndexState.End)).X; - - return TextIndexUtils.GetValueByState(textIndex, () => startPosition + (endPosition - startPosition) / 2, () => endPosition); + var rect = spriteText.GetCharacterDrawRectangle(textIndex.Index); + return TextIndexUtils.GetValueByState(textIndex, + () => new Tuple(rect.Left, rect.Centre.X), + () => new Tuple(rect.Centre.X, rect.Right)); } } } diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Compose/Toolbar/ToolbarButton.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Compose/Toolbar/ToolbarButton.cs index cf86183e7..a69468118 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Compose/Toolbar/ToolbarButton.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Compose/Toolbar/ToolbarButton.cs @@ -5,7 +5,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; -using osu.Framework.Input; using osu.Game.Graphics.Containers; using osuTK; @@ -26,9 +25,6 @@ public void SetIcon(Drawable icon) [Resolved] private TextureStore textures { get; set; } = null!; - [Resolved] - private ReadableKeyCombinationProvider keyCombinationProvider { get; set; } = null!; - public void SetIcon(string texture) => SetIcon(new Sprite { diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorClipboard.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorClipboard.cs index e6332938a..9dd360919 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorClipboard.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorClipboard.cs @@ -44,9 +44,6 @@ public partial class LyricEditorClipboard : Component, ILyricEditorClipboard [Resolved] private ITimeTagModeState timeTagModeState { get; set; } = null!; - [Resolved] - private IEditRomajiModeState editRomajiModeState { get; set; } = null!; - [Resolved] private ILyricsChangeHandler? lyricsChangeHandler { get; set; } diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorVerifier.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorVerifier.cs index f003a0504..100015ceb 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorVerifier.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorVerifier.cs @@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics; public partial class LyricEditorVerifier : EditorVerifier, ILyricEditorVerifier { [Resolved] - private EditorBeatmap beatmap { get; set; } = null!; + private EditorBeatmap editorBeatmap { get; set; } = null!; private readonly Dictionary> hitObjectIssues = new(); @@ -65,9 +65,9 @@ protected override void LoadComplete() base.LoadComplete(); // need to check is there any lyric added or removed. - beatmap.HitObjectAdded += hitObjectAdded; - beatmap.HitObjectRemoved += hitObjectRemoved; - beatmap.HitObjectUpdated += hitObjectUpdated; + editorBeatmap.HitObjectAdded += hitObjectAdded; + editorBeatmap.HitObjectRemoved += hitObjectRemoved; + editorBeatmap.HitObjectUpdated += hitObjectUpdated; recalculateIssues(); } @@ -80,7 +80,7 @@ private void load(KaraokeRulesetEditCheckerConfigManager? rulesetEditCheckerConf private void recalculateIssues() { - var hitObjects = beatmap.HitObjects.OfType().ToArray(); + var hitObjects = editorBeatmap.HitObjects.OfType().ToArray(); var listedHitObjects = hitObjectIssues.Keys.ToArray(); var newHitObjects = hitObjects.Except(listedHitObjects); @@ -182,9 +182,9 @@ protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); - beatmap.HitObjectAdded -= hitObjectAdded; - beatmap.HitObjectRemoved -= hitObjectRemoved; - beatmap.HitObjectUpdated -= hitObjectUpdated; + editorBeatmap.HitObjectAdded -= hitObjectAdded; + editorBeatmap.HitObjectRemoved -= hitObjectRemoved; + editorBeatmap.HitObjectUpdated -= hitObjectUpdated; } } diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/LyricEditorAutoGenerateSubsection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/LyricEditorAutoGenerateSubsection.cs index 22c7eee24..8d2135754 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/LyricEditorAutoGenerateSubsection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/LyricEditorAutoGenerateSubsection.cs @@ -17,7 +17,7 @@ public abstract partial class LyricEditorAutoGenerateSubsection : AutoGenerateSu protected LyricEditorAutoGenerateSubsection(AutoGenerateType generateType) { - this.autoGenerateType = generateType; + autoGenerateType = generateType; } protected override EditorSectionButton CreateGenerateButton() diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditSection.cs index e70646019..dffe4b520 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditSection.cs @@ -11,7 +11,6 @@ using osu.Game.Rulesets.Karaoke.Extensions; using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; -using osu.Game.Screens.Edit; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Romaji; @@ -44,9 +43,6 @@ private partial class RomajiTagsEditor : LyricPropertiesEditor { private readonly Bindable bindableRomajiEditPropertyMode = new(); - [Resolved] - private EditorBeatmap beatmap { get; set; } = null!; - public RomajiTagsEditor() { bindableRomajiEditPropertyMode.BindValueChanged(e => diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IHasEditStep.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IHasEditStep.cs index 2931161c9..82b5b3185 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IHasEditStep.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IHasEditStep.cs @@ -6,11 +6,11 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; -public interface IHasEditStep where T : Enum +public interface IHasEditStep where TEditStep : Enum { - IBindable BindableEditStep { get; } + IBindable BindableEditStep { get; } - T EditStep => BindableEditStep.Value; + TEditStep EditStep => BindableEditStep.Value; - void ChangeEditStep(T mode); + void ChangeEditStep(TEditStep step); } diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Pages/PageScreen.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Pages/PageScreen.cs index 78fcec632..afaedad43 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Pages/PageScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Pages/PageScreen.cs @@ -94,14 +94,12 @@ public void Select(Page item) private partial class FixedSectionsContainer : SectionsContainer where T : Drawable { - private readonly Container content; - // todo: check what this shit doing. - protected override Container Content => content; + protected override Container Content { get; } public FixedSectionsContainer() { - AddInternal(content = new Container + AddInternal(Content = new Container { Masking = true, RelativeSizeAxes = Axes.Both, diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Singers/SingerScreen.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Singers/SingerScreen.cs index 961c71232..989f7be45 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Singers/SingerScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Singers/SingerScreen.cs @@ -83,14 +83,12 @@ protected override void PopOut() private partial class FixedSectionsContainer : SectionsContainer where T : Drawable { - private readonly Container content; - // todo: check what this shit doing. - protected override Container Content => content; + protected override Container Content { get; } public FixedSectionsContainer() { - AddInternal(content = new Container + AddInternal(Content = new Container { Masking = true, RelativeSizeAxes = Axes.Both, diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Import/Lyrics/GenerateRuby/GenerateRubyNavigation.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Import/Lyrics/GenerateRuby/GenerateRubyNavigation.cs index 12042430d..97009fceb 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Import/Lyrics/GenerateRuby/GenerateRubyNavigation.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Import/Lyrics/GenerateRuby/GenerateRubyNavigation.cs @@ -43,8 +43,8 @@ protected override LocalisableString GetNavigationText(NavigationState value) => value switch { NavigationState.Initial => $"Lazy to typing ruby? Press [{auto_generate_ruby}].", - NavigationState.Working => $"Go to next step to generate time-tag.", - NavigationState.Done => $"Go to next step to generate time-tag.", + NavigationState.Working => "Go to next step to generate time-tag.", + NavigationState.Done => "Go to next step to generate time-tag.", NavigationState.Error => "Oops, seems cause some error in here.", _ => throw new ArgumentOutOfRangeException(nameof(value)), }; diff --git a/osu.Game.Rulesets.Karaoke/Utils/CharUtils.cs b/osu.Game.Rulesets.Karaoke/Utils/CharUtils.cs index b381b9656..31964e4d7 100644 --- a/osu.Game.Rulesets.Karaoke/Utils/CharUtils.cs +++ b/osu.Game.Rulesets.Karaoke/Utils/CharUtils.cs @@ -64,17 +64,17 @@ public static bool IsChinese(char c) /// public static bool IsLatin(char c) { - if (c >= 'A' && c <= 'Z') - return true; + switch (c) + { + case >= 'A' and <= 'Z': + case >= 'a' and <= 'z': + // another romanized characters + // see: https://www.unicode.org/charts/PDF/U1E00.pdf + case >= '\u1E00' and <= '\u1EFF': + return true; - if (c >= 'a' && c <= 'z') - return true; - - // another romanized characters - // see: https://www.unicode.org/charts/PDF/U1E00.pdf - if (c >= '\u1E00' && c <= '\u1EFF') - return true; - - return false; + default: + return false; + } } } diff --git a/osu.Game.Rulesets.Karaoke/Utils/FontUtils.cs b/osu.Game.Rulesets.Karaoke/Utils/FontUtils.cs index 98feb8680..589bfa350 100644 --- a/osu.Game.Rulesets.Karaoke/Utils/FontUtils.cs +++ b/osu.Game.Rulesets.Karaoke/Utils/FontUtils.cs @@ -17,17 +17,8 @@ public static class FontUtils public static float[] DefaultFontSize() => new float[] { 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72 }; - public static float[] DefaultFontSize(float? minSize = null, float? maxSize = null) - => DefaultFontSize().Where(x => - { - if (minSize.HasValue && x < minSize.Value) - return false; - - if (maxSize.HasValue && x > maxSize.Value) - return false; - - return true; - }).ToArray(); + public static float[] DefaultFontSize(float minSize, float maxSize) + => DefaultFontSize().Where(x => x >= minSize && x <= maxSize).ToArray(); /// /// For selecting preview size in editor.