feat: Speichern, Laden und Autosave für Kürläufe hinzufügen
- Datei-Menü mit Neu, Öffnen, Speichern und Speichern unter - .tres-Persistenz unter user://routines mit Schema-Version - Autosave nach 1,5 s und Wiederherstellung beim Start - Dirty-State im Fenstertitel und Rückfrage vor Verwerfen - Öffnen-Dialog mit 48-px-Buttons für Touch-Bedienung - Tests auf 265 Assertions erweitert
This commit is contained in:
parent
98eb5b7e2f
commit
1623fb2590
8 changed files with 590 additions and 34 deletions
|
|
@ -118,6 +118,10 @@ eine Abkürzung. So kann die UI Fehler konkret anzeigen.
|
||||||
durchnummeriert, die Section-IDs bleiben stabil. Die aktive Section wird
|
durchnummeriert, die Section-IDs bleiben stabil. Die aktive Section wird
|
||||||
voll gezeichnet, alle anderen mit 20 % Deckkraft geghostet. Beim Wechsel
|
voll gezeichnet, alle anderen mit 20 % Deckkraft geghostet. Beim Wechsel
|
||||||
wird eine eventuelle Segmentauswahl verworfen.
|
wird eine eventuelle Segmentauswahl verworfen.
|
||||||
|
- **Dokument-Lifecycle:** Das Datei-Menü bietet Neu, Öffnen, Speichern und
|
||||||
|
Speichern unter. Ein Dirty-State markiert ungespeicherte Änderungen im
|
||||||
|
Fenstertitel; Neu/Öffnen fragen vor dem Verwerfen. Autosave und Restore
|
||||||
|
laufen unabhängig davon im Hintergrund.
|
||||||
- **Darstellung:** vorwärts durchgezogen, rückwärts gestrichelt, außen rot,
|
- **Darstellung:** vorwärts durchgezogen, rückwärts gestrichelt, außen rot,
|
||||||
innen blau. Inaktive Sections werden mit 20 % Deckkraft geghostet.
|
innen blau. Inaktive Sections werden mit 20 % Deckkraft geghostet.
|
||||||
- **Ghosting** ist reine View-Logik: pro Section ein eigener Layer,
|
- **Ghosting** ist reine View-Logik: pro Section ein eigener Layer,
|
||||||
|
|
@ -151,9 +155,17 @@ standardmäßig bleibt es aus.
|
||||||
- **PNG** entsteht über einen Viewport-Render in hoher Auflösung.
|
- **PNG** entsteht über einen Viewport-Render in hoher Auflösung.
|
||||||
- **PDF** ist nicht nativ in Godot. Erste Stufe: Browser-Druck aus SVG;
|
- **PDF** ist nicht nativ in Godot. Erste Stufe: Browser-Druck aus SVG;
|
||||||
eine echte PDF-Ausgabe ist ein separates Arbeitspaket.
|
eine echte PDF-Ausgabe ist ein separates Arbeitspaket.
|
||||||
- **Persistenz** erfolgt lokal als `.tres`-Ressourcen. Auf Web schreibt
|
- **Persistenz** erfolgt lokal als `.tres`-Ressourcen unter
|
||||||
`FileAccess` in den IndexedDB-Speicher; Speichern/Laden/Autosave brauchen
|
`user://routines/`. `Routine.schema_version` schützt vor inkompatiblen
|
||||||
deshalb eine explizite UX.
|
neueren Dateien. Benannte Kürläufe werden über das Datei-Menü gespeichert
|
||||||
|
und geladen; der Öffnen-Dialog nutzt 48-px-Buttons statt einer kleinen
|
||||||
|
Dateiliste.
|
||||||
|
- **Autosave** schreibt nach 1,5 s Inaktivität nach `user://autosave.tres`
|
||||||
|
und wird beim Start automatisch wiederhergestellt. Der Dirty-State wird im
|
||||||
|
Fenstertitel als `*` angezeigt. Beim Verlassen wird zusätzlich gespeichert.
|
||||||
|
- **Web:** `FileAccess` schreibt in den IndexedDB-Speicher. Die Persistenz
|
||||||
|
funktioniert dort über `user://`; ein echter Browser-/Tablet-Test steht
|
||||||
|
noch aus.
|
||||||
|
|
||||||
## 7. Tests
|
## 7. Tests
|
||||||
|
|
||||||
|
|
@ -165,14 +177,19 @@ Headless, ohne Editor und ohne Display:
|
||||||
|
|
||||||
Aktueller Stand:
|
Aktueller Stand:
|
||||||
|
|
||||||
- **Model:** 45 Assertions für Rink-Geometrie, Clamping, Segment-Timing,
|
- **Model:** 46 Assertions für Rink-Geometrie, Clamping, Segment-Timing,
|
||||||
Template-Metadaten, Section-Aggregation und Routine-Validierung.
|
Template-Metadaten, Schema-Version, Section-Aggregation und
|
||||||
|
Routine-Validierung.
|
||||||
- **Canvas:** 90 Assertions für Meter→Pixel-Mapping, Fit/Zoom/Pan,
|
- **Canvas:** 90 Assertions für Meter→Pixel-Mapping, Fit/Zoom/Pan,
|
||||||
Rink-Kontur und die reine Bogen-Geometrie.
|
Rink-Kontur und die reine Bogen-Geometrie.
|
||||||
- **Whiteboard:** 111 Assertions für Controller-Verdrahtung, Segmenterzeugung,
|
- **Whiteboard:** 129 Assertions für Controller-Verdrahtung, Segmenterzeugung,
|
||||||
Linien-/Bogenpfade, Klemmen an der Bande, Auswahl, Griff- und
|
Linien-/Bogenpfade, Klemmen an der Bande, Auswahl, Griff- und
|
||||||
Richtungs-/Kanten-Bearbeitung, Segmentlöschung, Undo, Section-Verwaltung,
|
Richtungs-/Kanten-Bearbeitung, Segmentlöschung, Undo, Section-Verwaltung,
|
||||||
Ghosting-Zustand, Navigationsmodus und den Maus-Drag-Pfad.
|
Ghosting-Zustand, Speichern/Laden, Schema-Prüfung, Dirty-State,
|
||||||
|
Navigationsmodus und den Maus-Drag-Pfad.
|
||||||
|
|
||||||
|
Autosave/Restore wird zusätzlich in einem isolierten `XDG_DATA_HOME`
|
||||||
|
end-to-end geprüft.
|
||||||
|
|
||||||
Visuelle Smoke-Tests laufen zusätzlich über `xvfb-run` und einen
|
Visuelle Smoke-Tests laufen zusätzlich über `xvfb-run` und einen
|
||||||
Viewport-Screenshot; sie ersetzen die headless Tests nicht.
|
Viewport-Screenshot; sie ersetzen die headless Tests nicht.
|
||||||
|
|
@ -198,3 +215,9 @@ Viewport-Screenshot; sie ersetzen die headless Tests nicht.
|
||||||
7. **Section-Darstellung:** Die aktuelle Scrollliste funktioniert für wenige
|
7. **Section-Darstellung:** Die aktuelle Scrollliste funktioniert für wenige
|
||||||
Abschnitte. Bei langen Kürprogrammen ist zu prüfen, ob eine horizontale
|
Abschnitte. Bei langen Kürprogrammen ist zu prüfen, ob eine horizontale
|
||||||
Timeline mit Zeitproportionen die bessere Bedienung ist.
|
Timeline mit Zeitproportionen die bessere Bedienung ist.
|
||||||
|
8. **Persistenz-Backups:** Autosave nutzt genau einen Slot. Ob zusätzlich
|
||||||
|
rotierende Backups oder Versionen pro Speichervorgang nötig sind, zeigt
|
||||||
|
sich im Praxisbetrieb.
|
||||||
|
9. **Dateinamen:** Die Normalisierung ersetzt Leerzeichen und entfernt
|
||||||
|
Pfadzeichen, transliteriert aber keine Umlaute. Für Web/Windows ist zu
|
||||||
|
prüfen, ob eine ASCII-Normalisierung robuster ist.
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,14 @@ theme_override_font_sizes/font_size = 22
|
||||||
text = "Rinkplanner"
|
text = "Rinkplanner"
|
||||||
vertical_alignment = 1
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="FileMenuButton" type="MenuButton" parent="Layout/TopBar/Tools"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
custom_minimum_size = Vector2(48, 48)
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_font_sizes/font_size = 20
|
||||||
|
text = "☰"
|
||||||
|
tooltip_text = "Datei"
|
||||||
|
|
||||||
[node name="TitleSeparator" type="VSeparator" parent="Layout/TopBar/Tools"]
|
[node name="TitleSeparator" type="VSeparator" parent="Layout/TopBar/Tools"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
|
|
@ -88,7 +96,7 @@ layout_mode = 2
|
||||||
|
|
||||||
[node name="ForwardButton" type="Button" parent="Layout/TopBar/Tools"]
|
[node name="ForwardButton" type="Button" parent="Layout/TopBar/Tools"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(104, 48)
|
custom_minimum_size = Vector2(96, 48)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_font_sizes/font_size = 16
|
theme_override_font_sizes/font_size = 16
|
||||||
toggle_mode = true
|
toggle_mode = true
|
||||||
|
|
@ -98,7 +106,7 @@ text = "Vorwärts"
|
||||||
|
|
||||||
[node name="BackwardButton" type="Button" parent="Layout/TopBar/Tools"]
|
[node name="BackwardButton" type="Button" parent="Layout/TopBar/Tools"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(104, 48)
|
custom_minimum_size = Vector2(96, 48)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_font_sizes/font_size = 16
|
theme_override_font_sizes/font_size = 16
|
||||||
toggle_mode = true
|
toggle_mode = true
|
||||||
|
|
@ -110,7 +118,7 @@ layout_mode = 2
|
||||||
|
|
||||||
[node name="InsideButton" type="Button" parent="Layout/TopBar/Tools"]
|
[node name="InsideButton" type="Button" parent="Layout/TopBar/Tools"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(88, 48)
|
custom_minimum_size = Vector2(80, 48)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_font_sizes/font_size = 16
|
theme_override_font_sizes/font_size = 16
|
||||||
toggle_mode = true
|
toggle_mode = true
|
||||||
|
|
@ -119,7 +127,7 @@ text = "Innen"
|
||||||
|
|
||||||
[node name="OutsideButton" type="Button" parent="Layout/TopBar/Tools"]
|
[node name="OutsideButton" type="Button" parent="Layout/TopBar/Tools"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(88, 48)
|
custom_minimum_size = Vector2(80, 48)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_font_sizes/font_size = 16
|
theme_override_font_sizes/font_size = 16
|
||||||
toggle_mode = true
|
toggle_mode = true
|
||||||
|
|
@ -133,14 +141,14 @@ size_flags_horizontal = 3
|
||||||
|
|
||||||
[node name="UndoButton" type="Button" parent="Layout/TopBar/Tools"]
|
[node name="UndoButton" type="Button" parent="Layout/TopBar/Tools"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(120, 48)
|
custom_minimum_size = Vector2(100, 48)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_font_sizes/font_size = 16
|
theme_override_font_sizes/font_size = 16
|
||||||
text = "Rückgängig"
|
text = "Rückgängig"
|
||||||
|
|
||||||
[node name="FitButton" type="Button" parent="Layout/TopBar/Tools"]
|
[node name="FitButton" type="Button" parent="Layout/TopBar/Tools"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(110, 48)
|
custom_minimum_size = Vector2(96, 48)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_font_sizes/font_size = 16
|
theme_override_font_sizes/font_size = 16
|
||||||
text = "Einpassen"
|
text = "Einpassen"
|
||||||
|
|
@ -300,3 +308,73 @@ title = "Abschnitt löschen"
|
||||||
size = Vector2i(460, 160)
|
size = Vector2i(460, 160)
|
||||||
ok_button_text = "Löschen"
|
ok_button_text = "Löschen"
|
||||||
cancel_button_text = "Abbrechen"
|
cancel_button_text = "Abbrechen"
|
||||||
|
|
||||||
|
[node name="AutosaveTimer" type="Timer" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
wait_time = 1.5
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="SaveAsDialog" type="ConfirmationDialog" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
title = "Kür speichern unter"
|
||||||
|
size = Vector2i(460, 210)
|
||||||
|
ok_button_text = "Speichern"
|
||||||
|
cancel_button_text = "Abbrechen"
|
||||||
|
|
||||||
|
[node name="SaveAsBox" type="VBoxContainer" parent="SaveAsDialog"]
|
||||||
|
offset_left = 8.0
|
||||||
|
offset_top = 8.0
|
||||||
|
offset_right = 452.0
|
||||||
|
offset_bottom = 140.0
|
||||||
|
theme_override_constants/separation = 8
|
||||||
|
|
||||||
|
[node name="SaveAsLabel" type="Label" parent="SaveAsDialog/SaveAsBox"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Name der Kür"
|
||||||
|
|
||||||
|
[node name="SaveNameEdit" type="LineEdit" parent="SaveAsDialog/SaveAsBox"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
custom_minimum_size = Vector2(0, 48)
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="OpenDialog" type="AcceptDialog" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
title = "Kür öffnen"
|
||||||
|
size = Vector2i(520, 460)
|
||||||
|
ok_button_text = "Schließen"
|
||||||
|
|
||||||
|
[node name="OpenBox" type="VBoxContainer" parent="OpenDialog"]
|
||||||
|
offset_left = 8.0
|
||||||
|
offset_top = 8.0
|
||||||
|
offset_right = 512.0
|
||||||
|
offset_bottom = 390.0
|
||||||
|
theme_override_constants/separation = 8
|
||||||
|
|
||||||
|
[node name="OpenLabel" type="Label" parent="OpenDialog/OpenBox"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Gespeicherte Kürläufe"
|
||||||
|
|
||||||
|
[node name="OpenScroll" type="ScrollContainer" parent="OpenDialog/OpenBox"]
|
||||||
|
custom_minimum_size = Vector2(0, 300)
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
horizontal_scroll_mode = 0
|
||||||
|
|
||||||
|
[node name="OpenList" type="VBoxContainer" parent="OpenDialog/OpenBox/OpenScroll"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
theme_override_constants/separation = 6
|
||||||
|
|
||||||
|
[node name="ConfirmDialog" type="ConfirmationDialog" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
title = "Ungespeicherte Änderungen"
|
||||||
|
size = Vector2i(460, 160)
|
||||||
|
ok_button_text = "Verwerfen"
|
||||||
|
cancel_button_text = "Abbrechen"
|
||||||
|
|
||||||
|
[node name="MessageDialog" type="AcceptDialog" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
title = "Rinkplanner"
|
||||||
|
size = Vector2i(520, 180)
|
||||||
|
ok_button_text = "OK"
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@ extends Resource
|
||||||
## Root aggregate of a choreography. Pure data: no rendering, no input, no
|
## Root aggregate of a choreography. Pure data: no rendering, no input, no
|
||||||
## timing state. The whiteboard view and the future 3D layer both consume it.
|
## timing state. The whiteboard view and the future 3D layer both consume it.
|
||||||
|
|
||||||
|
const CURRENT_SCHEMA_VERSION := 1
|
||||||
|
|
||||||
|
@export var schema_version: int = CURRENT_SCHEMA_VERSION
|
||||||
@export var routine_id: String = ""
|
@export var routine_id: String = ""
|
||||||
@export var title: String = ""
|
@export var title: String = ""
|
||||||
@export var skater_name: String = ""
|
@export var skater_name: String = ""
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,23 @@ enum Tool {
|
||||||
ARC_RIGHT,
|
ARC_RIGHT,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum FileAction {
|
||||||
|
NEW,
|
||||||
|
OPEN,
|
||||||
|
SAVE,
|
||||||
|
SAVE_AS,
|
||||||
|
}
|
||||||
|
|
||||||
const DEFAULT_SPEED_MPS := 6.0
|
const DEFAULT_SPEED_MPS := 6.0
|
||||||
const MIN_SEGMENT_LENGTH_M := 0.3
|
const MIN_SEGMENT_LENGTH_M := 0.3
|
||||||
const EPSILON := 0.0001
|
const EPSILON := 0.0001
|
||||||
|
const ROUTINES_DIR := "user://routines"
|
||||||
|
const AUTOSAVE_PATH := "user://autosave.tres"
|
||||||
|
const AUTOSAVE_DELAY_SECONDS := 1.5
|
||||||
|
|
||||||
|
## Tests disable these before adding the scene to the tree.
|
||||||
|
@export var restore_autosave: bool = true
|
||||||
|
@export var autosave_enabled: bool = true
|
||||||
|
|
||||||
@onready var rink_canvas: RinkCanvas = %RinkCanvas
|
@onready var rink_canvas: RinkCanvas = %RinkCanvas
|
||||||
@onready var tool_option: OptionButton = %ToolOption
|
@onready var tool_option: OptionButton = %ToolOption
|
||||||
|
|
@ -34,6 +48,14 @@ const EPSILON := 0.0001
|
||||||
@onready var rename_dialog: ConfirmationDialog = %RenameDialog
|
@onready var rename_dialog: ConfirmationDialog = %RenameDialog
|
||||||
@onready var rename_edit: LineEdit = %RenameEdit
|
@onready var rename_edit: LineEdit = %RenameEdit
|
||||||
@onready var delete_dialog: ConfirmationDialog = %DeleteDialog
|
@onready var delete_dialog: ConfirmationDialog = %DeleteDialog
|
||||||
|
@onready var file_menu_button: MenuButton = %FileMenuButton
|
||||||
|
@onready var autosave_timer: Timer = %AutosaveTimer
|
||||||
|
@onready var save_as_dialog: ConfirmationDialog = %SaveAsDialog
|
||||||
|
@onready var save_name_edit: LineEdit = %SaveNameEdit
|
||||||
|
@onready var open_dialog: AcceptDialog = %OpenDialog
|
||||||
|
@onready var open_list: VBoxContainer = %OpenList
|
||||||
|
@onready var confirm_dialog: ConfirmationDialog = %ConfirmDialog
|
||||||
|
@onready var message_dialog: AcceptDialog = %MessageDialog
|
||||||
|
|
||||||
var _routine: Routine
|
var _routine: Routine
|
||||||
var _active_section: RoutineSection
|
var _active_section: RoutineSection
|
||||||
|
|
@ -45,27 +67,15 @@ var _section_buttons: Dictionary[String, Button] = {}
|
||||||
var _tool: Tool = Tool.LINE
|
var _tool: Tool = Tool.LINE
|
||||||
var _direction: PathSegment.Direction = PathSegment.Direction.FORWARD
|
var _direction: PathSegment.Direction = PathSegment.Direction.FORWARD
|
||||||
var _edge: PathSegment.Edge = PathSegment.Edge.OUTSIDE
|
var _edge: PathSegment.Edge = PathSegment.Edge.OUTSIDE
|
||||||
|
var _current_path: String = ""
|
||||||
|
var _dirty: bool = false
|
||||||
|
var _pending_action: Callable
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
_routine = Routine.new()
|
autosave_timer.wait_time = AUTOSAVE_DELAY_SECONDS
|
||||||
_routine.routine_id = "draft-routine"
|
|
||||||
_routine.title = "Neue Kür"
|
|
||||||
_routine.rink = RinkDimensions.new()
|
|
||||||
|
|
||||||
_active_section = RoutineSection.new()
|
|
||||||
_active_section.section_id = "section-001"
|
|
||||||
_active_section.title = "Abschnitt 1"
|
|
||||||
_active_section.sequence_order = 0
|
|
||||||
|
|
||||||
var sections: Array[RoutineSection] = []
|
|
||||||
sections.append(_active_section)
|
|
||||||
_routine.sections = sections
|
|
||||||
|
|
||||||
_setup_tool_options()
|
_setup_tool_options()
|
||||||
|
_setup_file_menu()
|
||||||
rink_canvas.set_routine(_routine)
|
|
||||||
rink_canvas.set_active_section(_active_section.section_id)
|
|
||||||
|
|
||||||
tool_option.item_selected.connect(_on_tool_selected)
|
tool_option.item_selected.connect(_on_tool_selected)
|
||||||
forward_button.pressed.connect(
|
forward_button.pressed.connect(
|
||||||
|
|
@ -97,8 +107,14 @@ func _ready() -> void:
|
||||||
rink_canvas.segment_handle_dragged.connect(_on_handle_dragged)
|
rink_canvas.segment_handle_dragged.connect(_on_handle_dragged)
|
||||||
rink_canvas.segment_handle_drag_finished.connect(_on_handle_drag_finished)
|
rink_canvas.segment_handle_drag_finished.connect(_on_handle_drag_finished)
|
||||||
|
|
||||||
_rebuild_section_list()
|
autosave_timer.timeout.connect(_on_autosave_timeout)
|
||||||
_update_status()
|
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)
|
||||||
|
|
||||||
|
_ensure_routines_dir()
|
||||||
|
if not (restore_autosave and _try_load_autosave()):
|
||||||
|
new_routine()
|
||||||
|
|
||||||
|
|
||||||
func get_routine() -> Routine:
|
func get_routine() -> Routine:
|
||||||
|
|
@ -109,6 +125,58 @@ func get_active_section() -> RoutineSection:
|
||||||
return _active_section
|
return _active_section
|
||||||
|
|
||||||
|
|
||||||
|
func get_current_path() -> String:
|
||||||
|
return _current_path
|
||||||
|
|
||||||
|
|
||||||
|
func is_dirty() -> bool:
|
||||||
|
return _dirty
|
||||||
|
|
||||||
|
|
||||||
|
func new_routine() -> void:
|
||||||
|
var routine := Routine.new()
|
||||||
|
routine.routine_id = "draft-routine"
|
||||||
|
routine.title = "Neue Kür"
|
||||||
|
routine.rink = RinkDimensions.new()
|
||||||
|
|
||||||
|
var section := RoutineSection.new()
|
||||||
|
section.section_id = "section-001"
|
||||||
|
section.title = "Abschnitt 1"
|
||||||
|
section.sequence_order = 0
|
||||||
|
|
||||||
|
var sections: Array[RoutineSection] = []
|
||||||
|
sections.append(section)
|
||||||
|
routine.sections = sections
|
||||||
|
|
||||||
|
_set_routine(routine, "")
|
||||||
|
|
||||||
|
|
||||||
|
func save_to_path(path: String) -> bool:
|
||||||
|
if _routine == null or path.is_empty():
|
||||||
|
return false
|
||||||
|
|
||||||
|
_ensure_routines_dir()
|
||||||
|
var error := ResourceSaver.save(_routine, path)
|
||||||
|
if error != OK:
|
||||||
|
_show_message("Speichern fehlgeschlagen: %s" % error_string(error))
|
||||||
|
return false
|
||||||
|
|
||||||
|
_current_path = path
|
||||||
|
_dirty = false
|
||||||
|
autosave_timer.stop()
|
||||||
|
_update_window_title()
|
||||||
|
_save_autosave()
|
||||||
|
return true
|
||||||
|
|
||||||
|
|
||||||
|
func load_from_path(path: String) -> bool:
|
||||||
|
var loaded := _read_routine(path)
|
||||||
|
if loaded == null:
|
||||||
|
return false
|
||||||
|
_set_routine(loaded, path)
|
||||||
|
return true
|
||||||
|
|
||||||
|
|
||||||
func get_tool() -> Tool:
|
func get_tool() -> Tool:
|
||||||
return _tool
|
return _tool
|
||||||
|
|
||||||
|
|
@ -127,6 +195,7 @@ func add_section() -> RoutineSection:
|
||||||
|
|
||||||
_routine.sections.append(section)
|
_routine.sections.append(section)
|
||||||
_renumber_sections()
|
_renumber_sections()
|
||||||
|
_mark_dirty()
|
||||||
_rebuild_section_list()
|
_rebuild_section_list()
|
||||||
set_active_section(section.section_id)
|
set_active_section(section.section_id)
|
||||||
return section
|
return section
|
||||||
|
|
@ -153,6 +222,7 @@ func rename_section(section_id: String, new_title: String) -> bool:
|
||||||
return false
|
return false
|
||||||
|
|
||||||
section.title = title
|
section.title = title
|
||||||
|
_mark_dirty()
|
||||||
_rebuild_section_list()
|
_rebuild_section_list()
|
||||||
_update_status()
|
_update_status()
|
||||||
return true
|
return true
|
||||||
|
|
@ -169,6 +239,7 @@ func delete_section(section_id: String) -> bool:
|
||||||
var was_active := section_id == _active_section.section_id
|
var was_active := section_id == _active_section.section_id
|
||||||
_routine.sections.remove_at(index)
|
_routine.sections.remove_at(index)
|
||||||
_renumber_sections()
|
_renumber_sections()
|
||||||
|
_mark_dirty()
|
||||||
|
|
||||||
if was_active:
|
if was_active:
|
||||||
var next_index := clampi(index, 0, _routine.sections.size() - 1)
|
var next_index := clampi(index, 0, _routine.sections.size() - 1)
|
||||||
|
|
@ -193,6 +264,7 @@ func move_section(section_id: String, delta: int) -> bool:
|
||||||
_routine.sections.remove_at(index)
|
_routine.sections.remove_at(index)
|
||||||
_routine.sections.insert(target, section)
|
_routine.sections.insert(target, section)
|
||||||
_renumber_sections()
|
_renumber_sections()
|
||||||
|
_mark_dirty()
|
||||||
_rebuild_section_list()
|
_rebuild_section_list()
|
||||||
_update_status()
|
_update_status()
|
||||||
return true
|
return true
|
||||||
|
|
@ -242,6 +314,7 @@ func add_segment(
|
||||||
var segment := _create_segment(start, direction, edge)
|
var segment := _create_segment(start, direction, edge)
|
||||||
_update_segment_geometry(segment, end, tool)
|
_update_segment_geometry(segment, end, tool)
|
||||||
_active_section.segments.append(segment)
|
_active_section.segments.append(segment)
|
||||||
|
_mark_dirty()
|
||||||
rink_canvas.refresh()
|
rink_canvas.refresh()
|
||||||
_update_status()
|
_update_status()
|
||||||
return segment
|
return segment
|
||||||
|
|
@ -259,6 +332,7 @@ func undo_last_segment() -> void:
|
||||||
_selected_segment_id = ""
|
_selected_segment_id = ""
|
||||||
rink_canvas.set_selected_segment("")
|
rink_canvas.set_selected_segment("")
|
||||||
|
|
||||||
|
_mark_dirty()
|
||||||
rink_canvas.refresh()
|
rink_canvas.refresh()
|
||||||
_update_status()
|
_update_status()
|
||||||
|
|
||||||
|
|
@ -270,6 +344,7 @@ func delete_selected_segment() -> bool:
|
||||||
|
|
||||||
_active_section.segments.erase(segment)
|
_active_section.segments.erase(segment)
|
||||||
_selected_segment_id = ""
|
_selected_segment_id = ""
|
||||||
|
_mark_dirty()
|
||||||
rink_canvas.set_selected_segment("")
|
rink_canvas.set_selected_segment("")
|
||||||
rink_canvas.refresh()
|
rink_canvas.refresh()
|
||||||
_update_status()
|
_update_status()
|
||||||
|
|
@ -334,6 +409,7 @@ func _on_direction_pressed(direction: PathSegment.Direction) -> void:
|
||||||
var selected := get_selected_segment()
|
var selected := get_selected_segment()
|
||||||
if selected != null:
|
if selected != null:
|
||||||
selected.direction = direction
|
selected.direction = direction
|
||||||
|
_mark_dirty()
|
||||||
rink_canvas.refresh()
|
rink_canvas.refresh()
|
||||||
_update_status()
|
_update_status()
|
||||||
|
|
||||||
|
|
@ -345,6 +421,7 @@ func _on_edge_pressed(edge: PathSegment.Edge) -> void:
|
||||||
var selected := get_selected_segment()
|
var selected := get_selected_segment()
|
||||||
if selected != null:
|
if selected != null:
|
||||||
selected.edge = edge
|
selected.edge = edge
|
||||||
|
_mark_dirty()
|
||||||
rink_canvas.refresh()
|
rink_canvas.refresh()
|
||||||
_update_status()
|
_update_status()
|
||||||
|
|
||||||
|
|
@ -369,10 +446,14 @@ func _on_draw_finished(model_point: Vector2) -> void:
|
||||||
return
|
return
|
||||||
|
|
||||||
_update_segment_geometry(_current_segment, model_point, _tool)
|
_update_segment_geometry(_current_segment, model_point, _tool)
|
||||||
|
var kept := true
|
||||||
if _current_segment.get_length_m() < MIN_SEGMENT_LENGTH_M:
|
if _current_segment.get_length_m() < MIN_SEGMENT_LENGTH_M:
|
||||||
_active_section.segments.erase(_current_segment)
|
_active_section.segments.erase(_current_segment)
|
||||||
|
kept = false
|
||||||
|
|
||||||
_current_segment = null
|
_current_segment = null
|
||||||
|
if kept:
|
||||||
|
_mark_dirty()
|
||||||
rink_canvas.refresh()
|
rink_canvas.refresh()
|
||||||
_update_status()
|
_update_status()
|
||||||
|
|
||||||
|
|
@ -414,6 +495,7 @@ func _on_handle_dragged(
|
||||||
return
|
return
|
||||||
|
|
||||||
_apply_handle_drag(segment, handle, model_point)
|
_apply_handle_drag(segment, handle, model_point)
|
||||||
|
_mark_dirty()
|
||||||
rink_canvas.refresh()
|
rink_canvas.refresh()
|
||||||
_update_status()
|
_update_status()
|
||||||
|
|
||||||
|
|
@ -567,6 +649,277 @@ func _update_duration(segment: PathSegment) -> void:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func _setup_file_menu() -> void:
|
||||||
|
var popup := file_menu_button.get_popup()
|
||||||
|
popup.add_item("Neu", FileAction.NEW)
|
||||||
|
popup.add_item("Öffnen…", FileAction.OPEN)
|
||||||
|
popup.add_separator()
|
||||||
|
popup.add_item("Speichern", FileAction.SAVE)
|
||||||
|
popup.add_item("Speichern unter…", FileAction.SAVE_AS)
|
||||||
|
popup.id_pressed.connect(_on_file_menu_pressed)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_file_menu_pressed(action: int) -> void:
|
||||||
|
match action:
|
||||||
|
FileAction.NEW:
|
||||||
|
_request_document_change(new_routine)
|
||||||
|
FileAction.OPEN:
|
||||||
|
_open_open_dialog()
|
||||||
|
FileAction.SAVE:
|
||||||
|
_save_or_prompt()
|
||||||
|
FileAction.SAVE_AS:
|
||||||
|
_open_save_as_dialog()
|
||||||
|
|
||||||
|
|
||||||
|
func _set_routine(routine: Routine, path: String) -> void:
|
||||||
|
rink_canvas.cancel_interaction()
|
||||||
|
|
||||||
|
_routine = routine
|
||||||
|
if _routine.rink == null or not _routine.rink.is_valid():
|
||||||
|
_routine.rink = RinkDimensions.new()
|
||||||
|
|
||||||
|
var valid_sections: Array[RoutineSection] = []
|
||||||
|
for section: RoutineSection in _routine.sections:
|
||||||
|
if section != null:
|
||||||
|
valid_sections.append(section)
|
||||||
|
_routine.sections = valid_sections
|
||||||
|
|
||||||
|
if _routine.sections.is_empty():
|
||||||
|
var fallback := RoutineSection.new()
|
||||||
|
fallback.section_id = "section-001"
|
||||||
|
fallback.title = "Abschnitt 1"
|
||||||
|
fallback.sequence_order = 0
|
||||||
|
_routine.sections.append(fallback)
|
||||||
|
|
||||||
|
_renumber_sections()
|
||||||
|
_active_section = _routine.sections[0]
|
||||||
|
_selected_segment_id = ""
|
||||||
|
_current_segment = null
|
||||||
|
_current_path = path
|
||||||
|
_dirty = false
|
||||||
|
autosave_timer.stop()
|
||||||
|
_rebuild_counters_from_ids()
|
||||||
|
|
||||||
|
rink_canvas.set_routine(_routine)
|
||||||
|
rink_canvas.set_selected_segment("")
|
||||||
|
rink_canvas.set_active_section(_active_section.section_id)
|
||||||
|
_rebuild_section_list()
|
||||||
|
_update_window_title()
|
||||||
|
_update_status()
|
||||||
|
_save_autosave()
|
||||||
|
|
||||||
|
|
||||||
|
func _rebuild_counters_from_ids() -> void:
|
||||||
|
var section_ids: Array[String] = []
|
||||||
|
var segment_ids: Array[String] = []
|
||||||
|
for section: RoutineSection in _routine.sections:
|
||||||
|
section_ids.append(section.section_id)
|
||||||
|
for segment: PathSegment in section.segments:
|
||||||
|
if segment != null:
|
||||||
|
segment_ids.append(segment.segment_id)
|
||||||
|
|
||||||
|
_section_counter = maxi(1, _max_numeric_suffix("section-", section_ids))
|
||||||
|
_segment_counter = _max_numeric_suffix("seg-", segment_ids)
|
||||||
|
|
||||||
|
|
||||||
|
func _max_numeric_suffix(prefix: String, ids: Array[String]) -> int:
|
||||||
|
var maximum := 0
|
||||||
|
for id: String in ids:
|
||||||
|
if not id.begins_with(prefix):
|
||||||
|
continue
|
||||||
|
var suffix := id.substr(prefix.length())
|
||||||
|
if suffix.is_valid_int():
|
||||||
|
maximum = maxi(maximum, suffix.to_int())
|
||||||
|
return maximum
|
||||||
|
|
||||||
|
|
||||||
|
func _read_routine(path: String, show_error: bool = true) -> Routine:
|
||||||
|
if not FileAccess.file_exists(path):
|
||||||
|
if show_error:
|
||||||
|
_show_message("Datei nicht gefunden:\n%s" % path)
|
||||||
|
return null
|
||||||
|
|
||||||
|
var resource := ResourceLoader.load(path, "", ResourceLoader.CACHE_MODE_IGNORE)
|
||||||
|
if not (resource is Routine):
|
||||||
|
if show_error:
|
||||||
|
_show_message("Die Datei enthält keine gültige Rinkplanner-Kür.")
|
||||||
|
return null
|
||||||
|
|
||||||
|
var routine := resource as Routine
|
||||||
|
if routine.schema_version > Routine.CURRENT_SCHEMA_VERSION:
|
||||||
|
if show_error:
|
||||||
|
_show_message(
|
||||||
|
"Die Datei wurde mit einer neueren Version erstellt (Schema %d)."
|
||||||
|
% routine.schema_version
|
||||||
|
)
|
||||||
|
return null
|
||||||
|
|
||||||
|
return routine
|
||||||
|
|
||||||
|
|
||||||
|
func _try_load_autosave() -> bool:
|
||||||
|
if not FileAccess.file_exists(AUTOSAVE_PATH):
|
||||||
|
return false
|
||||||
|
|
||||||
|
var loaded := _read_routine(AUTOSAVE_PATH, false)
|
||||||
|
if loaded == null:
|
||||||
|
return false
|
||||||
|
|
||||||
|
_set_routine(loaded, "")
|
||||||
|
return true
|
||||||
|
|
||||||
|
|
||||||
|
func _ensure_routines_dir() -> void:
|
||||||
|
if not DirAccess.dir_exists_absolute(ROUTINES_DIR):
|
||||||
|
DirAccess.make_dir_recursive_absolute(ROUTINES_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
func _save_autosave() -> void:
|
||||||
|
if not autosave_enabled or _routine == null:
|
||||||
|
return
|
||||||
|
|
||||||
|
_ensure_routines_dir()
|
||||||
|
ResourceSaver.save(_routine, AUTOSAVE_PATH)
|
||||||
|
|
||||||
|
|
||||||
|
func _mark_dirty() -> void:
|
||||||
|
if _routine == null:
|
||||||
|
return
|
||||||
|
|
||||||
|
_dirty = true
|
||||||
|
if autosave_enabled:
|
||||||
|
autosave_timer.start()
|
||||||
|
_update_window_title()
|
||||||
|
|
||||||
|
|
||||||
|
func _update_window_title() -> void:
|
||||||
|
if _routine == null:
|
||||||
|
return
|
||||||
|
|
||||||
|
var title := _routine.title.strip_edges()
|
||||||
|
if title.is_empty():
|
||||||
|
title = "Unbenannte Kür"
|
||||||
|
var dirty_marker := " *" if _dirty else ""
|
||||||
|
get_window().title = "Rinkplanner – %s%s" % [title, dirty_marker]
|
||||||
|
|
||||||
|
|
||||||
|
func _on_autosave_timeout() -> void:
|
||||||
|
_save_autosave()
|
||||||
|
|
||||||
|
|
||||||
|
func _notification(what: int) -> void:
|
||||||
|
if what == NOTIFICATION_WM_CLOSE_REQUEST:
|
||||||
|
_save_autosave()
|
||||||
|
|
||||||
|
|
||||||
|
func _save_or_prompt() -> void:
|
||||||
|
if _routine == null:
|
||||||
|
return
|
||||||
|
if _current_path.is_empty():
|
||||||
|
_open_save_as_dialog()
|
||||||
|
else:
|
||||||
|
save_to_path(_current_path)
|
||||||
|
|
||||||
|
|
||||||
|
func _open_save_as_dialog() -> void:
|
||||||
|
if _routine == null:
|
||||||
|
return
|
||||||
|
save_name_edit.text = _routine.title
|
||||||
|
save_as_dialog.popup_centered(Vector2i(460, 210))
|
||||||
|
save_name_edit.grab_focus()
|
||||||
|
save_name_edit.select_all()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_save_as_confirmed() -> void:
|
||||||
|
var name := save_name_edit.text.strip_edges()
|
||||||
|
if name.is_empty():
|
||||||
|
_show_message("Bitte einen Namen für die Kür eingeben.")
|
||||||
|
return
|
||||||
|
|
||||||
|
var stem := _normalize_file_stem(name)
|
||||||
|
_routine.title = name
|
||||||
|
if _routine.routine_id.is_empty() or _routine.routine_id == "draft-routine":
|
||||||
|
_routine.routine_id = stem
|
||||||
|
|
||||||
|
save_to_path(ROUTINES_DIR.path_join(stem + ".tres"))
|
||||||
|
|
||||||
|
|
||||||
|
func _open_open_dialog() -> void:
|
||||||
|
_refresh_open_list()
|
||||||
|
open_dialog.popup_centered(Vector2i(520, 460))
|
||||||
|
|
||||||
|
|
||||||
|
func _refresh_open_list() -> void:
|
||||||
|
for child: Node in open_list.get_children():
|
||||||
|
child.free()
|
||||||
|
_ensure_routines_dir()
|
||||||
|
|
||||||
|
var entries: Array[String] = []
|
||||||
|
for file: String in DirAccess.get_files_at(ROUTINES_DIR):
|
||||||
|
if file.ends_with(".tres"):
|
||||||
|
entries.append(file)
|
||||||
|
entries.sort()
|
||||||
|
|
||||||
|
for file: String in entries:
|
||||||
|
var button := Button.new()
|
||||||
|
button.text = file.get_basename()
|
||||||
|
button.custom_minimum_size = Vector2(0.0, 48.0)
|
||||||
|
button.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||||
|
button.clip_text = true
|
||||||
|
button.pressed.connect(
|
||||||
|
_on_open_file_pressed.bind(ROUTINES_DIR.path_join(file))
|
||||||
|
)
|
||||||
|
open_list.add_child(button)
|
||||||
|
|
||||||
|
if entries.is_empty():
|
||||||
|
var label := Label.new()
|
||||||
|
label.text = "Keine gespeicherten Kürläufe"
|
||||||
|
open_list.add_child(label)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_open_file_pressed(path: String) -> void:
|
||||||
|
open_dialog.hide()
|
||||||
|
_request_document_change(load_from_path.bind(path))
|
||||||
|
|
||||||
|
|
||||||
|
func _request_document_change(action: Callable) -> void:
|
||||||
|
if not action.is_valid():
|
||||||
|
return
|
||||||
|
if not _dirty:
|
||||||
|
action.call()
|
||||||
|
return
|
||||||
|
|
||||||
|
_pending_action = action
|
||||||
|
confirm_dialog.dialog_text = "Ungespeicherte Änderungen verwerfen?"
|
||||||
|
confirm_dialog.popup_centered(Vector2i(460, 170))
|
||||||
|
|
||||||
|
|
||||||
|
func _on_confirm_discard_confirmed() -> void:
|
||||||
|
var action := _pending_action
|
||||||
|
_pending_action = Callable()
|
||||||
|
if action.is_valid():
|
||||||
|
action.call()
|
||||||
|
|
||||||
|
|
||||||
|
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:
|
||||||
|
message_dialog.dialog_text = text
|
||||||
|
message_dialog.popup_centered(Vector2i(520, 180))
|
||||||
|
|
||||||
|
|
||||||
func _rebuild_section_list() -> void:
|
func _rebuild_section_list() -> void:
|
||||||
for child: Node in section_list.get_children():
|
for child: Node in section_list.get_children():
|
||||||
child.free()
|
child.free()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
Headless tests for the Phase 1 model. They require no editor and no display.
|
Headless tests for the Phase 1 model, canvas and whiteboard controller. They
|
||||||
|
require no editor and no display. `tools/test.sh` isolates `user://` in a
|
||||||
|
temporary `XDG_DATA_HOME`, so tests never touch real autosaves or routines.
|
||||||
|
|
||||||
From the repository root:
|
From the repository root:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,10 @@ func _test_section_aggregation() -> void:
|
||||||
func _test_routine_validation() -> void:
|
func _test_routine_validation() -> void:
|
||||||
var routine: Routine = _make_routine()
|
var routine: Routine = _make_routine()
|
||||||
|
|
||||||
|
_check(
|
||||||
|
routine.schema_version == Routine.CURRENT_SCHEMA_VERSION,
|
||||||
|
"new routines use the current schema version"
|
||||||
|
)
|
||||||
_check(routine.is_valid(), "complete routine is valid")
|
_check(routine.is_valid(), "complete routine is valid")
|
||||||
_check(routine.validate().is_empty(), "valid routine reports no errors")
|
_check(routine.validate().is_empty(), "valid routine reports no errors")
|
||||||
_check_approx(routine.get_duration_seconds(), 9.5, "routine duration sums all sections")
|
_check_approx(routine.get_duration_seconds(), 9.5, "routine duration sums all sections")
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,13 @@ func _init() -> void:
|
||||||
|
|
||||||
func _run() -> void:
|
func _run() -> void:
|
||||||
var scene := WhiteboardScene.instantiate()
|
var scene := WhiteboardScene.instantiate()
|
||||||
|
var controller := scene as WhiteboardController
|
||||||
|
if controller != null:
|
||||||
|
controller.restore_autosave = false
|
||||||
|
controller.autosave_enabled = false
|
||||||
root.add_child(scene)
|
root.add_child(scene)
|
||||||
await process_frame
|
await process_frame
|
||||||
|
|
||||||
var controller := scene as WhiteboardController
|
|
||||||
_check(controller != null, "whiteboard scene has a controller")
|
_check(controller != null, "whiteboard scene has a controller")
|
||||||
if controller == null:
|
if controller == null:
|
||||||
_finish()
|
_finish()
|
||||||
|
|
@ -535,6 +538,91 @@ func _run() -> void:
|
||||||
"rename dialog applies the edited title"
|
"rename dialog applies the edited title"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Save/load round-trip.
|
||||||
|
var roundtrip_path := "user://test_roundtrip.tres"
|
||||||
|
var saved_section_title := controller.get_active_section().title
|
||||||
|
var saved_segment_count := controller.get_active_section().segments.size()
|
||||||
|
var saved_arc_id := arc_left.segment_id
|
||||||
|
var saved_arc_depth := arc_left.arc_depth_ratio
|
||||||
|
var saved_arc_left := arc_left.arc_bulge_left
|
||||||
|
|
||||||
|
_check(controller.save_to_path(roundtrip_path), "routine can be saved")
|
||||||
|
_check(not controller.is_dirty(), "saving clears the dirty flag")
|
||||||
|
_check(
|
||||||
|
FileAccess.file_exists(roundtrip_path),
|
||||||
|
"save creates a routine file"
|
||||||
|
)
|
||||||
|
|
||||||
|
controller.add_section()
|
||||||
|
_check(controller.is_dirty(), "changes mark the routine dirty")
|
||||||
|
|
||||||
|
_check(controller.load_from_path(roundtrip_path), "routine can be loaded")
|
||||||
|
_check(
|
||||||
|
controller.get_routine().sections.size() == 1,
|
||||||
|
"load restores the section count"
|
||||||
|
)
|
||||||
|
_check(
|
||||||
|
controller.get_active_section().title == saved_section_title,
|
||||||
|
"load restores the section title"
|
||||||
|
)
|
||||||
|
_check(
|
||||||
|
controller.get_active_section().segments.size() == saved_segment_count,
|
||||||
|
"load restores all segments"
|
||||||
|
)
|
||||||
|
_check(not controller.is_dirty(), "loading clears the dirty flag")
|
||||||
|
|
||||||
|
var loaded_arc := controller.get_active_section().get_segment_by_id(
|
||||||
|
saved_arc_id
|
||||||
|
)
|
||||||
|
_check(loaded_arc != null, "loaded segments keep their ids")
|
||||||
|
if loaded_arc != null:
|
||||||
|
_check(
|
||||||
|
loaded_arc.template == PathSegment.Template.ARC,
|
||||||
|
"load restores the arc template"
|
||||||
|
)
|
||||||
|
_check_approx(
|
||||||
|
loaded_arc.arc_depth_ratio,
|
||||||
|
saved_arc_depth,
|
||||||
|
"load restores the arc depth"
|
||||||
|
)
|
||||||
|
_check(
|
||||||
|
loaded_arc.arc_bulge_left == saved_arc_left,
|
||||||
|
"load restores the arc side"
|
||||||
|
)
|
||||||
|
_check(
|
||||||
|
loaded_arc.curve.point_count > 2,
|
||||||
|
"load restores the sampled arc curve"
|
||||||
|
)
|
||||||
|
|
||||||
|
DirAccess.remove_absolute(roundtrip_path)
|
||||||
|
|
||||||
|
var too_new_path := "user://test_too_new.tres"
|
||||||
|
var too_new: Routine = controller.get_routine().duplicate(true)
|
||||||
|
too_new.schema_version = Routine.CURRENT_SCHEMA_VERSION + 1
|
||||||
|
ResourceSaver.save(too_new, too_new_path)
|
||||||
|
_check(
|
||||||
|
not controller.load_from_path(too_new_path),
|
||||||
|
"newer schema versions are rejected"
|
||||||
|
)
|
||||||
|
DirAccess.remove_absolute(too_new_path)
|
||||||
|
|
||||||
|
controller.save_name_edit.text = "Test Kür"
|
||||||
|
controller.save_as_dialog.confirmed.emit()
|
||||||
|
var save_as_path := "user://routines/test_kür.tres"
|
||||||
|
_check(
|
||||||
|
FileAccess.file_exists(save_as_path),
|
||||||
|
"save-as dialog writes a normalized filename"
|
||||||
|
)
|
||||||
|
_check(
|
||||||
|
controller.get_routine().title == "Test Kür",
|
||||||
|
"save-as dialog updates the routine title"
|
||||||
|
)
|
||||||
|
_check(
|
||||||
|
controller.get_current_path() == save_as_path,
|
||||||
|
"save-as dialog becomes the current file"
|
||||||
|
)
|
||||||
|
DirAccess.remove_absolute(save_as_path)
|
||||||
|
|
||||||
scene.queue_free()
|
scene.queue_free()
|
||||||
await process_frame
|
await process_frame
|
||||||
_finish()
|
_finish()
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,11 @@ REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
PROJECT_DIR="$REPO_ROOT/rinkplanner"
|
PROJECT_DIR="$REPO_ROOT/rinkplanner"
|
||||||
GODOT="${GODOT:-/opt/godot/Godot_v4.7.2-stable_linux.x86_64}"
|
GODOT="${GODOT:-/opt/godot/Godot_v4.7.2-stable_linux.x86_64}"
|
||||||
|
|
||||||
|
# Isolate user:// so tests never touch the real autosave or saved routines.
|
||||||
|
TEST_DATA_HOME="$(mktemp -d "${TMPDIR:-/tmp}/rinkplanner-tests.XXXXXX")"
|
||||||
|
trap 'rm -rf "$TEST_DATA_HOME"' EXIT
|
||||||
|
export XDG_DATA_HOME="$TEST_DATA_HOME"
|
||||||
|
|
||||||
if [[ ! -x "$GODOT" ]]; then
|
if [[ ! -x "$GODOT" ]]; then
|
||||||
echo "Godot binary not found: $GODOT" >&2
|
echo "Godot binary not found: $GODOT" >&2
|
||||||
echo "Set GODOT=/path/to/godot" >&2
|
echo "Set GODOT=/path/to/godot" >&2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue