diff --git a/lib/src/app.dart b/lib/src/app.dart index 832c175..854f0f3 100644 --- a/lib/src/app.dart +++ b/lib/src/app.dart @@ -116,7 +116,7 @@ class _AskiiNeverDieAppState extends State { if (exists) { // 세이브 파일에서 미리보기 정보 추출 - final (outcome, state) = await _controller.saveManager.loadState(); + final (outcome, state, _) = await _controller.saveManager.loadState(); if (outcome.success && state != null) { final actName = _getActName(state.progress.plotStageCount); preview = SavedGamePreview( @@ -477,7 +477,10 @@ class _AskiiNeverDieAppState extends State { }, ), ), - ); + ).then((_) { + // 새 게임 후 돌아오면 세이브 정보 갱신 + _checkForExistingSave(); + }); } Future _loadSave(BuildContext context) async { @@ -502,11 +505,8 @@ class _AskiiNeverDieAppState extends State { if (selectedFileName == null || !context.mounted) return; - // 선택된 파일 로드 - await _controller.loadAndStart( - fileName: selectedFileName, - cheatsEnabled: false, - ); + // 선택된 파일 로드 (치트 모드는 저장된 상태에서 복원) + await _controller.loadAndStart(fileName: selectedFileName); if (_controller.status == GameSessionStatus.running) { if (context.mounted) { @@ -553,7 +553,10 @@ class _AskiiNeverDieAppState extends State { onThemeModeChange: _changeThemeMode, ), ), - ); + ).then((_) { + // 게임에서 돌아오면 세이브 정보 갱신 + _checkForExistingSave(); + }); } /// Phase 10: 명예의 전당 화면으로 이동 diff --git a/lib/src/features/game/game_play_screen.dart b/lib/src/features/game/game_play_screen.dart index b6c02a6..e0b07b2 100644 --- a/lib/src/features/game/game_play_screen.dart +++ b/lib/src/features/game/game_play_screen.dart @@ -528,8 +528,8 @@ class _GamePlayScreenState extends State /// 모바일 재진입 시 전체 화면 재로드 Future _reloadGameScreen() async { - // 세이브 파일에서 다시 로드 - await widget.controller.loadAndStart(cheatsEnabled: widget.controller.cheatsEnabled); + // 세이브 파일에서 다시 로드 (치트 모드는 저장된 상태에서 복원) + await widget.controller.loadAndStart(); if (!mounted) return; @@ -550,7 +550,10 @@ class _GamePlayScreenState extends State final currentState = widget.controller.state; if (currentState == null || !widget.controller.isRunning) return; - await widget.controller.saveManager.saveState(currentState); + await widget.controller.saveManager.saveState( + currentState, + cheatsEnabled: widget.controller.cheatsEnabled, + ); } /// 뒤로가기 시 저장 확인 다이얼로그 diff --git a/lib/src/features/game/game_session_controller.dart b/lib/src/features/game/game_session_controller.dart index 045ca06..f599cd5 100644 --- a/lib/src/features/game/game_session_controller.dart +++ b/lib/src/features/game/game_session_controller.dart @@ -225,13 +225,13 @@ class GameSessionController extends ChangeNotifier { Future loadAndStart({ String? fileName, - bool cheatsEnabled = false, }) async { _status = GameSessionStatus.loading; _error = null; notifyListeners(); - final (outcome, loaded) = await saveManager.loadState(fileName: fileName); + final (outcome, loaded, savedCheatsEnabled) = + await saveManager.loadState(fileName: fileName); if (!outcome.success || loaded == null) { _status = GameSessionStatus.error; _error = outcome.error ?? 'Unknown error'; @@ -239,7 +239,8 @@ class GameSessionController extends ChangeNotifier { return; } - await startNew(loaded, cheatsEnabled: cheatsEnabled, isNewGame: false); + // 저장된 치트 모드 상태 복원 + await startNew(loaded, cheatsEnabled: savedCheatsEnabled, isNewGame: false); } Future pause({bool saveOnStop = false}) async { @@ -382,8 +383,11 @@ class GameSessionController extends ChangeNotifier { _state = resurrectedState; _status = GameSessionStatus.idle; // 사망 상태 해제 - // 저장 - await saveManager.saveState(resurrectedState); + // 저장 (치트 모드 상태 유지) + await saveManager.saveState( + resurrectedState, + cheatsEnabled: _cheatsEnabled, + ); notifyListeners(); }