diff options
| -rw-r--r-- | engines/sludge/builtin.cpp | 19 | ||||
| -rw-r--r-- | engines/sludge/fonttext.cpp | 147 | ||||
| -rw-r--r-- | engines/sludge/fonttext.h | 45 | ||||
| -rw-r--r-- | engines/sludge/loadsave.cpp | 37 | ||||
| -rw-r--r-- | engines/sludge/sludge.cpp | 4 | ||||
| -rw-r--r-- | engines/sludge/sludge.h | 2 | ||||
| -rw-r--r-- | engines/sludge/sprbanks.cpp | 19 | ||||
| -rw-r--r-- | engines/sludge/sprbanks.h | 1 | ||||
| -rw-r--r-- | engines/sludge/statusba.cpp | 19 | ||||
| -rw-r--r-- | engines/sludge/talk.cpp | 8 | 
10 files changed, 171 insertions, 130 deletions
| diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp index 4ae01ab78f..5156aa59ef 100644 --- a/engines/sludge/builtin.cpp +++ b/engines/sludge/builtin.cpp @@ -63,7 +63,6 @@ Variable *launchResult = NULL;  extern int lastFramesPerSecond, thumbWidth, thumbHeight;  extern bool allowAnyFilename;  extern bool captureAllKeys; -extern int16 fontSpace;  extern VariableStack *noStack;  extern StatusStuff  *nowStatus;  extern ScreenRegion *overRegion; @@ -534,7 +533,7 @@ builtIn(stringLength) {  	UNUSEDALL  	Common::String newText = getTextFromAnyVar(fun->stack->thisVar);  	trimStack(fun->stack); -	setVariable(fun->reg, SVT_INT, stringLength(newText)); +	setVariable(fun->reg, SVT_INT, g_sludge->_txtMan->stringLength(newText));  	return BR_CONTINUE;  } @@ -826,7 +825,7 @@ builtIn(setFont) {  		return BR_ERROR;  	//              newDebug ("  File:", fileNumber);  	trimStack(fun->stack); -	if (!loadFont(fileNumber, newText, newHeight)) +	if (!g_sludge->_txtMan->loadFont(fileNumber, newText, newHeight))  		return BR_ERROR;  	//              newDebug ("  Done!");  	return BR_CONTINUE; @@ -838,7 +837,7 @@ builtIn(inFont) {  	trimStack(fun->stack);  	// Return value -	setVariable(fun->reg, SVT_INT, isInFont(newText)); +	setVariable(fun->reg, SVT_INT, g_sludge->_txtMan->isInFont(newText));  	return BR_CONTINUE;  } @@ -854,8 +853,8 @@ builtIn(pasteString) {  		return BR_ERROR;  	trimStack(fun->stack);  	if (x == IN_THE_CENTRE) -		x = g_sludge->_gfxMan->getCenterX(stringWidth(newText)); -	pasteStringToBackdrop(newText, x, y, pastePalette); +		x = g_sludge->_gfxMan->getCenterX(g_sludge->_txtMan->stringWidth(newText)); +	g_sludge->_txtMan->pasteStringToBackdrop(newText, x, y, pastePalette);  	return BR_CONTINUE;  } @@ -1937,7 +1936,7 @@ builtIn(stringWidth) {  	trimStack(fun->stack);  	// Return value -	setVariable(fun->reg, SVT_INT, stringWidth(theText)); +	setVariable(fun->reg, SVT_INT, g_sludge->_txtMan->stringWidth(theText));  	return BR_CONTINUE;  } @@ -1977,7 +1976,7 @@ builtIn(setFontSpacing) {  	int fontSpaceI;  	if (!getValueType(fontSpaceI, SVT_INT, fun->stack->thisVar))  		return BR_ERROR; -	fontSpace = fontSpaceI; +	g_sludge->_txtMan->setFontSpace(fontSpaceI);  	trimStack(fun->stack);  	setVariable(fun->reg, SVT_INT, 1);  	return BR_CONTINUE; @@ -2170,8 +2169,8 @@ builtIn(burnString) {  		return BR_ERROR;  	trimStack(fun->stack);  	if (x == IN_THE_CENTRE) -		x = g_sludge->_gfxMan->getCenterX(stringWidth(newText)); -	burnStringToBackdrop(newText, x, y, pastePalette); +		x = g_sludge->_gfxMan->getCenterX(g_sludge->_txtMan->stringWidth(newText)); +	g_sludge->_txtMan->burnStringToBackdrop(newText, x, y, pastePalette);  	return BR_CONTINUE;  } diff --git a/engines/sludge/fonttext.cpp b/engines/sludge/fonttext.cpp index 9d38b2703a..4c273fec22 100644 --- a/engines/sludge/fonttext.cpp +++ b/engines/sludge/fonttext.cpp @@ -27,22 +27,33 @@  #include "sludge/newfatal.h"  #include "sludge/moreio.h"  #include "sludge/sludge.h" -#include "sludge/utf8.h" +#include "sludge/version.h"  namespace Sludge { -SpriteBank theFont; -int fontHeight = 0, numFontColours, loadedFontNum; -UTF8Converter fontOrder; -int16 fontSpace = -1; +TextManager::TextManager() { +	_theFont.total = 0; +	_theFont.sprites = nullptr; -uint32 *fontTable = NULL; -uint fontTableSize = 0; +	_fontHeight = 0; +	_numFontColours = 0; +	_loadedFontNum = 0; +	_fontSpace = -1; -#define fontInTable(x) ((x<fontTableSize) ? fontTable[(uint32) x] : 0) +	_fontTable = nullptr; +	_fontTableSize = 0; +} + +TextManager::~TextManager() { +	if (_fontTable) { +		delete []_fontTable; +		_fontTable = nullptr; +	} -bool isInFont(const Common::String &theText) { -	if (!fontTableSize) +} + +bool TextManager::isInFont(const Common::String &theText) { +	if (!_fontTableSize)  		return 0;  	if (theText.empty())  		return 0; @@ -56,73 +67,73 @@ bool isInFont(const Common::String &theText) {  	uint32 c = str32[0];  	// check if font order contains the utf8 char -	return fontOrder.getU32String().contains(c); +	return _fontOrder.getU32String().contains(c);  } -int stringLength(const Common::String &theText) { +int TextManager::stringLength(const Common::String &theText) {  	Common::U32String str32 = UTF8Converter::convertUtf8ToUtf32(theText);  	return str32.size();  } -int stringWidth(const Common::String &theText) { +int TextManager::stringWidth(const Common::String &theText) {  	int xOff = 0; -	if (!fontTableSize) +	if (!_fontTableSize)  		return 0;  	Common::U32String str32 = UTF8Converter::convertUtf8ToUtf32(theText);  	for (uint i = 0; i < str32.size(); ++i) {  		uint32 c = str32[i]; -		xOff += theFont.sprites[fontInTable(c)].surface.w + fontSpace; +		xOff += _theFont.sprites[fontInTable(c)].surface.w + _fontSpace;  	}  	return xOff;  } -void pasteString(const Common::String &theText, int xOff, int y, SpritePalette &thePal) { -	if (!fontTableSize) +void TextManager::pasteString(const Common::String &theText, int xOff, int y, SpritePalette &thePal) { +	if (!_fontTableSize)  		return; -	xOff += (int)((float)(fontSpace >> 1) / g_sludge->_gfxMan->getCamZoom()); +	xOff += (int)((float)(_fontSpace >> 1) / g_sludge->_gfxMan->getCamZoom());  	Common::U32String str32 = UTF8Converter::convertUtf8ToUtf32(theText);  	for (uint32 i = 0; i < str32.size(); ++i) {  		uint32 c = str32[i]; -		Sprite *mySprite = &theFont.sprites[fontInTable(c)]; +		Sprite *mySprite = &_theFont.sprites[fontInTable(c)];  		g_sludge->_gfxMan->fontSprite(xOff, y, *mySprite, thePal); -		xOff += (int)((double)(mySprite->surface.w + fontSpace) / g_sludge->_gfxMan->getCamZoom()); +		xOff += (int)((double)(mySprite->surface.w + _fontSpace) / g_sludge->_gfxMan->getCamZoom());  	}  } -void pasteStringToBackdrop(const Common::String &theText, int xOff, int y, SpritePalette &thePal) { -	if (!fontTableSize) +void TextManager::pasteStringToBackdrop(const Common::String &theText, int xOff, int y, SpritePalette &thePal) { +	if (!_fontTableSize)  		return;  	Common::U32String str32 = UTF8Converter::convertUtf8ToUtf32(theText); -	xOff += fontSpace >> 1; +	xOff += _fontSpace >> 1;  	for (uint32 i = 0; i < str32.size(); ++i) {  		uint32 c = str32[i]; -		Sprite *mySprite = &theFont.sprites[fontInTable(c)]; +		Sprite *mySprite = &_theFont.sprites[fontInTable(c)];  		g_sludge->_gfxMan->pasteSpriteToBackDrop(xOff, y, *mySprite, thePal); -		xOff += mySprite->surface.w + fontSpace; +		xOff += mySprite->surface.w + _fontSpace;  	}  } -void burnStringToBackdrop(const Common::String &theText, int xOff, int y, SpritePalette &thePal) { -	if (!fontTableSize) +void TextManager::burnStringToBackdrop(const Common::String &theText, int xOff, int y, SpritePalette &thePal) { +	if (!_fontTableSize)  		return;  	Common::U32String str32 = UTF8Converter::convertUtf8ToUtf32(theText); -	xOff += fontSpace >> 1; +	xOff += _fontSpace >> 1;  	for (uint i = 0; i < str32.size(); ++i) {  		uint32 c = str32[i]; -		Sprite *mySprite = &theFont.sprites[fontInTable(c)]; +		Sprite *mySprite = &_theFont.sprites[fontInTable(c)];  		g_sludge->_gfxMan->burnSpriteToBackDrop(xOff, y, *mySprite, thePal); -		xOff += mySprite->surface.w + fontSpace; +		xOff += mySprite->surface.w + _fontSpace;  	}  } @@ -132,46 +143,86 @@ void setFontColour(SpritePalette &sP, byte r, byte g, byte b) {  	sP.originalBlue = b;  } -bool loadFont(int filenum, const Common::String &charOrder, int h) { -	fontOrder.setUTF8String(charOrder); +bool TextManager::loadFont(int filenum, const Common::String &charOrder, int h) { +	_fontOrder.setUTF8String(charOrder); -	g_sludge->_gfxMan->forgetSpriteBank(theFont); +	g_sludge->_gfxMan->forgetSpriteBank(_theFont); -	loadedFontNum = filenum; +	_loadedFontNum = filenum;  	// get max value among all utf8 chars -	Common::U32String fontOrderString = fontOrder.getU32String(); -	fontTableSize = 0; +	Common::U32String fontOrderString = _fontOrder.getU32String(); +	_fontTableSize = 0;  	for (uint32 i = 0; i < fontOrderString.size(); ++i) {  		uint32 c = fontOrderString[i]; -		if (c > fontTableSize) -			fontTableSize = c; +		if (c > _fontTableSize) +			_fontTableSize = c;  	} -	fontTableSize++; +	_fontTableSize++;  	// create an index table from utf8 char to the index -	delete[] fontTable; -	fontTable = new uint32[fontTableSize]; -	if (!checkNew(fontTable)) +	if (_fontTable) { +		delete []_fontTable; +		_fontTable = nullptr; +	} +	_fontTable = new uint32[_fontTableSize]; +	if (!checkNew(_fontTable))  		return false; -	for (uint i = 0; i < fontTableSize; i++) { -		fontTable[i] = 0; +	for (uint i = 0; i < _fontTableSize; i++) { +		_fontTable[i] = 0;  	}  	for (uint i = 0; i < fontOrderString.size(); ++i) {  		uint32 c = fontOrderString[i]; -		fontTable[c] = i; +		_fontTable[c] = i;  	} -	if (!g_sludge->_gfxMan->loadSpriteBank(filenum, theFont, true)) { +	if (!g_sludge->_gfxMan->loadSpriteBank(filenum, _theFont, true)) {  		fatal("Can't load font");  		return false;  	} -	numFontColours = theFont.myPalette.total; -	fontHeight = h; +	_numFontColours = _theFont.myPalette.total; +	_fontHeight = h;  	return true;  } +// load & save +void TextManager::saveFont(Common::WriteStream *stream) { +	stream->writeByte(_fontTableSize > 0); +	if (_fontTableSize > 0) { +		stream->writeUint16BE(_loadedFontNum); +		stream->writeUint16BE(_fontHeight); +		writeString(_fontOrder.getUTF8String(), stream); +	} +	stream->writeSint16LE(_fontSpace); +} + +void TextManager::loadFont(int ssgVersion, Common::SeekableReadStream *stream) { +	bool fontLoaded = stream->readByte(); +	int fontNum = 0; +	Common::String charOrder = ""; +	if (fontLoaded) { +		fontNum = stream->readUint16BE(); +		_fontHeight = stream->readUint16BE(); + +		if (ssgVersion < VERSION(2, 2)) { +			char *tmp = new char[257]; +			for (int a = 0; a < 256; a++) { +				int x = stream->readByte(); +				tmp[x] = a; +			} +			tmp[256] = 0; +			charOrder = tmp; +			delete []tmp; +		} else { +			charOrder = readString(stream); +		} +	} +	loadFont(fontNum, charOrder, _fontHeight); + +	_fontSpace = stream->readSint16LE(); +} +  } // End of namespace Sludge diff --git a/engines/sludge/fonttext.h b/engines/sludge/fonttext.h index 06cadfded7..c8038cb28d 100644 --- a/engines/sludge/fonttext.h +++ b/engines/sludge/fonttext.h @@ -24,18 +24,49 @@  #include "common/ustr.h" +#include "sludge/sprites.h" +#include "sludge/utf8.h" +  namespace Sludge { +struct SpriteBank;  struct SpritePalette; -bool loadFont(int filenum, const Common::String &charOrder, int); -void pasteString(const Common::String &theText, int, int, SpritePalette &); +class TextManager { +public: +	TextManager(); +	virtual ~TextManager(); + +	int stringWidth(const Common::String &theText); +	int stringLength(const Common::String &theText); + +	bool loadFont(int filenum, const Common::String &charOrder, int); +	void pasteString(const Common::String &theText, int, int, SpritePalette &); +	void pasteStringToBackdrop(const Common::String &theText, int xOff, int y, SpritePalette &thePal); +	void burnStringToBackdrop(const Common::String &theText, int xOff, int y, SpritePalette &thePal); +	bool isInFont(const Common::String &theText); + +	void setFontSpace(int fontSpace) { _fontSpace = fontSpace; } +	int getFontHeight() const { return _fontHeight; } + +	// load & save +	void saveFont(Common::WriteStream *stream); +	void loadFont(int ssgVersion, Common::SeekableReadStream *stream); + +private: +	SpriteBank _theFont; +	int _fontHeight, _numFontColours, _loadedFontNum; +	UTF8Converter _fontOrder; +	int16 _fontSpace; + +	uint32 *_fontTable; +	uint _fontTableSize; + +	inline uint32 fontInTable(uint32 x) { return ((x < _fontTableSize) ? _fontTable[x] : 0); } + +}; +  void setFontColour(SpritePalette &sP, byte r, byte g, byte b); -int stringWidth(const Common::String &theText); -int stringLength(const Common::String &theText); -void pasteStringToBackdrop(const Common::String &theText, int xOff, int y, SpritePalette &thePal); -void burnStringToBackdrop(const Common::String &theText, int xOff, int y, SpritePalette &thePal); -bool isInFont(const Common::String &theText);  } // End of namespace Sludge diff --git a/engines/sludge/loadsave.cpp b/engines/sludge/loadsave.cpp index da3037e94f..494c767684 100644 --- a/engines/sludge/loadsave.cpp +++ b/engines/sludge/loadsave.cpp @@ -63,13 +63,9 @@ extern Floor *currentFloor;                          // In floor.cpp  extern SpeechStruct *speech;                        // In talk.cpp  extern PersonaAnimation  *mouseCursorAnim;           // In cursor.cpp  extern int mouseCursorFrameNum;                     // "    "   " -extern int loadedFontNum, fontHeight;				// In fonttext.cpp -extern uint fontTableSize;							//  -extern UTF8Converter fontOrder;                       // "    "   "  extern FILETIME fileTime;                           // In sludger.cpp  extern int speechMode;                              // "    "   "  extern byte brightnessLevel;               // "    "   " -extern int16 fontSpace;                             // in textfont.cpp  extern byte fadeMode;                      // In transition.cpp  extern bool captureAllKeys;  extern bool allowAnyFilename; @@ -370,14 +366,7 @@ bool saveGame(const Common::String &fname) {  	fp->writeByte(allowAnyFilename);  	fp->writeByte(captureAllKeys);  	fp->writeByte(true); -	fp->writeByte(fontTableSize > 0); - -	if (fontTableSize > 0) { -		fp->writeUint16BE(loadedFontNum); -		fp->writeUint16BE(fontHeight); -		writeString(fontOrder.getUTF8String(), fp); -	} -	fp->writeSint16LE(fontSpace); +	g_sludge->_txtMan->saveFont(fp);  	// Save backdrop  	fp->writeUint16BE(g_sludge->_gfxMan->getCamX()); @@ -520,29 +509,7 @@ bool loadGame(const Common::String &fname) {  	captureAllKeys = fp->readByte();  	fp->readByte();  // updateDisplay (part of movie playing) -	bool fontLoaded = fp->readByte(); -	int fontNum = 0; -	Common::String charOrder = ""; -	if (fontLoaded) { -		fontNum = fp->readUint16BE(); -		fontHeight = fp->readUint16BE(); - -		if (ssgVersion < VERSION(2, 2)) { -			char *tmp = new char[257]; -			for (int a = 0; a < 256; a++) { -				int x = fp->readByte(); -				tmp[x] = a; -			} -			tmp[256] = 0; -			charOrder = tmp; -			delete []tmp; -		} else { -			charOrder = readString(fp); -		} -	} -	loadFont(fontNum, charOrder, fontHeight); - -	fontSpace = fp->readSint16LE(); +	g_sludge->_txtMan->loadFont(ssgVersion, fp);  	killAllPeople();  	killAllRegions(); diff --git a/engines/sludge/sludge.cpp b/engines/sludge/sludge.cpp index 4766356b06..12b6a8b058 100644 --- a/engines/sludge/sludge.cpp +++ b/engines/sludge/sludge.cpp @@ -29,6 +29,7 @@  #include "sludge/graphics.h"  #include "sludge/sludge.h"  #include "sludge/sound.h" +#include "sludge/fonttext.h"  #include "sludge/main_loop.h"  namespace Sludge { @@ -71,6 +72,7 @@ SludgeEngine::SludgeEngine(OSystem *syst, const SludgeGameDescription *gameDesc)  	_gfxMan = new GraphicsManager(this);  	_evtMan = new EventManager(this);  	_soundMan = new SoundManager(); +	_txtMan = new TextManager();  }  SludgeEngine::~SludgeEngine() { @@ -93,6 +95,8 @@ SludgeEngine::~SludgeEngine() {  	_pixelFormat = nullptr;  	// Dispose managers +	delete _txtMan; +	_txtMan = nullptr;  	delete _soundMan;  	_soundMan = nullptr;  	delete _evtMan; diff --git a/engines/sludge/sludge.h b/engines/sludge/sludge.h index 6fb4689481..844d6d0d3f 100644 --- a/engines/sludge/sludge.h +++ b/engines/sludge/sludge.h @@ -41,6 +41,7 @@ extern SludgeEngine *g_sludge;  class EventManager;  class GraphicsManager;  class SoundManager; +class TextManager;  class SludgeConsole; @@ -79,6 +80,7 @@ public:  	GraphicsManager *_gfxMan;  	EventManager *_evtMan;  	SoundManager *_soundMan; +	TextManager *_txtMan;  	SludgeEngine(OSystem *syst, const SludgeGameDescription *gameDesc);  	virtual ~SludgeEngine(); diff --git a/engines/sludge/sprbanks.cpp b/engines/sludge/sprbanks.cpp index d1d63c7a38..265764bfdc 100644 --- a/engines/sludge/sprbanks.cpp +++ b/engines/sludge/sprbanks.cpp @@ -32,9 +32,6 @@  namespace Sludge {  LoadedSpriteBank *allLoadedBanks = NULL; -extern SpriteBank theFont; -extern int loadedFontNum; -extern uint fontTableSize;  LoadedSpriteBank *loadBankForAnim(int ID) {  	LoadedSpriteBank *returnMe = allLoadedBanks; @@ -62,20 +59,4 @@ LoadedSpriteBank *loadBankForAnim(int ID) {  		return NULL;  } -void reloadSpriteTextures() { -	LoadedSpriteBank *spriteBank = allLoadedBanks; -	while (spriteBank) { -		//fprintf (stderr, "Reloading bank %d: %s.\n", spriteBank->ID, resourceNameFromNum (spriteBank->ID)); -		delete spriteBank->bank.sprites; -		spriteBank->bank.sprites = NULL; -		g_sludge->_gfxMan->loadSpriteBank(spriteBank->ID, spriteBank->bank, false); -		spriteBank = spriteBank->next; -	} -	if (fontTableSize) { -		delete theFont.sprites; -		theFont.sprites = NULL; -		g_sludge->_gfxMan->loadSpriteBank(loadedFontNum, theFont, true); -	} -} -  } // End of namespace Sludge diff --git a/engines/sludge/sprbanks.h b/engines/sludge/sprbanks.h index bbf046a3f1..99651b7c6f 100644 --- a/engines/sludge/sprbanks.h +++ b/engines/sludge/sprbanks.h @@ -33,7 +33,6 @@ struct LoadedSpriteBank {  };  LoadedSpriteBank *loadBankForAnim(int ID); -void reloadSpriteTextures();  } // End of namespace Sludge diff --git a/engines/sludge/statusba.cpp b/engines/sludge/statusba.cpp index e46736a07d..9e8546a3ff 100644 --- a/engines/sludge/statusba.cpp +++ b/engines/sludge/statusba.cpp @@ -39,7 +39,6 @@ SpritePalette litVerbLinePalette;  StatusStuff  mainStatus;  StatusStuff  *nowStatus = & mainStatus; -extern int fontHeight;  void setLitStatus(int i) {  	nowStatus->litStatus = i; @@ -93,18 +92,24 @@ void drawStatusBar() {  	while (stat) {  		switch (nowStatus->alignStatus) {  		case IN_THE_CENTRE: -			pasteString(stat->text, ((g_system->getWidth() - stringWidth(stat->text)) >> 1) / cameraZoom, y / cameraZoom, (n++ == nowStatus->litStatus) ? litVerbLinePalette : verbLinePalette); +			g_sludge->_txtMan->pasteString(stat->text, +					((g_system->getWidth() - g_sludge->_txtMan->stringWidth(stat->text)) >> 1) / cameraZoom, y / cameraZoom, +					(n++ == nowStatus->litStatus) ? litVerbLinePalette : verbLinePalette);  			break;  		case 1001: -			pasteString(stat->text, (g_system->getWidth() - stringWidth(stat->text)) - nowStatus->statusX / cameraZoom, y / cameraZoom, (n ++ == nowStatus->litStatus) ? litVerbLinePalette : verbLinePalette); +			g_sludge->_txtMan->pasteString(stat->text, +					(g_system->getWidth() - g_sludge->_txtMan->stringWidth(stat->text)) - nowStatus->statusX / cameraZoom, y / cameraZoom, +					(n ++ == nowStatus->litStatus) ? litVerbLinePalette : verbLinePalette);  			break;  		default: -			pasteString(stat->text, nowStatus->statusX / cameraZoom, y / cameraZoom, (n ++ == nowStatus->litStatus) ? litVerbLinePalette : verbLinePalette); +			g_sludge->_txtMan->pasteString(stat->text, +					nowStatus->statusX / cameraZoom, y / cameraZoom, +					(n ++ == nowStatus->litStatus) ? litVerbLinePalette : verbLinePalette);  		}  		stat = stat->next; -		y -= fontHeight; +		y -= g_sludge->_txtMan->getFontHeight();  	}  } @@ -122,7 +127,7 @@ void statusBarLitColour(byte r, byte g, byte b) {  	nowStatus->statusLB = b;  } -StatusStuff  *copyStatusBarStuff(StatusStuff  *here) { +StatusStuff *copyStatusBarStuff(StatusStuff  *here) {  	// Things we want to keep  	here->statusLR = nowStatus->statusLR; @@ -145,7 +150,7 @@ StatusStuff  *copyStatusBarStuff(StatusStuff  *here) {  	return old;  } -void restoreBarStuff(StatusStuff  *here) { +void restoreBarStuff(StatusStuff *here) {  	delete nowStatus;  	setFontColour(verbLinePalette, here->statusR, here->statusG, here->statusB);  	setFontColour(litVerbLinePalette, here->statusLR, here->statusLG, here->statusLB); diff --git a/engines/sludge/talk.cpp b/engines/sludge/talk.cpp index 23ebc5f461..531fb42fd8 100644 --- a/engines/sludge/talk.cpp +++ b/engines/sludge/talk.cpp @@ -38,7 +38,7 @@  namespace Sludge { -extern int fontHeight, speechMode; +extern int speechMode;  SpeechStruct *speech;  float speechSpeed = 1; @@ -78,7 +78,7 @@ inline void setObjFontColour(ObjectType *t) {  void addSpeechLine(const Common::String &theLine, int x, int &offset) {  	float cameraZoom = g_sludge->_gfxMan->getCamZoom(); -	int halfWidth = (stringWidth(theLine) >> 1) / cameraZoom; +	int halfWidth = (g_sludge->_txtMan->stringWidth(theLine) >> 1) / cameraZoom;  	int xx1 = x - (halfWidth);  	int xx2 = x + (halfWidth);  	SpeechLine *newLine = new SpeechLine; @@ -103,6 +103,7 @@ int isThereAnySpeechGoingOn() {  int wrapSpeechXY(const Common::String &theText, int x, int y, int wrap, int sampleFile) {  	float cameraZoom = g_sludge->_gfxMan->getCamZoom(); +	int fontHeight = g_sludge->_txtMan->getFontHeight();  	int cameraY = g_sludge->_gfxMan->getCamY();  	int a, offset = 0; @@ -206,10 +207,11 @@ int wrapSpeech(const Common::String &theText, int objT, int sampleFile, bool ani  void viewSpeech() {  	float cameraZoom = g_sludge->_gfxMan->getCamZoom(); +	int fontHeight = g_sludge->_txtMan->getFontHeight();  	int viewY = speech->speechY;  	SpeechLine *viewLine = speech->allSpeech;  	while (viewLine) { -		pasteString(viewLine->textLine, viewLine->x, viewY, speech->talkCol); +		g_sludge->_txtMan->pasteString(viewLine->textLine, viewLine->x, viewY, speech->talkCol);  		viewY -= fontHeight / cameraZoom;  		viewLine = viewLine->next;  	} | 
