1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-25 14:10:48 +08:00

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.
This commit is contained in:
Bartłomiej Dach
2025-10-15 10:30:03 +02:00
Unverified
parent fa7bd482d2
commit 1f2f86b016
5 changed files with 27 additions and 24 deletions
@@ -11,7 +11,7 @@ namespace osu.Game.Tests.Visual.UserInterface
{
[Test]
public void TestLabelledDropdown()
=> AddStep(@"create dropdown", () => Child = new LabelledDropdown<string>
=> AddStep(@"create dropdown", () => Child = new LabelledDropdown<string>(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<BeatmapOnlineStatus>
=> AddStep(@"create dropdown", () => Child = new LabelledEnumDropdown<BeatmapOnlineStatus>(true)
{
Label = @"Beatmap status",
Description = @"This is a description"
@@ -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<RulesetInfo?>
new LabelledDropdown<RulesetInfo?>(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
{
@@ -9,8 +9,8 @@ namespace osu.Game.Graphics.UserInterfaceV2
{
public partial class LabelledDropdown<TItem> : LabelledComponent<OsuDropdown<TItem>, 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<TItem> CreateComponent() => CreateDropdown().With(d =>
{
d.RelativeSizeAxes = Axes.X;
d.Width = 0.5f;
});
protected virtual OsuDropdown<TItem> CreateDropdown() => new OsuDropdown<TItem>();
@@ -9,6 +9,11 @@ namespace osu.Game.Graphics.UserInterfaceV2
public partial class LabelledEnumDropdown<TEnum> : LabelledDropdown<TEnum>
where TEnum : struct, Enum
{
public LabelledEnumDropdown(bool padded)
: base(padded)
{
}
protected override OsuDropdown<TEnum> CreateDropdown() => new OsuEnumDropdown<TEnum>();
}
}
@@ -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<string> bank = null!;
private LabelledDropdown<string> additionBank = null!;
private IndeterminateSliderWithTextBoxInput<int> 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<string>(padded: false)
{
Label = "Bank Name",
SelectAllOnFocus = true,
Label = "Normal Bank",
Items = HitSampleInfo.ALL_BANKS,
},
additionBank = new LabelledTextBox
additionBank = new LabelledDropdown<string>(padded: false)
{
Label = "Addition Bank",
SelectAllOnFocus = true,
Items = HitSampleInfo.ALL_BANKS,
},
volume = new IndeterminateSliderWithTextBoxInput<int>("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)