diff --git a/play.pokemonshowdown.com/src/panel-battle.tsx b/play.pokemonshowdown.com/src/panel-battle.tsx index e0a7b623858..5df29becb66 100644 --- a/play.pokemonshowdown.com/src/panel-battle.tsx +++ b/play.pokemonshowdown.com/src/panel-battle.tsx @@ -245,6 +245,8 @@ class BattlePanel extends PSRoomPanel { static readonly id = 'battle'; static readonly routes = ['battle-*', 'game-*']; static readonly Model = BattleRoom; + private controlsMode: 'move' | 'switch' | null = null; + private overlayMode = false; static handleDrop(ev: DragEvent) { const file = ev.dataTransfer?.files?.[0]; if (file?.type === 'text/html') { @@ -364,17 +366,27 @@ class BattlePanel extends PSRoomPanel { battle.subscribe(() => this.forceUpdate()); } battleHeight = 360; + controlTop = 370; updateLayout() { if (!this.base) return; const room = this.props.room; + this.overlayMode = (window.innerHeight <= 570 && window.innerWidth >= 440); + if (!this.overlayMode) this.controlsMode = null; const width = this.base.offsetWidth; + const classList = this.base.classList; + if (classList) { + classList.toggle('small-layout', !!width && width < 830); + classList.toggle('tiny-layout', !!width && width < 640); + } if (width && width < 640) { const scale = (width / 640); room.battle?.scene.$frame!.css('transform', `scale(${scale})`); this.battleHeight = Math.round(360 * scale); + this.controlTop = Math.round(360 * scale) + 10; } else { room.battle?.scene.$frame!.css('transform', 'none'); this.battleHeight = 360; + this.controlTop = 370; } } override receiveLine(args: Args) { @@ -895,6 +907,7 @@ class BattlePanel extends PSRoomPanel { case 'move': { const index = choices.index(); const pokemon = request.side.pokemon[index]; + if (this.overlayMode && this.controlsMode === null) this.controlsMode = null; if (choices.current.move) { const moveName = choices.currentMove()?.name; @@ -912,23 +925,43 @@ class BattlePanel extends PSRoomPanel { } const canShift = room.battle.gameType === 'triples' && index !== 1; + const useOverlayToggles = this.overlayMode; + const showMoves = !useOverlayToggles || this.controlsMode === 'move'; + const showSwitches = !useOverlayToggles || this.controlsMode === 'switch'; + const overlayClass = (this.overlayMode && this.controlsMode) ? ` ${this.controlsMode}-controls` : ''; - return
+ return
{this.renderOldChoices(request, choices)} What will {pokemon.name} do?
-

Attack

- {this.renderMoveMenu(choices)} + {useOverlayToggles ? ( + + ) :

Attack

} + {showMoves && this.renderMoveMenu(choices)}
{canShift && [

Shift

, , ]} -

Switch

- {this.renderSwitchMenu(request, choices)} + {useOverlayToggles ? ( + + ) :

Switch

} + {showSwitches && this.renderSwitchMenu(request, choices)}
; } case 'switch': { @@ -1051,12 +1084,18 @@ class BattlePanel extends PSRoomPanel { return {hardcoreStyle} - -