diff options
author | Filippos Karapetis | 2019-10-29 00:13:57 +0200 |
---|---|---|
committer | Filippos Karapetis | 2019-10-29 02:58:36 +0200 |
commit | b2d1cfa12669b4273d8be8fd4fd99e6b02db10ec (patch) | |
tree | f47fb99fb510c860b76f1bc1be2168928c30f25f /engines/startrek/textbox.cpp | |
parent | f93bbfd7cae334d242760f6d3681b4ae318fa981 (diff) | |
download | scummvm-rg350-b2d1cfa12669b4273d8be8fd4fd99e6b02db10ec.tar.gz scummvm-rg350-b2d1cfa12669b4273d8be8fd4fd99e6b02db10ec.tar.bz2 scummvm-rg350-b2d1cfa12669b4273d8be8fd4fd99e6b02db10ec.zip |
STARTREK: Refactored mouse cursor and bitmap handling
- Reduced usage of SharedPtr
- Simplified the mouse cursor code (normal, locked, stack handling)
- Simplified the background handling code
- Initialize the mouse cursor after the graphics are initialized
Diffstat (limited to 'engines/startrek/textbox.cpp')
-rw-r--r-- | engines/startrek/textbox.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/engines/startrek/textbox.cpp b/engines/startrek/textbox.cpp index 33f2f235cf..542df25bc7 100644 --- a/engines/startrek/textbox.cpp +++ b/engines/startrek/textbox.cpp @@ -282,7 +282,7 @@ int StarTrekEngine::showText(TextGetterFunc textGetter, uintptr var, int xoffset error("showText: Not all choices have titles."); Sprite textboxSprite; - SharedPtr<TextBitmap> textBitmap = initTextSprite(&xoffset, &yoffset, textColor, numTextboxLines, numChoicesWithNames, &textboxSprite); + TextBitmap *textBitmap = initTextSprite(&xoffset, &yoffset, textColor, numTextboxLines, numChoicesWithNames, &textboxSprite); int choiceIndex = 0; int scrollOffset = 0; @@ -309,8 +309,6 @@ int StarTrekEngine::showText(TextGetterFunc textGetter, uintptr var, int xoffset loadMenuButtons("textbtns", xoffset + 0x96, yoffset - 0x11); Common::Point oldMousePos = _gfx->getMousePos(); - SharedPtr<Bitmap> oldMouseBitmap = _gfx->getMouseBitmap(); - _gfx->warpMouse(xoffset + 0xde, yoffset - 0x08); _gfx->setMouseBitmap(_gfx->loadBitmap("pushbtn")); @@ -450,7 +448,7 @@ readjustScroll: ticksUntilClickingEnabled = 0; } - _gfx->setMouseBitmap(oldMouseBitmap); + _gfx->popMouseBitmap(); _gfx->warpMouse(oldMousePos.x, oldMousePos.y); _mouseControllingShip = tmpMouseControllingShip; @@ -458,11 +456,14 @@ readjustScroll: textboxSprite.dontDrawNextFrame(); _gfx->drawAllSprites(); + //delete textBitmap; + textboxSprite.bitmap.reset(); _gfx->delSprite(&textboxSprite); } _textboxVar2 = _frameIndex; stopPlayingSpeech(); + return choiceIndex; } @@ -501,7 +502,7 @@ String StarTrekEngine::putTextIntoLines(const String &_text) { return output; } -SharedPtr<TextBitmap> StarTrekEngine::initTextSprite(int *xoffsetPtr, int *yoffsetPtr, byte textColor, int numTextLines, bool withHeader, Sprite *sprite) { +TextBitmap *StarTrekEngine::initTextSprite(int *xoffsetPtr, int *yoffsetPtr, byte textColor, int numTextLines, bool withHeader, Sprite *sprite) { int linesBeforeTextStart = 2; if (withHeader) linesBeforeTextStart = 4; @@ -511,12 +512,12 @@ SharedPtr<TextBitmap> StarTrekEngine::initTextSprite(int *xoffsetPtr, int *yoffs int textHeight = numTextLines + linesBeforeTextStart; - SharedPtr<TextBitmap> bitmap(new TextBitmap(TEXTBOX_WIDTH * 8, textHeight * 8)); + TextBitmap *bitmap = new TextBitmap(TEXTBOX_WIDTH * 8, textHeight * 8); *sprite = Sprite(); sprite->drawPriority = 15; sprite->drawPriority2 = 8; - sprite->bitmap = bitmap; + sprite->bitmap = SharedPtr<TextBitmap>(bitmap); // This is deallocated explicitly at the end of showText() sprite->textColor = textColor; memset(bitmap->pixels, ' ', textHeight * TEXTBOX_WIDTH); @@ -575,7 +576,7 @@ SharedPtr<TextBitmap> StarTrekEngine::initTextSprite(int *xoffsetPtr, int *yoffs return bitmap; } -void StarTrekEngine::drawMainText(SharedPtr<TextBitmap> bitmap, int numTextLines, int numTextboxLines, const String &_text, bool withHeader) { +void StarTrekEngine::drawMainText(TextBitmap *bitmap, int numTextLines, int numTextboxLines, const String &_text, bool withHeader) { byte *dest = bitmap->pixels + TEXTBOX_WIDTH + 1; // Start of 2nd row const char *text = _text.c_str(); @@ -601,7 +602,7 @@ void StarTrekEngine::drawMainText(SharedPtr<TextBitmap> bitmap, int numTextLines } } -String StarTrekEngine::readLineFormattedText(TextGetterFunc textGetter, uintptr var, int choiceIndex, SharedPtr<TextBitmap> textBitmap, int numTextboxLines, int *numTextLines) { +String StarTrekEngine::readLineFormattedText(TextGetterFunc textGetter, uintptr var, int choiceIndex, TextBitmap *textBitmap, int numTextboxLines, int *numTextLines) { String headerText; String text = (this->*textGetter)(choiceIndex, var, &headerText); |