diff --git a/osu.Game.Rulesets.Karaoke.Architectures/Extensions.cs b/osu.Game.Rulesets.Karaoke.Architectures/Extensions.cs index aa6eee30b..3fb33f4c2 100644 --- a/osu.Game.Rulesets.Karaoke.Architectures/Extensions.cs +++ b/osu.Game.Rulesets.Karaoke.Architectures/Extensions.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Text.RegularExpressions; using ArchUnitNET.Domain; -using ArchUnitNET.Domain.Dependencies; using ArchUnitNET.Domain.Extensions; using NUnit.Framework; using osu.Game.Rulesets.Karaoke.Tests; diff --git a/osu.Game.Rulesets.Karaoke.Architectures/TestTestClass.cs b/osu.Game.Rulesets.Karaoke.Architectures/TestTestClass.cs index c05cc284a..38a1fc03f 100644 --- a/osu.Game.Rulesets.Karaoke.Architectures/TestTestClass.cs +++ b/osu.Game.Rulesets.Karaoke.Architectures/TestTestClass.cs @@ -7,7 +7,6 @@ using ArchUnitNET.Domain.Extensions; using NUnit.Framework; using osu.Framework.Testing; -using osu.Game.Rulesets.Karaoke.Tests; using osu.Game.Tests.Visual; namespace osu.Game.Rulesets.Karaoke.Architectures; diff --git a/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/Content/TestScenePreviewKaraokeSpriteText.cs b/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/Content/TestScenePreviewKaraokeSpriteText.cs index e6e1ccb36..6c97fa4b7 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/Content/TestScenePreviewKaraokeSpriteText.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/Content/TestScenePreviewKaraokeSpriteText.cs @@ -57,7 +57,10 @@ private void load(OsuColour colour) RelativeSizeAxes = Axes.Both, Colour = colour.BlueDarker, }, - karaokeSpriteText = new PreviewKaraokeSpriteText(lyric), + karaokeSpriteText = new PreviewKaraokeSpriteText(lyric) + { + Position = new Vector2(24, 8), + }, mask = new Container { Masking = true, diff --git a/osu.Game.Rulesets.Karaoke/Objects/Utils/LyricUtils.cs b/osu.Game.Rulesets.Karaoke/Objects/Utils/LyricUtils.cs index 31e7f08eb..838fa797a 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Utils/LyricUtils.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Utils/LyricUtils.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Extensions; using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; -using osu.Game.Rulesets.Karaoke.Objects.Types; using osu.Game.Rulesets.Karaoke.Utils; namespace osu.Game.Rulesets.Karaoke.Objects.Utils; diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/CaretPosition/Algorithms/CreateRemoveTimeTagCaretPositionAlgorithm.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/CaretPosition/Algorithms/CreateRemoveTimeTagCaretPositionAlgorithm.cs index cb095c08e..c4751c993 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/CaretPosition/Algorithms/CreateRemoveTimeTagCaretPositionAlgorithm.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/CaretPosition/Algorithms/CreateRemoveTimeTagCaretPositionAlgorithm.cs @@ -1,7 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets.Karaoke.Objects; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.CaretPosition.Algorithms; diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/GridLayer.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/GridLayer.cs new file mode 100644 index 000000000..b3873c1ae --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/GridLayer.cs @@ -0,0 +1,65 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics; +using osu.Game.Rulesets.Karaoke.Objects; +using osu.Game.Screens.Edit.Compose.Components; +using osuTK; + +namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Components.Lyrics; + +public partial class GridLayer : Layer +{ + private readonly RectangularPositionSnapGrid rectangularPositionSnapGrid; + + public GridLayer(Lyric lyric) + : base(lyric) + { + InternalChild = rectangularPositionSnapGrid = new RectangularPositionSnapGrid + { + RelativeSizeAxes = Axes.Both, + }; + } + + public int Spacing + { + get => rectangularPositionSnapGrid.Spacing; + set => rectangularPositionSnapGrid.Spacing = value; + } + + public override void UpdateDisableEditState(bool editable) + { + this.FadeTo(editable ? 1 : 0.5f, 100); + } + + private partial class RectangularPositionSnapGrid : LinedPositionSnapGrid + { + protected override void CreateContent() + { + GenerateGridLines(new Vector2(0, -Spacing), DrawSize); + GenerateGridLines(new Vector2(0, Spacing), DrawSize); + + GenerateGridLines(new Vector2(-Spacing, 0), DrawSize); + GenerateGridLines(new Vector2(Spacing, 0), DrawSize); + + GenerateOutline(DrawSize); + } + + public override Vector2 GetSnappedPosition(Vector2 original) + { + return StartPosition.Value + original; + } + + private int spacing; + + public int Spacing + { + get => spacing; + set + { + spacing = value; + GridCache.Invalidate(); + } + } + } +} diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/InteractableLyric.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/InteractableLyric.cs index d3bdb2aaa..ac6086c92 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/InteractableLyric.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/InteractableLyric.cs @@ -13,6 +13,7 @@ using osu.Game.Rulesets.Karaoke.Edit.Utils; using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Screens.Edit; +using osuTK; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Components.Lyrics; @@ -28,6 +29,8 @@ public sealed partial class InteractableLyric : CompositeDrawable, IHasTooltip, private readonly Lyric lyric; private LocalisableString? lockReason; + public Action? TextSizeChanged = null; + public InteractableLyric(Lyric lyric) { this.lyric = lyric; @@ -36,9 +39,9 @@ public InteractableLyric(Lyric lyric) karaokeSpriteText = new PreviewKaraokeSpriteText(lyric); - karaokeSpriteText.SizeChanged = () => + karaokeSpriteText.SizeChanged = (size) => { - Height = karaokeSpriteText.DrawHeight; + TextSizeChanged?.Invoke(this, size); }; bindableMode.BindValueChanged(x => @@ -65,6 +68,12 @@ public IEnumerable Layers } } + public Vector2 LyricPosition + { + get => karaokeSpriteText.Position; + set => karaokeSpriteText.Position = value; + } + public void TriggerDisallowEditEffect() { InternalChildren.OfType().ForEach(x => x.TriggerDisallowEditEffect(bindableMode.Value)); @@ -108,14 +117,14 @@ private void triggerWritableVersionChanged() return mode switch { LyricEditorMode.View => null, - LyricEditorMode.EditText => HitObjectWritableUtils.GetLyricPropertyLockedBy(lyric, nameof(Objects.Lyric.Text), nameof(Objects.Lyric.RubyTags), nameof(Objects.Lyric.TimeTags)), - LyricEditorMode.EditReferenceLyric => HitObjectWritableUtils.GetLyricPropertyLockedBy(lyric, nameof(Objects.Lyric.ReferenceLyric), nameof(Objects.Lyric.ReferenceLyricConfig)), - LyricEditorMode.EditLanguage => HitObjectWritableUtils.GetLyricPropertyLockedBy(lyric, nameof(Objects.Lyric.Language)), - LyricEditorMode.EditRuby => HitObjectWritableUtils.GetLyricPropertyLockedBy(lyric, nameof(Objects.Lyric.RubyTags)), - LyricEditorMode.EditTimeTag => HitObjectWritableUtils.GetLyricPropertyLockedBy(lyric, nameof(Objects.Lyric.TimeTags)), - LyricEditorMode.EditRomanisation => HitObjectWritableUtils.GetLyricPropertyLockedBy(lyric, nameof(Objects.Lyric.TimeTags)), + LyricEditorMode.EditText => HitObjectWritableUtils.GetLyricPropertyLockedBy(lyric, nameof(Lyric.Text), nameof(Lyric.RubyTags), nameof(Lyric.TimeTags)), + LyricEditorMode.EditReferenceLyric => HitObjectWritableUtils.GetLyricPropertyLockedBy(lyric, nameof(Lyric.ReferenceLyric), nameof(Lyric.ReferenceLyricConfig)), + LyricEditorMode.EditLanguage => HitObjectWritableUtils.GetLyricPropertyLockedBy(lyric, nameof(Lyric.Language)), + LyricEditorMode.EditRuby => HitObjectWritableUtils.GetLyricPropertyLockedBy(lyric, nameof(Lyric.RubyTags)), + LyricEditorMode.EditTimeTag => HitObjectWritableUtils.GetLyricPropertyLockedBy(lyric, nameof(Lyric.TimeTags)), + LyricEditorMode.EditRomanisation => HitObjectWritableUtils.GetLyricPropertyLockedBy(lyric, nameof(Lyric.TimeTags)), LyricEditorMode.EditNote => HitObjectWritableUtils.GetCreateOrRemoveNoteLockedBy(lyric), - LyricEditorMode.EditSinger => HitObjectWritableUtils.GetLyricPropertyLockedBy(lyric, nameof(Objects.Lyric.SingerIds)), + LyricEditorMode.EditSinger => HitObjectWritableUtils.GetLyricPropertyLockedBy(lyric, nameof(Lyric.SingerIds)), _ => throw new ArgumentOutOfRangeException(nameof(mode), mode, null), }; } diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/PreviewKaraokeSpriteText.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/PreviewKaraokeSpriteText.cs index c3ee4eff0..248f1d554 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/PreviewKaraokeSpriteText.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/PreviewKaraokeSpriteText.cs @@ -26,7 +26,7 @@ public partial class PreviewKaraokeSpriteText : DrawableKaraokeSpriteText? SizeChanged; private readonly EditorLyricSpriteText spriteText; @@ -59,13 +59,16 @@ private void triggerSizeChangedEvent() { ScheduleAfterChildren(() => { - SizeChanged?.Invoke(); + SizeChanged?.Invoke(DrawSize); }); } #region Text char index public int? GetCharIndexByPosition(float position) + => getCharIndexByPosition(position - Position.X); + + private int? getCharIndexByPosition(float position) { for (int i = 0; i < Text.Length; i++) { @@ -84,6 +87,9 @@ Tuple getTriggerPositionByTimeIndex(int charIndex) } public RectangleF GetRectByCharIndex(int charIndex) + => getRectByCharIndex(charIndex).Offset(Position); + + private RectangleF getRectByCharIndex(int charIndex) { if (charIndex < 0 || charIndex >= Text.Length) throw new ArgumentOutOfRangeException(nameof(charIndex)); @@ -96,6 +102,9 @@ public RectangleF GetRectByCharIndex(int charIndex) #region Text indicator public int GetCharIndicatorByPosition(float position) + => getCharIndicatorByPosition(position - Position.X); + + private int getCharIndicatorByPosition(float position) { for (int i = 0; i < Text.Length; i++) { @@ -114,6 +123,9 @@ float getTriggerPositionByTimeIndex(int charIndex) } public RectangleF GetRectByCharIndicator(int charIndex) + => getRectByCharIndicator(charIndex).Offset(Position); + + private RectangleF getRectByCharIndicator(int charIndex) { if (charIndex < 0 || charIndex > Text.Length) throw new ArgumentOutOfRangeException(nameof(charIndex)); @@ -142,6 +154,9 @@ public RectangleF GetRectByCharIndicator(int charIndex) #region Ruby tag public RectangleF? GetRubyTagByPosition(RubyTag rubyTag) => + getRubyTagByPosition(rubyTag)?.Offset(Position); + + private RectangleF? getRubyTagByPosition(RubyTag rubyTag) => spriteText.GetRubyTagPosition(rubyTag); #endregion @@ -149,6 +164,9 @@ public RectangleF GetRectByCharIndicator(int charIndex) #region Time tag public TimeTag? GetTimeTagByPosition(float position) + => getTimeTagByPosition(position - Position.X); + + private TimeTag? getTimeTagByPosition(float position) { var hoverIndex = getHoverIndex(); if (hoverIndex == null) @@ -184,6 +202,9 @@ Tuple getTriggerRange(TextIndex textIndex) } public Vector2 GetPositionByTimeTag(TimeTag timeTag) + => getPositionByTimeTag(timeTag) + Position; + + private Vector2 getPositionByTimeTag(TimeTag timeTag) { var basePosition = spriteText.GetTimeTagPosition(timeTag.Index); float extraPosition = extraSpacing(HitObject.TimeTags, timeTag); diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/EditLyricDetailRow.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/EditLyricDetailRow.cs index 29c7cd886..fde045263 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/EditLyricDetailRow.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/EditLyricDetailRow.cs @@ -33,6 +33,10 @@ protected override Drawable CreateContent(Lyric lyric) Origin = Anchor.BottomLeft, Margin = new MarginPadding { Left = 10 }, RelativeSizeAxes = Axes.X, + TextSizeChanged = (self, size) => + { + self.Height = size.Y; + }, Layers = new Layer[] { new LyricLayer(lyric), diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/LyricEditor.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/LyricEditor.cs index a00700063..f32df6bf3 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/LyricEditor.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/LyricEditor.cs @@ -10,6 +10,7 @@ using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Components.Lyrics; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States; using osu.Game.Skinning; +using osuTK; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Compose; @@ -39,12 +40,24 @@ public LyricEditor() if (lyric == null) return; + const int border = 36; + skinProvidingContainer.Add(new InteractableLyric(lyric) { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, + LyricPosition = new Vector2(border), + TextSizeChanged = (self, size) => + { + self.Width = size.X + border * 2; + self.Height = size.Y + border * 2; + }, Layers = new Layer[] { + new GridLayer(lyric) + { + Spacing = 10, + }, new LyricLayer(lyric), new EditLyricLayer(lyric), new TimeTagLayer(lyric), diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/List/EditLyricPreviewRow.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/List/EditLyricPreviewRow.cs index 1ef287939..cf1f7aa5d 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/List/EditLyricPreviewRow.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/List/EditLyricPreviewRow.cs @@ -32,6 +32,10 @@ protected override Drawable CreateContent(Lyric lyric) { Margin = new MarginPadding { Left = 10 }, RelativeSizeAxes = Axes.X, + TextSizeChanged = (self, size) => + { + self.Height = size.Y; + }, Layers = new Layer[] { new LyricLayer(lyric), diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/GenericEditor.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/GenericEditor.cs index b6bd3ed8f..654f9b531 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/GenericEditor.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/GenericEditor.cs @@ -8,7 +8,6 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; @@ -19,9 +18,7 @@ using osu.Game.Input.Bindings; using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.Menus; using osu.Game.Screens.Edit; -using osu.Game.Screens.Edit.Components; using osu.Game.Screens.Edit.Components.Menus; -using osu.Game.Screens.Edit.Components.Timelines.Summary; using osu.Game.Screens.Play; namespace osu.Game.Rulesets.Karaoke.Screens.Edit; diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Import/Lyrics/EditLyric/EditLyricNavigation.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Import/Lyrics/EditLyric/EditLyricNavigation.cs index b1f72dcf3..4a34e195b 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Import/Lyrics/EditLyric/EditLyricNavigation.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Import/Lyrics/EditLyric/EditLyricNavigation.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using System.ComponentModel; -using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Localisation; using osu.Game.Rulesets.Karaoke.Objects; diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Import/Lyrics/LyricImporterSubScreenStack.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Import/Lyrics/LyricImporterSubScreenStack.cs index af7fd6a9d..c04fb5006 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Import/Lyrics/LyricImporterSubScreenStack.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Import/Lyrics/LyricImporterSubScreenStack.cs @@ -1,10 +1,8 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -using System; using System.Collections.Generic; using System.Linq; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Screens; using osu.Game.Rulesets.Karaoke.Screens.Edit.Import.Lyrics.AssignLanguage; using osu.Game.Rulesets.Karaoke.Screens.Edit.Import.Lyrics.DragFile; diff --git a/osu.Game.Rulesets.Karaoke/UI/HUD/GeneralSettingOverlay.cs b/osu.Game.Rulesets.Karaoke/UI/HUD/GeneralSettingOverlay.cs index 7bcecec3e..305b4c668 100644 --- a/osu.Game.Rulesets.Karaoke/UI/HUD/GeneralSettingOverlay.cs +++ b/osu.Game.Rulesets.Karaoke/UI/HUD/GeneralSettingOverlay.cs @@ -6,10 +6,8 @@ using osu.Framework.Graphics; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; -using osu.Game.Beatmaps; using osu.Game.Input.Bindings; using osu.Game.Overlays; -using osu.Game.Rulesets.Karaoke.Beatmaps; using osu.Game.Rulesets.Karaoke.Configuration; using osu.Game.Rulesets.Karaoke.UI.PlayerSettings; using osu.Game.Screens.Play.PlayerSettings;