diff options
author | David Eriksson | 2003-10-18 12:48:05 +0000 |
---|---|---|
committer | David Eriksson | 2003-10-18 12:48:05 +0000 |
commit | d2e65e35e91fc3bd3074e8d44887be90079ffbf3 (patch) | |
tree | 29a504592f8e09a5e5ebdb739eb53ea603bc190d /queen | |
parent | 935a476a29a8f045e54e1556e1c25ff76d9b942b (diff) | |
download | scummvm-rg350-d2e65e35e91fc3bd3074e8d44887be90079ffbf3.tar.gz scummvm-rg350-d2e65e35e91fc3bd3074e8d44887be90079ffbf3.tar.bz2 scummvm-rg350-d2e65e35e91fc3bd3074e8d44887be90079ffbf3.zip |
Handle cutaway text.
svn-id: r10892
Diffstat (limited to 'queen')
-rw-r--r-- | queen/cutaway.cpp | 81 | ||||
-rw-r--r-- | queen/cutaway.h | 9 | ||||
-rw-r--r-- | queen/graphics.cpp | 5 | ||||
-rw-r--r-- | queen/graphics.h | 3 |
4 files changed, 96 insertions, 2 deletions
diff --git a/queen/cutaway.cpp b/queen/cutaway.cpp index 3929c6ab5b..19b4d52cd0 100644 --- a/queen/cutaway.cpp +++ b/queen/cutaway.cpp @@ -632,6 +632,8 @@ byte *Cutaway::handleAnimation(byte *ptr, CutawayObject &object) { if (object.animType == 1) { // lines 1615-1636 in cutaway.c + + debug(0, "----- Not normal cutaway animation (animType = %i) -----", object.animType); if (/*(P_BNUM==1) &&*/ (_logic->currentRoom() == 47 || _logic->currentRoom() == 63)) { // The oracle @@ -678,6 +680,9 @@ byte *Cutaway::handleAnimation(byte *ptr, CutawayObject &object) { if (object.animType != 1) { // lines 1657-1761 in cutaway.c + + debug(0, "----- Normal cutaway animation (animType = %i) -----", object.animType); + for (i = 0; i < frameCount; i++) { BobSlot *bob = _graphics->bob(objAnim[i].object); bob->active = true; @@ -911,6 +916,12 @@ void Cutaway::run(char *nextFilename) { // Do nothing? break; + case OBJECT_TYPE_TEXT_SPEAK: + case OBJECT_TYPE_TEXT_DISPLAY_AND_SPEAK: + case OBJECT_TYPE_TEXT_DISPLAY: + handleText(objectType, object, sentence); + break; + default: warning("Unhandled object type: %i", objectType); break; @@ -1182,7 +1193,6 @@ void Cutaway::talk(char *nextFilename) { // Lines 2119-2131 in cutaway.c if (0 == scumm_stricmp(right(_talkFile, 4), ".dog")) { - warning("Cutaway::talk() used but not fully implemented"); nextFilename[0] = '\0'; Talk::talk(_talkFile, 0 /* XXX */, nextFilename, _graphics, _logic, _resource); @@ -1228,4 +1238,73 @@ int Cutaway::makeComplexAnimation(int16 currentImage, Cutaway::CutawayAnim *objA return currentImage + 1; } +void Cutaway::handleText( + ObjectType type, + CutawayObject &object, + const char *sentence) { + // lines 1776-1863 in cutaway.c + + debug(0, "----- Write '%s' ----", sentence); + + int spaces = countSpaces(type, sentence); + + int x; + int flags; + + if (OBJECT_TYPE_TEXT_DISPLAY == type) { + x = _graphics->textCenterX(sentence); + flags = 2; + } + else { + x = object.moveToX; + flags = 1; + } + + BobSlot *bob = + _graphics->bob( _logic->findBob(abs(object.objectNumber)) ); + + _graphics->bobSetText(bob, sentence, x, object.moveToY, object.specialMove, flags); + + if (OBJECT_TYPE_TEXT_SPEAK == type || OBJECT_TYPE_TEXT_DISPLAY_AND_SPEAK == type) { + // XXX: speak + } + + int i; + for (i = 0; i < spaces; i++) { + _graphics->update(); + + if (OBJECT_TYPE_TEXT_SPEAK == type || OBJECT_TYPE_TEXT_DISPLAY_AND_SPEAK == type) { + // XXX: see if speaking is finished + } + + if (_quit) + break; + +// XXX if(KEYVERB==101) { +// XXX KEYVERB=0; +// XXX break; +// XXX } + + } + + _graphics->textClear(0,198); + _graphics->update(); +} + +int Cutaway::countSpaces(ObjectType type, const char *segment) { + int tmp = 0; + + while (*segment++) + tmp++; + + if (tmp < 10) + tmp = 10; + + if (OBJECT_TYPE_TEXT_DISPLAY == type) + tmp *= 3; + + return (tmp * 2) / _logic->talkSpeed(); + +} + } // End of namespace Queen diff --git a/queen/cutaway.h b/queen/cutaway.h index 3782736be4..1155b6cde4 100644 --- a/queen/cutaway.h +++ b/queen/cutaway.h @@ -242,6 +242,12 @@ class Cutaway { int index, CutawayObject &object, const char *sentence); + + //! Perform text actions + void handleText( + ObjectType type, + CutawayObject &object, + const char *sentence); //! Restore QueenLogic::_objectData from _personData void restorePersonData(); @@ -270,6 +276,9 @@ class Cutaway { //! Dump a CutawayObject with debug() void dumpCutawayObject(int index, CutawayObject &object); + //! Used by handleText() + int countSpaces(ObjectType type, const char *segment); + //! Dump CutawayAnum data with debug() static void dumpCutawayAnim(CutawayAnim &anim); diff --git a/queen/graphics.cpp b/queen/graphics.cpp index fb9d8d0288..2d433d3480 100644 --- a/queen/graphics.cpp +++ b/queen/graphics.cpp @@ -909,5 +909,10 @@ void Graphics::bobSetText( textSet(lineX, y + 9 * i, lines[i]); } } + +int Graphics::textCenterX(const char *text) const { + return 160 - textWidth(text) / 2; +} + } // End of namespace Queen diff --git a/queen/graphics.h b/queen/graphics.h index 6fe656e3cc..b92685485d 100644 --- a/queen/graphics.h +++ b/queen/graphics.h @@ -148,7 +148,8 @@ public: void textSetCentered(uint16 y, const char *text, bool outlined = true); void textDrawAll(); // drawtext() void textClear(uint16 y1, uint16 y2); // blanktexts() - uint16 textWidth(const char* text) const; // textlen() + uint16 textWidth(const char *text) const; // textlen() + int textCenterX(const char *text) const; // MIDDLE() void frameErase(uint32 fslot); void frameEraseAll(bool joe); // freeframes, freeallframes |