From 1f2f86b016d112b28c75daba59e3144ada46f2e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 15 Oct 2025 10:30:03 +0200 Subject: [PATCH] Make bank selection controls dropdowns instead of text boxes Longstanding complaint. Text boxes make no sense if anything that isn't the three legacy values gets deleted on save anyway. --- .../TestSceneLabelledDropdown.cs | 4 +-- .../Screens/Setup/SetupScreen.cs | 3 +- .../UserInterfaceV2/LabelledDropdown.cs | 11 ++++++-- .../UserInterfaceV2/LabelledEnumDropdown.cs | 5 ++++ .../Components/Timeline/SamplePointPiece.cs | 28 +++++++------------ 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledDropdown.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledDropdown.cs index 300b451cf5..941f6667e2 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledDropdown.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledDropdown.cs @@ -11,7 +11,7 @@ namespace osu.Game.Tests.Visual.UserInterface { [Test] public void TestLabelledDropdown() - => AddStep(@"create dropdown", () => Child = new LabelledDropdown + => AddStep(@"create dropdown", () => Child = new LabelledDropdown(true) { Label = @"Countdown speed", Items = new[] @@ -25,7 +25,7 @@ namespace osu.Game.Tests.Visual.UserInterface [Test] public void TestLabelledEnumDropdown() - => AddStep(@"create dropdown", () => Child = new LabelledEnumDropdown + => AddStep(@"create dropdown", () => Child = new LabelledEnumDropdown(true) { Label = @"Beatmap status", Description = @"This is a description" diff --git a/osu.Game.Tournament/Screens/Setup/SetupScreen.cs b/osu.Game.Tournament/Screens/Setup/SetupScreen.cs index 536e8ba767..bd368d88a0 100644 --- a/osu.Game.Tournament/Screens/Setup/SetupScreen.cs +++ b/osu.Game.Tournament/Screens/Setup/SetupScreen.cs @@ -116,12 +116,13 @@ namespace osu.Game.Tournament.Screens.Setup Failing = api.IsLoggedIn != true, Description = "In order to access the API and display metadata, signing in is required." }, - new LabelledDropdown + new LabelledDropdown(padded: true) { Label = "Ruleset", Description = "Decides what stats are displayed and which ranks are retrieved for players. This requires a restart to reload data for an existing bracket.", Items = rulesets.AvailableRulesets, Current = LadderInfo.Ruleset, + DropdownWidth = 0.5f, }, new TournamentSwitcher { diff --git a/osu.Game/Graphics/UserInterfaceV2/LabelledDropdown.cs b/osu.Game/Graphics/UserInterfaceV2/LabelledDropdown.cs index dbbae390a7..a37267014f 100644 --- a/osu.Game/Graphics/UserInterfaceV2/LabelledDropdown.cs +++ b/osu.Game/Graphics/UserInterfaceV2/LabelledDropdown.cs @@ -9,8 +9,8 @@ namespace osu.Game.Graphics.UserInterfaceV2 { public partial class LabelledDropdown : LabelledComponent, TItem> { - public LabelledDropdown() - : base(true) + public LabelledDropdown(bool padded) + : base(padded) { } @@ -20,10 +20,15 @@ namespace osu.Game.Graphics.UserInterfaceV2 set => Component.Items = value; } + public float DropdownWidth + { + get => Component.Width; + set => Component.Width = value; + } + protected sealed override OsuDropdown CreateComponent() => CreateDropdown().With(d => { d.RelativeSizeAxes = Axes.X; - d.Width = 0.5f; }); protected virtual OsuDropdown CreateDropdown() => new OsuDropdown(); diff --git a/osu.Game/Graphics/UserInterfaceV2/LabelledEnumDropdown.cs b/osu.Game/Graphics/UserInterfaceV2/LabelledEnumDropdown.cs index 9c2c8397ed..5658175804 100644 --- a/osu.Game/Graphics/UserInterfaceV2/LabelledEnumDropdown.cs +++ b/osu.Game/Graphics/UserInterfaceV2/LabelledEnumDropdown.cs @@ -9,6 +9,11 @@ namespace osu.Game.Graphics.UserInterfaceV2 public partial class LabelledEnumDropdown : LabelledDropdown where TEnum : struct, Enum { + public LabelledEnumDropdown(bool padded) + : base(padded) + { + } + protected override OsuDropdown CreateDropdown() => new OsuEnumDropdown(); } } diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/SamplePointPiece.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/SamplePointPiece.cs index eaf9069431..bf31ea4e2e 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/SamplePointPiece.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/SamplePointPiece.cs @@ -187,8 +187,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline { private readonly HitObject hitObject; - private LabelledTextBox bank = null!; - private LabelledTextBox additionBank = null!; + private LabelledDropdown bank = null!; + private LabelledDropdown additionBank = null!; private IndeterminateSliderWithTextBoxInput volume = null!; private FillFlowContainer togglesCollection = null!; @@ -240,7 +240,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline { flow = new FillFlowContainer { - Width = 200, + Width = 220, Direction = FillDirection.Vertical, AutoSizeAxes = Axes.Y, Spacing = new Vector2(0, 10), @@ -253,15 +253,15 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline Direction = FillDirection.Horizontal, Spacing = new Vector2(5, 5), }, - bank = new LabelledTextBox + bank = new LabelledDropdown(padded: false) { - Label = "Bank Name", - SelectAllOnFocus = true, + Label = "Normal Bank", + Items = HitSampleInfo.ALL_BANKS, }, - additionBank = new LabelledTextBox + additionBank = new LabelledDropdown(padded: false) { Label = "Addition Bank", - SelectAllOnFocus = true, + Items = HitSampleInfo.ALL_BANKS, }, volume = new IndeterminateSliderWithTextBoxInput("Volume", new BindableInt(100) { @@ -272,8 +272,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline } }; - bank.TabbableContentContainer = flow; - additionBank.TabbableContentContainer = flow; volume.TabbableContentContainer = flow; // if the piece belongs to a currently selected object, assume that the user wants to change all selected objects. @@ -295,9 +293,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline setBank(val.NewValue); updatePrimaryBankState(); }); - // on commit, ensure that the value is correct by sourcing it from the objects' samples again. - // this ensures that committing empty text causes a revert to the previous value. - bank.OnCommit += (_, _) => updatePrimaryBankState(); updateAdditionBankState(); additionBank.Current.BindValueChanged(val => @@ -308,7 +303,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline setAdditionBank(val.NewValue); updateAdditionBankState(); }); - additionBank.OnCommit += (_, _) => updateAdditionBankState(); volume.Current.BindValueChanged(val => { @@ -338,15 +332,13 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline private void updatePrimaryBankState() { string? commonBank = getCommonBank(); - bank.Current.Value = commonBank; - bank.PlaceholderText = string.IsNullOrEmpty(commonBank) ? "(multiple)" : string.Empty; + bank.Current.Value = !string.IsNullOrEmpty(commonBank) ? commonBank : "(multiple)"; } private void updateAdditionBankState() { string? commonAdditionBank = getCommonAdditionBank(); - additionBank.PlaceholderText = string.IsNullOrEmpty(commonAdditionBank) ? "(multiple)" : string.Empty; - additionBank.Current.Value = commonAdditionBank; + additionBank.Current.Value = !string.IsNullOrEmpty(commonAdditionBank) ? commonAdditionBank : "(multiple)"; bool anyAdditions = allRelevantSamples.Any(o => o.samples.Any(s => s.Name != HitSampleInfo.HIT_NORMAL)); if (anyAdditions)