Skip to content

Commit

Permalink
Hide project logo on Ctrl+Shift+M press while preserving browser hotk…
Browse files Browse the repository at this point in the history
…ey functionality.
  • Loading branch information
Rondev9 committed Nov 14, 2023
1 parent e107739 commit 71f03d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
28 changes: 3 additions & 25 deletions src/ui/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class Hotkeys {
this.ui.game.signals.ui.dispatch('closeInterfaceScreens');
}

pressShiftKeyDown() {
pressShiftKeyDown(event) {
this.ui.$brandlogo.removeClass('hide');
this.ui.game.grid.showGrid(true);
this.ui.game.grid.showCurrentCreatureMovementInOverlay(this.ui.game.activeCreature);
Expand All @@ -137,19 +137,6 @@ export class Hotkeys {
pressSpace() {
!this.ui.dashopen && this.ui.game.grid.confirmHex();
}
handleKeyDown(event) {
if (event.key === 'Control') {
this.isCtrlPressed = true;
} else if (event.key === 'Shift') {
this.isShiftPressed = true;
} else if (event.key === 'M') {
this.isMPressed = true;
// Prevent the default behavior for Ctrl+Shift+M
if (this.isCtrlPressed && this.isShiftPressed) {
event.preventDefault();
}
}
}
}
export function getHotKeys(hk) {
const hotkeys = {
Expand All @@ -158,11 +145,6 @@ export function getHotKeys(hk) {
hk.pressS(event);
},
},
KeyM: {
onkeydown(event) {
hk.handleKeyDown(event);
},
},
KeyT: {
onkeydown() {
hk.pressT();
Expand Down Expand Up @@ -249,9 +231,8 @@ export function getHotKeys(hk) {
},
},
ShiftLeft: {
onkeydown(event) {
onkeydown() {
hk.pressShiftKeyDown();
hk.handleKeyDown(event);
},
onkeyup() {
hk.pressShiftKeyUp();
Expand All @@ -260,16 +241,14 @@ export function getHotKeys(hk) {
ShiftRight: {
onkeydown() {
hk.pressShiftKeyDown();
hk.handleKeyDown(event);
},
onkeyup() {
hk.pressShiftKeyUp();
},
},
ControlLeft: {
onkeydown(event) {
onkeydown() {
hk.pressControlKeyDown();
hk.handleKeyDown(event);
},
onkeyup() {
hk.pressControlKeyUp();
Expand All @@ -278,7 +257,6 @@ export function getHotKeys(hk) {
ControlRight: {
onkeydown() {
hk.pressControlKeyDown();
hk.handleKeyDown(event);
},
onkeyup() {
hk.pressControlKeyUp();
Expand Down
8 changes: 8 additions & 0 deletions src/ui/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -2383,6 +2383,14 @@ export class UI {
}
});

// Hide the project logo when navigating away using a hotkey (Ctrl+Shift+M)
document.addEventListener('keydown', (event) => {
if (event.ctrlKey && event.shiftKey && event.key === 'M') {
console.log('ctrl+shift+M pressed');
ui.$brandlogo.addClass('hide');
}
});

const SIGNAL_CREATURE_CLICK = 'vignettecreatureclick';
const SIGNAL_CREATURE_MOUSE_ENTER = 'vignettecreaturemouseenter';
const SIGNAL_CREATURE_MOUSE_LEAVE = 'vignettecreaturemouseleave';
Expand Down

0 comments on commit 71f03d5

Please sign in to comment.