Handle cutaway text.

svn-id: r10892
This commit is contained in:
David Eriksson
2003-10-18 12:48:05 +00:00
parent 935a476a29
commit d2e65e35e9
4 changed files with 96 additions and 2 deletions
+80 -1
View File
@@ -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
+9
View File
@@ -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);
+5
View File
@@ -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
+2 -1
View File
@@ -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