diff options
author | David Eriksson | 2003-11-15 21:16:01 +0000 |
---|---|---|
committer | David Eriksson | 2003-11-15 21:16:01 +0000 |
commit | b938b63ddf4bd09db1bd1d36408a217d6d13b3f8 (patch) | |
tree | 6166440414df0ea37696bad3eca63455f2ac6249 | |
parent | 4f97603c9c75e6796479b85d1198da844dc0ce05 (diff) | |
download | scummvm-rg350-b938b63ddf4bd09db1bd1d36408a217d6d13b3f8.tar.gz scummvm-rg350-b938b63ddf4bd09db1bd1d36408a217d6d13b3f8.tar.bz2 scummvm-rg350-b938b63ddf4bd09db1bd1d36408a217d6d13b3f8.zip |
- Talk clean-up
- Make it possible to quit a dialogue
svn-id: r11302
-rw-r--r-- | queen/input.cpp | 4 | ||||
-rw-r--r-- | queen/input.h | 5 | ||||
-rw-r--r-- | queen/logic.cpp | 3 | ||||
-rw-r--r-- | queen/structs.h | 6 | ||||
-rw-r--r-- | queen/talk.cpp | 30 | ||||
-rw-r--r-- | queen/talk.h | 16 |
6 files changed, 45 insertions, 19 deletions
diff --git a/queen/input.cpp b/queen/input.cpp index f0ecf3ae30..a394fed6a7 100644 --- a/queen/input.cpp +++ b/queen/input.cpp @@ -168,8 +168,8 @@ int Input::checkKeys() { _cutawayQuit = true; } - // XXX if (_joeWalk == 3) // Dialogue - // XXX _talkQuit = true; + if (_dialogueRunning) + _talkQuit = true; } break; diff --git a/queen/input.h b/queen/input.h index ff93b94a50..f4157eb860 100644 --- a/queen/input.h +++ b/queen/input.h @@ -69,6 +69,8 @@ class Input { bool cutawayQuit() const { return _cutawayQuit; } void cutawayQuitReset() { _cutawayQuit = false; } + void dialogueRunning(bool running) { _dialogueRunning = running; } + bool talkQuit() const { return _talkQuit; } void talkQuitReset() { _talkQuit = false; } @@ -135,6 +137,9 @@ class Input { //! moved Cutaway::_quit here bool _cutawayQuit; // cutawayQuit + //! set if a dialogue is running + bool _dialogueRunning; + //! moved Talk::_quit here bool _talkQuit; // TALKQUIT diff --git a/queen/logic.cpp b/queen/logic.cpp index 8977eae350..a64a2db2da 100644 --- a/queen/logic.cpp +++ b/queen/logic.cpp @@ -665,6 +665,9 @@ void Logic::joeY(uint16 y) { void Logic::joeWalk(JoeWalkMode walking) { _joe.walk = walking; + + // Do this so that Input doesn't need to know the walk value + _input->dialogueRunning(JWM_SPEAK == walking); } void Logic::joeScale(uint16 scale) { diff --git a/queen/structs.h b/queen/structs.h index 10377e53cb..8dec0982bb 100644 --- a/queen/structs.h +++ b/queen/structs.h @@ -550,18 +550,18 @@ struct Person { struct TalkSelected { - int16 hasTalkedTo; + bool hasTalkedTo; int16 values[4]; void readFrom(byte *&ptr) { - hasTalkedTo = (int16)READ_BE_UINT16(ptr); ptr += 2; + hasTalkedTo = (bool)READ_BE_UINT16(ptr); ptr += 2; for (int i = 0; i < 4; i++) { values[i] = (int16)READ_BE_UINT16(ptr); ptr += 2; } } void writeTo(byte *&ptr) { - WRITE_BE_UINT16(ptr, hasTalkedTo); ptr += 2; + WRITE_BE_UINT16(ptr, (uint16)hasTalkedTo); ptr += 2; for (int i = 0; i < 4; i++) { WRITE_BE_UINT16(ptr, values[i]); ptr += 2; } diff --git a/queen/talk.cpp b/queen/talk.cpp index effb706a8f..9a0499adcb 100644 --- a/queen/talk.cpp +++ b/queen/talk.cpp @@ -132,11 +132,11 @@ void Talk::talk(const char *filename, int personInRoom, char *cutawayFilename) { // Lines 828-846 in talk.c for (i = 1; i <= 4; i++) { - if (talkSelected()->values[i-1] > 0) { + if (selectedValue(i) > 0) { // This option has been redefined so display new dialogue option - _dialogueTree[1][i].head = talkSelected()->values[i-1]; + _dialogueTree[1][i].head = selectedValue(i); } - else if (talkSelected()->values[i-1] == -1) { + else if (selectedValue(i) == -1) { // Already selected so don't redisplay if (_dialogueTree[1][i].gameStateIndex >= 0) { @@ -164,12 +164,12 @@ void Talk::talk(const char *filename, int personInRoom, char *cutawayFilename) { _talkString[0][0] = '\0'; - if(talkSelected()->hasTalkedTo == 1 && head == 1) + if (hasTalkedTo() && head == 1) strcpy(_talkString[0], _person2String); else findDialogueString(_person1Ptr, head, _talkString[0]); - if(talkSelected()->hasTalkedTo == 1 && head == 1) + if (hasTalkedTo() && head == 1) sprintf(otherVoiceFilePrefix, "%2dXXXXP", _talkKey); else sprintf(otherVoiceFilePrefix, "%2d%4xP", _talkKey, head); @@ -261,8 +261,8 @@ void Talk::talk(const char *filename, int personInRoom, char *cutawayFilename) { if (_dialogueTree[level][0].dialogueNodeValue1 > 0) { if (1 == oldLevel) { _oldSelectedSentenceIndex = selectedSentence; - _oldSelectedSentenceValue = talkSelected()->values[selectedSentence-1]; - talkSelected()->values[selectedSentence-1] = _dialogueTree[level][0].dialogueNodeValue1; + _oldSelectedSentenceValue = selectedValue(selectedSentence); + selectedValue(selectedSentence, _dialogueTree[level][0].dialogueNodeValue1); } _dialogueTree[oldLevel][selectedSentence].head = _dialogueTree[level][0].dialogueNodeValue1; @@ -333,16 +333,18 @@ void Talk::talk(const char *filename, int personInRoom, char *cutawayFilename) { } if (_input->talkQuit()) { - // TODO: missing some code here! + if (_oldSelectedSentenceIndex > 0) + selectedValue(_oldSelectedSentenceIndex, _oldSelectedSentenceValue); + _input->talkQuitReset(); + _graphics->textClear(0, 198); + speak(_talkString[15], NULL, "JOE0015"); } else { - talkSelected()->hasTalkedTo = 1; + setHasTalkedTo(); } _logic->joeFace(); - // TODO: missing some code here! - if (cutawayFilename[0] == '\0') { BobSlot *pbs = _graphics->bob(person.actor->bobNum); @@ -365,8 +367,8 @@ void Talk::disableSentence(int oldLevel, int selectedSentence) { if (_dialogueTree[oldLevel][selectedSentence].dialogueNodeValue1 != -1) { // Make sure choice is not exit option _oldSelectedSentenceIndex = selectedSentence; - _oldSelectedSentenceValue = talkSelected()->values[selectedSentence-1]; - talkSelected()->values[selectedSentence-1] = -1; + _oldSelectedSentenceValue = selectedValue(selectedSentence); + selectedValue(selectedSentence, -1); } } @@ -486,7 +488,7 @@ void Talk::initialTalk() { ptr = getString(ptr, joe2String, MAX_STRING_LENGTH); //debug(0, "joe2String = '%s'", joe2String); - if (talkSelected()->hasTalkedTo == 0) { + if (!hasTalkedTo()) { // Not yet talked to this person diff --git a/queen/talk.h b/queen/talk.h index b70446df5d..31e8d80ead 100644 --- a/queen/talk.h +++ b/queen/talk.h @@ -180,6 +180,22 @@ private: //! Get TalkSelected struct for this talk TalkSelected *talkSelected(); + //! Interface to the TalkSelected struct + bool hasTalkedTo() { return talkSelected()->hasTalkedTo; } + + //! Interface to the TalkSelected struct + void setHasTalkedTo() { talkSelected()->hasTalkedTo = true; } + + //! Get a selected value + int16 selectedValue(int index) { + return talkSelected()->values[index-1]; + } + + //! Set a selected value + void selectedValue(int index, int16 value) { + talkSelected()->values[index-1] = value; + } + //! The sentence will not be displayed again void disableSentence(int oldLevel, int selectedSentence); |