Skip to content

Commit

Permalink
TONY: Added code to load and save the ScummVM sound settings
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jun 17, 2012
1 parent b554063 commit 9405f9e
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 7 deletions.
2 changes: 1 addition & 1 deletion engines/tony/font.cpp
Expand Up @@ -2144,7 +2144,7 @@ void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p
_startTime = _vm->getTime();

if (_bShowed) {
if (GLOBALS._bCfgSottotitoli || _bAlwaysDisplay) {
if (GLOBALS._bShowSubtitles || _bAlwaysDisplay) {
prim->getDst().topLeft() = _dst;
CORO_INVOKE_2(RMText::draw, bigBuf, prim);
}
Expand Down
7 changes: 5 additions & 2 deletions engines/tony/game.cpp
Expand Up @@ -700,7 +700,7 @@ void RMOptionScreen::initState(CORO_PARAM) {
_buttonGfx_AntiAlias->setActiveState(!GLOBALS._bCfgAntiAlias);
assert(_buttonGfx_Sottotitoli == NULL);
_buttonGfx_Sottotitoli = new RMOptionButton(20017, RMPoint(98, 82), true);
_buttonGfx_Sottotitoli->setActiveState(!GLOBALS._bCfgSottotitoli);
_buttonGfx_Sottotitoli->setActiveState(!GLOBALS._bShowSubtitles);
assert(_buttonGfx_Tips == NULL);
_buttonGfx_Tips = new RMOptionButton(20018, RMPoint(431, 246), true);
_buttonGfx_Tips->setActiveState(GLOBALS._bCfgInterTips);
Expand Down Expand Up @@ -822,7 +822,7 @@ void RMOptionScreen::closeState(void) {
delete _buttonGfx_AntiAlias;
_buttonGfx_AntiAlias = NULL;

GLOBALS._bCfgSottotitoli = !_buttonGfx_Sottotitoli->isActive();
GLOBALS._bShowSubtitles = !_buttonGfx_Sottotitoli->isActive();
delete _buttonGfx_Sottotitoli;
_buttonGfx_Sottotitoli = NULL;

Expand Down Expand Up @@ -858,6 +858,9 @@ void RMOptionScreen::closeState(void) {
delete _buttonSound_SFXOn;
_buttonSound_SFXOn = NULL;
}

// Save the new settings to ScummVM
_vm->saveSoundSettings();
}

_nState = MENUNONE;
Expand Down
4 changes: 2 additions & 2 deletions engines/tony/gfxengine.cpp
Expand Up @@ -659,7 +659,7 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm
f->writeByte(GLOBALS._bCfgInvUp);
f->writeByte(GLOBALS._bCfgAnni30);
f->writeByte(GLOBALS._bCfgAntiAlias);
f->writeByte(GLOBALS._bCfgSottotitoli);
f->writeByte(GLOBALS._bShowSubtitles);
f->writeByte(GLOBALS._bCfgTransparence);
f->writeByte(GLOBALS._bCfgInterTips);
f->writeByte(GLOBALS._bCfgDubbing);
Expand Down Expand Up @@ -795,7 +795,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) {
GLOBALS._bCfgInvUp = _ctx->f->readByte();
GLOBALS._bCfgAnni30 = _ctx->f->readByte();
GLOBALS._bCfgAntiAlias = _ctx->f->readByte();
GLOBALS._bCfgSottotitoli = _ctx->f->readByte();
GLOBALS._bShowSubtitles = _ctx->f->readByte();
GLOBALS._bCfgTransparence = _ctx->f->readByte();
GLOBALS._bCfgInterTips = _ctx->f->readByte();
GLOBALS._bCfgDubbing = _ctx->f->readByte();
Expand Down
2 changes: 1 addition & 1 deletion engines/tony/globals.cpp
Expand Up @@ -135,7 +135,7 @@ Globals::Globals() {
_bCfgAntiAlias = false;
_bCfgTransparence = true;
_bCfgInterTips = true;
_bCfgSottotitoli = true;
_bShowSubtitles = true;
_nCfgTonySpeed = 3;
_nCfgTextSpeed = 5;
_bCfgDubbing = true;
Expand Down
2 changes: 1 addition & 1 deletion engines/tony/globals.h
Expand Up @@ -194,7 +194,7 @@ class Globals {
bool _bCfgInvUp;
bool _bCfgAnni30;
bool _bCfgAntiAlias;
bool _bCfgSottotitoli;
bool _bShowSubtitles;
bool _bCfgTransparence;
bool _bCfgInterTips;
bool _bCfgDubbing;
Expand Down
32 changes: 32 additions & 0 deletions engines/tony/tony.cpp
Expand Up @@ -42,6 +42,7 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng
_vm = this;
_loadSlotNumber = -1;

// Set the up the debugger
_debugger = new Debugger();
DebugMan.addDebugChannel(kTonyDebugAnimations, "animations", "Animations debugging");
DebugMan.addDebugChannel(kTonyDebugActions, "actions", "Actions debugging");
Expand All @@ -62,6 +63,9 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng
_initialLoadSlotNumber = slotNumber;
}

// Load the ScummVM sound settings
syncSoundSettings();

_hEndOfFrame = 0;
for (int i = 0; i < 6; i++)
_stream[i] = NULL;
Expand Down Expand Up @@ -627,4 +631,32 @@ Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc) {
return Common::kNoError;
}

void TonyEngine::syncSoundSettings() {
Engine::syncSoundSettings();

GLOBALS._bCfgDubbing = !ConfMan.getBool("mute") && !ConfMan.getBool("speech_mute");
GLOBALS._bCfgSFX = !ConfMan.getBool("mute") && !ConfMan.getBool("sfx_mute");
GLOBALS._bCfgMusic = !ConfMan.getBool("mute") && !ConfMan.getBool("music_mute");

GLOBALS._nCfgDubbingVolume = ConfMan.getInt("speech_volume") * 10 / 256;
GLOBALS._nCfgSFXVolume = ConfMan.getInt("sfx_volume") * 10 / 256;
GLOBALS._nCfgMusicVolume = ConfMan.getInt("music_volume") * 10 / 256;

GLOBALS._bShowSubtitles = ConfMan.getBool("subtitles");
GLOBALS._nCfgTextSpeed = ConfMan.getInt("talkspeed") * 10 / 256;
}

void TonyEngine::saveSoundSettings() {
ConfMan.setBool("speech_mute", GLOBALS._bCfgDubbing);
ConfMan.setBool("sfx_mute", GLOBALS._bCfgSFX);
ConfMan.setBool("music_mute", GLOBALS._bCfgMusic);

ConfMan.setInt("speech_volume", GLOBALS._nCfgDubbingVolume * 256 / 10);
ConfMan.setInt("sfx_volume", GLOBALS._nCfgSFXVolume * 256 / 10);
ConfMan.setInt("music_volume", GLOBALS._nCfgMusicVolume * 256 / 10);

ConfMan.setBool("subtitles", GLOBALS._bShowSubtitles);
ConfMan.setBool("talkspeed", GLOBALS._nCfgTextSpeed);
}

} // End of namespace Tony
3 changes: 3 additions & 0 deletions engines/tony/tony.h
Expand Up @@ -221,6 +221,9 @@ class TonyEngine : public Engine {

void openInitLoadMenu(CORO_PARAM);
void openInitOptions(CORO_PARAM);

virtual void syncSoundSettings();
void saveSoundSettings();
};

// Global reference to the TonyEngine object
Expand Down

0 comments on commit 9405f9e

Please sign in to comment.