aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2007-04-15 12:12:21 +0000
committerPaul Gilbert2007-04-15 12:12:21 +0000
commit258ab37a9a0b2ca426d2908408dfe09e451eea02 (patch)
treeaab3ab59f4ef9277be1b05414e6f99a10be6d537
parent48c21a1e314c9c3b605e498a1de612d515975b96 (diff)
downloadscummvm-rg350-258ab37a9a0b2ca426d2908408dfe09e451eea02.tar.gz
scummvm-rg350-258ab37a9a0b2ca426d2908408dfe09e451eea02.tar.bz2
scummvm-rg350-258ab37a9a0b2ca426d2908408dfe09e451eea02.zip
Altered message display to correctly handle optional display of hotspot/character article prefixes
svn-id: r26491
-rw-r--r--engines/lure/strings.cpp25
-rw-r--r--engines/lure/strings.h6
-rw-r--r--engines/lure/surface.cpp12
3 files changed, 21 insertions, 22 deletions
diff --git a/engines/lure/strings.cpp b/engines/lure/strings.cpp
index 39f1377206..77f1471379 100644
--- a/engines/lure/strings.cpp
+++ b/engines/lure/strings.cpp
@@ -180,7 +180,7 @@ byte StringData::readBit() {
return result;
}
-void StringData::initPosition(uint16 stringId) {
+bool StringData::initPosition(uint16 stringId) {
uint16 roomNumber = Room::getReference().roomNumber();
byte *stringTable;
@@ -234,7 +234,7 @@ void StringData::initPosition(uint16 stringId) {
if (readBit() == 0) break;
_srcPos += 2;
}
- readBit();
+ return readBit() != 0;
}
// readCharatcer
@@ -262,14 +262,15 @@ char StringData::readCharacter() {
}
void StringData::getString(uint16 stringId, char *dest, const char *hotspotName,
- const char *characterName) {
+ const char *characterName, int hotspotArticle, int characterArticle) {
+ const char *articles[4] = {"the ", "a ", "an ", ""};
char ch;
strcpy(dest, "");
char *destPos = dest;
stringId &= 0x1fff; // Strip off any article identifier
if (stringId == 0) return;
- initPosition(stringId);
+ bool includeArticles = initPosition(stringId);
ch = readCharacter();
while (ch != '\0') {
@@ -277,9 +278,12 @@ void StringData::getString(uint16 stringId, char *dest, const char *hotspotName,
// Copy over hotspot or action
ch = readCharacter();
const char *p = (ch == '1') ? hotspotName : characterName;
+ int article = !includeArticles ? 3 : ((ch == 1) ? hotspotArticle : characterArticle);
+
if (p != NULL) {
- strcpy(destPos, p);
- destPos += strlen(p);
+ strcpy(destPos, articles[article]);
+ strcat(destPos, p);
+ destPos += strlen(destPos);
}
} else if ((uint8) ch >= 0xa0) {
const char *p = getName((uint8) ch - 0xa0);
@@ -307,13 +311,4 @@ char *StringData::getName(uint8 nameIndex) {
return (char *) (_names->data() + nameStart);
}
-// getStringWithArticle
-// Fills a buffer with the string specified by a given string Id with a definite article prefix
-
-void StringData::getStringWithArticle(uint16 stringId, char *dest) {
- const char *articles[4] = {"the ", "a ", "an ", ""};
- strcpy(dest, articles[stringId >> 14]);
- getString(stringId, dest + strlen(dest));
-}
-
} // namespace Lure
diff --git a/engines/lure/strings.h b/engines/lure/strings.h
index 8c89ae5419..a2d6b187c0 100644
--- a/engines/lure/strings.h
+++ b/engines/lure/strings.h
@@ -50,7 +50,7 @@ private:
byte _bitMask;
void add(const char *sequence, char ascii);
- void initPosition(uint16 stringId);
+ bool initPosition(uint16 stringId);
char readCharacter();
byte readBit();
public:
@@ -58,11 +58,11 @@ public:
~StringData();
static StringData &getReference();
- void getString(uint16 stringId, char *dest, const char *hotspotName, const char *characterName);
+ void getString(uint16 stringId, char *dest, const char *hotspotName, const char *characterName,
+ int hotspotArticle = 3, int characterArticle = 3);
void getString(uint16 stringId, char *dest) {
getString(stringId, dest, NULL, NULL);
}
- void getStringWithArticle(uint16 stringId, char *dest);
char *getName(uint8 nameIndex);
};
diff --git a/engines/lure/surface.cpp b/engines/lure/surface.cpp
index ef38854bee..fdb0e97128 100644
--- a/engines/lure/surface.cpp
+++ b/engines/lure/surface.cpp
@@ -504,6 +504,7 @@ TalkDialog::TalkDialog(uint16 characterId, uint16 destCharacterId, uint16 active
char srcCharName[MAX_DESC_SIZE];
char destCharName[MAX_DESC_SIZE];
char itemName[MAX_DESC_SIZE];
+ int characterArticle, hotspotArticle = 3;
HotspotData *talkingChar = res.getHotspot(characterId);
HotspotData *destCharacter = (destCharacterId == 0) ? NULL :
@@ -512,16 +513,19 @@ TalkDialog::TalkDialog(uint16 characterId, uint16 destCharacterId, uint16 active
res.getHotspot(activeItemId);
assert(talkingChar);
- strings.getString(talkingChar->nameId, srcCharName);
+ strings.getString(talkingChar->nameId & 0x1fff, srcCharName);
+ characterArticle = talkingChar->nameId >> 14;
strcpy(destCharName, "");
if (destCharacter != NULL)
strings.getString(destCharacter->nameId, destCharName);
strcpy(itemName, "");
- if (itemHotspot != NULL)
- strings.getStringWithArticle(itemHotspot->nameId, itemName);
+ if (itemHotspot != NULL) {
+ strings.getString(itemHotspot->nameId & 0x1fff, itemName);
+ hotspotArticle = itemHotspot->nameId >> 14;
+ }
- strings.getString(descId, _desc, itemName, destCharName);
+ strings.getString(descId, _desc, itemName, destCharName, hotspotArticle, characterArticle);
// Apply word wrapping to figure out the needed size of the dialog
Surface::wordWrap(_desc, TALK_DIALOG_WIDTH - (TALK_DIALOG_EDGE_SIZE + 3) * 2,