Author Topic: SCI1.1: Persistent Settings  (Read 4251 times)

0 Members and 1 Guest are viewing this topic.

Offline Kawa

SCI1.1: Persistent Settings
« on: November 01, 2015, 03:18:12 PM »
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:
Code: [Select]
(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):
Code: [Select]
(= 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.
« Last Edit: May 25, 2017, 01:06:59 PM by Kawa »



Offline troflip

Re: SCI1.1: Persistent Settings
« Reply #1 on: November 02, 2015, 12:04:52 AM »
Nice. That probably won't work in ScummVM... at least the saving part. But, you could set the settings while playing under DOSBox, then they would load in ScummVM.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Kawa

Re: SCI1.1: Persistent Settings
« Reply #2 on: November 02, 2015, 02:29:02 AM »
Nice. That probably won't work in ScummVM... at least the saving part. But, you could set the settings while playing under DOSBox, then they would load in ScummVM.
Actually I've found that saving does work in ScummVM. It loads from "settings" first if there is one, then "id-settings", but always saves to "id-settings". Which is more than I'd expected.

Clarifying edit: it considers DOSBox' "settings" first, but loads from "id-settings" if that's there too.
« Last Edit: November 02, 2015, 02:42:33 AM by Kawa »

Offline lskovlun

Re: SCI1.1: Persistent Settings
« Reply #3 on: November 02, 2015, 10:59:51 AM »
Clarifying edit: it considers DOSBox' "settings" first, but loads from "id-settings" if that's there too.
This is necessary, in case the game ships with a settings file. You never know. On the other hand, ScummVM already saves the volume separately, so this could cause trouble down the road.


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.023 seconds with 23 queries.