aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2006-08-07 13:16:07 +0000
committerPaul Gilbert2006-08-07 13:16:07 +0000
commite911afb525e22f0b9bf485f0404a7239e2d9d905 (patch)
tree8673f6683934cf5d193562d497cdb1916082c284
parentba32b916889f59045d796eec962081acc3f03250 (diff)
downloadscummvm-rg350-e911afb525e22f0b9bf485f0404a7239e2d9d905.tar.gz
scummvm-rg350-e911afb525e22f0b9bf485f0404a7239e2d9d905.tar.bz2
scummvm-rg350-e911afb525e22f0b9bf485f0404a7239e2d9d905.zip
Dialog::showMessage transferred over to the Hotspot class. Also enhanced TalkDialog to handle being passed a destination character and active item
svn-id: r23690
-rw-r--r--engines/lure/surface.cpp94
-rw-r--r--engines/lure/surface.h3
2 files changed, 28 insertions, 69 deletions
diff --git a/engines/lure/surface.cpp b/engines/lure/surface.cpp
index 5866857f93..6e1890543e 100644
--- a/engines/lure/surface.cpp
+++ b/engines/lure/surface.cpp
@@ -409,80 +409,40 @@ void Dialog::show(const char *text) {
void Dialog::show(uint16 stringId) {
char buffer[MAX_DESC_SIZE];
- Resources &res = Resources::getReference();
- Room &r = Room::getReference();
StringData &sl = StringData::getReference();
- const char *actionName = res.getCurrentActionStr();
- char hotspotName[MAX_HOTSPOT_NAME_SIZE];
- if (r.hotspotId() == 0)
- strcpy(hotspotName, "");
- else
- sl.getString(r.hotspot().nameId, hotspotName, NULL, NULL);
-
- sl.getString(stringId, buffer, hotspotName, actionName);
+ sl.getString(stringId, buffer);
show(buffer);
}
-void Dialog::showMessage(uint16 messageId, uint16 characterId) {
- Resources &res = Resources::getReference();
- MemoryBlock *data = res.messagesData();
- Hotspot *charHotspot = res.getActiveHotspot(characterId);
- Hotspot *hotspot;
- uint16 *v = (uint16 *) data->data();
- uint16 v2, idVal;
- messageId &= 0x7fff;
-
- // Skip through header to find table for given character
- while (READ_LE_UINT16(v) != characterId) v += 2;
-
- // Scan through secondary list
- ++v;
- v = (uint16 *) (data->data() + READ_LE_UINT16(v));
- v2 = 0;
- while ((idVal = READ_LE_UINT16(v)) != 0xffff) {
- ++v;
- if (READ_LE_UINT16(v) == messageId) break;
- ++v;
- }
-
- // default response if a specific response not found
- if (idVal == 0xffff) idVal = 0x8c4;
-
- if (idVal == 0x76) {
- // Special code id for showing the puzzled talk bubble
- if (!charHotspot) return;
- hotspot = new Hotspot(charHotspot, PUZZLED_ANIM_ID);
- res.addHotspot(hotspot);
-
- } else if (idVal == 0x120) {
- // Special code id for showing the exclamation talk bubble
- if (!charHotspot) return;
- hotspot = new Hotspot(charHotspot, EXCLAMATION_ANIM_ID);
- res.addHotspot(hotspot);
-
- } else if (idVal >= 0x8000) {
- // Handle string display
- idVal &= 0x7fff;
- Dialog::show(idVal);
-
- } else if (idVal != 0) {
- // Handle message as a talking dialog (the character talking to themselves)
-
- if (!charHotspot) return;
- charHotspot->converse(NOONE_ID, idVal, false);
- }
-}
-
/*--------------------------------------------------------------------------*/
-TalkDialog::TalkDialog(uint16 characterId, uint16 descId) {
+TalkDialog::TalkDialog(uint16 characterId, uint16 destCharacterId, uint16 activeItemId, uint16 descId) {
+ debugC(ERROR_DETAILED, kLureDebugAnimations, "TalkDialog(chars=%xh/%xh, item=%d, str=%d",
+ characterId, destCharacterId, activeItemId, descId);
StringData &strings = StringData::getReference();
Resources &res = Resources::getReference();
- HotspotData *character = res.getHotspot(characterId);
- char charName[MAX_DESC_SIZE];
- strings.getString(character->nameId, charName, NULL, NULL);
- strings.getString(descId, _desc, NULL, NULL);
+ char srcCharName[MAX_DESC_SIZE];
+ char destCharName[MAX_DESC_SIZE];
+ char itemName[MAX_DESC_SIZE];
+
+ HotspotData *talkingChar = res.getHotspot(characterId);
+ HotspotData *destCharacter = (destCharacterId == 0) ? NULL :
+ res.getHotspot(destCharacterId);
+ HotspotData *itemHotspot = (activeItemId == 0) ? NULL :
+ res.getHotspot(activeItemId);
+ assert(talkingChar);
+
+ strings.getString(talkingChar->nameId, srcCharName);
+
+ strcpy(destCharName, "");
+ if (destCharacter != NULL)
+ strings.getString(destCharacter->nameId, destCharName);
+ strcpy(itemName, "");
+ if (itemHotspot != NULL)
+ strings.getStringWithArticle(itemHotspot->nameId, itemName);
+
+ strings.getString(descId, _desc, itemName, destCharName);
// Apply word wrapping to figure out the needed size of the dialog
Surface::wordWrap(_desc, TALK_DIALOG_WIDTH - TALK_DIALOG_EDGE_SIZE * 2 - 2,
@@ -542,9 +502,9 @@ TalkDialog::TalkDialog(uint16 characterId, uint16 descId) {
}
// Write out the character name
- uint16 charWidth = Surface::textWidth(charName);
+ uint16 charWidth = Surface::textWidth(srcCharName);
_surface->writeString((TALK_DIALOG_WIDTH-charWidth)/2, TALK_DIALOG_EDGE_SIZE + 2,
- charName, true, DIALOG_WHITE_COLOUR);
+ srcCharName, true, DIALOG_WHITE_COLOUR);
// TEMPORARY CODE - write out description. More properly, the text is meant to
// be displayed slowly, word by word
diff --git a/engines/lure/surface.h b/engines/lure/surface.h
index 07b95e1183..9242bca03e 100644
--- a/engines/lure/surface.h
+++ b/engines/lure/surface.h
@@ -76,7 +76,6 @@ class Dialog {
public:
static void show(const char *text);
static void show(uint16 stringId);
- static void showMessage(uint16 messageId, uint16 characterId);
};
class TalkDialog {
@@ -86,7 +85,7 @@ private:
char **_lines;
uint8 _numLines;
public:
- TalkDialog(uint16 characterId, uint16 descId);
+ TalkDialog(uint16 characterId, uint16 destCharacterId, uint16 activeItemId, uint16 descId);
~TalkDialog();
char *desc() { return _desc; }