[UI/UX] Implement Mid-Run Save & Crash Recovery System - #607
Merged
Conversation
## Summary Implements deterministic hover preview showing combat outcomes before committing an action. Color-coded by severity. ## Changes ### New: HoverPreviewManager - scripts/ui/hover_preview_manager.gd: Tooltip panel that follows mouse - Shows damage preview, HP after hit, AP cost when hovering enemies - Shows move cost, elevation bonus, cover info when hovering tiles - Color-coded severity: green (safe), yellow (warning), red (lethal) - Panel keeps itself inside viewport bounds ### CombatRoom integration - Instantiates HoverPreviewManager in UIOverlay during _setup_hud() - _input() detects mouse motion and updates preview via _update_hover_preview() - Checks _enemies_node for entity at hovered tile, falls back to tile info - Only active during PLAYER_TURN; hidden during enemy turn ### Tests - test_hover_preview.gd: 2 cases for severity display and clear behavior ## Testing - 392 tests | 0 errors | 0 failures | 72/72 suites - Headless editor scan: clean Closes #597
## Summary Adds a deterministic undo/rewind system for player actions within a turn. Players can now undo misclicks or re-experiment with tactics. ## Changes ### New: ActionHistory - scripts/core/action_history.gd: LIFO stack of state snapshots - serialize_entity() / restore_entity(): Full entity state capture and restore - Configurable depth limit (default unlimited per turn) - Lightweight RefCounted — no autoload needed ### CombatInput signals - Added action_about_to_execute signal, emitted before attack/move mutations - Emitted in _execute_attack() and _execute_move_to() ### CombatRoom integration - Instantiates ActionHistory during _ready - _push_snapshot() captures player + all enemy states before each action - _undo_last_action() restores most recent snapshot on Ctrl+Z or Backspace - Snapshot captured for: keyboard moves, mouse moves, attacks - History cleared at start of each player turn (fresh stack) - Visual feedback: brief camera shake + toast message on undo ### Tests - test_action_history.gd: 4 cases for serialize round-trip, LIFO stack, empty noop, and depth limit trimming ## Testing - 396 tests | 0 errors | 0 failures | 73/73 suites - Headless editor scan: clean Closes #596
## Summary Adds atomic auto-save with rotating FIFO backups, enabling players to resume runs after crashes or quitting mid-session. ## Changes ### SaveManager extensions - AUTO_SAVE_DIR, AUTO_SAVE_PATH, AUTO_SAVE_SLOTS constants - auto_save_run(run_state): Atomic write with tmp→rename, then Steam Cloud sync - load_auto_save(): Reads auto-save JSON, returns empty Dict on error - has_auto_save(): Checks if auto-save exists - delete_auto_save(): Clears all slots - _rotate_auto_saves(): FIFO rotation (auto→auto_1→auto_2→auto_3) - _atomic_write_json(): Writes to .tmp then renames to prevent corruption - _load_json_file(): Graceful JSON parsing (empty Dict on error) ### RunManager integration - save_run_state() now includes player_entity_snapshot and burden_run_snapshot - load_run_state() restores player entity and burden snapshots - _auto_save_current_run() helper called from _enter_room and _enter_moral_eval - Auto-save triggers at phase boundaries: room entry and moral eval entry ### GameCoordinator / TitleScreen - TitleScreen: Continue button enabled if main save OR auto-save exists - GameCoordinator.cmd_continue_game(): Tries auto-save first, falls back to main save ### BurdenManager - Added get_trigger_count_this_run() and get_last_noun_index() getters ### AutoloadHelper - Added steam_manager() accessor for Steam Cloud sync ### Tests - test_auto_save.gd: 4 cases for atomic write, FIFO rotation, corrupt file handling, and empty state ## Testing - 400 tests | 0 errors | 0 failures | 74/74 suites - Headless editor scan: clean Closes #604
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds atomic auto-save with rotating FIFO backups, enabling players to resume runs after crashes, alt-tabs, or quitting mid-session.
Problem
Emberfall runs last 30–90 minutes. A crash, alt-tab, or system sleep currently loses all progress — a major pain point for modern PC gamers who expect session resumption.
Changes
SaveManager extensions
auto_save_run(run_state): Serializes run state and writes touser://saves/auto.json.tmpfirst, then renames to final path. If the game crashes during write, the existing save remains intact.auto_1.json…auto_3.json). Older backups are pushed out automatically.load_auto_save(): Reads auto-save JSON; returns empty Dictionary on any error (corrupt file, missing file, parse failure).has_auto_save(): Checks if auto-save exists on disk.delete_auto_save(): Clears all auto-save slots.RunManager integration
save_run_state()now captures:ActionHistory.serialize_entity)load_run_state()restores player entity and burden snapshots on resume._auto_save_current_run()helper called from:_enter_room()— auto-save at start of each room_enter_moral_eval()— auto-save after combat resolvedGameCoordinator / TitleScreen
BurdenManager
get_trigger_count_this_run()andget_last_noun_index()getters for serialization.AutoloadHelper
steam_manager()accessor for Steam Cloud sync.Edge Cases Handled
Tests
tests/test_auto_save.gd: 4 casesTesting
Related Issues
Closes #604