From d0cd252d9c81a0856269746ef9ad38968bc549dd Mon Sep 17 00:00:00 2001 From: andy840119 Date: Wed, 9 Oct 2024 20:37:28 +0800 Subject: [PATCH 1/2] Upgrade osu.game and fix the compile error. --- osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs | 2 +- osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs b/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs index e60b6fb9a..110126045 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs @@ -177,7 +177,7 @@ protected void CreateMenuBar() }); } - protected override IReadOnlyList CompositionTools => Array.Empty(); + protected override IReadOnlyList CompositionTools => Array.Empty(); protected override IEnumerable CreateTernaryButtons() => Array.Empty(); } diff --git a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj index bd51b716e..ff001b7b9 100644 --- a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj +++ b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj @@ -17,7 +17,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + From 65adbfcb989acb0f43f143ddd17f259f50cbb61f Mon Sep 17 00:00:00 2001 From: andy840119 Date: Wed, 9 Oct 2024 21:11:20 +0800 Subject: [PATCH 2/2] Adjust the style. --- .../{LanguageList.cs => FormLanguageList.cs} | 109 +++++++++++---- .../{SingerList.cs => FormSingerList.cs} | 130 +++++++++++++----- .../Setup/Components/LabelledLanguageList.cs | 20 --- .../Setup/Components/LabelledSingerList.cs | 20 --- .../Edit/Setup/KaraokeNoteSection.cs | 8 +- .../Edit/Setup/KaraokeSingerSection.cs | 9 +- .../Edit/Setup/KaraokeTranslationSection.cs | 9 +- 7 files changed, 193 insertions(+), 112 deletions(-) rename osu.Game.Rulesets.Karaoke/Edit/Setup/Components/{LanguageList.cs => FormLanguageList.cs} (63%) rename osu.Game.Rulesets.Karaoke/Edit/Setup/Components/{SingerList.cs => FormSingerList.cs} (70%) delete mode 100644 osu.Game.Rulesets.Karaoke/Edit/Setup/Components/LabelledLanguageList.cs delete mode 100644 osu.Game.Rulesets.Karaoke/Edit/Setup/Components/LabelledSingerList.cs diff --git a/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/LanguageList.cs b/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/FormLanguageList.cs similarity index 63% rename from osu.Game.Rulesets.Karaoke/Edit/Setup/Components/LanguageList.cs rename to osu.Game.Rulesets.Karaoke/Edit/Setup/Components/FormLanguageList.cs index 606565f16..40168729c 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/LanguageList.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/FormLanguageList.cs @@ -13,41 +13,82 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input.Events; +using osu.Framework.Localisation; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; +using osu.Game.Graphics.UserInterfaceV2; +using osu.Game.Overlays; using osu.Game.Rulesets.Karaoke.Graphics.UserInterfaceV2; using osu.Game.Rulesets.Karaoke.Utils; using osuTK; namespace osu.Game.Rulesets.Karaoke.Edit.Setup.Components; -/// -/// A component which displays a collection of -/// -public partial class LanguageList : CompositeDrawable +public partial class FormLanguageList : CompositeDrawable { public BindableList Languages { get; } = new(); - private FillFlowContainer languages = null!; + public LocalisableString Caption { get; init; } - private const int fade_duration = 200; + public LocalisableString HintText { get; init; } + + private Box background = null!; + private FormFieldCaption caption = null!; + private FillFlowContainer flow = null!; + + [Resolved] + private OverlayColourProvider colourProvider { get; set; } = null!; [BackgroundDependencyLoader] private void load() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - AutoSizeDuration = fade_duration; - AutoSizeEasing = Easing.OutQuint; - InternalChild = languages = new FillFlowContainer + Masking = true; + CornerRadius = 5; + + AddLanguageButton button; + + InternalChildren = new Drawable[] { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Spacing = new Vector2(8), - Direction = FillDirection.Full, + background = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colourProvider.Background5, + }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding(9), + Spacing = new Vector2(7), + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + caption = new FormFieldCaption + { + Caption = Caption, + TooltipText = HintText, + }, + flow = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Full, + Spacing = new Vector2(5), + Child = button = new AddLanguageButton + { + Action = languageInsertionRequested, + }, + }, + }, + }, }; + + flow.SetLayoutPosition(button, float.MaxValue); } protected override void LoadComplete() @@ -57,28 +98,46 @@ protected override void LoadComplete() Languages.BindCollectionChanged((_, args) => { if (args.Action != NotifyCollectionChangedAction.Replace) - updateSingers(); + updateLanguages(); }, true); - FinishTransforms(true); + updateState(); } - private void updateSingers() + protected override bool OnHover(HoverEvent e) { - languages.Clear(); + updateState(); + return true; + } - foreach (CultureInfo language in Languages) + protected override void OnHoverLost(HoverLostEvent e) + { + base.OnHoverLost(e); + updateState(); + } + + private void updateState() + { + background.Colour = colourProvider.Background5; + caption.Colour = colourProvider.Content2; + + BorderThickness = IsHovered ? 2 : 0; + + if (IsHovered) + BorderColour = colourProvider.Light4; + } + + private void updateLanguages() + { + flow.RemoveAll(d => d is LanguageDisplay, true); + + foreach (var language in Languages) { - languages.Add(new LanguageDisplay + flow.Add(new LanguageDisplay { Current = { Value = language }, DeleteRequested = languageDeletionRequested, }); } - - languages.Add(new AddLanguageButton - { - Action = languageInsertionRequested, - }); } private void languageInsertionRequested(CultureInfo language) @@ -162,6 +221,8 @@ internal partial class AddLanguageButton : CompositeDrawable, IHasPopover public AddLanguageButton() { + Size = new Vector2(35); + InternalChild = new IconButton { Action = this.ShowPopover, diff --git a/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/SingerList.cs b/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/FormSingerList.cs similarity index 70% rename from osu.Game.Rulesets.Karaoke/Edit/Setup/Components/SingerList.cs rename to osu.Game.Rulesets.Karaoke/Edit/Setup/Components/FormSingerList.cs index e64d67885..8e2e040e7 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/SingerList.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/FormSingerList.cs @@ -2,9 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; -using System.Collections.Generic; using System.Collections.Specialized; -using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions; @@ -15,10 +13,13 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input.Events; +using osu.Framework.Localisation; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; +using osu.Game.Graphics.UserInterfaceV2; +using osu.Game.Overlays; using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; using osu.Game.Rulesets.Karaoke.Beatmaps.Utils; using osu.Game.Rulesets.Karaoke.Graphics.Cursor; @@ -28,30 +29,69 @@ namespace osu.Game.Rulesets.Karaoke.Edit.Setup.Components; -/// -/// A component which displays a collection of singers in individual s. -/// -public partial class SingerList : CompositeDrawable +public partial class FormSingerList : CompositeDrawable { - public BindableList Singers { get; } = new(); + public BindableList Singers { get; } = new(); - private FillFlowContainer singers = null!; + public LocalisableString Caption { get; init; } + + public LocalisableString HintText { get; init; } + + private Box background = null!; + private FormFieldCaption caption = null!; + private FillFlowContainer flow = null!; + + [Resolved] + private OverlayColourProvider colourProvider { get; set; } = null!; [BackgroundDependencyLoader] private void load() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - AutoSizeDuration = fade_duration; - AutoSizeEasing = Easing.OutQuint; - InternalChild = singers = new FillFlowContainer + Masking = true; + CornerRadius = 5; + + AddSingerButton button; + + InternalChildren = new Drawable[] { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Spacing = new Vector2(10), - Direction = FillDirection.Full, + background = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colourProvider.Background5, + }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding(9), + Spacing = new Vector2(7), + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + caption = new FormFieldCaption + { + Caption = Caption, + TooltipText = HintText, + }, + flow = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Full, + Spacing = new Vector2(10), + Child = button = new AddSingerButton + { + Action = singerInsertionRequested, + }, + }, + }, + }, }; + + flow.SetLayoutPosition(button, float.MaxValue); } protected override void LoadComplete() @@ -63,35 +103,56 @@ protected override void LoadComplete() if (args.Action != NotifyCollectionChangedAction.Replace) updateSingers(); }, true); - FinishTransforms(true); + updateState(); + } + + protected override bool OnHover(HoverEvent e) + { + updateState(); + return true; } - private const int fade_duration = 200; + protected override void OnHoverLost(HoverLostEvent e) + { + base.OnHoverLost(e); + updateState(); + } + + private void updateState() + { + background.Colour = colourProvider.Background5; + caption.Colour = colourProvider.Content2; + + BorderThickness = IsHovered ? 2 : 0; + + if (IsHovered) + BorderColour = colourProvider.Light4; + } private void updateSingers() { - singers.Clear(); + flow.RemoveAll(d => d is SingerDisplay, true); foreach (var singer in Singers) { - singers.Add(new SingerDisplay + flow.Add(new SingerDisplay { Current = { Value = singer }, - DeleteRequested = singerDeletionRequested, + DeleteRequested = languageDeletionRequested, }); } + } - singers.Add(new AddSingerButton + private void singerInsertionRequested() + { + var singer = new Singer { - Action = () => Singers.Add(new Singer - { - Name = "New singer", - }), - }); + Name = "New singer", + }; + Singers.Add(singer); } - // todo : might have dialog to ask should delete singer or not if contains lyric. - private void singerDeletionRequested(Singer singer) => Singers.Remove(singer); + private void languageDeletionRequested(Singer singer) => Singers.Remove(singer); /// /// A component which displays a singer along with related description text. @@ -118,7 +179,7 @@ public Bindable Current private void load() { AutoSizeAxes = Axes.Y; - Width = 100; + Width = 50; InternalChild = new FillFlowContainer { @@ -169,8 +230,9 @@ private partial class SingerCircle : Container, IHasCustomTooltip public SingerCircle() { RelativeSizeAxes = Axes.X; - Height = 100; - CornerRadius = 50; + Height = 50; + + CornerRadius = 25; Masking = true; BorderThickness = 5; @@ -216,7 +278,7 @@ public Action Action public AddSingerButton() { AutoSizeAxes = Axes.Y; - Width = 100; + Width = 50; InternalChild = new FillFlowContainer { @@ -229,8 +291,8 @@ public AddSingerButton() circularButton = new OsuClickableContainer { RelativeSizeAxes = Axes.X, - Height = 100, - CornerRadius = 50, + Height = 50, + CornerRadius = 25, Masking = true, BorderThickness = 5, Children = new Drawable[] diff --git a/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/LabelledLanguageList.cs b/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/LabelledLanguageList.cs deleted file mode 100644 index db99efe22..000000000 --- a/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/LabelledLanguageList.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using System.Globalization; -using osu.Framework.Bindables; -using osu.Game.Graphics.UserInterfaceV2; - -namespace osu.Game.Rulesets.Karaoke.Edit.Setup.Components; - -public partial class LabelledLanguageList : LabelledDrawable -{ - public LabelledLanguageList() - : base(true) - { - } - - public BindableList Languages => Component.Languages; - - protected override LanguageList CreateComponent() => new(); -} diff --git a/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/LabelledSingerList.cs b/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/LabelledSingerList.cs deleted file mode 100644 index d8d994908..000000000 --- a/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/LabelledSingerList.cs +++ /dev/null @@ -1,20 +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.Bindables; -using osu.Game.Graphics.UserInterfaceV2; -using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; - -namespace osu.Game.Rulesets.Karaoke.Edit.Setup.Components; - -public partial class LabelledSingerList : LabelledDrawable -{ - public LabelledSingerList() - : base(true) - { - } - - public BindableList Singers => Component.Singers; - - protected override SingerList CreateComponent() => new(); -} diff --git a/osu.Game.Rulesets.Karaoke/Edit/Setup/KaraokeNoteSection.cs b/osu.Game.Rulesets.Karaoke/Edit/Setup/KaraokeNoteSection.cs index d3e65f593..4bed660ba 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Setup/KaraokeNoteSection.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Setup/KaraokeNoteSection.cs @@ -15,17 +15,17 @@ public partial class KaraokeNoteSection : SetupSection { public override LocalisableString Title => "Note"; - private LabelledSwitchButton scorable = null!; + private FormCheckBox scorable = null!; [BackgroundDependencyLoader] private void load() { Children = new Drawable[] { - scorable = new LabelledSwitchButton + scorable = new FormCheckBox { - Label = "Scorable", - Description = "Will not show score playfield if the option is unchecked.", + Caption = "Scorable", + HintText = "Will not show score playfield if the option is unchecked.", Current = { Value = true }, }, }; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Setup/KaraokeSingerSection.cs b/osu.Game.Rulesets.Karaoke/Edit/Setup/KaraokeSingerSection.cs index 3a64dd23a..a670194c2 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Setup/KaraokeSingerSection.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Setup/KaraokeSingerSection.cs @@ -20,7 +20,7 @@ public partial class KaraokeSingerSection : SetupSection private readonly IBeatmapSingersChangeHandler changeHandler = new BeatmapSingersChangeHandler(); - private LabelledSingerList singerList = null!; + private FormSingerList singerList = null!; [BackgroundDependencyLoader] private void load() @@ -29,11 +29,10 @@ private void load() Children = new Drawable[] { - singerList = new LabelledSingerList + singerList = new FormSingerList { - Label = "Singer list", - Description = "All the singers in beatmap.", - FixedLabelWidth = LABEL_WIDTH, + Caption = "Singer list", + HintText = "All the singers in beatmap.", }, }; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Setup/KaraokeTranslationSection.cs b/osu.Game.Rulesets.Karaoke/Edit/Setup/KaraokeTranslationSection.cs index e43518f46..2b838bcdc 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Setup/KaraokeTranslationSection.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Setup/KaraokeTranslationSection.cs @@ -21,7 +21,7 @@ public partial class KaraokeTranslationSection : SetupSection [Cached(typeof(IBeatmapTranslationsChangeHandler))] private readonly BeatmapTranslationsChangeHandler changeHandler = new(); - private LabelledLanguageList singerList = null!; + private FormLanguageList singerList = null!; [BackgroundDependencyLoader] private void load() @@ -30,11 +30,10 @@ private void load() Children = new Drawable[] { - singerList = new LabelledLanguageList + singerList = new FormLanguageList { - Label = "Translation list", - Description = "All the lyric translation in beatmap.", - FixedLabelWidth = LABEL_WIDTH, + Caption = "Translation list", + HintText = "All the lyric translation in beatmap.", }, };