From 866e34848f5f6c400742e8e19dd9a46fe3e61ddc Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 31 Oct 2020 17:04:59 +0900 Subject: [PATCH] Add preview note area. --- .../Edit/Style/LyricFontSection.cs | 2 +- .../Edit/Style/NoteColorSection.cs | 24 +++++ .../Edit/Style/NoteFontSection.cs | 26 +++++ .../Edit/Style/NoteStylePreview.cs | 98 +++++++++++++++++++ .../Edit/Style/StyleScreen.cs | 78 ++++++++++----- 5 files changed, 202 insertions(+), 26 deletions(-) create mode 100644 osu.Game.Rulesets.Karaoke/Edit/Style/NoteStylePreview.cs diff --git a/osu.Game.Rulesets.Karaoke/Edit/Style/LyricFontSection.cs b/osu.Game.Rulesets.Karaoke/Edit/Style/LyricFontSection.cs index 4edcb9b87..dbb141c7a 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Style/LyricFontSection.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Style/LyricFontSection.cs @@ -49,7 +49,7 @@ private void load(SkinManager manager) }, borderSliderBar = new LabelledRealTimeSliderBar { - Label = "Bold", + Label = "Border size", Description = "Adjust border size.", Current = new BindableInt { diff --git a/osu.Game.Rulesets.Karaoke/Edit/Style/NoteColorSection.cs b/osu.Game.Rulesets.Karaoke/Edit/Style/NoteColorSection.cs index 51119fad7..aebb8b6fc 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Style/NoteColorSection.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Style/NoteColorSection.cs @@ -1,10 +1,34 @@ // 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.Game.Rulesets.Karaoke.Graphics.UserInterface; +using osu.Game.Skinning; + namespace osu.Game.Rulesets.Karaoke.Edit.Style { internal class NoteColorSection : StyleSection { + private ColorPicker noteColorPicker; + private ColorPicker blinkColorPicker; + protected override string Title => "Color"; + + [BackgroundDependencyLoader] + private void load(SkinManager manager) + { + Children = new Drawable[] + { + noteColorPicker = new ColorPicker + { + RelativeSizeAxes = Axes.X, + }, + blinkColorPicker = new ColorPicker + { + RelativeSizeAxes = Axes.X, + } + }; + } } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Style/NoteFontSection.cs b/osu.Game.Rulesets.Karaoke/Edit/Style/NoteFontSection.cs index fbb32f58a..1fcf3cd1c 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Style/NoteFontSection.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Style/NoteFontSection.cs @@ -1,10 +1,36 @@ // 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.Game.Graphics.UserInterfaceV2; +using osu.Game.Rulesets.Karaoke.Graphics.UserInterface; +using osu.Game.Skinning; + namespace osu.Game.Rulesets.Karaoke.Edit.Style { internal class NoteFontSection : StyleSection { + private ColorPicker textColorPicker; + private LabelledSwitchButton boldSwitchButton; + protected override string Title => "Font"; + + [BackgroundDependencyLoader] + private void load(SkinManager manager) + { + Children = new Drawable[] + { + textColorPicker = new ColorPicker + { + RelativeSizeAxes = Axes.X, + }, + boldSwitchButton = new LabelledSwitchButton + { + Label = "Bold", + Description = "Select bold or not.", + } + }; + } } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Style/NoteStylePreview.cs b/osu.Game.Rulesets.Karaoke/Edit/Style/NoteStylePreview.cs new file mode 100644 index 000000000..c939e63bb --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Edit/Style/NoteStylePreview.cs @@ -0,0 +1,98 @@ +// 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.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Overlays; +using osu.Game.Rulesets.Karaoke.Configuration; +using osu.Game.Rulesets.Karaoke.UI; +using osu.Game.Rulesets.Karaoke.UI.Position; +using osu.Game.Rulesets.UI.Scrolling; +using osu.Game.Rulesets.UI.Scrolling.Algorithms; + +namespace osu.Game.Rulesets.Karaoke.Edit.Style +{ + public class NoteStylePreview : Container + { + private const int preview_column = 9; + + [Cached(Type = typeof(IScrollingInfo))] + private readonly PreviewScrollingInfo scrollingInfo = new PreviewScrollingInfo(); + + [Cached(Type = typeof(IPositionCalculator))] + private readonly PositionCalculator positionCalculator = new PositionCalculator(preview_column); + + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) + { + var configCache = parent.Get(); + var config = (KaraokeRulesetConfigManager)configCache.GetConfigFor(new KaraokeRuleset()); + var dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); + dependencies.Cache(new KaraokeSessionStatics(config, null)); + + return dependencies; + } + + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider, StyleManager manager) + { + Masking = true; + CornerRadius = 15; + FillMode = FillMode.Fit; + FillAspectRatio = 2f; + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colourProvider.Background1, + }, + new PreviewDrawableNoteArea + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre + } + }; + } + + public class PreviewDrawableNoteArea : NotePlayfield + { + public PreviewDrawableNoteArea() + : base(preview_column) + { + } + } + + public class PreviewScrollingInfo : IScrollingInfo + { + public IBindable Direction { get; } = new Bindable(); + + public IBindable TimeRange { get; } = new BindableDouble(); + + public IScrollAlgorithm Algorithm { get; set; } = new ZeroScrollAlgorithm(); + + private class ZeroScrollAlgorithm : IScrollAlgorithm + { + protected const double START_TIME = 1000000000; + + public double GetDisplayStartTime(double originTime, float offset, double timeRange, float scrollLength) + => double.MinValue; + + public float GetLength(double startTime, double endTime, double timeRange, float scrollLength) + => scrollLength; + + public float PositionAt(double time, double currentTime, double timeRange, float scrollLength) + => (float)((time - START_TIME) / timeRange) * scrollLength; + + public double TimeAt(float position, double currentTime, double timeRange, float scrollLength) + => 0; + + public void Reset() + { + } + } + } + } +} diff --git a/osu.Game.Rulesets.Karaoke/Edit/Style/StyleScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/Style/StyleScreen.cs index 1a6ba7945..408de0674 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Style/StyleScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Style/StyleScreen.cs @@ -22,6 +22,9 @@ public class StyleScreen : EditorScreen [Cached] protected readonly StyleManager StyleManager; + private StyleSectionsContainer styleSections; + private Container previewContainer; + public StyleScreen() : base(EditorScreenMode.SongSetup) { @@ -58,60 +61,85 @@ private void load() Colour = ColourProvider.Background2, RelativeSizeAxes = Axes.Both, }, - new StyleSectionsContainer + styleSections = new StyleSectionsContainer { RelativeSizeAxes = Axes.Both, } } }, - new LyricStylePreview + previewContainer = new Container { - Name = "Layout preview area", + RelativeSizeAxes = Axes.Both, + } + } + }, + }; + + styleSections.BindableStyle.BindValueChanged(e => + { + switch (e.NewValue) + { + case Style.Lyric: + previewContainer.Child = new LyricStylePreview + { + Name = "Lyric style preview area", Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(0.95f), RelativeSizeAxes = Axes.Both - }, - } - }, - }; + }; + break; + + case Style.Note: + previewContainer.Child = new NoteStylePreview + { + Name = "Note style preview area", + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(0.95f), + RelativeSizeAxes = Axes.Both + }; + break; + }; + }, true); } internal class StyleSectionsContainer : SectionsContainer { + private readonly StyleScreenHeader header; + private const float section_scale = 0.75f; + public IBindable