-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix scenario menu update after quitting to menu #1243
Conversation
@@ -454,56 +454,81 @@ getNormalizedCurrentScenarioPath = | |||
gs <- use $ gameState . scenarios | |||
Just <$> liftIO (normalizeScenarioPath gs p') | |||
|
|||
saveScenarioInfoOnFinish :: (MonadIO m, MonadState AppState m) => FilePath -> m (Maybe ScenarioInfo) | |||
saveScenarioInfoOnFinish p = do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a cut-and-paste of the body of saveScenarioInfoOnFinishNocheat
(formerly saveScenarioInfoOnFinish
).
|
||
-- | Write the @ScenarioInfo@ out to disk when exiting a game. | ||
saveScenarioInfoOnQuit :: (MonadIO m, MonadState AppState m) => m () | ||
saveScenarioInfoOnQuit = do | ||
saveScenarioInfoOnFinish |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function call is moved 8 lines down to make use of the "cheat" check, which was formerly implemented redundantly.
b52a32e
to
d6df551
Compare
d6df551
to
2d8c191
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish the code for dealing with the "new game" menu was simpler, it has been a fertile source of bugs. Maybe someday we'll figure out a nice refactoring that simplifies things...
I believe that since #1277 the progress has not been saved when exiting a scenario back to the menu. It is because `getNormalizedCurrentScenarioPath`, which is utilized by `saveScenarioInfoOnQuit`, was returning `Nothing`, in turn because `currentScenarioPath` was `Nothing`. This is because `scenarioToAppState` was clearing it immediately after being set inside `startGameWithSeed`. Foreshadowed by this comment: #1243 (review) .
Ensures that the "played" status and the "best scores" get updated in the scenario menu after "Quit to menu" is selected from within a scenario.
This bug appeared after merging #974.