diff options
| -rw-r--r-- | engines/startrek/actors.cpp | 16 | ||||
| -rw-r--r-- | engines/startrek/awaymission.cpp | 2 | ||||
| -rw-r--r-- | engines/startrek/graphics.cpp | 118 | ||||
| -rw-r--r-- | engines/startrek/graphics.h | 26 | ||||
| -rw-r--r-- | engines/startrek/intro.cpp | 5 | ||||
| -rw-r--r-- | engines/startrek/menu.cpp | 10 | ||||
| -rw-r--r-- | engines/startrek/room.cpp | 4 | ||||
| -rw-r--r-- | engines/startrek/rooms/demon4.cpp | 6 | ||||
| -rw-r--r-- | engines/startrek/rooms/demon6.cpp | 4 | ||||
| -rw-r--r-- | engines/startrek/sprite.cpp | 4 | ||||
| -rw-r--r-- | engines/startrek/sprite.h | 2 | ||||
| -rw-r--r-- | engines/startrek/startrek.cpp | 8 | ||||
| -rw-r--r-- | engines/startrek/startrek.h | 14 | ||||
| -rw-r--r-- | engines/startrek/textbox.cpp | 19 | 
14 files changed, 91 insertions, 147 deletions
diff --git a/engines/startrek/actors.cpp b/engines/startrek/actors.cpp index 21b2892868..a0c6b9c146 100644 --- a/engines/startrek/actors.cpp +++ b/engines/startrek/actors.cpp @@ -694,8 +694,8 @@ int StarTrekEngine::findObjectAt(int x, int y) {  	return -1;  } -SharedPtr<Bitmap> StarTrekEngine::loadAnimationFrame(const Common::String &filename, Fixed8 scale) { -	SharedPtr<Bitmap> bitmapToReturn; +Bitmap *StarTrekEngine::loadAnimationFrame(const Common::String &filename, Fixed8 scale) { +	Bitmap *bitmapToReturn = nullptr;  	char basename[5];  	strncpy(basename, filename.c_str() + 1, 4); @@ -718,12 +718,12 @@ SharedPtr<Bitmap> StarTrekEngine::loadAnimationFrame(const Common::String &filen  			if (bitmapToReturn == nullptr) {  				Common::String mccoyFilename = filename;  				mccoyFilename.setChar('m', 0); -				SharedPtr<Bitmap> bitmap = _gfx->loadBitmap(mccoyFilename); +				Bitmap *bitmap = _gfx->loadBitmap(mccoyFilename);  				uint16 width = bitmap->width;  				uint16 height = bitmap->height; -				bitmapToReturn = SharedPtr<Bitmap>(new Bitmap(width, height)); +				bitmapToReturn = new Bitmap(width, height);  				bitmapToReturn->xoffset = bitmap->xoffset;  				bitmapToReturn->yoffset = bitmap->yoffset; @@ -1278,7 +1278,7 @@ exitWithoutSelection:  	return lastItemIndex;  } -void StarTrekEngine::initStarfieldSprite(Sprite *sprite, SharedPtr<Bitmap> bitmap, const Common::Rect &rect) { +void StarTrekEngine::initStarfieldSprite(Sprite *sprite, Bitmap *bitmap, const Common::Rect &rect) {  	sprite->setXYAndPriority(rect.left, rect.top, 0);  	sprite->setBitmap(bitmap);  	bitmap->xoffset = 0; @@ -1289,7 +1289,7 @@ void StarTrekEngine::initStarfieldSprite(Sprite *sprite, SharedPtr<Bitmap> bitma  	sprite->drawMode = 1;  } -SharedPtr<Bitmap> StarTrekEngine::scaleBitmap(SharedPtr<Bitmap> bitmap, Fixed8 scale) { +Bitmap *StarTrekEngine::scaleBitmap(Bitmap *bitmap, Fixed8 scale) {  	int scaledWidth  = scale.multToInt(bitmap->width);  	int scaledHeight = scale.multToInt(bitmap->height);  	int origWidth  = bitmap->width; @@ -1300,7 +1300,7 @@ SharedPtr<Bitmap> StarTrekEngine::scaleBitmap(SharedPtr<Bitmap> bitmap, Fixed8 s  	if (scaledHeight < 1)  		scaledHeight = 1; -	SharedPtr<Bitmap> scaledBitmap(new Bitmap(scaledWidth, scaledHeight)); +	Bitmap *scaledBitmap = new Bitmap(scaledWidth, scaledHeight);  	scaledBitmap->xoffset = scale.multToInt(bitmap->xoffset);  	scaledBitmap->yoffset = scale.multToInt(bitmap->yoffset); @@ -1360,6 +1360,8 @@ SharedPtr<Bitmap> StarTrekEngine::scaleBitmap(SharedPtr<Bitmap> bitmap, Fixed8 s  		delete[] rowData;  	} +	delete bitmap; +  	return scaledBitmap;  } diff --git a/engines/startrek/awaymission.cpp b/engines/startrek/awaymission.cpp index 1b6af075a8..d05cc35a73 100644 --- a/engines/startrek/awaymission.cpp +++ b/engines/startrek/awaymission.cpp @@ -467,6 +467,8 @@ void StarTrekEngine::unloadRoom() {  	_room = nullptr;  	delete _mapFile;  	_mapFile = nullptr; +	delete _iwFile; +	_iwFile = nullptr;  }  int StarTrekEngine::loadActorAnimWithRoomScaling(int actorIndex, const Common::String &animName, int16 x, int16 y) { diff --git a/engines/startrek/graphics.cpp b/engines/startrek/graphics.cpp index f56d7d3707..e1073e2c50 100644 --- a/engines/startrek/graphics.cpp +++ b/engines/startrek/graphics.cpp @@ -61,14 +61,7 @@ Graphics::Graphics(StarTrekEngine *vm) : _vm(vm), _egaMode(false) {  	memset(_lutData, 0, 256 * 3);  	_paletteFadeLevel = 0; -	_mouseLocked = false; -	_mouseToBeShown = false; -	_mouseToBeHidden = false; -	_mouseWarpX = -1; -	_mouseWarpY = -1; - -	setMouseBitmap(loadBitmap("pushbtn")); -	CursorMan.showMouse(true); +	_lockedMousePos = Common::Point(-1, -1);  }  Graphics::~Graphics() { @@ -79,9 +72,8 @@ Graphics::~Graphics() {  	delete _font;  } - -void Graphics::setBackgroundImage(SharedPtr<Bitmap> bitmap) { -	_backgroundImage = SharedPtr<Bitmap>(new Bitmap(*bitmap)); +void Graphics::setBackgroundImage(Bitmap *bitmap) { +	_backgroundImage = SharedPtr<Bitmap>(bitmap);  }  void Graphics::drawBitmapToBackground(const Common::Rect &origRect, const Common::Rect &drawRect, Bitmap *bitmap) { @@ -246,68 +238,43 @@ byte Graphics::getPriValue(int x, int y) {  		return b >> 4;  } -SharedPtr<Bitmap> Graphics::loadBitmap(Common::String basename) { -	return SharedPtr<Bitmap>(new Bitmap(SharedPtr<Common::MemoryReadStreamEndian>(_vm->loadFile(basename + ".BMP")))); +Bitmap *Graphics::loadBitmap(Common::String basename) { +	return new Bitmap(SharedPtr<Common::MemoryReadStreamEndian>(_vm->loadFile(basename + ".BMP")));  }  Common::Point Graphics::getMousePos() { -	if (_mouseWarpX != -1) -		return Common::Point(_mouseWarpX, _mouseWarpY); -  	return _vm->_system->getEventManager()->getMousePos();  } -void Graphics::setMouseBitmap(SharedPtr<Bitmap> bitmap) { -	_mouseBitmap = bitmap; - -	if (_mouseLocked) -		_lockedMouseSprite.setBitmap(_mouseBitmap); +void Graphics::setMouseBitmap(Bitmap *bitmap) { +	CursorMan.pushCursor( +		bitmap->pixels, +		bitmap->width, +		bitmap->height, +		bitmap->xoffset, +		bitmap->yoffset, +		0 +	);  } -void Graphics::lockMousePosition(int16 x, int16 y) { -	if (_mouseLocked) { -		if (x != _lockedMouseSprite.pos.x || y != _lockedMouseSprite.pos.y) { -			_lockedMouseSprite.pos.x = x; -			_lockedMouseSprite.pos.y = y; -			_lockedMouseSprite.bitmapChanged = true; -		} -		return; -	} - -	_mouseLocked = true; -	_mouseToBeHidden = true; -	_mouseToBeShown = false; - -	_lockedMouseSprite = Sprite(); -	_lockedMouseSprite.setBitmap(_mouseBitmap); -	_lockedMouseSprite.drawPriority = 15; -	_lockedMouseSprite.drawPriority2 = 16; -	_lockedMouseSprite.pos.x = x; -	_lockedMouseSprite.pos.y = y; - -	addSprite(&_lockedMouseSprite); +void Graphics::popMouseBitmap() { +	CursorMan.popCursor();  } -void Graphics::unlockMousePosition() { -	if (!_mouseLocked) -		return; - -	_mouseLocked = false; -	_mouseToBeShown = true; -	_mouseToBeHidden = false; +void Graphics::toggleMouse(bool visible) { +	CursorMan.showMouse(visible); +} -	_lockedMouseSprite.dontDrawNextFrame(); -	drawAllSprites(false); -	delSprite(&_lockedMouseSprite); +void Graphics::lockMousePosition(int16 x, int16 y) { +	_lockedMousePos = Common::Point(x, y);  } -SharedPtr<Bitmap> Graphics::getMouseBitmap() { -	return _mouseBitmap; +void Graphics::unlockMousePosition() { +	_lockedMousePos = Common::Point(-1, -1);  }  void Graphics::warpMouse(int16 x, int16 y) { -	_mouseWarpX = x; -	_mouseWarpY = y; +	_vm->_system->warpMouse(x, y);  }  void Graphics::drawSprite(const Sprite &sprite, ::Graphics::Surface *surface) { @@ -621,24 +588,8 @@ void Graphics::forceDrawAllSprites(bool updateScreenFlag) {  }  void Graphics::updateScreen() { -	// Check if there are any pending updates to the mouse. -	if (_mouseBitmap != _mouseBitmapLastFrame) { -		_mouseBitmapLastFrame = _mouseBitmap; -		_vm->_system->setMouseCursor(_mouseBitmap->pixels, _mouseBitmap->width, _mouseBitmap->height, _mouseBitmap->xoffset, _mouseBitmap->yoffset, 0); -	} -	if (_mouseToBeShown) { -		CursorMan.showMouse(true); -		_mouseToBeShown = false; -	} else if (_mouseToBeHidden) { -		CursorMan.showMouse(false); -		_mouseToBeHidden = false; -	} - -	if (_mouseWarpX != -1) { -		_vm->_system->warpMouse(_mouseWarpX, _mouseWarpY); -		_mouseWarpX = -1; -		_mouseWarpY = -1; -	} +	if (_lockedMousePos.x != -1) +		_vm->_system->warpMouse(_lockedMousePos.x, _lockedMousePos.y);  	_vm->_console->onFrame();  	_vm->_system->updateScreen(); @@ -649,8 +600,6 @@ Sprite *Graphics::getSpriteAt(int16 x, int16 y) {  	for (int i = _numSprites - 1; i >= 0; i--) {  		Sprite *sprite = _sprites[i]; -		if (sprite == &_lockedMouseSprite) -			continue;  		if (sprite->drawMode == 1) // Invisible  			continue; @@ -723,16 +672,17 @@ byte *Graphics::getFontGfx(char c) {  	return _font->getCharData(c & 0xff);  } -  void Graphics::copyBackgroundScreen() { -	drawDirectToScreen(_backgroundImage); +	_vm->_system->copyRectToScreen( +		_backgroundImage->pixels, +		_backgroundImage->width, +		_backgroundImage->xoffset, +		_backgroundImage->yoffset, +		_backgroundImage->width, +		_backgroundImage->height +	);  } -void Graphics::drawDirectToScreen(SharedPtr<Bitmap> bitmap) { -	_vm->_system->copyRectToScreen(bitmap->pixels, bitmap->width, bitmap->xoffset, bitmap->yoffset, bitmap->width, bitmap->height); -} - -  void Graphics::loadEGAData(const char *filename) {  	// Load EGA palette data  	if (!_egaMode) diff --git a/engines/startrek/graphics.h b/engines/startrek/graphics.h index 3357931bb9..26a6798c8b 100644 --- a/engines/startrek/graphics.h +++ b/engines/startrek/graphics.h @@ -51,7 +51,7 @@ public:  	Graphics(StarTrekEngine *vm);  	~Graphics(); -	void setBackgroundImage(SharedPtr<Bitmap> bitmap); +	void setBackgroundImage(Bitmap *bitmap);  	/**  	 * @param origRect The rectangle containing the original bitmap (must contain the  	 *                 whole bitmap, even if some is outside the drawable space) @@ -84,14 +84,17 @@ public:  	void setPri(byte val);  	byte getPriValue(int x, int y); -	SharedPtr<Bitmap> loadBitmap(String basename); +	Bitmap *loadBitmap(String basename);  	Common::Point getMousePos();  	/**  	 * Changes the mouse bitmap. The change won't take effect until drawAllSprites is  	 * called again.  	 */ -	void setMouseBitmap(SharedPtr<Bitmap> bitmap); +	void setMouseBitmap(Bitmap *bitmap); +	void popMouseBitmap(); +	void toggleMouse(bool visible); +  	/**  	 * This function is a workaround for when the mouse position needs to be locked in a set  	 * position (used in the action menu). This only affects the position it is drawn at; the @@ -101,7 +104,6 @@ public:  	 */  	void lockMousePosition(int16 x, int16 y);  	void unlockMousePosition(); -	SharedPtr<Bitmap> getMouseBitmap();  	void warpMouse(int16 x, int16 y);  	void drawSprite(const Sprite &sprite, ::Graphics::Surface *surface); @@ -146,7 +148,6 @@ public:  	byte *getFontGfx(char c);  	void copyBackgroundScreen(); -	void drawDirectToScreen(SharedPtr<Bitmap> bitmap);  	void loadEGAData(const char *egaFile);  	void drawBackgroundImage(const char *filename); @@ -174,20 +175,7 @@ private:  	Sprite *_pushedSprites[MAX_SPRITES];  	int _pushedNumSprites; -	// Any changes to the mouse image are buffered until the next time "drawAllSprites" is -	// called (since the original game treats it like a sprite). -	bool _mouseToBeShown; -	bool _mouseToBeHidden; -	int16 _mouseWarpX, _mouseWarpY; -	SharedPtr<Bitmap> _mouseBitmapLastFrame; -	SharedPtr<Bitmap> _mouseBitmap; - -	// These are used as a workaround for when the mouse position must be locked. -	// The mouse is turned into a native game sprite when this happens. -	bool _mouseLocked; -	Sprite _lockedMouseSprite; - -public: +	Common::Point _lockedMousePos;  };  } // End of namespace StarTrek diff --git a/engines/startrek/intro.cpp b/engines/startrek/intro.cpp index ce77c974ef..cb0b096be6 100644 --- a/engines/startrek/intro.cpp +++ b/engines/startrek/intro.cpp @@ -30,8 +30,7 @@ void StarTrekEngine::playIntro() {  	initStarfieldPosition();  	initStarfield(10, 20, 309, 169, 128); -	SharedPtr<Bitmap> fakeStarfieldBitmap(new StubBitmap(0, 0)); -	_starfieldSprite.bitmap = fakeStarfieldBitmap; +	Bitmap *fakeStarfieldBitmap = new StubBitmap(0, 0);  	initStarfieldSprite(&_starfieldSprite, fakeStarfieldBitmap, _starfieldRect);  	//delR3(&_enterpriseR3); // TODO: uncomment @@ -58,7 +57,7 @@ void StarTrekEngine::playIntro() {  	Sprite subtitleSprite;  	_gfx->addSprite(&subtitleSprite);  	subtitleSprite.setXYAndPriority(0, 0, 12); -	subtitleSprite.bitmap = _gfx->loadBitmap("blank"); +	subtitleSprite.setBitmap(_gfx->loadBitmap("blank"));  	subtitleSprite.drawPriority2 = 16;  	int index = 12; diff --git a/engines/startrek/menu.cpp b/engines/startrek/menu.cpp index 039bddfab9..09528ce3c6 100644 --- a/engines/startrek/menu.cpp +++ b/engines/startrek/menu.cpp @@ -185,8 +185,6 @@ void StarTrekEngine::showOptionsMenu(int x, int y) {  	_mouseControllingShip = false;  	Common::Point oldMousePos = _gfx->getMousePos(); -	SharedPtr<Bitmap> oldMouseBitmap = _gfx->getMouseBitmap(); -  	_gfx->setMouseBitmap(_gfx->loadBitmap("options"));  	loadMenuButtons("options", x, y); @@ -213,7 +211,7 @@ void StarTrekEngine::showOptionsMenu(int x, int y) {  	unloadMenuButtons();  	_mouseControllingShip = tmpMouseControllingShip; -	_gfx->setMouseBitmap(oldMouseBitmap); +	_gfx->popMouseBitmap();  	if (event != MENUEVENT_LCLICK_OFFBUTTON && event != MENUEVENT_RCLICK_OFFBUTTON)  		_gfx->warpMouse(oldMousePos.x, oldMousePos.y); @@ -306,7 +304,7 @@ int StarTrekEngine::showActionMenu() {  	bool addEventBack = false;  	int action = ACTION_WALK; -	menuSprite.bitmap = _gfx->loadBitmap("action"); +	menuSprite.setBitmap(_gfx->loadBitmap("action"));  	int menuWidth = menuSprite.bitmap->width;  	int menuHeight = menuSprite.bitmap->height; @@ -522,7 +520,7 @@ void StarTrekEngine::loadMenuButtons(String mnuFilename, int xpos, int ypos) {  		}  		bitmapBasename[10] = '\0'; -		_activeMenu->sprites[i].bitmap = _gfx->loadBitmap(bitmapBasename); +		_activeMenu->sprites[i].setBitmap(_gfx->loadBitmap(bitmapBasename));  		_activeMenu->sprites[i].pos.x = stream->readUint16() + xpos;  		_activeMenu->sprites[i].pos.y = stream->readUint16() + ypos;  		_activeMenu->retvals[i] = stream->readUint16(); @@ -1131,7 +1129,7 @@ lclick:  				if (!spriteLoaded) {  					_gfx->addSprite(&someSprite);  					someSprite.setXYAndPriority(3, 168, 15); -					someSprite.bitmap = _gfx->loadBitmap(Common::String::format("turbo%d", clickedArea)); +					someSprite.setBitmap(_gfx->loadBitmap(Common::String::format("turbo%d", clickedArea)));  					spriteLoaded = true;  				}  			} else { diff --git a/engines/startrek/room.cpp b/engines/startrek/room.cpp index a01f52f92c..71c778acc0 100644 --- a/engines/startrek/room.cpp +++ b/engines/startrek/room.cpp @@ -536,8 +536,8 @@ void Room::loadMapFile(const Common::String &name) {  	delete _vm->_mapFile;  	_vm->_mapFile = _vm->loadFile(name + ".map"); -	_vm->_iwFile.reset(); -	_vm->_iwFile = SharedPtr<IWFile>(new IWFile(_vm, name + ".iw")); +	delete _vm->_iwFile; +	_vm->_iwFile = new IWFile(_vm, name + ".iw");  }  void Room::showBitmapFor5Ticks(const Common::String &bmpName, int priority) { diff --git a/engines/startrek/rooms/demon4.cpp b/engines/startrek/rooms/demon4.cpp index 848500d06c..30cfa729da 100644 --- a/engines/startrek/rooms/demon4.cpp +++ b/engines/startrek/rooms/demon4.cpp @@ -397,9 +397,9 @@ bool Room::demon4ShowSunPuzzle() {  	sprites[1].setBitmap(_vm->_gfx->loadBitmap("leverr"));  	sprites[2].setBitmap(_vm->_gfx->loadBitmap("leverb")); -	SharedPtr<Bitmap> lightyBitmap = _vm->_gfx->loadBitmap("lighty"); -	SharedPtr<Bitmap> lightrBitmap = _vm->_gfx->loadBitmap("lightr"); -	SharedPtr<Bitmap> lightbBitmap = _vm->_gfx->loadBitmap("lightb"); +	SharedPtr<Bitmap> lightyBitmap = SharedPtr<Bitmap>(_vm->_gfx->loadBitmap("lighty")); +	SharedPtr<Bitmap> lightrBitmap = SharedPtr<Bitmap>(_vm->_gfx->loadBitmap("lightr")); +	SharedPtr<Bitmap> lightbBitmap = SharedPtr<Bitmap>(_vm->_gfx->loadBitmap("lightb"));  	for (int i = 3; i < 9; i++)  		sprites[i].bitmap = lightyBitmap; diff --git a/engines/startrek/rooms/demon6.cpp b/engines/startrek/rooms/demon6.cpp index 379c26fbe5..8c35a70b43 100644 --- a/engines/startrek/rooms/demon6.cpp +++ b/engines/startrek/rooms/demon6.cpp @@ -466,7 +466,7 @@ int Room::demon6ShowCase(int visible) {  		sprites[i].pos.y = spritePositions[i].y;  		sprites[i].drawPriority = 2;  		sprites[i].bitmapChanged = true; -		sprites[i].bitmap = _vm->_gfx->loadBitmap(Common::String::format("stlitem%d", i)); +		sprites[i].setBitmap(_vm->_gfx->loadBitmap(Common::String::format("stlitem%d", i)));  	}  	Sprite buttonSprite; @@ -478,7 +478,7 @@ int Room::demon6ShowCase(int visible) {  	buttonSprite.pos.y = 0x19;  	buttonSprite.drawPriority = 2;  	buttonSprite.bitmapChanged = true; -	buttonSprite.bitmap = _vm->_gfx->loadBitmap("donebutt"); +	buttonSprite.setBitmap(_vm->_gfx->loadBitmap("donebutt"));  	_vm->_gfx->addSprite(&buttonSprite);  	_vm->_gfx->forceDrawAllSprites(); diff --git a/engines/startrek/sprite.cpp b/engines/startrek/sprite.cpp index 63e24c2ccf..8b042f2525 100644 --- a/engines/startrek/sprite.cpp +++ b/engines/startrek/sprite.cpp @@ -32,8 +32,8 @@ Sprite::Sprite() :  	drawRect(), rectangle2(), drawX(0), drawY(0)  {} -void Sprite::setBitmap(SharedPtr<Bitmap> b) { -	bitmap = b; +void Sprite::setBitmap(Bitmap *b) { +	bitmap = SharedPtr<Bitmap>(b);  	bitmapChanged = true;  } diff --git a/engines/startrek/sprite.h b/engines/startrek/sprite.h index ab66adee30..5c9792be6a 100644 --- a/engines/startrek/sprite.h +++ b/engines/startrek/sprite.h @@ -61,7 +61,7 @@ struct Sprite : Common::Serializable {  	Sprite(); -	void setBitmap(SharedPtr<Bitmap> b); +	void setBitmap(Bitmap *b);  	void setXYAndPriority(int16 x, int16 y, int16 priority);  	void dontDrawNextFrame(); diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp index d1d5fa5111..4266462cff 100644 --- a/engines/startrek/startrek.cpp +++ b/engines/startrek/startrek.cpp @@ -97,6 +97,7 @@ StarTrekEngine::StarTrekEngine(OSystem *syst, const StarTrekGameDescription *gam  	_missionToLoad = "DEMON";  	_roomIndexToLoad = 0;  	_mapFile = nullptr; +	_iwFile = nullptr;  	_showSubtitles = true;  	Common::fill(_r3List, _r3List + NUM_SPACE_OBJECTS, (R3 *)nullptr); @@ -131,6 +132,9 @@ Common::Error StarTrekEngine::run() {  	initGraphics(SCREEN_WIDTH, SCREEN_HEIGHT);  	initializeEventsAndMouse(); +	_gfx->setMouseBitmap(_gfx->loadBitmap("pushbtn")); +	_gfx->toggleMouse(true); +  	bool shouldPlayIntro = true;  	bool loadedSave = false; @@ -260,11 +264,11 @@ void StarTrekEngine::runTransportSequence(const Common::String &name) {  	actorFunc1();  	initActors(); -	SharedPtr<Bitmap> bgImage = _gfx->loadBitmap("transprt"); +	Bitmap *bgImage = _gfx->loadBitmap("transprt");  	_gfx->setBackgroundImage(bgImage);  	_gfx->clearPri();  	_gfx->loadPalette("palette"); -	_gfx->drawDirectToScreen(bgImage); +	_gfx->copyBackgroundScreen();  	_system->updateScreen();  	_system->delayMillis(10); diff --git a/engines/startrek/startrek.h b/engines/startrek/startrek.h index f07da10b20..a55b59e689 100644 --- a/engines/startrek/startrek.h +++ b/engines/startrek/startrek.h @@ -407,7 +407,7 @@ public:  	/**  	 * Loads a bitmap for the animation frame with the given scale.  	 */ -	SharedPtr<Bitmap> loadAnimationFrame(const Common::String &filename, Fixed8 scale); +	Bitmap *loadAnimationFrame(const Common::String &filename, Fixed8 scale);  	/**  	 * Called when the "get" action is first selected. Returns a selected object. @@ -436,8 +436,8 @@ public:  	void showInventoryIcons(bool showItem);  	void hideInventoryIcons();  	int showInventoryMenu(int x, int y, bool restoreMouse); -	void initStarfieldSprite(Sprite *sprite, SharedPtr<Bitmap> bitmap, const Common::Rect &rect); -	SharedPtr<Bitmap> scaleBitmap(SharedPtr<Bitmap> bitmap, Fixed8 scale); +	void initStarfieldSprite(Sprite *sprite, Bitmap *bitmap, const Common::Rect &rect); +	Bitmap *scaleBitmap(Bitmap *bitmap, Fixed8 scale);  	/**  	 * This takes a row of an unscaled bitmap, and copies it to a row of a scaled bitmap.  	 * This was heavily optimized in the original game (manually constructed an unrolled @@ -531,13 +531,13 @@ public:  	/**  	 * Creates a blank textbox in a TextBitmap, and initializes a sprite to use it.  	 */ -	SharedPtr<TextBitmap> initTextSprite(int *xoffsetPtr, int *yoffsetPtr, byte textColor, int numTextLines, bool withHeader, Sprite *sprite); +	TextBitmap *initTextSprite(int *xoffsetPtr, int *yoffsetPtr, byte textColor, int numTextLines, bool withHeader, Sprite *sprite);  	/**  	 * Draws the "main" text (everything but the header at the top) to a TextBitmap.  	 */ -	void drawMainText(SharedPtr<TextBitmap> bitmap, int numTextLines, int numTextboxLines, const String &text, bool withHeader); +	void drawMainText(TextBitmap *bitmap, int numTextLines, int numTextboxLines, const String &text, bool withHeader); -	String readLineFormattedText(TextGetterFunc textGetter, uintptr var, int choiceIndex, SharedPtr<TextBitmap> textBitmap, int numTextboxLines, int *numLines); +	String readLineFormattedText(TextGetterFunc textGetter, uintptr var, int choiceIndex, TextBitmap *textBitmap, int numTextboxLines, int *numLines);  	/**  	 * Text getter for showText which reads choices from an array of pointers. @@ -781,7 +781,7 @@ public:  	Graphics *_gfx;  	Sound *_sound;  	Console *_console; -	SharedPtr<IWFile> _iwFile; +	IWFile *_iwFile;  private:  	Common::RandomSource _randomSource; 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);  | 
