diff options
author | Torbjörn Andersson | 2005-09-28 06:33:13 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2005-09-28 06:33:13 +0000 |
commit | 1a48b01fefa916888c3139dfcc834463493a5308 (patch) | |
tree | d2559364bef67a3dd58b200767fe0f23fbc83067 /saga | |
parent | 2854ddbc809c01306761294be7851342808f6995 (diff) | |
download | scummvm-rg350-1a48b01fefa916888c3139dfcc834463493a5308.tar.gz scummvm-rg350-1a48b01fefa916888c3139dfcc834463493a5308.tar.bz2 scummvm-rg350-1a48b01fefa916888c3139dfcc834463493a5308.zip |
Some more IHNM-related stuff:
* Use the script-specified text area for subtitles, if there is one.
* Fixed a word-wrapping bug that would happen if a new line began with a
space. I don't know about ITE, but IHNM puts two spaces after periods. Of
course, the case where I saw this happen will probably go away once we
start using the right font, but it could still happen elsewhere.
svn-id: r18890
Diffstat (limited to 'saga')
-rw-r--r-- | saga/actor.cpp | 47 | ||||
-rw-r--r-- | saga/animation.cpp | 2 | ||||
-rw-r--r-- | saga/font.cpp | 27 | ||||
-rw-r--r-- | saga/font.h | 4 | ||||
-rw-r--r-- | saga/sfuncs.cpp | 2 |
5 files changed, 51 insertions, 31 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp index 73bc427f21..4b0fbf4189 100644 --- a/saga/actor.cpp +++ b/saga/actor.cpp @@ -1017,34 +1017,41 @@ void Actor::handleSpeech(int msec) { } if (_activeSpeech.actorsCount == 1) { - width = _activeSpeech.speechBox.width(); - height = _vm->_font->getHeight(kMediumFont, _activeSpeech.strings[0], width - 2, _activeSpeech.getFontFlags(0)) + 1; - - if (height > 40 && width < _vm->getDisplayWidth() - 100) { - width = _vm->getDisplayWidth() - 100; + if (_speechBoxScript.width() > 0) { + _activeSpeech.drawRect.left = _speechBoxScript.left; + _activeSpeech.drawRect.right = _speechBoxScript.right; + _activeSpeech.drawRect.top = _speechBoxScript.top; + _activeSpeech.drawRect.bottom = _speechBoxScript.bottom; + } else { + width = _activeSpeech.speechBox.width(); height = _vm->_font->getHeight(kMediumFont, _activeSpeech.strings[0], width - 2, _activeSpeech.getFontFlags(0)) + 1; - } - _activeSpeech.speechBox.setWidth(width); + if (height > 40 && width < _vm->getDisplayWidth() - 100) { + width = _vm->getDisplayWidth() - 100; + height = _vm->_font->getHeight(kMediumFont, _activeSpeech.strings[0], width - 2, _activeSpeech.getFontFlags(0)) + 1; + } + + _activeSpeech.speechBox.setWidth(width); + + if (_activeSpeech.actorIds[0] != 0) { + actor = getActor(_activeSpeech.actorIds[0]); + _activeSpeech.speechBox.setHeight(height); - if (_activeSpeech.actorIds[0] != 0) { - actor = getActor(_activeSpeech.actorIds[0]); - _activeSpeech.speechBox.setHeight(height); + if (_activeSpeech.speechBox.right > _vm->getDisplayWidth() - 10) { + _activeSpeech.drawRect.left = _vm->getDisplayWidth() - 10 - width; + } else { + _activeSpeech.drawRect.left = _activeSpeech.speechBox.left; + } - if (_activeSpeech.speechBox.right > _vm->getDisplayWidth() - 10) { - _activeSpeech.drawRect.left = _vm->getDisplayWidth() - 10 - width; + height2 = actor->_screenPosition.y - 50; + _activeSpeech.speechBox.top = _activeSpeech.drawRect.top = MAX(10, (height2 - height) / 2); } else { _activeSpeech.drawRect.left = _activeSpeech.speechBox.left; + _activeSpeech.drawRect.top = _activeSpeech.speechBox.top + (_activeSpeech.speechBox.height() - height) / 2; } - - height2 = actor->_screenPosition.y - 50; - _activeSpeech.speechBox.top = _activeSpeech.drawRect.top = MAX(10, (height2 - height) / 2); - } else { - _activeSpeech.drawRect.left = _activeSpeech.speechBox.left; - _activeSpeech.drawRect.top = _activeSpeech.speechBox.top + (_activeSpeech.speechBox.height() - height) / 2; + _activeSpeech.drawRect.setWidth(width); + _activeSpeech.drawRect.setHeight(height); } - _activeSpeech.drawRect.setWidth(width); - _activeSpeech.drawRect.setHeight(height); } _activeSpeech.playing = true; diff --git a/saga/animation.cpp b/saga/animation.cpp index a5f6e9bd68..04f383aac7 100644 --- a/saga/animation.cpp +++ b/saga/animation.cpp @@ -119,6 +119,8 @@ void Anim::playCutaway(int cut, bool fade) { free(buf); free(resourceData); + // Play the animation + int cutawaySlot = -1; for (int i = 0; i < ARRAYSIZE(_cutawayAnimations); i++) { diff --git a/saga/font.cpp b/saga/font.cpp index 649feb6e00..bcd9b785a8 100644 --- a/saga/font.cpp +++ b/saga/font.cpp @@ -62,6 +62,10 @@ Font::~Font(void) { } } +FontData *Font::getFont(FontId fontId) { + return _fonts[fontId]; +} + void Font::loadFont(uint32 fontResourceId) { FontData *font; byte *fontResourcePointer; @@ -70,7 +74,6 @@ void Font::loadFont(uint32 fontResourceId) { int c; ResourceContext *fontContext; - debug(1, "Font::loadFont(): Reading fontResourceId %d...", fontResourceId); fontContext = _vm->_resource->getContext(GAME_RESOURCEFILE); @@ -134,7 +137,6 @@ void Font::loadFont(uint32 fontResourceId) { _fonts[_loadedFonts++] = font; } - void Font::createOutline(FontData *font) { int i; int row; @@ -249,7 +251,7 @@ int Font::getStringWidth(FontId fontId, const char *text, size_t count, FontEffe validate(fontId); - font = _fonts[fontId]; + font = getFont(fontId); txt = (const byte *) text; @@ -273,7 +275,7 @@ int Font::getHeight(FontId fontId) { validate(fontId); - font = _fonts[fontId]; + font = getFont(fontId); return font->normal.header.charHeight; } @@ -285,7 +287,7 @@ void Font::draw(FontId fontId, Surface *ds, const char *text, size_t count, cons validate(fontId); - font = _fonts[fontId]; + font = getFont(fontId); if (flags & kFontOutline) { offsetPoint.x--; @@ -554,7 +556,7 @@ void Font::textDrawRect(FontId fontId, Surface *ds, const char *text, const Comm textPoint.y = rect.top; if (fitWidth >= textWidth) { - // Entire string fits, draw it + // Entire string fits, draw it textPoint.x -= (textWidth / 2); draw(fontId, ds, text, textLength, textPoint, color, effectColor, flags); return; @@ -604,6 +606,19 @@ void Font::textDrawRect(FontId fontId, Surface *ds, const char *text, const Comm searchPointer = measurePointer + 1; } wc = 0; + + // Advance the search pointer to the next non-space. + // Otherwise, the first "word" to be measured will be + // an empty string. Measuring or drawing a string of + // length 0 is interpreted as measure/draw the entire + // buffer, which certainly is not what we want here. + // + // This happes because a string may contain several + // spaces in a row, e.g. after a period. + + while (*searchPointer == ' ') + searchPointer++; + measurePointer = searchPointer; startPointer = searchPointer; } else { diff --git a/saga/font.h b/saga/font.h index 9ef83bb50f..46d6d229a3 100644 --- a/saga/font.h +++ b/saga/font.h @@ -76,7 +76,6 @@ public: } }; - struct FontHeader { int charHeight; int charWidth; @@ -106,6 +105,7 @@ class Font { public: Font(SagaEngine *vm); ~Font(void); + FontData *getFont(FontId fontId); int getStringWidth(FontId fontId, const char *text, size_t count, FontEffectFlags flags); int getHeight(FontId fontId); int getHeight(FontId fontId, const char *text, int width, FontEffectFlags flags); @@ -124,7 +124,6 @@ class Font { } private: - void loadFont(uint32 fontResourceId); void createOutline(FontData *font); void draw(FontId fontId, Surface *ds, const char *text, size_t count, const Common::Point &point, int color, int effectColor, FontEffectFlags flags); @@ -139,7 +138,6 @@ class Font { return byteLength; } - static const int _charMap[256]; SagaEngine *_vm; diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp index b64be9bdc6..d5b2f1caa3 100644 --- a/saga/sfuncs.cpp +++ b/saga/sfuncs.cpp @@ -1970,8 +1970,6 @@ void Script::sfSetSpeechBox(SCRIPTFUNC_PARAMS) { _vm->_actor->_speechBoxScript.top = param2; _vm->_actor->_speechBoxScript.setWidth(param3); _vm->_actor->_speechBoxScript.setHeight(param4); - - debug(0, "STUB: sfSetSpeechBox(%d, %d, %d, %d)", param1, param2, param3, param4); } void Script::sfDebugShowData(SCRIPTFUNC_PARAMS) { |