From ddbeb56f0f92544ee5463c94e4e6b3f69fe8d406 Mon Sep 17 00:00:00 2001 From: OliBomby Date: Wed, 23 Oct 2024 21:25:37 +0200 Subject: [PATCH] Show tooltip on auto normal bank when not usable --- .../Compose/Components/ComposeBlueprintContainer.cs | 11 +++++++++-- .../Edit/Compose/Components/EditorSelectionHandler.cs | 7 +++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs index fe9a6e6443..4331199a47 100644 --- a/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs @@ -68,7 +68,8 @@ namespace osu.Game.Screens.Edit.Compose.Components SampleBankTernaryStates = createSampleBankTernaryButtons(SelectionHandler.SelectionBankStates).ToArray(); SampleAdditionBankTernaryStates = createSampleBankTernaryButtons(SelectionHandler.SelectionAdditionBankStates).ToArray(); - SelectionHandler.SelectionAdditionBanksEnabled.BindValueChanged(_ => updateTernaryButtonTooltips()); + SelectionHandler.AutoSelectionBankEnabled.BindValueChanged(_ => updateAutoBankTernaryButtonTooltip(), true); + SelectionHandler.SelectionAdditionBanksEnabled.BindValueChanged(_ => updateAdditionBankTernaryButtonTooltips(), true); AddInternal(new DrawableRulesetDependenciesProvidingContainer(Composer.Ruleset) { @@ -290,7 +291,13 @@ namespace osu.Game.Screens.Edit.Compose.Components return null; } - private void updateTernaryButtonTooltips() + private void updateAutoBankTernaryButtonTooltip() + { + var autoBankButton = SampleBankTernaryStates.Single(t => t.Bindable == SelectionHandler.SelectionBankStates[EditorSelectionHandler.HIT_BANK_AUTO]); + autoBankButton.Tooltip = !SelectionHandler.AutoSelectionBankEnabled.Value ? "Auto normal bank can only be used during hit object placement" : string.Empty; + } + + private void updateAdditionBankTernaryButtonTooltips() { foreach (var ternaryButton in SampleAdditionBankTernaryStates) ternaryButton.Tooltip = !SelectionHandler.SelectionAdditionBanksEnabled.Value ? "Add an addition sample first to be able to set a bank" : string.Empty; diff --git a/osu.Game/Screens/Edit/Compose/Components/EditorSelectionHandler.cs b/osu.Game/Screens/Edit/Compose/Components/EditorSelectionHandler.cs index beead572e6..2d5341e85e 100644 --- a/osu.Game/Screens/Edit/Compose/Components/EditorSelectionHandler.cs +++ b/osu.Game/Screens/Edit/Compose/Components/EditorSelectionHandler.cs @@ -64,6 +64,11 @@ namespace osu.Game.Screens.Edit.Compose.Components /// public readonly Dictionary> SelectionAdditionBankStates = new Dictionary>(); + /// + /// Whether there is no selection and the auto can be used. + /// + public readonly Bindable AutoSelectionBankEnabled = new Bindable(); + /// /// Whether the selection contains any addition samples and the can be used. /// @@ -253,6 +258,7 @@ namespace osu.Game.Screens.Edit.Compose.Components private void resetTernaryStates() { + AutoSelectionBankEnabled.Value = true; SelectionBankStates[HIT_BANK_AUTO].Value = TernaryState.True; SelectionAdditionBankStates[HIT_BANK_AUTO].Value = TernaryState.True; } @@ -263,6 +269,7 @@ namespace osu.Game.Screens.Edit.Compose.Components protected virtual void UpdateTernaryStates() { SelectionNewComboState.Value = GetStateFromSelection(SelectedItems.OfType(), h => h.NewCombo); + AutoSelectionBankEnabled.Value = SelectedItems.Count == 0; var samplesInSelection = SelectedItems.SelectMany(enumerateAllSamples).ToArray();