Ticket #8689: sword1-options.diff
File sword1-options.diff, 5.2 KB (added by , 17 years ago) |
---|
-
engines/sword1/sword1.cpp
238 238 _logic = new Logic(_objectMan, _resMan, _screen, _mouse, _sound, _music, _menu, _system, _mixer); 239 239 _mouse->useLogicAndMenu(_logic, _menu); 240 240 241 uint musicVol = ConfMan.getInt("music_volume"); 242 uint speechVol = ConfMan.getInt("speech_volume"); 243 uint sfxVol = ConfMan.getInt("sfx_volume"); 244 if (musicVol > 255) 245 musicVol = 255; 246 if (speechVol > 255) 247 speechVol = 255; 248 if (sfxVol > 255) 249 sfxVol = 255; 241 uint musicVolL, musicVolR; 242 uint speechVolL, speechVolR; 243 uint sfxVolL, sfxVolR; 250 244 251 _music->setVolume(musicVol, musicVol); // these routines expect left and right volume, 252 _sound->setSpeechVol(speechVol, speechVol); // but our config manager doesn't support it. 253 _sound->setSfxVol(sfxVol, sfxVol); 245 getVolumeFromConfig("music_volume", musicVolL, musicVolR); 246 getVolumeFromConfig("speech_volume", speechVolL, speechVolR); 247 getVolumeFromConfig("sfx_volume", sfxVolL, sfxVolR); 248 249 _music->setVolume(musicVolL, musicVolR); 250 _sound->setSpeechVol(speechVolL, speechVolR); 251 _sound->setSfxVol(sfxVolL, sfxVolR); 254 252 255 253 _systemVars.justRestoredGame = 0; 256 254 _systemVars.currentCD = 0; … … 295 293 return 0; 296 294 } 297 295 296 void SwordEngine::getVolumeFromConfig(Common::String prefix, uint &volL, uint &volR) { 297 // There might not be any sensible way of doing this. Any user who have 298 // changed the volume settings both with the ScummVM options dialog and 299 // the Broken Sword 1 options dialog will almost certainly have brought 300 // them out of sync. 301 if (ConfMan.hasKey(prefix, ConfMan.getActiveDomainName())) { 302 // If we have the standard setting specifically for this game, 303 // use that. 304 volL = volR = ConfMan.getInt(prefix, ConfMan.getActiveDomainName()); 305 } else { 306 // If we have the left/right settings, which are almost 307 // certainly made by the Broken Sword 1 options dialog, use 308 // them. Otherwise, use the default settings. 309 if (ConfMan.hasKey(prefix + "_left")) { 310 volL = ConfMan.getInt(prefix + "_left"); 311 } else { 312 volL = ConfMan.getInt(prefix); 313 } 314 if (ConfMan.hasKey(prefix + "_right")) { 315 volR = ConfMan.getInt(prefix + "_right"); 316 } else { 317 volR = ConfMan.getInt(prefix); 318 } 319 } 320 if (volL > 255) 321 volL = 255; 322 if (volR > 255) 323 volR = 255; 324 } 325 298 326 void SwordEngine::reinitialize(void) { 299 327 _resMan->flush(); // free everything that's currently alloced and opened. (*evil*) 300 328 -
engines/sword1/control.h
108 108 uint8 handleButtonClick(uint8 id, uint8 mode, uint8 *retVal); 109 109 void handleVolumeClicks(void); 110 110 void changeVolume(uint8 id, uint8 action); 111 void saveVolume(Common::String prefix, uint8 left, uint8 right); 111 112 112 113 void setupMainPanel(void); 113 114 void setupSaveRestorePanel(bool saving); -
engines/sword1/control.cpp
24 24 */ 25 25 26 26 #include "common/stdafx.h" 27 #include "common/config-manager.h" 27 28 #include "common/file.h" 28 29 #include "common/util.h" 29 30 #include "common/savefile.h" … … 309 310 delay(1000 / 12); 310 311 newMode = getClicks(mode, &retVal); 311 312 } while ((newMode != BUTTON_DONE) && (retVal == 0) && (!SwordEngine::_systemVars.engineQuit)); 313 if (SwordEngine::_systemVars.controlPanelMode == CP_NORMAL) { 314 uint8 volL, volR; 315 _music->giveVolume(&volL, &volR); 316 saveVolume("music_volume", volL, volR); 317 _sound->giveSpeechVol(&volL, &volR); 318 saveVolume("speech_volume", volL, volR); 319 _sound->giveSfxVol(&volL, &volR); 320 saveVolume("sfx_volume", volL, volR); 321 ConfMan.setBool("subtitles", SwordEngine::_systemVars.showText); 322 ConfMan.flushToDisk(); 323 } 312 324 destroyButtons(); 313 325 _resMan->resClose(fontId); 314 326 _resMan->resClose(redFontId); … … 606 618 renderVolumeBar(id, volL, volR); 607 619 } 608 620 621 void Control::saveVolume(Common::String prefix, uint8 volL, uint8 volR) { 622 // We save either the left/right volume or the main one. Never both. 623 if (volL == volR) { 624 ConfMan.removeKey(prefix + "_left", ConfMan.getActiveDomainName()); 625 ConfMan.removeKey(prefix + "_right", ConfMan.getActiveDomainName()); 626 ConfMan.setInt(prefix, volL); 627 } else { 628 ConfMan.setInt(prefix + "_left", volL); 629 ConfMan.setInt(prefix + "_right", volR); 630 ConfMan.removeKey(prefix, ConfMan.getActiveDomainName()); 631 } 632 } 633 609 634 bool Control::getConfirm(const uint8 *title) { 610 635 ControlButton *panel = new ControlButton(0, 0, SR_CONFIRM, 0, 0, _resMan, _screenBuf, _system); 611 636 panel->draw(); -
engines/sword1/sword1.h
88 88 void checkCdFiles(void); 89 89 void checkCd(void); 90 90 void showFileErrorMsg(uint8 type, bool *fileExists); 91 void getVolumeFromConfig(Common::String prefix, uint &volL, uint &volR); 91 92 void flagsToBool(bool *dest, uint8 flags); 92 93 uint8 mainLoop(void); 93 94