Skip to content

Commit

Permalink
Add hotkeys for measure and beat changes
Browse files Browse the repository at this point in the history
Default settings:
* up/down to change measures by -1/1
* left/right to change beat by -1/1
* hold ctrl to multiply the value difference by the high delta (default = 2)
  • Loading branch information
Raymonf committed Dec 3, 2023
1 parent 346f74f commit 37d75e3
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 4 deletions.
11 changes: 11 additions & 0 deletions BAKKA_Editor/UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ public class HotkeySettings
public int ChainHotkey { get; set; } = Convert.ToInt32(Key.D6, DefaultParsingCulture);
public int HoldHotkey { get; set; } = Convert.ToInt32(Key.D7, DefaultParsingCulture);
public int PlayHotkey { get; set; } = Convert.ToInt32(Key.P, DefaultParsingCulture);

public bool EnableMeasureChangeHotkeys { get; set; } = true;
public int MeasureDecreaseHotkey { get; set; } = Convert.ToInt32(Key.Left, DefaultParsingCulture);
public int MeasureIncreaseHotkey { get; set; } = Convert.ToInt32(Key.Right, DefaultParsingCulture);
public bool EnableBeatChangeHotkeys { get; set; } = true;
public int BeatDecreaseHotkey { get; set; } = Convert.ToInt32(Key.Down, DefaultParsingCulture);
public int BeatIncreaseHotkey { get; set; } = Convert.ToInt32(Key.Up, DefaultParsingCulture);
public int MeasureChangeHotkeyDelta { get; set; } = 1;
public int MeasureChangeHotkeyHighDelta { get; set; } = 2;
public int BeatChangeHotkeyDelta { get; set; } = 1;
public int BeatChangeHotkeyHighDelta { get; set; } = 2;
}

public class SoundSettings
Expand Down
51 changes: 47 additions & 4 deletions BAKKA_Editor/Views/MainView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3158,6 +3158,47 @@ protected void OnPreviewKeyDown(object? sender, KeyEventArgs e)

try
{
if (userSettings.HotkeySettings.EnableBeatChangeHotkeys && !e.KeyModifiers.HasFlag(KeyModifiers.Shift))
{
var hkSettings = userSettings.HotkeySettings;

var intKey = (int) e.Key;
if (intKey == hkSettings.BeatIncreaseHotkey || intKey == hkSettings.BeatDecreaseHotkey)
{
// beat change
var delta = intKey == hkSettings.BeatIncreaseHotkey ? 1 : -1;
if (e.KeyModifiers.HasFlag(KeyModifiers.Control))
delta *= hkSettings.BeatChangeHotkeyHighDelta;
if (_vm.Beat1Numeric + delta >= _vm.Beat1NumericMinimum &&
_vm.Beat1Numeric + delta <= _vm.Beat1NumericMaximum)
{
_vm.Beat1Numeric += delta;
}
else
{
// wrap around
_vm.Beat1Numeric = _vm.Beat2Numeric + delta;
}

e.Handled = true;
return;
}

if (intKey == hkSettings.MeasureIncreaseHotkey || intKey == hkSettings.MeasureDecreaseHotkey)
{
// measure change
var delta = intKey == hkSettings.MeasureIncreaseHotkey ? hkSettings.MeasureChangeHotkeyDelta : -hkSettings.MeasureChangeHotkeyDelta;
if (e.KeyModifiers.HasFlag(KeyModifiers.Control))
delta *= hkSettings.MeasureChangeHotkeyHighDelta;
if (_vm.MeasureNumeric + delta >= _vm.MeasureNumericMinimum &&
_vm.MeasureNumeric + delta <= _vm.MeasureNumericMaximum)
_vm.MeasureNumeric += delta;

e.Handled = true;
return;
}
}

switch (e.Key)
{
case Key.Space:
Expand All @@ -3177,10 +3218,12 @@ protected void OnPreviewKeyDown(object? sender, KeyEventArgs e)
return;
case Key.Up:
case Key.Down:
if (!e.KeyModifiers.HasFlag(KeyModifiers.Shift))
return;
playbackVolumeChange(e.Key == Key.Up);
e.Handled = true;
if (e.KeyModifiers.HasFlag(KeyModifiers.Shift))
{
// volume change
playbackVolumeChange(e.Key == Key.Up);
e.Handled = true;
}
return;
default:
var key = (int) e.Key;
Expand Down

0 comments on commit 37d75e3

Please sign in to comment.