diff --git a/docs/isu-rules-structure.md b/docs/isu-rules-structure.md index 0c564f6..d57936f 100644 --- a/docs/isu-rules-structure.md +++ b/docs/isu-rules-structure.md @@ -369,10 +369,10 @@ außer „Kür öffnen und hoffen". **Nutzen:** Das ist der eigentliche Grund, warum sich die Mehrsaison-Struktur für den Anwender auszahlt – nicht das Archiv, sondern der Vergleich. -**Stand:** umgesetzt (`SeasonUpgradeCheck`). Der Validator ist eine reine +**Stand:** umgesetzt (`SeasonUpgradeCheck`) inklusive PDF-Ausgabe +(`RoutinePdfExporter.build_season_comparison`). Der Validator ist eine reine Funktion über (Kür, Regelpaket); der Bericht ist die Differenz zweier Pakete -für diese eine Kür. Bis auf den PDF-Export (siehe offene Punkte) entspricht -die Umsetzung dieser Planung. +für diese eine Kür. ### Bedienung @@ -531,8 +531,12 @@ Schritte 1 und 3 sind der Hebel; alles andere baut darauf auf. - Ob die Anwender-Doku (`docs/isu-rules.md`) vollständig generiert wird oder nur die Tabellen und Zahlen. -- Ob der Upgrade-Bericht als PDF ausgegeben wird (für die Weitergabe an - Trainer und Eltern) – naheliegend, aber eigenes Feature. +- **PDF-/SVG-Sprache:** Die Exporte sind derzeit durchgehend deutsch. + `RoutinePdfExporter._text()` berechnet `I18n.t(text)`, schreibt aber den + Originaltext; viele Aufrufstellen interpolieren außerdem vorher. Eine + konsequente Übersetzung müsste die Vorlagen vor dem Einsetzen übersetzen. + Bewusst zurückgestellt, weil gemischtsprachige Blätter schlechter sind als + einheitlich deutsche. - Ob `2025/26` auch im Inspector vollständig bedienbar bleibt (Elemente anlegen) oder nur lesend geprüft wird. Die Entscheidung „alte Küren bleiben gültig" verlangt Prüfbarkeit, nicht zwingend Bearbeitbarkeit. diff --git a/docs/isu-rules.md b/docs/isu-rules.md index 2be46e7..a180e54 100644 --- a/docs/isu-rules.md +++ b/docs/isu-rules.md @@ -310,6 +310,10 @@ Export-Presets mit ausgeliefert. ## Nächste Ausbaustufen -- Max. zwei Features pro Fuß und Feature-Positionsregeln -- GOE-Tabellen und `V`-/Unterrotations-Varianten +- `V`-/Unterrotations-Varianten als Was-wäre-wenn (der Basiswert-Effekt ist + deterministisch, die Eingabe bleibt eine Annahme) - Vorschlagsliste im Inspector direkt aus `suggest()` + +**Bewusst nicht:** GOE-Tabellen. GOE ist Richterermessen über die Ausführung +(−5 bis +5) und aus dem Plan nicht ableitbar; die Punktschätzung nennt die +Lücke statt sie zu füllen. diff --git a/docs/manual.md b/docs/manual.md index a224b8f..b2ecfed 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -253,6 +253,9 @@ Sport-TV-Bauchbinde bündig am oberen Rand der Eisfläche und gleitet nach zusätzlich ihre Teilstrecken-Anzahl. Reine Laufwege ohne Element stehen nur im Rink. Lange Abschnitte werden auf weiteren Seiten fortgesetzt. Bei „Aktiver Abschnitt“ entsteht nur die Seite dieses Abschnitts. + Die untere Blatthälfte bleibt bewusst frei: Dort schreibt man mit der Hand + mit — Korrekturen, Ansagen, Zeiten. Bitte nicht mit Inhalt füllen, nur um + Platz zu nutzen. Nach dem Export erscheint der **absolute Dateipfad** mit den Buttons **Öffnen**, **Ordner anzeigen** und **Pfad kopieren**. Die Option @@ -318,6 +321,11 @@ Der Vergleich **ändert nichts**. Erst „Auf Saison umstellen" übernimmt die Saison; die Elemente bleiben unangetastet, auch wenn einzelne davon in der neuen Saison nicht mehr existieren. +**„Als PDF"** schreibt denselben Bericht in den Exportordner +(`_saisonvergleich_.pdf`) — zum Weitergeben an Trainer, Eltern +oder die Läuferin. Danach erscheint wie bei den anderen Exporten der Dialog +mit „Öffnen", „Ordner zeigen" und „Pfad kopieren". + ## Sprungkombinationen Sprungkombinationen und -folgen sind strukturiert: diff --git a/docs/refactor-whiteboard-controller.md b/docs/refactor-whiteboard-controller.md new file mode 100644 index 0000000..de9eb82 --- /dev/null +++ b/docs/refactor-whiteboard-controller.md @@ -0,0 +1,293 @@ +# WhiteboardController zerlegen + +Stand: 2026-11-13 + +Ziel: Der Controller war mit **9.092 Zeilen und 465 Funktionen** der größte +Baustein im Projekt; die Roadmap nennt < 1.500 Zeilen pro Datei. Nach den +Nach Etappe 15 sind es 8.082 Zeilen. Diese Notiz +hält die Reihenfolge fest, damit der Umbau in Etappen mit grüner Suite +passiert und nicht als Big Bang. + +## Grundregeln + +1. **Erst reine Logik, dann UI.** Textaufbau, Formatierung und Prüf-Logik + lassen sich ohne Szene testen und sind risikofrei zu verschieben. Dialoge + und Signale kommen zuletzt. +2. **Eine Etappe = ein Commit mit grüner Suite.** Keine Etappe ändert + Verhalten; die Tests bleiben unverändert, nur Aufrufstellen wandern. +3. **Kein Big Bang.** Der Controller bleibt Node und Scene-Einstiegspunkt. + Ausgelagert werden Aufgaben, nicht die Klasse. +4. **Zustand bleibt beim Controller.** `_routine`, `_current_path`, Auswahl + und Historie gehören weiter dorthin; ausgelagerte Bausteine bekommen die + Daten übergeben, statt sie zu besitzen. + +## Zielbausteine + +| Baustein | Inhalt | Zeilen (grob) | Kopplung | Etappe | +| :--- | :--- | ---: | :--- | :--- | +| `HelpContent` | Hilfetext für den ?-Dialog | 137 | keine | 1 ✅ | +| `SeasonComparisonText` | Zeilen für den Saisonvergleichs-Dialog | 175 | nur Daten | 2 ✅ | +| `ValidationReportView` | Zeilen für den Prüfdialog | 300 | nur Daten | 3 ✅ | +| `ExportService` | SVG/PDF schreiben, Pfade und Dateinamen | 90 | Dateisystem | 4 ✅ | +| `ExportPanel` | Export- und Abschlussdialog (Node mit Signalen) | 130 | Szene | 9 ✅ | +| `RulesContext` | Regelsatz: Bibliothek, Paket, drei Dokumente | 80 | keine | 5 ✅ | +| `SeasonPanelModel` | Inhalt der drei Dropdowns | 120 | keine | 6 ✅ | +| `SyncSummaryText` | Text der Sync-Zusammenfassung | 60 | keine | 7 ✅ | +| Sync-Orchestrierung | Threads, OAuth, Konflikte, Küren verwalten | ~700 | Dialoge, Threads | offen | +| `HubPanel` | Kür-Hub (Login, Upload, Downloads) | ~650 | Dialoge, Threads | 8 | +| `PlaybackPose` | Position und Blickrichtung zur Zeit | 130 | keine | 8 ✅ | +| `PlaybackPanel` | Transportleiste: Play/Pause, Reset, Slider, Tempo | 110 | Szene | 10 ✅ | +| `TimelineLabelModel` | Labels der Zeitachse einsammeln | 55 | keine | 11 ✅ | +| `SyncSettingsModel` | Anbieterliste der Sync-Einstellungen | 40 | keine | 13 ✅ | +| `RoutineManagerModel` | Küren listen, Varianten finden | 55 | Dateisystem | 14 ✅ | +| `RoutineManagerPanel` | Dialog "Küren verwalten" (eigene Szene) | 95 | Szene | 15 ✅ | +| Playback-Rest | Musik, Label-Dialog, 3D-Anbindung | ~300 | Canvas, Audio | offen | +| `ElementInspector` | Element-Dialog, Features, Level, Kombinationen | ~800 | Dialog, Regeln | 10 | + +Danach bleibt ein Controller von grob 2.000–2.500 Zeilen: Verdrahtung, +Auswahl, Werkzeuge, Abschnitte, Undo/Redo, Statuszeile. + +## Etappen + +### 1. `HelpContent` ✅ + +Der Hilfetext ist ein reiner String. Verschoben nach +`src/whiteboard/view/help_content.gd` (`HelpContent.build()`), der Controller +setzt ihn nur noch in den Dialog. Kein Verhalten geändert. + +### 2. `SeasonComparisonText` ✅ + +Der Text des Saisonvergleichs (Kopf, Gruppen, Summe, Befunde) liegt jetzt in +`src/whiteboard/view/season_comparison_text.gd`. `build(routine, report)` +gibt die BBCode-Zeilen zurück; der Controller setzt sie nur noch in das +Label. Kein Verhalten geändert. + +### 3. `ValidationReportView` ✅ + +Der komplette Text des Prüfdialogs (Kopf, Saisonhinweis, Kategorie, +Basiswert, Punktschätzung, Wertung, Prüfliste, Befunde) liegt in +`src/whiteboard/view/validation_report_view.gd`. Signatur: +`build(routine, report, category, context)` mit einem kleinen Kontext für die +Anzeige-Optionen (Saison-Label, Saisonhinweis, Vergleich-Link, aufgeklappte +Details). Der Controller baut nur noch den Report und setzt das Label. + +Fertig: Dialog unverändert, Whiteboard-Test grün, eigener Test für den Text. + +### 4. `ExportService` ✅ + +`src/whiteboard/io/export_service.gd` schreibt SVG und PDF, legt den +Exportordner an, bildet Pfade und bereinigt Dateinamen. Der Controller +delegiert nur noch; `export_svg_to_path`/`export_pdf_to_path` bleiben als +schmale Einstiegspunkte, weil Tests sie direkt aufrufen. + +Bewusst im Controller geblieben: der Export-Dialog und der +Abschluss-Dialog (Szene), der PNG-Export (braucht ein SubViewport) und das +Öffnen im Dateimanager. + +### 5. `RulesContext` ✅ + +Der Regelsatz selbst ist jetzt ein eigenes Objekt +(`src/core/rules/rules_context.gd`): Es lädt die Bibliothek, merkt sich die +Voreinstellung, wendet eine Saison an und hält die drei Dokumente +(`catalog`, `levels`, `adult`). Der Controller besitzt genau eine Instanz +(`_ruleset`) und greift nur noch über sie zu; `_load_default_rules` und +`_apply_rules_for_season` sind auf je ein paar Zeilen geschrumpft. + +Damit ist die Regelauflösung testbar, ohne eine Szene zu bauen. + +Was noch offen bleibt: die drei Statusleisten-Widgets (Saison, Programm, +Kategorie) und ihre Sync-Funktionen. Sie sind reine UI und kommen als +eigener Node-Schnitt. + +### 6. `SeasonPanelModel` ✅ + +Der Inhalt der drei Dropdowns (Saison, Programm, Kategorie) liegt in +`src/whiteboard/view/season_panel_model.gd`: reine Funktionen, die +Beschriftungen und Werte bauen und die passende Auswahl zurückgeben +(`{"items": […], "selected": int}`). Der Controller füllt seine +OptionButtons nur noch über `_fill_option()` und behält die +Signalverdrahtung. + +Damit sind Fälle testbar, die vorher nur über die Szene prüfbar waren: +„nicht festgelegt", unbekannte Saison, unbekannte Kategorie (bleibt als +„nicht verfügbar" sichtbar), Programmtyp. + +Noch offen: die Widgets selbst als Node mit Signalen. Das ist reiner +Verdrahtungsumbau ohne Verhaltensänderung und lohnt erst, wenn Panels auch +Layout-Verantwortung übernehmen (Roadmap: „UI in logische Bereiche +gliedern"). + +### 7. `SyncSummaryText` ✅ (Textteil) + +Der Text der Sync-Zusammenfassung liegt in +`src/whiteboard/view/sync_summary_text.gd`; der Controller setzt nur noch das +Label. Die Zusammenfassung ist damit ohne Szene prüfbar (der Sync-Test nutzt +sie direkt). + +**Bewusst offen:** die Orchestrierung selbst — Thread starten und pollen, +OAuth, Konflikte aufräumen, Küren verwalten (zusammen ~700 Zeilen). Sie +braucht einen Node mit Signalen, weil Fortschritt, Dialoge und Threads +zusammenhängen, und sie ändert die Aufrufstellen in `run_sync_tests`. Das ist +ein eigener Durchgang, kein Nachtrag. + +### 8. `PlaybackPose` ✅ + +Die Wiedergabe-Geometrie liegt in `src/whiteboard/view/playback_pose.gd`: +`compute(entries, time, previous_heading, delta, force_heading)` liefert +Segment, Position, Blickrichtung und Markergröße. Die Markenlogik (Pirouette +dreht mit der Standzeit, Sprung dreht pro Umdrehung und wandert entlang des +Sprungvektors, Laufwege folgen der Kurve) steckt vollständig dort. + +Der Controller wendet das Ergebnis nur noch auf Canvas, 3D-Vorschau und +Oberfläche an. Abgesichert durch die bestehenden Wiedergabetests (121 +Assertions). + +**Offen:** Steuerung (Start/Pause/Reset, Geschwindigkeit), Musik und +Timeline-Labels sowie die 3D-Anbindung. + +### 10. `ElementInspector` + +Zuletzt: Element-Dialog, Feature-Auswahl, Fußzuordnung, Levelableitung. Der +größte UI-Block und der, an dem am meisten hängt. + +## Erster Node-Schnitt (2026-11-13) + +`ExportPanel` (`src/whiteboard/view/export_panel.gd`) besitzt jetzt die +beiden Exportdialoge und meldet nur die Auswahl: + +``` +Panel ──export_requested(pfad, format, abschnitt, danach öffnen)──▶ Controller +``` + +Der Controller prüft, ob die Datei existiert (`_confirm_overwrite` bleibt die +einzige Stelle dafür), schreibt über `ExportService` und ruft +`panel.show_done()`. Das Panel fasst kein Dateisystem an. + +Was beim Umhängen der Szene zu beachten war: + +- `parent=` in `.tscn` ist **absolut** ab Wurzel, nicht relativ zum vorigen + Knoten. Nach dem Umhängen müssen auch alle Kindknoten ihren Pfad ändern + (`ExportDialog/…` → `ExportPanel/ExportDialog/…`), sonst verschwinden sie + beim Instanziieren mit „Parent path … has vanished". +- Der neue Knoten braucht `script = ExtResource(...)` **und** eine + `ext_resource`-Zeile; ohne Skript bleibt eine typisierte `@onready`-Zuweisung + still null. +- `load_steps` in der Kopfzeile muss mitwachsen. + +### 10. `PlaybackPanel` ✅ + +Die Transportleiste (Play/Pause, Reset, Zeitschieber, Zeitanzeige, Tempo) ist +ein Node mit Signalen: `toggle_requested`, `reset_requested`, +`seek_requested(seconds)`, `speed_requested(speed)`. Der Controller besitzt +weiter Uhr, Tempo und Audio und ruft `set_state(time, duration, playing)`. + +Anders als beim Export brauchte es **kein Umhängen**: Die Widgets bleiben in +der Layout-Leiste, das Panel findet sie über `unique_name_in_owner`. Ein Node +ohne Control-Basis kann in einem HBox nicht sinnvoll Kindknoten aufnehmen. + +`_update_playback_ui` und `_update_play_button` sind zu `_sync_playback_ui()` +verschmolzen; die Zeitachse (`timeline_label_lane`) bleibt beim Controller, +weil sie zu den Timeline-Labels gehört. + +### 11. `TimelineLabelModel` ✅ + +Das Einsammeln der Timeline-Labels liegt in +`src/whiteboard/view/timeline_label_model.gd`. Es ist subtiler, als es aussieht: +Es läuft über die Abschnitte (nicht über die Wiedergabe-Einträge), damit +Marken ohne Standzeit sichtbar bleiben, und ein Segment ohne eigenes Label +erbt die Beschriftung seiner Elementgruppe — so wird eine Sequenz einmal +benannt. Abgesichert durch die Wiedergabetests, die die Labels der Zeitachse +prüfen. + +**Offen:** der Label-Dialog (Anlegen/Bearbeiten/Löschen) und die Musik +(Laden, Konvertierung, Synchronisation). + +### 12. `ExportPanel` als eigene Szene ✅ + +`scenes/export/export_panel.tscn` enthält die beiden Dialoge und das Skript; +die Whiteboard-Szene instanziiert sie nur noch. Dazu gibt es +`tests/run_export_panel_tests.gd`: Es lädt **nur** diese Szene, hängt sie an +den Root und prüft die Signale — kein WhiteboardController, keine Kür-Szene. + +Das ist die Messung, um die es ging: 15 Assertions laufen ohne die 8.154 +Zeilen Controller. Der Baustein ist damit nicht nur im Code getrennt. + +Zwei Stolpersteine beim Auslagern einer Szene: + +- Kindknoten eines Szenen-Roots nutzen `parent="."`, nicht den Root-Namen. +- Ein eigener Test braucht `root.size` vor `popup_centered`, sonst platziert + Godot die Fenster bei headless-Läufen auf negative Koordinaten. + +### 13. `SyncSettingsModel` ✅ + +Die Anbieterliste der Sync-Einstellungen liegt in +`src/whiteboard/view/sync_settings_model.gd`: Das Build-Konfigurationsobjekt +geht rein, die auswählbaren Anbieter kommen raus. Google Drive erscheint nur +mit OAuth-Zugangsdaten; Dropbox bleibt auch ohne sichtbar, damit ein +Entwickler-Build die fehlende Konfiguration zeigt statt einer leeren Liste. + +**Warum hier kein eigener Dialog-Schnitt folgt:** Der Sync-Dialog enthält +Sync *und* Hub (rund 30 Widgets) und hängt an Threads und OAuth-Zustand. Eine +eigene Szene ohne verschobenes Verhalten ergäbe einen Test, der nur prüft, +dass Widgets existieren — das ist keine Aussage über Modularität. + +### 14. `RoutineManagerModel` ✅ + +Die Kürenverwaltung bekommt ihren Verhaltenskern: `list_routines(dir)` liefert +eine Zeile pro Kür (JSON vor Legacy, nach Namen sortiert, Fremddateien +ignoriert), `variants(dir, name)` alle vorhandenen Dateien einer Kür. + +Damit ist die Grundlage für den späteren Panel-Schnitt gelegt — und der +Dateizugriff ist ohne Szene prüfbar (Test mit einem temporären Ordner: +Dubletten, Sortierung, Fremddateien, fehlende Kür). + +**Noch offen:** der Dialog selbst. Seine Zeilenknöpfe sind an +Controller-Handler gebunden (`open`, `rename`, `delete`, Konflikte), und die +Abläufe brauchen Sync und den aktuellen Dateipfad. Der nächste Schritt wäre, +diese Abläufe als `RoutineManagerActions` zu bündeln, dann das Panel. + +### 15. `RoutineManagerPanel` ✅ + +Der Dialog „Küren verwalten" liegt in `scenes/routine/routine_manager_panel.tscn` +mit eigenem Skript. Das Panel baut die Zeilen (Öffnen / Umbenennen / Löschen) +und meldet die Auswahl; die Abläufe — Datei öffnen, umbenennen, löschen, +Konflikte suchen — bleiben beim Controller, weil sie Dateien, den aktuellen +Pfad und den Sync brauchen. + +`tests/run_routine_manager_panel_tests.gd` prüft das Panel allein: Zeilen, +Signalnutzlast, Neuaufbau, Leerzustand, Öffnen/Schließen (13 Assertions). + +Merke: `%Name` gilt nur innerhalb der Szene, die den Knoten besitzt. Der +Controller musste deshalb auf `manager_tabs` verzichten — die Tabs liegen +jetzt im Panel. + +## Nächster Durchgang: weitere Node-Schnitte + +Die vier verbleibenden Blöcke (Sync-Orchestrierung, Hub, Playback-Rest, +Element-Inspector) lassen sich nicht mehr als reine Funktionen herausziehen; +sie brauchen eigene Nodes mit Signalen. Geprüft am 2026-11-13: + +- **Die Dialoge hängen direkt an der Wurzel** der Szene (31 Knoten mit + `parent="."`). Ein Panel braucht sie als Kinder, also `parent="ExportPanel"` + statt `parent="."`. +- **Das ist harmlos:** Alle Dialoge nutzen `unique_name_in_owner`, `%Name` + löst szenenweit auf. Ein Umhängen bricht weder den Controller noch die + Skripte, nur den Zugriff über Pfade (den gibt es hier nicht). +- **Der Aufwand liegt bei den Tests:** `run_sync_tests` greift direkt auf Controller-Felder zu + (`controller.export_dialog`, `controller.export_done_label`, + `controller.routine_manager_dialog`, `controller.cleanup_conflicts_dialog`). + Diese Zugriffe wandern auf `controller..`. +- **Eine geteilte Abhängigkeit:** Der Export nutzt `_confirm_overwrite()`, + das auch „Speichern unter" verwendet. Entweder bekommt das Panel einen + eigenen Bestätigungsdialog oder der Controller reicht einen Callback durch. + Diese Entscheidung sollte vor dem Umbau fallen. + +Reihenfolge: erst Export (kleinster Block, ~150 Zeilen), dann Playback-Rest, +dann Sync, zuletzt Hub und Element-Inspector. + +## Was bewusst bleibt + +- `_ready()` und die Signalverdrahtung der Szene. +- Undo/Redo und die Historie (arbeiten auf dem gesamten Kürzustand). +- Die Statuszeile als Zusammenfassung (`_update_status`), solange Panels sie + nicht selbst besitzen. diff --git a/docs/roadmap.md b/docs/roadmap.md index dc7010b..b027743 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -87,7 +87,6 @@ Voraussetzung für Phase 1. - [x] Windows-EXE mit Icon und Versionsinformationen (rcedit über portables Wine, `tools/setup_windows_export.sh`) - [ ] Release-Keystore für ein verteilbares APK -- [ ] Hochformat-, Multi-Window- und DeX-Layout (obere Leiste umbruchfähig) ### Erledigt: Touch-/Tablet-Härtung @@ -120,6 +119,16 @@ Webseite). Das Google-Drive-Backend ist im Code vorhanden, aber die OAuth-App ist nicht veröffentlicht. Google Drive und OneDrive stehen unter „Später: Weitere Cloud-Anbieter“. +**Rückmeldung der Fachtester (2026-11-13):** Sync wurde nicht genutzt – die +Tester arbeiten zuhause am PC und drucken die Abläufe aus. Sync bleibt als +Funktion (für andere Käufer und mehrere Geräte), wird aber nicht ausgebaut. +Der Ausdruck ist damit der Weg, den die PDF-Ausgabe tragen muss. + +**Kür-Hub:** ebenfalls noch ungenutzt, aber mit anderem Potential: Die +Tester wohnen weit auseinander, und der Hub ist der einzige Weg, sich +gegenseitig Küren zu zeigen. Abzuwarten, ob dieser Effekt greift, bevor hier +investiert wird. + ### Erledigt: Element-Marker - [x] Sprungpunkte, Pirouettenzentren und Sequenzbereiche platzieren @@ -193,8 +202,8 @@ OAuth-App ist nicht veröffentlicht. Google Drive und OneDrive stehen unter - [x] PCS und Sturzabzüge in der Punktschätzung (mit Annahmen) - [x] In-App-Hilfe „Hilfe & Annahmen“ und `docs/manual.md` - [ ] Optional: Suchfeld/Autovervollständigung aus `suggest()` -- [ ] Optional: GOE-Tabellen sowie `V`-/Unterrotationsvarianten - (2026-11-01 vorerst zurückgestellt) +- [ ] Optional: `V`-/Unterrotationsvarianten als Was-wäre-wenn + (Basiswert-Effekt ist deterministisch; Eingabe bleibt eine Annahme) ### Danach: Weitere fachliche Erweiterungen @@ -212,20 +221,19 @@ fachlichen Validierung angefasst. - [ ] Manuelles Zusammenführen mit der archivierten Fassung - [x] Löschweitergabe für einzelne Küren mit Bestätigung (Küren verwalten) - [ ] Optional: Sync-Ordner pro Anbieter getrennt konfigurieren -- [ ] Hochformat-, Multi-Window- und DeX-Layout (obere Leiste umbruchfähig) - [ ] Visuelles UI-Refactoring (z. B. Buttons statt Comboboxen) inklusive Übernahme des Feedbacks der Tester Die Reihenfolge ist bewusst: native Builds, Datenaustausch und Element-Marker -sind erledigt. Im PoC läuft jetzt das ISU-Regelwerk – Katalog 2026/27, +sind erledigt. Im PoC läuft das ISU-Regelwerk – Katalog 2026/27, Level-Features, Elementvalidierung, Adult-Kategorien, Dauer und -Wiederholungs-/Kombinationsgrenzen stehen; als Nächstes folgt die -Mehrsaison-Struktur (Regelpaket pro Saison, alte Küren bleiben gegen ihre -eigene Saison prüfbar) samt Saison-Upgrade-Prüfung, danach Feature-Grenzen pro -Fuß. GOE und Varianten sind vorerst zurückgestellt. Sync-Komfort und -UI-Refactoring sind zurückgestellt, weil der bestehende Stand für Tests -genügt und die endgültige Sync-Architektur (PHP-Webserver) sowie das -UI-Feedback der Tester ohnehin noch ausstehen. +Wiederholungs-/Kombinationsgrenzen stehen, ebenso die Mehrsaison-Struktur +(Regelpaket pro Saison, alte Küren bleiben gegen ihre eigene Saison prüfbar) +mit Saison-Upgrade-Prüfung und die Feature-Grenzen pro Fuß. GOE ist bewusst +ausgeschlossen (Richterermessen), die `V`-Varianten sind zurückgestellt. +Sync-Komfort und UI-Refactoring sind zurückgestellt, weil der bestehende +Stand für Tests genügt und die endgültige Sync-Architektur (PHP-Webserver) +sowie das UI-Feedback der Tester ohnehin noch ausstehen. ### Später: Weitere Cloud-Anbieter @@ -269,13 +277,20 @@ Schritte. - [ ] `WhiteboardController` in Services/Panels zerlegen: Datei-I/O, Sync, Playback, Validierung, Element-Inspector, Section-Liste. Ziel: < 1.500 - Zeilen pro Datei, keine 100 `%`-Lookups in einem Skript. + Zeilen pro Datei, keine 100 `%`-Lookups in einem Skript. In Etappen nach + `docs/refactor-whiteboard-controller.md`; Stand 2026-11-13: 8.154 Zeilen; `HelpContent`, `SeasonComparisonText`, + `ValidationReportView`, `ExportService`, `RulesContext`, + `SeasonPanelModel`, `SyncSummaryText`, `PlaybackPose`, `ExportPanel`, + `PlaybackPanel`, `TimelineLabelModel`, `SyncSettingsModel`, + `RoutineManagerModel`, `RoutineManagerPanel` und zwei eigenständigen + Panel-Tests ausgelagert. - [ ] Gemeinsamer Test-Harness (oder gdUnit4), Timeout pro Testlauf, Coverage; CI auf dem Gitea-/Forgejo-Remote mit `tools/test.sh` und `tools/check_export.sh`. -- [ ] Saison datengetrieben: Saison-Auswahl/Default aus `data/`, 2025/26 - auswählbar machen oder entfernen; Regelstand im UI anzeigen. +- [x] Saison datengetrieben: Saison-Auswahl aus `data/`, Voreinstellung nach + `valid_from`, Regelstand in Statusleiste und Prüfdialog. - [ ] Android-Export teilen: Share-Intent/SAF statt nur `user://exports/`. + Zurückgestellt am 2026-11-13: kein Testgerät verfügbar. - [ ] `Ctrl+S`/`Ctrl+O`/`Ctrl+N` und sichtbarer Speicherstatus (auch ohne Fenstertitel auf Android). @@ -290,7 +305,7 @@ Schritte. Schriftgrößen; kompakte Labels nicht mehr im Controller. - [ ] Canvas: Culling/Dirty-Regions, Kurven-Cache auch für Pan/Zoom; Perf-Test mit realistischem Budget (< 16 ms bei 480 Segmenten). -- [ ] Doku konsolidieren: 18 `findings-*.md` nach `docs/notes/` oder ins +- [ ] Doku konsolidieren: 25 `findings-*.md` nach `docs/notes/` oder ins Archiv; Architektur/Manual als aktuelle Quellen; Docstrings und Assertion-Zahlen pflegen. - [ ] Altlasten entfernen: `Flieger.obj` (nur Prototyp), alte @@ -336,6 +351,12 @@ Schritte. ## Bewusst nicht jetzt +- **Hochformat und DeX-Layout.** Die Eisfläche ist Querformat, und das Tablet + wird intuitiv so gehalten. Eine Hochformat-Fassung würde die Leisten + umbrechen oder Werkzeuge verstecken, ohne dem Planen zu helfen. Entschieden + am 2026-11-13; die Querformat-Leisten müssen nur auf schmalen + Querformat-Breiten passen (erledigt für 1400 logische Punkte). + - Native PDF-Ausgabe mit Bildern/Screenshots (die aktuelle PDF-Ausgabe ist vektorbasiert und enthält keine Fotos) - Vollständiges ISU-Regelwerk vor dem stabilen Planungs-Workflow @@ -343,6 +364,12 @@ Schritte. - Google Drive und OneDrive (aktuell reicht Dropbox; siehe „Später: Weitere Cloud-Anbieter“) - 3D-Produktionsreife +- **GOE-Tabellen.** GOE vergibt der Richter nach der Ausführung (−5 bis +5, + Kriterien wie Höhe, Fluss, Landung). Es ist aus einem Plan nicht ableitbar; + die App würde eine Zahl vortäuschen, die sie nicht kennt. Die + Punktschätzung bleibt deshalb bei Basiswert + PCS-Annahme − Sturzabzug und + benennt die Lücke (`docs/manual.md`). Auch die Maximalwerte je Elementtyp + als Bandbreite wären faktisch korrekt, aber für die Planung nutzlos. ### Weitere Disziplinen diff --git a/docs/updates.md b/docs/updates.md index ca33645..2276681 100644 --- a/docs/updates.md +++ b/docs/updates.md @@ -203,11 +203,11 @@ kein Netzwerkzugriff statt. ## Aktueller Stand und Übergang -- **0.3.0** ist seit 2026-11-13 für macOS und Windows veröffentlicht: Mehrere - Saisons (Regelwerk als Saisonordner mit Invariantenprüfung), Saison an der - Kür, Saison-Vergleich, Artistic als eigener Programmtyp (ohne - Punktschätzung) und die Feature-Grenzen aus ISU 2788. Das DMG wurde am - 13.11. nachgezogen; `downloads.macos` steht seitdem im Endpunkt. +- **0.3.0** ist seit 2026-11-13 für macOS und Windows veröffentlicht: + Mehrere Saisons (Regelwerk als Saisonordner mit Invariantenprüfung), Saison + an der Kür, Saison-Vergleich inklusive PDF-Bericht, Artistic als eigener + Programmtyp (ohne Punktschätzung) und die Feature-Grenzen aus ISU 2788. + Windows-Installer 30,3 MB, macOS-DMG 68,1 MB. - **0.2.3** ist seit 2026-11-12 für macOS und Windows veröffentlicht: Beim Schließen werden laufende Hintergrund-Verbindungen (Update-Check, Sync) eingesammelt; ein früher Ausstieg führt nicht mehr zu einem Absturz. Das @@ -221,11 +221,10 @@ kein Netzwerkzugriff statt. - **0.2.1** (2026-11-12): neuer Skater im Kürkleid, kontrastreichere 3D-Bande und ein schlankerer Build (frühere Modellvarianten entfernt, Installer 29 statt 32 MB). -- **macOS** ist seit dem 0.2.2-Release im Endpunkt (DMG, 65 MB); mit 0.2.3 und - 0.3.0 wurde das DMG jeweils nachgezogen. `publish_version.sh` übernimmt - Einträge anderer Plattformen nur, wenn die Live-Version zur neuen passt – ein - fehlendes DMG führt also nicht zu einem Hinweis auf eine Version ohne - Installer. +- **macOS** ist seit dem 0.2.2-Release im Endpunkt (DMG, 65 MB); mit 0.2.3 + wurde das DMG nachgezogen. `publish_version.sh` übernimmt Einträge anderer + Plattformen nur, wenn die Live-Version zur neuen passt – ein fehlendes DMG + führt also nicht zu einem Hinweis auf eine Version ohne Installer. - **Windows** ist seit 2026-11-11 im Endpunkt; die Installer enthalten die Update-Prüfung. - **Übergang von 0.1.0:** Die Version 0.1.0 enthält die Update-Prüfung noch diff --git a/rinkplanner/assets/i18n/strings.csv b/rinkplanner/assets/i18n/strings.csv index 1ccd983..4005aa7 100644 --- a/rinkplanner/assets/i18n/strings.csv +++ b/rinkplanner/assets/i18n/strings.csv @@ -798,3 +798,17 @@ "Fuß nicht angegeben für „%s“; max. zwei Features pro Fuß sind nicht prüfbar.","Fuß nicht angegeben für „%s“; max. zwei Features pro Fuß sind nicht prüfbar.","Foot missing for “%s”; the limit of two features per foot cannot be checked." "„%s“: %d Features auf einem Fuß, es zählen höchstens %d.","„%s“: %d Features auf einem Fuß, es zählen höchstens %d.","“%s”: %d features on one foot, at most %d count." "Bei „%s“ zählen höchstens %d Features der Gruppe „%s“.","Bei „%s“ zählen höchstens %d Features der Gruppe „%s“.","In “%s” at most %d features of the group “%s” count." +"Als PDF","Als PDF","As PDF" +"Kategorie: %s","Kategorie: %s","Category: %s" +"%d Abschnitte","%d Abschnitte","%d sections" +"Musik: %s","Musik: %s","Music: %s" +"+ %d weitere","+ %d weitere","+ %d more" +"Abschnitt","Abschnitt","Section" +"Abschnitte","Abschnitte","Sections" +"#","#","#" +"Fehler","Fehler","Error" +"Warnung","Warnung","Warning" +"Hinweis","Hinweis","Note" +"%s — nicht im Katalog","%s — nicht im Katalog","%s — not in the catalog" +"%s — Feature „%s“ in der Ziel-Saison unbekannt","%s — Feature „%s“ in der Ziel-Saison unbekannt","%s — feature “%s” unknown in the target season" +"• %s — in der Ziel-Saison nicht vorhanden","• %s — in der Ziel-Saison nicht vorhanden","• %s — not available in the target season" diff --git a/rinkplanner/assets/icons/boot_splash.png b/rinkplanner/assets/icons/boot_splash.png new file mode 100644 index 0000000..8424a34 Binary files /dev/null and b/rinkplanner/assets/icons/boot_splash.png differ diff --git a/rinkplanner/assets/icons/boot_splash.png.import b/rinkplanner/assets/icons/boot_splash.png.import new file mode 100644 index 0000000..5301610 --- /dev/null +++ b/rinkplanner/assets/icons/boot_splash.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://f72ldr1lvtq3" +path="res://.godot/imported/boot_splash.png-c2760ae15293ca9a9d17190592935c1e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/icons/boot_splash.png" +dest_files=["res://.godot/imported/boot_splash.png-c2760ae15293ca9a9d17190592935c1e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/rinkplanner/export_presets.cfg b/rinkplanner/export_presets.cfg index f09f2bd..59d0b2d 100644 --- a/rinkplanner/export_presets.cfg +++ b/rinkplanner/export_presets.cfg @@ -66,8 +66,8 @@ application/modify_resources=true application/icon="res://assets/icons/app_icon.png" application/console_wrapper_icon="" application/icon_interpolation=4 -application/file_version="0.3.0.0" -application/product_version="0.3.0.0" +application/file_version="0.4.0.0" +application/product_version="0.4.0.0" application/company_name="" application/product_name="Rinkplanner" application/file_description="2D-Whiteboard für Eiskunstlauf" @@ -118,8 +118,8 @@ application/icon_interpolation=4 application/bundle_identifier="de.rinkplanner.app" application/signature="" application/app_category="Education" -application/short_version="0.3.0" -application/version="0.3.0" +application/short_version="0.4.0" +application/version="0.4.0" application/copyright="" application/copyright_localized={} application/min_macos_version_x86_64="11.00" @@ -243,8 +243,8 @@ keystore/debug_password="" keystore/release="" keystore/release_user="" keystore/release_password="" -version/code=5 -version/name="0.3.0" +version/code=6 +version/name="0.4.0" package/unique_name="de.rinkplanner.app" package/name="Rinkplanner" package/signed=true diff --git a/rinkplanner/project.godot b/rinkplanner/project.godot index 7520cf5..049698d 100644 --- a/rinkplanner/project.godot +++ b/rinkplanner/project.godot @@ -15,10 +15,15 @@ compatibility/default_parent_skeleton_in_mesh_instance_3d=true [application] config/name="Rinkplanner" -config/version="0.3.0" +config/version="0.4.0" run/main_scene="res://scenes/whiteboard/whiteboard.tscn" config/features=PackedStringArray("4.7", "Forward Plus") config/icon="res://assets/icons/app_icon.png" +boot_splash/image="res://assets/icons/boot_splash.png" +boot_splash/bg_color=Color(0.043137, 0.070588, 0.12549, 1) +boot_splash/show_image=true +boot_splash/fullsize=false +boot_splash/minimum_display_time=0 [autoload] @@ -26,6 +31,9 @@ GodotAIBridgeRuntime="*res://addons/godot_ai_bridge/runtime_bridge.gd" [display] +; Querformat ist gesetzt: Die Eisfläche ist breiter als hoch, und das Tablet +; wird so gehalten. Eine Hochformat-Fassung ist bewusst nicht geplant. +window/handheld/orientation=0 window/size/viewport_width=1440 window/size/viewport_height=900 window/stretch/aspect="expand" diff --git a/rinkplanner/scenes/export/export_panel.tscn b/rinkplanner/scenes/export/export_panel.tscn new file mode 100644 index 0000000..ac43ee1 --- /dev/null +++ b/rinkplanner/scenes/export/export_panel.tscn @@ -0,0 +1,134 @@ +[gd_scene load_steps=2 format=3] + +[ext_resource type="Script" path="res://src/whiteboard/view/export_panel.gd" id="1_export_panel"] + +[node name="ExportPanel" type="Node"] +unique_name_in_owner = true +script = ExtResource("1_export_panel") + +[node name="ExportDialog" type="ConfirmationDialog" parent="."] +unique_name_in_owner = true +title = "Kür exportieren" +size = Vector2i(480, 520) +wrap_controls = false +ok_button_text = "Exportieren" +cancel_button_text = "Abbrechen" + +[node name="ExportScroll" type="ScrollContainer" parent="ExportDialog"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 8.0 +offset_top = 8.0 +offset_right = -8.0 +offset_bottom = -64.0 +grow_horizontal = 2 +grow_vertical = 2 +horizontal_scroll_mode = 0 +follow_focus = true + +[node name="ExportBox" type="VBoxContainer" parent="ExportDialog/ExportScroll"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_constants/separation = 4 + +[node name="ExportNameLabel" type="Label" parent="ExportDialog/ExportScroll/ExportBox"] +layout_mode = 2 +text = "Dateiname" + +[node name="ExportNameEdit" type="LineEdit" parent="ExportDialog/ExportScroll/ExportBox"] +unique_name_in_owner = true +custom_minimum_size = Vector2(0, 48) +layout_mode = 2 + +[node name="ExportFormatLabel" type="Label" parent="ExportDialog/ExportScroll/ExportBox"] +layout_mode = 2 +text = "Format" + +[node name="ExportFormatOption" type="OptionButton" parent="ExportDialog/ExportScroll/ExportBox"] +unique_name_in_owner = true +custom_minimum_size = Vector2(0, 48) +layout_mode = 2 + +[node name="ExportScopeLabel" type="Label" parent="ExportDialog/ExportScroll/ExportBox"] +layout_mode = 2 +text = "Umfang" + +[node name="ExportScopeOption" type="OptionButton" parent="ExportDialog/ExportScroll/ExportBox"] +unique_name_in_owner = true +custom_minimum_size = Vector2(0, 48) +layout_mode = 2 + +[node name="ExportHint" type="Label" parent="ExportDialog/ExportScroll/ExportBox"] +custom_minimum_size = Vector2(0, 34) +layout_mode = 2 +theme_override_colors/font_color = Color(0.580392, 0.639216, 0.721569, 1) +theme_override_font_sizes/font_size = 12 +text = "Ziel: export-Ordner im App-Datenverzeichnis · der absolute Pfad erscheint nach dem Export" +autowrap_mode = 3 + +[node name="ExportOpenAfterCheck" type="CheckBox" parent="ExportDialog/ExportScroll/ExportBox"] +unique_name_in_owner = true +custom_minimum_size = Vector2(0, 44) +layout_mode = 2 +button_pressed = true +text = "Nach dem Export öffnen" +tooltip_text = "Ergebnis nach dem Export mit dem Standardprogramm öffnen" + +[node name="ExportDoneDialog" type="AcceptDialog" parent="."] +unique_name_in_owner = true +title = "Export abgeschlossen" +size = Vector2i(660, 320) +wrap_controls = false +exclusive = false +ok_button_text = "Schließen" + +[node name="ExportDoneBox" type="VBoxContainer" parent="ExportDoneDialog"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 12.0 +offset_top = 12.0 +offset_right = -12.0 +offset_bottom = -64.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/separation = 4 + +[node name="ExportDoneLabel" type="RichTextLabel" parent="ExportDoneDialog/ExportDoneBox"] +unique_name_in_owner = true +custom_minimum_size = Vector2(0, 96) +layout_mode = 2 +size_flags_vertical = 3 +bbcode_enabled = false +scroll_active = false +selection_enabled = true +autowrap_mode = 3 + +[node name="ExportDoneButtons" type="HFlowContainer" parent="ExportDoneDialog/ExportDoneBox"] +layout_mode = 2 +theme_override_constants/h_separation = 6 +theme_override_constants/v_separation = 8 + +[node name="ExportOpenButton" type="Button" parent="ExportDoneDialog/ExportDoneBox/ExportDoneButtons"] +unique_name_in_owner = true +custom_minimum_size = Vector2(140, 48) +layout_mode = 2 +text = "Öffnen" +tooltip_text = "Datei mit dem Standardprogramm öffnen" + +[node name="ExportFolderButton" type="Button" parent="ExportDoneDialog/ExportDoneBox/ExportDoneButtons"] +unique_name_in_owner = true +custom_minimum_size = Vector2(180, 48) +layout_mode = 2 +text = "Ordner anzeigen" +tooltip_text = "Exportordner im Dateimanager öffnen" + +[node name="ExportCopyPathButton" type="Button" parent="ExportDoneDialog/ExportDoneBox/ExportDoneButtons"] +unique_name_in_owner = true +custom_minimum_size = Vector2(170, 48) +layout_mode = 2 +text = "Pfad kopieren" +tooltip_text = "Absoluten Dateipfad in die Zwischenablage kopieren" diff --git a/rinkplanner/scenes/routine/routine_manager_panel.tscn b/rinkplanner/scenes/routine/routine_manager_panel.tscn new file mode 100644 index 0000000..222d171 --- /dev/null +++ b/rinkplanner/scenes/routine/routine_manager_panel.tscn @@ -0,0 +1,77 @@ +[gd_scene load_steps=2 format=3] + +[ext_resource type="Script" path="res://src/whiteboard/view/routine_manager_panel.gd" id="1_manager_panel"] + +[node name="RoutineManagerPanel" type="Node"] +unique_name_in_owner = true +script = ExtResource("1_manager_panel") + +[node name="RoutineManagerDialog" type="AcceptDialog" parent="."] +unique_name_in_owner = true +title = "Küren verwalten" +size = Vector2i(800, 600) +exclusive = false +ok_button_text = "Schließen" + +[node name="ManagerBox" type="VBoxContainer" parent="RoutineManagerDialog"] +offset_left = 12.0 +offset_top = 12.0 +offset_right = 788.0 +offset_bottom = 530.0 +theme_override_constants/separation = 4 + +[node name="ManagerHint" type="Label" parent="RoutineManagerDialog/ManagerBox"] +layout_mode = 2 +theme_override_colors/font_color = Color(0.580392, 0.639216, 0.721569, 1) +theme_override_font_sizes/font_size = 14 +text = "Lokale Küren löschen oder alte Konfliktkopien aufräumen. Echte Sync-Konflikte löst die App automatisch nach dem neuesten Speicherstand auf." +autowrap_mode = 2 + +[node name="ManagerTabs" type="TabContainer" parent="RoutineManagerDialog/ManagerBox"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_vertical = 3 + +[node name="RoutinesTab" type="VBoxContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs"] +layout_mode = 2 +theme_override_constants/separation = 4 + +[node name="RoutineManagerScroll" type="ScrollContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/RoutinesTab"] +layout_mode = 2 +size_flags_vertical = 3 +horizontal_scroll_mode = 0 + +[node name="RoutineManagerList" type="VBoxContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/RoutinesTab/RoutineManagerScroll"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_constants/separation = 4 + +[node name="ConflictsTab" type="VBoxContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs"] +layout_mode = 2 +theme_override_constants/separation = 4 + +[node name="ConflictManagerHint" type="Label" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/ConflictsTab"] +layout_mode = 2 +theme_override_colors/font_color = Color(0.580392, 0.639216, 0.721569, 1) +theme_override_font_sizes/font_size = 14 +text = "Alte sichtbare Kopien wie „Kür (Server …).json“ werden gesucht und nach Bestätigung ins Konfliktarchiv verschoben. Kopien ohne Hauptdatei bleiben als mögliche letzte Fassung erhalten." +autowrap_mode = 2 + +[node name="ManagerConflictActions" type="HBoxContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/ConflictsTab"] +layout_mode = 2 +theme_override_constants/separation = 4 + +[node name="ManagerScanConflictsButton" type="Button" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/ConflictsTab/ManagerConflictActions"] +unique_name_in_owner = true +custom_minimum_size = Vector2(0, 48) +layout_mode = 2 +size_flags_horizontal = 3 +text = "Konfliktkopien suchen…" + +[node name="ManagerOpenArchiveButton" type="Button" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/ConflictsTab/ManagerConflictActions"] +unique_name_in_owner = true +custom_minimum_size = Vector2(0, 48) +layout_mode = 2 +size_flags_horizontal = 3 +text = "Konfliktarchiv öffnen" diff --git a/rinkplanner/scenes/whiteboard/whiteboard.tscn b/rinkplanner/scenes/whiteboard/whiteboard.tscn index 3f332fe..18b0150 100644 --- a/rinkplanner/scenes/whiteboard/whiteboard.tscn +++ b/rinkplanner/scenes/whiteboard/whiteboard.tscn @@ -1,8 +1,12 @@ -[gd_scene load_steps=22 format=3] +[gd_scene load_steps=26 format=3] [ext_resource type="Script" path="res://src/whiteboard/ctrl/whiteboard_controller.gd" id="1_controller"] [ext_resource type="Script" path="res://src/whiteboard/view/rink_canvas.gd" id="2_canvas"] [ext_resource type="Script" path="res://src/whiteboard/view/timeline_label_lane.gd" id="3_label_lane"] +[ext_resource type="Script" path="res://src/whiteboard/view/export_panel.gd" id="3_export_panel"] +[ext_resource type="Script" path="res://src/whiteboard/view/playback_panel.gd" id="3_playback_panel"] +[ext_resource type="PackedScene" path="res://scenes/export/export_panel.tscn" id="14_export_panel_scene"] +[ext_resource type="PackedScene" path="res://scenes/routine/routine_manager_panel.tscn" id="15_manager_panel_scene"] [ext_resource type="Texture2D" path="res://assets/icons/tools/select.svg" id="4_tool_select"] [ext_resource type="Texture2D" path="res://assets/icons/tools/line.svg" id="5_tool_line"] [ext_resource type="Texture2D" path="res://assets/icons/tools/arc_left.svg" id="6_tool_arc_left"] @@ -116,12 +120,18 @@ tooltip_text = "Datei" [node name="TitleSeparator" type="VSeparator" parent="Layout/TopBar/Tools"] layout_mode = 2 -[node name="ToolButtons" type="HBoxContainer" parent="Layout/TopBar/Tools"] +[node name="ToolFlow" type="HFlowContainer" parent="Layout/TopBar/Tools"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_constants/h_separation = 6 +theme_override_constants/v_separation = 6 + +[node name="ToolButtons" type="HBoxContainer" parent="Layout/TopBar/Tools/ToolFlow"] unique_name_in_owner = true layout_mode = 2 theme_override_constants/separation = 4 -[node name="SelectToolButton" type="Button" parent="Layout/TopBar/Tools/ToolButtons"] +[node name="SelectToolButton" type="Button" parent="Layout/TopBar/Tools/ToolFlow/ToolButtons"] unique_name_in_owner = true custom_minimum_size = Vector2(44, 48) icon_alignment = 1 @@ -140,7 +150,7 @@ theme_override_styles/pressed = SubResource("StyleBoxFlat_tool_active") theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_tool_active") icon = ExtResource("4_tool_select") -[node name="LineToolButton" type="Button" parent="Layout/TopBar/Tools/ToolButtons"] +[node name="LineToolButton" type="Button" parent="Layout/TopBar/Tools/ToolFlow/ToolButtons"] unique_name_in_owner = true custom_minimum_size = Vector2(44, 48) icon_alignment = 1 @@ -158,7 +168,7 @@ theme_override_styles/pressed = SubResource("StyleBoxFlat_tool_active") theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_tool_active") icon = ExtResource("5_tool_line") -[node name="ArcLeftToolButton" type="Button" parent="Layout/TopBar/Tools/ToolButtons"] +[node name="ArcLeftToolButton" type="Button" parent="Layout/TopBar/Tools/ToolFlow/ToolButtons"] unique_name_in_owner = true custom_minimum_size = Vector2(44, 48) icon_alignment = 1 @@ -176,7 +186,7 @@ theme_override_styles/pressed = SubResource("StyleBoxFlat_tool_active") theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_tool_active") icon = ExtResource("6_tool_arc_left") -[node name="ArcRightToolButton" type="Button" parent="Layout/TopBar/Tools/ToolButtons"] +[node name="ArcRightToolButton" type="Button" parent="Layout/TopBar/Tools/ToolFlow/ToolButtons"] unique_name_in_owner = true custom_minimum_size = Vector2(44, 48) icon_alignment = 1 @@ -194,7 +204,7 @@ theme_override_styles/pressed = SubResource("StyleBoxFlat_tool_active") theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_tool_active") icon = ExtResource("7_tool_arc_right") -[node name="FreeLineToolButton" type="Button" parent="Layout/TopBar/Tools/ToolButtons"] +[node name="FreeLineToolButton" type="Button" parent="Layout/TopBar/Tools/ToolFlow/ToolButtons"] unique_name_in_owner = true custom_minimum_size = Vector2(44, 48) icon_alignment = 1 @@ -212,7 +222,7 @@ theme_override_styles/pressed = SubResource("StyleBoxFlat_tool_active") theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_tool_active") icon = ExtResource("11_tool_freeline") -[node name="JumpToolButton" type="Button" parent="Layout/TopBar/Tools/ToolButtons"] +[node name="JumpToolButton" type="Button" parent="Layout/TopBar/Tools/ToolFlow/ToolButtons"] unique_name_in_owner = true custom_minimum_size = Vector2(44, 48) icon_alignment = 1 @@ -230,7 +240,7 @@ theme_override_styles/pressed = SubResource("StyleBoxFlat_tool_active") theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_tool_active") icon = ExtResource("8_tool_jump") -[node name="SpinToolButton" type="Button" parent="Layout/TopBar/Tools/ToolButtons"] +[node name="SpinToolButton" type="Button" parent="Layout/TopBar/Tools/ToolFlow/ToolButtons"] unique_name_in_owner = true custom_minimum_size = Vector2(44, 48) icon_alignment = 1 @@ -248,7 +258,7 @@ theme_override_styles/pressed = SubResource("StyleBoxFlat_tool_active") theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_tool_active") icon = ExtResource("9_tool_spin") -[node name="GroupSequenceButton" type="Button" parent="Layout/TopBar/Tools/ToolButtons"] +[node name="GroupSequenceButton" type="Button" parent="Layout/TopBar/Tools/ToolFlow/ToolButtons"] unique_name_in_owner = true custom_minimum_size = Vector2(44, 48) icon_alignment = 1 @@ -263,10 +273,10 @@ theme_override_colors/icon_disabled_color = Color(0.337255, 0.380392, 0.443137, theme_override_constants/icon_max_width = 28 icon = ExtResource("10_tool_group_sequence") -[node name="ToolSeparator" type="VSeparator" parent="Layout/TopBar/Tools"] +[node name="ToolSeparator" type="VSeparator" parent="Layout/TopBar/Tools/ToolFlow"] layout_mode = 2 -[node name="ForwardButton" type="Button" parent="Layout/TopBar/Tools"] +[node name="ForwardButton" type="Button" parent="Layout/TopBar/Tools/ToolFlow"] unique_name_in_owner = true custom_minimum_size = Vector2(88, 48) layout_mode = 2 @@ -277,7 +287,7 @@ button_group = SubResource("ButtonGroup_direction") text = "Vorwärts" tooltip_text = "Vorwärts" -[node name="BackwardButton" type="Button" parent="Layout/TopBar/Tools"] +[node name="BackwardButton" type="Button" parent="Layout/TopBar/Tools/ToolFlow"] unique_name_in_owner = true custom_minimum_size = Vector2(92, 48) layout_mode = 2 @@ -287,10 +297,10 @@ button_group = SubResource("ButtonGroup_direction") text = "Rückwärts" tooltip_text = "Rückwärts" -[node name="EdgeSeparator" type="VSeparator" parent="Layout/TopBar/Tools"] +[node name="EdgeSeparator" type="VSeparator" parent="Layout/TopBar/Tools/ToolFlow"] layout_mode = 2 -[node name="InsideButton" type="Button" parent="Layout/TopBar/Tools"] +[node name="InsideButton" type="Button" parent="Layout/TopBar/Tools/ToolFlow"] unique_name_in_owner = true custom_minimum_size = Vector2(64, 48) layout_mode = 2 @@ -299,7 +309,7 @@ toggle_mode = true button_group = SubResource("ButtonGroup_edge") text = "Innen" -[node name="OutsideButton" type="Button" parent="Layout/TopBar/Tools"] +[node name="OutsideButton" type="Button" parent="Layout/TopBar/Tools/ToolFlow"] unique_name_in_owner = true custom_minimum_size = Vector2(64, 48) layout_mode = 2 @@ -309,10 +319,6 @@ button_pressed = true button_group = SubResource("ButtonGroup_edge") text = "Außen" -[node name="Spacer" type="Control" parent="Layout/TopBar/Tools"] -layout_mode = 2 -size_flags_horizontal = 3 - [node name="UndoButton" type="Button" parent="Layout/TopBar/Tools"] unique_name_in_owner = true custom_minimum_size = Vector2(96, 48) @@ -765,6 +771,7 @@ theme_override_constants/separation = 6 unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 +clip_text = true theme_override_colors/font_color = Color(0.580392, 0.639216, 0.721569, 1) theme_override_font_sizes/font_size = 15 text = "Abschnitt 1 · 0 Segmente" @@ -780,25 +787,25 @@ tooltip_text = "Hilfe und Annahmen" [node name="SeasonOption" type="OptionButton" parent="Layout/StatusBar/StatusBarContent"] unique_name_in_owner = true -custom_minimum_size = Vector2(190, 48) +custom_minimum_size = Vector2(158, 48) layout_mode = 2 theme_override_font_sizes/font_size = 15 [node name="ProgramOption" type="OptionButton" parent="Layout/StatusBar/StatusBarContent"] unique_name_in_owner = true -custom_minimum_size = Vector2(120, 48) +custom_minimum_size = Vector2(104, 48) layout_mode = 2 theme_override_font_sizes/font_size = 15 [node name="AdultCategoryOption" type="OptionButton" parent="Layout/StatusBar/StatusBarContent"] unique_name_in_owner = true -custom_minimum_size = Vector2(170, 48) +custom_minimum_size = Vector2(146, 48) layout_mode = 2 theme_override_font_sizes/font_size = 15 [node name="ValidationButton" type="Button" parent="Layout/StatusBar/StatusBarContent"] unique_name_in_owner = true -custom_minimum_size = Vector2(120, 48) +custom_minimum_size = Vector2(104, 48) layout_mode = 2 theme_override_font_sizes/font_size = 15 text = "Prüfen" @@ -1293,75 +1300,8 @@ layout_mode = 2 size_flags_horizontal = 3 theme_override_constants/separation = 4 -[node name="RoutineManagerDialog" type="AcceptDialog" parent="."] +[node name="RoutineManagerPanel" parent="." instance=ExtResource("15_manager_panel_scene")] unique_name_in_owner = true -title = "Küren verwalten" -size = Vector2i(800, 600) -exclusive = false -ok_button_text = "Schließen" - -[node name="ManagerBox" type="VBoxContainer" parent="RoutineManagerDialog"] -offset_left = 12.0 -offset_top = 12.0 -offset_right = 788.0 -offset_bottom = 530.0 -theme_override_constants/separation = 4 - -[node name="ManagerHint" type="Label" parent="RoutineManagerDialog/ManagerBox"] -layout_mode = 2 -theme_override_colors/font_color = Color(0.580392, 0.639216, 0.721569, 1) -theme_override_font_sizes/font_size = 14 -text = "Lokale Küren löschen oder alte Konfliktkopien aufräumen. Echte Sync-Konflikte löst die App automatisch nach dem neuesten Speicherstand auf." -autowrap_mode = 2 - -[node name="ManagerTabs" type="TabContainer" parent="RoutineManagerDialog/ManagerBox"] -unique_name_in_owner = true -layout_mode = 2 -size_flags_vertical = 3 - -[node name="RoutinesTab" type="VBoxContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs"] -layout_mode = 2 -theme_override_constants/separation = 4 - -[node name="RoutineManagerScroll" type="ScrollContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/RoutinesTab"] -layout_mode = 2 -size_flags_vertical = 3 -horizontal_scroll_mode = 0 - -[node name="RoutineManagerList" type="VBoxContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/RoutinesTab/RoutineManagerScroll"] -unique_name_in_owner = true -layout_mode = 2 -size_flags_horizontal = 3 -theme_override_constants/separation = 4 - -[node name="ConflictsTab" type="VBoxContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs"] -layout_mode = 2 -theme_override_constants/separation = 4 - -[node name="ConflictManagerHint" type="Label" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/ConflictsTab"] -layout_mode = 2 -theme_override_colors/font_color = Color(0.580392, 0.639216, 0.721569, 1) -theme_override_font_sizes/font_size = 14 -text = "Alte sichtbare Kopien wie „Kür (Server …).json“ werden gesucht und nach Bestätigung ins Konfliktarchiv verschoben. Kopien ohne Hauptdatei bleiben als mögliche letzte Fassung erhalten." -autowrap_mode = 2 - -[node name="ManagerConflictActions" type="HBoxContainer" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/ConflictsTab"] -layout_mode = 2 -theme_override_constants/separation = 4 - -[node name="ManagerScanConflictsButton" type="Button" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/ConflictsTab/ManagerConflictActions"] -unique_name_in_owner = true -custom_minimum_size = Vector2(0, 48) -layout_mode = 2 -size_flags_horizontal = 3 -text = "Konfliktkopien suchen…" - -[node name="ManagerOpenArchiveButton" type="Button" parent="RoutineManagerDialog/ManagerBox/ManagerTabs/ConflictsTab/ManagerConflictActions"] -unique_name_in_owner = true -custom_minimum_size = Vector2(0, 48) -layout_mode = 2 -size_flags_horizontal = 3 -text = "Konfliktarchiv öffnen" [node name="DeleteRoutineDialog" type="ConfirmationDialog" parent="."] unique_name_in_owner = true @@ -1648,131 +1588,12 @@ theme_override_colors/font_color = Color(0.580392, 0.639216, 0.721569, 1) theme_override_font_sizes/font_size = 12 text = "Geschwindigkeit = Strecke / Zeit" -[node name="ExportDialog" type="ConfirmationDialog" parent="."] +[node name="PlaybackPanel" type="Node" parent="."] unique_name_in_owner = true -title = "Kür exportieren" -size = Vector2i(480, 520) -wrap_controls = false -ok_button_text = "Exportieren" -cancel_button_text = "Abbrechen" +script = ExtResource("3_playback_panel") -[node name="ExportScroll" type="ScrollContainer" parent="ExportDialog"] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = 8.0 -offset_top = 8.0 -offset_right = -8.0 -offset_bottom = -64.0 -grow_horizontal = 2 -grow_vertical = 2 -horizontal_scroll_mode = 0 -follow_focus = true - -[node name="ExportBox" type="VBoxContainer" parent="ExportDialog/ExportScroll"] -layout_mode = 2 -size_flags_horizontal = 3 -theme_override_constants/separation = 4 - -[node name="ExportNameLabel" type="Label" parent="ExportDialog/ExportScroll/ExportBox"] -layout_mode = 2 -text = "Dateiname" - -[node name="ExportNameEdit" type="LineEdit" parent="ExportDialog/ExportScroll/ExportBox"] +[node name="ExportPanel" parent="." instance=ExtResource("14_export_panel_scene")] unique_name_in_owner = true -custom_minimum_size = Vector2(0, 48) -layout_mode = 2 - -[node name="ExportFormatLabel" type="Label" parent="ExportDialog/ExportScroll/ExportBox"] -layout_mode = 2 -text = "Format" - -[node name="ExportFormatOption" type="OptionButton" parent="ExportDialog/ExportScroll/ExportBox"] -unique_name_in_owner = true -custom_minimum_size = Vector2(0, 48) -layout_mode = 2 - -[node name="ExportScopeLabel" type="Label" parent="ExportDialog/ExportScroll/ExportBox"] -layout_mode = 2 -text = "Umfang" - -[node name="ExportScopeOption" type="OptionButton" parent="ExportDialog/ExportScroll/ExportBox"] -unique_name_in_owner = true -custom_minimum_size = Vector2(0, 48) -layout_mode = 2 - -[node name="ExportHint" type="Label" parent="ExportDialog/ExportScroll/ExportBox"] -custom_minimum_size = Vector2(0, 34) -layout_mode = 2 -theme_override_colors/font_color = Color(0.580392, 0.639216, 0.721569, 1) -theme_override_font_sizes/font_size = 12 -text = "Ziel: export-Ordner im App-Datenverzeichnis · der absolute Pfad erscheint nach dem Export" -autowrap_mode = 3 - -[node name="ExportOpenAfterCheck" type="CheckBox" parent="ExportDialog/ExportScroll/ExportBox"] -unique_name_in_owner = true -custom_minimum_size = Vector2(0, 44) -layout_mode = 2 -button_pressed = true -text = "Nach dem Export öffnen" -tooltip_text = "Ergebnis nach dem Export mit dem Standardprogramm öffnen" - -[node name="ExportDoneDialog" type="AcceptDialog" parent="."] -unique_name_in_owner = true -title = "Export abgeschlossen" -size = Vector2i(660, 320) -wrap_controls = false -ok_button_text = "Schließen" - -[node name="ExportDoneBox" type="VBoxContainer" parent="ExportDoneDialog"] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = 12.0 -offset_top = 12.0 -offset_right = -12.0 -offset_bottom = -64.0 -grow_horizontal = 2 -grow_vertical = 2 -theme_override_constants/separation = 4 - -[node name="ExportDoneLabel" type="RichTextLabel" parent="ExportDoneDialog/ExportDoneBox"] -unique_name_in_owner = true -custom_minimum_size = Vector2(0, 96) -layout_mode = 2 -size_flags_vertical = 3 -bbcode_enabled = false -scroll_active = false -selection_enabled = true -autowrap_mode = 3 - -[node name="ExportDoneButtons" type="HFlowContainer" parent="ExportDoneDialog/ExportDoneBox"] -layout_mode = 2 -theme_override_constants/h_separation = 6 -theme_override_constants/v_separation = 8 - -[node name="ExportOpenButton" type="Button" parent="ExportDoneDialog/ExportDoneBox/ExportDoneButtons"] -unique_name_in_owner = true -custom_minimum_size = Vector2(140, 48) -layout_mode = 2 -text = "Öffnen" -tooltip_text = "Datei mit dem Standardprogramm öffnen" - -[node name="ExportFolderButton" type="Button" parent="ExportDoneDialog/ExportDoneBox/ExportDoneButtons"] -unique_name_in_owner = true -custom_minimum_size = Vector2(180, 48) -layout_mode = 2 -text = "Ordner anzeigen" -tooltip_text = "Exportordner im Dateimanager öffnen" - -[node name="ExportCopyPathButton" type="Button" parent="ExportDoneDialog/ExportDoneBox/ExportDoneButtons"] -unique_name_in_owner = true -custom_minimum_size = Vector2(170, 48) -layout_mode = 2 -text = "Pfad kopieren" -tooltip_text = "Absoluten Dateipfad in die Zwischenablage kopieren" [node name="ElementFeatureMenu" type="PopupMenu" parent="."] unique_name_in_owner = true @@ -1912,6 +1733,14 @@ theme_override_font_sizes/font_size = 15 disabled = true text = "Auf Saison umstellen" +[node name="UpgradePdfButton" type="Button" parent="UpgradeDialog/UpgradeBox/UpgradeActions"] +unique_name_in_owner = true +custom_minimum_size = Vector2(120, 48) +layout_mode = 2 +theme_override_font_sizes/font_size = 15 +disabled = true +text = "Als PDF" + [node name="UpgradeHint" type="Label" parent="UpgradeDialog/UpgradeBox/UpgradeActions"] unique_name_in_owner = true layout_mode = 2 diff --git a/rinkplanner/src/core/rules/rules_context.gd b/rinkplanner/src/core/rules/rules_context.gd new file mode 100644 index 0000000..d17ed5b --- /dev/null +++ b/rinkplanner/src/core/rules/rules_context.gd @@ -0,0 +1,71 @@ +class_name RulesContext +extends RefCounted + +## Owns the season rulebooks of the whiteboard. +## +## The context discovers the season packages, keeps the one that is currently +## applied and exposes its three documents (`catalog`, `levels`, `adult`). The +## controller holds one instance and asks it to switch seasons; nothing else +## needs to know about [RulesLibrary] or [RulesPackage]. + +var library: RulesLibrary +var package: RulesPackage +## Season new routines start with (newest complete season by `valid_from`). +var default_season: String = "" + +var catalog: ElementCatalog +var levels: ElementLevelRules +var adult: AdultCategoryRules + + +## Scans the season folders and applies the default season. Returns the +## package, or null when no usable season was found. +func load_default() -> RulesPackage: + library = RulesLibrary.scan() + default_season = library.get_default_season() if library != null else "" + return apply(default_season) + + +## Applies one season. An empty or unknown season clears the documents on +## purpose: the app then says that it cannot check instead of silently using +## the wrong rulebook. Returns the applied package or null. +func apply(season: String) -> RulesPackage: + package = null + catalog = null + levels = null + adult = null + if library == null: + return null + var cleaned := season.strip_edges() + if cleaned.is_empty(): + return null + package = library.get_package(cleaned) + if package == null: + return null + catalog = package.catalog + levels = package.levels + adult = package.adult + return package + + +func has_season() -> bool: + return package != null + + +func is_complete() -> bool: + return package != null and package.is_complete() + + +func season_label() -> String: + if package != null and not package.season.is_empty(): + return package.season + return "" + + +func get_errors() -> PackedStringArray: + var errors := PackedStringArray() + if library != null: + errors.append_array(library.get_errors()) + if package != null: + errors.append_array(package.get_errors()) + return errors diff --git a/rinkplanner/src/core/rules/rules_context.gd.uid b/rinkplanner/src/core/rules/rules_context.gd.uid new file mode 100644 index 0000000..26d740f --- /dev/null +++ b/rinkplanner/src/core/rules/rules_context.gd.uid @@ -0,0 +1 @@ +uid://vppy828isg22 diff --git a/rinkplanner/src/whiteboard/ctrl/whiteboard_controller.gd b/rinkplanner/src/whiteboard/ctrl/whiteboard_controller.gd index 2414d99..0253195 100644 --- a/rinkplanner/src/whiteboard/ctrl/whiteboard_controller.gd +++ b/rinkplanner/src/whiteboard/ctrl/whiteboard_controller.gd @@ -57,7 +57,7 @@ const DEFAULT_PROFILE_INDEX := 2 ## spin marker. Modern spins rotate around 2-3 rev/s (elite upright/scratch ## spins up to 5); 1.5 rev/s looked too sluggish. See ## docs/speed-assumptions.md, section 8. -const SPIN_REVOLUTIONS_PER_SECOND := 2.5 +const SPIN_REVOLUTIONS_PER_SECOND := PlaybackPose.SPIN_REVOLUTIONS_PER_SECOND const ELEMENT_DEFAULT_DURATIONS := { PathSegment.ElementType.JUMP: 0.7, PathSegment.ElementType.SPIN: 4.0, @@ -95,7 +95,7 @@ const TOOL_ELEMENT_TYPES := [ PathSegment.ElementType.SPIN, ] const ROUTINES_DIR := "user://routines" -const EXPORTS_DIR := "user://exports" +const EXPORTS_DIR := ExportService.EXPORTS_DIR const EXPORT_SHEET_SCENE := preload("res://scenes/export/export_sheet.tscn") const PRESENTATION_3D_SCENE_PATH := "res://scenes/presentation3d/presentation_3d.tscn" const PLAYBACK_PLAY_ICON := preload("res://assets/icons/playback/play.svg") @@ -185,11 +185,7 @@ const UPDATE_FILE_NAMES := { @onready var open_list: VBoxContainer = %OpenList @onready var confirm_dialog: ConfirmationDialog = %ConfirmDialog @onready var message_dialog: AcceptDialog = %MessageDialog -@onready var play_button: Button = %PlayButton -@onready var reset_playback_button: Button = %ResetPlaybackButton -@onready var playback_time_label: Label = %PlaybackTimeLabel -@onready var playback_timeline: HSlider = %PlaybackTimeline -@onready var speed_option: OptionButton = %SpeedOption +@onready var playback_panel: PlaybackPanel = %PlaybackPanel @onready var music_button: Button = %MusicButton @onready var music_label: Label = %MusicLabel @onready var music_clear_button: Button = %MusicClearButton @@ -234,6 +230,7 @@ const UPDATE_FILE_NAMES := { @onready var upgrade_season_option: OptionButton = %UpgradeSeasonOption @onready var upgrade_run_button: Button = %UpgradeRunButton @onready var upgrade_apply_button: Button = %UpgradeApplyButton +@onready var upgrade_pdf_button: Button = %UpgradePdfButton @onready var validation_text: RichTextLabel = %ValidationText @onready var score_assumptions_panel: VBoxContainer = %ScoreAssumptionsPanel @onready var pcs_average_spin: SpinBox = %PcsAverageSpin @@ -290,11 +287,7 @@ const UPDATE_FILE_NAMES := { @onready var cleanup_conflicts_dialog: ConfirmationDialog = %CleanupConflictsDialog @onready var cleanup_conflicts_intro: Label = %CleanupConflictsIntro @onready var cleanup_conflicts_list: VBoxContainer = %CleanupConflictsList -@onready var routine_manager_dialog: AcceptDialog = %RoutineManagerDialog -@onready var manager_tabs: TabContainer = %ManagerTabs -@onready var routine_manager_list: VBoxContainer = %RoutineManagerList -@onready var manager_scan_conflicts_button: Button = %ManagerScanConflictsButton -@onready var manager_open_archive_button: Button = %ManagerOpenArchiveButton +@onready var routine_manager_panel: RoutineManagerPanel = %RoutineManagerPanel @onready var delete_routine_dialog: ConfirmationDialog = %DeleteRoutineDialog @onready var delete_routine_text: Label = %DeleteRoutineText @onready var delete_routine_cloud_check: CheckBox = %DeleteRoutineCloudCheck @@ -310,16 +303,7 @@ const UPDATE_FILE_NAMES := { @onready var cloud_auth_user_code: Label = %CloudAuthUserCode @onready var cloud_auth_code_edit: LineEdit = %CloudAuthCodeEdit @onready var cloud_auth_code_hint: Label = %CloudAuthCodeHint -@onready var export_dialog: ConfirmationDialog = %ExportDialog -@onready var export_name_edit: LineEdit = %ExportNameEdit -@onready var export_format_option: OptionButton = %ExportFormatOption -@onready var export_scope_option: OptionButton = %ExportScopeOption -@onready var export_open_after_check: CheckBox = %ExportOpenAfterCheck -@onready var export_done_dialog: AcceptDialog = %ExportDoneDialog -@onready var export_done_label: RichTextLabel = %ExportDoneLabel -@onready var export_open_button: Button = %ExportOpenButton -@onready var export_folder_button: Button = %ExportFolderButton -@onready var export_copy_path_button: Button = %ExportCopyPathButton +@onready var export_panel: ExportPanel = %ExportPanel var _routine: Routine var _active_section: RoutineSection @@ -336,12 +320,7 @@ var _direction: PathSegment.Direction = PathSegment.Direction.FORWARD var _edge: PathSegment.Edge = PathSegment.Edge.OUTSIDE var _element_type: PathSegment.ElementType = PathSegment.ElementType.JUMP var _element_level: int = 0 -var _element_catalog: ElementCatalog -var _level_rules: ElementLevelRules -var _adult_rules: AdultCategoryRules -var _rules_library: RulesLibrary -var _rules_package: RulesPackage -var _default_season: String = "" +var _ruleset: RulesContext = RulesContext.new() var _dialog_features: PackedStringArray = PackedStringArray() var _dialog_feature_feet: Dictionary[String, String] = {} var _dialog_jump_kind: PathSegment.JumpKind = PathSegment.JumpKind.SOLO @@ -460,7 +439,6 @@ func _ready() -> void: _setup_program_controls() _setup_upgrade_controls() _setup_adult_category_controls() - _setup_export_controls() labels_toggle.set_pressed_no_signal(rink_canvas.labels_visible) _update_child_translations(self) @@ -500,10 +478,10 @@ func _ready() -> void: save_as_dialog.confirmed.connect(_on_save_as_confirmed) confirm_dialog.confirmed.connect(_on_confirm_discard_confirmed) confirm_dialog.canceled.connect(_on_confirm_discard_canceled) - play_button.pressed.connect(_toggle_playback) - reset_playback_button.pressed.connect(reset_playback) - playback_timeline.value_changed.connect(_on_timeline_changed) - speed_option.item_selected.connect(_on_speed_selected) + playback_panel.toggle_requested.connect(_toggle_playback) + playback_panel.reset_requested.connect(reset_playback) + playback_panel.seek_requested.connect(seek_playback) + playback_panel.speed_requested.connect(_on_speed_requested) music_button.pressed.connect(_open_music_dialog) music_clear_button.pressed.connect(_clear_music) music_file_dialog.file_selected.connect(_on_music_file_selected) @@ -525,16 +503,20 @@ func _ready() -> void: calibrate_button.pressed.connect(_open_calibration_dialog) reset_timing_button.pressed.connect(_reset_selected_timing) calibration_dialog.confirmed.connect(_on_calibration_confirmed) - export_dialog.confirmed.connect(_on_export_confirmed) - export_open_button.pressed.connect(_on_export_open_pressed) - export_folder_button.pressed.connect(_on_export_folder_pressed) - export_copy_path_button.pressed.connect(_on_export_copy_path_pressed) + export_panel.export_requested.connect(_on_export_requested) + export_panel.open_requested.connect(_on_export_open_pressed) + export_panel.folder_requested.connect(_on_export_folder_pressed) + export_panel.copy_requested.connect(_on_export_copy_path_pressed) + export_panel.message_requested.connect(_show_message) sync_settings_dialog.confirmed.connect(_on_sync_settings_confirmed) sync_provider_option.item_selected.connect(_on_sync_provider_selected) sync_connect_button.pressed.connect(_on_sync_connect_pressed) cleanup_conflicts_dialog.confirmed.connect(_on_cleanup_conflicts_confirmed) - manager_scan_conflicts_button.pressed.connect(_start_conflict_scan) - manager_open_archive_button.pressed.connect(_open_conflicts_folder) + routine_manager_panel.open_requested.connect(_on_manager_open_pressed) + routine_manager_panel.rename_requested.connect(_open_rename_routine_dialog) + routine_manager_panel.delete_requested.connect(_open_delete_routine_dialog) + routine_manager_panel.scan_conflicts_requested.connect(_start_conflict_scan) + routine_manager_panel.open_archive_requested.connect(_open_conflicts_folder) delete_routine_dialog.confirmed.connect(_on_delete_routine_confirmed) delete_routine_dialog.canceled.connect(_on_delete_routine_canceled) rename_routine_dialog.confirmed.connect(_on_rename_routine_confirmed) @@ -603,7 +585,7 @@ func new_routine() -> void: var routine := Routine.new() routine.routine_id = "draft-routine" routine.title = "Neue Kür" - routine.season = _default_season + routine.season = _ruleset.default_season routine.rink = RinkDimensions.new() var section := RoutineSection.new() @@ -804,31 +786,32 @@ func get_element_level() -> int: func get_element_catalog() -> ElementCatalog: - return _element_catalog + return _ruleset.catalog func get_level_rules() -> ElementLevelRules: - return _level_rules + return _ruleset.levels func get_rules_package() -> RulesPackage: - return _rules_package + return _ruleset.package func get_rules_library() -> RulesLibrary: - return _rules_library + return _ruleset.library ## Loads the season package new routines start with. Seasons are discovered on ## disk; there is no hardcoded file name here. func _load_default_rules() -> void: - _rules_library = RulesLibrary.scan() - if not _rules_library.get_errors().is_empty(): - push_warning("Rules: %s" % ", ".join(_rules_library.get_errors())) - _default_season = _rules_library.get_default_season() - if _default_season.is_empty(): + var package := _ruleset.load_default() + if _ruleset.library != null and not _ruleset.library.get_errors().is_empty(): + push_warning("Rules: %s" % ", ".join(_ruleset.library.get_errors())) + if package == null: push_warning("Rules: keine nutzbare Saison gefunden") - _apply_rules_for_season(_default_season) + return + for error: String in package.get_errors(): + push_warning("Rules (%s): %s" % [package.season, error]) ## Resolves the rule package of one season and points the inspector, the @@ -836,28 +819,16 @@ func _load_default_rules() -> void: ## rules unset on purpose: the app then says that it cannot check instead of ## silently validating against the wrong rulebook. func _apply_rules_for_season(season: String) -> void: - _rules_package = null - _element_catalog = null - _level_rules = null - _adult_rules = null - if _rules_library == null: + var package := _ruleset.apply(season) + if package == null: return - var cleaned := season.strip_edges() - if cleaned.is_empty(): - return - _rules_package = _rules_library.get_package(cleaned) - if _rules_package == null: - return - for error: String in _rules_package.get_errors(): - push_warning("Rules (%s): %s" % [_rules_package.season, error]) - _element_catalog = _rules_package.catalog - _level_rules = _rules_package.levels - _adult_rules = _rules_package.adult + for error: String in package.get_errors(): + push_warning("Rules (%s): %s" % [package.season, error]) func _catalog_season_label() -> String: - if _rules_package != null and not _rules_package.season.is_empty(): - return _rules_package.season + if _ruleset.package != null and not _ruleset.package.season.is_empty(): + return _ruleset.package.season if _routine != null and not _routine.season.is_empty(): return _routine.season return I18n.t("nicht festgelegt") @@ -867,9 +838,9 @@ func _catalog_season_label() -> String: ## Paths and section bookkeeping are validated by the model itself. func validate_routine() -> Array[ValidationIssue]: var validator: RoutineValidator = ROUTINE_VALIDATOR_SCRIPT.new( - _element_catalog, - _level_rules, - _adult_rules + _ruleset.catalog, + _ruleset.levels, + _ruleset.adult ) return validator.validate(_routine) @@ -886,171 +857,33 @@ func open_validation_dialog() -> void: func _render_validation_dialog() -> void: var validator: RoutineValidator = ROUTINE_VALIDATOR_SCRIPT.new( - _element_catalog, - _level_rules, - _adult_rules + _ruleset.catalog, + _ruleset.levels, + _ruleset.adult ) var report := validator.validate_report(_routine) - var errors := RoutineValidator.count_severity( - report.issues, - ValidationIssue.Severity.ERROR - ) - var warnings := RoutineValidator.count_severity( - report.issues, - ValidationIssue.Severity.WARNING - ) - var season := _catalog_season_label() - - var lines := PackedStringArray() - lines.append( - "[b]Geprüft: %s in %s (Saison %s)[/b]" - % [ - _element_count_label(report.element_count), - _section_count_label(report.section_count), - season, - ] - ) - var season_note := _season_note() - if not season_note.is_empty(): - lines.append("[color=#e0b050]%s[/color]" % season_note) - if _can_compare_seasons(): - lines.append( - "[url=upgrade][color=#60a5fa]%s[/color][/url]" - % I18n.t("ⓘ Gegen andere Saison prüfen …") - ) var category: AdultCategoryRules.Category = null if ( _routine != null and not _routine.adult_category.is_empty() - and _adult_rules != null + and _ruleset.adult != null ): - category = _adult_rules.get_category( + category = _ruleset.adult.get_category( _routine.adult_category, _routine.program_type ) - var category_name := "Ohne Kategorie" - if category != null: - category_name = "%s · %s · %s ±%d s" % [ - category.name, - _program_label(category.program_type), - _format_duration(category.duration_seconds), - category.duration_tolerance_seconds, - ] - lines.append("[b]Kategorie: %s[/b]" % category_name) - lines.append("") - lines.append( - "[b]Basiswert: %s[/b]" % _format_base_value(report.base_value_total) + var lines := ValidationReportView.build( + _routine, + report, + category, + { + "season": _catalog_season_label(), + "season_note": _season_note(), + "can_compare": _can_compare_seasons(), + "show_info": _show_score_info, + "show_assumptions": _show_score_assumptions, + } ) - var scored_text := ( - "%d von %d Elementen gewertet" - % [report.scored_elements, report.element_count] - ) - if report.unscored_elements > 0: - scored_text += " · %d ohne Base Value" % report.unscored_elements - lines.append(scored_text) - var info_label := ( - "ⓘ Details ausblenden" if _show_score_info else "ⓘ Was ist enthalten?" - ) - lines.append( - "[color=#94a3b8]Nur Base Values · [/color][url=score_info][color=#60a5fa]%s[/color][/url]" - % info_label - ) - if _show_score_info: - lines.append("") - lines.append_array(_score_info_lines()) - if category != null and category.scored: - var pcs_total := ( - _routine.assumed_pcs_average * 3.0 * category.pcs_factor - ) - var deduction := float(_routine.assumed_falls) * category.fall_deduction - var estimated := report.base_value_total + pcs_total - deduction - lines.append("") - lines.append("[b]Punktschätzung[/b]") - lines.append( - "PCS-Annahme: %s × 3 × %s = %s" - % [ - _format_base_value(_routine.assumed_pcs_average), - _format_base_value(category.pcs_factor), - _format_base_value(pcs_total), - ] - ) - lines.append( - "Sturzabzug: %d × %s = -%s" - % [ - _routine.assumed_falls, - _format_base_value(category.fall_deduction), - _format_base_value(deduction), - ] - ) - lines.append( - I18n.t("[b]Geschätzte Summe: %s[/b]") % _format_base_value(estimated) - ) - var assumptions_label := ( - "ⓘ Annahmen ausblenden" - if _show_score_assumptions - else "ⓘ Annahmen ändern" - ) - lines.append( - "[url=score_assumptions][color=#60a5fa]%s[/color][/url]" - % assumptions_label - ) - elif category != null: - lines.append("") - lines.append("[b]Punktschätzung[/b]") - lines.append( - "[color=#94a3b8]%s[/color]" - % I18n.t( - "Artistic wird nur über die Programmkomponenten bewertet; keine Punktschätzung." - ) - ) - else: - lines.append( - "[color=#94a3b8]PCS und Abzüge: Kategorie wählen.[/color]" - ) - if not report.element_values.is_empty(): - lines.append("") - lines.append("[b]Wertung[/b]") - for entry: Dictionary in report.element_values: - var value: float = entry["value"] - var value_text := ( - "—" if value < 0.0 else _format_base_value(value) - ) - lines.append( - "%s — %s" - % [_escape_bbcode(str(entry["label"])), value_text] - ) - lines.append("") - lines.append("[b]Prüfungen[/b]") - for check: ValidationCheck in report.checks: - lines.append(_validation_check_line(check)) - lines.append("") - lines.append("[b]Befunde[/b]") - - if report.issues.is_empty(): - if report.element_count == 0: - lines.append("Keine Elemente vorhanden.") - else: - lines.append("Keine Befunde.") - else: - lines.append( - "[b]%d Fehler, %d Warnungen[/b]" % [errors, warnings] - ) - for issue: ValidationIssue in report.issues: - var color := ( - "#ef4444" - if issue.severity == ValidationIssue.Severity.ERROR - else "#f59e0b" - ) - lines.append( - "[color=%s]●[/color] [b]%s[/b]%s: %s" - % [ - color, - issue.severity_label(), - _validation_location(issue), - _escape_bbcode(issue.message), - ] - ) - validation_text.text = I18n.join_lines(lines) if validation_dialog.visible: return @@ -1063,13 +896,10 @@ func _render_validation_dialog() -> void: target.y = mini(target.y, viewport_size.y) validation_dialog.popup_centered(target) - -## Opens the season comparison for the current routine. It only reports; the -## routine changes season when the user confirms it. func open_upgrade_dialog() -> void: - if _routine == null or _rules_package == null or _rules_library == null: + if _routine == null or _ruleset.package == null or _ruleset.library == null: return - if _rules_library.get_seasons().size() < 2: + if _ruleset.library.get_seasons().size() < 2: return _fill_upgrade_seasons() _run_upgrade_check() @@ -1085,7 +915,7 @@ func open_upgrade_dialog() -> void: func _fill_upgrade_seasons() -> void: upgrade_season_option.clear() var current := _routine.season.strip_edges() - for season: String in _rules_library.get_seasons(): + for season: String in _ruleset.library.get_seasons(): if season == current: continue var index := upgrade_season_option.item_count @@ -1103,170 +933,22 @@ func _selected_upgrade_season() -> String: func _run_upgrade_check() -> void: - if _routine == null or _rules_package == null or _rules_library == null: + if _routine == null or _ruleset.package == null or _ruleset.library == null: return var season := _selected_upgrade_season() _upgrade_target_season = season - var target := _rules_library.get_package(season) + var target := _ruleset.library.get_package(season) if target == null: upgrade_text.text = I18n.t("Ziel-Saison nicht verfügbar.") upgrade_apply_button.disabled = true + upgrade_pdf_button.disabled = true return - _upgrade_report = SeasonUpgradeCheck.run(_routine, _rules_package, target) - upgrade_text.text = I18n.join_lines(_upgrade_report_lines(_upgrade_report)) + _upgrade_report = SeasonUpgradeCheck.run(_routine, _ruleset.package, target) + upgrade_text.text = I18n.join_lines( + SeasonComparisonText.build(_routine, _upgrade_report) + ) upgrade_apply_button.disabled = false - - -func _upgrade_report_lines(report: SeasonUpgradeCheck.Report) -> PackedStringArray: - var lines := PackedStringArray() - var title := _routine.title.strip_edges() - if title.is_empty(): - title = I18n.t("Unbenannte Kür") - lines.append( - "[b]%s — %s → %s[/b]" - % [ - _escape_bbcode(title), - report.source_season, - report.target_season, - ] - ) - - if not report.has_changes(): - lines.append("") - lines.append( - I18n.t("Keine Unterschiede: Die Kür passt in beide Saisons.") - ) - - _append_upgrade_group( - lines, - I18n.t("Elemente"), - report.changes_of(SeasonUpgradeCheck.KIND_MISSING_CODE), - I18n.t("nicht im Katalog") - ) - _append_upgrade_group( - lines, - I18n.t("Base Values"), - report.changes_of(SeasonUpgradeCheck.KIND_VALUE_CHANGE) - ) - _append_upgrade_group( - lines, - I18n.t("Elementtyp"), - report.changes_of(SeasonUpgradeCheck.KIND_TYPE_CHANGE) - ) - _append_upgrade_group( - lines, - I18n.t("Features"), - report.changes_of(SeasonUpgradeCheck.KIND_UNKNOWN_FEATURE), - I18n.t("in der Ziel-Saison unbekannt") - ) - _append_upgrade_group( - lines, - I18n.t("Level"), - report.changes_of(SeasonUpgradeCheck.KIND_LEVEL_CHANGE) - ) - _append_upgrade_group( - lines, - I18n.t("Kategorie"), - report.changes_of(SeasonUpgradeCheck.KIND_CATEGORY_CHANGE) - ) - var missing_category := report.changes_of( - SeasonUpgradeCheck.KIND_CATEGORY_MISSING - ) - if not missing_category.is_empty(): - lines.append("") - lines.append("[b]%s[/b]" % I18n.t("Kategorie")) - lines.append( - "● %s: %s" - % [ - _escape_bbcode(missing_category[0].label), - I18n.t("in der Ziel-Saison nicht vorhanden"), - ] - ) - - lines.append("") - lines.append("[b]%s[/b]" % I18n.t("Summe")) - if report.base_value_before > 0.0 or report.base_value_after > 0.0: - lines.append( - I18n.t("Basiswert %s → %s (%s%s)") - % [ - _format_base_value(report.base_value_before), - _format_base_value(report.base_value_after), - "+" if report.value_delta() >= 0.0 else "−", - _format_base_value(absf(report.value_delta())), - ] - ) - else: - lines.append(I18n.t("Keine Elemente mit Base Value.")) - - if not report.issues.is_empty(): - lines.append("") - lines.append( - "[b]%s[/b]" % I18n.t("Befunde bei Prüfung gegen %s") % report.target_season - ) - for issue: ValidationIssue in report.issues: - var color := ( - "#ef4444" - if issue.severity == ValidationIssue.Severity.ERROR - else "#f59e0b" - ) - lines.append( - "[color=%s]●[/color] %s%s" - % [ - color, - _escape_bbcode(issue.message), - _upgrade_location(issue.section_id), - ] - ) - return lines - - -func _append_upgrade_group( - lines: PackedStringArray, - title: String, - changes: Array, - suffix: String = "" -) -> void: - if changes.is_empty(): - return - lines.append("") - lines.append("[b]%s[/b]" % title) - for change: SeasonUpgradeCheck.Change in changes: - var text := _escape_bbcode(change.label) - if change.kind == SeasonUpgradeCheck.KIND_MISSING_CODE: - text += ": " + I18n.t("nicht im Katalog") - elif change.kind == SeasonUpgradeCheck.KIND_UNKNOWN_FEATURE: - text += ": %s — %s" % [ - I18n.t("Feature"), - _escape_bbcode(change.before), - ] - if not suffix.is_empty(): - text += " " + suffix - elif change.kind == SeasonUpgradeCheck.KIND_CATEGORY_CHANGE: - text = "%s: %s → %s" % [ - _escape_bbcode(change.label), - _escape_bbcode(change.before), - _escape_bbcode(change.after), - ] - elif change.after.is_empty(): - text += ": " + _escape_bbcode(change.before) - else: - text += ": %s → %s" % [ - _escape_bbcode(change.before), - _escape_bbcode(change.after), - ] - text += _upgrade_location(change.section_id) - lines.append("● %s" % text) - - -func _upgrade_location(section_id: String) -> String: - if section_id.is_empty() or _routine == null: - return "" - if _routine.sections.size() < 2: - return "" - var section := _routine.get_section_by_id(section_id) - if section == null: - return "" - return " (%s)" % I18n.section_title(section.title) + upgrade_pdf_button.disabled = false func _on_upgrade_apply_pressed() -> void: @@ -1276,126 +958,31 @@ func _on_upgrade_apply_pressed() -> void: upgrade_dialog.hide() -func _score_info_lines() -> PackedStringArray: - var lines := PackedStringArray() - lines.append("[b]Enthalten[/b]") - lines.append("- Base Value jedes Elements aus Katalog und gewähltem Level") - lines.append("- ChSq und ChSp mit festem Level 1") - lines.append("- strukturierte Sprungkombinationen als Summe ihrer Sprünge") - lines.append("- nur Elemente mit gültigem Katalogwert") - lines.append("") - lines.append("[b]Nicht im Basiswert enthalten[/b]") - lines.append("- GOE / Ausführungsqualität") - lines.append("- 1,1-Faktor für Sprünge in der zweiten Programmhälfte") - lines.append("- Programmkomponenten (PCS)") - lines.append("- Abzüge (Stürze, Zeitüberschreitungen usw.)") - lines.append("- nicht katalogisierte Kombinationen und Freitext-Codes") - lines.append("- Programmtyp und Adult-spezifische Sonderregeln") - lines.append("") - lines.append( - "[b]Punktschätzung[/b]\nPCS und Sturzabzug werden separat in der " - + "Punktschätzung angesetzt." +## Writes the comparison as a PDF into the export folder and shows the usual +## "open / show folder / copy path" dialog. +func _on_upgrade_pdf_pressed() -> void: + if _routine == null or _upgrade_report == null: + return + var pdf := RoutinePdfExporter.build_season_comparison( + _routine, + _upgrade_report ) - lines.append("") - lines.append( - "[b]Ergebnis[/b]\nDer Basiswert ist ein technischer Wert, keine " - + "vorhergesagte Gesamtpunktzahl." + if pdf.is_empty(): + _show_message(I18n.t("Export fehlgeschlagen.")) + return + ExportService.ensure_dir() + var season := _upgrade_target_season.replace("/", "-") + var path := ExportService.build_path( + ExportService.normalize_stem(_routine.title), + "_saisonvergleich_" + season, + "pdf" ) - return lines - - -func _validation_check_line(check: ValidationCheck) -> String: - var color := "#22c55e" - var icon := "✓" - var detail := check.summary() - if check.is_skipped(): - color = "#64748b" - icon = "–" - detail = I18n.t("nicht anwendbar (%s)") % _validation_skip_reason(check.code) - elif check.findings > 0: - color = "#ef4444" if check.errors > 0 else "#f59e0b" - icon = "✗" - - var findings := PackedStringArray() - if check.errors > 0: - findings.append("%d Fehler" % check.errors) - if check.warnings > 0: - findings.append( - "%d Warnung%s" - % [check.warnings, "" if check.warnings == 1 else "en"] - ) - if not findings.is_empty(): - detail += " · " + " · ".join(findings) - - return "[color=%s]%s[/color] %s — %s" % [ - color, - icon, - _escape_bbcode(check.label), - detail, - ] - - -func _validation_skip_reason(check_code: String) -> String: - if check_code.begins_with("category"): - return "keine Kategorie oder keine passenden Elemente" - match check_code: - "code": - return "keine Elemente" - "type": - return "kein Kürzel im Katalog" - "level": - return "kein passendes Kürzel" - "fixed_level": - return "kein ChSq" - "features", "required", "level_features": - return "keine Features gesetzt" - "once": - return "keine Einmal-Features gesetzt" - "jump_sequence": - return "keine Sprungfolge" - return "keine passenden Daten" - - -func _element_count_label(count: int) -> String: - return "1 Element" if count == 1 else "%d Elemente" % count - - -func _section_count_label(count: int) -> String: - return "1 Abschnitt" if count == 1 else "%d Abschnitten" % count - - -func _validation_location(issue: ValidationIssue) -> String: - var parts := PackedStringArray() - if not issue.section_id.is_empty(): - var section := _routine.get_section_by_id(issue.section_id) - parts.append( - "Abschnitt „%s“" - % (I18n.section_title(section.title) if section != null else issue.section_id) - ) - if not issue.segment_id.is_empty(): - var segment := _find_routine_segment(issue.segment_id) - if segment != null and segment.is_element(): - var label := segment.element_code.strip_edges() - if label.is_empty(): - label = PathSegment.element_type_name(segment.element_type) - parts.append("Element „%s“" % label) - else: - parts.append(issue.segment_id) - if parts.is_empty(): - return "" - return " (%s)" % " · ".join(parts) - - -func _find_routine_segment(segment_id: String) -> PathSegment: - if _routine == null or segment_id.is_empty(): - return null - for section: RoutineSection in _routine.sections: - if section == null: - continue - var segment := section.get_segment_by_id(segment_id) - if segment != null: - return segment - return null + if not ExportService.write_bytes(path, pdf): + _show_message(I18n.t("Export fehlgeschlagen.")) + return + _last_export_path = ProjectSettings.globalize_path(path) + upgrade_dialog.hide() + _show_export_done() static func _escape_bbcode(text: String) -> String: @@ -1406,12 +993,8 @@ static func _format_base_value(value: float) -> String: return ("%.2f" % value).replace(".", ",") -static func _format_duration(seconds: int) -> String: - return "%d:%02d" % [seconds / 60, seconds % 60] - - func open_help_dialog() -> void: - help_text.text = _help_content() + help_text.text = HelpContent.build() var target := Vector2i(820, 680) var viewport_size := Vector2i(get_viewport_rect().size) if viewport_size.x > 0: @@ -1421,145 +1004,6 @@ func open_help_dialog() -> void: help_dialog.popup_centered(target) -func _help_content() -> String: - var lines := PackedStringArray() - lines.append("[b][font_size=22]Hilfe & Annahmen[/font_size][/b]") - lines.append( - "Diese Hilfe erklärt die Annahmen und Prüfungen der App. Sie ist " - + "keine offizielle ISU-Auslegung." - ) - lines.append("") - lines.append("[b][font_size=18]1. Kürzel und Base Value[/font_size][/b]") - lines.append( - "- Das Kürzel bezeichnet die Elementfamilie, z. B. 3Lz, CCoSp oder StSq." - ) - lines.append( - "- Der Level ist die Schwierigkeitsstufe. Bei Pirouetten und " - + "Schrittsequenzen folgt er aus den Features." - ) - lines.append( - "- Der Base Value wird aus Kürzel und Level im Saisonkatalog 2026/27 " - + "nachgeschlagen (ISU Communication 2786)." - ) - lines.append( - "- Sprünge haben keinen Level; ihr Base Value hängt von Rotation und " - + "Sprungtyp ab." - ) - lines.append( - "- Sprungkombinationen werden strukturiert gewählt: erster Sprung plus " - + "bis zu zwei weitere, als Kombination oder Folge. Die Base Values " - + "werden summiert." - ) - lines.append( - "- Eine Folge braucht einen Axel (1A/2A/3A) als 2. oder 3. Sprung." - ) - lines.append( - "- Alte Freitext-Kombinationen werden beim Laden oder Übernehmen " - + "automatisch in die strukturierte Form überführt." - ) - lines.append( - "- ChSq (Choreo-Sequenz) und ChSp (Choreographic Spin) sind fest " - + "Level 1." - ) - lines.append( - "- Unbekannte Freitext-Codes haben keinen Katalogwert und werden in " - + "der Schätzung nicht gewertet." - ) - lines.append("") - lines.append("[b][font_size=18]2. Level aus Features[/font_size][/b]") - lines.append( - "- Pirouetten haben 15 Features, Schrittsequenzen 5 " - + "(ISU Communication 2788)." - ) - lines.append( - "- 0 Features = Base, 1 = Level 1, 2 = Level 2, 3 = Level 3, " - + "4 oder mehr = Level 4." - ) - lines.append( - "- Level 4 bei Pirouetten verlangt zusätzlich eines von: schwieriger " - + "Ausgang, Kantenänderung, beide Richtungen, Temposteigerung, " - + "schwieriger Flug-Eingang oder Windmills." - ) - lines.append( - "- Bei Schrittsequenzen ist Feature 1 (Vielfalt) Pflicht." - ) - lines.append( - "- Features beschreiben die Ausführung. Die App kann sie nicht aus " - + "der gezeichneten Linie ableiten; sie werden im Element-Dialog " - + "ausgewählt." - ) - lines.append("") - lines.append("[b][font_size=18]3. Adult-Kategorie[/font_size][/b]") - lines.append( - "- Die Kategorie wird in der Statusleiste gewählt und mit der Kür " - + "gespeichert." - ) - lines.append( - "- Gold: max. 5 Sprünge, keine 2F/2Lz/2A/Triple, 3 Pirouetten inkl. " - + "ChSp, 1 Schrittsequenz, 2:50 ±10 s, Spins bis Level 3, Sequenz bis " - + "Level 2." - ) - lines.append( - "- Silver: max. 4 Einfachsprünge inkl. 1A, 2 Pirouetten, 1 ChSq, " - + "2:00 ±10 s, Level bis 2." - ) - lines.append( - "- Bronze: max. 4 Einfachsprünge ohne Axel, 1 Sprungkombination, " - + "2 Pirouetten, 1 ChSq, 1:40 ±10 s, Level bis 1." - ) - lines.append( - "- PCS-Faktor und Sturzabzug stehen in den Kategorie-Daten " - + "(Gold 2,67 und 1,0; Silver/Bronze 2,00 und 0,5)." - ) - lines.append("") - lines.append("[b][font_size=18]4. Punktschätzung[/font_size][/b]") - lines.append( - "- Basiswert: Summe der Base Values aller Elemente mit gültigem " - + "Katalogwert." - ) - lines.append( - "- PCS-Annahme: Durchschnitt pro Komponente × 3 Komponenten × " - + "Kategorie-Faktor." - ) - lines.append( - "- Der PCS-Durchschnitt ist eine Planungsannahme, kein Judge-Wert. " - + "Startwert 5,00; er kann über „Annahmen ändern“ angepasst werden." - ) - lines.append( - "- Sturzabzug: Anzahl Stürze × Kategorie-Abzug." - ) - lines.append( - "- Nicht enthalten: GOE, 1,1-Faktor, nicht katalogisierte " - + "Kombinationen und die offizielle Wettkampfwertung." - ) - lines.append( - "- Beispiel Gold: 5,00 × 3 × 2,67 = 40,05 PCS; Basiswert 9,50; " - + "geschätzte Summe 49,55." - ) - lines.append("") - lines.append("[b][font_size=18]5. Prüfung[/font_size][/b]") - lines.append( - "- Der Button „Prüfen“ zeigt Kürzel-, Level-, Feature- und " - + "Kategorie-Prüfungen sowie die Punktschätzung." - ) - lines.append( - "- Warnungen blockieren Speichern und Export nicht. Sie sind " - + "Planungshinweise." - ) - lines.append( - "- Wiederholungen: max. 2-mal pro gelistetem Sprung; " - + "Kombinationsbestandteile zählen mit." - ) - lines.append("") - lines.append("[b]Tipp:[/b] Für eine realistische PCS-Annahme helfen " - + "Protokolle früherer Wettkämpfe. Der Durchschnitt sollte zu deinem " - + "aktuellen Leistungsstand passen, nicht zum Wunschziel.") - lines.append("") - lines.append("[b]Quellen:[/b] ISU Communication 2786 (SoV 2026/27), " - + "2788 (Levels/GOE 2026/27), IAFSC Technical Announcement 2026/27.") - return I18n.join_lines(lines) - - func _on_validation_meta_clicked(meta: Variant) -> void: var key := str(meta) if key == "score_info": @@ -1575,9 +1019,9 @@ func _on_validation_meta_clicked(meta: Variant) -> void: func _can_compare_seasons() -> bool: return ( - _rules_package != null - and _rules_library != null - and _rules_library.get_seasons().size() > 1 + _ruleset.package != null + and _ruleset.library != null + and _ruleset.library.get_seasons().size() > 1 ) @@ -1694,17 +1138,17 @@ func update_element_feature_hint() -> void: if type == PathSegment.ElementType.JUMP: element_feature_hint.text = "Sprünge haben keine Level-Features." return - if _level_rules == null: + if _ruleset.levels == null: element_feature_hint.text = "" return if code.is_empty(): element_feature_hint.text = "Kürzel wählen, um Level-Features zu erfassen." return - if _element_catalog == null or not _element_catalog.has_code(code): + if _ruleset.catalog == null or not _ruleset.catalog.has_code(code): element_feature_hint.text = "Kürzel nicht im Katalog." return - var result := _level_rules.calculate_level( + var result := _ruleset.levels.calculate_level( type, code, features, @@ -1770,10 +1214,10 @@ func _open_feature_menu() -> void: ## Fills the feature menu from the pending dialog state. Split from the popup ## call so tests can inspect the items without opening a window. func _populate_feature_menu() -> bool: - if _level_rules == null or not element_dialog.visible: + if _ruleset.levels == null or not element_dialog.visible: return false var type := _dialog_element_type() - var features := _level_rules.get_features(type) + var features := _ruleset.levels.get_features(type) if features.is_empty(): return false @@ -1848,22 +1292,22 @@ func _update_feature_foot_panel() -> void: child.free() var per_foot: Array[ElementFeature] = [] - if _level_rules != null and _element_catalog != null: - var definition := _element_catalog.find(_dialog_element_code()) + if _ruleset.levels != null and _ruleset.catalog != null: + var definition := _ruleset.catalog.find(_dialog_element_code()) if ( definition != null and definition.element_type == PathSegment.ElementType.SPIN and definition.change_of_foot ): - for feature: ElementFeature in _level_rules.get_features( + for feature: ElementFeature in _ruleset.levels.get_features( PathSegment.ElementType.SPIN ): if feature.per_foot and _dialog_features.has(feature.code): per_foot.append(feature) var maximum := 0 - if _level_rules != null: - maximum = _level_rules.get_max_features_per_foot( + if _ruleset.levels != null: + maximum = _ruleset.levels.get_max_features_per_foot( PathSegment.ElementType.SPIN ) var needed := maximum > 0 and per_foot.size() > maximum @@ -1933,7 +1377,7 @@ func _refresh_foot_buttons() -> void: func update_element_value_hint() -> void: if element_value_label == null: return - if _element_catalog == null: + if _ruleset.catalog == null: element_value_label.text = "" return @@ -1945,7 +1389,7 @@ func update_element_value_hint() -> void: if element_level_option.selected >= 0: level = element_level_option.get_item_id(element_level_option.selected) var code := _dialog_element_code() - var source := "%s · %s" % [_element_catalog.season, _element_catalog.source] + var source := "%s · %s" % [_ruleset.catalog.season, _ruleset.catalog.source] element_value_label.tooltip_text = source if type == PathSegment.ElementType.NONE or code.is_empty(): @@ -1967,7 +1411,7 @@ func update_element_value_hint() -> void: if not parts.is_empty(): value = 0.0 for part: String in parts: - var part_value := _element_catalog.get_base_value( + var part_value := _ruleset.catalog.get_base_value( part, 0, PathSegment.ElementType.JUMP @@ -1977,10 +1421,10 @@ func update_element_value_hint() -> void: break value += part_value else: - value = _element_catalog.get_base_value(code, level, type) + value = _ruleset.catalog.get_base_value(code, level, type) if value < 0.0: element_value_label.text = ( - I18n.t("Base Value: – (Kürzel nicht im Katalog %s)") % _element_catalog.season + I18n.t("Base Value: – (Kürzel nicht im Katalog %s)") % _ruleset.catalog.season ) return element_value_label.text = ( @@ -2029,16 +1473,16 @@ func _is_derived_level( return true if ( type == PathSegment.ElementType.NONE - or _element_catalog == null - or _level_rules == null + or _ruleset.catalog == null + or _ruleset.levels == null ): return false - var definition := _element_catalog.find(code) + var definition := _ruleset.catalog.find(code) if definition == null or definition.element_type != type: return false - if _level_rules.get_fixed_level(type, code) >= 0: + if _ruleset.levels.get_fixed_level(type, code) >= 0: return true - return not _level_rules.get_features(type).is_empty() + return not _ruleset.levels.get_features(type).is_empty() func _derived_level( @@ -2049,9 +1493,9 @@ func _derived_level( ) -> int: if type == PathSegment.ElementType.JUMP: return 0 - if _level_rules == null: + if _ruleset.levels == null: return 0 - return _level_rules.calculate_level(type, code, features, feet).level + return _ruleset.levels.calculate_level(type, code, features, feet).level ## Keeps only the feet of selected features and normalises them to L/R. @@ -2096,9 +1540,9 @@ func _populate_code_options(type: PathSegment.ElementType) -> void: "— Kürzel wählen —", CODE_OPTION_PLACEHOLDER_ID ) - if _element_catalog != null and type != PathSegment.ElementType.NONE: - for family: String in _element_catalog.get_codes(type): - var definition := _element_catalog.find(family) + if _ruleset.catalog != null and type != PathSegment.ElementType.NONE: + for family: String in _ruleset.catalog.get_codes(type): + var definition := _ruleset.catalog.find(family) var label := family if definition != null and not definition.display_name.is_empty(): label = "%s — %s" % [family, definition.display_name] @@ -2130,8 +1574,8 @@ func _select_code_in_option( return var definition: ElementDefinition = null - if _element_catalog != null: - definition = _element_catalog.find(cleaned) + if _ruleset.catalog != null: + definition = _ruleset.catalog.find(cleaned) if definition != null and definition.element_type == type: var family := definition.code var index := _find_code_option_index(family) @@ -2139,11 +1583,11 @@ func _select_code_in_option( element_code_option.select(index) element_code_edit.text = family _set_code_free_text(false) - var suffix := _element_catalog.get_level_suffix(cleaned) + var suffix := _ruleset.catalog.get_level_suffix(cleaned) if suffix >= 0: _select_level_option(suffix) - elif _level_rules != null: - var fixed := _level_rules.get_fixed_level(type, family) + elif _ruleset.levels != null: + var fixed := _ruleset.levels.get_fixed_level(type, family) if fixed >= 0: _select_level_option(fixed) return @@ -2193,8 +1637,8 @@ func _on_element_code_option_selected(index: int) -> void: var type: PathSegment.ElementType = element_dialog_type_option.get_item_id( element_dialog_type_option.selected ) - if _level_rules != null: - var fixed := _level_rules.get_fixed_level(type, family) + if _ruleset.levels != null: + var fixed := _ruleset.levels.get_fixed_level(type, family) if fixed >= 0: _select_level_option(fixed) _update_level_control_state() @@ -2207,12 +1651,12 @@ func _populate_jump_extra_options() -> void: option.clear() option.add_item("— kein weiterer Sprung —", 0) option.set_item_metadata(0, "") - if _element_catalog == null: + if _ruleset.catalog == null: continue - for family: String in _element_catalog.get_codes( + for family: String in _ruleset.catalog.get_codes( PathSegment.ElementType.JUMP ): - var definition := _element_catalog.find(family) + var definition := _ruleset.catalog.find(family) var label := family if definition != null and not definition.display_name.is_empty(): label = "%s — %s" % [family, definition.display_name] @@ -2353,18 +1797,18 @@ func _normalize_element_input( var cleaned := code.strip_edges().left(PathSegment.ELEMENT_CODE_MAX_LENGTH) var clamped := clampi(level, 0, PathSegment.ELEMENT_MAX_LEVEL) if ( - _element_catalog == null + _ruleset.catalog == null or type == PathSegment.ElementType.NONE or cleaned.length() < 2 ): return {"code": cleaned, "level": clamped} - var suffix := _element_catalog.get_level_suffix(cleaned) + var suffix := _ruleset.catalog.get_level_suffix(cleaned) if suffix < 0: return {"code": cleaned, "level": clamped} var family := cleaned.left(cleaned.length() - 1) - var definition := _element_catalog.find(family) + var definition := _ruleset.catalog.find(family) if definition == null or definition.element_type != type: return {"code": cleaned, "level": clamped} if not definition.has_level(suffix): @@ -3000,16 +2444,8 @@ func _setup_element_controls() -> void: func _setup_adult_category_controls() -> void: - adult_category_option.clear() - adult_category_option.add_item("Ohne Kategorie", 0) - adult_category_option.set_item_metadata(0, "") - if _adult_rules != null: - for category: AdultCategoryRules.Category in _adult_rules.get_categories( - _program_type() - ): - var index := adult_category_option.item_count - adult_category_option.add_item(category.name, index) - adult_category_option.set_item_metadata(index, category.code) + if adult_category_option == null: + return if not adult_category_option.item_selected.is_connected( _on_adult_category_selected ): @@ -3017,7 +2453,6 @@ func _setup_adult_category_controls() -> void: _sync_adult_category_option() -## Programme type of the current routine: "free" (Kür) or "artistic". func _program_type() -> String: if _routine == null: return AdultCategoryRules.PROGRAM_FREE @@ -3027,11 +2462,6 @@ func _program_type() -> String: func _setup_program_controls() -> void: if program_option == null: return - program_option.clear() - program_option.add_item(I18n.t("Kür"), 0) - program_option.set_item_metadata(0, AdultCategoryRules.PROGRAM_FREE) - program_option.add_item(I18n.t("Artistic"), 1) - program_option.set_item_metadata(1, AdultCategoryRules.PROGRAM_ARTISTIC) if not program_option.item_selected.is_connected(_on_program_selected): program_option.item_selected.connect(_on_program_selected) _sync_program_option() @@ -3040,12 +2470,7 @@ func _setup_program_controls() -> void: func _sync_program_option() -> void: if program_option == null: return - var program := _program_type() - for index: int in range(program_option.item_count): - if str(program_option.get_item_metadata(index)) == program: - program_option.select(index) - return - program_option.select(0) + _fill_option(program_option, SeasonPanelModel.program_items(_program_type())) func _on_program_selected(index: int) -> void: @@ -3077,12 +2502,6 @@ func get_program_type() -> String: return _program_type() -func _program_label(program_type: String) -> String: - if program_type == AdultCategoryRules.PROGRAM_ARTISTIC: - return I18n.t("Artistic") - return I18n.t("Kür") - - func _on_adult_category_selected(index: int) -> void: set_adult_category(str(adult_category_option.get_item_metadata(index))) @@ -3094,8 +2513,8 @@ func set_adult_category(code: String) -> bool: if ( not cleaned.is_empty() and ( - _adult_rules == null - or not _adult_rules.has_category(cleaned, _program_type()) + _ruleset.adult == null + or not _ruleset.adult.has_category(cleaned, _program_type()) ) ): return false @@ -3114,39 +2533,44 @@ func get_adult_category() -> String: func get_adult_rules() -> AdultCategoryRules: - return _adult_rules + return _ruleset.adult func _sync_adult_category_option() -> void: if adult_category_option == null: return - var code := _routine.adult_category if _routine != null else "" - for index: int in range(adult_category_option.item_count): - if str(adult_category_option.get_item_metadata(index)) == code: - adult_category_option.select(index) - return - # The stored category is not part of this season. Show it instead of - # pretending the routine has no category. - if not code.is_empty(): - var index := adult_category_option.item_count - adult_category_option.add_item( - I18n.t("Kategorie „%s“ nicht verfügbar") % code.capitalize(), - index + var categories: Array = [] + if _ruleset.adult != null: + categories.assign(_ruleset.adult.get_categories(_program_type())) + _fill_option( + adult_category_option, + SeasonPanelModel.category_items( + _routine.adult_category if _routine != null else "", + categories ) - adult_category_option.set_item_metadata(index, code) - adult_category_option.select(index) - return - if adult_category_option.item_count > 0: - adult_category_option.select(0) + ) + + +## Fills an OptionButton from a SeasonPanelModel result. +func _fill_option(option: OptionButton, content: Dictionary) -> void: + option.clear() + var items: Array = content.get("items", []) + for index: int in range(items.size()): + var item: Dictionary = items[index] + option.add_item(str(item.get("label", "")), index) + option.set_item_metadata(index, str(item.get("value", ""))) + var selected := int(content.get("selected", -1)) + if selected >= 0: + option.select(selected) -## Fills the season dropdown. The list comes from the rules library, so a new -## season folder appears without touching this code. func _setup_upgrade_controls() -> void: if upgrade_run_button != null: upgrade_run_button.pressed.connect(_run_upgrade_check) if upgrade_apply_button != null: upgrade_apply_button.pressed.connect(_on_upgrade_apply_pressed) + if upgrade_pdf_button != null: + upgrade_pdf_button.pressed.connect(_on_upgrade_pdf_pressed) if upgrade_season_option != null: upgrade_season_option.item_selected.connect(_on_upgrade_season_selected) @@ -3167,56 +2591,18 @@ func _sync_season_option() -> void: if season_option == null: return var current := _routine.season.strip_edges() if _routine != null else "" - season_option.clear() - - var selected := -1 - if current.is_empty(): - season_option.add_item(I18n.t("Saison nicht festgelegt"), 0) - season_option.set_item_metadata(0, "") - selected = 0 - - if _rules_library != null: - for season: String in _rules_library.get_seasons(): - var index := season_option.item_count - var label := I18n.t("Saison %s") % season - var status := str( - _rules_library.get_manifest(season).get("status", "complete") - ).strip_edges() - if status != "complete": - label += " " + I18n.t("(unvollständig)") - season_option.add_item(label, index) - season_option.set_item_metadata(index, season) - if season == current: - selected = index - - if not current.is_empty() and selected < 0: - var index := season_option.item_count - season_option.add_item(I18n.t("Saison %s (unbekannt)") % current, index) - season_option.set_item_metadata(index, current) - selected = index - - if selected >= 0: - season_option.select(selected) - season_option.tooltip_text = _season_tooltip(current) - - -func _season_tooltip(current: String) -> String: - if not current.is_empty(): - return I18n.t("Regelwerk, gegen das diese Kür geprüft wird") - var inferred := _infer_season_from_current_path() - if inferred.is_empty(): - return I18n.t("Ohne Saison kann die Kür nicht geprüft werden") - return ( - I18n.t("Ohne Saison kann die Kür nicht geprüft werden") - + " " - + I18n.t("Vermutlich Saison %s (Dateidatum).") % inferred + _fill_option( + season_option, + SeasonPanelModel.season_items(current, _ruleset.library) + ) + season_option.tooltip_text = SeasonPanelModel.season_tooltip( + current, + _infer_season_from_current_path() ) -## Best guess for a routine that predates the season field: the season that was -## valid when its file was last written. Only used as a hint, never applied. func _infer_season_from_current_path() -> String: - if _current_path.is_empty() or _rules_library == null: + if _current_path.is_empty() or _ruleset.library == null: return "" if not FileAccess.file_exists(_current_path): return "" @@ -3224,7 +2610,7 @@ func _infer_season_from_current_path() -> String: if unix <= 0: return "" var date := Time.get_date_string_from_unix_time(unix) - return _rules_library.get_default_season(date) + return _ruleset.library.get_default_season(date) func _on_season_selected(index: int) -> void: @@ -3242,7 +2628,7 @@ func set_season(season: String) -> bool: return false if ( not cleaned.is_empty() - and (_rules_library == null or not _rules_library.has_season(cleaned)) + and (_ruleset.library == null or not _ruleset.library.has_season(cleaned)) ): return false _record_undo() @@ -3265,7 +2651,7 @@ func get_season() -> String: ## One line that explains why the check cannot use a rule package, if that is ## the case. Empty when the season resolved normally. func _season_note() -> String: - if _rules_package != null: + if _ruleset.package != null: return "" var raw := _routine.season.strip_edges() if _routine != null else "" if raw.is_empty(): @@ -4472,8 +3858,7 @@ func play() -> void: _playing = true _update_playback_state(0.0, true) _start_music() - _update_play_button() - _update_playback_ui() + _sync_playback_ui() _update_status() _sync_trail_fade() @@ -4483,8 +3868,7 @@ func pause() -> void: return _playing = false _stop_music() - _update_play_button() - _update_playback_ui() + _sync_playback_ui() _sync_trail_fade() @@ -4494,12 +3878,11 @@ func reset_playback() -> void: _playback_section_id = "" _playback_segment_id = "" _stop_music() - _update_play_button() rink_canvas.clear_playback_state() _update_section_buttons() if _view_3d_active and _presentation_3d != null: _presentation_3d.clear_pose() - _update_playback_ui() + _sync_playback_ui() _sync_trail_fade() @@ -4514,7 +3897,7 @@ func seek_playback(time: float) -> void: _update_playback_state(0.0, true) if _playing: _seek_music(_playback_time) - _update_playback_ui() + _sync_playback_ui() _sync_trail_fade() @@ -4532,8 +3915,7 @@ func advance_playback(delta: float) -> void: _update_playback_state(0.0, true) _playing = false _stop_music() - _update_play_button() - _update_playback_ui() + _sync_playback_ui() _sync_trail_fade() return @@ -4553,21 +3935,8 @@ func _process(delta: float) -> void: func _setup_playback_controls() -> void: - speed_option.clear() - speed_option.add_item("0,25×", 25) - speed_option.add_item("0,5×", 50) - speed_option.add_item("1×", 100) - speed_option.add_item("1,5×", 150) - speed_option.add_item("2×", 200) - speed_option.select(speed_option.get_item_index(100)) - _playback_speed = 1.0 - - playback_timeline.min_value = 0.0 - playback_timeline.max_value = 0.0 - playback_timeline.step = 0.01 - playback_timeline.editable = false - play_button.disabled = true - reset_playback_button.disabled = true + playback_panel.setup() + playback_panel.set_speed(_playback_speed) music_file_dialog.filters = PackedStringArray([ "*.mp3, *.m4a, *.aac ; MP3 / M4A / AAC", "*.ogg ; OGG-Musik", @@ -4576,7 +3945,7 @@ func _setup_playback_controls() -> void: music_player.pitch_scale = 1.0 timeline_label_edit.max_length = RoutineFile.MAX_TIMELINE_LABEL_LENGTH _update_music_ui() - _update_play_button() + _sync_playback_ui() func _toggle_playback() -> void: @@ -4586,8 +3955,8 @@ func _toggle_playback() -> void: play() -func _on_speed_selected(index: int) -> void: - _playback_speed = float(speed_option.get_item_id(index)) / 100.0 +func _on_speed_requested(speed: float) -> void: + _playback_speed = speed # The audio follows the routine clock. Changing the pitch also changes the # playback rate, so the music stays aligned at every speed. music_player.pitch_scale = _playback_speed @@ -4595,12 +3964,6 @@ func _on_speed_selected(index: int) -> void: _seek_music(_playback_time) -func _on_timeline_changed(value: float) -> void: - if _updating_timeline: - return - seek_playback(value) - - func _refresh_playback_timeline() -> void: var entries: Array[Dictionary] = [] var total := 0.0 @@ -4645,8 +4008,7 @@ func _refresh_playback_timeline() -> void: _playing = false _stop_music() - _update_play_button() - _update_playback_ui() + _sync_playback_ui() if total > 0.0 and (_playing or _playback_time > 0.0): _update_playback_state(0.0, true) @@ -4656,7 +4018,14 @@ func _update_playback_state( delta: float, force_heading: bool = false ) -> void: - if _playback_entries.is_empty() or _routine == null: + var pose := PlaybackPose.compute( + _playback_entries, + _playback_time, + _playback_heading, + delta, + force_heading + ) + if not pose.found or _routine == null: _playback_section_id = "" rink_canvas.clear_playback_state() _update_section_buttons() @@ -4664,182 +4033,44 @@ func _update_playback_state( _presentation_3d.clear_pose() return - var entry: Dictionary = _playback_entries[_playback_entries.size() - 1] - var entry_index := _playback_entries.size() - 1 - for index: int in range(_playback_entries.size()): - var candidate: Dictionary = _playback_entries[index] - var candidate_start: float = candidate["start"] - var candidate_duration: float = candidate["duration"] - if _playback_time < candidate_start + candidate_duration - 0.0001: - entry = candidate - entry_index = index - break - - var segment: PathSegment = entry["segment"] - var section_id: String = entry["section_id"] - var start: float = entry["start"] - var duration: float = entry["duration"] - var local_time := clampf(_playback_time - start, 0.0, duration) - var fraction := 0.0 if duration <= 0.0 else local_time / duration - - var curve := segment.curve - var length := segment.get_length_m() - var position := Vector2.ZERO - var tangent := Vector2.RIGHT - - if curve != null and length > 0.0: - var offset := clampf(fraction, 0.0, 1.0) * length - position = curve.sample_baked(offset) - var epsilon := maxf(0.01, length * 0.01) - var before := curve.sample_baked(maxf(0.0, offset - epsilon)) - var after := curve.sample_baked(minf(length, offset + epsilon)) - var direction_vector := after - before - if direction_vector.length_squared() > 0.0: - tangent = direction_vector.normalized() - elif curve != null and curve.point_count > 0: - position = curve.get_point_position(0) - - var facing := tangent - if segment.direction == PathSegment.Direction.BACKWARD: - facing = -facing - - var marker_scale := 1.0 - if segment.is_element_marker(): - # Markers have no tangent: keep facing the way the skater arrived. Spins - # and jumps rotate in place, so the heading follows the elapsed stand - # time. - facing = _entry_arrival_heading(entry_index) - var progress := 0.0 - if duration > 0.0: - progress = clampf(local_time / duration, 0.0, 1.0) - if segment.element_type == PathSegment.ElementType.SPIN: - var spin_rate := segment.get_spin_revolutions_per_second() - if spin_rate <= 0.0: - # Legacy files without a planned revolution count. - spin_rate = SPIN_REVOLUTIONS_PER_SECOND - facing = facing.rotated( - segment.get_rotation_sign() - * TAU - * spin_rate - * local_time - ) - _playback_heading = facing - elif segment.element_type == PathSegment.ElementType.JUMP: - # Jumps turn once per revolution in the air; the count is taken from - # the jump code (3Lz = 3, 2A = 2.5). The marker grows towards the - # middle of the air time and travels along the jump vector to the - # landing point. - var jump_vector := segment.element_jump_vector - if jump_vector.length_squared() <= 0.000001: - jump_vector = facing * segment.get_jump_distance_m() - var travel_heading := facing - if jump_vector.length_squared() > 0.000001: - travel_heading = jump_vector.normalized() - facing = travel_heading.rotated( - segment.get_rotation_sign() - * TAU - * segment.get_jump_revolutions() - * progress - ) - _playback_heading = facing - position += jump_vector * progress - marker_scale = 1.0 + 0.85 * sin(PI * progress) - elif force_heading or _playback_heading.length_squared() <= 0.0: - _playback_heading = facing - elif force_heading or delta <= 0.0 or _playback_heading.length_squared() <= 0.0: - _playback_heading = facing - else: - var turn := clampf(delta * 12.0, 0.0, 1.0) - _playback_heading = Vector2.from_angle( - lerp_angle(_playback_heading.angle(), facing.angle(), turn) - ) - - _playback_position = position - var section_changed := _playback_section_id != section_id - _playback_section_id = section_id - _playback_segment_id = segment.segment_id + _playback_position = pose.position + _playback_heading = pose.heading + var section_changed := _playback_section_id != pose.section_id + _playback_section_id = pose.section_id + _playback_segment_id = pose.segment_id if section_changed: - var section := _routine.get_section_by_id(section_id) + var section := _routine.get_section_by_id(pose.section_id) if section != null: rink_canvas.show_section_banner(I18n.section_title(section.title)) _update_section_buttons() rink_canvas.set_playback_state( - position, - _playback_heading, - section_id, - segment.edge, - segment.direction, - marker_scale + pose.position, + pose.heading, + pose.section_id, + pose.segment.edge, + pose.segment.direction, + pose.marker_scale ) if _view_3d_active and _presentation_3d != null: _presentation_3d.update_pose( - position, - _playback_heading, - segment, + pose.position, + pose.heading, + pose.segment, _playback_time ) - _update_playback_ui() + _sync_playback_ui() -## Heading with which the skater arrives at the timed entry [param entry_index]. -## Walks back to the last entry with a real path so a marker keeps facing the -## direction of travel. -func _entry_arrival_heading(entry_index: int) -> Vector2: - var index := entry_index - 1 - while index >= 0: - var previous: Dictionary = _playback_entries[index] - var previous_segment: PathSegment = previous["segment"] - if previous_segment != null: - var length := previous_segment.get_length_m() - if length > 0.0 and previous_segment.curve != null: - var epsilon := maxf(0.01, length * 0.01) - var before := previous_segment.curve.sample_baked( - maxf(0.0, length - epsilon) - ) - var end := previous_segment.curve.sample_baked(length) - var direction := end - before - if direction.length_squared() > 0.0: - direction = direction.normalized() - if previous_segment.direction == PathSegment.Direction.BACKWARD: - direction = -direction - return direction - index -= 1 - return Vector2.RIGHT - - -func _update_playback_ui() -> void: - _updating_timeline = true - playback_timeline.max_value = maxf(_playback_total_duration, 0.0) - playback_timeline.value = clampf( +func _sync_playback_ui() -> void: + playback_panel.set_state( _playback_time, - 0.0, - _playback_total_duration + _playback_total_duration, + _playing ) - _updating_timeline = false - timeline_label_lane.set_playhead(_playback_time) - playback_time_label.text = "%s / %s s" % [ - _format_seconds(_playback_time), - _format_seconds(_playback_total_duration), - ] - - var has_playback := _playback_total_duration > 0.0 - play_button.disabled = not has_playback - reset_playback_button.disabled = not has_playback - playback_timeline.editable = has_playback - - -func _update_play_button() -> void: - play_button.text = "" - play_button.icon = PLAYBACK_PAUSE_ICON if _playing else PLAYBACK_PLAY_ICON - play_button.tooltip_text = "Pause" if _playing else "Abspielen" - - -## --- Timeline-Labels ------------------------------------------------------ - func get_timeline_labels() -> Array[Dictionary]: var result: Array[Dictionary] = [] @@ -4916,50 +4147,10 @@ func _sort_timeline_labels() -> void: func _refresh_timeline_labels() -> void: if timeline_label_lane == null: return - - # Walk the authored routine like the playback timeline does. Using the - # segments directly (instead of only the timed playback entries) also - # keeps element markers with zero stand time visible. - var element_labels: Array[Dictionary] = [] - var total := 0.0 - if _routine != null: - for section: RoutineSection in _routine.sections: - if section == null: - continue - var group_starts: Dictionary[String, ResolvedElement] = {} - for element: ResolvedElement in section.get_elements(): - if not element.segments.is_empty(): - group_starts[element.segments[0].segment_id] = element - for segment: PathSegment in section.segments: - if segment == null: - continue - var text := segment.label.strip_edges() - if text.is_empty() and group_starts.has(segment.segment_id): - text = group_starts[segment.segment_id].get_caption().strip_edges() - if not text.is_empty(): - element_labels.append({ - "time_seconds": total, - "text": text, - }) - total += maxf( - segment.get_effective_duration_seconds(), - 0.0 - ) - - var custom_labels: Array[Dictionary] = [] - if _routine != null: - for entry: Dictionary in _routine.timeline_labels: - var text := str(entry.get("text", "")).strip_edges() - if text.is_empty(): - continue - custom_labels.append({ - "time_seconds": float(entry.get("time_seconds", 0.0)), - "text": text, - }) - + var labels := TimelineLabelModel.collect(_routine) timeline_label_lane.set_timeline( - element_labels, - custom_labels, + labels["elements"], + labels["custom"], _playback_total_duration ) @@ -6336,7 +5527,7 @@ func _on_save_as_confirmed() -> void: _show_message("Bitte einen Namen für die Kür eingeben.") return - var stem := _normalize_file_stem(name) + var stem := ExportService.normalize_stem(name) var path := ROUTINES_DIR.path_join(stem + ROUTINE_EXTENSION) var apply := func() -> void: _routine.title = name @@ -6360,18 +5551,6 @@ func _confirm_overwrite(path: String, action: Callable) -> void: confirm_dialog.popup_centered(Vector2i(480, 180)) -func _setup_export_controls() -> void: - export_format_option.clear() - export_format_option.add_item("SVG (Vektor)", 0) - export_format_option.add_item("PNG (hochauflösend)", 1) - export_format_option.add_item("PDF (Laufwege mit Zeit)", 2) - export_scope_option.clear() - export_scope_option.add_item("Gesamte Kür", 0) - export_scope_option.add_item("Aktiver Abschnitt", 1) - export_format_option.select(0) - export_scope_option.select(0) - - func _maximize_window_on_desktop() -> void: # Desktop builds start maximized. Mobile and web keep the window shape the # OS or browser provides, and headless test runs have no real window. @@ -6395,6 +5574,10 @@ func _apply_display_scale() -> void: var factor := maxf(1.0, DisplayServer.screen_get_scale()) if not is_equal_approx(window.content_scale_factor, factor): window.content_scale_factor = factor + # The viewport size changes with the scale factor, but only after the + # next frame. Without the deferred pass the compact layout would be + # decided from the pixel width and the bars would overflow on tablets. + _apply_responsive_layout.call_deferred() func _apply_responsive_layout() -> void: @@ -6510,25 +5693,13 @@ func _open_sync_settings_dialog() -> void: func _ensure_sync_provider_items() -> void: if sync_provider_option.item_count > 0: return - var app := SyncAppConfig.load_config() - var has_dropbox := SyncAppConfig.is_configured("dropbox", app) - var has_google := SyncAppConfig.is_configured("google_drive", app) - if not has_dropbox: - # Developer build without app credentials: show Dropbox so the - # missing configuration is visible instead of an empty dropdown. - has_dropbox = true - if has_dropbox: - sync_provider_option.add_item("Dropbox", 0) - sync_provider_option.set_item_metadata( - sync_provider_option.item_count - 1, - "dropbox" - ) - if has_google: - sync_provider_option.add_item("Google Drive", 1) - sync_provider_option.set_item_metadata( - sync_provider_option.item_count - 1, - "google_drive" - ) + var items := SyncSettingsModel.provider_items( + SyncAppConfig.load_config() + ) + for index: int in range(items.size()): + var item: Dictionary = items[index] + sync_provider_option.add_item(str(item["label"]), index) + sync_provider_option.set_item_metadata(index, str(item["value"])) func _apply_sync_provider_to_ui(provider: String) -> void: @@ -7200,7 +6371,7 @@ func _apply_hub_download(overwrite: bool) -> void: _discard_hub_download(pending) hub_status_label.text = "Vom Hub geladen: " + target_routine _refresh_open_list() - if routine_manager_dialog.visible: + if routine_manager_panel.is_open(): _refresh_routine_manager() _show_message( "Kür vom Hub geladen:\n\n%s\n\n" @@ -7580,59 +6751,12 @@ func _poll_sync_thread() -> void: _update_status() return - var summary := _format_sync_summary(job.result) + var summary := SyncSummaryText.format(job.result) _reload_after_sync(job.result) _update_status() _show_message("Sync abgeschlossen\n\n" + summary) -func _format_sync_summary(result: Dictionary) -> String: - var uploaded: Array = result.get("uploaded", []) - var downloaded: Array = result.get("downloaded", []) - var resolved: Array = result.get("resolved", []) - var skipped: Array = result.get("skipped", []) - var errors: Array = result.get("errors", []) - - var lines := PackedStringArray() - lines.append("Hochgeladen: %d" % uploaded.size()) - if not uploaded.is_empty(): - lines.append(" " + ", ".join(uploaded)) - lines.append("Heruntergeladen: %d" % downloaded.size()) - if not downloaded.is_empty(): - lines.append(" " + ", ".join(downloaded)) - lines.append(I18n.t("Automatisch aufgelöste Konflikte: %d") % resolved.size()) - for entry: Dictionary in resolved: - var winner := ( - "Cloud-Fassung" - if str(entry.get("winner", "")) == "cloud" - else "lokale Fassung" - ) - var moment := int(entry.get("timestamp", 0)) - var when := ( - SyncPlan.timestamp_label(moment) - if moment > 0 - else "Zeit unbekannt" - ) - lines.append(" %s – %s vom %s übernommen" % [ - str(entry.get("name", "")), - winner, - when, - ]) - if not resolved.is_empty(): - lines.append( - " Ältere Fassungen liegen im Konfliktarchiv " - + "(Datei → Konfliktarchiv öffnen)." - ) - if not skipped.is_empty(): - lines.append(I18n.t("Unverändert: %d") % skipped.size()) - if not errors.is_empty(): - lines.append("") - lines.append("Fehler:") - for message: String in errors: - lines.append(" " + message) - return "\n".join(lines) - - func _start_conflict_scan() -> void: if _sync_running: return @@ -7818,22 +6942,11 @@ func _exit_tree() -> void: func _open_export_dialog() -> void: - if _routine == null: - return - - export_name_edit.text = _routine.title - if export_name_edit.text.strip_edges().is_empty(): - export_name_edit.text = "kuer" - export_format_option.select(0) - export_scope_option.select(0) - var dialog_size := _fit_dialog_size(Vector2i(480, 520)) - export_dialog.popup_centered(dialog_size) - # AcceptDialog shrinks to its content minimum on popup; restore the target - # size so the scroll area has room. popup_centered already centered it for - # the requested size. - export_dialog.size = dialog_size - export_name_edit.grab_focus() - export_name_edit.select_all() + export_panel.open_for( + _routine, + _active_section, + _fit_dialog_size(Vector2i(480, 520)) + ) ## Keeps dialogs inside the visible viewport (important on Android portrait). @@ -7847,46 +6960,25 @@ func _fit_dialog_size(preferred: Vector2i) -> Vector2i: ) -func _on_export_confirmed() -> void: - var name := export_name_edit.text.strip_edges() - if name.is_empty(): - _show_message("Bitte einen Dateinamen eingeben.") - return - - var stem := _normalize_file_stem(name) - var scope_section_id := "" - var scope_suffix := "" - if export_scope_option.selected == 1: - if _active_section == null: - _show_message("Kein aktiver Abschnitt vorhanden.") - return - scope_section_id = _active_section.section_id - scope_suffix = "_" + _normalize_file_stem(_active_section.title) - - var format := export_format_option.get_item_id( - export_format_option.selected - ) - var extension := "svg" - if format == 1: - extension = "png" - elif format == 2: - extension = "pdf" - var path := EXPORTS_DIR.path_join(stem + scope_suffix + "." + extension) +func _on_export_requested( + path: String, + format: int, + section_id: String, + open_after: bool +) -> void: if FileAccess.file_exists(path): - _confirm_overwrite( - path, - _perform_export.bind(path, format, scope_section_id) - ) + _confirm_overwrite(path, _perform_export.bind(path, format, section_id, open_after)) return - await _perform_export(path, format, scope_section_id) + await _perform_export(path, format, section_id, open_after) func _perform_export( path: String, format: int, - scope_section_id: String + scope_section_id: String, + open_after: bool = false ) -> void: - _ensure_exports_dir() + ExportService.ensure_dir() var success := false match format: @@ -7900,23 +6992,17 @@ func _perform_export( if success: _last_export_path = ProjectSettings.globalize_path(path) _show_export_done() - if export_open_after_check.button_pressed: + if open_after: _open_path_externally(_last_export_path) else: _show_message("Export fehlgeschlagen.") func _show_export_done() -> void: - export_done_label.text = ( - "Exportiert nach:\n%s\n\n" - + "Du kannst die Datei direkt öffnen oder den Ordner anzeigen." - ) % _last_export_path - export_open_button.disabled = not FileAccess.file_exists(_last_export_path) - export_folder_button.disabled = _last_export_path.is_empty() - export_copy_path_button.text = "Pfad kopieren" - var dialog_size := _fit_dialog_size(Vector2i(660, 320)) - export_done_dialog.popup_centered(dialog_size) - export_done_dialog.size = dialog_size + export_panel.show_done( + _last_export_path, + _fit_dialog_size(Vector2i(660, 320)) + ) func _open_path_externally(path: String) -> Error: @@ -7954,37 +7040,15 @@ func _on_export_copy_path_pressed() -> void: if _last_export_path.is_empty(): return DisplayServer.clipboard_set(_last_export_path) - export_copy_path_button.text = "Kopiert" + export_panel.set_copy_label("Kopiert") func export_svg_to_path(path: String, section_id: String = "") -> bool: - if _routine == null: - return false - var svg := RoutineSvgExporter.build(_routine, section_id) - if svg.is_empty(): - return false - - var file := FileAccess.open(path, FileAccess.WRITE) - if file == null: - return false - file.store_string(svg) - file.close() - return true + return ExportService.write_svg(_routine, path, section_id) func export_pdf_to_path(path: String, section_id: String = "") -> bool: - if _routine == null: - return false - var pdf := RoutinePdfExporter.build(_routine, section_id) - if pdf.is_empty(): - return false - - var file := FileAccess.open(path, FileAccess.WRITE) - if file == null: - return false - file.store_buffer(pdf) - file.close() - return true + return ExportService.write_pdf(_routine, path, section_id) func export_png_to_path(path: String, section_id: String = "") -> bool: @@ -8014,13 +7078,10 @@ func export_png_to_path(path: String, section_id: String = "") -> bool: return image.save_png(path) == OK -func _ensure_exports_dir() -> void: - if not DirAccess.dir_exists_absolute(EXPORTS_DIR): - DirAccess.make_dir_recursive_absolute(EXPORTS_DIR) func _open_exports_folder() -> void: - _ensure_exports_dir() + ExportService.ensure_dir() var folder := ProjectSettings.globalize_path(EXPORTS_DIR) var error := OS.shell_show_in_file_manager(folder) if error != OK: @@ -8053,51 +7114,18 @@ func _open_open_dialog() -> void: func _open_routine_manager() -> void: - manager_tabs.set_tab_title(0, "Küren") - manager_tabs.set_tab_title(1, "Konfliktkopien") - _refresh_routine_manager() - routine_manager_dialog.popup_centered(Vector2i(800, 600)) + routine_manager_panel.open_for( + _routine_entries(), + Vector2i(800, 600) + ) func _refresh_routine_manager() -> void: - for child: Node in routine_manager_list.get_children(): - child.free() - var entries := _routine_entries() - for file: String in entries: - var row := HBoxContainer.new() - row.add_theme_constant_override("separation", 8) - var open_button := Button.new() - open_button.text = file.get_basename() - open_button.custom_minimum_size = Vector2(0.0, 48.0) - open_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL - open_button.alignment = HORIZONTAL_ALIGNMENT_LEFT - open_button.clip_text = true - open_button.pressed.connect( - _on_manager_open_pressed.bind(ROUTINES_DIR.path_join(file)) - ) - row.add_child(open_button) - var rename_button := Button.new() - rename_button.text = "Umbenennen" - rename_button.custom_minimum_size = Vector2(132.0, 48.0) - rename_button.pressed.connect( - _open_rename_routine_dialog.bind(file) - ) - row.add_child(rename_button) - var delete_button := Button.new() - delete_button.text = "Löschen" - delete_button.custom_minimum_size = Vector2(110.0, 48.0) - delete_button.pressed.connect(_open_delete_routine_dialog.bind(file)) - row.add_child(delete_button) - routine_manager_list.add_child(row) - - if entries.is_empty(): - var label := Label.new() - label.text = "Keine gespeicherten Kürläufe" - routine_manager_list.add_child(label) + routine_manager_panel.refresh(_routine_entries()) func _on_manager_open_pressed(path: String) -> void: - routine_manager_dialog.hide() + routine_manager_panel.close() _on_open_file_pressed(path) @@ -8167,18 +7195,7 @@ func _on_delete_routine_confirmed() -> void: ## A routine can exist as JSON and as a legacy `.tres` twin. Deleting the ## visible entry removes both so the old file does not reappear. func _routine_variants(file_name: String) -> PackedStringArray: - var stem := file_name.get_basename() - var result := PackedStringArray() - for extension: String in [ - RoutineFile.JSON_EXTENSION, - RoutineFile.LEGACY_EXTENSION, - ]: - var candidate := stem + extension - if FileAccess.file_exists(ROUTINES_DIR.path_join(candidate)): - result.append(candidate) - if result.is_empty(): - result.append(file_name) - return result + return RoutineManagerModel.variants(ROUTINES_DIR, file_name) func _open_rename_routine_dialog(file_name: String) -> void: @@ -8219,7 +7236,7 @@ func _on_rename_routine_confirmed() -> void: if new_title.is_empty(): _show_message("Bitte einen Namen für die Kür eingeben.") return - var new_stem := _normalize_file_stem(new_title) + var new_stem := ExportService.normalize_stem(new_title) var old_stem := old_file.get_basename() if new_stem != old_stem: for extension: String in [ @@ -8425,22 +7442,7 @@ func _refresh_open_list() -> void: ## Saved routine files, one per title (JSON wins over a legacy `.tres` twin). func _routine_entries() -> Array[String]: _ensure_routines_dir() - var by_stem: Dictionary[String, String] = {} - for file: String in DirAccess.get_files_at(ROUTINES_DIR): - if not RoutineFile.is_routine_path(file): - continue - var stem := file.get_basename() - var is_json := file.to_lower().ends_with(RoutineFile.JSON_EXTENSION) - if not by_stem.has(stem) or is_json: - by_stem[stem] = file - var entries: Array[String] = [] - for file: String in by_stem.values(): - entries.append(file) - entries.sort_custom( - func(a: String, b: String) -> bool: - return a.get_basename().naturalnocasecmp_to(b.get_basename()) < 0 - ) - return entries + return RoutineManagerModel.list_routines(ROUTINES_DIR) func _on_open_file_pressed(path: String) -> void: @@ -8472,14 +7474,6 @@ func _on_confirm_discard_canceled() -> void: _pending_action = Callable() -func _normalize_file_stem(name: String) -> String: - var stem := name.strip_edges().to_lower() - for character: String in ["/", "\\", ":", "*", "?", "\"", "<", ">", "|"]: - stem = stem.replace(character, "") - stem = stem.replace(" ", "_") - if stem.is_empty(): - stem = "kuer" - return stem func _show_message(text: String) -> void: diff --git a/rinkplanner/src/whiteboard/io/export_service.gd b/rinkplanner/src/whiteboard/io/export_service.gd new file mode 100644 index 0000000..5c7855f --- /dev/null +++ b/rinkplanner/src/whiteboard/io/export_service.gd @@ -0,0 +1,71 @@ +class_name ExportService +extends RefCounted + +## Writes exported documents and builds their paths. +## +## The dialogs ("Export", "Export abgeschlossen") stay in the controller; this +## service only knows the export folder, the file naming and how to serialise +## SVG and PDF. PNG needs a viewport and therefore stays in the controller. + +const EXPORTS_DIR := "user://exports" + + +static func ensure_dir() -> void: + if not DirAccess.dir_exists_absolute(EXPORTS_DIR): + DirAccess.make_dir_recursive_absolute(EXPORTS_DIR) + + +## Lower-case, space-free file stem. Falls back to "kuer" for empty titles. +static func normalize_stem(name: String) -> String: + var stem := name.strip_edges().to_lower() + for character: String in ["/", "\\", ":", "*", "?", "\"", "<", ">", "|"]: + stem = stem.replace(character, "") + stem = stem.replace(" ", "_") + if stem.is_empty(): + stem = "kuer" + return stem + + +## Full path inside the export folder, e.g. "user://exports/kuer_gold.pdf". +static func build_path(stem: String, suffix: String, extension: String) -> String: + return EXPORTS_DIR.path_join(stem + suffix + "." + extension) + + +static func write_bytes(path: String, bytes: PackedByteArray) -> bool: + if bytes.is_empty(): + return false + var file := FileAccess.open(path, FileAccess.WRITE) + if file == null: + return false + file.store_buffer(bytes) + file.close() + return true + + +static func write_svg( + routine: Routine, + path: String, + section_id: String = "" +) -> bool: + if routine == null: + return false + var svg := RoutineSvgExporter.build(routine, section_id) + if svg.is_empty(): + return false + var file := FileAccess.open(path, FileAccess.WRITE) + if file == null: + return false + file.store_string(svg) + file.close() + return true + + +static func write_pdf( + routine: Routine, + path: String, + section_id: String = "" +) -> bool: + if routine == null: + return false + var pdf := RoutinePdfExporter.build(routine, section_id) + return write_bytes(path, pdf) diff --git a/rinkplanner/src/whiteboard/io/export_service.gd.uid b/rinkplanner/src/whiteboard/io/export_service.gd.uid new file mode 100644 index 0000000..e865120 --- /dev/null +++ b/rinkplanner/src/whiteboard/io/export_service.gd.uid @@ -0,0 +1 @@ +uid://cl02cld4fbckd diff --git a/rinkplanner/src/whiteboard/io/routine_pdf_exporter.gd b/rinkplanner/src/whiteboard/io/routine_pdf_exporter.gd index 9f5468f..8091092 100644 --- a/rinkplanner/src/whiteboard/io/routine_pdf_exporter.gd +++ b/rinkplanner/src/whiteboard/io/routine_pdf_exporter.gd @@ -15,6 +15,11 @@ const MARGIN := 36.0 const CONTENT_TOP := 104.0 const FOOTER_RULE_Y := 566.0 +## Das Rink ist 2:1 und nimmt die volle Seitenbreite neben der Tabelle ein. +## Der Freiraum unter dem Diagramm ist Absicht: Auf dem ausgedruckten Blatt +## schreibt der Trainer mit der Hand mit. Nicht "optimieren", indem das Rink +## größer oder die Tabelle darunter gezogen wird — das wurde 2026-11-13 +## geprüft und verworfen. const OVERVIEW_DIAGRAM_WIDTH := 500.0 const OVERVIEW_DIAGRAM_HEIGHT := 268.0 const SECTION_DIAGRAM_WIDTH := 470.0 @@ -27,6 +32,10 @@ const ROW_HEIGHT := 18.0 const TABLE_HEADER_HEIGHT := 18.0 const SECTION_ROWS_PER_PAGE := 23 const OVERVIEW_ROWS_PER_PAGE := 24 +## Text-only pages of the season comparison: line height and the last usable +## baseline above the footer rule. +const REPORT_LINE := 13.0 +const REPORT_BOTTOM := 546.0 const ICE_COLOR := Color(0.933, 0.965, 0.984) const BOARDS_COLOR := Color(0.118, 0.161, 0.220) @@ -73,6 +82,236 @@ static func build(routine: Routine, section_id: String = "") -> PackedByteArray: return _assemble_pdf(pages) +## --- Season comparison ---------------------------------------------------- + + +## Builds a one- or two-page report for the season comparison: what changes +## between two seasons for this routine. The layout is text only, so it can be +## handed to a coach or a parent without further explanation. +static func build_season_comparison( + routine: Routine, + report: SeasonUpgradeCheck.Report +) -> PackedByteArray: + if routine == null or report == null: + return PackedByteArray() + + var title := "Saison-Vergleich" + var subtitle := "%s · %s → %s" % [ + _routine_title(routine), + report.source_season, + report.target_season, + ] + var blocks := _report_blocks(routine, report) + + var pages: Array[String] = [] + var lines := _begin_page(title, subtitle) + var y := CONTENT_TOP + for block: Dictionary in blocks: + var size := float(block.get("size", 10.0)) + var indent := float(block.get("indent", 0.0)) + var bold := bool(block.get("bold", false)) + var color: Color = block.get("color", TEXT_COLOR) + var wrapped := _report_lines( + str(block.get("text", "")), + size, + PAGE_WIDTH - 2.0 * MARGIN - indent + ) + for part: String in wrapped: + if y + REPORT_LINE > REPORT_BOTTOM: + pages.append("\n".join(lines)) + lines = _begin_page(title, subtitle) + y = CONTENT_TOP + _text(lines, part, MARGIN + indent, y, size, bold, color) + y += REPORT_LINE + y += float(block.get("gap", 0.0)) + + pages.append("\n".join(lines)) + for index: int in range(pages.size()): + pages[index] += "\n" + _build_footer(index + 1, pages.size(), title) + return _assemble_pdf(pages) + + +static func _report_blocks( + routine: Routine, + report: SeasonUpgradeCheck.Report +) -> Array[Dictionary]: + var blocks: Array[Dictionary] = [] + + if not report.has_changes(): + blocks.append(_report_block("Keine Unterschiede: Die Kür passt in beide Saisons.")) + blocks.append(_report_block("")) + + _add_report_group( + blocks, + routine, + "Elemente", + report.changes_of(SeasonUpgradeCheck.KIND_MISSING_CODE) + ) + _add_report_group( + blocks, + routine, + "Base Values", + report.changes_of(SeasonUpgradeCheck.KIND_VALUE_CHANGE) + ) + _add_report_group( + blocks, + routine, + "Elementtyp", + report.changes_of(SeasonUpgradeCheck.KIND_TYPE_CHANGE) + ) + _add_report_group( + blocks, + routine, + "Features", + report.changes_of(SeasonUpgradeCheck.KIND_UNKNOWN_FEATURE) + ) + _add_report_group( + blocks, + routine, + "Level", + report.changes_of(SeasonUpgradeCheck.KIND_LEVEL_CHANGE) + ) + _add_report_group( + blocks, + routine, + "Kategorie", + report.changes_of(SeasonUpgradeCheck.KIND_CATEGORY_CHANGE) + ) + var missing_category := report.changes_of( + SeasonUpgradeCheck.KIND_CATEGORY_MISSING + ) + if not missing_category.is_empty(): + blocks.append(_report_block("Kategorie", 12.0, true, TEXT_COLOR, 0.0, 6.0)) + for change: SeasonUpgradeCheck.Change in missing_category: + blocks.append( + _report_block( + I18n.t("• %s — in der Ziel-Saison nicht vorhanden") % change.label, + 10.0, + false, + TEXT_COLOR, + 8.0 + ) + ) + + blocks.append(_report_block("Summe", 12.0, true, TEXT_COLOR, 0.0, 6.0)) + if report.base_value_before > 0.0 or report.base_value_after > 0.0: + var sign := "+" if report.value_delta() >= 0.0 else "−" + blocks.append( + _report_block( + I18n.t("Basiswert %s → %s (%s%s)") + % [ + _number(report.base_value_before), + _number(report.base_value_after), + sign, + _number(absf(report.value_delta())), + ], + 10.0, + false, + TEXT_COLOR, + 8.0 + ) + ) + else: + blocks.append(_report_block("Keine Elemente mit Base Value.", 10.0, false, TEXT_COLOR, 8.0)) + + if not report.issues.is_empty(): + blocks.append( + _report_block( + I18n.t("Befunde bei Prüfung gegen %s") % report.target_season, + 12.0, + true, + TEXT_COLOR, + 0.0, + 8.0 + ) + ) + for issue: ValidationIssue in report.issues: + blocks.append( + _report_block( + "• %s: %s" % [I18n.t(issue.severity_label()), issue.message], + 9.5, + false, + MUTED_COLOR, + 4.0 + ) + ) + return blocks + + +static func _add_report_group( + blocks: Array[Dictionary], + routine: Routine, + title: String, + changes: Array +) -> void: + if changes.is_empty(): + return + blocks.append(_report_block(title, 12.0, true, TEXT_COLOR, 0.0, 6.0)) + for change: SeasonUpgradeCheck.Change in changes: + var text := _report_change_text(change) + var location := _report_location(routine, change.section_id) + if not location.is_empty(): + text += " (%s)" % location + blocks.append(_report_block("• " + text, 10.0, false, TEXT_COLOR, 8.0)) + + +static func _report_change_text(change: SeasonUpgradeCheck.Change) -> String: + match change.kind: + SeasonUpgradeCheck.KIND_MISSING_CODE: + return I18n.t("%s — nicht im Katalog") % change.label + SeasonUpgradeCheck.KIND_UNKNOWN_FEATURE: + return I18n.t("%s — Feature „%s“ in der Ziel-Saison unbekannt") % [ + change.label, + change.before, + ] + SeasonUpgradeCheck.KIND_CATEGORY_CHANGE: + return "%s: %s → %s" % [change.label, change.before, change.after] + if change.after.is_empty(): + return "%s: %s" % [change.label, change.before] + return "%s: %s → %s" % [change.label, change.before, change.after] + + +static func _report_location(routine: Routine, section_id: String) -> String: + if section_id.is_empty() or routine.sections.size() < 2: + return "" + var section := routine.get_section_by_id(section_id) + if section == null: + return "" + return I18n.section_title(section.title) + + +static func _report_block( + text: String, + size: float = 10.0, + bold: bool = false, + color: Color = TEXT_COLOR, + indent: float = 0.0, + gap: float = 0.0 +) -> Dictionary: + return { + "text": text, + "size": size, + "bold": bold, + "color": color, + "indent": indent, + "gap": gap, + } + + +## Breaks a sentence into lines that fit the page. Uses the same rough width +## estimate as the rest of this exporter. +static func _report_lines( + text: String, + size: float, + max_width: float +) -> PackedStringArray: + return _wrap_text(text, size, max_width, 200) + + +static func _number(value: float) -> String: + return String.num(value, 2).replace(".", ",") + + ## --- Page structure ------------------------------------------------------- @@ -340,14 +579,14 @@ static func _routine_subtitle(routine: Routine, section_count: int) -> String: parts.append(I18n.t("Artistic")) var category := routine.adult_category.strip_edges() if not category.is_empty(): - parts.append("Kategorie: %s" % category.capitalize()) + parts.append(I18n.t("Kategorie: %s") % category.capitalize()) var season := routine.season.strip_edges() if not season.is_empty(): parts.append(I18n.t("Saison %s") % season) - parts.append("%d Abschnitte" % section_count) + parts.append(I18n.t("%d Abschnitte") % section_count) parts.append(I18n.t("Gesamt %s") % _fmt_clock(routine.get_duration_seconds())) if routine.has_music(): - parts.append("Musik: %s" % routine.music_file) + parts.append(I18n.t("Musik: %s") % routine.music_file) return " · ".join(parts) @@ -462,7 +701,7 @@ static func _text( _n(color.b), _n(x), _n(_y(top)), - _pdf_literal(text), + _pdf_literal(caption), ] ) @@ -1320,7 +1559,7 @@ static func _draw_timeline_notes( if entries.size() > visible: _text( lines, - "+ %d weitere" % (entries.size() - visible), + I18n.t("+ %d weitere") % (entries.size() - visible), x, top + 16.0 + float(visible) * 13.0, 8.5, @@ -1422,7 +1661,7 @@ static func _draw_note( text: String ) -> void: _rect(lines, x, top, width, 36.0, ROW_COLOR, RULE_COLOR, 0.5) - var wrapped := _wrap_text(text, 8.0, width - 16.0, 2) + var wrapped := _wrap_text(I18n.t(text), 8.0, width - 16.0, 2) for index: int in range(wrapped.size()): _text( lines, diff --git a/rinkplanner/src/whiteboard/view/export_panel.gd b/rinkplanner/src/whiteboard/view/export_panel.gd new file mode 100644 index 0000000..15cf49b --- /dev/null +++ b/rinkplanner/src/whiteboard/view/export_panel.gd @@ -0,0 +1,120 @@ +class_name ExportPanel +extends Node + +## The export dialogs: file name, format and scope, plus the "done" dialog. +## +## The panel only collects choices and reports them — it never touches the +## file system. The controller decides about existing files, writes the +## document and opens it, so the overwrite confirmation stays in one place. + +signal export_requested( + path: String, + format: int, + section_id: String, + open_after: bool +) +signal open_requested +signal folder_requested +signal copy_requested +signal message_requested(text: String) + +const FORMAT_EXTENSIONS := ["svg", "png", "pdf"] + +@onready var dialog: ConfirmationDialog = %ExportDialog +@onready var name_edit: LineEdit = %ExportNameEdit +@onready var format_option: OptionButton = %ExportFormatOption +@onready var scope_option: OptionButton = %ExportScopeOption +@onready var open_after_check: CheckBox = %ExportOpenAfterCheck +@onready var done_dialog: AcceptDialog = %ExportDoneDialog +@onready var done_label: RichTextLabel = %ExportDoneLabel +@onready var open_button: Button = %ExportOpenButton +@onready var folder_button: Button = %ExportFolderButton +@onready var copy_button: Button = %ExportCopyPathButton + +var _active_section: RoutineSection + + +func _ready() -> void: + format_option.clear() + format_option.add_item("SVG (Vektor)", 0) + format_option.add_item("PNG (hochauflösend)", 1) + format_option.add_item("PDF (Laufwege mit Zeit)", 2) + scope_option.clear() + scope_option.add_item("Gesamte Kür", 0) + scope_option.add_item("Aktiver Abschnitt", 1) + format_option.select(0) + scope_option.select(0) + + dialog.confirmed.connect(_on_confirmed) + open_button.pressed.connect(func() -> void: open_requested.emit()) + folder_button.pressed.connect(func() -> void: folder_requested.emit()) + copy_button.pressed.connect(func() -> void: copy_requested.emit()) + + +## Fills and shows the export dialog. [param size] is the pre-fitted dialog +## size the controller computed for the current viewport. +func open_for( + routine: Routine, + active_section: RoutineSection, + size: Vector2i +) -> void: + if routine == null: + return + _active_section = active_section + name_edit.text = routine.title + if name_edit.text.strip_edges().is_empty(): + name_edit.text = "kuer" + format_option.select(0) + scope_option.select(0) + dialog.popup_centered(size) + # AcceptDialog shrinks to its content minimum on popup; restore the target + # size so the scroll area has room. + dialog.size = size + name_edit.grab_focus() + name_edit.select_all() + + +func _on_confirmed() -> void: + var name := name_edit.text.strip_edges() + if name.is_empty(): + message_requested.emit("Bitte einen Dateinamen eingeben.") + return + + var suffix := "" + var section_id := "" + if scope_option.selected == 1: + if _active_section == null: + message_requested.emit("Kein aktiver Abschnitt vorhanden.") + return + section_id = _active_section.section_id + suffix = "_" + ExportService.normalize_stem(_active_section.title) + + var format := format_option.get_item_id(format_option.selected) + var extension: String = FORMAT_EXTENSIONS[clampi(format, 0, 2)] + export_requested.emit( + ExportService.build_path( + ExportService.normalize_stem(name), + suffix, + extension + ), + format, + section_id, + open_after_check.button_pressed + ) + + +## Shows the "export done" dialog for [param path]. +func show_done(path: String, size: Vector2i) -> void: + done_label.text = ( + "Exportiert nach:\n%s\n\n" + + "Du kannst die Datei direkt öffnen oder den Ordner anzeigen." + ) % path + open_button.disabled = path.is_empty() or not FileAccess.file_exists(path) + folder_button.disabled = path.is_empty() + copy_button.text = "Pfad kopieren" + done_dialog.popup_centered(size) + done_dialog.size = size + + +func set_copy_label(text: String) -> void: + copy_button.text = text diff --git a/rinkplanner/src/whiteboard/view/export_panel.gd.uid b/rinkplanner/src/whiteboard/view/export_panel.gd.uid new file mode 100644 index 0000000..8f0e8c3 --- /dev/null +++ b/rinkplanner/src/whiteboard/view/export_panel.gd.uid @@ -0,0 +1 @@ +uid://hld4jpokdv6s diff --git a/rinkplanner/src/whiteboard/view/help_content.gd b/rinkplanner/src/whiteboard/view/help_content.gd new file mode 100644 index 0000000..56718fb --- /dev/null +++ b/rinkplanner/src/whiteboard/view/help_content.gd @@ -0,0 +1,145 @@ +class_name HelpContent +extends RefCounted + +## Text of the in-app help dialog ("Hilfe & Annahmen"). +## +## Kept out of the controller so the scene wiring stays readable. The strings +## are German keys of the i18n catalog; `I18n.join_lines()` translates them. + +static func build() -> String: + var lines := PackedStringArray() + lines.append("[b][font_size=22]Hilfe & Annahmen[/font_size][/b]") + lines.append( + "Diese Hilfe erklärt die Annahmen und Prüfungen der App. Sie ist " + + "keine offizielle ISU-Auslegung." + ) + lines.append("") + lines.append("[b][font_size=18]1. Kürzel und Base Value[/font_size][/b]") + lines.append( + "- Das Kürzel bezeichnet die Elementfamilie, z. B. 3Lz, CCoSp oder StSq." + ) + lines.append( + "- Der Level ist die Schwierigkeitsstufe. Bei Pirouetten und " + + "Schrittsequenzen folgt er aus den Features." + ) + lines.append( + "- Der Base Value wird aus Kürzel und Level im Saisonkatalog 2026/27 " + + "nachgeschlagen (ISU Communication 2786)." + ) + lines.append( + "- Sprünge haben keinen Level; ihr Base Value hängt von Rotation und " + + "Sprungtyp ab." + ) + lines.append( + "- Sprungkombinationen werden strukturiert gewählt: erster Sprung plus " + + "bis zu zwei weitere, als Kombination oder Folge. Die Base Values " + + "werden summiert." + ) + lines.append( + "- Eine Folge braucht einen Axel (1A/2A/3A) als 2. oder 3. Sprung." + ) + lines.append( + "- Alte Freitext-Kombinationen werden beim Laden oder Übernehmen " + + "automatisch in die strukturierte Form überführt." + ) + lines.append( + "- ChSq (Choreo-Sequenz) und ChSp (Choreographic Spin) sind fest " + + "Level 1." + ) + lines.append( + "- Unbekannte Freitext-Codes haben keinen Katalogwert und werden in " + + "der Schätzung nicht gewertet." + ) + lines.append("") + lines.append("[b][font_size=18]2. Level aus Features[/font_size][/b]") + lines.append( + "- Pirouetten haben 15 Features, Schrittsequenzen 5 " + + "(ISU Communication 2788)." + ) + lines.append( + "- 0 Features = Base, 1 = Level 1, 2 = Level 2, 3 = Level 3, " + + "4 oder mehr = Level 4." + ) + lines.append( + "- Level 4 bei Pirouetten verlangt zusätzlich eines von: schwieriger " + + "Ausgang, Kantenänderung, beide Richtungen, Temposteigerung, " + + "schwieriger Flug-Eingang oder Windmills." + ) + lines.append( + "- Bei Schrittsequenzen ist Feature 1 (Vielfalt) Pflicht." + ) + lines.append( + "- Features beschreiben die Ausführung. Die App kann sie nicht aus " + + "der gezeichneten Linie ableiten; sie werden im Element-Dialog " + + "ausgewählt." + ) + lines.append("") + lines.append("[b][font_size=18]3. Adult-Kategorie[/font_size][/b]") + lines.append( + "- Die Kategorie wird in der Statusleiste gewählt und mit der Kür " + + "gespeichert." + ) + lines.append( + "- Gold: max. 5 Sprünge, keine 2F/2Lz/2A/Triple, 3 Pirouetten inkl. " + + "ChSp, 1 Schrittsequenz, 2:50 ±10 s, Spins bis Level 3, Sequenz bis " + + "Level 2." + ) + lines.append( + "- Silver: max. 4 Einfachsprünge inkl. 1A, 2 Pirouetten, 1 ChSq, " + + "2:00 ±10 s, Level bis 2." + ) + lines.append( + "- Bronze: max. 4 Einfachsprünge ohne Axel, 1 Sprungkombination, " + + "2 Pirouetten, 1 ChSq, 1:40 ±10 s, Level bis 1." + ) + lines.append( + "- PCS-Faktor und Sturzabzug stehen in den Kategorie-Daten " + + "(Gold 2,67 und 1,0; Silver/Bronze 2,00 und 0,5)." + ) + lines.append("") + lines.append("[b][font_size=18]4. Punktschätzung[/font_size][/b]") + lines.append( + "- Basiswert: Summe der Base Values aller Elemente mit gültigem " + + "Katalogwert." + ) + lines.append( + "- PCS-Annahme: Durchschnitt pro Komponente × 3 Komponenten × " + + "Kategorie-Faktor." + ) + lines.append( + "- Der PCS-Durchschnitt ist eine Planungsannahme, kein Judge-Wert. " + + "Startwert 5,00; er kann über „Annahmen ändern“ angepasst werden." + ) + lines.append( + "- Sturzabzug: Anzahl Stürze × Kategorie-Abzug." + ) + lines.append( + "- Nicht enthalten: GOE, 1,1-Faktor, nicht katalogisierte " + + "Kombinationen und die offizielle Wettkampfwertung." + ) + lines.append( + "- Beispiel Gold: 5,00 × 3 × 2,67 = 40,05 PCS; Basiswert 9,50; " + + "geschätzte Summe 49,55." + ) + lines.append("") + lines.append("[b][font_size=18]5. Prüfung[/font_size][/b]") + lines.append( + "- Der Button „Prüfen“ zeigt Kürzel-, Level-, Feature- und " + + "Kategorie-Prüfungen sowie die Punktschätzung." + ) + lines.append( + "- Warnungen blockieren Speichern und Export nicht. Sie sind " + + "Planungshinweise." + ) + lines.append( + "- Wiederholungen: max. 2-mal pro gelistetem Sprung; " + + "Kombinationsbestandteile zählen mit." + ) + lines.append("") + lines.append("[b]Tipp:[/b] Für eine realistische PCS-Annahme helfen " + + "Protokolle früherer Wettkämpfe. Der Durchschnitt sollte zu deinem " + + "aktuellen Leistungsstand passen, nicht zum Wunschziel.") + lines.append("") + lines.append("[b]Quellen:[/b] ISU Communication 2786 (SoV 2026/27), " + + "2788 (Levels/GOE 2026/27), IAFSC Technical Announcement 2026/27.") + return I18n.join_lines(lines) diff --git a/rinkplanner/src/whiteboard/view/help_content.gd.uid b/rinkplanner/src/whiteboard/view/help_content.gd.uid new file mode 100644 index 0000000..0f4329e --- /dev/null +++ b/rinkplanner/src/whiteboard/view/help_content.gd.uid @@ -0,0 +1 @@ +uid://bpmg0ef1gpgbu diff --git a/rinkplanner/src/whiteboard/view/playback_panel.gd b/rinkplanner/src/whiteboard/view/playback_panel.gd new file mode 100644 index 0000000..aa601ab --- /dev/null +++ b/rinkplanner/src/whiteboard/view/playback_panel.gd @@ -0,0 +1,99 @@ +class_name PlaybackPanel +extends Node + +## Transport controls of the playback bar: play/pause, reset, the timeline +## slider, the time label and the speed choice. +## +## The panel only shows state and reports intents. The controller owns the +## routine clock, the speed value and the audio, and calls [method set_state] +## whenever time or duration change. + +signal toggle_requested +signal reset_requested +signal seek_requested(seconds: float) +signal speed_requested(speed: float) + +const PLAY_ICON := preload("res://assets/icons/playback/play.svg") +const PAUSE_ICON := preload("res://assets/icons/playback/pause.svg") +const SPEEDS := [25, 50, 100, 150, 200] + +@onready var play_button: Button = %PlayButton +@onready var reset_button: Button = %ResetPlaybackButton +@onready var time_label: Label = %PlaybackTimeLabel +@onready var timeline: HSlider = %PlaybackTimeline +@onready var speed_option: OptionButton = %SpeedOption + +var _updating_timeline := false + + +func setup() -> void: + speed_option.clear() + for percent: int in SPEEDS: + speed_option.add_item(_speed_label(percent), percent) + speed_option.select(speed_option.get_item_index(100)) + + timeline.min_value = 0.0 + timeline.max_value = 0.0 + timeline.step = 0.01 + timeline.editable = false + play_button.disabled = true + reset_button.disabled = true + + play_button.pressed.connect(func() -> void: toggle_requested.emit()) + reset_button.pressed.connect(func() -> void: reset_requested.emit()) + timeline.value_changed.connect(_on_timeline_changed) + speed_option.item_selected.connect(_on_speed_selected) + + +## Updates slider, time label and button states for [param time] seconds of a +## [param duration] seconds long routine. +func set_state(time: float, duration: float, playing: bool) -> void: + _updating_timeline = true + timeline.max_value = maxf(duration, 0.0) + timeline.value = clampf(time, 0.0, maxf(duration, 0.0)) + _updating_timeline = false + + time_label.text = "%s / %s s" % [_seconds(time), _seconds(duration)] + + var has_playback := duration > 0.0 + play_button.disabled = not has_playback + reset_button.disabled = not has_playback + timeline.editable = has_playback + + play_button.text = "" + play_button.icon = PAUSE_ICON if playing else PLAY_ICON + play_button.tooltip_text = "Pause" if playing else "Abspielen" + + +func set_speed(speed: float) -> void: + var percent := int(roundf(speed * 100.0)) + var index := speed_option.get_item_index(percent) + if index >= 0: + speed_option.select(index) + + +func _on_timeline_changed(value: float) -> void: + if _updating_timeline: + return + seek_requested.emit(value) + + +func _on_speed_selected(index: int) -> void: + speed_requested.emit(float(speed_option.get_item_id(index)) / 100.0) + + +static func _speed_label(percent: int) -> String: + match percent: + 25: + return "0,25×" + 50: + return "0,5×" + 150: + return "1,5×" + 200: + return "2×" + return "1×" if percent == 100 else "%d×" % (percent / 100) + + +static func _seconds(value: float) -> String: + return ("%.1f" % value).replace(".", ",") diff --git a/rinkplanner/src/whiteboard/view/playback_panel.gd.uid b/rinkplanner/src/whiteboard/view/playback_panel.gd.uid new file mode 100644 index 0000000..788ee8c --- /dev/null +++ b/rinkplanner/src/whiteboard/view/playback_panel.gd.uid @@ -0,0 +1 @@ +uid://s8khec6xpwjv diff --git a/rinkplanner/src/whiteboard/view/playback_pose.gd b/rinkplanner/src/whiteboard/view/playback_pose.gd new file mode 100644 index 0000000..bf68ed6 --- /dev/null +++ b/rinkplanner/src/whiteboard/view/playback_pose.gd @@ -0,0 +1,160 @@ +class_name PlaybackPose +extends RefCounted + +## Where the skater is and which way it faces at a given playback time. +## +## Pure: the timed entries and the previous heading go in, position, heading +## and marker scale come out. The controller applies the result to the canvas, +## the 3D preview and the UI, so the timing and geometry logic can be reasoned +## about without a scene. + +## Fallback rotation rate for legacy files without a planned revolution count. +const SPIN_REVOLUTIONS_PER_SECOND := 2.5 + + +class Result extends RefCounted: + var found: bool = false + var segment: PathSegment + var position: Vector2 = Vector2.ZERO + var heading: Vector2 = Vector2.RIGHT + var marker_scale: float = 1.0 + var section_id: String = "" + var segment_id: String = "" + + +static func compute( + entries: Array, + time: float, + previous_heading: Vector2, + delta: float, + force_heading: bool = false +) -> Result: + var result := Result.new() + if entries.is_empty(): + return result + + var entry: Dictionary = entries[entries.size() - 1] + var entry_index := entries.size() - 1 + for index: int in range(entries.size()): + var candidate: Dictionary = entries[index] + var candidate_start: float = candidate["start"] + var candidate_duration: float = candidate["duration"] + if time < candidate_start + candidate_duration - 0.0001: + entry = candidate + entry_index = index + break + + var segment: PathSegment = entry["segment"] + if segment == null: + return result + + var start: float = entry["start"] + var duration: float = entry["duration"] + var local_time := clampf(time - start, 0.0, duration) + var fraction := 0.0 if duration <= 0.0 else local_time / duration + + var curve := segment.curve + var length := segment.get_length_m() + var position := Vector2.ZERO + var tangent := Vector2.RIGHT + + if curve != null and length > 0.0: + var offset := clampf(fraction, 0.0, 1.0) * length + position = curve.sample_baked(offset) + var epsilon := maxf(0.01, length * 0.01) + var before := curve.sample_baked(maxf(0.0, offset - epsilon)) + var after := curve.sample_baked(minf(length, offset + epsilon)) + var direction_vector := after - before + if direction_vector.length_squared() > 0.0: + tangent = direction_vector.normalized() + elif curve != null and curve.point_count > 0: + position = curve.get_point_position(0) + + var facing := tangent + if segment.direction == PathSegment.Direction.BACKWARD: + facing = -facing + + var heading := previous_heading + var marker_scale := 1.0 + if segment.is_element_marker(): + # Markers have no tangent: keep facing the way the skater arrived. Spins + # and jumps rotate in place, so the heading follows the elapsed stand + # time. + facing = _arrival_heading(entries, entry_index) + var progress := 0.0 + if duration > 0.0: + progress = clampf(local_time / duration, 0.0, 1.0) + if segment.element_type == PathSegment.ElementType.SPIN: + var spin_rate := segment.get_spin_revolutions_per_second() + if spin_rate <= 0.0: + # Legacy files without a planned revolution count. + spin_rate = SPIN_REVOLUTIONS_PER_SECOND + heading = facing.rotated( + segment.get_rotation_sign() + * TAU + * spin_rate + * local_time + ) + elif segment.element_type == PathSegment.ElementType.JUMP: + # Jumps turn once per revolution in the air; the count is taken from + # the jump code (3Lz = 3, 2A = 2.5). The marker grows towards the + # middle of the air time and travels along the jump vector to the + # landing point. + var jump_vector := segment.element_jump_vector + if jump_vector.length_squared() <= 0.000001: + jump_vector = facing * segment.get_jump_distance_m() + var travel_heading := facing + if jump_vector.length_squared() > 0.000001: + travel_heading = jump_vector.normalized() + heading = travel_heading.rotated( + segment.get_rotation_sign() + * TAU + * segment.get_jump_revolutions() + * progress + ) + position += jump_vector * progress + marker_scale = 1.0 + 0.85 * sin(PI * progress) + elif force_heading or heading.length_squared() <= 0.0: + heading = facing + elif force_heading or delta <= 0.0 or heading.length_squared() <= 0.0: + heading = facing + else: + var turn := clampf(delta * 12.0, 0.0, 1.0) + heading = Vector2.from_angle( + lerp_angle(heading.angle(), facing.angle(), turn) + ) + + result.found = true + result.segment = segment + result.position = position + result.heading = heading + result.marker_scale = marker_scale + result.section_id = str(entry["section_id"]) + result.segment_id = segment.segment_id + return result + + +## Heading with which the skater arrives at the timed entry [param entry_index]. +## Walks back to the last entry with a real path so a marker keeps facing the +## direction of travel. +static func _arrival_heading(entries: Array, entry_index: int) -> Vector2: + var index := entry_index - 1 + while index >= 0: + var previous: Dictionary = entries[index] + var previous_segment: PathSegment = previous["segment"] + if previous_segment != null: + var length := previous_segment.get_length_m() + if length > 0.0 and previous_segment.curve != null: + var epsilon := maxf(0.01, length * 0.01) + var before := previous_segment.curve.sample_baked( + maxf(0.0, length - epsilon) + ) + var end := previous_segment.curve.sample_baked(length) + var direction := end - before + if direction.length_squared() > 0.0: + direction = direction.normalized() + if previous_segment.direction == PathSegment.Direction.BACKWARD: + direction = -direction + return direction + index -= 1 + return Vector2.RIGHT diff --git a/rinkplanner/src/whiteboard/view/playback_pose.gd.uid b/rinkplanner/src/whiteboard/view/playback_pose.gd.uid new file mode 100644 index 0000000..324d3ab --- /dev/null +++ b/rinkplanner/src/whiteboard/view/playback_pose.gd.uid @@ -0,0 +1 @@ +uid://chf1qjwr1ajff diff --git a/rinkplanner/src/whiteboard/view/routine_manager_model.gd b/rinkplanner/src/whiteboard/view/routine_manager_model.gd new file mode 100644 index 0000000..844b5ab --- /dev/null +++ b/rinkplanner/src/whiteboard/view/routine_manager_model.gd @@ -0,0 +1,45 @@ +class_name RoutineManagerModel +extends RefCounted + +## What the routine manager lists and deletes. +## +## Pure over a directory: no scene, no sync. A routine may exist as JSON and as +## the legacy `.tres`; the manager shows it once and works on all its variants. + + +## Routine files of [param dir], one entry per routine, sorted by name. +## JSON wins over the legacy format for the same stem. +static func list_routines(dir: String) -> Array[String]: + var by_stem: Dictionary[String, String] = {} + for file: String in DirAccess.get_files_at(dir): + if not RoutineFile.is_routine_path(file): + continue + var stem := file.get_basename() + var is_json := file.to_lower().ends_with(RoutineFile.JSON_EXTENSION) + if not by_stem.has(stem) or is_json: + by_stem[stem] = file + var entries: Array[String] = [] + for file: String in by_stem.values(): + entries.append(file) + entries.sort_custom( + func(a: String, b: String) -> bool: + return a.get_basename().naturalnocasecmp_to(b.get_basename()) < 0 + ) + return entries + + +## All existing file names of one routine: JSON and/or the legacy `.tres`. +## Falls back to [param file_name] when no variant is on disk. +static func variants(dir: String, file_name: String) -> PackedStringArray: + var stem := file_name.get_basename() + var result := PackedStringArray() + for extension: String in [ + RoutineFile.JSON_EXTENSION, + RoutineFile.LEGACY_EXTENSION, + ]: + var candidate := stem + extension + if FileAccess.file_exists(dir.path_join(candidate)): + result.append(candidate) + if result.is_empty(): + result.append(file_name) + return result diff --git a/rinkplanner/src/whiteboard/view/routine_manager_model.gd.uid b/rinkplanner/src/whiteboard/view/routine_manager_model.gd.uid new file mode 100644 index 0000000..7ff4b13 --- /dev/null +++ b/rinkplanner/src/whiteboard/view/routine_manager_model.gd.uid @@ -0,0 +1 @@ +uid://5q62oxkubssd diff --git a/rinkplanner/src/whiteboard/view/routine_manager_panel.gd b/rinkplanner/src/whiteboard/view/routine_manager_panel.gd new file mode 100644 index 0000000..970b487 --- /dev/null +++ b/rinkplanner/src/whiteboard/view/routine_manager_panel.gd @@ -0,0 +1,82 @@ +class_name RoutineManagerPanel +extends Node + +## The "Küren verwalten" dialog: one row per routine plus the conflict tools. +## +## The panel renders rows and reports what the user picked. Opening, renaming, +## deleting and the conflict scan stay with the controller, because they touch +## files, the current routine and the sync state. + +signal open_requested(file_name: String) +signal rename_requested(file_name: String) +signal delete_requested(file_name: String) +signal scan_conflicts_requested +signal open_archive_requested + +@onready var dialog: AcceptDialog = %RoutineManagerDialog +@onready var list: VBoxContainer = %RoutineManagerList +@onready var scan_button: Button = %ManagerScanConflictsButton +@onready var archive_button: Button = %ManagerOpenArchiveButton + + +func _ready() -> void: + scan_button.pressed.connect(func() -> void: scan_conflicts_requested.emit()) + archive_button.pressed.connect(func() -> void: open_archive_requested.emit()) + + +## Shows the dialog for [param entries] (file names, one per routine). +func open_for(entries: Array[String], size: Vector2i) -> void: + refresh(entries) + dialog.popup_centered(size) + dialog.size = size + + +## Rebuilds the row list. Safe to call while the dialog is open. +func refresh(entries: Array[String]) -> void: + for child: Node in list.get_children(): + list.remove_child(child) + child.free() + + for file: String in entries: + list.add_child(_build_row(file)) + + if entries.is_empty(): + var label := Label.new() + label.text = "Keine gespeicherten Kürläufe" + list.add_child(label) + + +func is_open() -> bool: + return dialog.visible + + +func close() -> void: + dialog.hide() + + +func _build_row(file: String) -> HBoxContainer: + var row := HBoxContainer.new() + row.add_theme_constant_override("separation", 8) + + var open_button := Button.new() + open_button.text = file.get_basename() + open_button.custom_minimum_size = Vector2(0.0, 48.0) + open_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL + open_button.alignment = HORIZONTAL_ALIGNMENT_LEFT + open_button.clip_text = true + open_button.pressed.connect(func() -> void: open_requested.emit(file)) + row.add_child(open_button) + + var rename_button := Button.new() + rename_button.text = "Umbenennen" + rename_button.custom_minimum_size = Vector2(132.0, 48.0) + rename_button.pressed.connect(func() -> void: rename_requested.emit(file)) + row.add_child(rename_button) + + var delete_button := Button.new() + delete_button.text = "Löschen" + delete_button.custom_minimum_size = Vector2(110.0, 48.0) + delete_button.pressed.connect(func() -> void: delete_requested.emit(file)) + row.add_child(delete_button) + + return row diff --git a/rinkplanner/src/whiteboard/view/routine_manager_panel.gd.uid b/rinkplanner/src/whiteboard/view/routine_manager_panel.gd.uid new file mode 100644 index 0000000..2dd11d5 --- /dev/null +++ b/rinkplanner/src/whiteboard/view/routine_manager_panel.gd.uid @@ -0,0 +1 @@ +uid://bu40o821wuiet diff --git a/rinkplanner/src/whiteboard/view/season_comparison_text.gd b/rinkplanner/src/whiteboard/view/season_comparison_text.gd new file mode 100644 index 0000000..5441be0 --- /dev/null +++ b/rinkplanner/src/whiteboard/view/season_comparison_text.gd @@ -0,0 +1,174 @@ +class_name SeasonComparisonText +extends RefCounted + +## Text of the season comparison dialog. +## +## Pure formatting: the routine and the comparison report go in, the BBCode +## lines for the RichTextLabel come out. Kept out of the controller so the +## dialog wiring stays readable and the text is testable on its own. + +static func build(routine: Routine, report: SeasonUpgradeCheck.Report) -> PackedStringArray: + var lines := PackedStringArray() + var title := routine.title.strip_edges() + if title.is_empty(): + title = I18n.t("Unbenannte Kür") + lines.append( + "[b]%s — %s → %s[/b]" + % [ + _escape(title), + report.source_season, + report.target_season, + ] + ) + + if not report.has_changes(): + lines.append("") + lines.append( + I18n.t("Keine Unterschiede: Die Kür passt in beide Saisons.") + ) + + _append_group( + routine, + lines, + I18n.t("Elemente"), + report.changes_of(SeasonUpgradeCheck.KIND_MISSING_CODE), + I18n.t("nicht im Katalog") + ) + _append_group( + routine, + lines, + I18n.t("Base Values"), + report.changes_of(SeasonUpgradeCheck.KIND_VALUE_CHANGE) + ) + _append_group( + routine, + lines, + I18n.t("Elementtyp"), + report.changes_of(SeasonUpgradeCheck.KIND_TYPE_CHANGE) + ) + _append_group( + routine, + lines, + I18n.t("Features"), + report.changes_of(SeasonUpgradeCheck.KIND_UNKNOWN_FEATURE), + I18n.t("in der Ziel-Saison unbekannt") + ) + _append_group( + routine, + lines, + I18n.t("Level"), + report.changes_of(SeasonUpgradeCheck.KIND_LEVEL_CHANGE) + ) + _append_group( + routine, + lines, + I18n.t("Kategorie"), + report.changes_of(SeasonUpgradeCheck.KIND_CATEGORY_CHANGE) + ) + var missing_category := report.changes_of( + SeasonUpgradeCheck.KIND_CATEGORY_MISSING + ) + if not missing_category.is_empty(): + lines.append("") + lines.append("[b]%s[/b]" % I18n.t("Kategorie")) + lines.append( + "● %s: %s" + % [ + _escape(missing_category[0].label), + I18n.t("in der Ziel-Saison nicht vorhanden"), + ] + ) + + lines.append("") + lines.append("[b]%s[/b]" % I18n.t("Summe")) + if report.base_value_before > 0.0 or report.base_value_after > 0.0: + lines.append( + I18n.t("Basiswert %s → %s (%s%s)") + % [ + _base_value(report.base_value_before), + _base_value(report.base_value_after), + "+" if report.value_delta() >= 0.0 else "−", + _base_value(absf(report.value_delta())), + ] + ) + else: + lines.append(I18n.t("Keine Elemente mit Base Value.")) + + if not report.issues.is_empty(): + lines.append("") + lines.append( + "[b]%s[/b]" % I18n.t("Befunde bei Prüfung gegen %s") % report.target_season + ) + for issue: ValidationIssue in report.issues: + var color := ( + "#ef4444" + if issue.severity == ValidationIssue.Severity.ERROR + else "#f59e0b" + ) + lines.append( + "[color=%s]●[/color] %s%s" + % [ + color, + _escape(issue.message), + _location(routine, issue.section_id), + ] + ) + return lines + + +static func _append_group( + routine: Routine, + lines: PackedStringArray, + title: String, + changes: Array, + suffix: String = "" +) -> void: + if changes.is_empty(): + return + lines.append("") + lines.append("[b]%s[/b]" % title) + for change: SeasonUpgradeCheck.Change in changes: + var text := _escape(change.label) + if change.kind == SeasonUpgradeCheck.KIND_MISSING_CODE: + text += ": " + I18n.t("nicht im Katalog") + elif change.kind == SeasonUpgradeCheck.KIND_UNKNOWN_FEATURE: + text += ": %s — %s" % [ + I18n.t("Feature"), + _escape(change.before), + ] + if not suffix.is_empty(): + text += " " + suffix + elif change.kind == SeasonUpgradeCheck.KIND_CATEGORY_CHANGE: + text = "%s: %s → %s" % [ + _escape(change.label), + _escape(change.before), + _escape(change.after), + ] + elif change.after.is_empty(): + text += ": " + _escape(change.before) + else: + text += ": %s → %s" % [ + _escape(change.before), + _escape(change.after), + ] + text += _location(routine, change.section_id) + lines.append("● %s" % text) + + +static func _location(routine: Routine, section_id: String) -> String: + if section_id.is_empty() or routine == null: + return "" + if routine.sections.size() < 2: + return "" + var section := routine.get_section_by_id(section_id) + if section == null: + return "" + return " (%s)" % I18n.section_title(section.title) + + +static func _escape(text: String) -> String: + return text.replace("[", "[lb]") + + +static func _base_value(value: float) -> String: + return ("%.2f" % value).replace(".", ",") diff --git a/rinkplanner/src/whiteboard/view/season_comparison_text.gd.uid b/rinkplanner/src/whiteboard/view/season_comparison_text.gd.uid new file mode 100644 index 0000000..e304526 --- /dev/null +++ b/rinkplanner/src/whiteboard/view/season_comparison_text.gd.uid @@ -0,0 +1 @@ +uid://boq3jg287aydi diff --git a/rinkplanner/src/whiteboard/view/season_panel_model.gd b/rinkplanner/src/whiteboard/view/season_panel_model.gd new file mode 100644 index 0000000..c2e08d0 --- /dev/null +++ b/rinkplanner/src/whiteboard/view/season_panel_model.gd @@ -0,0 +1,93 @@ +class_name SeasonPanelModel +extends RefCounted + +## Content of the three status bar dropdowns: season, programme type and adult +## category. +## +## Pure functions: they build labels and metadata, but never touch a node. The +## controller fills its OptionButtons from the result and keeps the signal +## wiring. Returns `{"items": [{"label": String, "value": String}], "selected": int}`. + +const NO_CATEGORY := "Ohne Kategorie" + + +static func season_items(current: String, library: RulesLibrary) -> Dictionary: + var items: Array[Dictionary] = [] + var selected := -1 + var cleaned := current.strip_edges() + + if cleaned.is_empty(): + items.append({"label": I18n.t("Saison nicht festgelegt"), "value": ""}) + selected = 0 + + if library != null: + for season: String in library.get_seasons(): + var label := I18n.t("Saison %s") % season + var status := str( + library.get_manifest(season).get("status", "complete") + ).strip_edges() + if status != "complete": + label += " " + I18n.t("(unvollständig)") + items.append({"label": label, "value": season}) + if season == cleaned: + selected = items.size() - 1 + + if not cleaned.is_empty() and selected < 0: + items.append( + { + "label": I18n.t("Saison %s (unbekannt)") % cleaned, + "value": cleaned, + } + ) + selected = items.size() - 1 + + return {"items": items, "selected": selected} + + +static func program_items(current: String) -> Dictionary: + var items: Array[Dictionary] = [ + {"label": I18n.t("Kür"), "value": AdultCategoryRules.PROGRAM_FREE}, + {"label": I18n.t("Artistic"), "value": AdultCategoryRules.PROGRAM_ARTISTIC}, + ] + var selected := 0 + for index: int in range(items.size()): + if str(items[index]["value"]) == current: + selected = index + return {"items": items, "selected": selected} + + +## Categories of one programme type plus "no category". A stored code that the +## season does not know stays visible as "nicht verfügbar" instead of silently +## selecting "no category". +static func category_items( + current: String, + categories: Array +) -> Dictionary: + var items: Array[Dictionary] = [{"label": NO_CATEGORY, "value": ""}] + var cleaned := current.strip_edges() + for category: AdultCategoryRules.Category in categories: + items.append({"label": category.name, "value": category.code}) + + for index: int in range(items.size()): + if str(items[index]["value"]) == cleaned: + return {"items": items, "selected": index} + + if not cleaned.is_empty(): + items.append( + { + "label": I18n.t("Kategorie „%s“ nicht verfügbar") % cleaned.capitalize(), + "value": cleaned, + } + ) + return {"items": items, "selected": items.size() - 1} + + return {"items": items, "selected": 0} + + +static func season_tooltip(current: String, inferred: String) -> String: + if not current.strip_edges().is_empty(): + return I18n.t("Regelwerk, gegen das diese Kür geprüft wird") + var base := I18n.t("Ohne Saison kann die Kür nicht geprüft werden") + if inferred.is_empty(): + return base + return base + " " + I18n.t("Vermutlich Saison %s (Dateidatum).") % inferred diff --git a/rinkplanner/src/whiteboard/view/season_panel_model.gd.uid b/rinkplanner/src/whiteboard/view/season_panel_model.gd.uid new file mode 100644 index 0000000..d601a60 --- /dev/null +++ b/rinkplanner/src/whiteboard/view/season_panel_model.gd.uid @@ -0,0 +1 @@ +uid://cpd3460lrabou diff --git a/rinkplanner/src/whiteboard/view/sync_settings_model.gd b/rinkplanner/src/whiteboard/view/sync_settings_model.gd new file mode 100644 index 0000000..0a77cba --- /dev/null +++ b/rinkplanner/src/whiteboard/view/sync_settings_model.gd @@ -0,0 +1,33 @@ +class_name SyncSettingsModel +extends RefCounted + +## Content of the sync provider dropdown. +## +## Pure: the app configuration goes in, the list of selectable providers comes +## out. Google Drive only appears when the build carries OAuth credentials; +## Dropbox always appears, even without credentials, so a developer build shows +## the missing configuration instead of an empty dropdown. + +const PROVIDERS := [ + {"id": "dropbox", "label": "Dropbox", "always": true}, + {"id": "google_drive", "label": "Google Drive", "always": false}, +] + + +## Returns `[{"label": String, "value": String}]`. +static func provider_items(app: Dictionary) -> Array[Dictionary]: + var items: Array[Dictionary] = [] + for provider: Dictionary in PROVIDERS: + var id := str(provider["id"]) + if not bool(provider["always"]) and not SyncAppConfig.is_configured(id, app): + continue + items.append({"label": str(provider["label"]), "value": id}) + return items + + +## Index of [param provider] in a list built by [method provider_items], or -1. +static func index_of(items: Array, provider: String) -> int: + for index: int in range(items.size()): + if str((items[index] as Dictionary).get("value", "")) == provider: + return index + return -1 diff --git a/rinkplanner/src/whiteboard/view/sync_settings_model.gd.uid b/rinkplanner/src/whiteboard/view/sync_settings_model.gd.uid new file mode 100644 index 0000000..2a5261d --- /dev/null +++ b/rinkplanner/src/whiteboard/view/sync_settings_model.gd.uid @@ -0,0 +1 @@ +uid://dycuog2mepmfp diff --git a/rinkplanner/src/whiteboard/view/sync_summary_text.gd b/rinkplanner/src/whiteboard/view/sync_summary_text.gd new file mode 100644 index 0000000..38c27c2 --- /dev/null +++ b/rinkplanner/src/whiteboard/view/sync_summary_text.gd @@ -0,0 +1,58 @@ +class_name SyncSummaryText +extends RefCounted + +## Text of the sync result dialog ("Synchronisierung"). +## +## Pure: the result dictionary of a sync job goes in, the lines come out. The +## controller only sets the label, which keeps this formatting testable without +## a scene. + +static func format(result: Dictionary) -> String: + var uploaded: Array = result.get("uploaded", []) + var downloaded: Array = result.get("downloaded", []) + var resolved: Array = result.get("resolved", []) + var skipped: Array = result.get("skipped", []) + var errors: Array = result.get("errors", []) + + var lines := PackedStringArray() + lines.append("Hochgeladen: %d" % uploaded.size()) + if not uploaded.is_empty(): + lines.append(" " + ", ".join(uploaded)) + lines.append("Heruntergeladen: %d" % downloaded.size()) + if not downloaded.is_empty(): + lines.append(" " + ", ".join(downloaded)) + lines.append(I18n.t("Automatisch aufgelöste Konflikte: %d") % resolved.size()) + for entry: Dictionary in resolved: + lines.append(" " + _resolved_line(entry)) + if not resolved.is_empty(): + lines.append( + " Ältere Fassungen liegen im Konfliktarchiv " + + "(Datei → Konfliktarchiv öffnen)." + ) + if not skipped.is_empty(): + lines.append(I18n.t("Unverändert: %d") % skipped.size()) + if not errors.is_empty(): + lines.append("") + lines.append("Fehler:") + for message: String in errors: + lines.append(" " + message) + return "\n".join(lines) + + +static func _resolved_line(entry: Dictionary) -> String: + var winner := ( + "Cloud-Fassung" + if str(entry.get("winner", "")) == "cloud" + else "lokale Fassung" + ) + var moment := int(entry.get("timestamp", 0)) + var when := ( + SyncPlan.timestamp_label(moment) + if moment > 0 + else "Zeit unbekannt" + ) + return "%s – %s vom %s übernommen" % [ + str(entry.get("name", "")), + winner, + when, + ] diff --git a/rinkplanner/src/whiteboard/view/sync_summary_text.gd.uid b/rinkplanner/src/whiteboard/view/sync_summary_text.gd.uid new file mode 100644 index 0000000..4d49127 --- /dev/null +++ b/rinkplanner/src/whiteboard/view/sync_summary_text.gd.uid @@ -0,0 +1 @@ +uid://b8j6xkdhtcai diff --git a/rinkplanner/src/whiteboard/view/timeline_label_model.gd b/rinkplanner/src/whiteboard/view/timeline_label_model.gd new file mode 100644 index 0000000..efd8d31 --- /dev/null +++ b/rinkplanner/src/whiteboard/view/timeline_label_model.gd @@ -0,0 +1,53 @@ +class_name TimelineLabelModel +extends RefCounted + +## Collects the labels shown on the playback timeline. +## +## Pure: the routine goes in, the two label lists and the total duration come +## out. Walks the authored sections (not the timed playback entries), so +## element markers with zero stand time stay visible. A segment without its own +## label falls back to the caption of its element group, so a sequence group is +## named once. + +## Returns `{"elements": Array, "custom": Array, "duration": float}`. Each +## entry is `{"time_seconds": float, "text": String}`. +static func collect(routine: Routine) -> Dictionary: + var element_labels: Array[Dictionary] = [] + var total := 0.0 + if routine != null: + for section: RoutineSection in routine.sections: + if section == null: + continue + var group_starts: Dictionary[String, ResolvedElement] = {} + for element: ResolvedElement in section.get_elements(): + if not element.segments.is_empty(): + group_starts[element.segments[0].segment_id] = element + for segment: PathSegment in section.segments: + if segment == null: + continue + var text := segment.label.strip_edges() + if text.is_empty() and group_starts.has(segment.segment_id): + text = group_starts[segment.segment_id].get_caption().strip_edges() + if not text.is_empty(): + element_labels.append({ + "time_seconds": total, + "text": text, + }) + total += maxf(segment.get_effective_duration_seconds(), 0.0) + + var custom_labels: Array[Dictionary] = [] + if routine != null: + for entry: Dictionary in routine.timeline_labels: + var text := str(entry.get("text", "")).strip_edges() + if text.is_empty(): + continue + custom_labels.append({ + "time_seconds": float(entry.get("time_seconds", 0.0)), + "text": text, + }) + + return { + "elements": element_labels, + "custom": custom_labels, + "duration": total, + } diff --git a/rinkplanner/src/whiteboard/view/timeline_label_model.gd.uid b/rinkplanner/src/whiteboard/view/timeline_label_model.gd.uid new file mode 100644 index 0000000..6d36ec8 --- /dev/null +++ b/rinkplanner/src/whiteboard/view/timeline_label_model.gd.uid @@ -0,0 +1 @@ +uid://bi7a47b46qnej diff --git a/rinkplanner/src/whiteboard/view/validation_report_view.gd b/rinkplanner/src/whiteboard/view/validation_report_view.gd new file mode 100644 index 0000000..cd557d9 --- /dev/null +++ b/rinkplanner/src/whiteboard/view/validation_report_view.gd @@ -0,0 +1,313 @@ +class_name ValidationReportView +extends RefCounted + +## Text of the validation dialog ("Kür prüfen"). +## +## Pure formatting: routine, report and the resolved category go in, the +## BBCode lines for the RichTextLabel come out. The controller owns the dialog +## and the view options (what is expanded); the text itself lives here so it +## can be reasoned about and tested without a scene. + +static func build( + routine: Routine, + report: ValidationReport, + category: AdultCategoryRules.Category, + context: Dictionary +) -> PackedStringArray: + var show_info := bool(context.get("show_info", false)) + var show_assumptions := bool(context.get("show_assumptions", false)) + var errors := RoutineValidator.count_severity( + report.issues, + ValidationIssue.Severity.ERROR + ) + var warnings := RoutineValidator.count_severity( + report.issues, + ValidationIssue.Severity.WARNING + ) + + var lines := PackedStringArray() + lines.append( + "[b]Geprüft: %s in %s (Saison %s)[/b]" + % [ + _element_count_label(report.element_count), + _section_count_label(report.section_count), + str(context.get("season", "")), + ] + ) + var season_note := str(context.get("season_note", "")) + if not season_note.is_empty(): + lines.append("[color=#e0b050]%s[/color]" % season_note) + if bool(context.get("can_compare", false)): + lines.append( + "[url=upgrade][color=#60a5fa]%s[/color][/url]" + % I18n.t("ⓘ Gegen andere Saison prüfen …") + ) + + var category_name := "Ohne Kategorie" + if category != null: + category_name = "%s · %s · %s ±%d s" % [ + category.name, + _program_label(category.program_type), + _clock(category.duration_seconds), + category.duration_tolerance_seconds, + ] + lines.append("[b]Kategorie: %s[/b]" % category_name) + lines.append("") + lines.append( + "[b]Basiswert: %s[/b]" % _base_value(report.base_value_total) + ) + var scored_text := ( + "%d von %d Elementen gewertet" + % [report.scored_elements, report.element_count] + ) + if report.unscored_elements > 0: + scored_text += " · %d ohne Base Value" % report.unscored_elements + lines.append(scored_text) + var info_label := ( + "ⓘ Details ausblenden" if show_info else "ⓘ Was ist enthalten?" + ) + lines.append( + "[color=#94a3b8]Nur Base Values · [/color][url=score_info][color=#60a5fa]%s[/color][/url]" + % info_label + ) + if show_info: + lines.append("") + lines.append_array(_score_info_lines()) + + if category != null and category.scored: + var pcs_total := ( + routine.assumed_pcs_average * 3.0 * category.pcs_factor + ) + var deduction := float(routine.assumed_falls) * category.fall_deduction + var estimated := report.base_value_total + pcs_total - deduction + lines.append("") + lines.append("[b]Punktschätzung[/b]") + lines.append( + "PCS-Annahme: %s × 3 × %s = %s" + % [ + _base_value(routine.assumed_pcs_average), + _base_value(category.pcs_factor), + _base_value(pcs_total), + ] + ) + lines.append( + "Sturzabzug: %d × %s = -%s" + % [ + routine.assumed_falls, + _base_value(category.fall_deduction), + _base_value(deduction), + ] + ) + lines.append( + I18n.t("[b]Geschätzte Summe: %s[/b]") % _base_value(estimated) + ) + var assumptions_label := ( + "ⓘ Annahmen ausblenden" + if show_assumptions + else "ⓘ Annahmen ändern" + ) + lines.append( + "[url=score_assumptions][color=#60a5fa]%s[/color][/url]" + % assumptions_label + ) + elif category != null: + lines.append("") + lines.append("[b]Punktschätzung[/b]") + lines.append( + "[color=#94a3b8]%s[/color]" + % I18n.t( + "Artistic wird nur über die Programmkomponenten bewertet; keine Punktschätzung." + ) + ) + else: + lines.append( + "[color=#94a3b8]PCS und Abzüge: Kategorie wählen.[/color]" + ) + + if not report.element_values.is_empty(): + lines.append("") + lines.append("[b]Wertung[/b]") + for entry: Dictionary in report.element_values: + var value: float = entry["value"] + var value_text := ( + "—" if value < 0.0 else _base_value(value) + ) + lines.append( + "%s — %s" + % [_escape(str(entry["label"])), value_text] + ) + + lines.append("") + lines.append("[b]Prüfungen[/b]") + for check: ValidationCheck in report.checks: + lines.append(_check_line(check)) + lines.append("") + lines.append("[b]Befunde[/b]") + + if report.issues.is_empty(): + if report.element_count == 0: + lines.append("Keine Elemente vorhanden.") + else: + lines.append("Keine Befunde.") + else: + lines.append( + "[b]%d Fehler, %d Warnungen[/b]" % [errors, warnings] + ) + for issue: ValidationIssue in report.issues: + var color := ( + "#ef4444" + if issue.severity == ValidationIssue.Severity.ERROR + else "#f59e0b" + ) + lines.append( + "[color=%s]●[/color] [b]%s[/b]%s: %s" + % [ + color, + issue.severity_label(), + _location(routine, issue), + _escape(issue.message), + ] + ) + return lines + + +static func _score_info_lines() -> PackedStringArray: + var lines := PackedStringArray() + lines.append("[b]Enthalten[/b]") + lines.append("- Base Value jedes Elements aus Katalog und gewähltem Level") + lines.append("- ChSq und ChSp mit festem Level 1") + lines.append("- strukturierte Sprungkombinationen als Summe ihrer Sprünge") + lines.append("- nur Elemente mit gültigem Katalogwert") + lines.append("") + lines.append("[b]Nicht im Basiswert enthalten[/b]") + lines.append("- GOE / Ausführungsqualität") + lines.append("- 1,1-Faktor für Sprünge in der zweiten Programmhälfte") + lines.append("- Programmkomponenten (PCS)") + lines.append("- Abzüge (Stürze, Zeitüberschreitungen usw.)") + lines.append("- nicht katalogisierte Kombinationen und Freitext-Codes") + lines.append("- Programmtyp und Adult-spezifische Sonderregeln") + lines.append("") + lines.append( + "[b]Punktschätzung[/b]\nPCS und Sturzabzug werden separat in der " + + "Punktschätzung angesetzt." + ) + lines.append("") + lines.append( + "[b]Ergebnis[/b]\nDer Basiswert ist ein technischer Wert, keine " + + "vorhergesagte Gesamtpunktzahl." + ) + return lines + + +static func _check_line(check: ValidationCheck) -> String: + var color := "#22c55e" + var icon := "✓" + var detail := check.summary() + if check.is_skipped(): + color = "#64748b" + icon = "–" + detail = I18n.t("nicht anwendbar (%s)") % _skip_reason(check.code) + elif check.findings > 0: + color = "#ef4444" if check.errors > 0 else "#f59e0b" + icon = "✗" + + var findings := PackedStringArray() + if check.errors > 0: + findings.append("%d Fehler" % check.errors) + if check.warnings > 0: + findings.append( + "%d Warnung%s" + % [check.warnings, "" if check.warnings == 1 else "en"] + ) + if not findings.is_empty(): + detail += " · " + " · ".join(findings) + + return "[color=%s]%s[/color] %s — %s" % [ + color, + icon, + _escape(check.label), + detail, + ] + + +static func _skip_reason(check_code: String) -> String: + if check_code.begins_with("category"): + return "keine Kategorie oder keine passenden Elemente" + match check_code: + "code": + return "keine Elemente" + "type": + return "kein Kürzel im Katalog" + "level": + return "kein passendes Kürzel" + "fixed_level": + return "kein ChSq" + "features", "required", "level_features": + return "keine Features gesetzt" + "once": + return "keine Einmal-Features gesetzt" + "jump_sequence": + return "keine Sprungfolge" + return "keine passenden Daten" + + +static func _location(routine: Routine, issue: ValidationIssue) -> String: + var parts := PackedStringArray() + if not issue.section_id.is_empty(): + var section := ( + routine.get_section_by_id(issue.section_id) if routine != null else null + ) + parts.append( + "Abschnitt „%s“" + % (I18n.section_title(section.title) if section != null else issue.section_id) + ) + if not issue.segment_id.is_empty(): + var segment := _find_segment(routine, issue.segment_id) + if segment != null and segment.is_element(): + var label := segment.element_code.strip_edges() + if label.is_empty(): + label = PathSegment.element_type_name(segment.element_type) + parts.append("Element „%s“" % label) + else: + parts.append(issue.segment_id) + if parts.is_empty(): + return "" + return " (%s)" % " · ".join(parts) + + +static func _find_segment(routine: Routine, segment_id: String) -> PathSegment: + if routine == null or segment_id.is_empty(): + return null + for section: RoutineSection in routine.sections: + if section == null: + continue + var segment := section.get_segment_by_id(segment_id) + if segment != null: + return segment + return null + + +static func _element_count_label(count: int) -> String: + return "1 Element" if count == 1 else "%d Elemente" % count + + +static func _section_count_label(count: int) -> String: + return "1 Abschnitt" if count == 1 else "%d Abschnitten" % count + + +static func _program_label(program_type: String) -> String: + if program_type == AdultCategoryRules.PROGRAM_ARTISTIC: + return I18n.t("Artistic") + return I18n.t("Kür") + + +static func _clock(seconds: int) -> String: + return "%d:%02d" % [seconds / 60, seconds % 60] + + +static func _base_value(value: float) -> String: + return ("%.2f" % value).replace(".", ",") + + +static func _escape(text: String) -> String: + return text.replace("[", "[lb]") diff --git a/rinkplanner/src/whiteboard/view/validation_report_view.gd.uid b/rinkplanner/src/whiteboard/view/validation_report_view.gd.uid new file mode 100644 index 0000000..51961de --- /dev/null +++ b/rinkplanner/src/whiteboard/view/validation_report_view.gd.uid @@ -0,0 +1 @@ +uid://4shkok0ey0x3 diff --git a/rinkplanner/tests/manual/render_print_sample.gd b/rinkplanner/tests/manual/render_print_sample.gd new file mode 100644 index 0000000..a0c4e72 --- /dev/null +++ b/rinkplanner/tests/manual/render_print_sample.gd @@ -0,0 +1,95 @@ +extends SceneTree + +## Erzeugt eine Beispieldatei zum Prüfen des Ausdrucks. Nicht Teil der Tests. + +const PathSegmentModel := preload("res://src/core/model/path_segment.gd") + + +func _init() -> void: + _run.call_deferred() + + +func _run() -> void: + var routine := Routine.new() + routine.routine_id = "print-sample" + routine.title = "Kür Testdruck" + routine.skater_name = "Erika Mustermann" + routine.adult_category = "gold" + routine.season = "2026/27" + routine.rink = RinkDimensions.new() + + _add_section(routine, "Start", 0, [ + {"from": Vector2(-18.0, -6.0), "to": Vector2(-6.0, 2.0), "kind": "jump", "code": "1A", "label": "Auftakt"}, + {"from": Vector2(-6.0, 2.0), "to": Vector2(6.0, 6.0), "kind": "spin", "code": "CCoSp", "label": "Pirouette"}, + {"from": Vector2(6.0, 6.0), "to": Vector2(14.0, 0.0), "kind": "plain", "code": "", "label": ""}, + ], 26.0) + _add_section(routine, "Abschnitt 2", 1, [ + {"from": Vector2(14.0, 0.0), "to": Vector2(0.0, -8.0), "kind": "jump", "code": "3Lz", "label": "Kombination"}, + {"from": Vector2(0.0, -8.0), "to": Vector2(-12.0, -4.0), "kind": "plain", "code": "", "label": "Übergang"}, + ], 24.0) + _add_section(routine, "Step Seq Absch.", 2, [ + {"from": Vector2(-12.0, -4.0), "to": Vector2(-2.0, 4.0), "kind": "sequence", "code": "StSq", "label": ""}, + {"from": Vector2(-2.0, 4.0), "to": Vector2(10.0, 2.0), "kind": "plain", "code": "", "label": ""}, + ], 22.0) + _add_section(routine, "Abschnitt 4", 3, [ + {"from": Vector2(10.0, 2.0), "to": Vector2(2.0, 8.0), "kind": "jump", "code": "2T", "label": "Finale"}, + {"from": Vector2(2.0, 8.0), "to": Vector2(-14.0, 2.0), "kind": "plain", "code": "", "label": ""}, + ], 22.7) + + routine.timeline_labels = [ + {"time_seconds": 5.0, "text": "Musikstart"}, + {"time_seconds": 60.0, "text": "Höhepunkt"}, + ] + + var pdf := RoutinePdfExporter.build(routine) + if pdf.is_empty(): + printerr("PDF leer") + quit(1) + return + var path := "user://print-sample.pdf" + var file := FileAccess.open(path, FileAccess.WRITE) + file.store_buffer(pdf) + file.close() + print("PDF: ", ProjectSettings.globalize_path(path)) + quit(0) + + +func _add_section( + routine: Routine, + title: String, + order: int, + entries: Array, + seconds: float +) -> void: + var section := RoutineSection.new() + section.section_id = "section-%03d" % (order + 1) + section.title = title + section.sequence_order = order + var share := seconds / maxf(float(entries.size()), 1.0) + for entry: Dictionary in entries: + var segment := PathSegment.new() + segment.segment_id = "seg-%s-%d" % [section.section_id, section.segments.size()] + var curve := Curve2D.new() + curve.add_point(entry["from"]) + curve.add_point((entry["from"] + entry["to"]) * 0.5 + Vector2(0.0, -3.0)) + curve.add_point(entry["to"]) + segment.curve = curve + segment.direction = PathSegment.Direction.FORWARD + segment.edge = PathSegment.Edge.OUTSIDE + segment.label = entry["label"] + if not str(entry["code"]).is_empty(): + match str(entry["kind"]): + "jump": + segment.set_element(PathSegment.ElementType.JUMP, entry["code"], 0) + "spin": + segment.set_element(PathSegment.ElementType.SPIN, entry["code"], 3) + segment.set_element_features( + PackedStringArray(["difficult_variation_sit", "difficult_exit"]) + ) + "sequence": + segment.set_element(PathSegment.ElementType.SEQUENCE, entry["code"], 2) + segment.apply_geometry_length(segment.get_length_m()) + segment.duration_seconds = share + segment.timing_mode = PathSegment.TimingMode.DURATION + section.segments.append(segment) + routine.sections.append(section) diff --git a/rinkplanner/tests/run_export_panel_tests.gd b/rinkplanner/tests/run_export_panel_tests.gd new file mode 100644 index 0000000..e332361 --- /dev/null +++ b/rinkplanner/tests/run_export_panel_tests.gd @@ -0,0 +1,131 @@ +extends SceneTree + +## Headless test for `ExportPanel` on its own. +## +## No WhiteboardController, no routine scene: the panel is instantiated from +## `scenes/export/export_panel.tscn` and reports its choices through signals. +## This is the measure of whether the module is really separate. +## +## Run with: +## godot --headless --path rinkplanner --script res://tests/run_export_panel_tests.gd + +const PanelScene := preload("res://scenes/export/export_panel.tscn") + +var _assertions: int = 0 +var _failures: PackedStringArray = PackedStringArray() + + +func _init() -> void: + _run.call_deferred() + + +func _run() -> void: + var panel := PanelScene.instantiate() as ExportPanel + _check(panel != null, "the panel scene carries its script") + if panel == null: + _finish() + return + # Without a window size, popup_centered places dialogs at negative offsets + # in headless runs; give the root window a sane size. + root.size = Vector2i(1280, 800) + root.add_child(panel) + await process_frame + + _check( + panel.dialog != null and panel.done_dialog != null, + "both dialogs are wired" + ) + _check( + panel.format_option.item_count == 3, + "three export formats are offered" + ) + + var routine := Routine.new() + routine.routine_id = "panel-test" + routine.title = "Kür am See" + routine.rink = RinkDimensions.new() + var section := RoutineSection.new() + section.section_id = "s1" + section.title = "Abschnitt 1" + + # Lambdas capture by value: mutate the dictionary instead of rebinding it. + var captured: Dictionary = {} + panel.export_requested.connect( + func( + path: String, + format: int, + section_id: String, + open_after: bool + ) -> void: + captured["path"] = path + captured["format"] = format + captured["section_id"] = section_id + captured["open_after"] = open_after + ) + + panel.open_for(routine, section, Vector2i(480, 520)) + _check(panel.dialog.visible, "the dialog opens") + _check(panel.name_edit.text == "Kür am See", "the routine title fills the name") + + panel.dialog.confirmed.emit() + _check( + str(captured.get("path", "")).ends_with("kür_am_see.svg"), + "the default format is SVG with a clean file stem (%s)" + % captured.get("path", "") + ) + _check(int(captured.get("format", -1)) == 0, "the format id is passed") + _check( + str(captured.get("section_id", "x")).is_empty(), + "the whole routine is the default scope" + ) + + panel.scope_option.select(1) + panel.format_option.select(2) + captured.clear() + panel.dialog.confirmed.emit() + _check(int(captured.get("format", -1)) == 2, "the PDF format is passed") + _check( + str(captured.get("path", "")).ends_with("_abschnitt_1.pdf"), + "the section suffix is added (%s)" % captured.get("path", "") + ) + _check( + str(captured.get("section_id", "")) == "s1", + "the section id is passed" + ) + + var messages: Array = [] + panel.message_requested.connect( + func(text: String) -> void: + messages.append(text) + ) + panel.name_edit.text = " " + captured.clear() + panel.dialog.confirmed.emit() + _check(captured.is_empty(), "an empty name does not export") + _check(not messages.is_empty(), "an empty name asks for input") + + # The done dialog only enables "open" for an existing file. + panel.show_done("/tmp/does-not-exist.pdf", Vector2i(660, 320)) + _check(panel.open_button.disabled, "missing files cannot be opened") + _check(panel.done_dialog.visible, "the done dialog opens") + + panel.queue_free() + await process_frame + _finish() + + +func _check(condition: bool, message: String) -> void: + _assertions += 1 + if not condition: + _failures.append(message) + + +func _finish() -> void: + if _failures.is_empty(): + print("PASS: %d assertions" % _assertions) + quit(0) + return + for failure: String in _failures: + printerr("FAIL: %s" % failure) + printerr("%d of %d assertions failed" % [_failures.size(), _assertions]) + quit(1) diff --git a/rinkplanner/tests/run_export_panel_tests.gd.uid b/rinkplanner/tests/run_export_panel_tests.gd.uid new file mode 100644 index 0000000..14dcb04 --- /dev/null +++ b/rinkplanner/tests/run_export_panel_tests.gd.uid @@ -0,0 +1 @@ +uid://b6r15yds80ibm diff --git a/rinkplanner/tests/run_export_tests.gd b/rinkplanner/tests/run_export_tests.gd index 4360e91..cd83203 100644 --- a/rinkplanner/tests/run_export_tests.gd +++ b/rinkplanner/tests/run_export_tests.gd @@ -106,6 +106,23 @@ func _run() -> void: "the second section excludes the spin of section one" ) + # ExportService: Pfadbildung, Namensbereinigung und Schreiben. + _check( + ExportService.build_path("kuer", "_gold", "pdf").ends_with("kuer_gold.pdf"), + "the export path carries stem, suffix and extension" + ) + _check( + ExportService.normalize_stem("Kür 2026/27: Gold?").begins_with("kür_2026"), + "the file stem drops forbidden characters" + ) + var service_path := ExportService.build_path("service_test", "", "pdf") + _check(ExportService.write_pdf(routine, service_path), "the service writes a PDF") + _check( + FileAccess.file_exists(service_path), + "the written PDF exists" + ) + DirAccess.remove_absolute(service_path) + var pdf := RoutinePdfExporter.build(routine) var pdf_text := pdf.get_string_from_ascii() _check(pdf.size() > 1000, "PDF export produces data") @@ -134,6 +151,83 @@ func _run() -> void: pdf_text.contains("Test & "), "PDF export encodes umlauts as WinAnsi escapes" ) + + # Saison-Vergleich als PDF: eigener Bericht, gleiche PDF-Bausteine. + var library := RulesLibrary.scan() + var current := library.get_package("2026/27") + var older := library.get_package("2025/26") + if current != null and older != null: + var comparison_routine := Routine.new() + comparison_routine.routine_id = "upgrade-pdf" + comparison_routine.title = "Vergleich" + comparison_routine.rink = RinkDimensions.new() + comparison_routine.season = "2026/27" + comparison_routine.adult_category = "gold" + var comparison_section := RoutineSection.new() + comparison_section.section_id = "section-upgrade" + comparison_section.title = "Abschnitt 1" + comparison_section.sequence_order = 0 + var marker := _make_segment( + "seg-upgrade", + Vector2(0.0, 0.0), + Vector2(0.0, 0.0), + PathSegment.Direction.FORWARD, + PathSegment.Edge.INSIDE + ) + marker.set_element(PathSegment.ElementType.SPIN, "ChSp", 1) + comparison_section.segments.append(marker) + comparison_routine.sections.append(comparison_section) + + var report := SeasonUpgradeCheck.run( + comparison_routine, + current, + older + ) + var comparison_pdf := RoutinePdfExporter.build_season_comparison( + comparison_routine, + report + ) + var comparison_text := comparison_pdf.get_string_from_ascii() + _check(comparison_pdf.size() > 1000, "the comparison PDF produces data") + _check( + comparison_text.begins_with("%PDF-1.4"), + "the comparison PDF has a PDF header" + ) + _check( + comparison_text.contains("Saison-Vergleich"), + "the comparison PDF has its own title" + ) + _check( + comparison_text.contains("nicht im Katalog"), + "the comparison PDF names the missing element" + ) + _check( + comparison_text.contains("2026/27") and comparison_text.contains("2025/26"), + "the comparison PDF names both seasons" + ) + _check( + comparison_text.contains("Basiswert"), + "the comparison PDF sums the base values" + ) + + # Die PDF-Texte folgen der Sprache der Oberfläche. + AppSettings.apply_locale("en") + var english_pdf := ( + RoutinePdfExporter.build(routine).get_string_from_ascii() + ) + var english_comparison := ( + RoutinePdfExporter.build_season_comparison(comparison_routine, report) + .get_string_from_ascii() + ) + AppSettings.apply_locale("de") + _check( + english_pdf.contains("Duration") and english_pdf.contains("Section"), + "PDF table labels follow the interface language" + ) + _check( + english_comparison.contains("not in the catalog"), + "the comparison PDF follows the interface language" + ) _check( pdf_text.contains(" c") or pdf_text.contains(" l"), "PDF export contains vector path operators" @@ -201,12 +295,12 @@ func _run() -> void: return _check( - controller.export_format_option.item_count == 3 - and controller.export_format_option.get_item_text(2).contains("PDF"), + controller.export_panel.format_option.item_count == 3 + and controller.export_panel.format_option.get_item_text(2).contains("PDF"), "export dialog offers the PDF format" ) _check( - controller.export_open_after_check.button_pressed, + controller.export_panel.open_after_check.button_pressed, "export dialog opens the result by default" ) @@ -216,7 +310,7 @@ func _run() -> void: await process_frame controller._open_export_dialog() await process_frame - var export_dialog := controller.export_dialog + var export_dialog := controller.export_panel.dialog var scroll := export_dialog.get_node("ExportScroll") as ScrollContainer var ok_button := export_dialog.get_ok_button() _check( @@ -279,21 +373,21 @@ func _run() -> void: controller._last_export_path = ProjectSettings.globalize_path(pdf_path) controller._show_export_done() _check( - controller.export_done_dialog.visible, + controller.export_panel.done_dialog.visible, "export completion dialog opens" ) _check( - controller.export_done_label.text.contains( + controller.export_panel.done_label.text.contains( ProjectSettings.globalize_path(pdf_path) ), "export completion dialog shows the absolute path" ) _check( - not controller.export_open_button.disabled - and not controller.export_folder_button.disabled, + not controller.export_panel.open_button.disabled + and not controller.export_panel.folder_button.disabled, "export completion dialog enables open and folder buttons" ) - controller.export_done_dialog.hide() + controller.export_panel.done_dialog.hide() DirAccess.remove_absolute(pdf_path) _check( diff --git a/rinkplanner/tests/run_playback_tests.gd b/rinkplanner/tests/run_playback_tests.gd index a0ed223..a59ef74 100644 --- a/rinkplanner/tests/run_playback_tests.gd +++ b/rinkplanner/tests/run_playback_tests.gd @@ -32,8 +32,8 @@ func _run() -> void: return _check_approx(controller.get_playback_duration(), 0.0, "empty routine has no duration") - _check(controller.play_button.disabled, "play is disabled without segments") - _check(controller.playback_timeline.editable == false, "timeline is disabled without segments") + _check(controller.playback_panel.play_button.disabled, "play is disabled without segments") + _check(controller.playback_panel.timeline.editable == false, "timeline is disabled without segments") var section_one := controller.get_active_section() var forward := controller.add_segment( @@ -62,10 +62,10 @@ func _run() -> void: controller._update_status() _check_approx(controller.get_playback_duration(), 6.0, "duration sums all sections") - _check(not controller.play_button.disabled, "play is enabled with segments") - _check(controller.playback_timeline.editable, "timeline is enabled with segments") + _check(not controller.playback_panel.play_button.disabled, "play is enabled with segments") + _check(controller.playback_panel.timeline.editable, "timeline is enabled with segments") _check_approx( - controller.playback_timeline.max_value, + controller.playback_panel.timeline.max_value, 6.0, "timeline covers the whole routine" ) @@ -80,7 +80,7 @@ func _run() -> void: "selecting a section moves the playback to its start" ) _check_approx( - controller.playback_timeline.value, + controller.playback_panel.timeline.value, 4.0, "timeline slider jumps to the section start" ) @@ -101,7 +101,7 @@ func _run() -> void: "switching back moves the playback to the first section" ) _check_approx( - controller.playback_timeline.value, + controller.playback_panel.timeline.value, 0.0, "timeline slider returns to the first section" ) @@ -199,20 +199,20 @@ func _run() -> void: "faded section banner has no alpha" ) - controller.play_button.pressed.emit() + controller.playback_panel.play_button.pressed.emit() _check(controller.is_playing(), "play button starts playback") - controller.play_button.pressed.emit() + controller.playback_panel.play_button.pressed.emit() _check(not controller.is_playing(), "play button pauses playback") controller.play() _check(controller.is_playing(), "play starts playback") - _check(controller.play_button.icon == PAUSE_ICON, "play button switches to pause") + _check(controller.playback_panel.play_button.icon == PAUSE_ICON, "play button switches to pause") controller.advance_playback(0.5) _check_approx(controller.get_playback_time(), 5.5, "playback advances by delta") controller.advance_playback(1.0) _check(not controller.is_playing(), "playback stops at the end") _check_approx(controller.get_playback_time(), 6.0, "playback ends at the total duration") - _check(controller.play_button.icon == PLAY_ICON, "play button switches back after the end") + _check(controller.playback_panel.play_button.icon == PLAY_ICON, "play button switches back after the end") controller.play() _check_approx( @@ -223,21 +223,21 @@ func _run() -> void: _check(controller.is_playing(), "restarted playback is running") controller.pause() _check(not controller.is_playing(), "pause stops playback") - controller.reset_playback_button.pressed.emit() + controller.playback_panel.reset_button.pressed.emit() _check_approx(controller.get_playback_time(), 0.0, "reset returns to the start") _check( controller.rink_canvas.get_playback_section_id().is_empty(), "reset clears the playback highlight" ) - controller.playback_timeline.value = 2.5 + controller.playback_panel.timeline.value = 2.5 _check_approx( controller.get_playback_time(), 2.5, "timeline scrubbing seeks the playback" ) - controller.speed_option.item_selected.emit(4) + controller.playback_panel.speed_option.item_selected.emit(4) _check_approx(controller.get_playback_speed(), 2.0, "speed option selects 2x") controller.reset_playback() controller.play() @@ -248,7 +248,7 @@ func _run() -> void: "2x speed doubles the elapsed routine time" ) controller.pause() - controller.speed_option.item_selected.emit(2) + controller.playback_panel.speed_option.item_selected.emit(2) _check_approx(controller.get_playback_speed(), 1.0, "speed option returns to 1x") # Element markers take their stand time from the element, not the geometry, @@ -656,13 +656,13 @@ func _run() -> void: 3.0, "scrubbing moves the routine clock" ) - controller.speed_option.item_selected.emit(4) + controller.playback_panel.speed_option.item_selected.emit(4) _check_approx( controller.music_player.pitch_scale, 2.0, "music follows the selected playback speed" ) - controller.speed_option.item_selected.emit(2) + controller.playback_panel.speed_option.item_selected.emit(2) controller.reset_playback() _check(not controller.music_player.playing, "reset stops the music") _check_approx( diff --git a/rinkplanner/tests/run_presentation3d_tests.gd b/rinkplanner/tests/run_presentation3d_tests.gd index a1ce86d..ad969c4 100644 --- a/rinkplanner/tests/run_presentation3d_tests.gd +++ b/rinkplanner/tests/run_presentation3d_tests.gd @@ -303,7 +303,7 @@ func _test_controller() -> void: _check(not controller.sections_panel.visible, "section panel is hidden in 3D") _check(not controller.timing_bar.visible, "timing bar is hidden in 3D") _check(not controller.delete_segment_button.visible, "delete button is hidden in 3D") - _check(controller.play_button.visible, "playback bar stays visible in 3D") + _check(controller.playback_panel.play_button.visible, "playback bar stays visible in 3D") var presentation := controller.get_presentation_3d() _check(presentation != null, "controller owns a presentation") diff --git a/rinkplanner/tests/run_routine_manager_panel_tests.gd b/rinkplanner/tests/run_routine_manager_panel_tests.gd new file mode 100644 index 0000000..cf427bc --- /dev/null +++ b/rinkplanner/tests/run_routine_manager_panel_tests.gd @@ -0,0 +1,86 @@ +extends SceneTree + +## Headless test for `RoutineManagerPanel` on its own: rows and signals, no +## WhiteboardController and no routine files. +## +## Run with: +## godot --headless --path rinkplanner --script res://tests/run_routine_manager_panel_tests.gd + +const PanelScene := preload("res://scenes/routine/routine_manager_panel.tscn") + +var _assertions: int = 0 +var _failures: PackedStringArray = PackedStringArray() + + +func _init() -> void: + _run.call_deferred() + + +func _run() -> void: + var panel := PanelScene.instantiate() as RoutineManagerPanel + _check(panel != null, "the panel scene carries its script") + if panel == null: + _finish() + return + root.size = Vector2i(1280, 800) + root.add_child(panel) + await process_frame + + _check(not panel.is_open(), "the dialog starts closed") + + var opened: Array = [] + var renamed: Array = [] + var deleted: Array = [] + panel.open_requested.connect(func(name: String) -> void: opened.append(name)) + panel.rename_requested.connect(func(name: String) -> void: renamed.append(name)) + panel.delete_requested.connect(func(name: String) -> void: deleted.append(name)) + + panel.open_for(["b.json", "a.json"], Vector2i(800, 600)) + _check(panel.is_open(), "the dialog opens") + _check(panel.list.get_child_count() == 2, "one row per routine") + + var first_row := panel.list.get_child(0) as HBoxContainer + _check(first_row != null and first_row.get_child_count() == 3, "a row has open, rename and delete") + if first_row != null and first_row.get_child_count() == 3: + var open_button := first_row.get_child(0) as Button + _check(open_button.text == "b", "the row shows the name without extension") + open_button.pressed.emit() + (first_row.get_child(1) as Button).pressed.emit() + (first_row.get_child(2) as Button).pressed.emit() + _check(opened == ["b.json"], "the open signal carries the file") + _check(renamed == ["b.json"], "the rename signal carries the file") + _check(deleted == ["b.json"], "the delete signal carries the file") + + panel.refresh(["c.json"]) + _check(panel.list.get_child_count() == 1, "refreshing replaces the rows") + + panel.refresh([]) + _check(panel.list.get_child_count() == 1, "an empty list shows one hint") + _check( + (panel.list.get_child(0) as Label).text.contains("Keine"), + "the hint says that no routines are stored" + ) + + panel.close() + _check(not panel.is_open(), "the dialog closes") + + panel.queue_free() + await process_frame + _finish() + + +func _check(condition: bool, message: String) -> void: + _assertions += 1 + if not condition: + _failures.append(message) + + +func _finish() -> void: + if _failures.is_empty(): + print("PASS: %d assertions" % _assertions) + quit(0) + return + for failure: String in _failures: + printerr("FAIL: %s" % failure) + printerr("%d of %d assertions failed" % [_failures.size(), _assertions]) + quit(1) diff --git a/rinkplanner/tests/run_routine_manager_panel_tests.gd.uid b/rinkplanner/tests/run_routine_manager_panel_tests.gd.uid new file mode 100644 index 0000000..b88876a --- /dev/null +++ b/rinkplanner/tests/run_routine_manager_panel_tests.gd.uid @@ -0,0 +1 @@ +uid://bkwa2hkn4gob7 diff --git a/rinkplanner/tests/run_rules_audit_tests.gd b/rinkplanner/tests/run_rules_audit_tests.gd index 33f4514..c4e9858 100644 --- a/rinkplanner/tests/run_rules_audit_tests.gd +++ b/rinkplanner/tests/run_rules_audit_tests.gd @@ -19,6 +19,9 @@ func _init() -> void: _test_broken_fixture_is_reported() _test_season_pair_difference() _test_upgrade_check() + _test_season_comparison_text() + _test_rules_context() + _test_season_panel_model() _cleanup() _finish() @@ -264,6 +267,103 @@ func _test_upgrade_check() -> void: ) + +## Der Text des Saisonvergleichs ist reine Formatierung und damit testbar. +func _test_season_comparison_text() -> void: + var library := RulesLibrary.scan() + var current := library.get_package("2026/27") + var older := library.get_package("2025/26") + if current == null or older == null: + _check(false, "both seasons load for the comparison text") + return + var routine := _make_pair_routine() + routine.adult_category = "gold" + var report := SeasonUpgradeCheck.run(routine, current, older) + var text := "\n".join(SeasonComparisonText.build(routine, report)) + _check( + text.contains("2026/27") and text.contains("2025/26"), + "the comparison text names both seasons" + ) + _check(text.contains("[b]Elemente[/b]"), "the text has the element group") + _check(text.contains("ChSp"), "the text names the missing element") + _check(text.contains("[b]Summe[/b]"), "the text sums the base values") + _check( + text.contains("Befunde bei Prüfung gegen 2025/26"), + "the text adds the findings of the target season" + ) + + + +## Der Regelsatz als eigenes Objekt: Saison laden, wechseln, leeren. +func _test_rules_context() -> void: + var context := RulesContext.new() + var package := context.load_default() + _check(package != null, "the rules context loads the default season") + _check( + context.catalog != null and context.levels != null and context.adult != null, + "the context exposes the three documents" + ) + _check( + context.season_label() == context.library.get_default_season(), + "the context reports the default season" + ) + var older := context.apply("2025/26") + _check(older != null, "the context switches to an older season") + _check(context.season_label() == "2025/26", "the applied season is reported") + _check(context.adult != null, "2025/26 has adult rules") + _check(context.apply("") == null, "an empty season applies nothing") + _check(context.catalog == null, "an empty season clears the documents") + context.apply("2030/31") + _check(context.package == null, "an unknown season clears the documents") + + + +## Inhalt der Statusleisten-Auswahl: Beschriftung, Zuordnung, Auswahl. +func _test_season_panel_model() -> void: + var library := RulesLibrary.scan() + + var empty := SeasonPanelModel.season_items("", library) + _check(int(empty["selected"]) == 0, "without a season the first entry is selected") + _check(str(empty["items"][0]["value"]) == "", "the first entry has no value") + + var current := SeasonPanelModel.season_items("2026/27", library) + _check( + str(current["items"][int(current["selected"])]["value"]) == "2026/27", + "the current season is selected" + ) + var unknown := SeasonPanelModel.season_items("2030/31", library) + _check( + str(unknown["items"][int(unknown["selected"])]["value"]) == "2030/31", + "an unknown season stays visible" + ) + + var categories: Array = [] + var package := library.get_package("2026/27") + if package != null and package.adult != null: + categories.assign(package.adult.get_categories("free")) + _check(categories.size() == 5, "the free-skating categories are offered") + var known := SeasonPanelModel.category_items("gold", categories) + _check( + str(known["items"][int(known["selected"])]["value"]) == "gold", + "a known category is selected" + ) + var missing := SeasonPanelModel.category_items("legacy", categories) + _check( + str(missing["items"][int(missing["selected"])]["value"]) == "legacy", + "an unknown category stays visible" + ) + _check( + str(missing["items"][int(missing["selected"])]["label"]).contains( + "nicht verfügbar" + ), + "an unknown category is labelled" + ) + _check( + SeasonPanelModel.program_items("artistic")["selected"] == 1, + "the artistic programme is selected" + ) + + func _make_pair_routine() -> Routine: var routine := Routine.new() routine.routine_id = "season-pair" diff --git a/rinkplanner/tests/run_sync_tests.gd b/rinkplanner/tests/run_sync_tests.gd index e93ac3a..81636d7 100644 --- a/rinkplanner/tests/run_sync_tests.gd +++ b/rinkplanner/tests/run_sync_tests.gd @@ -784,7 +784,7 @@ func _test_controller_wiring() -> void: manager_item = index _check(manager_item >= 0, "das Dateimenü bietet die Kürenverwaltung an") _check( - controller.routine_manager_dialog != null + controller.routine_manager_panel.dialog != null and controller.delete_routine_dialog != null, "Verwaltungs- und Löschdialog sind in der Szene verdrahtet" ) @@ -792,7 +792,7 @@ func _test_controller_wiring() -> void: controller.cleanup_conflicts_dialog != null, "der Aufräumdialog ist in der Szene verdrahtet" ) - var summary := controller._format_sync_summary({ + var summary := SyncSummaryText.format({ "uploaded": [], "downloaded": [], "skipped": [], @@ -813,6 +813,55 @@ func _test_controller_wiring() -> void: "die Sync-Zusammenfassung nennt Gewinner und Konfliktarchiv" ) + # SyncSettingsModel: Anbieterliste hängt an der Build-Konfiguration. + var only_dropbox := SyncSettingsModel.provider_items({"dropbox_app_key": "key"}) + _check( + only_dropbox.size() == 1 + and str(only_dropbox[0]["value"]) == "dropbox", + "without Google credentials only Dropbox is offered" + ) + var with_google := SyncSettingsModel.provider_items( + { + "dropbox_app_key": "key", + "google_client_id": "id", + "google_client_secret": "secret", + } + ) + _check(with_google.size() == 2, "Google Drive appears when configured") + _check( + SyncSettingsModel.index_of(with_google, "google_drive") == 1, + "the provider list is searchable by id" + ) + _check( + SyncSettingsModel.provider_items({}).size() == 1, + "Dropbox stays visible without credentials" + ) + + # RoutineManagerModel: eine Zeile pro Kür, JSON vor Legacy, sortiert. + var model_dir := "user://routine-manager-model" + DirAccess.make_dir_recursive_absolute(ProjectSettings.globalize_path(model_dir)) + for name: String in ["b.tres", "a.json", "c.json", "c.tres", "notes.txt"]: + var file := FileAccess.open(model_dir.path_join(name), FileAccess.WRITE) + if file != null: + file.store_string("{}") + file.close() + var listed := RoutineManagerModel.list_routines(model_dir) + _check(listed.size() == 3, "one row per routine, ignoring other files (%d)" % listed.size()) + _check(str(listed[0]) == "a.json", "routines are sorted by name") + _check(listed.has("c.json") and not listed.has("c.tres"), "JSON wins over the legacy format") + var variants := RoutineManagerModel.variants(model_dir, "c.json") + _check( + variants.size() == 2 and variants.has("c.json") and variants.has("c.tres"), + "both variants of a routine are found" + ) + _check( + RoutineManagerModel.variants(model_dir, "missing.json") == PackedStringArray(["missing.json"]), + "a missing routine falls back to its name" + ) + for name: String in ["b.tres", "a.json", "c.json", "c.tres", "notes.txt"]: + DirAccess.remove_absolute(model_dir.path_join(name)) + DirAccess.remove_absolute(model_dir) + # "Küren verwalten": rows expose open/delete, the music stay-check works. controller.sync_settings_dialog.hide() DirAccess.make_dir_recursive_absolute( @@ -843,13 +892,13 @@ func _test_controller_wiring() -> void: ) ) controller._refresh_routine_manager() - controller.routine_manager_dialog.show() + controller.routine_manager_panel.dialog.show() _check( - controller.routine_manager_dialog.visible, + controller.routine_manager_panel.dialog.visible, "der Verwaltungsdialog lässt sich öffnen" ) var manager_row: HBoxContainer = null - for child: Node in controller.routine_manager_list.get_children(): + for child: Node in controller.routine_manager_panel.list.get_children(): if child is HBoxContainer: var open_button := child.get_child(0) as Button if open_button != null and open_button.text == "sync-test-manager": @@ -946,7 +995,7 @@ func _test_controller_wiring() -> void: ) ) controller._refresh_routine_manager() - controller.routine_manager_dialog.hide() + controller.routine_manager_panel.dialog.hide() controller.sync_settings_dialog.hide() # Ohne Refresh-Token öffnet "Jetzt synchronisieren" die Einstellungen. diff --git a/rinkplanner/tests/run_validation_tests.gd b/rinkplanner/tests/run_validation_tests.gd index f45a837..29b1e8a 100644 --- a/rinkplanner/tests/run_validation_tests.gd +++ b/rinkplanner/tests/run_validation_tests.gd @@ -43,6 +43,7 @@ func _init() -> void: _test_jump_sequence() _test_program_once_features() _test_missing_rules() + _test_report_view() _finish() @@ -562,6 +563,42 @@ func _messages(issues: Array[ValidationIssue]) -> String: return "; ".join(parts) + +## Der Dialogtext ist reine Formatierung und damit ohne Szene testbar. +func _test_report_view() -> void: + var routine := _make_routine() + _add_marker( + routine.sections[0], + "spin", + PathSegment.ElementType.SPIN, + "CCoSp", + 4, + PackedStringArray(["difficult_variation_sit", "difficult_exit"]) + ) + var report := _validator.validate_report(routine) + var text := "\n".join( + ValidationReportView.build( + routine, + report, + null, + { + "season": "2026/27", + "season_note": "", + "can_compare": true, + "show_info": false, + "show_assumptions": false, + } + ) + ) + _check(text.contains("Geprüft:"), "the view has the header line") + _check(text.contains("Saison 2026/27"), "the view names the season") + _check(text.contains("[url=upgrade]"), "the view offers the season comparison") + _check(text.contains("Kategorie: Ohne Kategorie"), "the view reports no category") + _check(text.contains("[b]Basiswert:"), "the view shows the base value") + _check(text.contains("[b]Prüfungen[/b]"), "the view lists the checks") + _check(text.contains("[b]Befunde[/b]"), "the view lists the findings") + + func _check(condition: bool, message: String) -> void: _assertions += 1 if not condition: diff --git a/rinkplanner/tests/run_whiteboard_tests.gd b/rinkplanner/tests/run_whiteboard_tests.gd index 5d4909e..0adaaa1 100644 --- a/rinkplanner/tests/run_whiteboard_tests.gd +++ b/rinkplanner/tests/run_whiteboard_tests.gd @@ -1790,6 +1790,20 @@ func _run() -> void: controller.get_season() == "2026/27", "checking alone does not change the season" ) + _check( + not controller.upgrade_pdf_button.disabled, + "the comparison can be written as a PDF" + ) + controller._on_upgrade_pdf_pressed() + _check( + controller._last_export_path.ends_with(".pdf"), + "the comparison PDF lands in the export folder" + ) + _check( + FileAccess.file_exists(controller._last_export_path), + "the comparison PDF was written" + ) + controller.export_panel.done_dialog.hide() controller._on_upgrade_apply_pressed() _check( controller.get_season() == "2025/26", diff --git a/tools/export_windows_installer.sh b/tools/export_windows_installer.sh index caed987..ce84087 100755 --- a/tools/export_windows_installer.sh +++ b/tools/export_windows_installer.sh @@ -43,7 +43,7 @@ VERSION="$( sed -n 's/^[[:space:]]*application\/product_version="\([^"]*\)"/\1/p' \ "$PROJECT_DIR/export_presets.cfg" | head -1 )" -VERSION="${VERSION:-0.3.0.0}" +VERSION="${VERSION:-0.4.0.0}" if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then VERSION="$VERSION.0" fi diff --git a/tools/test.sh b/tools/test.sh index 26346bb..f279d7e 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -66,6 +66,12 @@ fi "$GODOT" --headless --path "$PROJECT_DIR" \ --script res://tests/run_timing_tests.gd +"$GODOT" --headless --path "$PROJECT_DIR" \ + --script res://tests/run_export_panel_tests.gd + +"$GODOT" --headless --path "$PROJECT_DIR" \ + --script res://tests/run_routine_manager_panel_tests.gd + "$GODOT" --headless --path "$PROJECT_DIR" \ --script res://tests/run_export_tests.gd diff --git a/tools/windows_installer.nsi b/tools/windows_installer.nsi index 293e965..fd0ffcc 100644 --- a/tools/windows_installer.nsi +++ b/tools/windows_installer.nsi @@ -7,7 +7,7 @@ ; -DICON_FILE=/pfad/zu/rinkplanner.ico !ifndef APP_VERSION - !define APP_VERSION "0.3.0.0" + !define APP_VERSION "0.4.0.0" !endif !ifndef SOURCE_EXE !error "SOURCE_EXE fehlt (Pfad zur rinkplanner.exe)." diff --git a/web/i18n.php b/web/i18n.php index 47b8165..22fb5c4 100644 --- a/web/i18n.php +++ b/web/i18n.php @@ -43,7 +43,7 @@ return [ 'downloads.kicker' => 'Test-Build', 'downloads.title' => 'Rinkplanner herunterladen', - 'downloads.lede' => 'Installer für macOS und Windows vom 13.11.2026. Wähle deine Plattform – die Downloads sind direkt einsatzbereit.', + 'downloads.lede' => 'macOS- und Windows-Installer vom 13.11.2026. Wähle deine Plattform – die Downloads sind direkt einsatzbereit.', 'downloads.mac.title' => 'Für den Mac', 'downloads.mac.body' => 'Universal Binary für Apple Silicon (macOS 13+) und Intel (macOS 11+).', 'downloads.mac.cta' => 'Installer herunterladen', @@ -142,7 +142,7 @@ return [ 'downloads.kicker' => 'Test build', 'downloads.title' => 'Download Rinkplanner', - 'downloads.lede' => 'Installers for macOS and Windows from 13 Nov 2026. Pick your platform – the downloads are ready to use.', + 'downloads.lede' => 'macOS and Windows installers from 13 Nov 2026. Pick your platform – the downloads are ready to use.', 'downloads.mac.title' => 'For your Mac', 'downloads.mac.body' => 'Universal binary for Apple Silicon (macOS 13+) and Intel (macOS 11+).', 'downloads.mac.cta' => 'Download installer',