From d1f95f1a118b90c366763205d677e82b0b9fd6fc Mon Sep 17 00:00:00 2001 From: andy840119 Date: Mon, 19 Aug 2024 22:39:11 +0800 Subject: [PATCH 1/5] Remove unnsed injection. --- .../Beatmaps/Lyrics/Content/Compose/Toolbar/ToolbarButton.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/ToolbarButton.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/ToolbarButton.cs index 673fa3d1c..d15ffe301 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/ToolbarButton.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Compose/Toolbar/ToolbarButton.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Textures; using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Graphics.Containers; @@ -17,9 +16,6 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Compose /// public abstract partial class ToolbarButton : OsuClickableContainer { - [Resolved] - private TextureStore textures { get; set; } = null!; - [Resolved] private OsuColour colours { get; set; } = null!; From 888463659b9d2e4575c08908c835590e33179c9b Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 16 Aug 2024 00:32:13 +0800 Subject: [PATCH 2/5] Implement the drag feature. --- .../Lyrics/Content/Compose/LyricEditor.cs | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) 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 63581996a..8d19f8ca3 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 @@ -5,6 +5,8 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Input.Events; using osu.Game.Rulesets.Karaoke.Configuration; using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Components.Lyrics; @@ -20,20 +22,20 @@ public partial class LyricEditor : CompositeDrawable private readonly IBindable bindableFontSize = new Bindable(); private readonly LyricEditorSkin skin; - private readonly SkinProvidingContainer skinProvidingContainer; + private readonly DragContainer dragContainer; public LyricEditor() { RelativeSizeAxes = Axes.Both; - InternalChild = skinProvidingContainer = new SkinProvidingContainer(skin = new LyricEditorSkin(null)) + InternalChild = new SkinProvidingContainer(skin = new LyricEditorSkin(null)) { - Padding = new MarginPadding + RelativeSizeAxes = Axes.Both, + Child = dragContainer = new DragContainer { - Vertical = 64, - Horizontal = 120, + Position = new Vector2(64, 120), + AutoSizeAxes = Axes.Both, }, - RelativeSizeAxes = Axes.Both, }; bindableFocusedLyric.BindValueChanged(e => @@ -50,17 +52,15 @@ public LyricEditor() private void refreshPreviewLyric(Lyric? lyric) { - skinProvidingContainer.Clear(); + dragContainer.Clear(); if (lyric == null) return; const int border = 36; - skinProvidingContainer.Add(new InteractableLyric(lyric) + dragContainer.Add(new InteractableLyric(lyric) { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, TextSizeChanged = (self, size) => { self.Width = size.X + border * 2; @@ -97,4 +97,22 @@ private void load(ILyricCaretState lyricCaretState, KaraokeRulesetLyricEditorCon lyricEditorConfigManager.BindWith(KaraokeRulesetLyricEditorSetting.FontSizeInComposer, bindableFontSize); } + + private partial class DragContainer : Container + { + protected override bool OnDragStart(DragStartEvent e) => true; + + public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) + { + // only receive input only if outside the content + return !ScreenSpaceDrawQuad.AABBFloat.Contains(screenSpacePos); + } + + protected override bool ComputeIsMaskedAway(RectangleF maskingBounds) => false; + + protected override void OnDrag(DragEvent e) + { + Position += e.Delta; + } + } } From 222e0d8fe631febfc74aa78380870003ff6639e0 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 16 Aug 2024 00:32:50 +0800 Subject: [PATCH 3/5] Maybe should be better to drag only if press the alt button? --- .../Edit/Beatmaps/Lyrics/Content/Compose/LyricEditor.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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 8d19f8ca3..f0caee99a 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 @@ -102,16 +102,15 @@ private partial class DragContainer : Container { protected override bool OnDragStart(DragStartEvent e) => true; - public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) - { - // only receive input only if outside the content - return !ScreenSpaceDrawQuad.AABBFloat.Contains(screenSpacePos); - } + public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; protected override bool ComputeIsMaskedAway(RectangleF maskingBounds) => false; protected override void OnDrag(DragEvent e) { + if (!e.AltPressed) + return; + Position += e.Delta; } } From 78d2a69414f130e5f9916a3e065a7d2102724032 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 16 Aug 2024 21:35:57 +0800 Subject: [PATCH 4/5] Able to scroll the mouse wheel to change the font size. --- .../Lyrics/Content/Compose/LyricEditor.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) 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 f0caee99a..586a03fb5 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 @@ -6,6 +6,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; +using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; using osu.Game.Rulesets.Karaoke.Configuration; using osu.Game.Rulesets.Karaoke.Objects; @@ -113,5 +114,25 @@ protected override void OnDrag(DragEvent e) Position += e.Delta; } + + protected override bool OnScroll(ScrollEvent e) + { + if (!e.AltPressed) + return false; + + var triggerKey = e.ScrollDelta.Y > 0 ? KaraokeEditAction.DecreasePreviewFontSize : KaraokeEditAction.IncreasePreviewFontSize; + return trigger(triggerKey); + + bool trigger(KaraokeEditAction action) + { + var inputManager = this.FindClosestParent>(); + if (inputManager == null) + return false; + + inputManager.TriggerPressed(action); + inputManager.TriggerReleased(action); + return true; + } + } } } From ff0c65b2590c375c07596b770e3c40b2f4549549 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Mon, 19 Aug 2024 23:26:02 +0800 Subject: [PATCH 5/5] Add the damn hint button. --- .../Lyrics/Content/Compose/LyricEditor.cs | 139 +++++++++++++++++- 1 file changed, 136 insertions(+), 3 deletions(-) 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 586a03fb5..c0a296640 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 @@ -1,19 +1,34 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; using osu.Framework.Allocation; +using osu.Framework.Audio; using osu.Framework.Bindables; +using osu.Framework.Extensions; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.UserInterface; +using osu.Game.Graphics.UserInterfaceV2; +using osu.Game.Overlays; using osu.Game.Rulesets.Karaoke.Configuration; using osu.Game.Rulesets.Karaoke.Objects; 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.Rulesets.Karaoke.Screens.Edit.Components.Markdown; using osu.Game.Skinning; using osuTK; +using osuTK.Graphics; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Compose; @@ -32,10 +47,21 @@ public LyricEditor() InternalChild = new SkinProvidingContainer(skin = new LyricEditorSkin(null)) { RelativeSizeAxes = Axes.Both, - Child = dragContainer = new DragContainer + Children = new Drawable[] { - Position = new Vector2(64, 120), - AutoSizeAxes = Axes.Both, + dragContainer = new DragContainer + { + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, + new ScrollBackButton + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Size = new Vector2(40), + Margin = new MarginPadding(20), + }, }, }; @@ -135,4 +161,111 @@ bool trigger(KaraokeEditAction action) } } } + + public partial class ScrollBackButton : OsuHoverContainer, IHasPopover + { + private const int fade_duration = 500; + + private Visibility state; + + public Visibility State + { + get => state; + set + { + if (value == state) + return; + + state = value; + Enabled.Value = state == Visibility.Visible; + this.FadeTo(state == Visibility.Visible ? 1 : 0, fade_duration, Easing.OutQuint); + } + } + + protected override IEnumerable EffectTargets => new[] { background }; + + private Color4 flashColour; + + private readonly Container content; + private readonly Box background; + private readonly SpriteIcon spriteIcon; + + protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new(); + + public ScrollBackButton() + { + Add(content = new CircularContainer + { + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Masking = true, + EdgeEffect = new EdgeEffectParameters + { + Type = EdgeEffectType.Shadow, + Offset = new Vector2(0f, 1f), + Radius = 3f, + Colour = Color4.Black.Opacity(0.25f), + }, + Children = new Drawable[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both, + }, + spriteIcon = new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(15), + Icon = FontAwesome.Solid.Lightbulb, + }, + }, + }); + + TooltipText = "Hover to see the tutorial"; + } + + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider, AudioManager audio) + { + IdleColour = colourProvider.Background6; + HoverColour = colourProvider.Background5; + flashColour = colourProvider.Light1; + } + + protected override bool OnClick(ClickEvent e) + { + background.FlashColour(flashColour, 800, Easing.OutQuint); + + this.ShowPopover(); + return base.OnClick(e); + } + + protected override bool OnHover(HoverEvent e) + { + content.ScaleTo(1.1f, 2000, Easing.OutQuint); + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + content.ScaleTo(1, 1000, Easing.OutElastic); + base.OnHoverLost(e); + } + + public Popover? GetPopover() => new DescriptionPopover(); + + private partial class DescriptionPopover : OsuPopover + { + public DescriptionPopover() + { + Child = new DescriptionTextFlowContainer + { + Size = new Vector2(200, 100), + Description = "Press `alt` and `drag the compose area` or `scroll the mouse wheel` can move the lyric position or change the font size.", + }; + } + } + } }