From 97125416ea57eb84780e7441b3c64fe4b1f6da06 Mon Sep 17 00:00:00 2001 From: Petrificus-totalus <1966710331@qq.com> Date: Thu, 19 Oct 2023 10:46:00 +1100 Subject: [PATCH 1/4] fix issue#2511 --- src/ui/hotkeys.js | 10 ++++++++++ src/ui/interface.js | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ui/hotkeys.js b/src/ui/hotkeys.js index a67d9f3f2..ddf276458 100644 --- a/src/ui/hotkeys.js +++ b/src/ui/hotkeys.js @@ -70,6 +70,11 @@ export class Hotkeys { this.ui.btnExit.triggerClick(); } } + pressTab(event) { + if (event.shiftKey) { + this.ui.$brandlogo.addClass('hide'); + } + } pressArrowUp() { this.ui.dashopen ? this.ui.gridSelectUp() : this.ui.game.grid.selectHexUp(); @@ -187,6 +192,11 @@ export function getHotKeys(hk) { hk.pressX(event); }, }, + Tab: { + onkeydown(event) { + hk.pressTab(event); + }, + }, ArrowUp: { onkeydown() { hk.pressArrowUp(); diff --git a/src/ui/interface.js b/src/ui/interface.js index af95242ed..957148596 100644 --- a/src/ui/interface.js +++ b/src/ui/interface.js @@ -395,7 +395,9 @@ export class UI { if (keydownAction !== undefined) { keydownAction.call(this, e); - e.preventDefault(); + if (!(e.code === 'Tab' && e.shiftKey)) { + e.preventDefault(); + } } }); @@ -1480,7 +1482,7 @@ export class UI { this.showRandomCreature(); } else if (!randomize) { this.showCreature('--', game.activeCreature.team, ''); - } else if (this.lastViewedCreature) { + } else if (this.lastViewedCreature) { this.showCreature(this.lastViewedCreature, game.activeCreature.team, ''); } else { this.showCreature(game.activeCreature.type, game.activeCreature.team, ''); From 1d45becf08d5f1ade0ca5d45f5311d6a650493a5 Mon Sep 17 00:00:00 2001 From: Petrificus-totalus <1966710331@qq.com> Date: Sat, 21 Oct 2023 11:03:54 +1100 Subject: [PATCH 2/4] fix#2511 hideLogo --- src/ui/hotkeys.js | 1 + src/ui/interface.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/ui/hotkeys.js b/src/ui/hotkeys.js index ddf276458..1ce6754de 100644 --- a/src/ui/hotkeys.js +++ b/src/ui/hotkeys.js @@ -71,6 +71,7 @@ export class Hotkeys { } } pressTab(event) { + console.log(event); if (event.shiftKey) { this.ui.$brandlogo.addClass('hide'); } diff --git a/src/ui/interface.js b/src/ui/interface.js index 957148596..dfae888fd 100644 --- a/src/ui/interface.js +++ b/src/ui/interface.js @@ -2333,6 +2333,13 @@ export class UI { ui.game.grid.redoLastQuery(); }; + // hide the brand logo when navigating away using a hotkey + document.addEventListener('visibilitychange', function () { + if (document.hidden) { + ui.$brandlogo.addClass('hide'); + } + }); + const SIGNAL_CREATURE_CLICK = 'vignettecreatureclick'; const SIGNAL_CREATURE_MOUSE_ENTER = 'vignettecreaturemouseenter'; const SIGNAL_CREATURE_MOUSE_LEAVE = 'vignettecreaturemouseleave'; From c4e1129e48270c95b173dc4714187228c34451c9 Mon Sep 17 00:00:00 2001 From: Dread Knight Date: Sat, 21 Oct 2023 15:18:27 +0300 Subject: [PATCH 3/4] tweaked comment --- src/ui/interface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/interface.js b/src/ui/interface.js index dfae888fd..c142d7187 100644 --- a/src/ui/interface.js +++ b/src/ui/interface.js @@ -2333,7 +2333,7 @@ export class UI { ui.game.grid.redoLastQuery(); }; - // hide the brand logo when navigating away using a hotkey + // Hide the project logo when navigating away using a hotkey document.addEventListener('visibilitychange', function () { if (document.hidden) { ui.$brandlogo.addClass('hide'); From 1dcb77872586635388f0c2ad4b349f4978410d89 Mon Sep 17 00:00:00 2001 From: Samuel Macauley Date: Sun, 22 Oct 2023 21:57:59 +1100 Subject: [PATCH 4/4] Fix for issue 2183. Tested on mobile touchscreen and desktop --- src/ui/interface.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/ui/interface.js b/src/ui/interface.js index c142d7187..5c259c873 100644 --- a/src/ui/interface.js +++ b/src/ui/interface.js @@ -375,6 +375,32 @@ export class UI { const slider = document.getElementById('sfx'); slider.addEventListener('input', () => (game.soundsys.allEffectsMultiplier = slider.value)); + // Prevents default touch behaviour on slider when first touched (prevents scrolling the screen). + slider.addEventListener('touchstart', (e) => e.preventDefault(), { passive: false }); + + slider.addEventListener('touchmove', (e) =>{ + // Get slider relative to the view port. + const sliderRect = slider.getBoundingClientRect(); + // The original touch point Y coordinate relative to the view port. + const touchPoint = e.touches[0].clientY; + /// The y coord of the touch event relative to the slider. + const touchRelToSlider = touchPoint - sliderRect.top; + const distFromBottom = sliderRect.height - touchRelToSlider; + // Normalize the distance from the bottom of the slider to a value between 0 and 1. + const normDist = distFromBottom / sliderRect.height; + // Scale normDist to range of the slider. + const scaledDist = normDist * (slider.max - slider.min); + // New value of the slider. + const slidersNewVal = scaledDist + parseFloat(slider.min); + // Sets the slider value to the new value between the min/max bounds of the slider. + slider.value = Math.min(Math.max(slidersNewVal, slider.min), slider.max); + + // Manually dispatches the input event to update the sound system with new slider value. + slider.dispatchEvent(new Event('input')); + }); + + + this.hotkeys = new Hotkeys(this); const ingameHotkeys = getHotKeys(this.hotkeys);