Ticket #8689: sword1-balance.diff

File sword1-balance.diff, 3.3 KB (added by sev-, 16 years ago)

Balance patch

  • control.cpp

     
    310310                delay(1000 / 12);
    311311                newMode = getClicks(mode, &retVal);
    312312        } while ((newMode != BUTTON_DONE) && (retVal == 0) && (!SwordEngine::_systemVars.engineQuit));
     313        if (SwordEngine::_systemVars.controlPanelMode == CP_NORMAL && !SwordEngine::_systemVars.engineQuit) {
     314                uint8 volL, volR;
     315                _music->giveVolume(&volL, &volR);
     316                ConfMan.setInt("music_volume", (int)((volR + volL) / 2));
     317                if (volR + volL == 0) {
     318                        ConfMan.setInt("music_balance", 50);
     319                } else {
     320                        ConfMan.setInt("music_balance", (int)(100 * volL / (volR + volL)));
     321                }
     322                _sound->giveSpeechVol(&volL, &volR);
     323                ConfMan.setInt("speech_volume", (int)((volR + volL) / 2));
     324                if (volR + volL == 0) {
     325                        ConfMan.setInt("speech_balance", 50);
     326                } else {
     327                        ConfMan.setInt("speech_balance", (int)(100 * volL / (volR + volL)));
     328                }
     329                _sound->giveSfxVol(&volL, &volR);
     330                ConfMan.setInt("sfx_volume", (int)((volR + volL) / 2));
     331                if (volR + volL == 0) {
     332                        ConfMan.setInt("sfx_balance", 50);
     333                } else {
     334                        ConfMan.setInt("sfx_balance", (int)(100 * volL / (volR + volL)));
     335                }
     336                ConfMan.setBool("subtitles", SwordEngine::_systemVars.showText == 1);
     337                ConfMan.flushToDisk();
     338        }
    313339        destroyButtons();
    314340        _resMan->resClose(fontId);
    315341        _resMan->resClose(redFontId);
  • sword1.cpp

     
    241241        uint musicVol = ConfMan.getInt("music_volume");
    242242        uint speechVol = ConfMan.getInt("speech_volume");
    243243        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 = ConfMan.getInt("music_balance");
     247        }
     248        uint speechBal = 50;
     249        if (ConfMan.hasKey("speech_balance")) {
     250                speechBal = ConfMan.getInt("speech_balance");
     251        }
     252        uint sfxBal = 50;
     253        if (ConfMan.hasKey("sfx_balance")) {
     254                sfxBal = ConfMan.getInt("sfx_balance");
     255        }
     256        uint musicVolR = musicVol;
     257        if (musicBal < 100) {
     258                musicVolR = 2 * musicVol * (1 - (float)musicBal / 100);
     259        }
     260        uint musicVolL = 2 * musicVol - musicVolR;
     261        uint speechVolR = speechVol;
     262        if (speechBal < 100) {
     263                speechVolR = 2 * speechVol * (1 - (float)speechBal / 100);
     264        }
     265        uint speechVolL = 2 * speechVol - speechVolR;
     266        uint sfxVolR = sfxVol;
     267        if (speechBal < 100) {
     268                sfxVolR = 2 * sfxVol * (1 - (float)sfxBal / 100);
     269        }
     270        uint sfxVolL = 2 * sfxVol - sfxVolR;
     271        if (musicVolR > 255) {
     272                musicVolR = 255;
     273        }
     274        if (musicVolL > 255) {
     275                musicVolL = 255;
     276        }
     277        if (speechVolR > 255) {
     278                speechVolR = 255;
     279        }
     280        if (speechVolL > 255) {
     281                speechVolL = 255;
     282        }
     283        if (sfxVolR > 255) {
     284                sfxVolR = 255;
     285        }
     286        if (sfxVolL > 255) {
     287                sfxVolL = 255;
     288        }
    250289
    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);
     290        _music->setVolume(musicVolL, musicVolR);
     291        _sound->setSpeechVol(speechVolL, speechVolR);
     292        _sound->setSfxVol(sfxVolL, sfxVolR);
    254293
    255294        _systemVars.justRestoredGame = 0;
    256295        _systemVars.currentCD = 0;