diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp index 322a7b9735c..934749e2c8c 100644 --- a/engines/asylum/resources/encounters.cpp +++ b/engines/asylum/resources/encounters.cpp @@ -58,7 +58,7 @@ Encounter::Encounter(AsylumEngine *engine) : _vm(engine), _value1 = 0; _tick = 0; _data_455B14 = 0; - _data_455B3C = false; + _data_455B3C = 0; _data_455B70 = 0; _data_455BCC = false; _data_455BD0 = false; @@ -328,7 +328,7 @@ bool Encounter::init() { _data_455BE0 = false; _data_455BE4 = false; _data_455BCC = false; - _data_455B3C = true; + _data_455B3C = 1; _rectIndex = -1; _value1 = 0; _data_455BF4 = 0; @@ -687,7 +687,7 @@ void Encounter::resetSpeech(uint32 keywordIndex, uint32 a2) { setupPortraits(); _data_455BCC = false; - _data_455B3C = false; + _data_455B3C = 1; if (keywordIndex) { getSpeech()->setTextResourceId(keywordIndex + a2); @@ -751,7 +751,7 @@ void Encounter::setupSpeechText() { } _data_455BCC = false; - _data_455B3C = true; + _data_455B3C = 1; } void Encounter::setupSpeech(ResourceId textResourceId, ResourceId fontResourceId) { @@ -793,7 +793,7 @@ bool Encounter::setupSpeech(ResourceId id) { getSpeech()->setTextDataPos(0); _data_455BCC = false; - _data_455B3C = true; + _data_455B3C = 1; setupPortraits(); @@ -1119,10 +1119,27 @@ void Encounter::drawText(char *text, ResourceId font, int32 y) { if (!text) return; - //int width = _background.rect.width() - _portrait1.rect.width() - _portrait2.rect.width() - 20; - //int x = _point.x + _portrait1.rect.width() + 10; + int width = _background.rect.width() - _portrait1.rect.width() - _portrait2.rect.width() - 20; + int x = _point.x + _portrait1.rect.width() + 10; - error("[Encounter::drawText] not implemented!"); + getText()->loadFont(font); + + if (_data_455BCC) { + if (_data_455B3C != 1 && _tick < _vm->getTick()) { + _tick = _vm->getTick() + 1000 * getResource()->get(getSpeech()->getSoundResourceId())->size / 11025 / _data_455B3C; + + if ((_data_455BF0 + 8) < _data_455B70) + _data_455BF0 += 8; + } + } else { + _data_455BCC = true; + _data_455B70 = getText()->draw(kTextCalculate, x, y, 16, width, text); + _data_455B3C = _data_455B70 / 8 + 1; + _data_455BF0 = 0; + _tick = _vm->getTick() + 1000 * getResource()->get(getSpeech()->getSoundResourceId())->size / 11025 / _data_455B3C; + } + + getText()->draw(_data_455BF0, 7, kTextCenter, x, y, 16, width, text); } void Encounter::drawScreen() { diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h index ce1c4c19cc8..4e1d564aea4 100644 --- a/engines/asylum/resources/encounters.h +++ b/engines/asylum/resources/encounters.h @@ -141,7 +141,7 @@ private: // Internal data int32 _data_455B14; - bool _data_455B3C; + uint32 _data_455B3C; uint32 _data_455B70; bool _data_455BCC; bool _data_455BD0; diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h index 757a10d2d6d..daa44f7ffc7 100644 --- a/engines/asylum/respack.h +++ b/engines/asylum/respack.h @@ -55,7 +55,6 @@ struct ResourceEntry { class ResourcePack { public: ResourceEntry *get(uint16 index); - int count(); protected: ResourcePack(Common::String filename); diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp index 7e42a7909bc..1b40985f71c 100644 --- a/engines/asylum/system/text.cpp +++ b/engines/asylum/system/text.cpp @@ -171,17 +171,17 @@ void Text::draw(int32 x, int32 y, ResourceId resourceId) { void Text::draw(const char *text, ResourceId fontResourceId, int32 y) { if (text) { loadFont(fontResourceId); - draw(true, 20, y, 16, 600, text); + draw(kTextCenter, 20, y, 16, 600, text); } } -void Text::draw(bool isCentered, int32 x, int32 y, int32 spacing, int32 width, const char *text) { - draw(0, 99, isCentered, x, y, spacing, width, text); +uint32 Text::draw(TextCentering centering, int32 x, int32 y, int32 spacing, int32 width, const char *text) { + return draw(0, 99, centering, x, y, spacing, width, text); } -void Text::draw(int32 a1, int32 a2, bool isCentered, int32 x, int32 y, int32 spacing, int32 width, const char *text) { +uint32 Text::draw(int32 a1, int32 a2, TextCentering centering, int32 x, int32 y, int32 spacing, int32 width, const char *text) { if (!text || !*text) - return; + return 0; bool drawText = false; int32 charWidth = 0; @@ -191,6 +191,8 @@ void Text::draw(int32 a1, int32 a2, bool isCentered, int32 x, int32 y, int32 spa const char *string = text; const char *endText = text; + uint32 printed = 0; + for (;;) { label_start: @@ -201,14 +203,23 @@ label_start: char currentChar = *endText; if (index >= a1 && index <= (a1 + 2)) { - if (isCentered) { + switch (centering) { + default: + case kTextCalculate: + break; + + case kTextCenter: drawCentered(x, y, width, endText - string, string); - } else { + break; + + case kTextNormal: setPosition(x, y); draw(text, endText - text); + break; } y += spacing; + ++printed; } ++index; @@ -271,6 +282,8 @@ label_start: endText = txt; drawText = true; } + + return printed; } void Text::drawCentered(int32 x, int32 y, int32 width, const char *text) { diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h index f374c082006..1e1be18dad6 100644 --- a/engines/asylum/system/text.h +++ b/engines/asylum/system/text.h @@ -36,6 +36,12 @@ class AsylumEngine; class GraphicResource; class ResourcePack; +enum TextCentering { + kTextNormal, + kTextCenter, + kTextCalculate +}; + class Text { public: Text(AsylumEngine *engine); @@ -57,8 +63,8 @@ public: void draw(int32 x, int32 y, ResourceId resourceId); void draw(const char *text, ResourceId fontResourceId, int32 y); void draw(const char *text, uint32 length); - void draw(bool isCentered, int32 x, int32 y, int32 spacing, int32 width, const char *text); - void draw(int32 a1, int32 a2, bool isCentered, int32 x, int32 y, int32 spacing, int32 width, const char *text); + uint32 draw(TextCentering centering, int32 x, int32 y, int32 spacing, int32 width, const char *text); + uint32 draw(int32 a1, int32 a2, TextCentering centering, int32 x, int32 y, int32 spacing, int32 width, const char *text); void drawCentered(int32 x, int32 y, int32 width, const char *text); void drawCentered(int32 x, int32 y, int32 width, ResourceId resourceId);