Ticket #8689: sword1-balance2.diff
File sword1-balance2.diff, 3.2 KB (added by , 17 years ago) |
---|
-
engines/sword1/sword1.cpp
241 241 uint musicVol = ConfMan.getInt("music_volume"); 242 242 uint speechVol = ConfMan.getInt("speech_volume"); 243 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; 244 uint musicBal = 50; 245 if (ConfMan.hasKey("music_balance")) { 246 musicBal = CLIP(ConfMan.getInt("music_balance"), 0, 100); 247 } 248 uint speechBal = 50; 249 if (ConfMan.hasKey("speech_balance")) { 250 speechBal = CLIP(ConfMan.getInt("speech_balance"), 0, 100); 251 } 252 uint sfxBal = 50; 253 if (ConfMan.hasKey("sfx_balance")) { 254 sfxBal = CLIP(ConfMan.getInt("sfx_balance"), 0, 100); 255 } 250 256 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); 257 uint musicVolL = 2 * musicVol * musicBal / 100; 258 uint musicVolR = 2 * musicVol - musicVolL; 254 259 260 uint speechVolL = 2 * speechVol * speechBal / 100; 261 uint speechVolR = 2 * speechVol - speechVolL; 262 263 uint sfxVolL = 2 * sfxVol * sfxBal / 100; 264 uint sfxVolR = 2 * sfxVol - sfxVolL; 265 266 if (musicVolR > 255) { 267 musicVolR = 255; 268 } 269 if (musicVolL > 255) { 270 musicVolL = 255; 271 } 272 if (speechVolR > 255) { 273 speechVolR = 255; 274 } 275 if (speechVolL > 255) { 276 speechVolL = 255; 277 } 278 if (sfxVolR > 255) { 279 sfxVolR = 255; 280 } 281 if (sfxVolL > 255) { 282 sfxVolL = 255; 283 } 284 285 _music->setVolume(musicVolL, musicVolR); 286 _sound->setSpeechVol(speechVolL, speechVolR); 287 _sound->setSfxVol(sfxVolL, sfxVolR); 288 255 289 _systemVars.justRestoredGame = 0; 256 290 _systemVars.currentCD = 0; 257 291 _systemVars.controlPanelMode = CP_NEWGAME; -
engines/sword1/control.cpp
221 221 free(_screenBuf); 222 222 } 223 223 224 static int volToBalance(int volL, int volR) { 225 if (volL + volR == 0) { 226 return 50; 227 } else { 228 return (100 * volL / (volL + volR)); 229 } 230 } 231 224 232 uint8 Control::runPanel(void) { 225 233 _mouseDown = false; 226 234 _restoreBuf = NULL; … … 310 318 delay(1000 / 12); 311 319 newMode = getClicks(mode, &retVal); 312 320 } while ((newMode != BUTTON_DONE) && (retVal == 0) && (!SwordEngine::_systemVars.engineQuit)); 321 322 if (SwordEngine::_systemVars.controlPanelMode == CP_NORMAL) { 323 uint8 volL, volR; 324 _music->giveVolume(&volL, &volR); 325 ConfMan.setInt("music_volume", (int)((volR + volL) / 2)); 326 ConfMan.setInt("music_balance", volToBalance(volL, volR)); 327 328 _sound->giveSpeechVol(&volL, &volR); 329 ConfMan.setInt("speech_volume", (int)((volR + volL) / 2)); 330 ConfMan.setInt("speech_balance", volToBalance(volL, volR)); 331 332 _sound->giveSfxVol(&volL, &volR); 333 ConfMan.setInt("sfx_volume", (int)((volR + volL) / 2)); 334 ConfMan.setInt("sfx_balance", volToBalance(volL, volR)); 335 336 ConfMan.setBool("subtitles", SwordEngine::_systemVars.showText == 1); 337 ConfMan.flushToDisk(); 338 } 339 313 340 destroyButtons(); 314 341 _resMan->resClose(fontId); 315 342 _resMan->resClose(redFontId);