From fdfdda29f123c2a294ba290a584b3d3872d571b7 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 24 Oct 2020 17:25:06 +0900 Subject: [PATCH 1/4] Implement style preview. --- .../Edit/Style/StylePreview.cs | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Style/StylePreview.cs b/osu.Game.Rulesets.Karaoke/Edit/Style/StylePreview.cs index 9ef7a91be..d3e4f570a 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Style/StylePreview.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Style/StylePreview.cs @@ -1,11 +1,112 @@ // Copyright (c) andy840119 . 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.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Game.Overlays; +using osu.Game.Rulesets.Karaoke.Objects; +using osu.Game.Rulesets.Karaoke.Objects.Drawables; +using osu.Game.Rulesets.Karaoke.Skinning.Components; +using System.Collections.Generic; namespace osu.Game.Rulesets.Karaoke.Edit.Style { internal class StylePreview : Container { + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider, StyleManager manager) + { + Masking = true; + CornerRadius = 15; + FillMode = FillMode.Fit; + FillAspectRatio = 1.25f; + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colourProvider.Background1, + }, + new PreviewDrawableLyricLine(createDefaultLyricLine()) + }; + } + + private LyricLine createDefaultLyricLine() + { + var startTime = Time.Current; + const double duration = 1000000; + + return new LyricLine + { + StartTime = startTime, + Duration = duration, + Text = "カラオケ!", + TimeTags = new Dictionary + { + { new TimeTagIndex(0), startTime + 500 }, + { new TimeTagIndex(1), startTime + 600 }, + { new TimeTagIndex(2), startTime + 1000 }, + { new TimeTagIndex(3), startTime + 1500 }, + { new TimeTagIndex(4), startTime + 2000 }, + }, + RubyTags = new[] + { + new RubyTag + { + StartIndex = 0, + EndIndex = 1, + Text = "か" + }, + new RubyTag + { + StartIndex = 2, + EndIndex = 3, + Text = "お" + } + }, + RomajiTags = new[] + { + new RomajiTag + { + StartIndex = 1, + EndIndex = 2, + Text = "ra" + }, + new RomajiTag + { + StartIndex = 3, + EndIndex = 4, + Text = "ke" + } + } + }; + } + + public class PreviewDrawableLyricLine : DrawableLyricLine + { + private KaraokeFont style; + + public PreviewDrawableLyricLine(LyricLine hitObject) + : base(hitObject) + { + } + + /// + /// It's an tricky to force add style into here. + /// Should be removed eventually. + /// + public KaraokeFont PreviewStyle + { + get => style; + set + { + style = value; + ApplyFont(style); + } + } + } } } From de00bdf30c7bb95304bb61a25d0057e628964d7a Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 24 Oct 2020 17:25:29 +0900 Subject: [PATCH 2/4] Implement some part of style manager. --- .../Edit/Style/StyleManager.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Style/StyleManager.cs b/osu.Game.Rulesets.Karaoke/Edit/Style/StyleManager.cs index c77a04f5f..27d3730f2 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Style/StyleManager.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Style/StyleManager.cs @@ -1,11 +1,40 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; +using osu.Game.Rulesets.Karaoke.Skinning.Components; +using osu.Game.Skinning; +using System; namespace osu.Game.Rulesets.Karaoke.Edit.Style { public class StyleManager : Component { + public readonly Bindable EditStyle = new Bindable(); + + public readonly Bindable EditNoteStyle = new Bindable(); + + [Resolved] + private ISkinSource source { get; set; } + + [BackgroundDependencyLoader] + private void load() + { + + } + + public void ApplyCurrentStyleChange(Action action) + { + action?.Invoke(EditStyle.Value); + EditStyle.TriggerChange(); + } + + public void ApplyCurrentNoteStyle(Action action) + { + action?.Invoke(EditNoteStyle.Value); + EditNoteStyle.TriggerChange(); + } } } From 66ca76107137a94a11f28c49a7b6f849f2458edf Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 24 Oct 2020 17:29:06 +0900 Subject: [PATCH 3/4] Make code factor happy. --- osu.Game.Rulesets.Karaoke/Edit/Style/StyleManager.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Style/StyleManager.cs b/osu.Game.Rulesets.Karaoke/Edit/Style/StyleManager.cs index 27d3730f2..1773109c4 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Style/StyleManager.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Style/StyleManager.cs @@ -22,7 +22,6 @@ public class StyleManager : Component [BackgroundDependencyLoader] private void load() { - } public void ApplyCurrentStyleChange(Action action) From 049df8754a7115286433c3f94cd4207871b10ac0 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 25 Oct 2020 20:21:04 +0900 Subject: [PATCH 4/4] Fix compile error. --- osu.Game.Rulesets.Karaoke/Edit/Style/StylePreview.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Style/StylePreview.cs b/osu.Game.Rulesets.Karaoke/Edit/Style/StylePreview.cs index d3e4f570a..67ceb64ac 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Style/StylePreview.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Style/StylePreview.cs @@ -34,12 +34,12 @@ private void load(OverlayColourProvider colourProvider, StyleManager manager) }; } - private LyricLine createDefaultLyricLine() + private Lyric createDefaultLyricLine() { var startTime = Time.Current; const double duration = 1000000; - return new LyricLine + return new Lyric { StartTime = startTime, Duration = duration, @@ -85,12 +85,12 @@ private LyricLine createDefaultLyricLine() }; } - public class PreviewDrawableLyricLine : DrawableLyricLine + public class PreviewDrawableLyricLine : DrawableLyric { private KaraokeFont style; - public PreviewDrawableLyricLine(LyricLine hitObject) - : base(hitObject) + public PreviewDrawableLyricLine(Lyric hitObject) + : base(hitObject) { }