2020-10-01 17:49:48 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2023-05-08 21:14:25 +08:00
|
|
|
using System;
|
2021-11-14 00:21:48 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2023-05-08 21:08:40 +08:00
|
|
|
using Humanizer;
|
2020-10-01 17:49:48 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
2021-09-14 17:51:22 +08:00
|
|
|
using osu.Framework.Extensions;
|
2021-11-14 00:21:48 +08:00
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
2021-09-14 17:51:22 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
using osu.Framework.Input.Events;
|
2023-04-26 19:45:58 +08:00
|
|
|
using osu.Game.Audio;
|
2023-04-26 00:12:53 +08:00
|
|
|
using osu.Game.Graphics;
|
2023-05-08 21:08:40 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2021-09-14 17:51:22 +08:00
|
|
|
using osu.Game.Graphics.UserInterfaceV2;
|
2021-09-14 18:21:23 +08:00
|
|
|
using osu.Game.Rulesets.Objects;
|
2023-05-08 21:08:40 +08:00
|
|
|
using osu.Game.Screens.Edit.Components.TernaryButtons;
|
2021-09-14 17:51:22 +08:00
|
|
|
using osu.Game.Screens.Edit.Timing;
|
2021-11-14 01:09:40 +08:00
|
|
|
using osuTK;
|
2023-04-26 00:12:53 +08:00
|
|
|
using osuTK.Graphics;
|
2023-05-08 21:08:40 +08:00
|
|
|
using osuTK.Input;
|
2020-10-01 17:49:48 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|
|
|
{
|
2021-09-14 17:51:22 +08:00
|
|
|
public partial class SamplePointPiece : HitObjectPointPiece, IHasPopover
|
2020-10-01 17:49:48 +08:00
|
|
|
{
|
2021-11-13 23:58:24 +08:00
|
|
|
public readonly HitObject HitObject;
|
2020-10-01 18:29:34 +08:00
|
|
|
|
2021-09-14 18:21:23 +08:00
|
|
|
public SamplePointPiece(HitObject hitObject)
|
2020-10-01 17:49:48 +08:00
|
|
|
{
|
2021-11-13 23:58:24 +08:00
|
|
|
HitObject = hitObject;
|
2020-10-01 17:49:48 +08:00
|
|
|
}
|
|
|
|
|
2023-05-31 20:33:06 +08:00
|
|
|
public bool AlternativeColor { get; init; }
|
|
|
|
|
|
|
|
protected override Color4 GetRepresentingColour(OsuColour colours) => AlternativeColor ? colours.Purple : colours.Pink;
|
2023-04-26 00:12:53 +08:00
|
|
|
|
2020-10-01 17:49:48 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2022-01-15 08:06:39 +08:00
|
|
|
private void load()
|
2020-10-01 17:49:48 +08:00
|
|
|
{
|
2023-05-08 17:54:33 +08:00
|
|
|
HitObject.DefaultsApplied += _ => updateText();
|
|
|
|
updateText();
|
2021-09-10 12:44:39 +08:00
|
|
|
}
|
2020-10-01 17:49:48 +08:00
|
|
|
|
2021-09-14 17:51:22 +08:00
|
|
|
protected override bool OnClick(ClickEvent e)
|
|
|
|
{
|
|
|
|
this.ShowPopover();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-09-10 12:44:39 +08:00
|
|
|
private void updateText()
|
|
|
|
{
|
2023-05-08 19:16:30 +08:00
|
|
|
Label.Text = $"{abbreviateBank(GetBankValue(GetSamples()))} {GetVolumeValue(GetSamples())}";
|
|
|
|
}
|
|
|
|
|
|
|
|
private static string? abbreviateBank(string? bank)
|
|
|
|
{
|
|
|
|
return bank switch
|
|
|
|
{
|
|
|
|
"normal" => "N",
|
|
|
|
"soft" => "S",
|
|
|
|
"drum" => "D",
|
|
|
|
_ => bank
|
|
|
|
};
|
2023-04-26 19:45:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public static string? GetBankValue(IEnumerable<HitSampleInfo> samples)
|
|
|
|
{
|
2023-05-08 22:12:03 +08:00
|
|
|
return samples.FirstOrDefault(o => o.Name == HitSampleInfo.HIT_NORMAL)?.Bank;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string? GetAdditionBankValue(IEnumerable<HitSampleInfo> samples)
|
|
|
|
{
|
|
|
|
return samples.FirstOrDefault(o => o.Name != HitSampleInfo.HIT_NORMAL)?.Bank ?? GetBankValue(samples);
|
2023-04-26 19:45:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public static int GetVolumeValue(ICollection<HitSampleInfo> samples)
|
|
|
|
{
|
|
|
|
return samples.Count == 0 ? 0 : samples.Max(o => o.Volume);
|
2020-10-01 17:49:48 +08:00
|
|
|
}
|
2021-09-14 17:51:22 +08:00
|
|
|
|
2023-05-08 18:38:53 +08:00
|
|
|
protected virtual IList<HitSampleInfo> GetSamples() => HitObject.Samples;
|
|
|
|
|
|
|
|
public virtual Popover GetPopover() => new SampleEditPopover(HitObject);
|
2021-09-14 17:51:22 +08:00
|
|
|
|
|
|
|
public partial class SampleEditPopover : OsuPopover
|
|
|
|
{
|
2021-09-14 18:21:23 +08:00
|
|
|
private readonly HitObject hitObject;
|
2021-09-14 17:51:22 +08:00
|
|
|
|
2021-11-14 00:21:48 +08:00
|
|
|
private LabelledTextBox bank = null!;
|
2023-05-08 22:12:03 +08:00
|
|
|
private LabelledTextBox additionBank = null!;
|
2021-11-14 00:21:48 +08:00
|
|
|
private IndeterminateSliderWithTextBoxInput<int> volume = null!;
|
2021-09-14 17:51:22 +08:00
|
|
|
|
2023-05-08 21:08:40 +08:00
|
|
|
private FillFlowContainer togglesCollection = null!;
|
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
private HitObject[] relevantObjects = null!;
|
|
|
|
private IList<HitSampleInfo>[] relevantSamples = null!;
|
|
|
|
|
2023-05-08 18:38:53 +08:00
|
|
|
protected virtual IList<HitSampleInfo> GetSamples(HitObject ho) => ho.Samples;
|
|
|
|
|
2021-09-14 17:51:22 +08:00
|
|
|
[Resolved(canBeNull: true)]
|
2021-11-14 00:21:48 +08:00
|
|
|
private EditorBeatmap beatmap { get; set; } = null!;
|
2021-09-14 17:51:22 +08:00
|
|
|
|
2021-09-14 18:21:23 +08:00
|
|
|
public SampleEditPopover(HitObject hitObject)
|
2021-09-14 17:51:22 +08:00
|
|
|
{
|
2021-09-14 18:21:23 +08:00
|
|
|
this.hitObject = hitObject;
|
2021-09-14 17:51:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
2022-03-06 08:43:56 +08:00
|
|
|
FillFlowContainer flow;
|
|
|
|
|
2021-09-14 17:51:22 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2022-03-06 08:43:56 +08:00
|
|
|
flow = new FillFlowContainer
|
2021-09-14 17:51:22 +08:00
|
|
|
{
|
|
|
|
Width = 200,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2021-11-14 01:09:40 +08:00
|
|
|
Spacing = new Vector2(0, 10),
|
2021-09-14 17:51:22 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2023-05-08 21:08:40 +08:00
|
|
|
togglesCollection = new FillFlowContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Spacing = new Vector2(5, 5),
|
|
|
|
},
|
2021-09-14 17:51:22 +08:00
|
|
|
bank = new LabelledTextBox
|
|
|
|
{
|
|
|
|
Label = "Bank Name",
|
|
|
|
},
|
2023-05-08 22:12:03 +08:00
|
|
|
additionBank = new LabelledTextBox
|
|
|
|
{
|
|
|
|
Label = "Addition Bank",
|
|
|
|
},
|
2023-04-26 19:45:58 +08:00
|
|
|
volume = new IndeterminateSliderWithTextBoxInput<int>("Volume", new BindableInt(100)
|
|
|
|
{
|
|
|
|
MinValue = 0,
|
|
|
|
MaxValue = 100,
|
|
|
|
})
|
2021-09-14 17:51:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-03-06 08:43:56 +08:00
|
|
|
bank.TabbableContentContainer = flow;
|
2023-05-08 22:12:03 +08:00
|
|
|
additionBank.TabbableContentContainer = flow;
|
2022-03-06 08:43:56 +08:00
|
|
|
volume.TabbableContentContainer = flow;
|
|
|
|
|
2021-11-14 00:21:48 +08:00
|
|
|
// if the piece belongs to a currently selected object, assume that the user wants to change all selected objects.
|
|
|
|
// if the piece belongs to an unselected object, operate on that object alone, independently of the selection.
|
2023-06-01 02:00:19 +08:00
|
|
|
relevantObjects = (beatmap.SelectedHitObjects.Contains(hitObject) ? beatmap.SelectedHitObjects : hitObject.Yield()).ToArray();
|
|
|
|
relevantSamples = relevantObjects.Select(GetSamples).ToArray();
|
2021-11-14 00:21:48 +08:00
|
|
|
|
|
|
|
// even if there are multiple objects selected, we can still display sample volume or bank if they all have the same value.
|
2023-06-01 02:00:19 +08:00
|
|
|
string? commonBank = getCommonBank();
|
2021-11-14 00:21:48 +08:00
|
|
|
if (!string.IsNullOrEmpty(commonBank))
|
|
|
|
bank.Current.Value = commonBank;
|
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
int? commonVolume = getCommonVolume();
|
2021-11-14 00:21:48 +08:00
|
|
|
if (commonVolume != null)
|
|
|
|
volume.Current.Value = commonVolume.Value;
|
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
updateBankPlaceholderText();
|
2021-11-14 01:06:32 +08:00
|
|
|
bank.Current.BindValueChanged(val =>
|
|
|
|
{
|
2023-06-01 02:00:19 +08:00
|
|
|
updateBank(val.NewValue);
|
|
|
|
updateBankPlaceholderText();
|
2021-11-14 01:06:32 +08:00
|
|
|
});
|
2023-04-26 19:45:58 +08:00
|
|
|
// on commit, ensure that the value is correct by sourcing it from the objects' samples again.
|
2021-11-14 01:06:32 +08:00
|
|
|
// this ensures that committing empty text causes a revert to the previous value.
|
2023-06-01 02:00:19 +08:00
|
|
|
bank.OnCommit += (_, _) => bank.Current.Value = getCommonBank();
|
2021-11-14 01:06:32 +08:00
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
updateAdditionBankPlaceholderText();
|
|
|
|
updateAdditionBankText();
|
2023-06-01 02:00:45 +08:00
|
|
|
updateAdditionBankActivated();
|
2023-05-08 22:12:03 +08:00
|
|
|
additionBank.Current.BindValueChanged(val =>
|
|
|
|
{
|
2023-06-01 02:00:19 +08:00
|
|
|
updateAdditionBank(val.NewValue);
|
|
|
|
updateAdditionBankPlaceholderText();
|
2023-05-08 22:12:03 +08:00
|
|
|
});
|
2023-06-01 02:00:19 +08:00
|
|
|
additionBank.OnCommit += (_, _) => updateAdditionBankText();
|
2023-05-08 22:12:03 +08:00
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
volume.Current.BindValueChanged(val => updateVolume(val.NewValue));
|
2023-05-08 21:08:40 +08:00
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
createStateBindables();
|
|
|
|
updateTernaryStates();
|
2023-05-08 21:08:40 +08:00
|
|
|
togglesCollection.AddRange(createTernaryButtons().Select(b => new DrawableTernaryButton(b) { RelativeSizeAxes = Axes.None, Size = new Vector2(40, 40) }));
|
2021-11-14 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
2022-05-11 14:55:34 +08:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
ScheduleAfterChildren(() => GetContainingInputManager().ChangeFocus(volume));
|
|
|
|
}
|
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
private string? getCommonBank() => relevantSamples.Select(GetBankValue).Distinct().Count() == 1 ? GetBankValue(relevantSamples.First()) : null;
|
|
|
|
private string? getCommonAdditionBank() => relevantSamples.Select(GetAdditionBankValue).Distinct().Count() == 1 ? GetAdditionBankValue(relevantSamples.First()) : null;
|
|
|
|
private int? getCommonVolume() => relevantSamples.Select(GetVolumeValue).Distinct().Count() == 1 ? GetVolumeValue(relevantSamples.First()) : null;
|
2021-11-14 01:06:32 +08:00
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
private void update(Action<HitObject, IList<HitSampleInfo>> updateAction)
|
2021-11-14 00:21:48 +08:00
|
|
|
{
|
|
|
|
beatmap.BeginChange();
|
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
foreach (var h in relevantObjects)
|
2021-11-14 00:21:48 +08:00
|
|
|
{
|
2023-05-08 19:05:53 +08:00
|
|
|
var samples = GetSamples(h);
|
2023-05-08 21:14:25 +08:00
|
|
|
updateAction(h, samples);
|
|
|
|
beatmap.Update(h);
|
|
|
|
}
|
|
|
|
|
|
|
|
beatmap.EndChange();
|
|
|
|
}
|
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
private void updateBank(string? newBank)
|
2023-05-08 21:14:25 +08:00
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(newBank))
|
|
|
|
return;
|
2023-05-08 19:05:53 +08:00
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
update((_, samples) =>
|
2023-05-08 21:14:25 +08:00
|
|
|
{
|
2023-05-08 19:05:53 +08:00
|
|
|
for (int i = 0; i < samples.Count; i++)
|
2023-04-26 19:45:58 +08:00
|
|
|
{
|
2023-05-08 22:12:03 +08:00
|
|
|
if (samples[i].Name != HitSampleInfo.HIT_NORMAL) continue;
|
|
|
|
|
|
|
|
samples[i] = samples[i].With(newBank: newBank);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
private void updateAdditionBank(string? newBank)
|
2023-05-08 22:12:03 +08:00
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(newBank))
|
|
|
|
return;
|
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
update((_, samples) =>
|
2023-05-08 22:12:03 +08:00
|
|
|
{
|
|
|
|
for (int i = 0; i < samples.Count; i++)
|
|
|
|
{
|
|
|
|
if (samples[i].Name == HitSampleInfo.HIT_NORMAL) continue;
|
|
|
|
|
2023-05-08 19:05:53 +08:00
|
|
|
samples[i] = samples[i].With(newBank: newBank);
|
2023-04-26 19:45:58 +08:00
|
|
|
}
|
2023-05-08 21:14:25 +08:00
|
|
|
});
|
2021-11-14 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
private void updateBankPlaceholderText()
|
2021-11-14 01:06:32 +08:00
|
|
|
{
|
2023-06-01 02:00:19 +08:00
|
|
|
string? commonBank = getCommonBank();
|
2022-05-17 16:42:46 +08:00
|
|
|
bank.PlaceholderText = string.IsNullOrEmpty(commonBank) ? "(multiple)" : string.Empty;
|
2021-11-14 01:06:32 +08:00
|
|
|
}
|
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
private void updateAdditionBankPlaceholderText()
|
2023-05-08 22:12:03 +08:00
|
|
|
{
|
2023-06-01 02:00:19 +08:00
|
|
|
string? commonAdditionBank = getCommonAdditionBank();
|
2023-05-08 22:12:03 +08:00
|
|
|
additionBank.PlaceholderText = string.IsNullOrEmpty(commonAdditionBank) ? "(multiple)" : string.Empty;
|
|
|
|
}
|
|
|
|
|
2023-06-01 02:00:45 +08:00
|
|
|
private void updateAdditionBankActivated()
|
|
|
|
{
|
|
|
|
bool anyAdditions = relevantSamples.Any(o => o.Any(s => s.Name != HitSampleInfo.HIT_NORMAL));
|
|
|
|
if (anyAdditions)
|
|
|
|
additionBank.Show();
|
|
|
|
else
|
|
|
|
additionBank.Hide();
|
|
|
|
}
|
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
private void updateAdditionBankText()
|
|
|
|
{
|
|
|
|
if (additionBank.Current.Disabled) return;
|
|
|
|
|
|
|
|
string? commonAdditionBank = getCommonAdditionBank();
|
|
|
|
if (string.IsNullOrEmpty(commonAdditionBank)) return;
|
|
|
|
|
|
|
|
additionBank.Current.Value = commonAdditionBank;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateVolume(int? newVolume)
|
2021-11-14 00:21:48 +08:00
|
|
|
{
|
|
|
|
if (newVolume == null)
|
|
|
|
return;
|
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
update((_, samples) =>
|
2021-11-14 00:21:48 +08:00
|
|
|
{
|
2023-05-08 19:05:53 +08:00
|
|
|
for (int i = 0; i < samples.Count; i++)
|
2023-04-26 19:45:58 +08:00
|
|
|
{
|
2023-05-08 19:05:53 +08:00
|
|
|
samples[i] = samples[i].With(newVolume: newVolume.Value);
|
2023-04-26 19:45:58 +08:00
|
|
|
}
|
2023-05-08 21:14:25 +08:00
|
|
|
});
|
2021-09-14 17:51:22 +08:00
|
|
|
}
|
2023-05-08 21:08:40 +08:00
|
|
|
|
|
|
|
#region hitsound toggles
|
|
|
|
|
|
|
|
private readonly Dictionary<string, Bindable<TernaryState>> selectionSampleStates = new Dictionary<string, Bindable<TernaryState>>();
|
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
private void createStateBindables()
|
2023-05-08 21:08:40 +08:00
|
|
|
{
|
|
|
|
foreach (string sampleName in HitSampleInfo.AllAdditions)
|
|
|
|
{
|
|
|
|
var bindable = new Bindable<TernaryState>
|
|
|
|
{
|
|
|
|
Description = sampleName.Replace("hit", string.Empty).Titleize()
|
|
|
|
};
|
|
|
|
|
|
|
|
bindable.ValueChanged += state =>
|
|
|
|
{
|
|
|
|
switch (state.NewValue)
|
|
|
|
{
|
|
|
|
case TernaryState.False:
|
2023-06-01 02:00:19 +08:00
|
|
|
removeHitSample(sampleName);
|
2023-05-08 21:08:40 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TernaryState.True:
|
2023-06-01 02:00:19 +08:00
|
|
|
addHitSample(sampleName);
|
2023-05-08 21:08:40 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
selectionSampleStates[sampleName] = bindable;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
private void updateTernaryStates()
|
2023-05-08 21:08:40 +08:00
|
|
|
{
|
|
|
|
foreach ((string sampleName, var bindable) in selectionSampleStates)
|
|
|
|
{
|
2023-06-01 02:00:19 +08:00
|
|
|
bindable.Value = SelectionHandler<HitObject>.GetStateFromSelection(relevantObjects, h => GetSamples(h).Any(s => s.Name == sampleName));
|
2023-05-08 21:08:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private IEnumerable<TernaryButton> createTernaryButtons()
|
|
|
|
{
|
|
|
|
foreach ((string sampleName, var bindable) in selectionSampleStates)
|
|
|
|
yield return new TernaryButton(bindable, string.Empty, () => ComposeBlueprintContainer.GetIconForSample(sampleName));
|
|
|
|
}
|
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
private void addHitSample(string sampleName)
|
2023-05-08 21:08:40 +08:00
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(sampleName))
|
|
|
|
return;
|
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
update((h, samples) =>
|
2023-05-08 21:08:40 +08:00
|
|
|
{
|
|
|
|
// Make sure there isn't already an existing sample
|
|
|
|
if (samples.Any(s => s.Name == sampleName))
|
|
|
|
return;
|
|
|
|
|
2023-05-31 22:28:43 +08:00
|
|
|
// First try inheriting the sample info from the node samples instead of the samples of the hitobject
|
|
|
|
var relevantSample = samples.FirstOrDefault(s => s.Name != HitSampleInfo.HIT_NORMAL) ?? samples.FirstOrDefault();
|
|
|
|
samples.Add(relevantSample?.With(sampleName) ?? h.CreateHitSampleInfo(sampleName));
|
2023-05-08 21:14:25 +08:00
|
|
|
});
|
2023-06-01 02:00:19 +08:00
|
|
|
|
2023-06-01 02:00:45 +08:00
|
|
|
updateAdditionBankActivated();
|
2023-06-01 02:00:19 +08:00
|
|
|
updateAdditionBankText();
|
2023-05-08 21:08:40 +08:00
|
|
|
}
|
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
private void removeHitSample(string sampleName)
|
2023-05-08 21:08:40 +08:00
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(sampleName))
|
|
|
|
return;
|
|
|
|
|
2023-06-01 02:00:19 +08:00
|
|
|
update((_, samples) =>
|
2023-05-08 21:08:40 +08:00
|
|
|
{
|
|
|
|
for (int i = 0; i < samples.Count; i++)
|
|
|
|
{
|
|
|
|
if (samples[i].Name == sampleName)
|
|
|
|
samples.RemoveAt(i--);
|
|
|
|
}
|
2023-05-08 21:14:25 +08:00
|
|
|
});
|
2023-06-01 02:00:19 +08:00
|
|
|
|
|
|
|
updateAdditionBankText();
|
2023-06-01 02:00:45 +08:00
|
|
|
updateAdditionBankActivated();
|
2023-05-08 21:08:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override bool OnKeyDown(KeyDownEvent e)
|
|
|
|
{
|
|
|
|
if (e.ControlPressed || e.AltPressed || e.SuperPressed || e.ShiftPressed || !checkRightToggleFromKey(e.Key, out int rightIndex))
|
|
|
|
return base.OnKeyDown(e);
|
|
|
|
|
|
|
|
var item = togglesCollection.ElementAtOrDefault(rightIndex);
|
|
|
|
|
|
|
|
if (item is not DrawableTernaryButton button) return base.OnKeyDown(e);
|
|
|
|
|
|
|
|
button.Button.Toggle();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private bool checkRightToggleFromKey(Key key, out int index)
|
|
|
|
{
|
|
|
|
switch (key)
|
|
|
|
{
|
|
|
|
case Key.W:
|
|
|
|
index = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Key.E:
|
|
|
|
index = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Key.R:
|
|
|
|
index = 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
index = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return index >= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
2021-09-14 17:51:22 +08:00
|
|
|
}
|
2020-10-01 17:49:48 +08:00
|
|
|
}
|
|
|
|
}
|