From 36faf0890fec6bab90531ade42c0eb924b31b64a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 Apr 2016 22:22:12 -0400 Subject: TITANIC: Minor work towards text display --- engines/titanic/pet_control/pet_text.cpp | 9 +++++++-- engines/titanic/pet_control/pet_text.h | 5 ++++- engines/titanic/support/font.cpp | 10 +++++++--- engines/titanic/support/font.h | 5 +++++ engines/titanic/support/screen_manager.cpp | 11 ++++++++++- engines/titanic/support/screen_manager.h | 14 +++++++++++--- 6 files changed, 44 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/titanic/pet_control/pet_text.cpp b/engines/titanic/pet_control/pet_text.cpp index ca65b23ee1..35f5f8d8de 100644 --- a/engines/titanic/pet_control/pet_text.cpp +++ b/engines/titanic/pet_control/pet_text.cpp @@ -130,7 +130,7 @@ void CPetText::draw(CScreenManager *screenManager) { screenManager->fillRect(SURFACE_BACKBUFFER, &tempRect, _backR, _backG, _backB); } - draw2(screenManager); + getTextHeight(screenManager); tempRect = _bounds; tempRect.grow(-2); @@ -217,8 +217,13 @@ void CPetText::updateStr3(int lineNum) { } } -void CPetText::draw2(CScreenManager *screenManager) { +int CPetText::getTextHeight(CScreenManager *screenManager) { + mergeStrings(); + int oldFontNumber = screenManager->setFontNumber(_fontNumber2); + int textHeight = screenManager->getTextBounds(_lines, _bounds.width()); + screenManager->setFontNumber(oldFontNumber); + return textHeight; } } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_text.h b/engines/titanic/pet_control/pet_text.h index 9fd057a652..24c4e949b6 100644 --- a/engines/titanic/pet_control/pet_text.h +++ b/engines/titanic/pet_control/pet_text.h @@ -78,7 +78,10 @@ private: void updateStr3(int lineNum); - void draw2(CScreenManager *screenManager); + /** + * Get the required height to draw the text + */ + int getTextHeight(CScreenManager *screenManager); public: CPetText(uint count = 10); diff --git a/engines/titanic/support/font.cpp b/engines/titanic/support/font.cpp index f5d28ea9ca..e903abaf97 100644 --- a/engines/titanic/support/font.cpp +++ b/engines/titanic/support/font.cpp @@ -127,7 +127,11 @@ int STFont::stringWidth(const CString &text) const { return total; } -int STFont::writeChar(CVideoSurface *surface, unsigned char c, const Common::Point &pt, Rect *destRect, Rect *srcRect) { +int STFont::writeString(CVideoSurface *surface, const Point &pt, const CString &str) { + return 0; +} + +int STFont::writeChar(CVideoSurface *surface, unsigned char c, const Point &pt, Rect *destRect, Rect *srcRect) { if (c == 233) c = '$'; @@ -174,7 +178,7 @@ int STFont::writeChar(CVideoSurface *surface, unsigned char c, const Common::Poi return 0; } -void STFont::copyRect(CVideoSurface *surface, const Common::Point &pt, Rect &rect) { +void STFont::copyRect(CVideoSurface *surface, const Point &pt, Rect &rect) { if (surface->lock()) { uint16 *lineP = surface->getBasePtr(pt.x, pt.y); uint16 color = getColor(); @@ -203,7 +207,7 @@ void STFont::extendBounds(Point &textSize, byte c, int maxWidth) const { void STFont::checkLineWrap(Point &textSize, int maxWidth, const char *&str) const { bool flag = false; int totalWidth = 0; - for (const char *srcPtr = str; *srcPtr; ++srcPtr) { + for (const char *srcPtr = str; *srcPtr && *srcPtr != ' '; ++srcPtr) { if (*srcPtr == ' ' && flag) break; diff --git a/engines/titanic/support/font.h b/engines/titanic/support/font.h index e1c63e6544..4bb1b2e6d6 100644 --- a/engines/titanic/support/font.h +++ b/engines/titanic/support/font.h @@ -82,6 +82,11 @@ public: */ int stringWidth(const CString &text) const; + /** + * Write a string to the specified surface + */ + int writeString(CVideoSurface *surface, const Point &pt, const CString &str); + /** * Get the text area a string will fit into * @param str String diff --git a/engines/titanic/support/screen_manager.cpp b/engines/titanic/support/screen_manager.cpp index f772bc6f7e..b467c8593d 100644 --- a/engines/titanic/support/screen_manager.cpp +++ b/engines/titanic/support/screen_manager.cpp @@ -68,6 +68,12 @@ void CScreenManager::setSurfaceBounds(SurfaceNum surfaceNum, const Rect &r) { _backSurfaces[surfaceNum]._bounds = r; } +int CScreenManager::setFontNumber(int fontNumber) { + int oldFontNumber = _fontNumber; + _fontNumber = fontNumber; + return oldFontNumber; +} + /*------------------------------------------------------------------------*/ OSScreenManager::OSScreenManager(TitanicEngine *vm): CScreenManager(vm), @@ -197,7 +203,10 @@ void OSScreenManager::blitFrom(SurfaceNum surfaceNum, CVideoSurface *src, void OSScreenManager::proc12() {} void OSScreenManager::proc13() {} void OSScreenManager::proc14() {} -void OSScreenManager::proc15() {} + +void OSScreenManager::setFontColor(byte r, byte g, byte b) { + _fonts[_fontNumber].setColor(r, g, b); +} int OSScreenManager::getTextBounds(const CString &str, int maxWidth, Point *sizeOut) const { return _fonts[_fontNumber].getTextBounds(str, maxWidth, sizeOut); diff --git a/engines/titanic/support/screen_manager.h b/engines/titanic/support/screen_manager.h index baba662564..b1e949ad58 100644 --- a/engines/titanic/support/screen_manager.h +++ b/engines/titanic/support/screen_manager.h @@ -108,7 +108,11 @@ public: virtual void proc12() = 0; virtual void proc13() = 0; virtual void proc14() = 0; - virtual void proc15() = 0; + + /** + * Set the font color + */ + virtual void setFontColor(byte r, byte g, byte b) = 0; /** * Get the text area a string will fit into @@ -164,7 +168,7 @@ public: /** * Set the current font number */ - void setFontNumber(int fontNumber) { _fontNumber = fontNumber; } + int setFontNumber(int fontNumber); }; class OSScreenManager: CScreenManager { @@ -224,7 +228,11 @@ public: virtual void proc12(); virtual void proc13(); virtual void proc14(); - virtual void proc15(); + + /** + * Set the font color + */ + virtual void setFontColor(byte r, byte g, byte b); /** * Get the text area a string will fit into -- cgit v1.2.3