[Scummvm-cvs-logs] CVS: scummvm/queen cutaway.cpp,1.88,1.89 journal.cpp,1.7,1.8 journal.h,1.2,1.3 logic.cpp,1.124,1.125 logic.h,1.81,1.82 queen.cpp,1.50,1.51 talk.cpp,1.55,1.56 xref.txt,1.45,1.46

Gregory Montoir cyx at users.sourceforge.net
Wed Dec 10 12:14:08 CET 2003


Update of /cvsroot/scummvm/scummvm/queen
In directory sc8-pr-cvs1:/tmp/cvs-serv19999/queen

Modified Files:
	cutaway.cpp journal.cpp journal.h logic.cpp logic.h queen.cpp 
	talk.cpp xref.txt 
Log Message:
get rid of GameConfig, use ConfigurationManager

Index: cutaway.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/cutaway.cpp,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- cutaway.cpp	10 Dec 2003 15:36:44 -0000	1.88
+++ cutaway.cpp	10 Dec 2003 20:13:25 -0000	1.89
@@ -1409,7 +1409,7 @@
 	if (OBJECT_TYPE_TEXT_DISPLAY == type)
 		tmp *= 3;
 
-	return (tmp * 2) / _logic->talkSpeed();
+	return (tmp * 2) / (_logic->talkSpeed() / 3);
 
 }
 

Index: journal.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/journal.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- journal.cpp	6 Dec 2003 13:13:13 -0000	1.7
+++ journal.cpp	10 Dec 2003 20:13:25 -0000	1.8
@@ -31,8 +31,8 @@
 namespace Queen {
 
 
-Journal::Journal(Logic *l, Graphics *g, Display *d, Sound *s, GameConfig *c)
-	: _logic(l), _graphics(g), _display(d), _sound(s), _cfg(c) {
+Journal::Journal(Logic *l, Graphics *g, Display *d, Sound *s)
+	: _logic(l), _graphics(g), _display(d), _sound(s) {
 	_savePath = g_engine->getSavePath();
 	_currentSavePage = 0;
 	_currentSaveSlot = 0;
@@ -44,7 +44,6 @@
 	BobSlot *joe = _graphics->bob(0);
 	_prevJoeX = joe->x;
 	_prevJoeY = joe->y;
-	debug(0, "Journal::prepare() - Joe.pos = (%d,%d)", _prevJoeX, _prevJoeY);
 
 	_edit.enable = false;
 	_mode = M_NORMAL;
@@ -81,6 +80,8 @@
 		g_system->delay_msecs(20);
 	}
 
+	_logic->writeOptionSettings();
+
 	_graphics->textClear(0, GAME_SCREEN_HEIGHT - 1);
 	_graphics->cameraBob(0);
 	if (_quitCleanly) {
@@ -172,9 +173,7 @@
 void Journal::showBob(int bobNum, int16 x, int16 y, int frameNum) {
 
 	BobSlot *bob = _graphics->bob(bobNum);
-	bob->active = true;
-	bob->x = x;
-	bob->y = y;
+	bob->curPos(x, y);
 	bob->frameNum = JOURNAL_FRAMES + frameNum;
 }
 
@@ -201,7 +200,6 @@
 			SaveFile *f = mgr->open_savefile(filename, _savePath, false);
 			if (f) {
 				f->read(_saveDescriptions[i], MAX_SAVE_DESC_LEN);
-				debug(0, "Journal::findSaveDescriptions() - %d %s desc=%s", i, filename, _saveDescriptions[i]);
 				delete f;
 			}
 		}
@@ -266,10 +264,7 @@
 		enterYesNoMode(zoneNum, TXT_GIVE_UP);
 	}
 	if (zoneNum == ZN_TEXT_SPEED) {
-		_cfg->talkSpeed = (x - 136) / 4;
-		if (_cfg->talkSpeed < 1) {
-			_cfg->talkSpeed = 1;
-		}
+		_logic->talkSpeed((x - 136) * 100 / 130);
 		drawConfigPanel();
 	}
 	else if (zoneNum == ZN_SFX_TOGGLE) {
@@ -277,13 +272,7 @@
 		drawConfigPanel();
 	}
 	else if (zoneNum == ZN_MUSIC_VOLUME) {
-		_cfg->musicVolume = (x - 136) * 100 / 130;
-		if (_cfg->musicVolume < 4) {
-			_cfg->musicVolume = 4;
-		}
-		else if (_cfg->musicVolume > 95) {
-			_cfg->musicVolume = 100;
-		}
+		// int val = (x - 136) * 100 / 130;
 		// XXX alter_current_volume();
 		drawConfigPanel();
 	}
@@ -311,22 +300,11 @@
 	}
 	else if (zoneNum == ZN_VOICE_TOGGLE) {
 		_sound->toggleSpeech();
-		if (!_sound->speechOn()) {
-			// ensure text is always on when voice is off
-			_cfg->textToggle = true;
-		}
 		drawConfigPanel();
 	}
 	else if (zoneNum == ZN_TEXT_TOGGLE) {
-		// only allow change on CD-ROM version
-		if (_logic->resource()->JASVersion()[0] == 'C') {
-			_cfg->textToggle = !_cfg->textToggle;
-			if (!_sound->speechOn()) {
-				// ensure text is always on when voice is off
-				_cfg->textToggle = true;
-			}
-			drawConfigPanel();
-		}
+		_logic->subtitles(!_logic->subtitles());
+		drawConfigPanel();
 	}
 }
 
@@ -494,13 +472,16 @@
 
 void Journal::drawConfigPanel() {
 
-	drawSlideBar(_cfg->talkSpeed,     4,   1, BOB_TALK_SPEED,   136 - 4, 164, FRAME_BLUE_PIN);
-	drawSlideBar(_cfg->musicVolume, 130, 100, BOB_MUSIC_VOLUME, 136 - 4, 177, FRAME_GREEN_PIN);
+	_logic->checkOptionSettings();
 
-	drawCheckBox(_sound->sfxOn(),    BOB_SFX_TOGGLE,    221, 155, FRAME_CHECK_BOX);
+	drawSlideBar(_logic->talkSpeed(), 130, 100, BOB_TALK_SPEED, 136 - 4, 164, FRAME_BLUE_PIN);
+	// XXX music_volume
+	drawSlideBar(100, 130, 100, BOB_MUSIC_VOLUME, 136 - 4, 177, FRAME_GREEN_PIN);
+
+	drawCheckBox(_sound->sfxOn(), BOB_SFX_TOGGLE, 221, 155, FRAME_CHECK_BOX);
 	drawCheckBox(_sound->speechOn(), BOB_SPEECH_TOGGLE, 158, 155, FRAME_CHECK_BOX);
-	drawCheckBox(_cfg->textToggle,   BOB_TEXT_TOGGLE,   125, 167, FRAME_CHECK_BOX);
-	drawCheckBox(_sound->musicOn(),  BOB_MUSIC_TOGGLE,  125, 181, FRAME_CHECK_BOX);
+	drawCheckBox(_logic->subtitles(), BOB_TEXT_TOGGLE, 125, 167, FRAME_CHECK_BOX);
+	drawCheckBox(_sound->musicOn(), BOB_MUSIC_TOGGLE, 125, 181, FRAME_CHECK_BOX);
 }
 
 

Index: journal.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/journal.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- journal.h	1 Dec 2003 20:48:40 -0000	1.2
+++ journal.h	10 Dec 2003 20:13:25 -0000	1.3
@@ -35,7 +35,7 @@
 class Journal {
 public:
 
-	Journal(Logic *, Graphics *, Display *, Sound *, GameConfig *);
+	Journal(Logic *, Graphics *, Display *, Sound *);
 	void use();
   
 	enum {
@@ -184,7 +184,6 @@
 	Graphics *_graphics;
 	Display *_display;
 	Sound *_sound;
-	GameConfig *_cfg;
 	const char *_savePath;
 };
 

Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.cpp,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -d -r1.124 -r1.125
--- logic.cpp	10 Dec 2003 15:36:44 -0000	1.124
+++ logic.cpp	10 Dec 2003 20:13:25 -0000	1.125
@@ -20,6 +20,7 @@
  */
 
 #include "stdafx.h"
+#include "common/config-manager.h"
 #include "queen/logic.h"
 #include "queen/command.h"
 #include "queen/cutaway.h"
@@ -181,7 +182,6 @@
 Logic::Logic(Resource *theResource, Graphics *graphics, Display *theDisplay, Input *input, Sound *sound)
 	: _resource(theResource), _graphics(graphics), _display(theDisplay), 
 	_input(input), _sound(sound) {
-	_settings.talkSpeed = DEFAULT_TALK_SPEED;
 	_jas = _resource->loadFile("QUEEN.JAS", 20);
 	_joe.x = _joe.y = 0;
 	_joe.scale = 100;
@@ -381,12 +381,6 @@
 	for (i = 1; i <= _numAFile; i++)
 		_aFile[i] = _resource->getJAS2Line();
 
-	_settings.textToggle = true;	
-	if (_resource->isFloppy())
-		_sound->speechToggle(false);
-	else
-		_sound->speechToggle(true);
-
 	_cmd->clear(false);
 	_scene = 0;
 	memset(_gameState, 0, sizeof(_gameState));
@@ -2404,12 +2398,12 @@
 	memcpy(ptr, buf, 32); ptr += 32;
 	delete[] buf;
 	
-	WRITE_BE_UINT16(ptr, _settings.talkSpeed); ptr += 2;
-	WRITE_BE_UINT16(ptr, _settings.musicVolume); ptr += 2;
+	WRITE_BE_UINT16(ptr, _talkSpeed); ptr += 2;
+	WRITE_BE_UINT16(ptr, 0 /*_settings.musicVolume*/); ptr += 2;
 	WRITE_BE_UINT16(ptr, _sound->sfxOn() ? 1 : 0); ptr += 2;
 	WRITE_BE_UINT16(ptr, _sound->speechOn() ? 1 : 0); ptr += 2;
 	WRITE_BE_UINT16(ptr, _sound->musicOn() ? 1 : 0); ptr += 2;
-	WRITE_BE_UINT16(ptr, _settings.textToggle ? 1 : 0); ptr += 2;
+	WRITE_BE_UINT16(ptr, _subtitles ? 1 : 0); ptr += 2;
 	
 	for (i = 0; i < 4; i++) {
 		WRITE_BE_UINT16(ptr, _inventoryItem[i]); ptr += 2;
@@ -2471,12 +2465,13 @@
 	
 	debug(3, "Loading game from slot %d", slot);
 	ptr += 32;	//skip description
-	_settings.talkSpeed = (int16)READ_BE_UINT16(ptr); ptr += 2;
-	_settings.musicVolume = (int16)READ_BE_UINT16(ptr); ptr += 2;
+	_talkSpeed = (int16)READ_BE_UINT16(ptr); ptr += 2;
+	/*_settings.musicVolume = (int16)READ_BE_UINT16(ptr);*/ ptr += 2;
 	_sound->sfxToggle(READ_BE_UINT16(ptr) != 0); ptr += 2;
 	_sound->speechToggle(READ_BE_UINT16(ptr) != 0); ptr += 2;
 	_sound->musicToggle(READ_BE_UINT16(ptr) != 0); ptr += 2;
-	_settings.textToggle = READ_BE_UINT16(ptr) != 0; ptr += 2;
+	_subtitles = READ_BE_UINT16(ptr) != 0; ptr += 2;
+	ptr += 2 * 6;
 
 	for (i = 0; i < 4; i++) {
 		_inventoryItem[i] = (int16)READ_BE_UINT16(ptr); ptr += 2;
@@ -2647,7 +2642,7 @@
 
 		_cmd->clear(false);
 
-		Journal j(this, _graphics, _display, _sound, &_settings);
+		Journal j(this, _graphics, _display, _sound);
 		j.use();
 
 		_walk->stopJoe();
@@ -2659,6 +2654,67 @@
 		// XXX TALKQUIT=CUTQUIT=0; Make sure that we turn off cut stuff in case we use Journal during cutaways
 
 	}
+}
+
+
+void Logic::registerDefaultSettings() {
+
+	ConfMan.registerDefault("master_volume", 255);
+	ConfMan.registerDefault("music_mute", false);
+	ConfMan.registerDefault("sfx_mute", false);
+	ConfMan.registerDefault("talkspeed", DEFAULT_TALK_SPEED);
+	ConfMan.registerDefault("speech_mute", _resource->isFloppy());
+	ConfMan.registerDefault("subtitles", true);
+}
+
+
+void Logic::checkOptionSettings() {
+
+	// check talkspeed value
+	if (_talkSpeed < 4) {
+		_talkSpeed = 4;
+	}
+	else if (_talkSpeed > 95) {
+		_talkSpeed = 100;
+	}
+
+	// XXX check master_volume value
+
+	// only CD-ROM version has speech
+	if (_resource->JASVersion()[0] != 'C' && _sound->speechOn()) {
+		_sound->speechToggle(false);
+	}
+
+	// ensure text is always on when voice is off
+	if (!_sound->speechOn()) {
+		_subtitles = true;
+	}
+}
+
+
+void Logic::readOptionSettings() {
+
+	// XXX master_volume
+	_sound->musicToggle(!ConfMan.getBool("music_mute"));
+	_sound->sfxToggle(!ConfMan.getBool("sfx_mute"));
+	_talkSpeed = ConfMan.getInt("talkspeed");
+	_sound->speechToggle(!ConfMan.getBool("speech_mute"));
+	_subtitles = ConfMan.getBool("subtitles");
+
+	checkOptionSettings();
+}
+
+
+void Logic::writeOptionSettings() {
+
+	// XXX master_volume
+	ConfMan.set("music_mute", !_sound->musicOn());
+	ConfMan.set("sfx_mute", !_sound->sfxOn());
+	ConfMan.set("talkspeed", _talkSpeed);
+	ConfMan.set("speech_mute", !_sound->speechOn());
+	ConfMan.set("subtitles", _subtitles);
+
+	ConfMan.flushToDisk();
 }
 
 

Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.h,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- logic.h	10 Dec 2003 15:36:44 -0000	1.81
+++ logic.h	10 Dec 2003 20:13:25 -0000	1.82
@@ -41,13 +41,6 @@
 	Box box;
 };
 
-// FIXME: get rid of that and use ConfigurationManager
-struct GameConfig {
-	int musicVolume;
-	bool textToggle;
-	int talkSpeed;
-};
-
 
 /*!
 	Each object/item in game has a state field. 
@@ -202,8 +195,6 @@
 
 	uint16 numFrames() const { return _numFrames; }
 
-	int talkSpeed() const { return _settings.talkSpeed; }
-
 	void zoneSet(uint16 screen, uint16 zone, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void zoneSet(uint16 screen, uint16 zone, const Box& box);
 	uint16 zoneIn(uint16 screen, uint16 x, uint16 y) const;
@@ -300,6 +291,16 @@
 
 	void useJournal();
 
+	int talkSpeed() const { return _talkSpeed; }
+	void talkSpeed(int speed) { _talkSpeed = speed; }
+	bool subtitles() const { return _subtitles; }
+	void subtitles(bool enable) { _subtitles = enable; }
+
+	void registerDefaultSettings();
+	void checkOptionSettings();
+	void readOptionSettings();
+	void writeOptionSettings();
+
 	void executeSpecialMove(uint16 sm);
 
 	void asmMakeJoeUseDress();
@@ -350,7 +351,7 @@
 		MAX_ZONES_NUMBER   = 32,
 		MAX_AREAS_NUMBER   = 11,
 		JOE_RESPONSE_MAX   = 40,
-		DEFAULT_TALK_SPEED = 7,
+		DEFAULT_TALK_SPEED = 7 * 3,
 		GAME_STATE_COUNT   = 211,
 		TALK_SELECTED_COUNT = 86
 	};
@@ -474,13 +475,15 @@
 	//! Describe a string based animation (30 frames maximum, bob number must be < 17)
 	AnimFrame _newAnim[17][30];
 
-	GameConfig _settings;
-
 	//! Inventory items
 	int16 _inventoryItem[4];
 
 	//! scene counter
 	int _scene;
+
+	int _talkSpeed;
+
+	bool _subtitles;
 
 	Resource *_resource;
 	Graphics *_graphics;

Index: queen.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/queen.cpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- queen.cpp	10 Dec 2003 15:37:57 -0000	1.50
+++ queen.cpp	10 Dec 2003 20:13:25 -0000	1.51
@@ -127,6 +127,9 @@
 
 	initialise();
 
+	_logic->registerDefaultSettings();
+	_logic->readOptionSettings();
+
 	_logic->oldRoom(0);
 	_logic->newRoom(_logic->currentRoom());
 

Index: talk.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/talk.cpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- talk.cpp	6 Dec 2003 13:12:52 -0000	1.55
+++ talk.cpp	10 Dec 2003 20:13:25 -0000	1.56
@@ -677,6 +677,7 @@
 	return personWalking;
 }
 
+// cyx : there is a similar function in Cutaway, what about merging them ?
 int Talk::countSpaces(const char *segment) {
 	int tmp = 0;
 
@@ -686,7 +687,7 @@
 	if (tmp < 10)
 		tmp = 10;
 
-	return (tmp * 2) / _logic->talkSpeed();
+	return (tmp * 2) / (_logic->talkSpeed() / 3);
 }
 
 void Talk::headStringAnimation(const SpeechParameters *parameters, int bobNum, int bankNum) {

Index: xref.txt
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/xref.txt,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- xref.txt	10 Dec 2003 15:36:44 -0000	1.45
+++ xref.txt	10 Dec 2003 20:13:25 -0000	1.46
@@ -107,13 +107,13 @@
 game_save()					Logic::gameSave()
 -
 config_request
-MUSICTOGGLE					Sound::musicToggle
-SFXTOGGLE					Sound::sfxToggle
-TALKSPD						GameConfig::talkSpeed
-TEXTTOGGLE					GameConfig::textToggle
-VersionStr					Logic::language (add more functions if needed)
-VOICETOGGLE					Sound::speechToggle
-VOLUME						GameConfig::musicVolume
+MUSICTOGGLE					Sound::_musicToggle / ConfMan.("music_mute")
+SFXTOGGLE					Sound::_sfxToggle / ConfMan.("sfx_mute")
+TALKSPD						Logic::_talkSpeed / ConfMan.("talkspeed")
+TEXTTOGGLE					Logic::_subtitles / ConfMan.("subtitles")
+VersionStr					GameVersion::versionString
+VOICETOGGLE					Sound::_speechToggle / ConfMan.("speech_mute")
+VOLUME						? / ConfMan.("master_volume")
 
 
 GRAPHICS





More information about the Scummvm-git-logs mailing list