refactor: Prüfdialog-Text aus dem Controller lösen
Etappe 3 der Controller-Zerlegung. Der komplette Text des Prüfdialogs (Kopf, Saisonhinweis, Kategorie, Basiswert, Punktschätzung, Wertung, Prüfliste, Befunde) liegt jetzt in `src/whiteboard/view/validation_report_view.gd`. - `ValidationReportView.build(routine, report, category, context)` bekommt einen kleinen Kontext für die Anzeige-Optionen und gibt die BBCode-Zeilen zurück; der Controller baut nur noch den Report und setzt das Label. - Mit dem Text wandern die Hilfsfunktionen (Prüfliste-Zeile, Skip-Gründe, Fundstelle, Zähl-Labels) in die View. Sie waren nur hier im Einsatz. - Eigener Test für den Aufbau des Textes (Kopf, Saison, Vergleichslink, Kategorie, Basiswert, Prüfliste, Befunde). Controller: 8.839 -> 8.566 Zeilen. Kein Verhalten geändert, Suite grün. Nächste Etappe laut Notiz: ExportService.
This commit is contained in:
parent
1245f438f1
commit
a3d35076dc
6 changed files with 374 additions and 296 deletions
|
|
@ -4,7 +4,7 @@ Stand: 2026-11-13
|
||||||
|
|
||||||
Ziel: Der Controller war mit **9.092 Zeilen und 465 Funktionen** der größte
|
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
|
Baustein im Projekt; die Roadmap nennt < 1.500 Zeilen pro Datei. Nach den
|
||||||
Etappen 1 und 2 sind es 8.839 Zeilen. Diese Notiz
|
Etappen 1–3 sind es 8.566 Zeilen. Diese Notiz
|
||||||
hält die Reihenfolge fest, damit der Umbau in Etappen mit grüner Suite
|
hält die Reihenfolge fest, damit der Umbau in Etappen mit grüner Suite
|
||||||
passiert und nicht als Big Bang.
|
passiert und nicht als Big Bang.
|
||||||
|
|
||||||
|
|
@ -27,7 +27,7 @@ passiert und nicht als Big Bang.
|
||||||
| :--- | :--- | ---: | :--- | :--- |
|
| :--- | :--- | ---: | :--- | :--- |
|
||||||
| `HelpContent` | Hilfetext für den ?-Dialog | 137 | keine | 1 ✅ |
|
| `HelpContent` | Hilfetext für den ?-Dialog | 137 | keine | 1 ✅ |
|
||||||
| `SeasonComparisonText` | Zeilen für den Saisonvergleichs-Dialog | 175 | nur Daten | 2 ✅ |
|
| `SeasonComparisonText` | Zeilen für den Saisonvergleichs-Dialog | 175 | nur Daten | 2 ✅ |
|
||||||
| `ValidationReportView` | Zeilen für den Prüfdialog | ~350 | nur Daten | 3 |
|
| `ValidationReportView` | Zeilen für den Prüfdialog | 300 | nur Daten | 3 ✅ |
|
||||||
| `ExportService` | PDF/SVG/PNG schreiben, Abschlussdialog-Daten | ~250 | Dateisystem | 4 |
|
| `ExportService` | PDF/SVG/PNG schreiben, Abschlussdialog-Daten | ~250 | Dateisystem | 4 |
|
||||||
| `SeasonPanel` | Saison-/Programm-/Kategorieauswahl und Regelnachführung | ~250 | Statusleiste | 5 |
|
| `SeasonPanel` | Saison-/Programm-/Kategorieauswahl und Regelnachführung | ~250 | Statusleiste | 5 |
|
||||||
| `SyncPanel` | Dropbox-Sync, Konflikte, Küren verwalten | ~900 | Dialoge, Threads | 6 |
|
| `SyncPanel` | Dropbox-Sync, Konflikte, Küren verwalten | ~900 | Dialoge, Threads | 6 |
|
||||||
|
|
@ -53,16 +53,16 @@ Der Text des Saisonvergleichs (Kopf, Gruppen, Summe, Befunde) liegt jetzt in
|
||||||
gibt die BBCode-Zeilen zurück; der Controller setzt sie nur noch in das
|
gibt die BBCode-Zeilen zurück; der Controller setzt sie nur noch in das
|
||||||
Label. Kein Verhalten geändert.
|
Label. Kein Verhalten geändert.
|
||||||
|
|
||||||
### 3. `ValidationReportView`
|
### 3. `ValidationReportView` ✅
|
||||||
|
|
||||||
Derselbe Schnitt für den Prüfdialog: Kopf, Saisonhinweis, Kategorie,
|
Der komplette Text des Prüfdialogs (Kopf, Saisonhinweis, Kategorie,
|
||||||
Basiswert, Punktschätzung, Prüfliste und Befunde. Weil dort Anzeige-Optionen
|
Basiswert, Punktschätzung, Wertung, Prüfliste, Befunde) liegt in
|
||||||
(„Was ist enthalten?", „Annahmen ändern") mit hineinspielen, bekommt die
|
`src/whiteboard/view/validation_report_view.gd`. Signatur:
|
||||||
Klasse einen kleinen Kontext (Dictionary) statt vieler Einzelparameter.
|
`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, wenn der Controller nur noch `validation_text.text = ...` setzt und
|
Fertig: Dialog unverändert, Whiteboard-Test grün, eigener Test für den Text.
|
||||||
der Dialog unverändert aussieht (Whiteboard-Test grün, keine neuen
|
|
||||||
Typfehler).
|
|
||||||
|
|
||||||
### 4. `ExportService`
|
### 4. `ExportService`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -270,8 +270,8 @@ Schritte.
|
||||||
- [ ] `WhiteboardController` in Services/Panels zerlegen: Datei-I/O, Sync,
|
- [ ] `WhiteboardController` in Services/Panels zerlegen: Datei-I/O, Sync,
|
||||||
Playback, Validierung, Element-Inspector, Section-Liste. Ziel: < 1.500
|
Playback, Validierung, Element-Inspector, Section-Liste. Ziel: < 1.500
|
||||||
Zeilen pro Datei, keine 100 `%`-Lookups in einem Skript. In Etappen nach
|
Zeilen pro Datei, keine 100 `%`-Lookups in einem Skript. In Etappen nach
|
||||||
`docs/refactor-whiteboard-controller.md`; Stand 2026-11-13: 8.839 Zeilen,
|
`docs/refactor-whiteboard-controller.md`; Stand 2026-11-13: 8.566 Zeilen,
|
||||||
`HelpContent` und `SeasonComparisonText` ausgelagert.
|
`HelpContent`, `SeasonComparisonText` und `ValidationReportView` ausgelagert.
|
||||||
- [ ] Gemeinsamer Test-Harness (oder gdUnit4), Timeout pro Testlauf,
|
- [ ] Gemeinsamer Test-Harness (oder gdUnit4), Timeout pro Testlauf,
|
||||||
Coverage; CI auf dem Gitea-/Forgejo-Remote mit `tools/test.sh` und
|
Coverage; CI auf dem Gitea-/Forgejo-Remote mit `tools/test.sh` und
|
||||||
`tools/check_export.sh`.
|
`tools/check_export.sh`.
|
||||||
|
|
|
||||||
|
|
@ -892,33 +892,6 @@ func _render_validation_dialog() -> void:
|
||||||
_adult_rules
|
_adult_rules
|
||||||
)
|
)
|
||||||
var report := validator.validate_report(_routine)
|
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
|
var category: AdultCategoryRules.Category = null
|
||||||
if (
|
if (
|
||||||
_routine != null
|
_routine != null
|
||||||
|
|
@ -929,129 +902,18 @@ func _render_validation_dialog() -> void:
|
||||||
_routine.adult_category,
|
_routine.adult_category,
|
||||||
_routine.program_type
|
_routine.program_type
|
||||||
)
|
)
|
||||||
var category_name := "Ohne Kategorie"
|
var lines := ValidationReportView.build(
|
||||||
if category != null:
|
_routine,
|
||||||
category_name = "%s · %s · %s ±%d s" % [
|
report,
|
||||||
category.name,
|
category,
|
||||||
_program_label(category.program_type),
|
{
|
||||||
_format_duration(category.duration_seconds),
|
"season": _catalog_season_label(),
|
||||||
category.duration_tolerance_seconds,
|
"season_note": _season_note(),
|
||||||
]
|
"can_compare": _can_compare_seasons(),
|
||||||
lines.append("[b]Kategorie: %s[/b]" % category_name)
|
"show_info": _show_score_info,
|
||||||
lines.append("")
|
"show_assumptions": _show_score_assumptions,
|
||||||
lines.append(
|
}
|
||||||
"[b]Basiswert: %s[/b]" % _format_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_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)
|
validation_text.text = I18n.join_lines(lines)
|
||||||
if validation_dialog.visible:
|
if validation_dialog.visible:
|
||||||
return
|
return
|
||||||
|
|
@ -1064,9 +926,6 @@ func _render_validation_dialog() -> void:
|
||||||
target.y = mini(target.y, viewport_size.y)
|
target.y = mini(target.y, viewport_size.y)
|
||||||
validation_dialog.popup_centered(target)
|
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:
|
func open_upgrade_dialog() -> void:
|
||||||
if _routine == null or _rules_package == null or _rules_library == null:
|
if _routine == null or _rules_package == null or _rules_library == null:
|
||||||
return
|
return
|
||||||
|
|
@ -1160,128 +1019,6 @@ func _on_upgrade_pdf_pressed() -> void:
|
||||||
_show_export_done()
|
_show_export_done()
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
static func _escape_bbcode(text: String) -> String:
|
static func _escape_bbcode(text: String) -> String:
|
||||||
return text.replace("[", "[lb]")
|
return text.replace("[", "[lb]")
|
||||||
|
|
||||||
|
|
@ -1290,10 +1027,6 @@ static func _format_base_value(value: float) -> String:
|
||||||
return ("%.2f" % value).replace(".", ",")
|
return ("%.2f" % value).replace(".", ",")
|
||||||
|
|
||||||
|
|
||||||
static func _format_duration(seconds: int) -> String:
|
|
||||||
return "%d:%02d" % [seconds / 60, seconds % 60]
|
|
||||||
|
|
||||||
|
|
||||||
func open_help_dialog() -> void:
|
func open_help_dialog() -> void:
|
||||||
help_text.text = HelpContent.build()
|
help_text.text = HelpContent.build()
|
||||||
var target := Vector2i(820, 680)
|
var target := Vector2i(820, 680)
|
||||||
|
|
@ -2822,12 +2555,6 @@ func get_program_type() -> String:
|
||||||
return _program_type()
|
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:
|
func _on_adult_category_selected(index: int) -> void:
|
||||||
set_adult_category(str(adult_category_option.get_item_metadata(index)))
|
set_adult_category(str(adult_category_option.get_item_metadata(index)))
|
||||||
|
|
||||||
|
|
|
||||||
313
rinkplanner/src/whiteboard/view/validation_report_view.gd
Normal file
313
rinkplanner/src/whiteboard/view/validation_report_view.gd
Normal file
|
|
@ -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]")
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
uid://4shkok0ey0x3
|
||||||
|
|
@ -43,6 +43,7 @@ func _init() -> void:
|
||||||
_test_jump_sequence()
|
_test_jump_sequence()
|
||||||
_test_program_once_features()
|
_test_program_once_features()
|
||||||
_test_missing_rules()
|
_test_missing_rules()
|
||||||
|
_test_report_view()
|
||||||
_finish()
|
_finish()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -562,6 +563,42 @@ func _messages(issues: Array[ValidationIssue]) -> String:
|
||||||
return "; ".join(parts)
|
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:
|
func _check(condition: bool, message: String) -> void:
|
||||||
_assertions += 1
|
_assertions += 1
|
||||||
if not condition:
|
if not condition:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue