1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 21:17:25 +08:00

allow hotkeys in sample point piece

This commit is contained in:
OliBomby 2024-07-14 20:59:46 +02:00
parent 952540024e
commit 5e86a01e5e
2 changed files with 33 additions and 14 deletions

View File

@ -373,6 +373,8 @@ namespace osu.Game.Rulesets.Edit
if (e.ControlPressed || e.SuperPressed)
return false;
bool handled = false;
if (checkLeftToggleFromKey(e.Key, out int leftIndex))
{
var item = toolboxCollection.Items.ElementAtOrDefault(leftIndex);
@ -387,20 +389,30 @@ namespace osu.Game.Rulesets.Edit
if (checkRightToggleFromKey(e.Key, out int rightIndex))
{
var item = e.AltPressed
? sampleAdditionBankTogglesCollection.ElementAtOrDefault(rightIndex)
: e.ShiftPressed
? sampleBankTogglesCollection.ElementAtOrDefault(rightIndex)
: togglesCollection.ElementAtOrDefault(rightIndex);
if (e.ShiftPressed || e.AltPressed)
{
if (e.ShiftPressed)
attemptToggle(rightIndex, sampleBankTogglesCollection);
if (e.AltPressed)
attemptToggle(rightIndex, sampleAdditionBankTogglesCollection);
}
else
attemptToggle(rightIndex, togglesCollection);
}
return handled || base.OnKeyDown(e);
void attemptToggle(int index, FillFlowContainer collection)
{
var item = collection.ElementAtOrDefault(index);
if (item is DrawableTernaryButton button)
{
button.Button.Toggle();
return true;
handled = true;
}
}
return base.OnKeyDown(e);
}
private bool checkLeftToggleFromKey(Key key, out int index)

View File

@ -381,20 +381,27 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
protected override bool OnKeyDown(KeyDownEvent e)
{
if (e.ControlPressed || e.AltPressed || e.SuperPressed || !checkRightToggleFromKey(e.Key, out int rightIndex))
if (e.ControlPressed || e.SuperPressed || !checkRightToggleFromKey(e.Key, out int rightIndex))
return base.OnKeyDown(e);
if (e.ShiftPressed)
if (e.ShiftPressed || e.AltPressed)
{
string? newBank = banks.ElementAtOrDefault(rightIndex);
if (string.IsNullOrEmpty(newBank))
return true;
setBank(newBank);
updatePrimaryBankState();
setAdditionBank(newBank);
updateAdditionBankState();
if (e.ShiftPressed)
{
setBank(newBank);
updatePrimaryBankState();
}
if (e.AltPressed)
{
setAdditionBank(newBank);
updateAdditionBankState();
}
}
else
{