[Scummvm-git-logs] scummvm master -> bb986b65d6b3e6799a9293c5309360e7d5d17b3e

mgerhardy martin.gerhardy at gmail.com
Thu Dec 17 11:23:53 UTC 2020


This automated email contains information about 10 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
438f4aeadb TWINE: fps limit helper
c2f5ed1533 TWINE: use ScopedFPS in GameState::processFoundItem
035d2fe0c0 TWINE: fixed not being able to quit the item-collected dialog
243053c4d0 TWINE: renamed enum identifier
c0ba8e524a TWINE: use ScopedFPS in processInventoryMenu
82994f91d4 TWINE: renamed variable
78ac4c3681 TWINE: removed member var
57ec195b7e TWINE: fixed UINextPage check - the keymap wasn't active
82e0035239 TWINE: comment on progressiveTextBuffer
bb986b65d6 TWINE: implemented credits sequence in main menu


Commit: 438f4aeadbc143a7c101f1eefa761546f92a52dd
    https://github.com/scummvm/scummvm/commit/438f4aeadbc143a7c101f1eefa761546f92a52dd
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-17T10:28:08+01:00

Commit Message:
TWINE: fps limit helper

Changed paths:
    engines/twine/twine.cpp
    engines/twine/twine.h


diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index f0c466eff2..697cad1252 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -90,6 +90,21 @@ ScopedCursor::~ScopedCursor() {
 	_engine->popMouseCursorVisible();
 }
 
+ScopedFPS::ScopedFPS(uint32 fps) : _fps(fps) {
+	_start = g_system->getMillis();
+}
+
+ScopedFPS::~ScopedFPS() {
+	const uint32 end = g_system->getMillis();
+	const uint32 frameTime = end - _start;
+	const uint32 maxDelay = 1000 / _fps;
+	if (frameTime > maxDelay) {
+		return;
+	}
+	const uint32 waitMillis = maxDelay - frameTime;
+	g_system->delayMillis(waitMillis);
+}
+
 TwinEEngine::TwinEEngine(OSystem *system, Common::Language language, uint32 flags, TwineGameType gameType)
     : Engine(system), _gameType(gameType), _gameLang(language), _gameFlags(flags), _rnd("twine") {
 	// Add default file directories
diff --git a/engines/twine/twine.h b/engines/twine/twine.h
index af70889bf6..347a884390 100644
--- a/engines/twine/twine.h
+++ b/engines/twine/twine.h
@@ -169,6 +169,15 @@ struct ScopedCursor {
 	~ScopedCursor();
 };
 
+class ScopedFPS {
+private:
+	uint32 _fps;
+	uint32 _start;
+public:
+	ScopedFPS(uint32 fps);
+	~ScopedFPS();
+};
+
 class TwinEEngine : public Engine {
 private:
 	int32 isTimeFreezed = 0;
@@ -204,8 +213,8 @@ public:
 	void pushMouseCursorVisible();
 	void popMouseCursorVisible();
 
-	bool isLBA1() const { return _gameType == TwineGameType::GType_LBA; };
-	bool isLBA2() const { return _gameType == TwineGameType::GType_LBA2; };
+	bool isLBA1() const { return _gameType == TwineGameType::GType_LBA; }
+	bool isLBA2() const { return _gameType == TwineGameType::GType_LBA2; }
 
 	Actor *_actor;
 	Animations *_animations;


Commit: c2f5ed15335691e3745ddf95fcb289b4281add50
    https://github.com/scummvm/scummvm/commit/c2f5ed15335691e3745ddf95fcb289b4281add50
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-17T10:28:09+01:00

Commit Message:
TWINE: use ScopedFPS in GameState::processFoundItem

Changed paths:
    engines/twine/gamestate.cpp


diff --git a/engines/twine/gamestate.cpp b/engines/twine/gamestate.cpp
index 6f793769a9..73c5a702ab 100644
--- a/engines/twine/gamestate.cpp
+++ b/engines/twine/gamestate.cpp
@@ -332,6 +332,7 @@ void GameState::processFoundItem(int32 item) {
 	_engine->_redraw->numOfRedrawBox = 0;
 
 	while (!quitItem) {
+		ScopedFPS fps(1000 / 15);
 		_engine->_interface->resetClip();
 		_engine->_redraw->currNumOfRedrawBox = 0;
 		_engine->_redraw->blitBackgroundAreas();
@@ -365,10 +366,6 @@ void GameState::processFoundItem(int32 item) {
 			textState = _engine->_text->updateProgressiveText();
 		}
 
-		if (textState == ProgressiveTextState::End || textState == ProgressiveTextState::UNK2) {
-			_engine->_system->delayMillis(15);
-		}
-
 		_engine->_redraw->flipRedrawAreas();
 
 		_engine->readKeys();


Commit: 035d2fe0c06b87fe8a0648345d4f6a439ec0fd93
    https://github.com/scummvm/scummvm/commit/035d2fe0c06b87fe8a0648345d4f6a439ec0fd93
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-17T10:28:09+01:00

Commit Message:
TWINE: fixed not being able to quit the item-collected dialog

related to https://bugs.scummvm.org/ticket/12002

Changed paths:
    engines/twine/gamestate.cpp


diff --git a/engines/twine/gamestate.cpp b/engines/twine/gamestate.cpp
index 73c5a702ab..621e9b2ec1 100644
--- a/engines/twine/gamestate.cpp
+++ b/engines/twine/gamestate.cpp
@@ -370,6 +370,11 @@ void GameState::processFoundItem(int32 item) {
 
 		_engine->readKeys();
 		if (_engine->_input->toggleAbortAction()) {
+			quitItem = true;
+			_engine->_text->stopVox(_engine->_text->currDialTextEntry);
+		}
+
+		if (_engine->_input->toggleActionIfActive(TwinEActionType::UINextPage)) {
 			if (textState == ProgressiveTextState::End) {
 				quitItem = true;
 			}


Commit: 243053c4d0008395e6836785214aab1534bbf813
    https://github.com/scummvm/scummvm/commit/243053c4d0008395e6836785214aab1534bbf813
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-17T10:28:09+01:00

Commit Message:
TWINE: renamed enum identifier

Changed paths:
    engines/twine/gamestate.cpp
    engines/twine/menu.cpp
    engines/twine/text.cpp
    engines/twine/text.h


diff --git a/engines/twine/gamestate.cpp b/engines/twine/gamestate.cpp
index 621e9b2ec1..99f94d8963 100644
--- a/engines/twine/gamestate.cpp
+++ b/engines/twine/gamestate.cpp
@@ -378,8 +378,7 @@ void GameState::processFoundItem(int32 item) {
 			if (textState == ProgressiveTextState::End) {
 				quitItem = true;
 			}
-
-			if (textState == ProgressiveTextState::UNK2) {
+			if (textState == ProgressiveTextState::NextPage) {
 				textState = ProgressiveTextState::UNK1;
 			}
 		}
diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index 971399475a..a120aeb19b 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -1167,17 +1167,17 @@ void Menu::processInventoryMenu() {
 			updateItemText = false;
 		}
 
-		if (updateItemText || bx != ProgressiveTextState::UNK2) {
+		if (updateItemText || bx != ProgressiveTextState::NextPage) {
 			bx = _engine->_text->updateProgressiveText();
 		}
 
 		// TRICKY: 3D model rotation delay - only apply when no text is drawing
-		if (bx == ProgressiveTextState::End || bx == ProgressiveTextState::UNK2) {
+		if (bx == ProgressiveTextState::End || bx == ProgressiveTextState::NextPage) {
 			_engine->_system->delayMillis(15);
 		}
 
 		if (_engine->_input->toggleActionIfActive(TwinEActionType::UINextPage)) {
-			if (bx == ProgressiveTextState::UNK2) {
+			if (bx == ProgressiveTextState::NextPage) {
 				_engine->_text->initInventoryDialogueBox();
 				bx = ProgressiveTextState::End;
 			} else {
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index b77dbdefd3..6476c79cfe 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -572,7 +572,7 @@ ProgressiveTextState Text::updateProgressiveText() {
 
 	if (_progressiveTextNextPage && !_progressiveTextEnd) {
 		renderContinueReadingTriangle();
-		return ProgressiveTextState::UNK2;
+		return ProgressiveTextState::NextPage;
 	}
 
 	_dialTextBoxCurrentLine++;
@@ -778,7 +778,7 @@ void Text::drawAskQuestion(int32 index) {
 		_engine->readKeys();
 		textStatus = updateProgressiveText();
 
-		if (textStatus == ProgressiveTextState::UNK2) {
+		if (textStatus == ProgressiveTextState::NextPage) {
 			do {
 				_engine->readKeys();
 				if (_engine->shouldQuit()) {
diff --git a/engines/twine/text.h b/engines/twine/text.h
index f40762aeb3..7bad873577 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -104,7 +104,7 @@ enum _TextId {
 enum class ProgressiveTextState {
 	End = 0,
 	UNK1 = 1,
-	UNK2 = 2
+	NextPage = 2
 };
 
 class TwinEEngine;


Commit: c0ba8e524aab16a2254e6a6a2e24e4b4a7cc5bc3
    https://github.com/scummvm/scummvm/commit/c0ba8e524aab16a2254e6a6a2e24e4b4a7cc5bc3
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-17T10:28:09+01:00

Commit Message:
TWINE: use ScopedFPS in processInventoryMenu

Changed paths:
    engines/twine/menu.cpp


diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index a120aeb19b..2a157cec10 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -1115,6 +1115,7 @@ void Menu::processInventoryMenu() {
 #endif
 	ScopedKeyMap scopedKeyMap(_engine, uiKeyMapId);
 	for (;;) {
+		ScopedFPS fps(1000 / 15);
 		_engine->readKeys();
 		int32 prevSelectedItem = inventorySelectedItem;
 
@@ -1171,11 +1172,6 @@ void Menu::processInventoryMenu() {
 			bx = _engine->_text->updateProgressiveText();
 		}
 
-		// TRICKY: 3D model rotation delay - only apply when no text is drawing
-		if (bx == ProgressiveTextState::End || bx == ProgressiveTextState::NextPage) {
-			_engine->_system->delayMillis(15);
-		}
-
 		if (_engine->_input->toggleActionIfActive(TwinEActionType::UINextPage)) {
 			if (bx == ProgressiveTextState::NextPage) {
 				_engine->_text->initInventoryDialogueBox();


Commit: 82994f91d46d2d83311b4610ce9c36f4debc0fee
    https://github.com/scummvm/scummvm/commit/82994f91d46d2d83311b4610ce9c36f4debc0fee
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-17T10:28:09+01:00

Commit Message:
TWINE: renamed variable

Changed paths:
    engines/twine/text.cpp


diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 6476c79cfe..fea36b6955 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -540,16 +540,17 @@ ProgressiveTextState Text::updateProgressiveText() {
 		processTextLine();
 	}
 
+	const char currentChar = *_progressiveTextBufferPtr;
 	// RECHECK this later
-	if (*_progressiveTextBufferPtr == '\0') {
+	if (currentChar == '\0') {
 		return ProgressiveTextState::UNK1;
 	}
 
-	fillFadeInBuffer(_dialTextXPos, _dialTextYPos, *_progressiveTextBufferPtr);
+	fillFadeInBuffer(_dialTextXPos, _dialTextYPos, currentChar);
 	fadeInCharacters(_fadeInCharactersPos, _dialTextStartColor);
-	int8 charWidth = getCharWidth(*_progressiveTextBufferPtr);
+	int8 charWidth = getCharWidth(currentChar);
 
-	if (*_progressiveTextBufferPtr != ' ') {
+	if (currentChar != ' ') {
 		_dialTextXPos += charWidth + 2;
 	} else {
 		if (printText10Var1 != 0) {


Commit: 78ac4c36817cdba5e59e14d64139314ad296547c
    https://github.com/scummvm/scummvm/commit/78ac4c36817cdba5e59e14d64139314ad296547c
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-17T10:28:09+01:00

Commit Message:
TWINE: removed member var

this was always negative and always just decreased. So reaching 0 was only possible in the far
far away future.

Changed paths:
    engines/twine/text.cpp
    engines/twine/text.h


diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index fea36b6955..dd5f7beef5 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -446,7 +446,6 @@ void Text::processTextLine() {
 		}
 		// split the remaining space between the words
 		_dialCharSpace += (_dialTextBoxMaxX - lineBreakX) / spaceCharCount;
-		printText10Var1 = -2 * lineBreakX;
 	}
 
 	_progressiveTextNextWord = buffer;
@@ -550,14 +549,10 @@ ProgressiveTextState Text::updateProgressiveText() {
 	fadeInCharacters(_fadeInCharactersPos, _dialTextStartColor);
 	int8 charWidth = getCharWidth(currentChar);
 
-	if (currentChar != ' ') {
-		_dialTextXPos += charWidth + 2;
+	if (currentChar == ' ') {
+		_dialTextXPos += _dialCharSpace + 1;
 	} else {
-		if (printText10Var1 != 0) {
-			_dialTextXPos++;
-			printText10Var1--;
-		}
-		_dialTextXPos += _dialCharSpace;
+		_dialTextXPos += charWidth + 2;
 	}
 
 	// next character
diff --git a/engines/twine/text.h b/engines/twine/text.h
index 7bad873577..6affebef59 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -169,7 +169,6 @@ private:
 	// TODO: refactor all this variables and related functions
 	char _progressiveTextBuffer[256] {'\0'};
 	const char *_progressiveTextNextWord = nullptr;
-	int32 printText10Var1 = 0;
 
 	int32 _dialTextXPos = 0;
 	int32 _dialTextYPos = 0;


Commit: 57ec195b7e106c9736bcf96cfba3a3c7400ca2d2
    https://github.com/scummvm/scummvm/commit/57ec195b7e106c9736bcf96cfba3a3c7400ca2d2
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-17T10:28:09+01:00

Commit Message:
TWINE: fixed UINextPage check - the keymap wasn't active

Changed paths:
    engines/twine/gamestate.cpp
    engines/twine/text.cpp


diff --git a/engines/twine/gamestate.cpp b/engines/twine/gamestate.cpp
index 99f94d8963..ace49fd14d 100644
--- a/engines/twine/gamestate.cpp
+++ b/engines/twine/gamestate.cpp
@@ -315,7 +315,6 @@ void GameState::processFoundItem(int32 item) {
 	_engine->_text->initDialogueBox();
 
 	ProgressiveTextState textState = ProgressiveTextState::UNK1;
-	bool quitItem = false;
 
 	_engine->_text->initVoxToPlay(item);
 
@@ -331,7 +330,8 @@ void GameState::processFoundItem(int32 item) {
 	Renderer::prepareIsoModel(_engine->_resources->inventoryTable[item]);
 	_engine->_redraw->numOfRedrawBox = 0;
 
-	while (!quitItem) {
+	ScopedKeyMap uiKeyMap(_engine, uiKeyMapId);
+	for (;;) {
 		ScopedFPS fps(1000 / 15);
 		_engine->_interface->resetClip();
 		_engine->_redraw->currNumOfRedrawBox = 0;
@@ -370,13 +370,13 @@ void GameState::processFoundItem(int32 item) {
 
 		_engine->readKeys();
 		if (_engine->_input->toggleAbortAction()) {
-			quitItem = true;
 			_engine->_text->stopVox(_engine->_text->currDialTextEntry);
+			break;
 		}
 
 		if (_engine->_input->toggleActionIfActive(TwinEActionType::UINextPage)) {
 			if (textState == ProgressiveTextState::End) {
-				quitItem = true;
+				break;
 			}
 			if (textState == ProgressiveTextState::NextPage) {
 				textState = ProgressiveTextState::UNK1;
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index dd5f7beef5..ab31a9cad8 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -483,7 +483,6 @@ void Text::renderContinueReadingTriangle() {
 }
 
 void Text::fadeInCharacters(int32 counter, int32 fontColor) {
-	_engine->_system->delayMillis(15);
 	while (--counter >= 0) {
 		const BlendInCharacter *ptr = &_fadeInCharacters[counter];
 		setFontColor(fontColor);


Commit: 82e0035239d600e16b9e0e63a7dbe2a703510b3f
    https://github.com/scummvm/scummvm/commit/82e0035239d600e16b9e0e63a7dbe2a703510b3f
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-17T10:28:09+01:00

Commit Message:
TWINE: comment on progressiveTextBuffer

Changed paths:
    engines/twine/text.cpp


diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index ab31a9cad8..97c0a994da 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -333,6 +333,9 @@ void Text::initText(int32 index) {
 
 void Text::initProgressiveTextBuffer() {
 	Common::fill(&_progressiveTextBuffer[0], &_progressiveTextBuffer[256], ' ');
+	// the end of the buffer defines how fast the next page is shown - as the
+	// whitespaces are handled in the fade in process, too. But we need at least 32 chars,
+	// to completly fade in the last characters of a full page (see TEXT_MAX_FADE_IN_CHR)
 	_progressiveTextBuffer[255] = '\0';
 	_progressiveTextBufferPtr = _progressiveTextBuffer;
 	_dialTextBoxCurrentLine = 0;


Commit: bb986b65d6b3e6799a9293c5309360e7d5d17b3e
    https://github.com/scummvm/scummvm/commit/bb986b65d6b3e6799a9293c5309360e7d5d17b3e
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-17T12:22:47+01:00

Commit Message:
TWINE: implemented credits sequence in main menu

Changed paths:
    engines/twine/gamestate.cpp
    engines/twine/menu.cpp
    engines/twine/menuoptions.cpp
    engines/twine/menuoptions.h
    engines/twine/text.cpp
    engines/twine/text.h
    engines/twine/twine.cpp


diff --git a/engines/twine/gamestate.cpp b/engines/twine/gamestate.cpp
index ace49fd14d..58b8e3129b 100644
--- a/engines/twine/gamestate.cpp
+++ b/engines/twine/gamestate.cpp
@@ -311,7 +311,7 @@ void GameState::processFoundItem(int32 item) {
 	_engine->_text->initTextBank(TextBankId::Inventory_Intro_and_Holomap);
 
 	_engine->_interface->resetClip();
-	_engine->_text->initText(item);
+	_engine->_text->initItemFoundText(item);
 	_engine->_text->initDialogueBox();
 
 	ProgressiveTextState textState = ProgressiveTextState::UNK1;
diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index 2a157cec10..05e9c38a55 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -404,7 +404,9 @@ int32 Menu::processMenu(MenuSettings *menuSettings) {
 		_engine->_screens->copyScreen(_engine->workVideoBuffer, _engine->frontVideoBuffer);
 		_engine->flip();
 	}
+	uint32 startMillis = _engine->_system->getMillis();
 	do {
+		const uint32 loopMillis = _engine->_system->getMillis();
 		_engine->readKeys();
 
 		Common::Point newmousepos = _engine->_input->getMousePositions();
@@ -420,6 +422,7 @@ int32 Menu::processMenu(MenuSettings *menuSettings) {
 			}
 			useMouse = false;
 			buttonsNeedRedraw = true;
+			startMillis = loopMillis;
 		} else if (_engine->_input->toggleActionIfActive(TwinEActionType::UIUp)) {
 			currentButton--;
 			if (currentButton < 0) { // if current button is the first, than previous button is the last
@@ -427,6 +430,7 @@ int32 Menu::processMenu(MenuSettings *menuSettings) {
 			}
 			useMouse = false;
 			buttonsNeedRedraw = true;
+			startMillis = loopMillis;
 		}
 
 		const int16 id = menuSettings->getActiveButtonState();
@@ -550,6 +554,12 @@ int32 Menu::processMenu(MenuSettings *menuSettings) {
 					return textId;
 				}
 			}
+			startMillis = loopMillis;
+		}
+		if (loopMillis - startMillis > 15000) {
+			_engine->_menuOptions->showCredits();
+			startMillis = _engine->_system->getMillis();
+			_engine->_screens->loadMenuImage(false);
 		}
 		_engine->_system->delayMillis(10);
 	} while (!_engine->_input->toggleActionIfActive(TwinEActionType::UIEnter));
@@ -715,7 +725,6 @@ bool Menu::init() {
 	return HQR::getEntry(plasmaEffectPtr, Resources::HQR_RESS_FILE, RESSHQR_PLASMAEFFECT) > 0;
 }
 
-// TODO: if you stay long enough in the main menu without actions, the credits-scene is started
 EngineState Menu::run() {
 	_engine->_text->initTextBank(TextBankId::Options_and_menus);
 
@@ -1108,7 +1117,7 @@ void Menu::processInventoryMenu() {
 	_engine->_text->setFontCrossColor(4);
 	_engine->_text->initDialogueBox();
 
-	ProgressiveTextState bx = ProgressiveTextState::End;
+	ProgressiveTextState textStatus = ProgressiveTextState::End;
 
 #if 0
 	ScopedCursor scopedCursor(_engine);
@@ -1161,25 +1170,25 @@ void Menu::processInventoryMenu() {
 			_engine->_text->initInventoryDialogueBox();
 
 			if (inventorySelectedItem < NUM_INVENTORY_ITEMS && _engine->_gameState->hasItem((InventoryItems)inventorySelectedItem) && !_engine->_gameState->inventoryDisabled()) {
-				_engine->_text->initText(inventorySelectedItem + 100);
+				_engine->_text->initInventoryText(inventorySelectedItem);
 			} else {
-				_engine->_text->initText(NUM_INVENTORY_ITEMS + 100);
+				_engine->_text->initInventoryText(NUM_INVENTORY_ITEMS);
 			}
-			updateItemText = false;
 		}
 
-		if (updateItemText || bx != ProgressiveTextState::NextPage) {
-			bx = _engine->_text->updateProgressiveText();
+		if (updateItemText || textStatus != ProgressiveTextState::NextPage) {
+			textStatus = _engine->_text->updateProgressiveText();
+			updateItemText = false;
 		}
 
 		if (_engine->_input->toggleActionIfActive(TwinEActionType::UINextPage)) {
-			if (bx == ProgressiveTextState::NextPage) {
+			if (textStatus == ProgressiveTextState::NextPage) {
 				_engine->_text->initInventoryDialogueBox();
-				bx = ProgressiveTextState::End;
+				textStatus = ProgressiveTextState::End;
 			} else {
 				if (inventorySelectedItem < NUM_INVENTORY_ITEMS && _engine->_gameState->hasItem((InventoryItems)inventorySelectedItem) && !_engine->_gameState->inventoryDisabled()) {
 					_engine->_text->initInventoryDialogueBox();
-					_engine->_text->initText(inventorySelectedItem + 100);
+					_engine->_text->initInventoryText(inventorySelectedItem);
 				}
 			}
 		}
diff --git a/engines/twine/menuoptions.cpp b/engines/twine/menuoptions.cpp
index ccb4d562d8..5061581941 100644
--- a/engines/twine/menuoptions.cpp
+++ b/engines/twine/menuoptions.cpp
@@ -96,21 +96,24 @@ void MenuOptions::newGame() {
 }
 
 void MenuOptions::showCredits() {
-	canShowCredits = true;
-	int32 tmpShadowMode = _engine->cfgfile.ShadowMode;
+	const int32 tmpShadowMode = _engine->cfgfile.ShadowMode;
 	_engine->cfgfile.ShadowMode = 0;
 	_engine->_gameState->initEngineVars();
 	_engine->_scene->currentSceneIdx = LBA1SceneId::Credits_List_Sequence;
 	_engine->_scene->needChangeScene = LBA1SceneId::Credits_List_Sequence;
 
+	canShowCredits = true;
 	_engine->gameEngineLoop();
-
+	_engine->_scene->stopRunningGame();
 	canShowCredits = false;
+
 	_engine->cfgfile.ShadowMode = tmpShadowMode;
 
 	_engine->_screens->clearScreen();
 	_engine->flip();
+}
 
+void MenuOptions::showEndSequence() {
 	_engine->_flaMovies->playFlaMovie(FLA_THEEND);
 
 	_engine->_screens->clearScreen();
diff --git a/engines/twine/menuoptions.h b/engines/twine/menuoptions.h
index 3b70323475..c0610abf58 100644
--- a/engines/twine/menuoptions.h
+++ b/engines/twine/menuoptions.h
@@ -52,6 +52,7 @@ private:
 public:
 	MenuOptions(TwinEEngine *engine) : _engine(engine) {}
 
+	void showEndSequence();
 	void showCredits();
 	bool canShowCredits = false;
 
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 97c0a994da..eb6cb17862 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -56,7 +56,7 @@ Text::~Text() {
 }
 
 void Text::initVoxBank(int32 bankIdx) {
-	static const char *LanguageSufixTypes[] = {
+	static const char *LanguageSuffixTypes[] = {
 	    "sys",
 	    "cre",
 	    "gam", // global game voices (e.g. inventory descriptions)
@@ -73,11 +73,11 @@ void Text::initVoxBank(int32 bankIdx) {
 	    "010", // Polar Island voices
 	    "011"  //
 	};
-	if (bankIdx < 0 || bankIdx >= ARRAYSIZE(LanguageSufixTypes)) {
+	if (bankIdx < 0 || bankIdx >= ARRAYSIZE(LanguageSuffixTypes)) {
 		error("bankIdx is out of bounds: %i", bankIdx);
 	}
 	// get the correct vox hqr file
-	currentVoxBankFile = Common::String::format("%s%s" VOX_EXT, LanguageTypes[_engine->cfgfile.LanguageId].id, LanguageSufixTypes[bankIdx]);
+	currentVoxBankFile = Common::String::format("%s%s" VOX_EXT, LanguageTypes[_engine->cfgfile.LanguageId].id, LanguageSuffixTypes[bankIdx]);
 	// TODO: loop through other languages and take the scummvm settings regarding voices into account...
 
 	// TODO check the rest to reverse
@@ -307,6 +307,16 @@ void Text::initInventoryDialogueBox() { // SecondInitDialWindow
 	_fadeInCharactersPos = 0;
 }
 
+void Text::initInventoryText(int index) {
+	// 100 if the offset for the inventory item descriptions
+	//
+	initText(100 + index);
+}
+
+void Text::initItemFoundText(int index) {
+	initText(100 + index);
+}
+
 // TODO: refactor this code
 void Text::initText(int32 index) {
 	if (!getText(index)) {
@@ -687,11 +697,12 @@ bool Text::getText(int32 index) {
 	int32 currIdx = 0;
 	// choose right text from order index
 	do {
-		const int32 orderIdx = *(localOrderBuf++);
+		const int16 orderIdx = READ_LE_UINT16(localOrderBuf);
 		if (orderIdx == index) {
 			break;
 		}
 		currIdx++;
+		localOrderBuf++;
 	} while (currIdx < numEntries);
 
 	if (currIdx >= numEntries) {
diff --git a/engines/twine/text.h b/engines/twine/text.h
index 6affebef59..91dfbf33c0 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -264,6 +264,8 @@ public:
 	void initInventoryDialogueBox();
 
 	void initText(int32 index);
+	void initInventoryText(int index);
+	void initItemFoundText(int index);
 	ProgressiveTextState updateProgressiveText();
 
 	/**
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 697cad1252..a5ac037e0a 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -236,6 +236,7 @@ Common::Error TwinEEngine::run() {
 		case EngineState::GameLoop:
 			if (gameEngineLoop()) {
 				_menuOptions->showCredits();
+				_menuOptions->showEndSequence();
 			}
 			_state = EngineState::Menu;
 			break;
@@ -643,7 +644,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 	if (_menuOptions->canShowCredits) {
 		// TODO: if current music playing != 8, than play_track(8);
 		if (_input->toggleAbortAction()) {
-			return 0;
+			return 1;
 		}
 	} else {
 		// Process give up menu - Press ESC




More information about the Scummvm-git-logs mailing list