[Scummvm-cvs-logs] SF.net SVN: scummvm:[45617] scummvm/trunk/engines/tinsel

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Nov 2 22:56:29 CET 2009


Revision: 45617
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45617&view=rev
Author:   fingolfin
Date:     2009-11-02 21:56:29 +0000 (Mon, 02 Nov 2009)

Log Message:
-----------
TINSEL: Turn config code into a simple C++ class

Modified Paths:
--------------
    scummvm/trunk/engines/tinsel/bmv.cpp
    scummvm/trunk/engines/tinsel/config.cpp
    scummvm/trunk/engines/tinsel/config.h
    scummvm/trunk/engines/tinsel/dialogs.cpp
    scummvm/trunk/engines/tinsel/events.cpp
    scummvm/trunk/engines/tinsel/music.cpp
    scummvm/trunk/engines/tinsel/sound.cpp
    scummvm/trunk/engines/tinsel/sysvar.cpp
    scummvm/trunk/engines/tinsel/tinlib.cpp
    scummvm/trunk/engines/tinsel/tinsel.cpp
    scummvm/trunk/engines/tinsel/tinsel.h

Modified: scummvm/trunk/engines/tinsel/bmv.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/bmv.cpp	2009-11-02 21:54:57 UTC (rev 45616)
+++ scummvm/trunk/engines/tinsel/bmv.cpp	2009-11-02 21:56:29 UTC (rev 45617)
@@ -577,7 +577,7 @@
 
 		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);
 

Modified: scummvm/trunk/engines/tinsel/config.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/config.cpp	2009-11-02 21:54:57 UTC (rev 45616)
+++ scummvm/trunk/engines/tinsel/config.cpp	2009-11-02 21:56:29 UTC (rev 45617)
@@ -38,36 +38,35 @@
 
 namespace Tinsel {
 
-//----------------- GLOBAL GLOBAL DATA --------------------
+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;
+}
 
-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;
 
-
-
 /**
  * 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 @@
 /**
  * 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 @@
 
 		// 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;
 		}
 	}
 }

Modified: scummvm/trunk/engines/tinsel/config.h
===================================================================
--- scummvm/trunk/engines/tinsel/config.h	2009-11-02 21:54:57 UTC (rev 45616)
+++ scummvm/trunk/engines/tinsel/config.h	2009-11-02 21:56:29 UTC (rev 45617)
@@ -36,19 +36,31 @@
 	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;
+class TinselEngine;
 
-void WriteConfig();
-void ReadConfig();
+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();
 
 } // End of namespace Tinsel

Modified: scummvm/trunk/engines/tinsel/dialogs.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/dialogs.cpp	2009-11-02 21:54:57 UTC (rev 45616)
+++ scummvm/trunk/engines/tinsel/dialogs.cpp	2009-11-02 21:56:29 UTC (rev 45617)
@@ -793,18 +793,18 @@
 \*-------------------------------------------------------------*/
 
 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 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 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 @@
 	{ 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 @@
 	{ 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 @@
 	{ 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 @@
 
 
 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 @@
 		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 @@
 
 		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 @@
 	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 @@
 		OpenMenu(MAIN_MENU);
 
 		// Write config changes
-		WriteConfig();
+		_vm->_config->writeToDisk();
 
 	} else if (ino == INV_CONF)
 		InventoryIconCursor(false);
@@ -4456,7 +4456,7 @@
 	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 @@
 	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

Modified: scummvm/trunk/engines/tinsel/events.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/events.cpp	2009-11-02 21:54:57 UTC (rev 45616)
+++ scummvm/trunk/engines/tinsel/events.cpp	2009-11-02 21:56:29 UTC (rev 45617)
@@ -101,7 +101,7 @@
 	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 @@
  * ProcessButEvent
  */
 void ProcessButEvent(PLR_EVENT be) {
-	if (bSwapButtons) {
+	if (_vm->_config->_swapButtons) {
 		switch (be) {
 		case PLR_SLEFT:
 			be = PLR_SRIGHT;

Modified: scummvm/trunk/engines/tinsel/music.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/music.cpp	2009-11-02 21:54:57 UTC (rev 45616)
+++ scummvm/trunk/engines/tinsel/music.cpp	2009-11-02 21:56:29 UTC (rev 45617)
@@ -184,8 +184,8 @@
 	// 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 @@
  * Gets the volume of the MIDI music.
  */
 int GetMidiVolume() {
-	return volMusic;
+	return _vm->_config->_musicVolume;
 }
 
 static int priorVolMusic = 0;
@@ -963,9 +963,9 @@
 	currentMidi = Midi;
 	currentLoop = Loop;
 
-	if (volMusic != 0 && Loop) {
+	if (_vm->_config->_musicVolume != 0 && Loop) {
 		PlayMidiSequence(currentMidi, true);
-		SetMidiVolume(volMusic);
+		SetMidiVolume(_vm->_config->_musicVolume);
 	}
 }
 

Modified: scummvm/trunk/engines/tinsel/sound.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/sound.cpp	2009-11-02 21:54:57 UTC (rev 45616)
+++ scummvm/trunk/engines/tinsel/sound.cpp	2009-11-02 21:56:29 UTC (rev 45617)
@@ -111,9 +111,9 @@
 		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 @@
 			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 @@
 	}
 
 	// 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;

Modified: scummvm/trunk/engines/tinsel/sysvar.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/sysvar.cpp	2009-11-02 21:54:57 UTC (rev 45616)
+++ scummvm/trunk/engines/tinsel/sysvar.cpp	2009-11-02 21:56:29 UTC (rev 45617)
@@ -155,7 +155,7 @@
 	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;

Modified: scummvm/trunk/engines/tinsel/tinlib.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/tinlib.cpp	2009-11-02 21:54:57 UTC (rev 45616)
+++ scummvm/trunk/engines/tinsel/tinlib.cpp	2009-11-02 21:56:29 UTC (rev 45617)
@@ -402,10 +402,10 @@
 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 @@
 		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 @@
 	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 @@
 
 	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 @@
 		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 @@
 			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 @@
 		}
 
 		// 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 @@
 					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 @@
 
 	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 @@
 			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 @@
 	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 @@
 	/*
 	 * 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 @@
 
 		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 @@
 			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 @@
 		if (escOn && myEscape != GetEscEvents())
 			return;
 
-		if (!isJapanMode() && (bSubtitles || !_vm->_sound->sampleExists(text)))
+		if (!isJapanMode() && (_vm->_config->_useSubtitles || !_vm->_sound->sampleExists(text)))
 			SetTextPal(GetActorRGB(actor));
 	}
 

Modified: scummvm/trunk/engines/tinsel/tinsel.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/tinsel.cpp	2009-11-02 21:54:57 UTC (rev 45616)
+++ scummvm/trunk/engines/tinsel/tinsel.cpp	2009-11-02 21:56:29 UTC (rev 45617)
@@ -152,12 +152,12 @@
 		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 @@
 	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 @@
 		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 @@
 					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 @@
 		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 @@
 			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 @@
 		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 @@
 	FreeGlobals();
 	delete _scheduler;
 
+	delete _config;
+
 	MemoryDeinit();
 }
 
@@ -940,7 +944,7 @@
 	MemoryInit();
 
 	// load user configuration
-	ReadConfig();
+	_vm->_config->readFromDisk();
 
 #if 1
 	// FIXME: The following is taken from RestartGame().
@@ -958,7 +962,7 @@
 #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 @@
 	}
 
 	// Write configuration
-	WriteConfig();
+	_vm->_config->writeToDisk();
 
 	return Common::kNoError;
 }
@@ -1172,7 +1176,7 @@
 	}
 
 	// Set midi volume
-	SetMidiVolume(volMusic);
+	SetMidiVolume(_vm->_config->_musicVolume);
 }
 
 /**

Modified: scummvm/trunk/engines/tinsel/tinsel.h
===================================================================
--- scummvm/trunk/engines/tinsel/tinsel.h	2009-11-02 21:54:57 UTC (rev 45616)
+++ scummvm/trunk/engines/tinsel/tinsel.h	2009-11-02 21:56:29 UTC (rev 45617)
@@ -45,6 +45,7 @@
 namespace Tinsel {
 
 class BMVPlayer;
+class Config;
 class MidiMusicPlayer;
 class PCMMusicPlayer;
 class Scheduler;
@@ -182,6 +183,8 @@
 	PCMMusicPlayer *_pcmMusic;
 	BMVPlayer *_bmv;
 
+	Config *_config;
+
 	KEYFPTR _keyHandler;
 
 	// Stack of pending mouse button events


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list