feat: Sport-Theme, Küren-Verwaltung und Sync-Konflikte

- zentrales Sport-Theme für das Weißbrett
- Küren im Sync umbenennen, löschen und Musikzuordnung aufräumen
- Konfliktbereinigung mit Vorschau und gezieltem Löschen
- Sync nutzt saved_at aus der Kür statt Gerätezeit
- Schrittsequenzen über Mehrfachauswahl gruppieren
- Startskript aktualisiert den class_name-Cache bei Änderungen
This commit is contained in:
torsten 2026-11-11 13:14:14 +01:00
parent dbcba27ebd
commit 6172d311bc
25 changed files with 2993 additions and 820 deletions

View file

@ -279,6 +279,15 @@ func _test_atomic_write() -> void:
_check(FileAccess.file_exists(JSON_PATH), "JSON file exists")
_check(not FileAccess.file_exists(JSON_PATH + ".tmp"), "no temp file remains")
_check(not FileAccess.file_exists(JSON_PATH + ".bak"), "no backup remains")
_check(routine.saved_at > 0, "saving stamps the routine content time")
_check(
RoutineFile.read_saved_at(JSON_PATH) == routine.saved_at,
"the content timestamp can be read without loading the routine"
)
_check(
RoutineFile.read_music_file(JSON_PATH) == routine.music_file,
"the music attachment can be read without loading the routine"
)
routine.title = "Zweite Fassung"
_check(
@ -291,6 +300,10 @@ func _test_atomic_write() -> void:
loaded != null and loaded.title == "Zweite Fassung",
"atomic replacement writes the new content"
)
_check(
loaded != null and loaded.saved_at == routine.saved_at,
"the content timestamp survives a save/load roundtrip"
)
func _test_legacy_roundtrip() -> void:

View file

@ -189,10 +189,10 @@ func _run() -> void:
controller._section_buttons[section_two.section_id].text.begins_with("▶ "),
"section list marks the second section"
)
controller.rink_canvas._process(2.1)
controller.rink_canvas._process(2.7)
_check(
controller.rink_canvas.get_section_banner_text().is_empty(),
"section banner fades out within two seconds"
"section banner fades out after its display time"
)
_check(
controller.rink_canvas.get_section_banner_alpha() == 0.0,
@ -545,7 +545,7 @@ func _run() -> void:
DirAccess.remove_absolute(ProjectSettings.globalize_path(old_path))
_write_test_wav(music_source)
_check(
controller.load_music_from_path(music_source),
await controller.load_music_from_path(music_source),
"music file is loaded into the routine"
)
_check(
@ -562,9 +562,9 @@ func _run() -> void:
"playback bar shows the music file"
)
# Loading the very same track again must not create a numbered duplicate.
# Loading the very same track again must not create a duplicate.
_check(
controller.load_music_from_path(music_source),
await controller.load_music_from_path(music_source),
"the same music file can be loaded again"
)
_check(
@ -576,36 +576,70 @@ func _run() -> void:
"reloading identical music creates no numbered duplicate"
)
# A different track with the same name still gets its own numbered copy.
# A different track with the same name opens a decision dialog. Choosing
# the existing file must not overwrite it or create a numbered copy.
var alt_dir := "user://music_alt"
DirAccess.make_dir_recursive_absolute(
ProjectSettings.globalize_path(alt_dir)
)
var alt_source := alt_dir.path_join("test_music.wav")
_write_test_wav(alt_source, 16000)
controller.load_music_from_path(alt_source)
await process_frame
_check(
controller.load_music_from_path(alt_source),
"a different track with the same name loads"
)
_check(
controller.get_music_file_name() == "test_music 2.wav",
"a different track is stored under a numbered name"
)
_check(
controller.load_music_from_path(alt_source),
"the numbered track can be loaded again"
)
_check(
controller.get_music_file_name() == "test_music 2.wav",
"reloading the numbered track keeps its name"
)
_check(
controller.load_music_from_path(music_source),
"switching back to the first track works"
controller.music_conflict_dialog.visible,
"a different track with the same name opens a decision dialog"
)
controller._decide_music_conflict("use_existing")
await process_frame
_check(
controller.get_music_file_name() == "test_music.wav",
"switching back reuses the existing first copy"
"keeping the existing file uses the known name"
)
_check(
not FileAccess.file_exists("user://routines/test_music 2.wav"),
"keeping the existing file creates no numbered duplicate"
)
# Overwriting replaces the existing file under the same name.
controller.load_music_from_path(alt_source)
await process_frame
_check(
controller.music_conflict_dialog.visible,
"the decision dialog appears again for the same name"
)
controller._decide_music_conflict("replace")
await process_frame
_check(
controller.get_music_file_name() == "test_music.wav",
"overwriting keeps the clean file name"
)
_check(
FileAccess.get_sha256("user://routines/test_music.wav")
== FileAccess.get_sha256(alt_source),
"overwriting replaces the existing music content"
)
_check(
not FileAccess.file_exists("user://routines/test_music 2.wav"),
"overwriting creates no numbered duplicate"
)
# Cancel leaves the current file untouched.
var before_cancel_hash := FileAccess.get_sha256(
"user://routines/test_music.wav"
)
controller.load_music_from_path(music_source)
await process_frame
_check(
controller.music_conflict_dialog.visible,
"the decision dialog appears for the original track again"
)
controller._decide_music_conflict("cancel")
await process_frame
_check(
FileAccess.get_sha256("user://routines/test_music.wav")
== before_cancel_hash,
"cancelling the decision leaves the existing file untouched"
)
controller.seek_playback(0.5)

View file

@ -9,6 +9,46 @@ extends SceneTree
const WhiteboardScene := preload("res://scenes/whiteboard/whiteboard.tscn")
## Minimal in-memory cloud used to exercise the newest-wins resolution without
## network access.
class FakeRemoteStore extends RemoteStore:
var remote_files: Dictionary = {}
var uploads: Array[String] = []
var deleted: Array[String] = []
var renames: Array[Dictionary] = []
func download(remote_name: String, local_path: String) -> String:
if not remote_files.has(remote_name):
return "Datei fehlt in der Test-Cloud"
var file := FileAccess.open(local_path, FileAccess.WRITE)
if file == null:
return "Temporäre Datei nicht schreibbar"
file.store_string(str(remote_files[remote_name]))
file.close()
return ""
func upload(local_path: String, remote_name: String) -> String:
var file := FileAccess.open(local_path, FileAccess.READ)
if file == null:
return "Lokale Datei nicht lesbar"
remote_files[remote_name] = file.get_as_text()
file.close()
uploads.append(remote_name)
return ""
func delete_file(remote_name: String) -> String:
deleted.append(remote_name)
remote_files.erase(remote_name)
return ""
func rename(from_name: String, to_name: String) -> String:
if not remote_files.has(from_name):
return "Datei fehlt in der Test-Cloud"
remote_files[to_name] = remote_files[from_name]
remote_files.erase(from_name)
renames.append({"from": from_name, "to": to_name})
return ""
var _assertions: int = 0
var _failures: PackedStringArray = PackedStringArray()
@ -19,7 +59,11 @@ func _init() -> void:
func _run() -> void:
_test_plan()
_test_naming()
_test_resolution()
_test_resolution_files()
_test_cleanup_files()
_test_delete_files()
_test_rename_files()
_test_cloud_helpers()
_test_app_config()
_test_state_roundtrip()
@ -91,32 +135,58 @@ func _test_plan() -> void:
)
func _test_naming() -> void:
func _test_resolution() -> void:
_check(
SyncPlan.conflict_file_name("kuer.json", "2026-10-30 1050")
== "kuer (Server 2026-10-30 1050).json",
"Konfliktname enthält Zeitstempel"
)
var used := {"kuer (Server 2026-10-30 1050).json": true}
_check(
SyncPlan.unique_name("kuer (Server 2026-10-30 1050).json", used)
== "kuer (Server 2026-10-30 1050) 2.json",
"Konfliktname wird bei Bedarf durchnummeriert"
SyncPlan.remote_wins(100, 200, false),
"die neuere Cloud-Fassung gewinnt"
)
_check(
SyncPlan.unique_name("frei.json", used) == "frei.json",
"freier Name bleibt unverändert"
not SyncPlan.remote_wins(200, 100, true),
"die neuere lokale Fassung gewinnt"
)
_check(
SyncPlan.local_backup_file_name("kuer.json", "2026-10-30 1050")
== "kuer (Lokal 2026-10-30 1050).json",
"lokale Sicherung trägt den Lokal-Zeitstempel"
SyncPlan.remote_wins(100, 100, true),
"Gleichstand beim ersten Sync übernimmt die Cloud"
)
_check(
SyncPlan.conflict_file_name("alt.tres", "2026-10-30 1050")
== "alt (Server 2026-10-30 1050).tres",
"Legacy-Dateien behalten ihre .tres-Endung"
not SyncPlan.remote_wins(100, 100, false),
"Gleichstand im Konflikt behält die lokale Fassung"
)
_check(
SyncPlan.remote_wins(0, 0, true),
"unbekannte Zeiten fallen beim ersten Sync auf die Cloud zurück"
)
_check(
RoutineSync.archive_path("kuer.json")
== "user://conflicts/kuer.json",
"das Konfliktarchiv liegt außerhalb der Kürliste"
)
_check(
RoutineSync.archive_path("kuer.mp3")
== "user://conflicts/kuer.mp3",
"Audio-Konflikte behalten ihren Dateinamen im Archiv"
)
_check(
SyncPlan.old_conflict_base("kuer (Server 2026-10-30 1050).json")
== "kuer.json",
"alte Server-Kopien werden erkannt"
)
_check(
SyncPlan.old_conflict_base("kuer (Lokal 2026-10-30 1050) 2.mp3")
== "kuer.mp3",
"alte Lokal-Kopien mit Nummer werden erkannt"
)
_check(
SyncPlan.old_conflict_base(
"kuer (Server 2026-10-30 1050) (Lokal 2026-10-31 1200).json"
) == "kuer.json",
"mehrfach gestapelte Konfliktkopien werden aufgelöst"
)
_check(
SyncPlan.old_conflict_base("kuer.json").is_empty(),
"normale Kürnamen gelten nicht als Konfliktkopie"
)
_check(
RoutineSync.is_routine_file("kuer.json")
and RoutineSync.is_routine_file("alt.tres")
@ -130,11 +200,6 @@ func _test_naming() -> void:
and not RoutineSync.is_synced_file("notizen.txt"),
"der Sync akzeptiert Musikdateien der Kür"
)
_check(
SyncPlan.conflict_file_name("kuer.mp3", "2026-10-30 1050")
== "kuer (Server 2026-10-30 1050).mp3",
"Konfliktnamen behalten die Audio-Endung"
)
var label := SyncPlan.timestamp_label(0)
_check(
label.length() == 15 and label.contains("-") and label.contains(" "),
@ -142,6 +207,323 @@ func _test_naming() -> void:
)
func _test_resolution_files() -> void:
DirAccess.make_dir_recursive_absolute(
ProjectSettings.globalize_path(RoutineSync.LOCAL_DIR)
)
var names: Array[String] = []
names.append(_check_resolution(
"sync-test-local-newer.json", 200, "lokal", 100, "cloud", false,
"lokal", true
))
names.append(_check_resolution(
"sync-test-cloud-newer.json", 100, "lokal", 200, "cloud", false,
"cloud", false
))
names.append(_check_resolution(
"sync-test-tie-first.json", 100, "lokal", 100, "cloud", true,
"cloud", false
))
names.append(_check_resolution(
"sync-test-tie-conflict.json", 100, "lokal", 100, "cloud", false,
"lokal", true
))
for name: String in names:
for path: String in [
RoutineSync.LOCAL_DIR.path_join(name),
RoutineSync.archive_path(name),
]:
if FileAccess.file_exists(path):
DirAccess.remove_absolute(ProjectSettings.globalize_path(path))
DirAccess.remove_absolute(
ProjectSettings.globalize_path(RoutineSync.CONFLICT_DIR)
)
## Runs one resolution case and returns the file name for cleanup.
func _check_resolution(
name: String,
local_saved_at: int,
local_title: String,
remote_saved_at: int,
remote_title: String,
prefer_server: bool,
expected_main: String,
expect_upload: bool
) -> String:
var local_path := RoutineSync.LOCAL_DIR.path_join(name)
_write_text(local_path, _routine_content(local_saved_at, local_title))
var store := FakeRemoteStore.new()
store.remote_files[name] = _routine_content(remote_saved_at, remote_title)
var job := RoutineSync.new()
job.result = {
"uploaded": [],
"downloaded": [],
"resolved": [],
}
var err := job._resolve_newest(store, name, 0, prefer_server)
_check(err.is_empty(), "%s wird ohne Fehler aufgelöst" % name)
_check(
_routine_title(local_path) == expected_main,
"%s behält die neuere Fassung (%s)" % [name, expected_main]
)
_check(
job.result["uploaded"].has(name) == expect_upload,
"%s lädt die lokale Fassung genau dann hoch, wenn sie gewinnt" % name
)
var archived := RoutineSync.archive_path(name)
_check(
FileAccess.file_exists(archived),
"%s legt die unterlegene Fassung ins Konfliktarchiv" % name
)
if FileAccess.file_exists(archived):
var expected_archive := (
remote_title if expect_upload else local_title
)
_check(
_routine_title(archived) == expected_archive,
"%s archiviert die unterlegene Fassung" % name
)
return name
func _routine_content(saved_at: int, title: String, music: String = "") -> String:
var routine := Routine.new()
routine.routine_id = "sync-test"
routine.title = title
routine.saved_at = saved_at
routine.music_file = music
return RoutineFile.encode(routine)
func _write_text(path: String, content: String) -> void:
var file := FileAccess.open(path, FileAccess.WRITE)
if file == null:
return
file.store_string(content)
file.close()
func _routine_title(path: String) -> String:
var result := RoutineFile.load_file(path)
var routine: Routine = result.get("routine", null)
return routine.title if routine != null else ""
func _test_delete_files() -> void:
DirAccess.make_dir_recursive_absolute(
ProjectSettings.globalize_path(RoutineSync.LOCAL_DIR)
)
var routine_name := "sync-test-delete.json"
var music_name := "sync-test-delete.mp3"
_write_text(
RoutineSync.LOCAL_DIR.path_join(routine_name),
_routine_content(300, "delete")
)
_write_text(RoutineSync.LOCAL_DIR.path_join(music_name), "ID3")
var state_path := "user://test_delete_state.cfg"
RoutineSync.save_state(state_path, {
routine_name: {"local_mtime": 1, "remote_modify": 2},
music_name: {"local_mtime": 1, "remote_modify": 2},
})
var errors := RoutineSync.delete_local_files(
PackedStringArray([routine_name, music_name]),
state_path
)
_check(errors.is_empty(), "lokales Löschen meldet keinen Fehler")
_check(
not FileAccess.file_exists(RoutineSync.LOCAL_DIR.path_join(routine_name))
and not FileAccess.file_exists(
RoutineSync.LOCAL_DIR.path_join(music_name)
),
"Kür und Musik werden lokal entfernt"
)
_check(
RoutineSync.load_state(state_path).is_empty(),
"gelöschte Dateien verschwinden aus dem Sync-Stand"
)
DirAccess.remove_absolute(ProjectSettings.globalize_path(state_path))
var cloud_name := "sync-test-delete-cloud.json"
_write_text(
RoutineSync.LOCAL_DIR.path_join(cloud_name),
_routine_content(300, "cloud-delete")
)
var store := FakeRemoteStore.new()
store.remote_files[cloud_name] = _routine_content(300, "cloud-delete")
var job := RoutineSync.new()
job.result = {"deleted": [], "errors": []}
job.delete_names = PackedStringArray([cloud_name])
job._delete_routines(
store,
RoutineSync.local_files(),
{cloud_name: {"modify": 1, "size": 1}}
)
_check(
store.deleted.has(cloud_name),
"Löschen entfernt die Cloud-Kopie"
)
_check(
job.result["deleted"].has(cloud_name),
"Löschen meldet die entfernte Kür"
)
_check(
not FileAccess.file_exists(RoutineSync.LOCAL_DIR.path_join(cloud_name)),
"Löschen entfernt die lokale Kür nach der Cloud-Kopie"
)
_check(job.result["errors"].is_empty(), "Cloud-Löschen meldet keinen Fehler")
if FileAccess.file_exists(RoutineSync.LOCAL_DIR.path_join(cloud_name)):
DirAccess.remove_absolute(
ProjectSettings.globalize_path(
RoutineSync.LOCAL_DIR.path_join(cloud_name)
)
)
func _test_rename_files() -> void:
var old_json := "sync-test-rename-old.json"
var new_json := "sync-test-rename-new.json"
var old_tres := "sync-test-rename-old.tres"
var store := FakeRemoteStore.new()
store.remote_files[old_json] = _routine_content(1, "old")
store.remote_files[old_tres] = "legacy"
DirAccess.make_dir_recursive_absolute(
ProjectSettings.globalize_path(RoutineSync.LOCAL_DIR)
)
_write_text(
RoutineSync.LOCAL_DIR.path_join(new_json),
_routine_content(2, "neu")
)
var job := RoutineSync.new()
job.result = {"renamed": [], "errors": []}
job.rename_from = PackedStringArray([old_json, old_tres])
job.rename_to = PackedStringArray([
new_json,
"sync-test-rename-new.tres",
])
job._rename_routines(store, {
old_json: {"modify": 1, "size": 1},
old_tres: {"modify": 1, "size": 1},
})
_check(
store.remote_files.has(new_json),
"Cloud-Umbenennen legt den neuen Namen an"
)
_check(
not store.remote_files.has(old_json),
"Cloud-Umbenennen entfernt den alten Namen"
)
_check(
not store.remote_files.has(old_tres) and store.deleted.has(old_tres),
"Legacy-.tres wird in der Cloud entfernt"
)
_check(
job.result["renamed"].has(old_json),
"Umbenennen meldet die umbenannte Datei"
)
_check(
store.uploads.has(new_json),
"Umbenennen lädt den neuen Inhalt in die Cloud"
)
_check(job.result["errors"].is_empty(), "Cloud-Umbenennen meldet keinen Fehler")
if FileAccess.file_exists(RoutineSync.LOCAL_DIR.path_join(new_json)):
DirAccess.remove_absolute(
ProjectSettings.globalize_path(
RoutineSync.LOCAL_DIR.path_join(new_json)
)
)
func _test_cleanup_files() -> void:
DirAccess.make_dir_recursive_absolute(
ProjectSettings.globalize_path(RoutineSync.LOCAL_DIR)
)
var base_name := "sync-test-cleanup.json"
var copy_name := "sync-test-cleanup (Server 2026-10-30 1050).json"
var orphan_name := "sync-test-orphan (Lokal 2026-10-30 1050).json"
var unconfirmed := "sync-test-cleanup (Lokal 2026-10-31 1200).json"
var remote_only := "sync-test-remote (Server 2026-10-30 1050).json"
_write_text(RoutineSync.LOCAL_DIR.path_join(base_name), _routine_content(300, "base"))
_write_text(RoutineSync.LOCAL_DIR.path_join(copy_name), _routine_content(100, "old"))
_write_text(RoutineSync.LOCAL_DIR.path_join(orphan_name), _routine_content(100, "orphan"))
_write_text(RoutineSync.LOCAL_DIR.path_join(unconfirmed), _routine_content(100, "keep"))
var store := FakeRemoteStore.new()
store.remote_files[copy_name] = _routine_content(100, "old-cloud")
store.remote_files[remote_only] = _routine_content(100, "remote-only")
store.remote_files["sync-test-remote.json"] = _routine_content(300, "remote-base")
var local := RoutineSync.local_files()
var remote := {
copy_name: {"modify": 1, "size": 1},
remote_only: {"modify": 1, "size": 1},
"sync-test-remote.json": {"modify": 2, "size": 1},
}
var job := RoutineSync.new()
job.result = {
"cleanup_candidates": [],
"cleanup_skipped": [],
"cleanup_done": [],
"errors": [],
}
job.cleanup_names = PackedStringArray([copy_name, remote_only])
job._clean_old_conflicts(store, local, remote)
_check(
not FileAccess.file_exists(RoutineSync.LOCAL_DIR.path_join(copy_name)),
"bestätigte lokale Konfliktkopie wird entfernt"
)
_check(
FileAccess.file_exists(RoutineSync.archive_path(copy_name)),
"entfernte Kopie liegt im Konfliktarchiv"
)
_check(store.deleted.has(copy_name), "Cloud-Konfliktkopie wird gelöscht")
_check(
FileAccess.file_exists(RoutineSync.LOCAL_DIR.path_join(base_name)),
"Hauptdatei bleibt beim Aufräumen erhalten"
)
_check(
store.deleted.has(remote_only),
"nur in der Cloud liegende Kopie wird gelöscht"
)
_check(
FileAccess.file_exists(RoutineSync.archive_path(remote_only))
and _routine_title(RoutineSync.archive_path(remote_only)) == "remote-only",
"nur in der Cloud liegende Kopie wird vorher lokal archiviert"
)
_check(
FileAccess.file_exists(RoutineSync.LOCAL_DIR.path_join(unconfirmed)),
"nicht bestätigte Kopie bleibt erhalten"
)
_check(
job.result["cleanup_done"].size() == 2,
"Aufräumen meldet beide erledigten Kopien"
)
_check(
job.result["cleanup_skipped"].has(orphan_name),
"Kopie ohne Hauptdatei wird übersprungen"
)
_check(
FileAccess.file_exists(RoutineSync.LOCAL_DIR.path_join(orphan_name)),
"verwaiste Kopie bleibt als einzige Fassung erhalten"
)
for name: String in [base_name, orphan_name, unconfirmed, copy_name]:
var path := RoutineSync.LOCAL_DIR.path_join(name)
if FileAccess.file_exists(path):
DirAccess.remove_absolute(ProjectSettings.globalize_path(path))
if FileAccess.file_exists(RoutineSync.archive_path(copy_name)):
DirAccess.remove_absolute(
ProjectSettings.globalize_path(RoutineSync.archive_path(copy_name))
)
if FileAccess.file_exists(RoutineSync.archive_path(remote_only)):
DirAccess.remove_absolute(
ProjectSettings.globalize_path(RoutineSync.archive_path(remote_only))
)
DirAccess.remove_absolute(
ProjectSettings.globalize_path(RoutineSync.CONFLICT_DIR)
)
func _test_cloud_helpers() -> void:
var url := CloudHttp.parse_url(
"https://api.dropboxapi.com/2/files/list_folder?limit=10"
@ -373,6 +755,176 @@ func _test_controller_wiring() -> void:
controller.sync_connect_button.text == "Trennen",
"Verbundenes Konto bietet Trennen an"
)
var manager_item := -1
var popup := controller.file_menu_button.get_popup()
for index: int in range(popup.item_count):
if popup.get_item_text(index) == "Küren verwalten…":
manager_item = index
_check(manager_item >= 0, "das Dateimenü bietet die Kürenverwaltung an")
_check(
controller.routine_manager_dialog != null
and controller.delete_routine_dialog != null,
"Verwaltungs- und Löschdialog sind in der Szene verdrahtet"
)
_check(
controller.cleanup_conflicts_dialog != null,
"der Aufräumdialog ist in der Szene verdrahtet"
)
var summary := controller._format_sync_summary({
"uploaded": [],
"downloaded": [],
"skipped": [],
"errors": [],
"resolved": [
{
"name": "kuer.json",
"winner": "cloud",
"timestamp": 0,
"archive": "kuer.json",
},
],
})
_check(
summary.contains("Automatisch aufgelöste Konflikte: 1")
and summary.contains("Cloud-Fassung")
and summary.contains("Konfliktarchiv"),
"die Sync-Zusammenfassung nennt Gewinner und Konfliktarchiv"
)
# "Küren verwalten": rows expose open/delete, the music stay-check works.
controller.sync_settings_dialog.hide()
DirAccess.make_dir_recursive_absolute(
ProjectSettings.globalize_path(RoutineSync.LOCAL_DIR)
)
var manager_file := "sync-test-manager.json"
var manager_file_two := "sync-test-manager-two.json"
var shared_music := "sync-test-shared.mp3"
_write_text(
RoutineSync.LOCAL_DIR.path_join(manager_file),
_routine_content(1, "manager", shared_music)
)
_write_text(
RoutineSync.LOCAL_DIR.path_join(manager_file_two),
_routine_content(1, "manager two", shared_music)
)
_write_text(
RoutineSync.LOCAL_DIR.path_join("sync-test-manager.tres"),
"legacy twin"
)
_check(
controller._routine_variants(manager_file).size() == 2,
"Löschen erfasst JSON und Legacy-.tres derselben Kür"
)
DirAccess.remove_absolute(
ProjectSettings.globalize_path(
RoutineSync.LOCAL_DIR.path_join("sync-test-manager.tres")
)
)
controller._refresh_routine_manager()
controller.routine_manager_dialog.show()
_check(
controller.routine_manager_dialog.visible,
"der Verwaltungsdialog lässt sich öffnen"
)
var manager_row: HBoxContainer = null
for child: Node in controller.routine_manager_list.get_children():
if child is HBoxContainer:
var open_button := child.get_child(0) as Button
if open_button != null and open_button.text == "sync-test-manager":
manager_row = child
break
_check(
manager_row != null and manager_row.get_child_count() == 3,
"die Kürenverwaltung zeigt Öffnen, Umbenennen und Löschen je Kür"
)
controller._open_rename_routine_dialog(manager_file)
_check(
controller.rename_routine_dialog.visible
and controller.rename_routine_edit.text == "sync-test-manager",
"der Umbenennen-Dialog ist mit dem aktuellen Namen gefüllt"
)
controller.rename_routine_dialog.hide()
controller._pending_rename_name = ""
controller._open_delete_routine_dialog(manager_file)
_check(
controller.delete_routine_dialog.visible
and controller.delete_routine_text.text.contains("sync-test-manager"),
"der Löschdialog nennt die gewählte Kür"
)
controller.delete_routine_dialog.hide()
controller._pending_delete_name = ""
_check(
controller._orphan_music_for(manager_file).is_empty(),
"gemeinsam genutzte Musik wird nicht als verwaist markiert"
)
_write_text(
RoutineSync.LOCAL_DIR.path_join(manager_file_two),
_routine_content(1, "manager two")
)
_check(
controller._orphan_music_for(manager_file)
== PackedStringArray([shared_music]),
"ungenutzte Musik wird beim Löschen erkannt"
)
controller.delete_routine_cloud_check.disabled = true
controller.delete_routine_cloud_check.button_pressed = false
controller._pending_delete_name = manager_file_two
controller._on_delete_routine_confirmed()
_check(
not FileAccess.file_exists(
RoutineSync.LOCAL_DIR.path_join(manager_file_two)
),
"die Kürenverwaltung löscht eine Kür lokal"
)
controller.message_dialog.hide()
var rename_file := "sync-test-rename-ui.json"
var rename_tres := "sync-test-rename-ui.tres"
var renamed_file := "sync-test-rename-ui-neu.json"
_write_text(
RoutineSync.LOCAL_DIR.path_join(rename_file),
_routine_content(1, "Alte Kür")
)
_write_text(RoutineSync.LOCAL_DIR.path_join(rename_tres), "legacy")
var rename_error := controller._rename_local_routine(
rename_file,
"sync-test-rename-ui-neu",
"Neue Kür",
false
)
_check(rename_error.is_empty(), "lokales Umbenennen meldet keinen Fehler")
_check(
FileAccess.file_exists(RoutineSync.LOCAL_DIR.path_join(renamed_file)),
"Umbenennen legt die Kür unter dem neuen Namen ab"
)
_check(
not FileAccess.file_exists(
RoutineSync.LOCAL_DIR.path_join(rename_file)
)
and not FileAccess.file_exists(
RoutineSync.LOCAL_DIR.path_join(rename_tres)
),
"Umbenennen entfernt alten JSON- und Legacy-Namen"
)
_check(
_routine_title(RoutineSync.LOCAL_DIR.path_join(renamed_file))
== "Neue Kür",
"Umbenennen schreibt den neuen Titel in die Kür"
)
if FileAccess.file_exists(RoutineSync.LOCAL_DIR.path_join(renamed_file)):
DirAccess.remove_absolute(
ProjectSettings.globalize_path(
RoutineSync.LOCAL_DIR.path_join(renamed_file)
)
)
for name: String in [manager_file, manager_file_two]:
if FileAccess.file_exists(RoutineSync.LOCAL_DIR.path_join(name)):
DirAccess.remove_absolute(
ProjectSettings.globalize_path(
RoutineSync.LOCAL_DIR.path_join(name)
)
)
controller._refresh_routine_manager()
controller.routine_manager_dialog.hide()
controller.sync_settings_dialog.hide()
# Ohne Refresh-Token öffnet "Jetzt synchronisieren" die Einstellungen.

View file

@ -28,6 +28,11 @@ func _run() -> void:
if controller == null:
_finish()
return
_check(controller.theme != null, "the sport theme is applied")
_check(
controller.title_label.text == "RINKPLANNER",
"the app title uses the sport branding"
)
var canvas := controller.rink_canvas
var view := canvas.get_view_transform()
@ -297,6 +302,12 @@ func _run() -> void:
playback_bar.get_combined_minimum_size().x <= 1024.0,
"playback bar fits a 1024 px landscape tablet"
)
_check(
top_bar.custom_minimum_size.y <= 60.0
and timing_bar.custom_minimum_size.y <= 60.0
and playback_bar.custom_minimum_size.y <= 92.0,
"the main bars stay vertically compact for more rink space"
)
scene.queue_free()
await process_frame

View file

@ -241,7 +241,6 @@ func _run() -> void:
controller.get_node("%FreeLineToolButton"),
controller.get_node("%JumpToolButton"),
controller.get_node("%SpinToolButton"),
controller.get_node("%SequenceToolButton"),
]
var arc_right_button: Button = controller.get_node("%ArcRightToolButton")
arc_right_button.pressed.emit()
@ -282,22 +281,23 @@ func _run() -> void:
"%s is the only highlighted element icon" % entry[0]
)
# The sequence icon starts drawing mode instead of placing a point marker.
controller.set_tool(WhiteboardController.Tool.ARC_LEFT)
var sequence_button: Button = controller.get_node("%SequenceToolButton")
sequence_button.pressed.emit()
# The group action replaces the former sequence drawing tool and sits in
# the same top tool bar, without joining the tool button group.
var group_button: Button = controller.get_node("%GroupSequenceButton")
var select_tool_button: Button = controller.get_node("%SelectToolButton")
_check(
controller.is_sequence_mode()
and controller.get_element_type() == PathSegment.ElementType.SEQUENCE,
"the sequence icon starts sequence drawing mode"
group_button.get_parent() == controller.get_node("%ToolButtons"),
"the group action lives in the top tool bar"
)
_check(
sequence_button.button_pressed
and (controller.get_node("%ArcLeftToolButton") as Button).button_pressed,
"sequence mode keeps the current path tool active"
group_button.icon != null and group_button.text.is_empty(),
"the group action is an icon button"
)
sequence_button.pressed.emit()
_check(not controller.is_sequence_mode(), "the sequence icon finishes sequence mode")
_check(
group_button.button_group != select_tool_button.button_group,
"the group action does not join the tool button group"
)
controller.set_element_type(PathSegment.ElementType.JUMP)
controller.set_tool(WhiteboardController.Tool.ARC_LEFT)
_mouse_button(canvas, view.model_to_screen(Vector2(-15.0, 5.0)), true)
@ -1952,37 +1952,50 @@ func _run() -> void:
"a tap behind the last segment appends the marker"
)
# Sequence drawing mode: consecutive drags become one sequence range.
# Grouping consecutive segments creates one sequence range.
controller.new_routine()
controller.set_tool(WhiteboardController.Tool.LINE)
var sequence_view := canvas.get_view_transform()
var range_sequence_button: Button = controller.get_node("%SequenceToolButton")
range_sequence_button.pressed.emit()
_check(controller.is_sequence_mode(), "sequence drawing mode can be started")
var sequence_section := controller.get_active_section()
for x_start: float in [-15.0, -5.0, 5.0]:
_mouse_button(canvas, sequence_view.model_to_screen(Vector2(x_start, 0.0)), true)
_mouse_motion(canvas, sequence_view.model_to_screen(Vector2(x_start + 10.0, 0.0)))
_mouse_button(
canvas,
sequence_view.model_to_screen(Vector2(x_start + 10.0, 0.0)),
false
)
_check(
sequence_section.segments.size() == 3,
"the sequence fixture has three segments"
)
controller.set_tool(WhiteboardController.Tool.LINE)
_mouse_button(canvas, sequence_view.model_to_screen(Vector2(-15.0, 0.0)), true)
_mouse_motion(canvas, sequence_view.model_to_screen(Vector2(-5.0, 0.0)))
_mouse_button(canvas, sequence_view.model_to_screen(Vector2(-5.0, 0.0)), false)
_mouse_button(canvas, sequence_view.model_to_screen(Vector2(-5.0, 0.0)), true)
_mouse_motion(canvas, sequence_view.model_to_screen(Vector2(5.0, 0.0)))
_mouse_button(canvas, sequence_view.model_to_screen(Vector2(5.0, 0.0)), false)
controller.set_tool(WhiteboardController.Tool.SELECT)
controller.set_multi_select_enabled(true)
controller.clear_selection()
for x_mid: float in [-10.0, 0.0, 10.0]:
_mouse_button(canvas, sequence_view.model_to_screen(Vector2(x_mid, 0.0)), true)
_mouse_button(canvas, sequence_view.model_to_screen(Vector2(x_mid, 0.0)), false)
_check(
controller.get_selected_segment_ids().size() == 3,
"the sequence fixture selects all three segments"
)
controller.group_sequence_button.pressed.emit()
var sequence_elements := sequence_section.get_elements()
_check(
sequence_elements.size() == 1,
"two drawn segments resolve to one sequence element"
"three grouped segments resolve to one sequence element"
)
if sequence_elements.size() == 1:
var sequence_element: ResolvedElement = sequence_elements[0]
_check(
sequence_element.segments.size() == 2,
"the sequence group contains both drawn segments"
sequence_element.segments.size() == 3,
"the sequence group contains all grouped segments"
)
_check(
sequence_element.get_lead() == sequence_section.segments[0],
"the first drawn segment is the sequence lead"
"the first grouped segment is the sequence lead"
)
_check(
sequence_element.get_code() == "StSq",
@ -1990,47 +2003,26 @@ func _run() -> void:
)
_check(
sequence_element.is_sequence_range(),
"the drawn group is a sequence range, not a point marker"
"the grouped range is a sequence range, not a point marker"
)
_check(
controller.timeline_label_lane.get_element_label_count() == 1,
"the sequence group shows one timeline label"
)
# Finish the group, then continue it from a member at the section tail.
range_sequence_button.pressed.emit()
_check(not controller.is_sequence_mode(), "the sequence button finishes the group")
var tail_member := sequence_section.segments[1]
controller.select_segment(tail_member.segment_id)
range_sequence_button.pressed.emit()
_check(
controller.is_sequence_mode(),
"sequence mode continues a group that ends at the section tail"
)
# Later segments do not join the group unless they are grouped again.
controller.set_tool(WhiteboardController.Tool.LINE)
_mouse_button(canvas, sequence_view.model_to_screen(Vector2(-15.0, 5.0)), true)
_mouse_motion(canvas, sequence_view.model_to_screen(Vector2(-5.0, 5.0)))
_mouse_button(canvas, sequence_view.model_to_screen(Vector2(-5.0, 5.0)), false)
_check(
sequence_section.get_elements().size() == 1
and sequence_section.get_elements()[0].segments.size() == 3,
"a drawn segment continues the selected sequence group"
)
range_sequence_button.pressed.emit()
# Leaving sequence mode must not pull later path segments into the group.
controller.set_tool(WhiteboardController.Tool.LINE)
_mouse_button(canvas, sequence_view.model_to_screen(Vector2(-15.0, 10.0)), true)
_mouse_motion(canvas, sequence_view.model_to_screen(Vector2(-5.0, 10.0)))
_mouse_button(canvas, sequence_view.model_to_screen(Vector2(-5.0, 10.0)), false)
_check(
sequence_section.segments.size() == 4,
"a segment drawn after the group is added to the section"
"a segment drawn after grouping is added to the section"
)
_check(
sequence_section.get_elements().size() == 1
and sequence_section.get_elements()[0].segments.size() == 3,
"a segment after sequence mode stays outside the group"
"a segment drawn after grouping stays outside the group"
)
# Selecting a member shows and edits the lead element.
@ -2121,9 +2113,8 @@ func _run() -> void:
)
_check(group_section.is_valid(), "the section stays valid with marker and group")
# A legacy single-segment sequence becomes a group when it is continued.
# A single segment can be tagged as a sequence range without a group id.
controller.new_routine()
var legacy_section := controller.get_active_section()
var legacy_range := controller.add_segment(
Vector2(-10.0, 0.0),
Vector2(0.0, 0.0),
@ -2143,73 +2134,6 @@ func _run() -> void:
legacy_range.element_group_id.is_empty(),
"a single tagged segment needs no group id yet"
)
var legacy_button: Button = controller.get_node("%SequenceToolButton")
legacy_button.pressed.emit()
controller.set_tool(WhiteboardController.Tool.LINE)
var legacy_view := canvas.get_view_transform()
_mouse_button(canvas, legacy_view.model_to_screen(Vector2(0.0, 0.0)), true)
_mouse_motion(canvas, legacy_view.model_to_screen(Vector2(10.0, 0.0)))
_mouse_button(canvas, legacy_view.model_to_screen(Vector2(10.0, 0.0)), false)
var legacy_elements := legacy_section.get_elements()
_check(
legacy_elements.size() == 1 and legacy_elements[0].segments.size() == 2,
"drawing after a legacy range turns it into a group"
)
if legacy_elements.size() == 1:
_check(
not legacy_elements[0].get_group_id().is_empty(),
"the continued legacy range gets a group id"
)
_check(
legacy_elements[0].segments[0].element_group_id
== legacy_elements[0].segments[1].element_group_id,
"both continued segments share the group id"
)
legacy_button.pressed.emit()
# Undo removes one drawn part at a time and keeps the group consistent.
controller.new_routine()
controller.set_tool(WhiteboardController.Tool.LINE)
var undo_sequence_button: Button = controller.get_node("%SequenceToolButton")
undo_sequence_button.pressed.emit()
controller.set_tool(WhiteboardController.Tool.LINE)
var undo_view := canvas.get_view_transform()
_mouse_button(canvas, undo_view.model_to_screen(Vector2(-10.0, 0.0)), true)
_mouse_motion(canvas, undo_view.model_to_screen(Vector2(0.0, 0.0)))
_mouse_button(canvas, undo_view.model_to_screen(Vector2(0.0, 0.0)), false)
_mouse_button(canvas, undo_view.model_to_screen(Vector2(0.0, 0.0)), true)
_mouse_motion(canvas, undo_view.model_to_screen(Vector2(10.0, 0.0)))
_mouse_button(canvas, undo_view.model_to_screen(Vector2(10.0, 0.0)), false)
var undo_section := controller.get_active_section()
_check(
undo_section.get_elements().size() == 1
and undo_section.get_elements()[0].segments.size() == 2,
"the undo fixture has one two-part sequence"
)
_check(controller.undo(), "the last sequence part can be undone")
var undone_section := controller.get_active_section()
_check(
undone_section.get_elements().size() == 1
and undone_section.get_elements()[0].segments.size() == 1,
"undo leaves a valid one-part sequence"
)
_check(controller.undo(), "the first sequence part can be undone")
undone_section = controller.get_active_section()
_check(
undone_section.get_elements().is_empty(),
"undo removes the empty sequence group"
)
# Sequence drawing mode also accepts freehand strokes.
controller.set_tool(WhiteboardController.Tool.SELECT)
var freehand_sequence_button: Button = controller.get_node("%SequenceToolButton")
freehand_sequence_button.pressed.emit()
controller.set_tool(WhiteboardController.Tool.FREELINE)
_check(
controller.is_sequence_mode(),
"sequence mode stays active when switching to freeline"
)
freehand_sequence_button.pressed.emit()
# Multi-selection groups existing segments into a sequence.
controller.new_routine()
@ -2266,8 +2190,8 @@ func _run() -> void:
"the group button is enabled for a valid selection"
)
_check(
controller.group_sequence_button.text.contains("3"),
"the group button shows the selection count"
controller.group_sequence_button.tooltip_text.contains("3"),
"the group button tooltip shows the selection count"
)
controller.group_sequence_button.pressed.emit()
var grouped_elements := controller.get_active_section().get_elements()