Skip to content

Commit

Permalink
Show tooltip on auto normal bank when not usable
Browse files Browse the repository at this point in the history
  • Loading branch information
OliBomby committed Oct 23, 2024
1 parent 5939c78 commit ddbeb56
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ private void load()
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)
{
Expand Down Expand Up @@ -290,7 +291,13 @@ public static Drawable GetIconForSample(string sampleName)
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ private void load()
/// </summary>
public readonly Dictionary<string, Bindable<TernaryState>> SelectionAdditionBankStates = new Dictionary<string, Bindable<TernaryState>>();

/// <summary>
/// Whether there is no selection and the auto <see cref="SelectionBankStates"/> can be used.
/// </summary>
public readonly Bindable<bool> AutoSelectionBankEnabled = new Bindable<bool>();

/// <summary>
/// Whether the selection contains any addition samples and the <see cref="SelectionAdditionBankStates"/> can be used.
/// </summary>
Expand Down Expand Up @@ -253,6 +258,7 @@ private void createStateBindables()

private void resetTernaryStates()
{
AutoSelectionBankEnabled.Value = true;
SelectionBankStates[HIT_BANK_AUTO].Value = TernaryState.True;
SelectionAdditionBankStates[HIT_BANK_AUTO].Value = TernaryState.True;
}
Expand All @@ -263,6 +269,7 @@ private void resetTernaryStates()
protected virtual void UpdateTernaryStates()
{
SelectionNewComboState.Value = GetStateFromSelection(SelectedItems.OfType<IHasComboInformation>(), h => h.NewCombo);
AutoSelectionBankEnabled.Value = SelectedItems.Count == 0;

var samplesInSelection = SelectedItems.SelectMany(enumerateAllSamples).ToArray();

Expand Down

0 comments on commit ddbeb56

Please sign in to comment.