aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2007-10-24 10:03:11 +0000
committerPaul Gilbert2007-10-24 10:03:11 +0000
commit5635256f308c8687ceea0e8f6280e4e575c90fed (patch)
treede078fd7ce52bd2585224f23c04fbfa0647e06b3 /engines
parent6faff895c31ec9ac3b2878bd46a826b39fc20b52 (diff)
downloadscummvm-rg350-5635256f308c8687ceea0e8f6280e4e575c90fed.tar.gz
scummvm-rg350-5635256f308c8687ceea0e8f6280e4e575c90fed.tar.bz2
scummvm-rg350-5635256f308c8687ceea0e8f6280e4e575c90fed.zip
Implemented gradual display of text in talk dialogs
svn-id: r29251
Diffstat (limited to 'engines')
-rw-r--r--engines/lure/surface.cpp61
-rw-r--r--engines/lure/surface.h6
2 files changed, 55 insertions, 12 deletions
diff --git a/engines/lure/surface.cpp b/engines/lure/surface.cpp
index 1c69662b69..c175b3d687 100644
--- a/engines/lure/surface.cpp
+++ b/engines/lure/surface.cpp
@@ -23,14 +23,15 @@
*
*/
-#include "lure/surface.h"
#include "lure/decode.h"
#include "lure/events.h"
-#include "lure/screen.h"
+#include "lure/game.h"
#include "lure/lure.h"
#include "lure/room.h"
+#include "lure/screen.h"
#include "lure/sound.h"
#include "lure/strings.h"
+#include "lure/surface.h"
#include "common/endian.h"
namespace Lure {
@@ -133,16 +134,20 @@ int Surface::writeChar(uint16 x, uint16 y, uint8 ascii, bool transparent, uint8
void Surface::writeString(uint16 x, uint16 y, Common::String line, bool transparent,
uint8 colour, bool varLength) {
+ writeSubstring(x, y, line, line.size(), transparent, colour, varLength);
+}
+
+void Surface::writeSubstring(uint16 x, uint16 y, Common::String line, int len,
+ bool transparent, uint8 colour, bool varLength) {
+
const char *sPtr = line.c_str();
- while (*sPtr) {
+ for (int index = 0; (index < len) && (*sPtr != NULL); ++index, ++sPtr) {
writeChar(x, y, (uint8) *sPtr, transparent, colour);
// Move to after the character in preparation for the next character
if (!varLength) x += FONT_WIDTH;
else x += fontSize[(uint8)*sPtr - 32] + 2;
-
- ++sPtr; // Move to next character
}
}
@@ -538,6 +543,7 @@ TalkDialog::TalkDialog(uint16 characterId, uint16 destCharacterId, uint16 active
// Apply word wrapping to figure out the needed size of the dialog
Surface::wordWrap(_desc, TALK_DIALOG_WIDTH - (TALK_DIALOG_EDGE_SIZE + 3) * 2,
_lines, _numLines);
+ _endLine = 0; _endIndex = 0;
_surface = new Surface(TALK_DIALOG_WIDTH,
(_numLines + 1) * FONT_HEIGHT + TALK_DIALOG_EDGE_SIZE * 4);
@@ -592,17 +598,12 @@ TalkDialog::TalkDialog(uint16 characterId, uint16 destCharacterId, uint16 active
*pDest++ = *pSrc++;
}
+ _wordCountdown = 0;
+
// Write out the character name
uint16 charWidth = Surface::textWidth(srcCharName);
_surface->writeString((TALK_DIALOG_WIDTH-charWidth)/2, TALK_DIALOG_EDGE_SIZE + 2,
srcCharName, true, DIALOG_WHITE_COLOUR);
-
- // TEMPORARY CODE - write out description. More properly, the text is meant to
- // be displayed slowly, word by word
- for (int lineCtr = 0; lineCtr < _numLines; ++lineCtr)
- _surface->writeString(TALK_DIALOG_EDGE_SIZE + 2,
- TALK_DIALOG_EDGE_SIZE + 4 + (lineCtr + 1) * FONT_HEIGHT,
- _lines[lineCtr], true);
}
TalkDialog::~TalkDialog() {
@@ -610,6 +611,42 @@ TalkDialog::~TalkDialog() {
delete _surface;
}
+void TalkDialog::copyTo(Surface *dest, uint16 x, uint16 y) {
+ if (_endLine < _numLines) {
+ if (_wordCountdown > 0) {
+ // Handle delay between words
+ --_wordCountdown;
+
+ } else {
+ // Set a delay before the next word is displayed
+ Game &game = Game::getReference();
+ _wordCountdown = game.fastTextFlag() ? 0 : 1;
+
+ // Scan forward to find the next word break
+ char ch = '\0';
+ bool wordFlag = false;
+
+ while (!wordFlag) {
+ ch = _lines[_endLine][++_endIndex];
+ wordFlag = (ch == ' ') || (ch == '\0');
+ }
+
+ // Write out the completed portion of the current line
+ _surface->writeSubstring(TALK_DIALOG_EDGE_SIZE + 2,
+ TALK_DIALOG_EDGE_SIZE + 4 + (_endLine + 1) * FONT_HEIGHT,
+ _lines[_endLine], _endIndex, true);
+
+ // If at end of line, move to next line for next time
+ if (ch == '\0') {
+ ++_endLine;
+ _endIndex = -1;
+ }
+ }
+ }
+
+ _surface->copyTo(dest, x, y);
+}
+
/*--------------------------------------------------------------------------*/
#define SR_SEPARATOR_Y 21
diff --git a/engines/lure/surface.h b/engines/lure/surface.h
index e590ac9c60..07111a6625 100644
--- a/engines/lure/surface.h
+++ b/engines/lure/surface.h
@@ -55,6 +55,8 @@ public:
int writeChar(uint16 x, uint16 y, uint8 ascii, bool transparent, uint8 colour);
void writeString(uint16 x, uint16 y, Common::String line, bool transparent,
uint8 colour = DIALOG_TEXT_COLOUR, bool varLength = true);
+ void writeSubstring(uint16 x, uint16 y, Common::String line, int len,
+ bool transparent, uint8 colour = DIALOG_TEXT_COLOUR, bool varLength = true);
void transparentCopyTo(Surface *dest);
void copyTo(Surface *dest);
void copyTo(Surface *dest, uint16 x, uint16 y);
@@ -89,12 +91,16 @@ private:
char _desc[MAX_DESC_SIZE];
char **_lines;
uint8 _numLines;
+ int _endLine, _endIndex;
+ int _wordCountdown;
public:
TalkDialog(uint16 characterId, uint16 destCharacterId, uint16 activeItemId, uint16 descId);
~TalkDialog();
char *desc() { return _desc; }
Surface &surface() { return *_surface; }
+ void copyTo(Surface *dest, uint16 x, uint16 y);
+ bool isBuilding() { return _endLine < _numLines; }
};
class SaveRestoreDialog {