From 41d32c04835aeaa02f870aba21aed66b1a7e314b Mon Sep 17 00:00:00 2001 From: shrianshChari <30420527+shrianshChari@users.noreply.github.com> Date: Thu, 11 Apr 2024 19:56:13 -0400 Subject: [PATCH 1/2] Add keyboard controls for battle speed --- .../src/replays-battle.tsx | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/replay.pokemonshowdown.com/src/replays-battle.tsx b/replay.pokemonshowdown.com/src/replays-battle.tsx index fb96324f38..8871bf8229 100644 --- a/replay.pokemonshowdown.com/src/replays-battle.tsx +++ b/replay.pokemonshowdown.com/src/replays-battle.tsx @@ -168,6 +168,7 @@ export class BattlePanel extends preact.Component<{id: string}> { } // @ts-ignore if (e.target?.tagName === 'INPUT' || e.target?.tagName === 'SELECT') return; + let target; switch (e.keyCode) { case 75: // k if (this.battle?.atQueueEnd) { @@ -195,6 +196,11 @@ export class BattlePanel extends preact.Component<{id: string}> { case 191: // / (?) if (e.shiftKey) { alert( + 'h = hyperfast speed\n' + + 'f = fast speed\n' + + 'n = normal speed\n' + + 's = slow speed\n' + + 'r = really slow speed\n' + 'k = play/pause\n' + 'j = previous turn\n' + 'l = next turn\n' + @@ -219,6 +225,36 @@ export class BattlePanel extends preact.Component<{id: string}> { case 77: // m this.toggleMute(); break; + case 72: // h + target = this.base?.querySelector('select[name=speed]'); + if (!target) return; + target.value = 'hyperfast'; + this.changeSpeed({target}); + break; + case 70: // f + target = this.base?.querySelector('select[name=speed]'); + if (!target) return; + target.value = 'fast'; + this.changeSpeed({target}); + break; + case 78: // n + target = this.base?.querySelector('select[name=speed]'); + if (!target) return; + target.value = 'normal'; + this.changeSpeed({target}); + break; + case 83: // s + target = this.base?.querySelector('select[name=speed]'); + if (!target) return; + target.value = 'slow'; + this.changeSpeed({target}); + break; + case 82: // r + target = this.base?.querySelector('select[name=speed]'); + if (!target) return; + target.value = 'reallyslow'; + this.changeSpeed({target}); + break; } this.forceUpdate(); }; From d4649b423a1bb114122ec9b1159693e6e4389943 Mon Sep 17 00:00:00 2001 From: Shriansh Chari <30420527+shrianshChari@users.noreply.github.com> Date: Tue, 8 Oct 2024 00:20:13 -0400 Subject: [PATCH 2/2] Turn tabs into spaces for indentation --- replay.pokemonshowdown.com/src/replays-battle.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/replay.pokemonshowdown.com/src/replays-battle.tsx b/replay.pokemonshowdown.com/src/replays-battle.tsx index 8871bf8229..91f024188c 100644 --- a/replay.pokemonshowdown.com/src/replays-battle.tsx +++ b/replay.pokemonshowdown.com/src/replays-battle.tsx @@ -168,7 +168,7 @@ export class BattlePanel extends preact.Component<{id: string}> { } // @ts-ignore if (e.target?.tagName === 'INPUT' || e.target?.tagName === 'SELECT') return; - let target; + let target; switch (e.keyCode) { case 75: // k if (this.battle?.atQueueEnd) { @@ -232,26 +232,26 @@ export class BattlePanel extends preact.Component<{id: string}> { this.changeSpeed({target}); break; case 70: // f - target = this.base?.querySelector('select[name=speed]'); - if (!target) return; + target = this.base?.querySelector('select[name=speed]'); + if (!target) return; target.value = 'fast'; this.changeSpeed({target}); break; case 78: // n target = this.base?.querySelector('select[name=speed]'); - if (!target) return; + if (!target) return; target.value = 'normal'; this.changeSpeed({target}); break; case 83: // s target = this.base?.querySelector('select[name=speed]'); - if (!target) return; + if (!target) return; target.value = 'slow'; this.changeSpeed({target}); break; case 82: // r target = this.base?.querySelector('select[name=speed]'); - if (!target) return; + if (!target) return; target.value = 'reallyslow'; this.changeSpeed({target}); break;