1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 00:37:26 +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) if (e.ControlPressed || e.SuperPressed)
return false; return false;
bool handled = false;
if (checkLeftToggleFromKey(e.Key, out int leftIndex)) if (checkLeftToggleFromKey(e.Key, out int leftIndex))
{ {
var item = toolboxCollection.Items.ElementAtOrDefault(leftIndex); var item = toolboxCollection.Items.ElementAtOrDefault(leftIndex);
@ -387,20 +389,30 @@ namespace osu.Game.Rulesets.Edit
if (checkRightToggleFromKey(e.Key, out int rightIndex)) if (checkRightToggleFromKey(e.Key, out int rightIndex))
{ {
var item = e.AltPressed if (e.ShiftPressed || e.AltPressed)
? sampleAdditionBankTogglesCollection.ElementAtOrDefault(rightIndex) {
: e.ShiftPressed if (e.ShiftPressed)
? sampleBankTogglesCollection.ElementAtOrDefault(rightIndex) attemptToggle(rightIndex, sampleBankTogglesCollection);
: togglesCollection.ElementAtOrDefault(rightIndex);
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) if (item is DrawableTernaryButton button)
{ {
button.Button.Toggle(); button.Button.Toggle();
return true; handled = true;
} }
} }
return base.OnKeyDown(e);
} }
private bool checkLeftToggleFromKey(Key key, out int index) private bool checkLeftToggleFromKey(Key key, out int index)

View File

@ -381,21 +381,28 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
protected override bool OnKeyDown(KeyDownEvent e) 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); return base.OnKeyDown(e);
if (e.ShiftPressed) if (e.ShiftPressed || e.AltPressed)
{ {
string? newBank = banks.ElementAtOrDefault(rightIndex); string? newBank = banks.ElementAtOrDefault(rightIndex);
if (string.IsNullOrEmpty(newBank)) if (string.IsNullOrEmpty(newBank))
return true; return true;
if (e.ShiftPressed)
{
setBank(newBank); setBank(newBank);
updatePrimaryBankState(); updatePrimaryBankState();
}
if (e.AltPressed)
{
setAdditionBank(newBank); setAdditionBank(newBank);
updateAdditionBankState(); updateAdditionBankState();
} }
}
else else
{ {
var item = togglesCollection.ElementAtOrDefault(rightIndex); var item = togglesCollection.ElementAtOrDefault(rightIndex);