Skip to content

Commit

Permalink
fix shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
Awuwunya committed Aug 18, 2021
1 parent 4259388 commit c8849db
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
9 changes: 5 additions & 4 deletions src/settings/shortcuts.json5
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,12 @@
"ui.save": [ "ctrl+S" ], /* shortcut for saving the project */
"ui.saveas": [ "ctrl+shift+S" ], /* shortcut for saving the project as another file */

"ui.play": [ "Enter", "F5" ], /* shortcut for playing from start */
"ui.playpattern": [ "F6" ], /* shortcut for playing back the current pattern */
"ui.playstart": [ "shift+Enter" ], /* shortcut for playing from the start of the first pattern */
"ui.play": [ "Enter", "F5" ], /* shortcut for playing from the current pattern */
"ui.repeatpattern": [ "F6" ], /* shortcut for repeating the current pattern */
"ui.playrow": [ "F7" ], /* shortcut for playing from the current row */
"ui.playstep": [ "ctrl+Enter" ], /* shortcut for playing from the current row */
"ui.stop": [ "F5", "F6", "F7", "Enter" ], /* shortcut for stopping playback */
"ui.playstep": [ "ctrl+Enter" ], /* shortcut for stepping the current row */
"ui.stop": [ "F8", "Enter" ], /* shortcut for stopping playback */
"ui.record": [ "Space" ], /* shortcut for toggling record mode */

"ui.muteselected": [ "F9" ], /* shortcut for muting selected channel */
Expand Down
12 changes: 7 additions & 5 deletions src/ui/elements/playbuttonsbar/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ export class PlayBar implements UIComponent<HTMLDivElement> {
},
},
{
tooltip: "Start playback",
tooltip: "Start playback at current pattern.\nCTRL+Click = Start from current row.",
click: async(e:MouseEvent) => {
// change playback mode to play all
if(e.button === 0 && Tab.active && Tab.active.playMode !== PlayMode.PlayAll) {
if(await startPlayback(0, false, false)) {
const row = Tab.active.activeRow, cr = e.ctrlKey ? row : row - (row % (Tab.active.module?.patternRows ?? 1));

if(await startPlayback(cr, false, false)) {
Tab.active.playMode = PlayMode.PlayAll;
}
}
Expand All @@ -108,13 +110,13 @@ export class PlayBar implements UIComponent<HTMLDivElement> {
},
},
{
tooltip: "Repeat pattern",
tooltip: "Repeat playback of the current pattern.\nCTRL+Click = Start from current row.",
click: async(e:MouseEvent) => {
// change playback mode to play pattern
if(e.button === 0 && Tab.active && Tab.active.playMode !== PlayMode.PlayPattern) {
const row = Tab.active.activeRow;
const row = Tab.active.activeRow, cr = e.ctrlKey ? row : row - (row % (Tab.active.module?.patternRows ?? 1));

if(await startPlayback(row - (row % (Tab.active.module?.patternRows ?? 1)), true, false)) {
if(await startPlayback(cr, true, false)) {
Tab.active.playMode = PlayMode.PlayPattern;
}
}
Expand Down
22 changes: 19 additions & 3 deletions src/ui/windows/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,9 @@ async function loadMainShortcuts() {
}

// toggle play mode
if(await startPlayback(0, false, false)){
const row = Tab.active.activeRow;

if(await startPlayback(row - (row % (Tab.active.module?.patternRows ?? 1)), false, false)){
Tab.active.playMode = PlayMode.PlayAll;
}

Expand All @@ -365,15 +367,15 @@ async function loadMainShortcuts() {
}

// toggle play mode
if(await startPlayback(Tab.active.playMode === PlayMode.Stopped ? Tab.active.activeRow : -1, false, false)){
if(await startPlayback(Tab.active.activeRow, false, false)){
Tab.active.playMode = PlayMode.PlayAll;
}

return true;
},

/* shortcut for enabling play pattern mode */
playpattern: async() => {
repeatpattern: async() => {
if(!Tab.active || Tab.active.playMode === PlayMode.PlayPattern){
return false;
}
Expand All @@ -388,6 +390,20 @@ async function loadMainShortcuts() {
return true;
},

/* shortcut for enabling play pattern mode */
playstart: async() => {
if(!Tab.active || Tab.active.playMode === PlayMode.PlayPattern){
return false;
}

// toggle play mode
if(await startPlayback(0, false, false)){
Tab.active.playMode = PlayMode.PlayAll;
}

return true;
},

/* shortcut for enabling play mode */
playstep: async() => {
if(!Tab.active){
Expand Down

0 comments on commit c8849db

Please sign in to comment.