From a7779e4652570d5268a424d044f8055d1ad9fa7c Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 31 Oct 2020 19:24:43 +0900 Subject: [PATCH 01/10] Create initial file and test case. --- .../Edit/TestSceneSinger.cs | 228 ++---------------- .../Edit/Singer/SingerEditSection.cs | 11 + .../Edit/Singer/SingerManager.cs | 15 ++ .../Edit/Singer/SingerScreen.cs | 82 +++++++ 4 files changed, 123 insertions(+), 213 deletions(-) create mode 100644 osu.Game.Rulesets.Karaoke/Edit/Singer/SingerEditSection.cs create mode 100644 osu.Game.Rulesets.Karaoke/Edit/Singer/SingerManager.cs create mode 100644 osu.Game.Rulesets.Karaoke/Edit/Singer/SingerScreen.cs diff --git a/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs b/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs index c60642a57..32094b132 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs @@ -1,20 +1,13 @@ // 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 System.Linq; using NUnit.Framework; using osu.Framework.Allocation; -using osu.Framework.Bindables; -using osu.Framework.Extensions; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics; -using osu.Game.Graphics.Containers; -using osu.Game.Graphics.Sprites; -using osu.Game.Graphics.UserInterface; -using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; +using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Karaoke.Beatmaps; +using osu.Game.Rulesets.Karaoke.Edit.Singer; +using osu.Game.Rulesets.Karaoke.Tests.Beatmaps; +using osu.Game.Screens.Edit; using osu.Game.Tests.Visual; namespace osu.Game.Rulesets.Karaoke.Tests.Edit @@ -22,215 +15,24 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Edit [TestFixture] public class TestSceneSinger : OsuTestScene { - private readonly Box background; - private readonly SingerTableContainer singerTableContainer; - private readonly SingerInfoContainer singerInfoContainer; + [Cached(typeof(EditorBeatmap))] + [Cached(typeof(IBeatSnapProvider))] + private readonly EditorBeatmap editorBeatmap; public TestSceneSinger() { - Child = new Container - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Width = 700, - Height = 500, - Masking = true, - CornerRadius = 5, - Children = new Drawable[] - { - background = new Box - { - Name = "Background", - RelativeSizeAxes = Axes.Both - }, - new GridContainer - { - RelativeSizeAxes = Axes.Both, - ColumnDimensions = new[] - { - new Dimension(GridSizeMode.Absolute, 300) - }, - Content = new[] - { - new Drawable[] - { - new OsuScrollContainer - { - RelativeSizeAxes = Axes.Both, - Child = singerTableContainer = new SingerTableContainer() - }, - new OsuScrollContainer - { - RelativeSizeAxes = Axes.Both, - Child = singerInfoContainer = new SingerInfoContainer - { - RelativeSizeAxes = Axes.X - } - } - } - } - } - } - }; + var beatmap = new TestKaraokeBeatmap(null); + var karaokeBeatmap = new KaraokeBeatmapConverter(beatmap, new KaraokeRuleset()).Convert() as KaraokeBeatmap; + // todo : insert singers - // todo : add singer. - var singerMetadata = new SingerMetadata(); - singerTableContainer.Metadata = singerMetadata; - - singerTableContainer.BindableSinger.BindValueChanged(x => - { - // Update singer info - singerInfoContainer.Singer = x.NewValue; - }); + editorBeatmap = new EditorBeatmap(karaokeBeatmap); } [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - background.Colour = colours.Gray9; - } - - public class SingerTableContainer : TableContainer + private void load() { - private const float horizontal_inset = 20; - private const float row_height = 10; - - public Bindable BindableSinger { get; } = new Bindable(); - - private readonly FillFlowContainer backgroundFlow; - - public SingerTableContainer() - { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - - Padding = new MarginPadding { Horizontal = horizontal_inset }; - RowSize = new Dimension(GridSizeMode.AutoSize); - - AddInternal(backgroundFlow = new FillFlowContainer - { - RelativeSizeAxes = Axes.Both, - Depth = 1f, - Padding = new MarginPadding { Horizontal = -horizontal_inset }, - Margin = new MarginPadding { Top = row_height } - }); - } - - private SingerMetadata metadata; - - public SingerMetadata Metadata - { - get => metadata; - set - { - metadata = value; - - Content = null; - backgroundFlow.Clear(); - - var signer = Metadata.Singers; - if (signer?.Any() != true) - return; - - Columns = createHeaders(); - Content = signer.Select(s => createContent(s.ID, s)).ToArray().ToRectangular(); - - // All the singer is not selected - BindableSinger.Value = signer.FirstOrDefault(); - } - } - - private TableColumn[] createHeaders() - { - var columns = new List - { - new TableColumn("Selected", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 50)), - new TableColumn("Singer name", Anchor.Centre), - }; - - return columns.ToArray(); - } - - private Drawable[] createContent(int index, Singer singer) - { - return new Drawable[] - { - new OsuSpriteText - { - Text = $"# {index}" - }, - new OsuSpriteText - { - Text = singer.Name - }, - }; - } - } - - public class SingerInfoContainer : TableContainer - { - private readonly OsuTextBox nameTextBox; - private readonly OsuTextBox englishNameTextBox; - private readonly OsuTextBox romajiNameTextBox; - - public SingerInfoContainer() - { - AutoSizeAxes = Axes.Y; - RowSize = new Dimension(GridSizeMode.AutoSize); - Content = new Drawable[,] - { - { - new OsuSpriteText - { - Text = "Singer name :" - }, - nameTextBox = new OsuTextBox - { - RelativeSizeAxes = Axes.X, - } - }, - { - new OsuSpriteText - { - Text = "English name :" - }, - englishNameTextBox = new OsuTextBox - { - RelativeSizeAxes = Axes.X, - } - }, - { - new OsuSpriteText - { - Text = "Romaji name :" - }, - romajiNameTextBox = new OsuTextBox - { - RelativeSizeAxes = Axes.X, - } - }, - }; - - nameTextBox.Current.BindValueChanged(x => { Singer.Name = x.NewValue; }); - - englishNameTextBox.Current.BindValueChanged(x => { Singer.EnglishName = x.NewValue; }); - - romajiNameTextBox.Current.BindValueChanged(x => { Singer.RomajiName = x.NewValue; }); - } - - private Singer singer; - - public Singer Singer - { - get => singer; - set - { - singer = value; - nameTextBox.Text = singer.Name; - englishNameTextBox.Text = singer.EnglishName; - romajiNameTextBox.Text = singer.RomajiName; - } - } + Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap); + Child = new SingerScreen(); } } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singer/SingerEditSection.cs b/osu.Game.Rulesets.Karaoke/Edit/Singer/SingerEditSection.cs new file mode 100644 index 000000000..5af3d6484 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Edit/Singer/SingerEditSection.cs @@ -0,0 +1,11 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics.Containers; + +namespace osu.Game.Rulesets.Karaoke.Edit.Singer +{ + public class SingerEditSection : Container + { + } +} diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singer/SingerManager.cs b/osu.Game.Rulesets.Karaoke/Edit/Singer/SingerManager.cs new file mode 100644 index 000000000..88b6247a5 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Edit/Singer/SingerManager.cs @@ -0,0 +1,15 @@ +// 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.Screens.Edit; + +namespace osu.Game.Rulesets.Karaoke.Edit.Singer +{ + public class SingerManager : Component + { + [Resolved] + private EditorBeatmap beatmap { get; set; } + } +} diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singer/SingerScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/Singer/SingerScreen.cs new file mode 100644 index 000000000..4531228ed --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Edit/Singer/SingerScreen.cs @@ -0,0 +1,82 @@ +// 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.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Overlays; +using osu.Game.Screens.Edit; + +namespace osu.Game.Rulesets.Karaoke.Edit.Singer +{ + public class SingerScreen : EditorScreen + { + [Cached] + protected readonly OverlayColourProvider ColourProvider; + + [Cached] + protected readonly SingerManager SingerManager; + + public SingerScreen() + : base(EditorScreenMode.SongSetup) + { + ColourProvider = new OverlayColourProvider(OverlayColourScheme.Purple); + Content.Add(SingerManager = new SingerManager()); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Child = new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding(50), + Child = new Container + { + RelativeSizeAxes = Axes.Both, + Masking = true, + CornerRadius = 10, + Children = new Drawable[] + { + new Box + { + Colour = colours.GreySeafoamDark, + RelativeSizeAxes = Axes.Both, + }, + new SectionsContainer + { + FixedHeader = new SingerScreenHeader(), + RelativeSizeAxes = Axes.Both, + Children = new Container[] + { + new SingerEditSection() + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + }, + } + }, + } + } + }; + } + + internal class SingerScreenHeader : OverlayHeader + { + protected override OverlayTitle CreateTitle() => new TranslateScreenTitle(); + + private class TranslateScreenTitle : OverlayTitle + { + public TranslateScreenTitle() + { + Title = "singer"; + Description = "create singer of your beatmap"; + IconTexture = "Icons/Hexacons/social"; + } + } + } + } +} From c0b3b2e2ca77b5161d48d83222ad0b84e6b0fa5b Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 1 Nov 2020 11:57:35 +0900 Subject: [PATCH 02/10] Singer -> Singers Also implement base rearrangeable list contaner. --- .../Edit/TestSceneSinger.cs | 2 +- .../Edit/Singer/SingerEditSection.cs | 11 ---- .../Edit/Singers/SingerEditSection.cs | 52 ++++++++++++++++++ .../Edit/{Singer => Singers}/SingerManager.cs | 2 +- .../SingerRearrangeableListContainer.cs | 54 +++++++++++++++++++ .../Edit/{Singer => Singers}/SingerScreen.cs | 28 +++++++--- 6 files changed, 130 insertions(+), 19 deletions(-) delete mode 100644 osu.Game.Rulesets.Karaoke/Edit/Singer/SingerEditSection.cs create mode 100644 osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs rename osu.Game.Rulesets.Karaoke/Edit/{Singer => Singers}/SingerManager.cs (88%) create mode 100644 osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs rename osu.Game.Rulesets.Karaoke/Edit/{Singer => Singers}/SingerScreen.cs (74%) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs b/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs index 32094b132..18148f451 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs @@ -5,7 +5,7 @@ using osu.Framework.Allocation; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Karaoke.Beatmaps; -using osu.Game.Rulesets.Karaoke.Edit.Singer; +using osu.Game.Rulesets.Karaoke.Edit.Singers; using osu.Game.Rulesets.Karaoke.Tests.Beatmaps; using osu.Game.Screens.Edit; using osu.Game.Tests.Visual; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singer/SingerEditSection.cs b/osu.Game.Rulesets.Karaoke/Edit/Singer/SingerEditSection.cs deleted file mode 100644 index 5af3d6484..000000000 --- a/osu.Game.Rulesets.Karaoke/Edit/Singer/SingerEditSection.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. - -using osu.Framework.Graphics.Containers; - -namespace osu.Game.Rulesets.Karaoke.Edit.Singer -{ - public class SingerEditSection : Container - { - } -} diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs new file mode 100644 index 000000000..946bc4a6c --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs @@ -0,0 +1,52 @@ +// 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.Game.Rulesets.Karaoke.Beatmaps.Metadatas; + +namespace osu.Game.Rulesets.Karaoke.Edit.Singers +{ + public class SingerEditSection : CompositeDrawable + { + private SingerRearrangeableListContainer singerContainers; + + [BackgroundDependencyLoader] + private void load() + { + InternalChild = new GridContainer + { + RelativeSizeAxes = Axes.Both, + RowDimensions = new[] + { + new Dimension(GridSizeMode.Absolute, 100), + new Dimension() + }, + Content = new Drawable[][] + { + new Drawable[] + { + new Container + { + Name = "Default", + RelativeSizeAxes = Axes.Both, + } + }, + new Drawable[] + { + singerContainers = new SingerRearrangeableListContainer + { + Name = "List of singer", + RelativeSizeAxes = Axes.Both, + } + } + } + }; + + singerContainers.Items.Add(new Singer(0)); + singerContainers.Items.Add(new Singer(1)); + singerContainers.Items.Add(new Singer(2)); + } + } +} diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singer/SingerManager.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerManager.cs similarity index 88% rename from osu.Game.Rulesets.Karaoke/Edit/Singer/SingerManager.cs rename to osu.Game.Rulesets.Karaoke/Edit/Singers/SingerManager.cs index 88b6247a5..54923f00a 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singer/SingerManager.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerManager.cs @@ -5,7 +5,7 @@ using osu.Framework.Graphics; using osu.Game.Screens.Edit; -namespace osu.Game.Rulesets.Karaoke.Edit.Singer +namespace osu.Game.Rulesets.Karaoke.Edit.Singers { public class SingerManager : Component { diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs new file mode 100644 index 000000000..68dd4a77a --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs @@ -0,0 +1,54 @@ +// 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.Game.Graphics.Containers; +using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; +using osu.Game.Overlays; + +namespace osu.Game.Rulesets.Karaoke.Edit.Singers +{ + public class SingerRearrangeableListContainer : OsuRearrangeableListContainer + { + protected override OsuRearrangeableListItem CreateOsuDrawable(Singer item) + => new SingerRearrangeableListItem(item); + + public class SingerRearrangeableListItem : OsuRearrangeableListItem + { + private Box background; + + public SingerRearrangeableListItem(Singer item) + : base(item) + { + } + + protected override Drawable CreateContent() + { + return new Container + { + Masking = true, + CornerRadius = 5, + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Children = new Drawable[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0.3f + }, + } + }; + } + + [BackgroundDependencyLoader] + private void load(OverlayColourProvider privider) + { + background.Colour = privider.Content1; + } + } + } +} diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singer/SingerScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerScreen.cs similarity index 74% rename from osu.Game.Rulesets.Karaoke/Edit/Singer/SingerScreen.cs rename to osu.Game.Rulesets.Karaoke/Edit/Singers/SingerScreen.cs index 4531228ed..993c70fe7 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singer/SingerScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerScreen.cs @@ -10,7 +10,7 @@ using osu.Game.Overlays; using osu.Game.Screens.Edit; -namespace osu.Game.Rulesets.Karaoke.Edit.Singer +namespace osu.Game.Rulesets.Karaoke.Edit.Singers { public class SingerScreen : EditorScreen { @@ -46,16 +46,15 @@ private void load(OsuColour colours) Colour = colours.GreySeafoamDark, RelativeSizeAxes = Axes.Both, }, - new SectionsContainer + new FixedSectionsContainer { FixedHeader = new SingerScreenHeader(), RelativeSizeAxes = Axes.Both, - Children = new Container[] + Children = new [] { - new SingerEditSection() + new SingerEditSection { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.Both, }, } }, @@ -64,6 +63,23 @@ private void load(OsuColour colours) }; } + internal class FixedSectionsContainer : SectionsContainer where T : Drawable + { + private readonly Container content; + + protected override Container Content => content; + + public FixedSectionsContainer() + { + AddInternal(content = new Container + { + Masking = true, + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = 55 } + }); + } + } + internal class SingerScreenHeader : OverlayHeader { protected override OverlayTitle CreateTitle() => new TranslateScreenTitle(); From 9115a53079f874c3c95e4a44cb464438162fea9b Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 1 Nov 2020 13:11:12 +0900 Subject: [PATCH 03/10] Implement base singer component. --- .../Edit/TestSceneSinger.cs | 20 ++++- .../Edit/Singers/SingerContent.cs | 90 +++++++++++++++++++ .../Edit/Singers/SingerEditSection.cs | 2 +- .../SingerRearrangeableListContainer.cs | 41 +++++++-- 4 files changed, 144 insertions(+), 9 deletions(-) create mode 100644 osu.Game.Rulesets.Karaoke/Edit/Singers/SingerContent.cs diff --git a/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs b/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs index 18148f451..bfd1ce1c8 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs @@ -3,6 +3,8 @@ using NUnit.Framework; using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Karaoke.Beatmaps; using osu.Game.Rulesets.Karaoke.Edit.Singers; @@ -19,6 +21,8 @@ public class TestSceneSinger : OsuTestScene [Cached(typeof(IBeatSnapProvider))] private readonly EditorBeatmap editorBeatmap; + protected override Container Content { get; } = new Container { RelativeSizeAxes = Axes.Both }; + public TestSceneSinger() { var beatmap = new TestKaraokeBeatmap(null); @@ -32,7 +36,21 @@ public TestSceneSinger() private void load() { Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap); - Child = new SingerScreen(); + + var beatDivisor = new BindableBeatDivisor + { + Value = Beatmap.Value.BeatmapInfo.BeatDivisor + }; + var editorClock = new EditorClock(Beatmap.Value, beatDivisor) { IsCoupled = false }; + Dependencies.CacheAs(editorClock); + + base.Content.Add(Content); } + + [SetUp] + public void SetUp() => Schedule(() => + { + Child = new SingerScreen(); + }); } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerContent.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerContent.cs new file mode 100644 index 000000000..fa048080f --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerContent.cs @@ -0,0 +1,90 @@ +// 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.Game.Overlays; +using osu.Game.Rulesets.Edit; +using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts; +using osu.Game.Screens.Edit.Compose.Components; +using osu.Game.Screens.Edit.Compose.Components.Timeline; + +namespace osu.Game.Rulesets.Karaoke.Edit.Singers +{ + public class SingerContent : CompositeDrawable + { + private Box background; + + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) + { + InternalChildren = new Drawable[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0.3f, + Colour = colourProvider.Background1, + }, + new GridContainer + { + RelativeSizeAxes = Axes.Both, + ColumnDimensions = new[] + { + new Dimension(GridSizeMode.Absolute, SingerInfoSize), + new Dimension(GridSizeMode.Absolute, 5), + new Dimension(), + }, + Content = new [] + { + new Drawable[] + { + CreateSingerInfo().With(x => { + x.RelativeSizeAxes = Axes.Both; + }), + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colourProvider.Dark1, + }, + new SingerLyricBlueprintContainer + { + RelativeSizeAxes = Axes.Both, + } + } + } + } + }; + } + + protected virtual float SingerInfoSize => 200; + + protected virtual Drawable CreateSingerInfo() => new Container(); + + protected class SingerLyricBlueprintContainer : BlueprintContainer + { + [Resolved(CanBeNull = true)] + private Timeline timeline { get; set; } + + protected class TimelineSelectionBlueprintContainer : Container + { + protected override Container Content { get; } + + public TimelineSelectionBlueprintContainer() + { + AddInternal(new SingerLyricPart(Content = new Container { RelativeSizeAxes = Axes.Both }) { RelativeSizeAxes = Axes.Both }); + } + } + + protected class SingerLyricPart : TimelinePart where T : Drawable + { + public SingerLyricPart(Container content = null) + :base(content) + { + } + } + } + } +} diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs index 946bc4a6c..24753d411 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs @@ -27,7 +27,7 @@ private void load() { new Drawable[] { - new Container + new SingerContent { Name = "Default", RelativeSizeAxes = Axes.Both, diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs index 68dd4a77a..dba08709c 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs @@ -5,9 +5,10 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input.Events; +using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; -using osu.Game.Overlays; namespace osu.Game.Rulesets.Karaoke.Edit.Singers { @@ -18,7 +19,7 @@ protected override OsuRearrangeableListItem CreateOsuDrawable(Singer ite public class SingerRearrangeableListItem : OsuRearrangeableListItem { - private Box background; + private Box dragAlert; public SingerRearrangeableListItem(Singer item) : base(item) @@ -31,23 +32,49 @@ protected override Drawable CreateContent() { Masking = true, CornerRadius = 5, - AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, + Height = 120, + Margin = new MarginPadding { Top = 5 }, Children = new Drawable[] { - background = new Box + dragAlert = new Box { RelativeSizeAxes = Axes.Both, - Alpha = 0.3f + Alpha = 0 }, + new RealSingerContent + { + RelativeSizeAxes = Axes.Both, + } } }; } [BackgroundDependencyLoader] - private void load(OverlayColourProvider privider) + private void load(OsuColour colours) + { + dragAlert.Colour = colours.YellowDarker; + } + + protected override bool OnDragStart(DragStartEvent e) + { + if (!base.OnDragStart(e)) + return false; + + dragAlert.Show(); + return true; + } + + protected override void OnDragEnd(DragEndEvent e) + { + dragAlert.Hide(); + base.OnDragEnd(e); + } + + public class RealSingerContent : SingerContent { - background.Colour = privider.Content1; + // todo : implement singer info here + protected override float SingerInfoSize => base.SingerInfoSize - 22; } } } From 3cb6a04c5e01b64bb77af2d6893ed3226721d9b1 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 1 Nov 2020 15:15:06 +0900 Subject: [PATCH 04/10] Apply test singers and tooltip --- .../Edit/TestSceneSinger.cs | 21 +++++++++ .../Beatmaps/Metadatas/Singer.cs | 2 +- .../Edit/Singers/SingerContent.cs | 12 ++++- .../Edit/Singers/SingerEditSection.cs | 14 ++++-- .../Edit/Singers/SingerManager.cs | 14 ++++++ .../SingerRearrangeableListContainer.cs | 46 ++++++++++++++++++- 6 files changed, 100 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs b/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs index bfd1ce1c8..17d8a9bc3 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs @@ -28,6 +28,27 @@ public TestSceneSinger() var beatmap = new TestKaraokeBeatmap(null); var karaokeBeatmap = new KaraokeBeatmapConverter(beatmap, new KaraokeRuleset()).Convert() as KaraokeBeatmap; // todo : insert singers + karaokeBeatmap.SingerMetadata.CreateSinger(singer => + { + singer.Name = "初音ミク"; + singer.RomajiName = "Hatsune Miku"; + singer.EnglishName = "Miku"; + singer.Description = "International superstar vocaloid Hatsune Miku."; + }); + karaokeBeatmap.SingerMetadata.CreateSinger(singer => + { + singer.Name = "ハク"; + singer.RomajiName = "haku"; + singer.EnglishName = "andy840119"; + singer.Description = "Creator of this ruleset."; + }); + karaokeBeatmap.SingerMetadata.CreateSinger(singer => + { + singer.Name = "ゴミパソコン"; + singer.RomajiName = "gomi-pasokonn"; + singer.EnglishName = "garbage desktop"; + singer.Description = "My fucking slow desktop."; + }); editorBeatmap = new EditorBeatmap(karaokeBeatmap); } diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/Metadatas/Singer.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/Metadatas/Singer.cs index 2178e1e4b..272715bef 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/Metadatas/Singer.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/Metadatas/Singer.cs @@ -21,7 +21,7 @@ public Singer(int id) public string EnglishName { get; set; } - public Color4 Color { get; set; } + public Color4? Color { get; set; } public string Avatar { get; set; } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerContent.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerContent.cs index fa048080f..699ab5d24 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerContent.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerContent.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Overlays; using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts; using osu.Game.Screens.Edit.Compose.Components; using osu.Game.Screens.Edit.Compose.Components.Timeline; @@ -16,6 +17,13 @@ namespace osu.Game.Rulesets.Karaoke.Edit.Singers public class SingerContent : CompositeDrawable { private Box background; + private Singer singer; + + public SingerContent(Singer singer) + { + this.singer = singer; + } + [BackgroundDependencyLoader] private void load(OverlayColourProvider colourProvider) @@ -41,7 +49,7 @@ private void load(OverlayColourProvider colourProvider) { new Drawable[] { - CreateSingerInfo().With(x => { + CreateSingerInfo(singer).With(x => { x.RelativeSizeAxes = Axes.Both; }), new Box @@ -61,7 +69,7 @@ private void load(OverlayColourProvider colourProvider) protected virtual float SingerInfoSize => 200; - protected virtual Drawable CreateSingerInfo() => new Container(); + protected virtual Drawable CreateSingerInfo(Singer singer) => new Container(); protected class SingerLyricBlueprintContainer : BlueprintContainer { diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs index 24753d411..d155e8905 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs @@ -5,6 +5,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; +using System.Linq; namespace osu.Game.Rulesets.Karaoke.Edit.Singers { @@ -13,7 +14,7 @@ public class SingerEditSection : CompositeDrawable private SingerRearrangeableListContainer singerContainers; [BackgroundDependencyLoader] - private void load() + private void load(SingerManager singerManager) { InternalChild = new GridContainer { @@ -27,7 +28,7 @@ private void load() { new Drawable[] { - new SingerContent + new SingerContent(new Singer(-1){ Name = "Default" }) { Name = "Default", RelativeSizeAxes = Axes.Both, @@ -44,9 +45,12 @@ private void load() } }; - singerContainers.Items.Add(new Singer(0)); - singerContainers.Items.Add(new Singer(1)); - singerContainers.Items.Add(new Singer(2)); + singerManager.Singers.BindCollectionChanged((a, b) => + { + var newSingers = singerManager.Singers.ToList(); + singerContainers.Items.Clear(); + singerContainers.Items.AddRange(newSingers); + }, true); } } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerManager.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerManager.cs index 54923f00a..1d6797693 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerManager.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerManager.cs @@ -2,14 +2,28 @@ // 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.Beatmaps; +using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; using osu.Game.Screens.Edit; namespace osu.Game.Rulesets.Karaoke.Edit.Singers { public class SingerManager : Component { + public readonly BindableList Singers = new BindableList(); + [Resolved] private EditorBeatmap beatmap { get; set; } + + [BackgroundDependencyLoader] + private void load() + { + if (beatmap?.PlayableBeatmap is KaraokeBeatmap karaokeBeatmap) + { + Singers.AddRange(karaokeBeatmap.SingerMetadata.Singers); + } + } } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs index dba08709c..1c5063265 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs @@ -4,11 +4,14 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; +using osu.Game.Rulesets.Karaoke.Graphics.Cursor; +using osuTK.Graphics; namespace osu.Game.Rulesets.Karaoke.Edit.Singers { @@ -42,7 +45,7 @@ protected override Drawable CreateContent() RelativeSizeAxes = Axes.Both, Alpha = 0 }, - new RealSingerContent + new RealSingerContent(Model) { RelativeSizeAxes = Axes.Both, } @@ -73,8 +76,49 @@ protected override void OnDragEnd(DragEndEvent e) public class RealSingerContent : SingerContent { + public RealSingerContent(Singer singer) + : base(singer) + { + } + // todo : implement singer info here protected override float SingerInfoSize => base.SingerInfoSize - 22; + + protected override Drawable CreateSingerInfo(Singer singer) + { + return new DrawableSingerInfo(singer) + { + RelativeSizeAxes = Axes.Both, + }; + } + + internal class DrawableSingerInfo : CompositeDrawable, IHasCustomTooltip + { + private Singer singer; + public DrawableSingerInfo(Singer singer) + { + this.singer = singer; + InternalChildren = new Drawable[] + { + new Box + { + Name = "Background", + RelativeSizeAxes = Axes.Both, + Colour = singer.Color ?? new Color4(), + Alpha = singer.Color != null ? 1 : 0 + }, + new FillFlowContainer + { + Name = "Infos", + RelativeSizeAxes = Axes.Both, + } + }; + } + + public object TooltipContent => singer; + + public ITooltip GetCustomTooltip() => new SingerToolTip(); + } } } } From cbaa1d2f4ec5486be4ecb207562b4939e3d64ede Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 1 Nov 2020 15:31:42 +0900 Subject: [PATCH 05/10] To better naming. --- .../Components/DefaultLyricPlacementColumn.cs | 15 +++++ .../LyricPlacementColumn.cs} | 7 +-- .../Components/SingerLyricPlacementColumn.cs | 60 +++++++++++++++++++ .../Edit/Singers/SingerEditSection.cs | 3 +- .../SingerRearrangeableListContainer.cs | 53 +--------------- 5 files changed, 82 insertions(+), 56 deletions(-) create mode 100644 osu.Game.Rulesets.Karaoke/Edit/Singers/Components/DefaultLyricPlacementColumn.cs rename osu.Game.Rulesets.Karaoke/Edit/Singers/{SingerContent.cs => Components/LyricPlacementColumn.cs} (94%) create mode 100644 osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/DefaultLyricPlacementColumn.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/DefaultLyricPlacementColumn.cs new file mode 100644 index 000000000..2be06a296 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/DefaultLyricPlacementColumn.cs @@ -0,0 +1,15 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; + +namespace osu.Game.Rulesets.Karaoke.Edit.Singers.Components +{ + public class DefaultLyricPlacementColumn : LyricPlacementColumn + { + public DefaultLyricPlacementColumn() + : base(new Singer(-1) { Name = "Default" }) + { + } + } +} diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerContent.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/LyricPlacementColumn.cs similarity index 94% rename from osu.Game.Rulesets.Karaoke/Edit/Singers/SingerContent.cs rename to osu.Game.Rulesets.Karaoke/Edit/Singers/Components/LyricPlacementColumn.cs index 699ab5d24..1e30ed84b 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerContent.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/LyricPlacementColumn.cs @@ -12,19 +12,18 @@ using osu.Game.Screens.Edit.Compose.Components; using osu.Game.Screens.Edit.Compose.Components.Timeline; -namespace osu.Game.Rulesets.Karaoke.Edit.Singers +namespace osu.Game.Rulesets.Karaoke.Edit.Singers.Components { - public class SingerContent : CompositeDrawable + public abstract class LyricPlacementColumn : CompositeDrawable { private Box background; private Singer singer; - public SingerContent(Singer singer) + public LyricPlacementColumn(Singer singer) { this.singer = singer; } - [BackgroundDependencyLoader] private void load(OverlayColourProvider colourProvider) { diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs new file mode 100644 index 000000000..2d89914fb --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs @@ -0,0 +1,60 @@ +// 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.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.Shapes; +using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; +using osu.Game.Rulesets.Karaoke.Graphics.Cursor; +using osuTK.Graphics; + +namespace osu.Game.Rulesets.Karaoke.Edit.Singers.Components +{ + public class SingerLyricPlacementColumn : LyricPlacementColumn + { + public SingerLyricPlacementColumn(Singer singer) + : base(singer) + { + } + + // todo : implement singer info here + protected override float SingerInfoSize => base.SingerInfoSize - 22; + + protected override Drawable CreateSingerInfo(Singer singer) + { + return new DrawableSingerInfo(singer) + { + RelativeSizeAxes = Axes.Both, + }; + } + + internal class DrawableSingerInfo : CompositeDrawable, IHasCustomTooltip + { + private Singer singer; + public DrawableSingerInfo(Singer singer) + { + this.singer = singer; + InternalChildren = new Drawable[] + { + new Box + { + Name = "Background", + RelativeSizeAxes = Axes.Both, + Colour = singer.Color ?? new Color4(), + Alpha = singer.Color != null ? 1 : 0 + }, + new FillFlowContainer + { + Name = "Infos", + RelativeSizeAxes = Axes.Both, + } + }; + } + + public object TooltipContent => singer; + + public ITooltip GetCustomTooltip() => new SingerToolTip(); + } + } +} diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs index d155e8905..51cd929ac 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs @@ -5,6 +5,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; +using osu.Game.Rulesets.Karaoke.Edit.Singers.Components; using System.Linq; namespace osu.Game.Rulesets.Karaoke.Edit.Singers @@ -28,7 +29,7 @@ private void load(SingerManager singerManager) { new Drawable[] { - new SingerContent(new Singer(-1){ Name = "Default" }) + new DefaultLyricPlacementColumn() { Name = "Default", RelativeSizeAxes = Axes.Both, diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs index 1c5063265..a68e9351e 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs @@ -4,14 +4,12 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; -using osu.Game.Rulesets.Karaoke.Graphics.Cursor; -using osuTK.Graphics; +using osu.Game.Rulesets.Karaoke.Edit.Singers.Components; namespace osu.Game.Rulesets.Karaoke.Edit.Singers { @@ -45,7 +43,7 @@ protected override Drawable CreateContent() RelativeSizeAxes = Axes.Both, Alpha = 0 }, - new RealSingerContent(Model) + new SingerLyricPlacementColumn(Model) { RelativeSizeAxes = Axes.Both, } @@ -73,53 +71,6 @@ protected override void OnDragEnd(DragEndEvent e) dragAlert.Hide(); base.OnDragEnd(e); } - - public class RealSingerContent : SingerContent - { - public RealSingerContent(Singer singer) - : base(singer) - { - } - - // todo : implement singer info here - protected override float SingerInfoSize => base.SingerInfoSize - 22; - - protected override Drawable CreateSingerInfo(Singer singer) - { - return new DrawableSingerInfo(singer) - { - RelativeSizeAxes = Axes.Both, - }; - } - - internal class DrawableSingerInfo : CompositeDrawable, IHasCustomTooltip - { - private Singer singer; - public DrawableSingerInfo(Singer singer) - { - this.singer = singer; - InternalChildren = new Drawable[] - { - new Box - { - Name = "Background", - RelativeSizeAxes = Axes.Both, - Colour = singer.Color ?? new Color4(), - Alpha = singer.Color != null ? 1 : 0 - }, - new FillFlowContainer - { - Name = "Infos", - RelativeSizeAxes = Axes.Both, - } - }; - } - - public object TooltipContent => singer; - - public ITooltip GetCustomTooltip() => new SingerToolTip(); - } - } } } } From 2d9503c453223ffd9df50d6269b6e2c8d51fffbf Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 1 Nov 2020 15:33:04 +0900 Subject: [PATCH 06/10] Add test case to mark singer tooltip's description is not showing. --- .../Edit/TestSceneSinger.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs b/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs index 17d8a9bc3..0e8976dc3 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs @@ -11,11 +11,12 @@ using osu.Game.Rulesets.Karaoke.Tests.Beatmaps; using osu.Game.Screens.Edit; using osu.Game.Tests.Visual; +using osuTK; namespace osu.Game.Rulesets.Karaoke.Tests.Edit { [TestFixture] - public class TestSceneSinger : OsuTestScene + public class TestSceneSinger : OsuManualInputManagerTestScene { [Cached(typeof(EditorBeatmap))] [Cached(typeof(IBeatSnapProvider))] @@ -73,5 +74,12 @@ public void SetUp() => Schedule(() => { Child = new SingerScreen(); }); + + [Test] + public void HoverToSingerArea() + { + // todo : add this step because description is not showing. + AddStep("Move mouse to singer area", () => InputManager.MoveMouseTo(Child, new Vector2(-400,-100))); + } } } From 1451b392e3a663326f0e474150cbb731765addd6 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 1 Nov 2020 15:36:35 +0900 Subject: [PATCH 07/10] Clean-up code --- .../Components/LyricPlacementColumn.cs | 13 ++++----- .../Components/SingerLyricPlacementColumn.cs | 27 ++++++++++--------- .../Edit/Singers/SingerEditSection.cs | 5 ++-- .../Edit/Singers/SingerScreen.cs | 2 +- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/LyricPlacementColumn.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/LyricPlacementColumn.cs index 1e30ed84b..a45ff0d93 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/LyricPlacementColumn.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/LyricPlacementColumn.cs @@ -17,9 +17,9 @@ namespace osu.Game.Rulesets.Karaoke.Edit.Singers.Components public abstract class LyricPlacementColumn : CompositeDrawable { private Box background; - private Singer singer; + private readonly Singer singer; - public LyricPlacementColumn(Singer singer) + protected LyricPlacementColumn(Singer singer) { this.singer = singer; } @@ -44,11 +44,12 @@ private void load(OverlayColourProvider colourProvider) new Dimension(GridSizeMode.Absolute, 5), new Dimension(), }, - Content = new [] + Content = new[] { - new Drawable[] + new[] { - CreateSingerInfo(singer).With(x => { + CreateSingerInfo(singer).With(x => + { x.RelativeSizeAxes = Axes.Both; }), new Box @@ -88,7 +89,7 @@ public TimelineSelectionBlueprintContainer() protected class SingerLyricPart : TimelinePart where T : Drawable { public SingerLyricPart(Container content = null) - :base(content) + : base(content) { } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs index 2d89914fb..ec0831e68 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs @@ -31,24 +31,25 @@ protected override Drawable CreateSingerInfo(Singer singer) internal class DrawableSingerInfo : CompositeDrawable, IHasCustomTooltip { - private Singer singer; + private readonly Singer singer; + public DrawableSingerInfo(Singer singer) { this.singer = singer; InternalChildren = new Drawable[] { - new Box - { - Name = "Background", - RelativeSizeAxes = Axes.Both, - Colour = singer.Color ?? new Color4(), - Alpha = singer.Color != null ? 1 : 0 - }, - new FillFlowContainer - { - Name = "Infos", - RelativeSizeAxes = Axes.Both, - } + new Box + { + Name = "Background", + RelativeSizeAxes = Axes.Both, + Colour = singer.Color ?? new Color4(), + Alpha = singer.Color != null ? 1 : 0 + }, + new FillFlowContainer + { + Name = "Infos", + RelativeSizeAxes = Axes.Both, + } }; } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs index 51cd929ac..3132658e8 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerEditSection.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; using osu.Game.Rulesets.Karaoke.Edit.Singers.Components; using System.Linq; @@ -25,11 +24,11 @@ private void load(SingerManager singerManager) new Dimension(GridSizeMode.Absolute, 100), new Dimension() }, - Content = new Drawable[][] + Content = new[] { new Drawable[] { - new DefaultLyricPlacementColumn() + new DefaultLyricPlacementColumn { Name = "Default", RelativeSizeAxes = Axes.Both, diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerScreen.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerScreen.cs index 993c70fe7..9149314b6 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerScreen.cs @@ -50,7 +50,7 @@ private void load(OsuColour colours) { FixedHeader = new SingerScreenHeader(), RelativeSizeAxes = Axes.Both, - Children = new [] + Children = new[] { new SingerEditSection { From 6fb5aff4c81698402554d72cfdb8908b2dbe250f Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 1 Nov 2020 15:57:21 +0900 Subject: [PATCH 08/10] Implement singer info and separate singer avatar. --- .../Components/SingerLyricPlacementColumn.cs | 55 ++++++++++++++++++- .../Graphics/Cursor/SingerToolTip.cs | 27 +-------- .../Graphics/Sprites/DrawableSingerAvatar.cs | 34 ++++++++++++ 3 files changed, 89 insertions(+), 27 deletions(-) create mode 100644 osu.Game.Rulesets.Karaoke/Graphics/Sprites/DrawableSingerAvatar.cs diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs index ec0831e68..a6e1327c1 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs @@ -5,8 +5,12 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; using osu.Game.Rulesets.Karaoke.Graphics.Cursor; +using osu.Game.Rulesets.Karaoke.Graphics.Sprites; +using osuTK; using osuTK.Graphics; namespace osu.Game.Rulesets.Karaoke.Edit.Singers.Components @@ -36,6 +40,7 @@ internal class DrawableSingerInfo : CompositeDrawable, IHasCustomTooltip public DrawableSingerInfo(Singer singer) { this.singer = singer; + InternalChildren = new Drawable[] { new Box @@ -45,11 +50,57 @@ public DrawableSingerInfo(Singer singer) Colour = singer.Color ?? new Color4(), Alpha = singer.Color != null ? 1 : 0 }, - new FillFlowContainer + new GridContainer { Name = "Infos", RelativeSizeAxes = Axes.Both, - } + Margin = new MarginPadding(10), + ColumnDimensions = new[] + { + new Dimension(GridSizeMode.AutoSize, 48), + new Dimension(), + }, + Content = new[] + { + new Drawable[] + { + new DrawableSingerAvatar + { + Name = "Avatar", + Size = new Vector2(48) + }, + new FillFlowContainer + { + Name = "Singer name", + RelativeSizeAxes = Axes.X, + Direction = FillDirection.Vertical, + Spacing = new Vector2(1), + Padding = new MarginPadding{ Left = 5 }, + Children = new[] + { + new OsuSpriteText + { + Name = "Singer name", + Text = singer.Name, + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 20), + }, + new OsuSpriteText + { + Name = "Romaji name", + Text = singer.RomajiName, + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 9), + }, + new OsuSpriteText + { + Name = "English name", + Text = singer.EnglishName != null ? $"({singer.EnglishName})" : "", + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 12), + } + } + }, + } + } + }, }; } diff --git a/osu.Game.Rulesets.Karaoke/Graphics/Cursor/SingerToolTip.cs b/osu.Game.Rulesets.Karaoke/Graphics/Cursor/SingerToolTip.cs index 371d66c37..6d5c54585 100644 --- a/osu.Game.Rulesets.Karaoke/Graphics/Cursor/SingerToolTip.cs +++ b/osu.Game.Rulesets.Karaoke/Graphics/Cursor/SingerToolTip.cs @@ -1,17 +1,14 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -using System; -using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Textures; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; +using osu.Game.Rulesets.Karaoke.Graphics.Sprites; using osuTK; using osuTK.Graphics; @@ -91,26 +88,6 @@ public override bool SetContent(object content) return true; } - public class DrawableSingerAvatar : Container - { - [BackgroundDependencyLoader] - private void load(LargeTextureStore textures) - { - if (textures == null) - throw new ArgumentNullException(nameof(textures)); - - // todo : get real texture from beatmap - Texture texture = textures.Get(@"Online/avatar-guest"); - - Add(new Sprite - { - RelativeSizeAxes = Axes.Both, - Texture = texture, - FillMode = FillMode.Fit, - Anchor = Anchor.Centre, - Origin = Anchor.Centre - }); - } - } + } } diff --git a/osu.Game.Rulesets.Karaoke/Graphics/Sprites/DrawableSingerAvatar.cs b/osu.Game.Rulesets.Karaoke/Graphics/Sprites/DrawableSingerAvatar.cs new file mode 100644 index 000000000..f505c39ec --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Graphics/Sprites/DrawableSingerAvatar.cs @@ -0,0 +1,34 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; + +namespace osu.Game.Rulesets.Karaoke.Graphics.Sprites +{ + public class DrawableSingerAvatar : Container + { + [BackgroundDependencyLoader] + private void load(LargeTextureStore textures) + { + if (textures == null) + throw new ArgumentNullException(nameof(textures)); + + // todo : get real texture from beatmap + Texture texture = textures.Get(@"Online/avatar-guest"); + + Add(new Sprite + { + RelativeSizeAxes = Axes.Both, + Texture = texture, + FillMode = FillMode.Fit, + Anchor = Anchor.Centre, + Origin = Anchor.Centre + }); + } + } +} From bb2ad966a3a2732753d561c3333a6e809cdc94ae Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 1 Nov 2020 16:00:55 +0900 Subject: [PATCH 09/10] Make some method abstract. --- .../Edit/Singers/Components/DefaultLyricPlacementColumn.cs | 7 +++++++ .../Edit/Singers/Components/LyricPlacementColumn.cs | 4 ++-- .../Edit/Singers/Components/SingerLyricPlacementColumn.cs | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/DefaultLyricPlacementColumn.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/DefaultLyricPlacementColumn.cs index 2be06a296..7b907e322 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/DefaultLyricPlacementColumn.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/DefaultLyricPlacementColumn.cs @@ -1,6 +1,8 @@ // 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.Framework.Graphics.Containers; using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; namespace osu.Game.Rulesets.Karaoke.Edit.Singers.Components @@ -11,5 +13,10 @@ public DefaultLyricPlacementColumn() : base(new Singer(-1) { Name = "Default" }) { } + + protected override float SingerInfoSize => 200; + + // todo : might display song info? + protected override Drawable CreateSingerInfo(Singer singer) => new Container(); } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/LyricPlacementColumn.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/LyricPlacementColumn.cs index a45ff0d93..e4c225f22 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/LyricPlacementColumn.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/LyricPlacementColumn.cs @@ -67,9 +67,9 @@ private void load(OverlayColourProvider colourProvider) }; } - protected virtual float SingerInfoSize => 200; + protected abstract float SingerInfoSize { get; } - protected virtual Drawable CreateSingerInfo(Singer singer) => new Container(); + protected abstract Drawable CreateSingerInfo(Singer singer) ; protected class SingerLyricBlueprintContainer : BlueprintContainer { diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs index a6e1327c1..c4adef07c 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs @@ -23,7 +23,7 @@ public SingerLyricPlacementColumn(Singer singer) } // todo : implement singer info here - protected override float SingerInfoSize => base.SingerInfoSize - 22; + protected override float SingerInfoSize => 178; protected override Drawable CreateSingerInfo(Singer singer) { From 2f1db9d39c697af884028326f946a6ca15b82a09 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 1 Nov 2020 16:07:38 +0900 Subject: [PATCH 10/10] Adjust style. --- osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs | 3 +++ .../Edit/Singers/Components/LyricPlacementColumn.cs | 2 +- .../Edit/Singers/Components/SingerLyricPlacementColumn.cs | 2 +- .../Edit/Singers/SingerRearrangeableListContainer.cs | 2 +- osu.Game.Rulesets.Karaoke/Graphics/Cursor/SingerToolTip.cs | 2 -- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs b/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs index 0e8976dc3..d07d796a3 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs @@ -35,6 +35,7 @@ public TestSceneSinger() singer.RomajiName = "Hatsune Miku"; singer.EnglishName = "Miku"; singer.Description = "International superstar vocaloid Hatsune Miku."; + singer.Color = Colour4.AliceBlue; }); karaokeBeatmap.SingerMetadata.CreateSinger(singer => { @@ -42,6 +43,7 @@ public TestSceneSinger() singer.RomajiName = "haku"; singer.EnglishName = "andy840119"; singer.Description = "Creator of this ruleset."; + singer.Color = Colour4.Yellow; }); karaokeBeatmap.SingerMetadata.CreateSinger(singer => { @@ -49,6 +51,7 @@ public TestSceneSinger() singer.RomajiName = "gomi-pasokonn"; singer.EnglishName = "garbage desktop"; singer.Description = "My fucking slow desktop."; + singer.Color = Colour4.Brown; }); editorBeatmap = new EditorBeatmap(karaokeBeatmap); diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/LyricPlacementColumn.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/LyricPlacementColumn.cs index e4c225f22..51e31a649 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/LyricPlacementColumn.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/LyricPlacementColumn.cs @@ -69,7 +69,7 @@ private void load(OverlayColourProvider colourProvider) protected abstract float SingerInfoSize { get; } - protected abstract Drawable CreateSingerInfo(Singer singer) ; + protected abstract Drawable CreateSingerInfo(Singer singer); protected class SingerLyricBlueprintContainer : BlueprintContainer { diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs index c4adef07c..5c6ad0bf9 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/Components/SingerLyricPlacementColumn.cs @@ -48,7 +48,7 @@ public DrawableSingerInfo(Singer singer) Name = "Background", RelativeSizeAxes = Axes.Both, Colour = singer.Color ?? new Color4(), - Alpha = singer.Color != null ? 1 : 0 + Alpha = singer.Color != null ? 0.3f : 0 }, new GridContainer { diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs index a68e9351e..dc03e504a 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/SingerRearrangeableListContainer.cs @@ -34,7 +34,7 @@ protected override Drawable CreateContent() Masking = true, CornerRadius = 5, RelativeSizeAxes = Axes.X, - Height = 120, + Height = 90, Margin = new MarginPadding { Top = 5 }, Children = new Drawable[] { diff --git a/osu.Game.Rulesets.Karaoke/Graphics/Cursor/SingerToolTip.cs b/osu.Game.Rulesets.Karaoke/Graphics/Cursor/SingerToolTip.cs index 6d5c54585..11e357469 100644 --- a/osu.Game.Rulesets.Karaoke/Graphics/Cursor/SingerToolTip.cs +++ b/osu.Game.Rulesets.Karaoke/Graphics/Cursor/SingerToolTip.cs @@ -87,7 +87,5 @@ public override bool SetContent(object content) return true; } - - } }