From 90415cf083d26e593ff05acb3a511c088a533b8b Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sat, 7 Jul 2012 13:23:54 +0200 Subject: GOB: Implement GCT text drawing in the end section The end section is now complete. --- engines/gob/pregob/onceupon/onceupon.cpp | 48 ++++++++++++++++++++++++++------ engines/gob/pregob/onceupon/onceupon.h | 3 ++ 2 files changed, 43 insertions(+), 8 deletions(-) (limited to 'engines/gob') diff --git a/engines/gob/pregob/onceupon/onceupon.cpp b/engines/gob/pregob/onceupon/onceupon.cpp index f1b24c3353..8c617e2c41 100644 --- a/engines/gob/pregob/onceupon/onceupon.cpp +++ b/engines/gob/pregob/onceupon/onceupon.cpp @@ -94,6 +94,9 @@ enum ClownAnimation { kClownAnimationClownCry = 6 }; +// 12 seconds delay for one area full of GCT text +static const uint32 kGCTDelay = 12000; + namespace Gob { namespace OnceUpon { @@ -222,6 +225,9 @@ void OnceUpon::init() { // We start with no selected difficulty and at section 0 _difficulty = kDifficultyMAX; _section = 0; + + // Default name + _name = "Nemo"; } void OnceUpon::deinit() { @@ -1518,6 +1524,10 @@ bool OnceUpon::sectionEnd() { _vm->_draw->_backSurface->blit(endBackground, 0, 0, 288, 137, 16, 50); + GCTFile *endText = loadGCT(getLocFile("final.gc")); + endText->setArea(17, 18, 303, 41); + endText->setText(1, _name); + ANIFile ani(_vm, "fin.ani", 320); ANIList anims; @@ -1526,26 +1536,48 @@ bool OnceUpon::sectionEnd() { _vm->_draw->forceBlit(); + uint32 textStartTime = 0; + MenuAction action = kMenuActionNone; while (!_vm->shouldQuit() && (action == kMenuActionNone)) { - redrawAnim(anims); - - fadeIn(); - - endFrame(true); + // Check user input int16 mouseX, mouseY; MouseButtons mouseButtons; int16 key = checkInput(mouseX, mouseY, mouseButtons); - if ((key != 0) && (key != kKeyEscape)) - // Any key pressed => Quit - action = kMenuActionQuit; action = doIngameMenu(key, mouseButtons); + if (action != kMenuActionNone) + break; + + clearAnim(anims); + + // Pressed a key or mouse button => Skip to next area-full of text + if ((mouseButtons == kMouseButtonsLeft) || (key != 0)) + textStartTime = 0; + + // Draw the next area-full of text + uint32 now = _vm->_util->getTimeKey(); + if (!endText->finished() && ((textStartTime == 0) || (now >= (textStartTime + kGCTDelay)))) { + textStartTime = now; + + int16 left, top, right, bottom; + if (endText->clear(*_vm->_draw->_backSurface, left, top, right, bottom)) + _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom); + + if (endText->draw(*_vm->_draw->_backSurface, 0, *_plettre, 10, left, top, right, bottom)) + _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom); + } + + drawAnim(anims); + fadeIn(); + + endFrame(true); } freeAnims(anims); + delete endText; // Restart requested if (action == kMenuActionRestart) diff --git a/engines/gob/pregob/onceupon/onceupon.h b/engines/gob/pregob/onceupon/onceupon.h index 7ae3a39485..386d410c95 100644 --- a/engines/gob/pregob/onceupon/onceupon.h +++ b/engines/gob/pregob/onceupon/onceupon.h @@ -24,6 +24,7 @@ #define GOB_PREGOB_ONCEUPON_ONCEUPON_H #include "common/system.h" +#include "common/str.h" #include "gob/pregob/pregob.h" @@ -312,6 +313,8 @@ private: Difficulty _difficulty; ///< The current difficulty. int _section; ///< The current game section. + + Common::String _name; ///< The name of the child. }; } // End of namespace OnceUpon -- cgit v1.2.3