// Nur in der Entwicklung (vite dev, E2E): Karte per Skript auf einen Ort und Maßstab stellen, z. B. für Bildschirmfotos // der Kartendarstellung (apps/web/e2e/32-karte-darstellung.spec.ts). Im gebauten Spiel nicht vorhanden. import type { Application, Container } from "pixi.js"; import { clampView, zoomAround } from "./gestures.ts"; import { xyOf } from "./terrain.ts"; type ViewFn = (lon: number, lat: number, scale: number) => { scale: number; resolution: number }; /** Prüfhilfe (E2E): Lage der Kartenzeichen und der Verbandssymbole in Weltkoordinaten (km). */ export interface MapProbe { markers: () => { x: number; y: number; col: number; row: number }[]; ships: () => { key: number; x: number; y: number }[]; } export function installViewHook(app: Application, world: Container, probe?: MapProbe): () => void { if (!import.meta.env.DEV) return () => {}; const w = window as unknown as { __tfMapView?: ViewFn; __tfMapApp?: Application; __tfMapProbe?: MapProbe }; w.__tfMapApp = app; // Leistungsmessung (E2E) if (probe) w.__tfMapProbe = probe; // Linien und Symbole an den Zeichen (E2E 34-routen-anker) w.__tfMapView = (lon, lat, scale) => { const { width, height } = app.screen; const p = xyOf(lon, lat); zoomAround(world, { x: width / 2, y: height / 2 }, scale, width, height); const s = world.scale.x; world.position.set(width / 2 - p.x * s, height / 2 - p.y * s); clampView(world, width, height); return { scale: world.scale.x, resolution: app.renderer.resolution }; }; return () => { delete w.__tfMapView; delete w.__tfMapApp; delete w.__tfMapProbe; }; }