From e0de03463e0c8145bd7700cd2f4955dfc0676967 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 14 Dec 2015 21:44:06 +0100 Subject: LAB: Use strlen to compute text length instead of a difference between start and end address. Some refactoring. --- engines/lab/intro.cpp | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) (limited to 'engines/lab/intro.cpp') diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp index 5c1c837da5..c739389425 100644 --- a/engines/lab/intro.cpp +++ b/engines/lab/intro.cpp @@ -80,11 +80,9 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) { return; uint32 lastMillis = 0; - IntuiMessage *msg; - bool drawNextText = true, end = false, begin = true; - - int32 cls, code, Drawn; - int16 qualifier; + bool drawNextText = true; + bool doneFl = false; + bool begin = true; Common::File *textFile = _vm->_resource->openDataFile(path); byte *textBuffer = new byte[textFile->size()]; @@ -99,19 +97,18 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) { else if (isScreen) _vm->_graphics->fade(false, 0); + int charDrawn = 0; if (isScreen) { _vm->_graphics->setAPen(7); _vm->_graphics->rectFillScaled(10, 10, 310, 190); - Drawn = _vm->_graphics->flowTextScaled(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, 14, 11, 306, 189, (char *)curText); + charDrawn = _vm->_graphics->flowTextScaled(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, 14, 11, 306, 189, (char *)curText); _vm->_graphics->fade(true, 0); - } else { - Drawn = _vm->_graphics->longDrawMessage((char *)curText); - } - - curText += Drawn; + } else + charDrawn = _vm->_graphics->longDrawMessage((char *)curText); - end = (*curText == 0); + curText += charDrawn; + doneFl = (*curText == 0); drawNextText = false; introEatMessages(); @@ -127,7 +124,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) { lastMillis = g_system->getMillis(); } - msg = _vm->_event->getMsg(); + IntuiMessage *msg = _vm->_event->getMsg(); if (msg == NULL) { _vm->_music->updateMusic(); @@ -136,7 +133,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) { uint32 elapsedSeconds = (g_system->getMillis() - lastMillis) / 1000; if (elapsedSeconds > timeDelay) { - if (end) { + if (doneFl) { if (isScreen) _vm->_graphics->fade(false, 0); @@ -146,15 +143,14 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) { drawNextText = true; } } - _vm->waitTOF(); } else { - cls = msg->_msgClass; - qualifier = msg->_qualifier; - code = msg->_code; + uint32 msgClass = msg->_msgClass; + uint16 qualifier = msg->_qualifier; + uint16 code = msg->_code; - if (((cls == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || - ((cls == RAWKEY) && (code == 27))) { + if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || + ((msgClass == RAWKEY) && (code == 27))) { _quitIntro = true; if (isScreen) @@ -162,9 +158,9 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) { delete[] textBuffer; return; - } else if (cls == MOUSEBUTTONS) { + } else if (msgClass == MOUSEBUTTONS) { if (IEQUALIFIER_LEFTBUTTON & qualifier) { - if (end) { + if (doneFl) { if (isScreen) _vm->_graphics->fade(false, 0); @@ -185,7 +181,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) { } } - if (end) { + if (doneFl) { if (isScreen) _vm->_graphics->fade(false, 0); -- cgit v1.2.3