aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2009-11-02 21:56:29 +0000
committerMax Horn2009-11-02 21:56:29 +0000
commit5cf868b75711c69736d3b2eb6f1068bdc48349ae (patch)
tree1cc0ba610669f66f6b038dd5b668a496a50f09cc /engines
parent51933629d1f1a17839ddbb75b2b619effe117abb (diff)
downloadscummvm-rg350-5cf868b75711c69736d3b2eb6f1068bdc48349ae.tar.gz
scummvm-rg350-5cf868b75711c69736d3b2eb6f1068bdc48349ae.tar.bz2
scummvm-rg350-5cf868b75711c69736d3b2eb6f1068bdc48349ae.zip
TINSEL: Turn config code into a simple C++ class
svn-id: r45617
Diffstat (limited to 'engines')
-rw-r--r--engines/tinsel/bmv.cpp2
-rw-r--r--engines/tinsel/config.cpp89
-rw-r--r--engines/tinsel/config.h36
-rw-r--r--engines/tinsel/dialogs.cpp60
-rw-r--r--engines/tinsel/events.cpp4
-rw-r--r--engines/tinsel/music.cpp10
-rw-r--r--engines/tinsel/sound.cpp12
-rw-r--r--engines/tinsel/sysvar.cpp2
-rw-r--r--engines/tinsel/tinlib.cpp35
-rw-r--r--engines/tinsel/tinsel.cpp26
-rw-r--r--engines/tinsel/tinsel.h3
11 files changed, 147 insertions, 132 deletions
diff --git a/engines/tinsel/bmv.cpp b/engines/tinsel/bmv.cpp
index e89f1f091f..7d3481bafc 100644
--- a/engines/tinsel/bmv.cpp
+++ b/engines/tinsel/bmv.cpp
@@ -577,7 +577,7 @@ int BMVPlayer::MovieCommand(char cmd, int commandOffset) {
return sz_CMD_PRINT_pkt;
} else {
- if (bSubtitles) {
+ if (_vm->_config->_useSubtitles) {
TALK_CMD *pCmd = (TALK_CMD *)(bigBuffer + commandOffset);
talkColour = TINSEL_RGB(pCmd->r, pCmd->g, pCmd->b);
diff --git a/engines/tinsel/config.cpp b/engines/tinsel/config.cpp
index 86ba213398..9249da6edd 100644
--- a/engines/tinsel/config.cpp
+++ b/engines/tinsel/config.cpp
@@ -38,36 +38,35 @@
namespace Tinsel {
-//----------------- GLOBAL GLOBAL DATA --------------------
-
-int dclickSpeed = DOUBLE_CLICK_TIME;
-int volMusic = Audio::Mixer::kMaxChannelVolume;
-int volSound = Audio::Mixer::kMaxChannelVolume;
-int volVoice = Audio::Mixer::kMaxChannelVolume;
-int speedText = DEFTEXTSPEED;
-int bSubtitles = false;
-int bSwapButtons = 0;
-LANGUAGE g_language = TXT_ENGLISH;
-int bAmerica = 0;
-
+Config::Config(TinselEngine *vm) : _vm(vm) {
+ _dclickSpeed = DOUBLE_CLICK_TIME;
+ _musicVolume = Audio::Mixer::kMaxChannelVolume;
+ _soundVolume = Audio::Mixer::kMaxChannelVolume;
+ _voiceVolume = Audio::Mixer::kMaxChannelVolume;
+ _textSpeed = DEFTEXTSPEED;
+ _useSubtitles = false;
+ _swapButtons = false;
+ _language = TXT_ENGLISH;
+ _isAmericanEnglishVersion = false;
+}
/**
* Write settings to config manager and flush the config file to disk.
*/
-void WriteConfig() {
- ConfMan.setInt("dclick_speed", dclickSpeed);
- ConfMan.setInt("music_volume", volMusic);
- ConfMan.setInt("sfx_volume", volSound);
- ConfMan.setInt("speech_volume", volVoice);
- ConfMan.setInt("talkspeed", (speedText * 255) / 100);
- ConfMan.setBool("subtitles", bSubtitles);
- //ConfMan.setBool("swap_buttons", bSwapButtons ? 1 : 0);
+void Config::writeToDisk() {
+ ConfMan.setInt("dclick_speed", _dclickSpeed);
+ ConfMan.setInt("music_volume", _musicVolume);
+ ConfMan.setInt("sfx_volume", _soundVolume);
+ ConfMan.setInt("speech_volume", _voiceVolume);
+ ConfMan.setInt("talkspeed", (_textSpeed * 255) / 100);
+ ConfMan.setBool("subtitles", _useSubtitles);
+ //ConfMan.setBool("swap_buttons", _swapButtons ? 1 : 0);
// Store language for multilingual versions
if ((_vm->getFeatures() & GF_USE_3FLAGS) || (_vm->getFeatures() & GF_USE_4FLAGS) || (_vm->getFeatures() & GF_USE_5FLAGS)) {
Common::Language lang;
- switch (g_language) {
+ switch (_language) {
case TXT_FRENCH:
lang = Common::FR_FRA;
break;
@@ -94,50 +93,50 @@ void WriteConfig() {
/**
* Read configuration settings from the config file into memory
*/
-void ReadConfig() {
+void Config::readFromDisk() {
if (ConfMan.hasKey("dclick_speed"))
- dclickSpeed = ConfMan.getInt("dclick_speed");
+ _dclickSpeed = ConfMan.getInt("dclick_speed");
// HACK/FIXME:
// We need to clip the volumes from [0, 256] to [0, 255]
// here, since for example Tinsel's internal options dialog
// and also the midi playback code rely on the volumes to be
// in [0, 255]
- volMusic = CLIP(ConfMan.getInt("music_volume"), 0, 255);
- volSound = CLIP(ConfMan.getInt("sfx_volume"), 0, 255);
- volVoice = CLIP(ConfMan.getInt("speech_volume"), 0, 255);
+ _musicVolume = CLIP(ConfMan.getInt("music_volume"), 0, 255);
+ _soundVolume = CLIP(ConfMan.getInt("sfx_volume"), 0, 255);
+ _voiceVolume = CLIP(ConfMan.getInt("speech_volume"), 0, 255);
if (ConfMan.hasKey("talkspeed"))
- speedText = (ConfMan.getInt("talkspeed") * 100) / 255;
+ _textSpeed = (ConfMan.getInt("talkspeed") * 100) / 255;
if (ConfMan.hasKey("subtitles"))
- bSubtitles = ConfMan.getBool("subtitles");
+ _useSubtitles = ConfMan.getBool("subtitles");
// FIXME: If JAPAN is set, subtitles are forced OFF in the original engine
- //bSwapButtons = ConfMan.getBool("swap_buttons") == 1 ? true : false;
+ //_swapButtons = ConfMan.getBool("swap_buttons") == 1 ? true : false;
//ConfigData.language = language; // not necessary, as language has been set in the launcher
- //ConfigData.bAmerica = bAmerica; // EN_USA / EN_GRB
+ //ConfigData._isAmericanEnglishVersion = _isAmericanEnglishVersion; // EN_USA / EN_GRB
// Set language - we'll be clever here and use the ScummVM language setting
- g_language = TXT_ENGLISH;
+ _language = TXT_ENGLISH;
Common::Language lang = _vm->getLanguage();
if (lang == Common::UNK_LANG && ConfMan.hasKey("language"))
lang = Common::parseLanguage(ConfMan.get("language")); // For multi-lingual versions, fall back to user settings
switch (lang) {
case Common::FR_FRA:
- g_language = TXT_FRENCH;
+ _language = TXT_FRENCH;
break;
case Common::DE_DEU:
- g_language = TXT_GERMAN;
+ _language = TXT_GERMAN;
break;
case Common::ES_ESP:
- g_language = TXT_SPANISH;
+ _language = TXT_SPANISH;
break;
case Common::IT_ITA:
- g_language = TXT_ITALIAN;
+ _language = TXT_ITALIAN;
break;
default:
- g_language = TXT_ENGLISH;
+ _language = TXT_ENGLISH;
}
if (lang == Common::JA_JPN) {
@@ -147,22 +146,22 @@ void ReadConfig() {
// The Hebrew version appears to the software as being English
// but it needs to have subtitles on...
- g_language = TXT_ENGLISH;
- bSubtitles = true;
+ _language = TXT_ENGLISH;
+ _useSubtitles = true;
} else if (_vm->getFeatures() & GF_USE_3FLAGS) {
// 3 FLAGS version supports French, German, Spanish
// Fall back to German if necessary
- if (g_language != TXT_FRENCH && g_language != TXT_GERMAN && g_language != TXT_SPANISH) {
- g_language = TXT_GERMAN;
- bSubtitles = true;
+ if (_language != TXT_FRENCH && _language != TXT_GERMAN && _language != TXT_SPANISH) {
+ _language = TXT_GERMAN;
+ _useSubtitles = true;
}
} else if (_vm->getFeatures() & GF_USE_4FLAGS) {
// 4 FLAGS version supports French, German, Spanish, Italian
// Fall back to German if necessary
- if (g_language != TXT_FRENCH && g_language != TXT_GERMAN &&
- g_language != TXT_SPANISH && g_language != TXT_ITALIAN) {
- g_language = TXT_GERMAN;
- bSubtitles = true;
+ if (_language != TXT_FRENCH && _language != TXT_GERMAN &&
+ _language != TXT_SPANISH && _language != TXT_ITALIAN) {
+ _language = TXT_GERMAN;
+ _useSubtitles = true;
}
}
}
diff --git a/engines/tinsel/config.h b/engines/tinsel/config.h
index 67655c58fc..70418372f8 100644
--- a/engines/tinsel/config.h
+++ b/engines/tinsel/config.h
@@ -36,18 +36,30 @@ enum {
DEFTEXTSPEED = 0
};
-extern int dclickSpeed;
-extern int volMusic;
-extern int volSound;
-extern int volVoice;
-extern int speedText;
-extern int bSubtitles;
-extern int bSwapButtons;
-extern LANGUAGE g_language;
-extern int bAmerica;
-
-void WriteConfig();
-void ReadConfig();
+class TinselEngine;
+
+class Config {
+private:
+ TinselEngine *_vm;
+
+public:
+ int _dclickSpeed;
+ int _musicVolume;
+ int _soundVolume;
+ int _voiceVolume;
+ int _textSpeed;
+ int _useSubtitles;
+ int _swapButtons;
+ LANGUAGE _language;
+ int _isAmericanEnglishVersion;
+
+public:
+ Config(TinselEngine *vm);
+
+ void writeToDisk();
+ void readFromDisk();
+};
+
extern bool isJapanMode();
diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp
index ca760db0f5..2d4aa97f17 100644
--- a/engines/tinsel/dialogs.cpp
+++ b/engines/tinsel/dialogs.cpp
@@ -793,18 +793,18 @@ static CONFINIT t2ciRestart = { 4, 2, 196, 53, false, t2RestartBox, sizeof(t2Res
\*-------------------------------------------------------------*/
static CONFBOX t1SoundBox[] = {
- { SLIDER, MUSICVOL, TM_NONE, NULL, SIX_MVOL_SLIDER, 142, 25, Audio::Mixer::kMaxChannelVolume, 2, &volMusic, 0 },
- { SLIDER, NOFUNC, TM_NONE, NULL, SIX_SVOL_SLIDER, 142, 25+40, Audio::Mixer::kMaxChannelVolume, 2, &volSound, 0 },
- { SLIDER, NOFUNC, TM_NONE, NULL, SIX_VVOL_SLIDER, 142, 25+2*40, Audio::Mixer::kMaxChannelVolume, 2, &volVoice, 0 }
+ { SLIDER, MUSICVOL, TM_NONE, NULL, SIX_MVOL_SLIDER, 142, 25, Audio::Mixer::kMaxChannelVolume, 2, &_vm->_config->_musicVolume, 0 },
+ { SLIDER, NOFUNC, TM_NONE, NULL, SIX_SVOL_SLIDER, 142, 25+40, Audio::Mixer::kMaxChannelVolume, 2, &_vm->_config->_soundVolume, 0 },
+ { SLIDER, NOFUNC, TM_NONE, NULL, SIX_VVOL_SLIDER, 142, 25+2*40, Audio::Mixer::kMaxChannelVolume, 2, &_vm->_config->_voiceVolume, 0 }
};
static CONFBOX t2SoundBox[] = {
- { SLIDER, MUSICVOL, TM_INDEX, NULL, SS_MVOL_SLIDER, 280, 50, Audio::Mixer::kMaxChannelVolume, 2, &volMusic, 0 },
- { SLIDER, NOFUNC, TM_INDEX, NULL, SS_SVOL_SLIDER, 280, 50+30, Audio::Mixer::kMaxChannelVolume, 2, &volSound, 0 },
- { SLIDER, NOFUNC, TM_INDEX, NULL, SS_VVOL_SLIDER, 280, 50+2*30, Audio::Mixer::kMaxChannelVolume, 2, &volVoice, 0 },
+ { SLIDER, MUSICVOL, TM_INDEX, NULL, SS_MVOL_SLIDER, 280, 50, Audio::Mixer::kMaxChannelVolume, 2, &_vm->_config->_musicVolume, 0 },
+ { SLIDER, NOFUNC, TM_INDEX, NULL, SS_SVOL_SLIDER, 280, 50+30, Audio::Mixer::kMaxChannelVolume, 2, &_vm->_config->_soundVolume, 0 },
+ { SLIDER, NOFUNC, TM_INDEX, NULL, SS_VVOL_SLIDER, 280, 50+2*30, Audio::Mixer::kMaxChannelVolume, 2, &_vm->_config->_voiceVolume, 0 },
- { SLIDER, NOFUNC, TM_INDEX, NULL, SS_TSPEED_SLIDER, 280, 160, 100, 2, &speedText, 0 },
- { TOGGLE2, NOFUNC, TM_INDEX, NULL, SS_STITLE_TOGGLE, 100, 220, BW, BH, &bSubtitles, 0 },
+ { SLIDER, NOFUNC, TM_INDEX, NULL, SS_TSPEED_SLIDER, 280, 160, 100, 2, &_vm->_config->_textSpeed, 0 },
+ { TOGGLE2, NOFUNC, TM_INDEX, NULL, SS_STITLE_TOGGLE, 100, 220, BW, BH, &_vm->_config->_useSubtitles, 0 },
{ ROTATE, NOFUNC, TM_INDEX, NULL, SS_LANGUAGE_SELECT, 320,220, BW, BH, NULL, 0 }
};
@@ -821,12 +821,12 @@ static CONFINIT t2ciSound = { 10, 5, 40, 16, false, t2SoundBox, sizeof(t2SoundBo
static int bFlipped; // looks like this is just so the code has something to alter!
static CONFBOX controlBox[] = {
- { SLIDER, NOFUNC, TM_NONE, NULL, SIX_DCLICK_SLIDER, 142, 25, 3*DOUBLE_CLICK_TIME, 1, &dclickSpeed, 0 },
+ { SLIDER, NOFUNC, TM_NONE, NULL, SIX_DCLICK_SLIDER, 142, 25, 3*DOUBLE_CLICK_TIME, 1, &_vm->_config->_dclickSpeed, 0 },
{ FLIP, NOFUNC, TM_NONE, NULL, SIX_DCLICK_TEST, 142, 25+30, 23, 19, &bFlipped, IX1_CIRCLE1 },
#ifdef JAPAN
- { TOGGLE, NOFUNC, TM_NONE, NULL, SIX_SWAP_TOGGLE, 205, 25+70, 23, 19, &bSwapButtons, 0 }
+ { TOGGLE, NOFUNC, TM_NONE, NULL, SIX_SWAP_TOGGLE, 205, 25+70, 23, 19, &_vm->_config->_swapButtons, 0 }
#else
- { TOGGLE, NOFUNC, TM_NONE, NULL, SIX_SWAP_TOGGLE, 155, 25+70, 23, 19, &bSwapButtons, 0 }
+ { TOGGLE, NOFUNC, TM_NONE, NULL, SIX_SWAP_TOGGLE, 155, 25+70, 23, 19, &_vm->_config->_swapButtons, 0 }
#endif
};
@@ -837,8 +837,8 @@ static CONFINIT ciControl = { 10, 5, 20, 16, false, controlBox, ARRAYSIZE(contro
\*-------------------------------------------------------------*/
static CONFBOX subtitlesBox[] = {
- { SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, &speedText, 0 },
- { TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20+40, 23, 19, &bSubtitles, 0 },
+ { SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, &_vm->_config->_textSpeed, 0 },
+ { TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20+40, 23, 19, &_vm->_config->_useSubtitles, 0 },
};
static CONFBOX subtitlesBox3Flags[] = {
@@ -846,8 +846,8 @@ static CONFBOX subtitlesBox3Flags[] = {
{ FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 85, 118, 56, 32, NULL, FIX_GR },
{ FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 155, 118, 56, 32, NULL, FIX_SP },
- { SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, &speedText, 0 },
- { TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20+40, 23, 19, &bSubtitles, 0 },
+ { SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, &_vm->_config->_textSpeed, 0 },
+ { TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20+40, 23, 19, &_vm->_config->_useSubtitles, 0 },
{ ARSGBUT, CLANG, TM_NONE, NULL, USE_POINTER, 230, 110, 23, 19, NULL, IX1_TICK1 },
{ AAGBUT, RLANG, TM_NONE, NULL, USE_POINTER, 230, 140, 23, 19, NULL, IX1_CROSS1 }
@@ -859,8 +859,8 @@ static CONFBOX subtitlesBox4Flags[] = {
{ FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 64, 137, 56, 32, NULL, FIX_IT },
{ FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 152, 137, 56, 32, NULL, FIX_SP },
- { SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, &speedText, 0 },
- { TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20+40, 23, 19, &bSubtitles, 0 },
+ { SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, &_vm->_config->_textSpeed, 0 },
+ { TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20+40, 23, 19, &_vm->_config->_useSubtitles, 0 },
{ ARSGBUT, CLANG, TM_NONE, NULL, USE_POINTER, 230, 110, 23, 19, NULL, IX1_TICK1 },
{ AAGBUT, RLANG, TM_NONE, NULL, USE_POINTER, 230, 140, 23, 19, NULL, IX1_CROSS1 }
@@ -874,8 +874,8 @@ static CONFBOX subtitlesBox5Flags[] = {
{ FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 50, 137, 56, 32, NULL, FIX_IT },
{ FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 120, 137, 56, 32, NULL, FIX_SP },
- { SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, &speedText, 0 },
- { TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20+40, 23, 19, &bSubtitles, 0 },
+ { SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, &_vm->_config->_textSpeed, 0 },
+ { TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20+40, 23, 19, &_vm->_config->_useSubtitles, 0 },
{ ARSGBUT, CLANG, TM_NONE, NULL, USE_POINTER, 230, 110, 23, 19, NULL, IX1_TICK1 },
{ AAGBUT, RLANG, TM_NONE, NULL, USE_POINTER, 230, 140, 23, 19, NULL, IX1_CROSS1 }
@@ -1055,7 +1055,7 @@ static void ConfActionSpecial(int i);
bool LanguageChange() {
- LANGUAGE nLang = g_language;
+ LANGUAGE nLang = _vm->_config->_language;
if (_vm->getFeatures() & GF_USE_3FLAGS) {
// VERY quick dodgy bodge
@@ -1071,10 +1071,10 @@ bool LanguageChange() {
nLang = (LANGUAGE)cd.selBox;
}
- if (nLang != g_language) {
+ if (nLang != _vm->_config->_language) {
KillInventory();
ChangeLanguage(nLang);
- g_language = nLang;
+ _vm->_config->_language = nLang;
return true;
} else
return false;
@@ -2822,7 +2822,7 @@ void AddBox(int *pi, int i) {
pFilm = (const FILM *)LockMem(flagFilm);
- if (bAmerica && cd.box[i].bi == FIX_UK)
+ if (_vm->_config->_isAmericanEnglishVersion && cd.box[i].bi == FIX_UK)
cd.box[i].bi = FIX_USA;
iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi], -1);
@@ -4007,16 +4007,16 @@ void OpenMenu(CONFTYPE menuType) {
else if (menuType == SUBTITLES_MENU) {
if (_vm->getFeatures() & GF_USE_3FLAGS) {
// VERY quick dirty bodges
- if (g_language == TXT_FRENCH)
+ if (_vm->_config->_language == TXT_FRENCH)
Select(0, false);
- else if (g_language == TXT_GERMAN)
+ else if (_vm->_config->_language == TXT_GERMAN)
Select(1, false);
else
Select(2, false);
} else if (_vm->getFeatures() & GF_USE_4FLAGS) {
- Select(g_language-1, false);
+ Select(_vm->_config->_language-1, false);
} else if (_vm->getFeatures() & GF_USE_5FLAGS) {
- Select(g_language, false);
+ Select(_vm->_config->_language, false);
}
}
@@ -4053,7 +4053,7 @@ void KillInventory() {
OpenMenu(MAIN_MENU);
// Write config changes
- WriteConfig();
+ _vm->_config->writeToDisk();
} else if (ino == INV_CONF)
InventoryIconCursor(false);
@@ -4456,7 +4456,7 @@ static void SlideMSlider(int x, SSFN fn) {
case S_END: // End of a drag on the slider
AddBoxes(false); // Might change position slightly
if (ino == INV_CONF && cd.box == subtitlesBox)
- Select(g_language, false);
+ Select(_vm->_config->_language, false);
break;
}
}
@@ -5083,7 +5083,7 @@ void InvPdProcess(CORO_PARAM, const void *param) {
CORO_BEGIN_CODE(_ctx);
GetToken(TOKEN_LEFT_BUT);
- CORO_SLEEP(dclickSpeed+1);
+ CORO_SLEEP(_vm->_config->_dclickSpeed+1);
FreeToken(TOKEN_LEFT_BUT);
// get the stuff copied to process when it was created
diff --git a/engines/tinsel/events.cpp b/engines/tinsel/events.cpp
index 8a9c4833a8..c66c127413 100644
--- a/engines/tinsel/events.cpp
+++ b/engines/tinsel/events.cpp
@@ -101,7 +101,7 @@ void AllowDclick(CORO_PARAM, PLR_EVENT be) {
CORO_BEGIN_CODE(_ctx);
if (be == PLR_SLEFT) {
GetToken(TOKEN_LEFT_BUT);
- CORO_SLEEP(dclickSpeed+1);
+ CORO_SLEEP(_vm->_config->_dclickSpeed+1);
FreeToken(TOKEN_LEFT_BUT);
// Prevent activation of 2 events on the same tick
@@ -329,7 +329,7 @@ static void ProcessUserEvent(TINSEL_EVENT uEvent, const Common::Point &coOrds, P
* ProcessButEvent
*/
void ProcessButEvent(PLR_EVENT be) {
- if (bSwapButtons) {
+ if (_vm->_config->_swapButtons) {
switch (be) {
case PLR_SLEFT:
be = PLR_SRIGHT;
diff --git a/engines/tinsel/music.cpp b/engines/tinsel/music.cpp
index 7bce8a3bd6..4f218c937e 100644
--- a/engines/tinsel/music.cpp
+++ b/engines/tinsel/music.cpp
@@ -184,8 +184,8 @@ bool PlayMidiSequence(uint32 dwFileOffset, bool bLoop) {
// TODO: Maybe this should be moved to a better place...
if (TinselV1PSX) return false;
- if (volMusic != 0) {
- SetMidiVolume(volMusic);
+ if (_vm->_config->_musicVolume != 0) {
+ SetMidiVolume(_vm->_config->_musicVolume);
}
// the index and length of the last tune loaded
@@ -317,7 +317,7 @@ bool StopMidi() {
* Gets the volume of the MIDI music.
*/
int GetMidiVolume() {
- return volMusic;
+ return _vm->_config->_musicVolume;
}
static int priorVolMusic = 0;
@@ -963,9 +963,9 @@ void RestoreMidiFacts(SCNHANDLE Midi, bool Loop) {
currentMidi = Midi;
currentLoop = Loop;
- if (volMusic != 0 && Loop) {
+ if (_vm->_config->_musicVolume != 0 && Loop) {
PlayMidiSequence(currentMidi, true);
- SetMidiVolume(volMusic);
+ SetMidiVolume(_vm->_config->_musicVolume);
}
}
diff --git a/engines/tinsel/sound.cpp b/engines/tinsel/sound.cpp
index 457b9b54b0..d8ed39006a 100644
--- a/engines/tinsel/sound.cpp
+++ b/engines/tinsel/sound.cpp
@@ -111,9 +111,9 @@ bool SoundManager::playSample(int id, Audio::Mixer::SoundType type, Audio::Sound
Audio::AudioStream *vagStream = new Audio::VagStream(_sampleStream.readStream(sampleLen), false, 44100);
// FIXME: Should set this in a different place ;)
- _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, volSound);
+ _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, _vm->_config->_soundVolume);
//_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic);
- _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, volVoice);
+ _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, _vm->_config->_voiceVolume);
// Play the audio stream
_vm->_mixer->playInputStream(type, &curChan.handle, vagStream);
@@ -127,9 +127,9 @@ bool SoundManager::playSample(int id, Audio::Mixer::SoundType type, Audio::Sound
error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage));
// FIXME: Should set this in a different place ;)
- _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, volSound);
+ _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, _vm->_config->_soundVolume);
//_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic);
- _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, volVoice);
+ _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, _vm->_config->_voiceVolume);
Common::MemoryReadStream *compressedStream =
new Common::MemoryReadStream(sampleBuf, sampleLen, Common::DisposeAfterUse::YES);
@@ -308,9 +308,9 @@ bool SoundManager::playSample(int id, int sub, bool bLooped, int x, int y, int p
}
// FIXME: Should set this in a different place ;)
- _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, volSound);
+ _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, _vm->_config->_soundVolume);
//_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic);
- _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, volVoice);
+ _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, _vm->_config->_voiceVolume);
curChan->sampleNum = id;
curChan->subSample = sub;
diff --git a/engines/tinsel/sysvar.cpp b/engines/tinsel/sysvar.cpp
index a83116433e..1732207659 100644
--- a/engines/tinsel/sysvar.cpp
+++ b/engines/tinsel/sysvar.cpp
@@ -155,7 +155,7 @@ int SysVar(int varId) {
case SV_SUBTITLES:
// FIXME: This isn't currently defined
return false;
- //return bSubtitles;
+ //return _vm->_config->_useSubtitles;
case SV_SAVED_GAME_EXISTS:
return NewestSavedGame() != -1;
diff --git a/engines/tinsel/tinlib.cpp b/engines/tinsel/tinlib.cpp
index e4711c97e8..890912ece2 100644
--- a/engines/tinsel/tinlib.cpp
+++ b/engines/tinsel/tinlib.cpp
@@ -402,10 +402,10 @@ void SetTextPal(COLORREF col) {
static int TextTime(char *pTstring) {
if (isJapanMode())
return JAP_TEXT_TIME;
- else if (!speedText)
+ else if (!_vm->_config->_textSpeed)
return strlen(pTstring) + ONE_SECOND;
else
- return strlen(pTstring) + ONE_SECOND + (speedText * 5 * ONE_SECOND) / 100;
+ return strlen(pTstring) + ONE_SECOND + (_vm->_config->_textSpeed * 5 * ONE_SECOND) / 100;
}
/**
@@ -1680,7 +1680,7 @@ static void PlaySample(CORO_PARAM, int sample, bool bComplete, bool escOn, int m
return;
}
- if (volSound != 0 && _vm->_sound->sampleExists(sample)) {
+ if (_vm->_config->_soundVolume != 0 && _vm->_sound->sampleExists(sample)) {
_vm->_sound->playSample(sample, Audio::Mixer::kSFXSoundType, &_ctx->handle);
if (bComplete) {
@@ -1728,7 +1728,7 @@ static void PlaySample(CORO_PARAM, int sample, int x, int y, int flags, int myEs
if (_ctx->myEscape && _ctx->myEscape != GetEscEvents())
return;
- if (volSound != 0 && _vm->_sound->sampleExists(sample)) {
+ if (_vm->_config->_soundVolume != 0 && _vm->_sound->sampleExists(sample)) {
if (x == 0)
x = -1;
@@ -1884,7 +1884,7 @@ static void Print(CORO_PARAM, int x, int y, SCNHANDLE text, int time, bool bSust
if (!TinselV2) {
// Kick off the voice sample
- if (volVoice != 0 && _vm->_sound->sampleExists(text)) {
+ if (_vm->_config->_voiceVolume != 0 && _vm->_sound->sampleExists(text)) {
_vm->_sound->playSample(text, Audio::Mixer::kSpeechSoundType, &_ctx->handle);
_ctx->bSample = _vm->_mixer->isSoundHandleActive(_ctx->handle);
}
@@ -1922,7 +1922,7 @@ static void Print(CORO_PARAM, int x, int y, SCNHANDLE text, int time, bool bSust
if (IsTopWindow())
MultiSetZPosition(_ctx->pText, Z_TOPW_TEXT);
- } else if (bJapDoPrintText || (!isJapanMode() && (bSubtitles || !_ctx->bSample))) {
+ } else if (bJapDoPrintText || (!isJapanMode() && (_vm->_config->_useSubtitles || !_ctx->bSample))) {
int Loffset, Toffset; // Screen position
PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
_ctx->pText = ObjectTextOut(coroParam, GetPlayfieldList(FIELD_STATUS), TextBufferAddr(),
@@ -1980,7 +1980,7 @@ static void Print(CORO_PARAM, int x, int y, SCNHANDLE text, int time, bool bSust
if (_ctx->bSample) {
// Wait for sample to end whether or not
if (!_vm->_mixer->isSoundHandleActive(_ctx->handle)) {
- if (_ctx->pText == NULL || speedText == DEFTEXTSPEED) {
+ if (_ctx->pText == NULL || _vm->_config->_textSpeed == DEFTEXTSPEED) {
// No text or speed modification - just depends on sample
break;
} else {
@@ -2080,7 +2080,7 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,
}
// Display the text and set it's Z position
- if (event == POINTED || (!isJapanMode() && (bSubtitles || !_ctx->bSample))) {
+ if (event == POINTED || (!isJapanMode() && (_vm->_config->_useSubtitles || !_ctx->bSample))) {
int xshift;
// Get the text string
@@ -2182,7 +2182,7 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,
if (_ctx->bSample) {
// Wait for sample to end whether or not
if (!_vm->_mixer->isSoundHandleActive(_ctx->handle)) {
- if (_ctx->pText == NULL || speedText == DEFTEXTSPEED) {
+ if (_ctx->pText == NULL || _vm->_config->_textSpeed == DEFTEXTSPEED) {
// No text or speed modification - just depends on sample
break;
} else {
@@ -2286,7 +2286,7 @@ static void PrintObjNonPointed(CORO_PARAM, const SCNHANDLE text, const OBJECT *p
CORO_BEGIN_CODE(_ctx);
// Kick off the voice sample
- if (volVoice != 0 && _vm->_sound->sampleExists(text)) {
+ if (_vm->_config->_voiceVolume != 0 && _vm->_sound->sampleExists(text)) {
_vm->_sound->playSample(text, Audio::Mixer::kSpeechSoundType, &_ctx->handle);
_ctx->bSample = _vm->_mixer->isSoundHandleActive(_ctx->handle);
} else
@@ -2317,7 +2317,7 @@ static void PrintObjNonPointed(CORO_PARAM, const SCNHANDLE text, const OBJECT *p
if (_ctx->bSample) {
// Wait for sample to end whether or not
if (!_vm->_mixer->isSoundHandleActive(_ctx->handle)) {
- if (pText == NULL || speedText == DEFTEXTSPEED) {
+ if (pText == NULL || _vm->_config->_textSpeed == DEFTEXTSPEED) {
// No text or speed modification - just depends on sample
break;
} else {
@@ -3013,10 +3013,7 @@ static void Subtitles(int onoff) {
if (isJapanMode())
return; // Subtitles are always off in JAPAN version (?)
- if (onoff == ST_ON)
- bSubtitles = true;
- else
- bSubtitles = false;
+ _vm->_config->_useSubtitles = (onoff == ST_ON);
}
/**
@@ -3249,7 +3246,7 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x
/*
* Kick off the voice sample
*/
- if (volVoice != 0 && _vm->_sound->sampleExists(hText)) {
+ if (_vm->_config->_voiceVolume != 0 && _vm->_sound->sampleExists(hText)) {
if (!TinselV2) {
_vm->_sound->playSample(hText, Audio::Mixer::kSpeechSoundType, &_ctx->handle);
_ctx->bSamples = _vm->_mixer->isSoundHandleActive(_ctx->handle);
@@ -3310,7 +3307,7 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x
if (isJapanMode()) {
_ctx->ticks = JAP_TEXT_TIME;
- } else if (bSubtitles || !_ctx->bSample) {
+ } else if (_vm->_config->_useSubtitles || !_ctx->bSample) {
/*
* Work out where to display the text
*/
@@ -3427,7 +3424,7 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x
if (_ctx->bSample) {
// Wait for sample to end whether or not
if (!_vm->_mixer->isSoundHandleActive(_ctx->handle)) {
- if (_ctx->pText == NULL || speedText == DEFTEXTSPEED) {
+ if (_ctx->pText == NULL || _vm->_config->_textSpeed == DEFTEXTSPEED) {
// No text or speed modification - just depends on sample
break;
} else {
@@ -3505,7 +3502,7 @@ static void TalkAt(CORO_PARAM, int actor, int x, int y, SCNHANDLE text, bool esc
if (escOn && myEscape != GetEscEvents())
return;
- if (!isJapanMode() && (bSubtitles || !_vm->_sound->sampleExists(text)))
+ if (!isJapanMode() && (_vm->_config->_useSubtitles || !_vm->_sound->sampleExists(text)))
SetTextPal(GetActorRGB(actor));
}
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index 8b9a30d517..6a200b446d 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -152,12 +152,12 @@ void KeyboardProcess(CORO_PARAM, const void *) {
case Common::KEYCODE_LALT:
case Common::KEYCODE_RALT:
if (evt.type == Common::EVENT_KEYDOWN) {
- if (!bSwapButtons)
+ if (!_vm->_config->_swapButtons)
ProcessButEvent(PLR_DRAG2_START);
else
ProcessButEvent(PLR_DRAG1_START);
} else {
- if (!bSwapButtons)
+ if (!_vm->_config->_swapButtons)
ProcessButEvent(PLR_DRAG1_END);
else
ProcessButEvent(PLR_DRAG2_END);
@@ -273,7 +273,7 @@ static void SingleLeftProcess(CORO_PARAM, const void *) {
CORO_BEGIN_CODE(_ctx);
// Work out when to wait until
- _ctx->endTicks = DwGetCurrentTime() + (uint32)dclickSpeed;
+ _ctx->endTicks = DwGetCurrentTime() + (uint32)_vm->_config->_dclickSpeed;
// Timeout a double click (may not work once every 49 days!)
do {
@@ -323,7 +323,7 @@ static void MouseProcess(CORO_PARAM, const void *) {
switch (type) {
case Common::EVENT_LBUTTONDOWN:
// left button press
- if (DwGetCurrentTime() - _ctx->lastLeftClick < (uint32)dclickSpeed) {
+ if (DwGetCurrentTime() - _ctx->lastLeftClick < (uint32)_vm->_config->_dclickSpeed) {
// Left button double-click
if (TinselV2) {
@@ -375,7 +375,7 @@ static void MouseProcess(CORO_PARAM, const void *) {
g_scheduler->createProcess(PID_BTN_CLICK, SingleLeftProcess, NULL, 0);
}
} else
- _ctx->lastLeftClick -= dclickSpeed;
+ _ctx->lastLeftClick -= _vm->_config->_dclickSpeed;
if (TinselV2)
// Signal left drag end
@@ -388,7 +388,7 @@ static void MouseProcess(CORO_PARAM, const void *) {
case Common::EVENT_RBUTTONDOWN:
// right button press
- if (DwGetCurrentTime() - _ctx->lastRightClick < (uint32)dclickSpeed) {
+ if (DwGetCurrentTime() - _ctx->lastRightClick < (uint32)_vm->_config->_dclickSpeed) {
// Right button double-click
if (TinselV2) {
PlayerEvent(PLR_NOEVENT, clickPos);
@@ -424,7 +424,7 @@ static void MouseProcess(CORO_PARAM, const void *) {
if (_ctx->lastRWasDouble == false)
_ctx->lastRightClick = DwGetCurrentTime();
else
- _ctx->lastRightClick -= dclickSpeed;
+ _ctx->lastRightClick -= _vm->_config->_dclickSpeed;
if (TinselV2)
// Signal left drag end
@@ -820,6 +820,8 @@ TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc)
Engine(syst), _gameDescription(gameDesc) {
_vm = this;
+ _config = new Config(this);
+
// Register debug flags
Common::addDebugChannel(kTinselDebugAnimations, "animations", "Animations debugging");
Common::addDebugChannel(kTinselDebugActions, "actions", "Actions debugging");
@@ -894,6 +896,8 @@ TinselEngine::~TinselEngine() {
FreeGlobals();
delete _scheduler;
+ delete _config;
+
MemoryDeinit();
}
@@ -940,7 +944,7 @@ Common::Error TinselEngine::run() {
MemoryInit();
// load user configuration
- ReadConfig();
+ _vm->_config->readFromDisk();
#if 1
// FIXME: The following is taken from RestartGame().
@@ -958,7 +962,7 @@ Common::Error TinselEngine::run() {
#endif
// Load in text strings
- ChangeLanguage(g_language);
+ ChangeLanguage(_vm->_config->_language);
// Init palette and object managers, scheduler, keyboard and mouse
RestartDrivers();
@@ -1030,7 +1034,7 @@ Common::Error TinselEngine::run() {
}
// Write configuration
- WriteConfig();
+ _vm->_config->writeToDisk();
return Common::kNoError;
}
@@ -1172,7 +1176,7 @@ void TinselEngine::RestartDrivers() {
}
// Set midi volume
- SetMidiVolume(volMusic);
+ SetMidiVolume(_vm->_config->_musicVolume);
}
/**
diff --git a/engines/tinsel/tinsel.h b/engines/tinsel/tinsel.h
index e396f663c7..27be657624 100644
--- a/engines/tinsel/tinsel.h
+++ b/engines/tinsel/tinsel.h
@@ -45,6 +45,7 @@
namespace Tinsel {
class BMVPlayer;
+class Config;
class MidiMusicPlayer;
class PCMMusicPlayer;
class Scheduler;
@@ -182,6 +183,8 @@ public:
PCMMusicPlayer *_pcmMusic;
BMVPlayer *_bmv;
+ Config *_config;
+
KEYFPTR _keyHandler;
// Stack of pending mouse button events