add logic to conditionally align window (#851)

This commit is contained in:
Adrian Torrano 2024-05-16 00:01:20 +08:00 committed by GitHub
parent afcffab90f
commit 7769c06393
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,7 +2,7 @@ import SettingsUiHandler from "#app/ui/settings-ui-handler";
import { Mode } from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
import i18next from "i18next"; import i18next from "i18next";
import BattleScene from "../battle-scene"; import BattleScene from "../battle-scene";
import { hasTouchscreen } from "../touch-controls"; import { hasTouchscreen, isMobile } from "../touch-controls";
import { updateWindowType } from "../ui/ui-theme"; import { updateWindowType } from "../ui/ui-theme";
import { PlayerGender } from "./game-data"; import { PlayerGender } from "./game-data";
@ -167,6 +167,14 @@ export function setSetting(scene: BattleScene, setting: Setting, value: integer)
const touchControls = document.getElementById('touchControls'); const touchControls = document.getElementById('touchControls');
if (touchControls) if (touchControls)
touchControls.classList.toggle('visible', scene.enableTouchControls); touchControls.classList.toggle('visible', scene.enableTouchControls);
const isLandscape = window.matchMedia("(orientation: landscape)").matches;
const appContainer = document.getElementById('app');
if (!isMobile() && isLandscape && !scene.enableTouchControls)
appContainer.style.alignItems = 'center';
else
appContainer.style.alignItems = 'start';
break; break;
case Setting.Vibration: case Setting.Vibration:
scene.enableVibration = settingOptions[setting][value] !== 'Disabled' && hasTouchscreen(); scene.enableVibration = settingOptions[setting][value] !== 'Disabled' && hasTouchscreen();