feat: Saison-Vergleich als PDF ausgeben

Der Vergleichsdialog hat jetzt "Als PDF". Der Bericht schreibt dieselben
Gruppen wie der Dialog in eine Textseite im Exportordner
(<Kür>_saisonvergleich_<Saison>.pdf) und zeigt danach den bekannten
Abschluss-Dialog mit Öffnen, Ordner zeigen und Pfad kopieren.

- RoutinePdfExporter.build_season_comparison() nutzt die vorhandenen
  PDF-Bausteine (Seitenkopf, Fußzeile, WinAnsi-Text) und bricht lange
  Meldungen auf die Seitenbreite um.
- Inhalt: fehlende Elemente, Base Values, Elementtyp, Features, Level,
  Kategorie-Grenzen, Summe und die Befunde gegen die Ziel-Saison.
- ExportDoneDialog ist nicht mehr exklusiv, damit er sich über den offenen
  Prüfdialog legen kann.

Bewusst nicht geändert: PDFs bleiben einheitlich deutsch. _text() berechnet
zwar I18n.t(text), schreibt aber das Original; eine konsequente Übersetzung
müsste vor der Interpolation ansetzen. Als offener Punkt dokumentiert.
This commit is contained in:
torsten 2026-11-13 12:47:50 +01:00
parent ad9f60b8aa
commit 4bc00d2bf9
8 changed files with 366 additions and 5 deletions

View file

@ -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.

View file

@ -318,6 +318,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
(`<Kür>_saisonvergleich_<Saison>.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:

View file

@ -798,3 +798,4 @@
"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"

1 keys de en
798 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.
799 „%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.
800 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.
801 Als PDF Als PDF As PDF

View file

@ -1723,6 +1723,7 @@ 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"]
@ -1912,6 +1913,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

View file

@ -234,6 +234,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
@ -1111,10 +1112,12 @@ func _run_upgrade_check() -> void:
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_apply_button.disabled = false
upgrade_pdf_button.disabled = false
func _upgrade_report_lines(report: SeasonUpgradeCheck.Report) -> PackedStringArray:
@ -1276,6 +1279,37 @@ func _on_upgrade_apply_pressed() -> void:
upgrade_dialog.hide()
## 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
)
if pdf.is_empty():
_show_message(I18n.t("Export fehlgeschlagen."))
return
_ensure_exports_dir()
var stem := _normalize_file_stem(_routine.title)
if stem.is_empty():
stem = "kuer"
var season := _upgrade_target_season.replace("/", "-")
var path := EXPORTS_DIR.path_join(
"%s_saisonvergleich_%s.pdf" % [stem, season]
)
var file := FileAccess.open(path, FileAccess.WRITE)
if file == null:
_show_message(I18n.t("Export fehlgeschlagen."))
return
file.store_buffer(pdf)
file.close()
_last_export_path = ProjectSettings.globalize_path(path)
upgrade_dialog.hide()
_show_export_done()
func _score_info_lines() -> PackedStringArray:
var lines := PackedStringArray()
lines.append("[b]Enthalten[/b]")
@ -3147,6 +3181,8 @@ func _setup_upgrade_controls() -> void:
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)

View file

@ -27,6 +27,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 +77,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(
"• %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(
"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(
"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" % [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 "%s — nicht im Katalog" % change.label
SeasonUpgradeCheck.KIND_UNKNOWN_FEATURE:
return "%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 -------------------------------------------------------

View file

@ -134,6 +134,64 @@ func _run() -> void:
pdf_text.contains("Test & <K\\374r>"),
"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"
)
_check(
pdf_text.contains(" c") or pdf_text.contains(" l"),
"PDF export contains vector path operators"

View file

@ -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_done_dialog.hide()
controller._on_upgrade_apply_pressed()
_check(
controller.get_season() == "2025/26",