diff --git a/AGENTS.md b/AGENTS.md index 907e8b25..578ff406 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,7 +2,7 @@ ## Authority and scope -- This is U-Jagd 1.3.35 (`src/core/version.py`); current saves are v27-only. Treat these as compatibility contracts, not changelog entries. +- This is U-Jagd 1.3.36 (`src/core/version.py`); current saves are v27-only. Treat these as compatibility contracts, not changelog entries. - Resolve conflicts in this order: executable code and focused tests; packaged JSON/runtime resources; `pyproject.toml` and provenance/license notices; `README.md`; design/history documents under `docs/`. A plan or old comment is not an implementation contract. - Preserve explicit compatibility tests and user data unless a task intentionally changes the contract. Add a regression test for behavior changes. - Older phase/milestone labels under `docs/GDD.md`, `docs/implementation-plan.md`, `docs/plan-0.1.6.md`, and `docs/plan-0.1.7.md` are historical. Current resumable work is tracked in `docs/plan-1.3.md` and `docs/resume.md`. diff --git a/CHANGELOG.de.md b/CHANGELOG.de.md index da9bda23..9870ba8b 100644 --- a/CHANGELOG.de.md +++ b/CHANGELOG.de.md @@ -4,6 +4,16 @@ Alle Versionen von U-Jagd, die neueste zuerst. Die [README](README.de.md) zeigt nur die neueste. +## 1.3.36 + +Version 1.3.36 lässt die Karten auf der uConsole viel weiter hineinzoomen. +`Q`/`E` springen jetzt auf Brücke, Waffen, Helikopter und der U-Boot-Karte in +festen Stufen durch die Kartenhöhen 500, 250, 100, 50, 25, 10, 5, 2, 1 und +0,5 sm, das Mausrad zoomt stufenlos bis 0,5 sm; die OPZ-Karte geht bis 0,25 sm +Radius. Das Gitter wird beim Hineinzoomen feiner (bis 0,1 sm, mit +Dezimalbeschriftung), der Maßstab zeigt Bruchteile, und Küsten und Radarringe +werden beschnitten, damit starker Zoom schnell bleibt. Spielstände bleiben v27. + ## 1.3.35 Version 1.3.35 bringt weniger Text auf die uConsole-Bildschirme. Die obere diff --git a/CHANGELOG.md b/CHANGELOG.md index 71db2aa4..21703315 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ Every U-Jagd release, newest first. The [README](README.md) shows only the latest one. +## 1.3.36 + +Release 1.3.36 lets the uConsole charts zoom much further in. `Q`/`E` now +step through fixed chart heights of 500, 250, 100, 50, 25, 10, 5, 2, 1 and +0.5 NM on the bridge, weapons, helicopter and submarine charts, and the mouse +wheel zooms smoothly down to 0.5 NM; the operations centre chart goes down to +a 0.25 NM radius. The grid gets finer as you zoom (down to 0.1 NM, with +decimal labels), the scale line shows fractions, and coastlines and radar +rings are clipped so strong zoom stays fast. Saves stay v27. + ## 1.3.35 Release 1.3.35 puts less text on the uConsole screens. The top bar names only diff --git a/README.de.md b/README.de.md index f9fb11d0..659fadd5 100644 --- a/README.de.md +++ b/README.de.md @@ -14,18 +14,15 @@ Sie führen eine fiktive Fregatte und wechseln zwischen neun Arbeitsplätzen, um zu navigieren, zu suchen, Kontakte zu klassifizieren, Ziele zu bekämpfen und das Schiff einsatzfähig zu halten. -Aktuelle Version: **1.3.35** +Aktuelle Version: **1.3.36** -Version 1.3.35 bringt weniger Text auf die uConsole-Bildschirme. Die obere -Leiste nennt nur Station und Uhrzeit, der Kartenkopf nur den Maßstab. Das Sonar -verliert die Statusfelder im Kopf und die Legendenzeilen und behält eine Zeile -mit vier Haupttasten (der Rest steht in F1); ein Schlepp- oder Tiefensonar -zeigt seinen Zustand nur, solange es fährt oder nicht bereit ist. Die -Bedrohungsbox des U-Boots erscheint nur bei frischer Bedrohung, danach markiert -ein gelbes Dreieck neben der Uhrzeit anstehende Warnungen. Kurse stehen in -ganzen Grad mit °, der Drehkreis nur während einer Drehung. Der TMA-Kopf -überlappt nicht mehr, und Waffen-Reiter, Rohrzeile und Alarmzeilen des U-Boots -werden nicht mehr abgeschnitten. Spielstände bleiben v27. +Version 1.3.36 lässt die Karten auf der uConsole viel weiter hineinzoomen. +`Q`/`E` springen jetzt auf Brücke, Waffen, Helikopter und der U-Boot-Karte in +festen Stufen durch die Kartenhöhen 500, 250, 100, 50, 25, 10, 5, 2, 1 und +0,5 sm, das Mausrad zoomt stufenlos bis 0,5 sm; die OPZ-Karte geht bis 0,25 sm +Radius. Das Gitter wird beim Hineinzoomen feiner (bis 0,1 sm, mit +Dezimalbeschriftung), der Maßstab zeigt Bruchteile, und Küsten und Radarringe +werden beschnitten, damit starker Zoom schnell bleibt. Spielstände bleiben v27. Frühere Versionen: [CHANGELOG.de.md](CHANGELOG.de.md). diff --git a/README.md b/README.md index c298e7bd..7b78c34c 100644 --- a/README.md +++ b/README.md @@ -12,17 +12,15 @@ around the ClockworkPi uConsole's 1280 x 720 workspace. You command a fictional frigate and move between nine workstations to navigate, search, classify, engage, and keep the ship operational. -Current release: **1.3.35** +Current release: **1.3.36** -Release 1.3.35 puts less text on the uConsole screens. The top bar names only -the station and the clock, the chart header only its scale. The sonar loses its -header status chips and legend lines and keeps one row of four main keys (the -rest is in F1); a towed or variable-depth array shows its state only while it -is moving or not ready. The submarine's threat box appears only while a threat -is fresh, then an amber triangle next to the clock marks standing warnings. -Courses read in whole degrees with °, and the turn radius shows only in a turn. -The TMA header no longer overlaps, and the submarine's Weapons tab, tube line -and alarm lines are no longer cut off. Saves stay v27. +Release 1.3.36 lets the uConsole charts zoom much further in. `Q`/`E` now +step through fixed chart heights of 500, 250, 100, 50, 25, 10, 5, 2, 1 and +0.5 NM on the bridge, weapons, helicopter and submarine charts, and the mouse +wheel zooms smoothly down to 0.5 NM; the operations centre chart goes down to +a 0.25 NM radius. The grid gets finer as you zoom (down to 0.1 NM, with +decimal labels), the scale line shows fractions, and coastlines and radar +rings are clipped so strong zoom stays fast. Saves stay v27. Earlier releases: [CHANGELOG.md](CHANGELOG.md). diff --git a/data/i18n/de.json b/data/i18n/de.json index 0fcbf246..aed8ca0c 100644 --- a/data/i18n/de.json +++ b/data/i18n/de.json @@ -2109,7 +2109,7 @@ "help.control.speed_input": "Direkte Zielgeschwindigkeit eingeben (0-31 kn)", "help.control.engine_order": "Telegraph: Motorenbefehl (ASTERN-STOP-SLOW-HALF-FULL-FLANK)", "help.control.mouse_map": "Mausrad: Zoom, Maus-Drag: Pan", - "help.control.zoom": "Karte heraus-/hineinzoomen", + "help.control.zoom": "Karte in Stufen zoomen, 500 bis 0,5 sm", "help.control.follow": "Kamera-Follow an/aus", "help.control.active_ping": "Aktiv-Ping abfeuern (Kühlzeit, verrät Position!)", "help.control.array": "Empfangsarray wechseln: HMS, TAS, VDS", @@ -4298,7 +4298,7 @@ "help.uboot.views": "Stationen: 1 Führung, 2 Sonar, 3 Waffen, 4 Maschine, 5 Mast & ESM, 6 Navigation, 7 Funkraum; Tab weiter (oder Reiter anklicken)", "help.uboot.orders": "Kurs / Fahrt / Tiefe befehlen (Führung; Kurs und Tiefe auch Navigation, Fahrt auch Maschine)", "help.uboot.pages": "Führungsseiten: Navigation / Waffen & Kontakte / Sehrohr / Bedrohung (oder erneut 1); Seiten Navigation: Navigation / Bedrohung (oder erneut 6); Seiten Mast & ESM: ESM / Sehrohr (oder erneut 5)", - "help.uboot.zoom": "Karte heraus- / hineinzoomen", + "help.uboot.zoom": "Karte in Stufen zoomen, 500 bis 0,5 sm", "help.uboot.follow": "Karte folgt dem U-Boot an/aus", "help.key.uboot_drag": "Mausrad / Ziehen", "help.uboot.drag": "Karte zoomen / verschieben (Maus auf der Karte)", diff --git a/data/i18n/en.json b/data/i18n/en.json index cad0e810..d1601655 100644 --- a/data/i18n/en.json +++ b/data/i18n/en.json @@ -2109,7 +2109,7 @@ "help.control.speed_input": "Enter target speed directly (0-31 kn)", "help.control.engine_order": "Telegraph: engine order (ASTERN-STOP-SLOW-HALF-FULL-FLANK)", "help.control.mouse_map": "Mouse wheel: zoom, mouse drag: pan", - "help.control.zoom": "Zoom chart out/in", + "help.control.zoom": "Zoom chart in steps, 500 to 0.5 NM", "help.control.follow": "Camera follow on/off", "help.control.active_ping": "Transmit active ping (cooldown; reveals position!)", "help.control.array": "Switch receiver array: HMS, TAS, VDS", @@ -4298,7 +4298,7 @@ "help.uboot.views": "Stations: 1 Command, 2 Sonar, 3 Weapons, 4 Engine room, 5 Mast & ESM, 6 Navigation, 7 Radio room; Tab next (click a tab too)", "help.uboot.orders": "Order course / speed / depth (Command; course and depth also Navigation, speed also Engine room)", "help.uboot.pages": "Command pages: Navigation / Weapons & contacts / Periscope / Threat (or 1 again); Navigation pages: Navigation / Threat (or 6 again); Mast & ESM pages: ESM / Periscope (or 5 again)", - "help.uboot.zoom": "Chart zoom out / in", + "help.uboot.zoom": "Zoom chart in steps, 500 to 0.5 NM", "help.uboot.follow": "Chart follows the submarine on/off", "help.key.uboot_drag": "Wheel / drag", "help.uboot.drag": "Zoom / pan the chart (mouse on the chart)", diff --git a/data/manual/01-bridge.de.md b/data/manual/01-bridge.de.md index 485392c9..16fc7739 100644 --- a/data/manual/01-bridge.de.md +++ b/data/manual/01-bridge.de.md @@ -28,7 +28,7 @@ Die obere Leiste nennt nur die Station und die Uhrzeit; Kurs und Fahrt stehen in - **Kurs / Ruder:** aktueller Kurs, befohlener Kurs (`→`), Ruderlage in ganzen Grad und, nur während einer Drehung, der Drehkreis. - **Fahrt / Akustik:** Telegraphenstufe, Fahrt, Eigenlärm in Prozent und Warnung KAVITATION über 15 kn. - **Taktische Lage:** beobachtete Bedrohungen (gehörter Torpedo-Starttransient oder HF-Ortungsimpulse, ein vom Sonar als Torpedo klassifizierter Kontakt oder ein als möglicher Flugkörper markierter Luftkontakt), Sensorzustand (Radar, TAS), Mittel (Helikopter, Bojen) und Wetter/Tag-Nacht. -- **Karte:** synthetische Kartentiefe und Küste, eigenes Schiff, von anderen Stationen veröffentlichte Tracks. Mausrad oder `Q`/`E` zoomen, Ziehen verschiebt, `K` folgt dem eigenen Schiff. +- **Karte:** synthetische Kartentiefe und Küste, eigenes Schiff, von anderen Stationen veröffentlichte Tracks. `Q`/`E` zoomen in festen Stufen (Kartenhöhe 500, 250, 100, 50, 25, 10, 5, 2, 1 und 0,5 sm), das Mausrad stufenlos bis 0,5 sm; das Gitter wird beim Hineinzoomen feiner (bis 0,1 sm). Ziehen verschiebt, `K` folgt dem eigenen Schiff. ## Ausguck-Meldungen {#bridge-lookout} diff --git a/data/manual/01-bridge.en.md b/data/manual/01-bridge.en.md index 44034182..d9e75e7b 100644 --- a/data/manual/01-bridge.en.md +++ b/data/manual/01-bridge.en.md @@ -28,7 +28,7 @@ The top bar names only the station and the clock; course and speed are in the te - **Course / rudder:** current course, ordered course (`→`), rudder angle in whole degrees and, only while turning, the turn radius. - **Speed / acoustics:** telegraph order, speed, own noise in percent and a CAVITATION warning above 15 kn. - **Tactical picture:** observed threats (a heard torpedo launch transient or HF seeker pulses, a contact sonar classified as torpedo, or an air track flagged as a possible missile), sensor state (radar, TAS), assets (helicopter, buoys) and weather/day-night. -- **Chart:** synthetic chart depth and coastline, own ship, tracks published by the other stations. Wheel or `Q`/`E` zoom, drag pans, `K` follows own ship. +- **Chart:** synthetic chart depth and coastline, own ship, tracks published by the other stations. `Q`/`E` zoom in fixed steps (chart height 500, 250, 100, 50, 25, 10, 5, 2, 1 and 0.5 NM), the wheel zooms smoothly down to 0.5 NM; the grid gets finer as you zoom in (down to 0.1 NM). Drag pans, `K` follows own ship. ## Bridge lookout reports {#bridge-lookout} diff --git a/data/manual/05-opz.de.md b/data/manual/05-opz.de.md index db390fc4..666e0468 100644 --- a/data/manual/05-opz.de.md +++ b/data/manual/05-opz.de.md @@ -6,7 +6,7 @@ Die Operationszentrale (OPZ / CIC) bildet das Lagebild über Wasser: Überwasser ## Anzeigen und Instrumente {#opz-displays} -Seite 1 ist eine freie Karte über die volle Höhe mit allen veröffentlichten Tracks; Seite 2 ist die Zielseite für den gewählten Track; Seite 3 führt den Seefernaufklärer. Das schiffszentrierte Radarbild hat eine eigene Bereichsskala (10/20/40/80/120 sm, `Bild Auf`/`Bild Ab`), unabhängig vom Kartenzoom (Mausrad bis 5 sm Radius; Ziehen verschiebt; `K` folgt). Eigene Einheiten stammen aus dem Datenlink, nicht aus Sensoren: das Schiff, der fliegende Helikopter ("HSP-5 DL") und jede laufende eigene Waffe, also Torpedos von Schiff, Helikopter oder ASROC (`T`), ASROC im Flug und ESSM, jeweils mit Freund-Symbol und Kursstrich. +Seite 1 ist eine freie Karte über die volle Höhe mit allen veröffentlichten Tracks; Seite 2 ist die Zielseite für den gewählten Track; Seite 3 führt den Seefernaufklärer. Das schiffszentrierte Radarbild hat eine eigene Bereichsskala (10/20/40/80/120 sm, `Bild Auf`/`Bild Ab`), unabhängig vom Kartenzoom (Mausrad bis 0,25 sm Radius; Ziehen verschiebt; `K` folgt). Eigene Einheiten stammen aus dem Datenlink, nicht aus Sensoren: das Schiff, der fliegende Helikopter ("HSP-5 DL") und jede laufende eigene Waffe, also Torpedos von Schiff, Helikopter oder ASROC (`T`), ASROC im Flug und ESSM, jeweils mit Freund-Symbol und Kursstrich. ```text NATO-Rahmenfarben (Bedienervermerk, keine Wahrheit) diff --git a/data/manual/05-opz.en.md b/data/manual/05-opz.en.md index 18ecff0f..de148305 100644 --- a/data/manual/05-opz.en.md +++ b/data/manual/05-opz.en.md @@ -6,7 +6,7 @@ Operations (OPZ / CIC) builds the tactical picture above the water: surface and ## Displays and instruments {#opz-displays} -Page 1 is a full-height free chart with all published tracks; page 2 is the target page for the selected track; page 3 commands the patrol aircraft. The ship-centred radar picture uses its own range scale (10/20/40/80/120 NM, `PgUp`/`PgDn`), independent of the chart zoom (wheel, down to 5 NM radius; drag pans; `K` follows). Own units come from the datalink, not from sensors: the ship, the airborne helicopter ("HSP-5 DL") and every own weapon under way, i.e. torpedoes from ship, helicopter or ASROC (`T`), ASROC in flight and ESSM, each with a friendly symbol and a heading tick. +Page 1 is a full-height free chart with all published tracks; page 2 is the target page for the selected track; page 3 commands the patrol aircraft. The ship-centred radar picture uses its own range scale (10/20/40/80/120 NM, `PgUp`/`PgDn`), independent of the chart zoom (wheel, down to 0.25 NM radius; drag pans; `K` follows). Own units come from the datalink, not from sensors: the ship, the airborne helicopter ("HSP-5 DL") and every own weapon under way, i.e. torpedoes from ship, helicopter or ASROC (`T`), ASROC in flight and ESSM, each with a friendly symbol and a heading tick. ```text NATO frame colours (operator annotation, not truth) diff --git a/docs/manual/manual.de.md b/docs/manual/manual.de.md index a5a29e79..3b821bdf 100644 --- a/docs/manual/manual.de.md +++ b/docs/manual/manual.de.md @@ -163,7 +163,7 @@ Die obere Leiste nennt nur die Station und die Uhrzeit; Kurs und Fahrt stehen in - **Kurs / Ruder:** aktueller Kurs, befohlener Kurs (`→`), Ruderlage in ganzen Grad und, nur während einer Drehung, der Drehkreis. - **Fahrt / Akustik:** Telegraphenstufe, Fahrt, Eigenlärm in Prozent und Warnung KAVITATION über 15 kn. - **Taktische Lage:** beobachtete Bedrohungen (gehörter Torpedo-Starttransient oder HF-Ortungsimpulse, ein vom Sonar als Torpedo klassifizierter Kontakt oder ein als möglicher Flugkörper markierter Luftkontakt), Sensorzustand (Radar, TAS), Mittel (Helikopter, Bojen) und Wetter/Tag-Nacht. -- **Karte:** synthetische Kartentiefe und Küste, eigenes Schiff, von anderen Stationen veröffentlichte Tracks. Mausrad oder `Q`/`E` zoomen, Ziehen verschiebt, `K` folgt dem eigenen Schiff. +- **Karte:** synthetische Kartentiefe und Küste, eigenes Schiff, von anderen Stationen veröffentlichte Tracks. `Q`/`E` zoomen in festen Stufen (Kartenhöhe 500, 250, 100, 50, 25, 10, 5, 2, 1 und 0,5 sm), das Mausrad stufenlos bis 0,5 sm; das Gitter wird beim Hineinzoomen feiner (bis 0,1 sm). Ziehen verschiebt, `K` folgt dem eigenen Schiff. ### Ausguck-Meldungen @@ -185,7 +185,7 @@ Klasse und Typ brauchen eine feiner aufgelöste Silhouette als die Sichtung (Joh | `V` | Direkte Zielgeschwindigkeit eingeben (0-31 kn) | | `+ / -` | Telegraph: Motorenbefehl (ASTERN-STOP-SLOW-HALF-FULL-FLANK) | | `Karte` | Mausrad: Zoom, Maus-Drag: Pan | -| `Q / E` | Karte heraus-/hineinzoomen | +| `Q / E` | Karte in Stufen zoomen, 500 bis 0,5 sm | | `K` | Kamera-Follow an/aus | | `, / .` | Ausguck-Seite: Radius kleiner / größer | | `B` | Ausguck-Seite: Fernglas über der Karte ein/aus (, / . schwenken) | @@ -461,7 +461,7 @@ Torpedolauf von oben: | `B` | Sonarbojen aussetzen (HSP-5 in Luft) | | `D` | Leichttorpedo vom HSP-5 | | `V` | Einen begrenzten geschleppten Akustik-Täuschkörper ausbringen | -| `Q / E` | Karte heraus-/hineinzoomen | +| `Q / E` | Karte in Stufen zoomen, 500 bis 0,5 sm | | `K` | Kamera-Follow an/aus | | `F` | Flak-Feuerfreigabe umschalten (gesperrt = feuert nie auf Angreifer) | @@ -593,7 +593,7 @@ Die Operationszentrale (OPZ / CIC) bildet das Lagebild über Wasser: Überwasser ### Anzeigen und Instrumente -Seite 1 ist eine freie Karte über die volle Höhe mit allen veröffentlichten Tracks; Seite 2 ist die Zielseite für den gewählten Track; Seite 3 führt den Seefernaufklärer. Das schiffszentrierte Radarbild hat eine eigene Bereichsskala (10/20/40/80/120 sm, `Bild Auf`/`Bild Ab`), unabhängig vom Kartenzoom (Mausrad bis 5 sm Radius; Ziehen verschiebt; `K` folgt). Eigene Einheiten stammen aus dem Datenlink, nicht aus Sensoren: das Schiff, der fliegende Helikopter ("HSP-5 DL") und jede laufende eigene Waffe, also Torpedos von Schiff, Helikopter oder ASROC (`T`), ASROC im Flug und ESSM, jeweils mit Freund-Symbol und Kursstrich. +Seite 1 ist eine freie Karte über die volle Höhe mit allen veröffentlichten Tracks; Seite 2 ist die Zielseite für den gewählten Track; Seite 3 führt den Seefernaufklärer. Das schiffszentrierte Radarbild hat eine eigene Bereichsskala (10/20/40/80/120 sm, `Bild Auf`/`Bild Ab`), unabhängig vom Kartenzoom (Mausrad bis 0,25 sm Radius; Ziehen verschiebt; `K` folgt). Eigene Einheiten stammen aus dem Datenlink, nicht aus Sensoren: das Schiff, der fliegende Helikopter ("HSP-5 DL") und jede laufende eigene Waffe, also Torpedos von Schiff, Helikopter oder ASROC (`T`), ASROC im Flug und ESSM, jeweils mit Freund-Symbol und Kursstrich. ```text NATO-Rahmenfarben (Bedienervermerk, keine Wahrheit) @@ -882,7 +882,7 @@ Die Station hat vier Seiten (nochmals `8` blättert); sie öffnet auf Seite 3. | `U / V` | Solltiefe des Tauchsonars heben / senken | | `A` | Aktiven Ping vom abgesenkten Tauchsonar senden | | `D / Ctrl+Enter` | Leichttorpedo abwerfen | -| `Q / E` | Karte heraus-/hineinzoomen | +| `Q / E` | Karte in Stufen zoomen, 500 bis 0,5 sm | | `K` | Kamera-Follow an/aus | | `Akustik: Bild Auf / Ab` | Akustikseite: Breitband / LOFAR / DEMON | | `Akustik: <- / ->` | Hubschrauber-Horchpeilung -/+ 5 Grad | @@ -1134,7 +1134,7 @@ Die obere Leiste zeigt die sieben Stationen des U-Boots als Reiter: `1` Führung | `C / V / D` | Kurs / Fahrt / Tiefe befehlen (Führung; Kurs und Tiefe auch Navigation, Fahrt auch Maschine) | | `U / J / H` | Tiefenstufen: Sehrohr- / Schnorcheltiefe (Umschalt), unter / über dem gemessenen Layer (Umschalt), tief (Führung, Navigation) | | `Bild auf/ab` | Führungsseiten: Navigation / Waffen & Kontakte / Sehrohr / Bedrohung (oder erneut 1); Seiten Navigation: Navigation / Bedrohung (oder erneut 6); Seiten Mast & ESM: ESM / Sehrohr (oder erneut 5) | -| `Q / E` | Karte heraus- / hineinzoomen | +| `Q / E` | Karte in Stufen zoomen, 500 bis 0,5 sm | | `K` | Karte folgt dem U-Boot an/aus | | `Mausrad / Ziehen` | Karte zoomen / verschieben (Maus auf der Karte) | | `Pfeiltasten` | Eigenen Sonarkontakt wählen | diff --git a/docs/manual/manual.en.md b/docs/manual/manual.en.md index 7eaf7189..02cf4a31 100644 --- a/docs/manual/manual.en.md +++ b/docs/manual/manual.en.md @@ -163,7 +163,7 @@ The top bar names only the station and the clock; course and speed are in the te - **Course / rudder:** current course, ordered course (`→`), rudder angle in whole degrees and, only while turning, the turn radius. - **Speed / acoustics:** telegraph order, speed, own noise in percent and a CAVITATION warning above 15 kn. - **Tactical picture:** observed threats (a heard torpedo launch transient or HF seeker pulses, a contact sonar classified as torpedo, or an air track flagged as a possible missile), sensor state (radar, TAS), assets (helicopter, buoys) and weather/day-night. -- **Chart:** synthetic chart depth and coastline, own ship, tracks published by the other stations. Wheel or `Q`/`E` zoom, drag pans, `K` follows own ship. +- **Chart:** synthetic chart depth and coastline, own ship, tracks published by the other stations. `Q`/`E` zoom in fixed steps (chart height 500, 250, 100, 50, 25, 10, 5, 2, 1 and 0.5 NM), the wheel zooms smoothly down to 0.5 NM; the grid gets finer as you zoom in (down to 0.1 NM). Drag pans, `K` follows own ship. ### Bridge lookout reports @@ -185,7 +185,7 @@ Class and type need a finer resolved silhouette than the sighting (Johnson crite | `V` | Enter target speed directly (0-31 kn) | | `+ / -` | Telegraph: engine order (ASTERN-STOP-SLOW-HALF-FULL-FLANK) | | `Chart` | Mouse wheel: zoom, mouse drag: pan | -| `Q / E` | Zoom chart out/in | +| `Q / E` | Zoom chart in steps, 500 to 0.5 NM | | `K` | Camera follow on/off | | `, / .` | Lookout page: scope radius smaller / larger | | `B` | Lookout page: binoculars over the chart on/off (, / . train them) | @@ -460,7 +460,7 @@ Torpedo run, seen from above: | `B` | Deploy sonobuoys (HSP-5 airborne) | | `D` | Lightweight torpedo from HSP-5 | | `V` | Stream one finite towed acoustic decoy | -| `Q / E` | Zoom chart out/in | +| `Q / E` | Zoom chart in steps, 500 to 0.5 NM | | `K` | Camera follow on/off | | `F` | Toggle AA gun fire release (withheld = never fires on raiders) | @@ -592,7 +592,7 @@ Operations (OPZ / CIC) builds the tactical picture above the water: surface and ### Displays and instruments -Page 1 is a full-height free chart with all published tracks; page 2 is the target page for the selected track; page 3 commands the patrol aircraft. The ship-centred radar picture uses its own range scale (10/20/40/80/120 NM, `PgUp`/`PgDn`), independent of the chart zoom (wheel, down to 5 NM radius; drag pans; `K` follows). Own units come from the datalink, not from sensors: the ship, the airborne helicopter ("HSP-5 DL") and every own weapon under way, i.e. torpedoes from ship, helicopter or ASROC (`T`), ASROC in flight and ESSM, each with a friendly symbol and a heading tick. +Page 1 is a full-height free chart with all published tracks; page 2 is the target page for the selected track; page 3 commands the patrol aircraft. The ship-centred radar picture uses its own range scale (10/20/40/80/120 NM, `PgUp`/`PgDn`), independent of the chart zoom (wheel, down to 0.25 NM radius; drag pans; `K` follows). Own units come from the datalink, not from sensors: the ship, the airborne helicopter ("HSP-5 DL") and every own weapon under way, i.e. torpedoes from ship, helicopter or ASROC (`T`), ASROC in flight and ESSM, each with a friendly symbol and a heading tick. ```text NATO frame colours (operator annotation, not truth) @@ -881,7 +881,7 @@ The station has four pages (`8` again cycles them); it opens on page 3. | `U / V` | Raise / lower dipping-sonar target depth | | `A` | Transmit active ping from deployed dipping sonar | | `D / Ctrl+Enter` | Drop lightweight torpedo | -| `Q / E` | Zoom chart out/in | +| `Q / E` | Zoom chart in steps, 500 to 0.5 NM | | `K` | Camera follow on/off | | `Acoustic: Page Up / Down` | Acoustic page: Broadband / LOFAR / DEMON | | `Acoustic: <- / ->` | Helicopter listening bearing -/+ 5 degrees | @@ -1133,7 +1133,7 @@ The top bar shows the submarine's seven stations as tabs: `1` Command, `2` Sonar | `C / V / D` | Order course / speed / depth (Command; course and depth also Navigation, speed also Engine room) | | `U / J / H` | Depth steps: periscope / snorkel depth (Shift), below / above the measured layer (Shift), deep (Command, Navigation) | | `Page Up/Down` | Command pages: Navigation / Weapons & contacts / Periscope / Threat (or 1 again); Navigation pages: Navigation / Threat (or 6 again); Mast & ESM pages: ESM / Periscope (or 5 again) | -| `Q / E` | Chart zoom out / in | +| `Q / E` | Zoom chart in steps, 500 to 0.5 NM | | `K` | Chart follows the submarine on/off | | `Wheel / drag` | Zoom / pan the chart (mouse on the chart) | | `Arrow keys` | Select an own sonar contact | diff --git a/docs/station-shortcuts.de.md b/docs/station-shortcuts.de.md index 1d2f0901..1fa7d0b8 100644 --- a/docs/station-shortcuts.de.md +++ b/docs/station-shortcuts.de.md @@ -47,7 +47,7 @@ Berechtigungsprüfungen bleiben wirksam. | `V` | Direkte Zielgeschwindigkeit eingeben (0-31 kn) | | `+ / -` | Telegraph: Motorenbefehl (ASTERN-STOP-SLOW-HALF-FULL-FLANK) | | `Karte` | Mausrad: Zoom, Maus-Drag: Pan | -| `Q / E` | Karte heraus-/hineinzoomen | +| `Q / E` | Karte in Stufen zoomen, 500 bis 0,5 sm | | `K` | Kamera-Follow an/aus | | `, / .` | Ausguck-Seite: Radius kleiner / größer | | `B` | Ausguck-Seite: Fernglas über der Karte ein/aus (, / . schwenken) | @@ -116,7 +116,7 @@ Berechtigungsprüfungen bleiben wirksam. | `B` | Sonarbojen aussetzen (HSP-5 in Luft) | | `D` | Leichttorpedo vom HSP-5 | | `V` | Einen begrenzten geschleppten Akustik-Täuschkörper ausbringen | -| `Q / E` | Karte heraus-/hineinzoomen | +| `Q / E` | Karte in Stufen zoomen, 500 bis 0,5 sm | | `K` | Kamera-Follow an/aus | | `F` | Flak-Feuerfreigabe umschalten (gesperrt = feuert nie auf Angreifer) | @@ -205,7 +205,7 @@ Berechtigungsprüfungen bleiben wirksam. | `U / V` | Solltiefe des Tauchsonars heben / senken | | `A` | Aktiven Ping vom abgesenkten Tauchsonar senden | | `D / Ctrl+Enter` | Leichttorpedo abwerfen | -| `Q / E` | Karte heraus-/hineinzoomen | +| `Q / E` | Karte in Stufen zoomen, 500 bis 0,5 sm | | `K` | Kamera-Follow an/aus | | `Akustik: Bild Auf / Ab` | Akustikseite: Breitband / LOFAR / DEMON | | `Akustik: <- / ->` | Hubschrauber-Horchpeilung -/+ 5 Grad | diff --git a/docs/station-shortcuts.de.pdf b/docs/station-shortcuts.de.pdf index 11197754..e13291a5 100644 Binary files a/docs/station-shortcuts.de.pdf and b/docs/station-shortcuts.de.pdf differ diff --git a/src/core/config.py b/src/core/config.py index 7fd12ab4..81979e5f 100644 --- a/src/core/config.py +++ b/src/core/config.py @@ -98,11 +98,13 @@ PHYS_SUBSTEP_S = 0.05 # max. sim-Sekunden pro Physik-Substep (Anti-T # 45 kn legen in 0.05 s ca. 0.000625 NM zurueck) PHYS_SUBSTEP_MAX = 240 MAP_ZOOM_MIN_PX_PER_NM = 1.0 # ganze Welt sichtbar (500 NM in 510 px) -MAP_ZOOM_MAX_PX_PER_NM = 14.0 # Detail-Zoom (~36 NM in 510 px) +MAP_ZOOM_MAX_PX_PER_NM = 1400.0 # Detail-Zoom (0.5 NM in 668 px Kartenhoehe) MAP_ZOOM_DEFAULT_PX_PER_NM = 10.0 # Start-Zoom (~51 NM hoch, ~64 NM breit) MAP_ZOOM_WHEEL_FACTOR = 1.25 # stufenlos pro Mausrad-Schritt +# Q/E springen auf feste Kartenhoehen (NM), von der ganzen Welt bis 0.5 NM. +MAP_ZOOM_STEPS_NM = (500.0, 250.0, 100.0, 50.0, 25.0, 10.0, 5.0, 2.0, 1.0, 0.5) OPZ_MAP_DEFAULT_RADIUS_NM = 40.0 -OPZ_MAP_MAX_ZOOM_RADIUS_NM = 5.0 +OPZ_MAP_MAX_ZOOM_RADIUS_NM = 0.25 # Welt WORLD_SIZE_NM = 500.0 # quadratische Welt in NM diff --git a/src/core/game_events.py b/src/core/game_events.py index 02c88528..6675c701 100644 --- a/src/core/game_events.py +++ b/src/core/game_events.py @@ -1317,7 +1317,7 @@ class EventMixin: self.launch_essm() elif self._map_station_visible(): self.map_view.set_rect(config.MAP_RECT) - self.map_view.zoom(config.MAP_ZOOM_WHEEL_FACTOR) + self.map_view.step_zoom(1, config.MAP_ZOOM_STEPS_NM) elif e.key == pygame.K_g and self.station in (Station.OPZ, Station.RADAR): self.launch_chaff() @@ -1418,7 +1418,7 @@ class EventMixin: else "runtime.map_follow.off"), 1.5) elif e.key == pygame.K_q and self._map_station_visible(): self.map_view.set_rect(config.MAP_RECT) - self.map_view.zoom(1.0 / config.MAP_ZOOM_WHEEL_FACTOR) + self.map_view.step_zoom(-1, config.MAP_ZOOM_STEPS_NM) elif e.key == pygame.K_v and self.station in (Station.BRIDGE, Station.ENGINE): self._begin_numeric_input("speed") diff --git a/src/core/uboot_local.py b/src/core/uboot_local.py index c4d17e8c..e64cc25b 100644 --- a/src/core/uboot_local.py +++ b/src/core/uboot_local.py @@ -614,8 +614,8 @@ def _command_key(game, current, key, mods) -> None: sub.command_bulkhead(compartment, closed), compartment=message(f"uboot.compartment.{compartment}")) elif key in (pygame.K_q, pygame.K_e): - _chart_zoom(game, current, (1.0 / config.MAP_ZOOM_WHEEL_FACTOR - if key == pygame.K_q else config.MAP_ZOOM_WHEEL_FACTOR)) + uboot_view.chart_view(game, current).step_zoom( + -1 if key == pygame.K_q else 1, config.MAP_ZOOM_STEPS_NM) elif key == pygame.K_k: current.chart_follow = not current.chart_follow game.flash(message("runtime.map_follow.on" if current.chart_follow diff --git a/src/core/version.py b/src/core/version.py index 31c11242..681d0d3a 100644 --- a/src/core/version.py +++ b/src/core/version.py @@ -4,7 +4,7 @@ This module is deliberately dependency-free because setuptools imports the version while building the project. """ -APP_VERSION = "1.3.35" +APP_VERSION = "1.3.36" SAVE_VERSION = 27 SAVE_SCHEMA = "u-jagd-save-v27" SPLASH_TEXT = ( diff --git a/src/ui/map_view.py b/src/ui/map_view.py index 4740efcb..b91d53a2 100644 --- a/src/ui/map_view.py +++ b/src/ui/map_view.py @@ -212,6 +212,87 @@ def _in_rect(px: float, py: float, r: tuple, m: float = 60.0) -> bool: r[1] - m <= py <= r[1] + r[3] + m) +GRID_STEPS_NM = (0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 25.0, 50.0) +# Clip margin around the chart: far outside lines never reach gfxdraw's +# 16-bit coordinates, and polygon edges stay outside the visible chart. +_CLIP_MARGIN_PX = 64.0 + + +def grid_step_nm(scale_px_per_nm: float) -> float: + """Grid spacing for a chart scale: the legacy 50/25/10 NM steps up to + 8 px/NM, then the smallest step at least 80 px apart.""" + if scale_px_per_nm < 3.0: + return 50.0 + if scale_px_per_nm < 8.0: + return 25.0 + for step in GRID_STEPS_NM: + if step <= 10.0 and step * scale_px_per_nm >= 80.0: + return step + return 10.0 + + +def grid_label(value_nm: float) -> str: + """Grid coordinate label: whole NM without decimals, else one decimal.""" + rounded = round(value_nm, 1) + return f"{rounded:.0f}" if abs(rounded - round(rounded)) < 1e-6 else f"{rounded:.1f}" + + +def scale_label(height_nm: float) -> str: + """Chart height for the scale line (``0.5``, ``2``, ``51``).""" + if height_nm < 9.95: + text = f"{height_nm:.1f}" + return text[:-2] if text.endswith(".0") else text + return f"{height_nm:.0f}" + + +def clip_polygon_to_rect(points, rect, margin: float = _CLIP_MARGIN_PX) -> list: + """Clip a screen polygon to ``rect`` grown by ``margin`` (Sutherland-Hodgman). + + Polygons already inside the grown rect are returned unchanged, so the + normal zoom levels keep their exact outline; at strong zoom the huge + off-screen coordinates are cut away before drawing.""" + left = rect[0] - margin + top = rect[1] - margin + right = rect[0] + rect[2] + margin + bottom = rect[1] + rect[3] + margin + pts = list(points) + if all(left <= x <= right and top <= y <= bottom for x, y in pts): + return pts + for edge in range(4): + if not pts: + break + out = [] + prev = pts[-1] + for cur in pts: + inside_cur = _clip_inside(cur, edge, left, top, right, bottom) + inside_prev = _clip_inside(prev, edge, left, top, right, bottom) + if inside_cur: + if not inside_prev: + out.append(_clip_cross(prev, cur, edge, left, top, right, bottom)) + out.append(cur) + elif inside_prev: + out.append(_clip_cross(prev, cur, edge, left, top, right, bottom)) + prev = cur + pts = out + return pts + + +def _clip_inside(point, edge, left, top, right, bottom) -> bool: + x, y = point + return (x >= left, y >= top, x <= right, y <= bottom)[edge] + + +def _clip_cross(a, b, edge, left, top, right, bottom): + (x0, y0), (x1, y1) = a, b + if edge in (0, 2): + bound = left if edge == 0 else right + t = (bound - x0) / (x1 - x0) + return bound, y0 + (y1 - y0) * t + bound = top if edge == 1 else bottom + t = (bound - y0) / (y1 - y0) + return x0 + (x1 - x0) * t, bound + + def _visible_landmasses(coast, view, rect): """Cull in world space before transforming dense coastline points.""" left, top = view.screen_to_world(rect[0], rect[1]) @@ -270,7 +351,8 @@ def draw_chart_geography(game, view, r) -> None: cached = (w, coast, key, colors) draw_map_view._bathymetry_cache = cached colors = cached[3] - cell_nm = 10.0 if view.scale >= 4.0 else 25.0 + cell_nm = (2.0 if view.scale >= 40.0 else + 10.0 if view.scale >= 4.0 else 25.0) wl, wt = view.screen_to_world(r[0], r[1]) wr, wb = view.screen_to_world(r[0] + r[2], r[1] + r[3]) x0 = max(0.0, math.floor(min(wl, wr) / cell_nm) * cell_nm) @@ -305,25 +387,27 @@ def draw_chart_geography(game, view, r) -> None: max(1, int(py2 - py) + 1))) x_nm += cell_nm y_nm += cell_nm - # Gitter (sichtbare 50-NM-Linien) - step = 10 if view.scale >= 8 else (25 if view.scale >= 3 else 50) + # Gitter: Linienabstand waechst mit dem Zoom (50 NM bis 0.1 NM). + step = grid_step_nm(view.scale) wl, wt = view.screen_to_world(r[0], r[1]) wr, wb = view.screen_to_world(r[0] + r[2], r[1] + r[3]) - gx0 = int(max(0.0, min(wl, wr)) // step) * step - gx1 = int(min(w.size_nm, max(wl, wr)) // step) * step - gy0 = int(max(0.0, min(wt, wb)) // step) * step - gy1 = int(min(w.size_nm, max(wt, wb)) // step) * step - for g in range(gx0, gx1 + 1, step): + gx0 = math.ceil(max(0.0, min(wl, wr)) / step - 1e-9) + gx1 = math.floor(min(w.size_nm, max(wl, wr)) / step + 1e-9) + gy0 = math.ceil(max(0.0, min(wt, wb)) / step - 1e-9) + gy1 = math.floor(min(w.size_nm, max(wt, wb)) / step + 1e-9) + for k in range(gx0, gx1 + 1): + g = k * step x, _ = view.world_to_screen(g, 0) if r[0] <= x <= r[0] + r[2]: lines.line(s, config.COLOR_GEO_GRID, (int(x), r[1]), (int(x), r[1] + r[3])) - s.blit(game.font.render(f"{g}", True, config.COLOR_TEXT_DIM), + s.blit(game.font.render(grid_label(g), True, config.COLOR_TEXT_DIM), (int(x) + 3, r[1] + r[3] - 18)) - for g in range(gy0, gy1 + 1, step): + for k in range(gy0, gy1 + 1): + g = k * step _, y = view.world_to_screen(0, g) if r[1] <= y <= r[1] + r[3]: lines.line(s, config.COLOR_GEO_GRID, (r[0], int(y)), (r[0] + r[2], int(y))) - s.blit(game.font.render(f"{g}", True, config.COLOR_TEXT_DIM), + s.blit(game.font.render(grid_label(g), True, config.COLOR_TEXT_DIM), (r[0] + 3, int(y) + 3)) # Land / Inseln. Legacy/fake coast providers retain their old API. @@ -334,6 +418,9 @@ def draw_chart_geography(game, view, r) -> None: for land in visible_land] if visible_land is not None else coast.land_points_px(view)) for poly in polygons: + poly = clip_polygon_to_rect(poly, r) + if len(poly) < 3: + continue lines.polygon(s, config.COLOR_LAND, poly) lines.polygon(s, config.COLOR_LAND_EDGE, poly, 1) shown_countries = set() @@ -635,6 +722,6 @@ def draw_chart_frame(game, view, r, following: bool) -> None: zoom_nm = r[3] / view.scale layout.blit_line( s, structured_message("map.line.scale_follow" if following else "map.line.scale", - zoom=f"{zoom_nm:.0f}"), + zoom=scale_label(zoom_nm)), (r[0] + 4, r[1] + 4, r[2] - 8, 20), config.COLOR_TEXT_DIM, size=13) diff --git a/src/ui/stations/opz.py b/src/ui/stations/opz.py index 5dc54052..20ed4157 100644 --- a/src/ui/stations/opz.py +++ b/src/ui/stations/opz.py @@ -487,14 +487,35 @@ def _contour_segments_in_circle(coast, cx: float, cy: float, return out +# (largest visible radius NM, grid step NM) for the OPZ chart. +_OPZ_GRID_STEPS = ((0.5, 0.1), (1.0, 0.2), (2.5, 0.5), (5.0, 1.0), (10.0, 2.0), + (20.0, 5.0), (40.0, 10.0), (80.0, 20.0)) + + +def _ring_visible(center, radius, rect) -> bool: + """True when a circle outline crosses ``rect``: it is neither wholly + outside the rect nor so large that the whole rect lies inside it.""" + cx, cy = center + left, top, right, bottom = rect.left, rect.top, rect.right, rect.bottom + near_x = min(max(cx, left), right) + near_y = min(max(cy, top), bottom) + if math.hypot(near_x - cx, near_y - cy) > radius + 2: + return False + far = max(math.hypot(x - cx, y - cy) + for x in (left, right) for y in (top, bottom)) + return far >= radius - 2 + + def _opz_basemap_surface(game, map_rect: pygame.Rect, view) -> pygame.Surface: """Build a bounded cached chart layer beneath the live OPZ radar picture.""" world = game.world coast = getattr(world, "coast", None) world_size_nm = float(getattr(world, "size_nm", config.WORLD_SIZE_NM)) - bucket_x = round(view.cx * 10.0) / 10.0 - bucket_y = round(view.cy * 10.0) / 10.0 scale = view.scale + # Re-render when the camera moved about a pixel (0.1 NM at normal zoom). + quantum = min(0.1, 1.0 / max(scale, 1e-6)) + bucket_x = round(view.cx / quantum) * quantum + bucket_y = round(view.cy / quantum) * quantum key = (world, coast, map_rect.size, round(scale, 6), bucket_x, bucket_y, config.COLOR_GEO_BG, config.COLOR_GEO_GRID, config.COLOR_LAND, config.COLOR_LAND_EDGE, @@ -528,8 +549,7 @@ def _opz_basemap_surface(game, map_rect: pygame.Rect, view) -> pygame.Surface: pygame.draw.rect(layer, color, (px, py, cell_px + 1, cell_px + 1)) visible_radius = min(map_rect.w, map_rect.h) / (2.0 * scale) - step = 5 if visible_radius <= 20 else (10 if visible_radius <= 40 else - (20 if visible_radius <= 80 else 40)) + step = next((value for limit, value in _OPZ_GRID_STEPS if visible_radius <= limit), 40) half_w_nm = map_rect.w / (2.0 * scale) half_h_nm = map_rect.h / (2.0 * scale) first_x = math.ceil((bucket_x - half_w_nm) / step) * step @@ -624,17 +644,26 @@ def draw_opz_view(game, tr=None) -> None: # Radar presentation remains ship-centred and independent of the camera. for ring_index in range(1, 5): rr = radar_radius * ring_index / 4.0 + if not _ring_visible((own_x, own_y), rr, chart): + continue pygame.draw.circle(s, config.COLOR_SONAR_RING, (int(own_x), int(own_y)), max(1, int(rr)), 1) - pygame.draw.line(s, config.COLOR_SONAR_RING, - (int(own_x - radar_radius), int(own_y)), - (int(own_x + radar_radius), int(own_y)), 1) - pygame.draw.line(s, config.COLOR_SONAR_RING, - (int(own_x), int(own_y - radar_radius)), - (int(own_x), int(own_y + radar_radius)), 1) + # Axis lines clipped to the chart (strong zoom gives huge radii). + x0 = max(chart.left, own_x - radar_radius) + x1 = min(chart.right, own_x + radar_radius) + if chart.top <= own_y <= chart.bottom and x0 < x1: + pygame.draw.line(s, config.COLOR_SONAR_RING, + (int(x0), int(own_y)), (int(x1), int(own_y)), 1) + y0 = max(chart.top, own_y - radar_radius) + y1 = min(chart.bottom, own_y + radar_radius) + if chart.left <= own_x <= chart.right and y0 < y1: + pygame.draw.line(s, config.COLOR_SONAR_RING, + (int(own_x), int(y0)), (int(own_x), int(y1)), 1) # Range labels at the top of each ring, beside the north axis. for ring_index in range(1, 5): rr = radar_radius * ring_index / 4.0 + if not chart.top - 18 <= own_y - rr <= chart.bottom: + continue layout.blit_line( s, message("map.tooltip.range_value", range=f"{max_nm * ring_index / 4.0:g}"), diff --git a/src/ui/viewport.py b/src/ui/viewport.py index 7d1aac95..15ecc70b 100644 --- a/src/ui/viewport.py +++ b/src/ui/viewport.py @@ -70,6 +70,22 @@ class Viewport: self.scale = new_scale self.clamp_center() + def step_zoom(self, direction: int, heights_nm, pivot: tuple = None) -> None: + """Jump to the next fixed chart height (NM across the rect's height). + + ``direction`` > 0 zooms in (smaller height), < 0 zooms out.""" + h = self._rect[3] + if h <= 0 or direction == 0: + return + current = h / self.scale + if direction > 0: + smaller = [v for v in heights_nm if v < current * 0.97] + target = max(smaller) if smaller else h / self.max_scale + else: + larger = [v for v in heights_nm if v > current * 1.03] + target = min(larger) if larger else h / self.min_scale + self.zoom((h / target) / self.scale, pivot=pivot) + def pan_px(self, dx_px: float, dy_px: float) -> None: """Karte um (dx_px, dy_px) verschieben (Kamera folgt dem Drag).""" self.cx -= dx_px / self.scale diff --git a/tests/test_map_zoom.py b/tests/test_map_zoom.py new file mode 100644 index 00000000..f092d15b --- /dev/null +++ b/tests/test_map_zoom.py @@ -0,0 +1,103 @@ +"""Chart zoom reaches 0.5 NM with a readable grid, clipped coast and rings.""" + +import pygame + +from src.core import config +from src.core.station import Station +from src.core.game import Game +from src.ui import map_view +from src.ui.stations import opz +from src.ui.viewport import Viewport + + +def _chart_view(): + view = Viewport(500.0, config.MAP_ZOOM_MIN_PX_PER_NM, + config.MAP_ZOOM_MAX_PX_PER_NM) + view.set_rect((0, 30, 640, 668)) + view.scale = config.MAP_ZOOM_DEFAULT_PX_PER_NM + view.cx = view.cy = 250.0 + return view + + +def _height(view): + return round(view.rect[3] / view.scale, 3) + + +def test_keys_step_through_fixed_heights_down_to_half_a_mile(): + view = _chart_view() + heights = [] + for _ in range(12): + view.step_zoom(1, config.MAP_ZOOM_STEPS_NM) + heights.append(_height(view)) + assert heights[:7] == [50.0, 25.0, 10.0, 5.0, 2.0, 1.0, 0.5] + # Past the last step the view stops at the maximum zoom. + assert view.scale == config.MAP_ZOOM_MAX_PX_PER_NM + for _ in range(12): + view.step_zoom(-1, config.MAP_ZOOM_STEPS_NM) + # Fully out shows the whole world again (min scale). + assert view.scale == config.MAP_ZOOM_MIN_PX_PER_NM + + +def test_wheel_reaches_the_same_detail_and_keeps_the_pivot(): + view = _chart_view() + pivot = (100, 200) + anchor = view.screen_to_world(*pivot) + for _ in range(40): + view.zoom(config.MAP_ZOOM_WHEEL_FACTOR, pivot=pivot) + assert view.scale == config.MAP_ZOOM_MAX_PX_PER_NM + assert _height(view) < 0.5 + x, y = view.screen_to_world(*pivot) + assert abs(x - anchor[0]) < 1e-6 and abs(y - anchor[1]) < 1e-6 + + +def test_grid_step_keeps_legacy_steps_and_gets_finer_when_zoomed(): + assert map_view.grid_step_nm(1.0) == 50.0 + assert map_view.grid_step_nm(5.0) == 25.0 + assert map_view.grid_step_nm(10.0) == 10.0 + assert map_view.grid_step_nm(100.0) == 1.0 + assert map_view.grid_step_nm(config.MAP_ZOOM_MAX_PX_PER_NM) == 0.1 + for scale in (8.0, 20.0, 60.0, 300.0, 1400.0): + assert map_view.grid_step_nm(scale) * scale >= 80.0 + assert map_view.grid_label(247.1) == "247.1" + assert map_view.grid_label(250.0) == "250" + + +def test_scale_line_shows_fractions_below_ten_miles(): + assert map_view.scale_label(0.477) == "0.5" + assert map_view.scale_label(2.0) == "2" + assert map_view.scale_label(66.8) == "67" + + +def test_polygon_clip_keeps_small_outlines_and_cuts_huge_ones(): + rect = (0, 30, 640, 668) + small = [(10.0, 40.0), (100.0, 40.0), (50.0, 90.0)] + assert map_view.clip_polygon_to_rect(small, rect) == small + huge = [(-200000.0, -200000.0), (300.0, -200000.0), (300.0, 200000.0), + (-200000.0, 200000.0)] + clipped = map_view.clip_polygon_to_rect(huge, rect) + assert len(clipped) >= 3 + assert all(-64.0 <= x <= 704.0 and -34.0 <= y <= 762.0 for x, y in clipped) + assert max(x for x, _ in clipped) == 300.0 + + +def test_ring_visibility_skips_circles_that_cannot_be_seen(): + chart = pygame.Rect(0, 0, 400, 300) + assert opz._ring_visible((200, 150), 100, chart) + assert not opz._ring_visible((200, 150), 100000, chart) + assert not opz._ring_visible((5000, 150), 100, chart) + + +def test_every_chart_draws_at_maximum_zoom(): + game = Game(seed=31, start_menu=False) + game.station = Station.BRIDGE + game.map_view.set_rect(config.MAP_RECT) + game.map_view.scale = config.MAP_ZOOM_MAX_PX_PER_NM + game.map_view.cx, game.map_view.cy = game.ship.x, game.ship.y + game.draw() + game.station = Station.OPZ + chart = opz.opz_regions()["chart"] + game._configure_opz_map_view(chart) + game.opz_map_view.scale = game.opz_map_view.max_scale + assert game.opz_map_view.max_scale == min(chart.w, chart.h) / ( + 2.0 * config.OPZ_MAP_MAX_ZOOM_RADIUS_NM) + game.draw() diff --git a/tests/test_packaging.py b/tests/test_packaging.py index 76a911d3..b3dd6384 100644 --- a/tests/test_packaging.py +++ b/tests/test_packaging.py @@ -85,7 +85,7 @@ def test_source_and_wheel_contain_editor_templates(tmp_path): (ROOT / "data/contact_analysis" / name).read_bytes() assert any(name.endswith(".dist-info/licenses/THIRD_PARTY_NOTICES.md") for name in wheel_names) - assert any(name.endswith("-1.3.35.dist-info/METADATA") for name in wheel_names) + assert any(name.endswith("-1.3.36.dist-info/METADATA") for name in wheel_names) source = next(tmp_path.glob("u_jagd-*.tar.gz")) with tarfile.open(source) as archive: @@ -137,7 +137,7 @@ def test_source_and_wheel_contain_editor_templates(tmp_path): [sys.executable, "-c", "from importlib import resources; " "assert resources.files('data.editor_templates').joinpath('mission.json').is_file(); " - "from src.core.version import APP_VERSION; assert APP_VERSION == '1.3.35'; " + "from src.core.version import APP_VERSION; assert APP_VERSION == '1.3.36'; " "from src.commander.server import CommanderServer; " "server=CommanderServer(); server.start('127.0.0.1',0); server.stop(); " "from src.core import manual; page=manual.html_page('de'); assert 'station-sonar' in page; " diff --git a/tests/test_startup.py b/tests/test_startup.py index af58b48a..3fe56a1d 100644 --- a/tests/test_startup.py +++ b/tests/test_startup.py @@ -14,9 +14,9 @@ from src.world.real_coast import sector_for_seed def test_release_version_and_exact_splash_text(): - assert APP_VERSION == "1.3.35" + assert APP_VERSION == "1.3.36" assert SPLASH_TEXT == ( - "Anti Sub Marine Warfare on uConsole by Dominik Bornhäußer Version 1.3.35" + "Anti Sub Marine Warfare on uConsole by Dominik Bornhäußer Version 1.3.36" )