diff options
| author | Jaromir Wysoglad | 2019-05-30 15:28:12 +0200 | 
|---|---|---|
| committer | Thierry Crozat | 2019-07-28 15:09:14 +0100 | 
| commit | 43393fc29fbda09d5df0bbe58d76ecb854c87b74 (patch) | |
| tree | fb1f5bb54bb75c7f9a727dc89028e4568d9fa2de | |
| parent | 701a9570070009dfc45f93330d19645b6f6ed1ce (diff) | |
| download | scummvm-rg350-43393fc29fbda09d5df0bbe58d76ecb854c87b74.tar.gz scummvm-rg350-43393fc29fbda09d5df0bbe58d76ecb854c87b74.tar.bz2 scummvm-rg350-43393fc29fbda09d5df0bbe58d76ecb854c87b74.zip  | |
SUPERNOVA2: Add Dialogues from supernova engine
| -rw-r--r-- | engines/supernova2/ms2_def.h | 5 | ||||
| -rw-r--r-- | engines/supernova2/state.cpp | 128 | ||||
| -rw-r--r-- | engines/supernova2/state.h | 8 | 
3 files changed, 138 insertions, 3 deletions
diff --git a/engines/supernova2/ms2_def.h b/engines/supernova2/ms2_def.h index a495adf585..0f404974b0 100644 --- a/engines/supernova2/ms2_def.h +++ b/engines/supernova2/ms2_def.h @@ -128,7 +128,7 @@ enum StringId {  	kNoString = -1,  kStringCommandGo, kStringCommandLook, kStringCommandTake, kStringCommandOpen, kStringCommandClose,  kStringCommandPress, kStringCommandPull, kStringCommandUse, kStringCommandTalk, kStringCommandGive, -kString10, kStringStatusCommandGo, kStringStatusCommandLook, kStringStatusCommandTake, kStringStatusCommandOpen, +kStringConversationEnd, kStringStatusCommandGo, kStringStatusCommandLook, kStringStatusCommandTake, kStringStatusCommandOpen,  kStringStatusCommandClose, kStringStatusCommandPress, kStringStatusCommandPull, kStringStatusCommandUse, kStringStatusCommandTalk,  kStringStatusCommandGive, kPhrasalVerbParticleGiveTo, kPhrasalVerbParticleUseWith, kString23, kString24,  kString25, kString26, kString27, kStringTextSpeed, kString29, @@ -248,7 +248,8 @@ kStringIntro6, kStringIntro7, kStringIntro8, kStringIntroTV1, kStringIntroTV2,  kStringIntroTV3, kStringIntroTV4, kStringIntroTV5, kStringIntroTV6, kStringIntroTV7,  kStringIntroTV8, kStringIntroTV9, kStringIntroTV10, kStringIntroTV11, kStringIntroTV12,  kStringIntroTV13, kStringIntroTV14, kStringIntroTV15, kStringIntroTV16, kStringIntro9, -kStringIntro10, kStringIntro11, kStringIntro12, kStringIntro13, kStringIntro14 +kStringIntro10, kStringIntro11, kStringIntro12, kStringIntro13, kStringIntro14, +kStringDialogSeparator  };  ObjectType operator|(ObjectType a, ObjectType b); diff --git a/engines/supernova2/state.cpp b/engines/supernova2/state.cpp index 4a10522cd8..204264e2c9 100644 --- a/engines/supernova2/state.cpp +++ b/engines/supernova2/state.cpp @@ -184,7 +184,7 @@ void GameManager::initState() {  	_currentSentence = -1;  	for (int i = 0 ; i < 6 ; ++i) {  		_sentenceNumber[i] = -1; -//		_texts[i] = kNoString; +		_texts[i] = kNoString;  		_rows[i] = 0;  		_rowsStart[i] = 0;  	} @@ -561,6 +561,132 @@ void GameManager::drawStatus() {  	}  } +void GameManager::sentence(int number, bool brightness) { +	if (number < 0) +		return; +	_vm->renderBox(0, 141 + _rowsStart[number] * 10, 320, _rows[number] * 10 - 1, kColorWhite44); +	if (_texts[_rowsStart[number]] == kStringDialogSeparator) +		_vm->renderText(kStringConversationEnd, 1, 142 + _rowsStart[number] * 10, kColorRed); +	else { +		for (int r = _rowsStart[number]; r < _rowsStart[number] + _rows[number]; ++r) +			_vm->renderText(_texts[r], 1, 142 + r * 10, kColorGreen); +	} +} + +void GameManager::say(StringId textId) { +	Common::String str = _vm->getGameString(textId); +	if (!str.empty()) +		say(str.c_str()); +} + +void GameManager::say(const char *text) { +	Common::String t(text); +	char *row[6]; +	Common::String::iterator p = t.begin(); +	uint numRows = 0; +	while (*p) { +		row[numRows++] = p; +		while ((*p != '\0') && (*p != '|')) { +			++p; +		} +		if (*p == '|') { +			*p = 0; +			++p; +		} +	} + +	_vm->renderBox(0, 138, 320, 62, kColorBlack); +	_vm->renderBox(0, 141, 320, numRows * 10 - 1, kColorWhite25); +	for (uint r = 0; r < numRows; ++r) +		_vm->renderText(row[r], 1, 142 + r * 10, kColorDarkGreen); +	waitOnInput((t.size() + 20) * _vm->_textSpeed / 10); +	_vm->renderBox(0, 138, 320, 62, kColorBlack); +} + +void GameManager::reply(StringId textId, int aus1, int aus2) { +	Common::String str = _vm->getGameString(textId); +	if (!str.empty()) +		reply(str.c_str(), aus1, aus2); +} + +void GameManager::reply(const char *text, int aus1, int aus2) { +	if (*text != '|') +		_vm->renderMessage(text, kMessageTop); + +	for (int z = (strlen(text) + 20) * _vm->_textSpeed / 40; z > 0; --z) { +		_vm->renderImage(aus1); +		waitOnInput(2); +		if (_keyPressed || _mouseClicked) +			z = 1; +		_vm->renderImage(aus2); +		waitOnInput(2); +		if (_keyPressed || _mouseClicked) +			z = 1; +	} +	if (*text != '|') +		_vm->removeMessage(); +} + +int GameManager::dialog(int num, byte rowLength[6], StringId text[6], int number) { +	_vm->_allowLoadGame = false; +	_guiEnabled = false; + +	bool remove[6]; +	for (int i = 0; i < 5; ++i) +		remove[i] = _currentRoom->sentenceRemoved(i, number); +	// The original does not initialize remove[5]!!! +	// Set it to false/0. But maybe the loop above should use 6 instead of 5? +	remove[5] = false; + +	_vm->renderBox(0, 138, 320, 62, kColorBlack); + +	for (int i = 0; i < 6 ; ++i) +		_sentenceNumber[i] = -1; + +	int r = 0, rq = 0; +	for (int i = 0; i < num; ++i) { +		if (!remove[i]) { +			_rowsStart[i] = r; +			_rows[i] = rowLength[i]; +			for (int j = 0; j < _rows[i]; ++j, ++r, ++rq) { +				_texts[r] = text[rq]; +				_sentenceNumber[r] = i; +			} +			sentence(i, false); +		} else +			rq += rowLength[i]; +	} + +	_currentSentence = -1; +	do { +		do { +			updateEvents(); +			mousePosDialog(_mouseX, _mouseY); +			g_system->updateScreen(); +			g_system->delayMillis(_vm->_delay); +		} while (!_mouseClicked && !_vm->shouldQuit()); +	} while (_currentSentence == -1 && !_vm->shouldQuit()); + +	_vm->renderBox(0, 138, 320, 62, kColorBlack); + +	if (number && _currentSentence != -1 && _texts[_rowsStart[_currentSentence]] != kStringDialogSeparator) +		_currentRoom->removeSentence(_currentSentence, number); + +	_guiEnabled = true; +	_vm->_allowLoadGame = true; + +	return _currentSentence; +} + +void GameManager::mousePosDialog(int x, int y) { +	int a = y < 141 ? -1 : _sentenceNumber[(y - 141) / 10]; +	if (a != _currentSentence) { +		sentence(_currentSentence, false); +		_currentSentence = a; +		sentence(_currentSentence, true); +	} +} +  void GameManager::takeObject(Object &obj) {  	if (obj.hasProperty(CARRIED))  		return; diff --git a/engines/supernova2/state.h b/engines/supernova2/state.h index b849cde14d..237298f24e 100644 --- a/engines/supernova2/state.h +++ b/engines/supernova2/state.h @@ -143,6 +143,7 @@ public:  	// Dialog  	int _currentSentence;  	int _sentenceNumber[6]; +	StringId _texts[6];  	byte _rows[6];  	byte _rowsStart[6]; @@ -171,6 +172,13 @@ public:  	void handleInput();  	void handleTime();  	void setAnimationTimer(int ticks); +	int  dialog(int num, byte rowLength[6], StringId text[6], int number); +	void sentence(int number, bool brightness); +	void say(StringId textId); +	void say(const char *text); +	void reply(StringId textId, int aus1, int aus2); +	void reply(const char *text, int aus1, int aus2); +	void mousePosDialog(int x, int y);  private:  	int _prevImgId;  | 
