Whenever you start a new game, you get these default settings for your detail, volume, and speed. Three, twelve, six respectively I believe. These values are included in savegames, as a necessity of the savegame design, but what if you have a particular volume preference and start a new game? Bam, it's back to twelve!
That won't do.
What if we could save these things in a separate file, apart from savegames, and detect and reload it when a new game starts?
In ControlIcon.sc, add this to gameControls:
(method (dispose &tmp fHnd, value)
(= fHnd FileIO fiOPEN "settings" fCREATE)
(= value (gGame _detailLevel?))
(FileIO fiWRITE fHnd @value 2)
(= value (gGamemasterVolume?))
(FileIO fiWRITE fHnd @value 2)
(= value gGEgoMoveSpeed)
(FileIO fiWRITE fHnd @value 2)
(= value gTextSpeech)
(FileIO fiWRITE fHnd @value 2)
(FileIO fiCLOSE fHnd)
(super dispose:)
)
And in Main.sc, SQ5::play, add this right between the debug trigger and (self newRoom: theStartRoom):
(= fHnd (FileIO fiOPEN "settings" fOPENFAIL)
(if (> fHnd 0)
(FileIO(fiREAD fHnd @value 2)
(= _detailLevel value)
(FileIO fiREAD fHnd @value 2)
(self masterVolume: value)
(FileIO fiREAD fHnd @value 2)
(= gGEgoMoveSpeed value)
(FileIO fiREAD fHnd @value 2)
(= gTextSpeech value)
(FileIO fiCLOSE fHnd)
)
If you restore a savegame with different settings and press Play, the saved settings will of course reflect the savegame's settings.