feat(input): make double-tap placement the default
New saves start in double-tap mode. Version 1 saves migrate once to double-tap and are rewritten as version 2, while the settings toggle still persists a later choice. Smoke tests now force hold mode for their hold checks; UI tests cover the fresh default and the migration.
This commit is contained in:
1 parent
15e79ae38c
commit
82c5691d2e
3 files changed
+47
-4
No files matched your search
+12
-2
@@ -13,7 +13,7 @@ const DEFAULTS := {
|
||||
"show_timer": true,
|
||||
"reduce_motion": false,
|
||||
"hold_seconds": 0.35,
|
||||
"double_tap_place": false,
|
||||
"double_tap_place": true,
|
||||
}
|
||||
|
||||
var data := {}
|
||||
@@ -25,7 +25,7 @@ func _ready() -> void:
|
||||
|
||||
func _default_data() -> Dictionary:
|
||||
return {
|
||||
"version": 1,
|
||||
"version": 2,
|
||||
"completed_rooms": [],
|
||||
"unlocked_guests": [],
|
||||
"settings": DEFAULTS.duplicate(true),
|
||||
@@ -35,6 +35,7 @@ func _default_data() -> Dictionary:
|
||||
|
||||
func load_game() -> void:
|
||||
data = _default_data()
|
||||
var stored_version := 2
|
||||
|
||||
if FileAccess.file_exists(PATH):
|
||||
var file := FileAccess.open(PATH, FileAccess.READ)
|
||||
@@ -42,6 +43,7 @@ func load_game() -> void:
|
||||
var parsed = JSON.parse_string(file.get_as_text())
|
||||
file.close()
|
||||
if typeof(parsed) == TYPE_DICTIONARY:
|
||||
stored_version = int(parsed.get("version", 1))
|
||||
for key in parsed:
|
||||
data[key] = parsed[key]
|
||||
|
||||
@@ -51,6 +53,14 @@ func load_game() -> void:
|
||||
if not data["settings"].has(key):
|
||||
data["settings"][key] = DEFAULTS[key]
|
||||
|
||||
# Version 2 makes double-tap the default. Older saves were written while
|
||||
# hold was the default, so switch them once; the toggle still persists
|
||||
# after that.
|
||||
if stored_version < 2:
|
||||
data["settings"]["double_tap_place"] = true
|
||||
data["version"] = 2
|
||||
save_game()
|
||||
|
||||
if typeof(data.get("completed_rooms")) != TYPE_ARRAY:
|
||||
data["completed_rooms"] = []
|
||||
if typeof(data.get("unlocked_guests")) != TYPE_ARRAY:
|
||||
|
||||
@@ -93,6 +93,13 @@ func _run() -> void:
|
||||
print("FAIL mapping: expected (3,4), got %s" % str(mapped))
|
||||
|
||||
# Tap marks X, right-click checks in, and hold checks in without a tap.
|
||||
# This section exercises hold mode explicitly; double-tap has its own
|
||||
# checks in ui_test.gd.
|
||||
var save = root.get_node_or_null("SaveGame")
|
||||
var previous_mode := true
|
||||
if save != null:
|
||||
previous_mode = bool(save.get_setting("double_tap_place"))
|
||||
save.set_setting("double_tap_place", false)
|
||||
board.set_level(first)
|
||||
board._update_layout()
|
||||
var tap_cell := _find_empty_cell(board)
|
||||
@@ -122,6 +129,9 @@ func _run() -> void:
|
||||
all_ok = false
|
||||
print("FAIL hold release: guest was removed")
|
||||
|
||||
if save != null:
|
||||
save.set_setting("double_tap_place", previous_mode)
|
||||
|
||||
print("SMOKE TEST: %s" % ("PASS" if all_ok else "FAIL"))
|
||||
quit(0 if all_ok else 1)
|
||||
|
||||
|
||||
+25
-2
@@ -33,6 +33,7 @@ func _run() -> void:
|
||||
quit(1)
|
||||
return
|
||||
|
||||
_test_save_defaults(save)
|
||||
save.reset_progress()
|
||||
|
||||
main.game.start_level(0)
|
||||
@@ -100,12 +101,34 @@ func _run() -> void:
|
||||
save.set_setting("show_timer", true)
|
||||
save.set_setting("reduce_motion", false)
|
||||
save.set_setting("hold_seconds", 0.35)
|
||||
save.set_setting("double_tap_place", false)
|
||||
save.set_setting("double_tap_place", true)
|
||||
|
||||
print("UI TEST: ", "PASS" if failures == 0 else "FAIL (%d)" % failures)
|
||||
quit(0 if failures == 0 else 1)
|
||||
|
||||
|
||||
func _test_save_defaults(save) -> void:
|
||||
# A fresh save starts in double-tap mode at version 2.
|
||||
var abs_path := ProjectSettings.globalize_path(save.PATH)
|
||||
if FileAccess.file_exists(save.PATH):
|
||||
DirAccess.remove_absolute(abs_path)
|
||||
save.load_game()
|
||||
_check(int(save.data.get("version", 0)) == 2, "fresh saves should be version 2")
|
||||
_check(bool(save.get_setting("double_tap_place")), "fresh saves should default to double-tap")
|
||||
|
||||
# A version 1 save with hold selected migrates to double-tap once.
|
||||
var old: Dictionary = save._default_data()
|
||||
old["version"] = 1
|
||||
old["settings"]["double_tap_place"] = false
|
||||
var file := FileAccess.open(save.PATH, FileAccess.WRITE)
|
||||
file.store_string(JSON.stringify(old, "\t"))
|
||||
file.close()
|
||||
|
||||
save.load_game()
|
||||
_check(int(save.data.get("version", 0)) == 2, "version 1 saves should migrate to version 2")
|
||||
_check(bool(save.get_setting("double_tap_place")), "version 1 saves should migrate to double-tap")
|
||||
|
||||
|
||||
func _find_empty(board: Board) -> Vector2i:
|
||||
for r in board.n:
|
||||
for c in board.n:
|
||||
@@ -182,7 +205,7 @@ func _test_placement_modes(save, board: Board) -> void:
|
||||
save.set_setting("double_tap_place", true)
|
||||
save.load_game()
|
||||
_check(bool(save.get_setting("double_tap_place")), "double_tap_place should persist")
|
||||
save.set_setting("double_tap_place", false)
|
||||
save.set_setting("double_tap_place", true)
|
||||
board.restart()
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user