From 07cebdbf2b70e02b12d32880d23dbe293ab12358 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 12:27:06 +0200 Subject: WINTERMUTE: Change usage of Common::Rect to our own 32-bit variant. --- engines/wintermute/Ad/AdGame.cpp | 6 +- engines/wintermute/Ad/AdInventoryBox.cpp | 6 +- engines/wintermute/Ad/AdInventoryBox.h | 2 +- engines/wintermute/Ad/AdItem.cpp | 2 +- engines/wintermute/Ad/AdResponseBox.cpp | 2 +- engines/wintermute/Ad/AdResponseBox.h | 2 +- engines/wintermute/Ad/AdScene.cpp | 4 +- engines/wintermute/Ad/AdSentence.h | 3 +- engines/wintermute/Base/BActiveRect.cpp | 2 +- engines/wintermute/Base/BActiveRect.h | 3 +- engines/wintermute/Base/BFontBitmap.cpp | 2 +- engines/wintermute/Base/BFontTT.cpp | 2 +- engines/wintermute/Base/BFrame.cpp | 6 +- engines/wintermute/Base/BFrame.h | 2 +- engines/wintermute/Base/BGame.cpp | 14 ++--- engines/wintermute/Base/BGame.h | 9 +-- engines/wintermute/Base/BObject.h | 2 +- engines/wintermute/Base/BPersistMgr.cpp | 4 +- engines/wintermute/Base/BPersistMgr.h | 5 +- engines/wintermute/Base/BRegion.cpp | 6 +- engines/wintermute/Base/BRegion.h | 4 +- engines/wintermute/Base/BRenderSDL.cpp | 8 +-- engines/wintermute/Base/BRenderSDL.h | 4 +- engines/wintermute/Base/BRenderer.cpp | 8 +-- engines/wintermute/Base/BRenderer.h | 12 ++-- engines/wintermute/Base/BSprite.cpp | 6 +- engines/wintermute/Base/BSprite.h | 4 +- engines/wintermute/Base/BSubFrame.cpp | 6 +- engines/wintermute/Base/BSubFrame.h | 4 +- engines/wintermute/Base/BSurface.cpp | 4 +- engines/wintermute/Base/BSurface.h | 15 ++--- engines/wintermute/Base/BSurfaceSDL.cpp | 14 ++--- engines/wintermute/Base/BSurfaceSDL.h | 14 ++--- engines/wintermute/Base/BViewport.cpp | 2 +- engines/wintermute/Base/BViewport.h | 4 +- engines/wintermute/Base/PartEmitter.h | 2 +- engines/wintermute/Base/PartParticle.cpp | 2 +- engines/wintermute/Base/PartParticle.h | 3 +- engines/wintermute/PlatformSDL.cpp | 22 +++---- engines/wintermute/PlatformSDL.h | 22 +++---- engines/wintermute/UI/UIButton.cpp | 4 +- engines/wintermute/UI/UIObject.cpp | 2 +- engines/wintermute/UI/UITiledImage.h | 18 +++--- engines/wintermute/UI/UIWindow.cpp | 2 +- engines/wintermute/UI/UIWindow.h | 6 +- engines/wintermute/math/Rect32.h | 86 ++++++++++++++++++++++++++++ engines/wintermute/utils/utils.cpp | 2 +- engines/wintermute/utils/utils.h | 3 +- engines/wintermute/video/VidTheoraPlayer.cpp | 2 +- 49 files changed, 231 insertions(+), 138 deletions(-) create mode 100644 engines/wintermute/math/Rect32.h (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 6a58f99881..ed31cd3acb 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1210,7 +1210,7 @@ ERRORCODE CAdGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SCENE_VIEWPORT: { - Common::Rect rc; + Rect32 rc; parser.scanStr((char *)params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); if (!_sceneViewport) _sceneViewport = new CBViewport(Game); if (_sceneViewport) _sceneViewport->setRect(rc.left, rc.top, rc.right, rc.bottom); @@ -1698,7 +1698,7 @@ ERRORCODE CAdGame::displayContent(bool doUpdate, bool displayAll) { // process scripts if (doUpdate) _scEngine->tick(); - Common::Point p; + Point32 p; getMousePos(&p); _scene->update(); @@ -1924,7 +1924,7 @@ char *CAdGame::findSpeechFile(char *stringID) { ////////////////////////////////////////////////////////////////////////// bool CAdGame::validMouse() { - Common::Point pos; + Point32 pos; CBPlatform::getCursorPos(&pos); return _renderer->pointInViewport(&pos); diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index fe3a9b8a09..a528167e8c 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -47,7 +47,7 @@ IMPLEMENT_PERSISTENT(CAdInventoryBox, false) ////////////////////////////////////////////////////////////////////////// CAdInventoryBox::CAdInventoryBox(CBGame *inGame): CBObject(inGame) { - CBPlatform::setRectEmpty(&_itemsArea); + _itemsArea.setEmpty(); _scrollOffset = 0; _spacing = 0; _itemWidth = _itemHeight = 50; @@ -123,9 +123,9 @@ ERRORCODE CAdInventoryBox::display() { // display window - Common::Rect rect = _itemsArea; + Rect32 rect = _itemsArea; if (_window) { - CBPlatform::offsetRect(&rect, _window->_posX, _window->_posY); + rect.offsetRect(_window->_posX, _window->_posY); _window->display(); } diff --git a/engines/wintermute/Ad/AdInventoryBox.h b/engines/wintermute/Ad/AdInventoryBox.h index e3aec3a20b..857abd5d35 100644 --- a/engines/wintermute/Ad/AdInventoryBox.h +++ b/engines/wintermute/Ad/AdInventoryBox.h @@ -49,7 +49,7 @@ public: CUIButton *_closeButton; int _spacing; int _scrollOffset; - Common::Rect _itemsArea; + Rect32 _itemsArea; ERRORCODE listen(CBScriptHolder *param1, uint32 param2); CUIWindow *_window; CAdInventoryBox(CBGame *inGame); diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index 435947e96d..e8c32607dc 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -389,7 +389,7 @@ ERRORCODE CAdItem::update() { ERRORCODE CAdItem::display(int x, int y) { int width = 0; if (_currentSprite) { - Common::Rect rc; + Rect32 rc; _currentSprite->getBoundingRect(&rc, 0, 0); width = rc.width(); } diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index f2162012e0..cb9a0496d1 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -397,7 +397,7 @@ ERRORCODE CAdResponseBox::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdResponseBox::display() { - Common::Rect rect = _responseArea; + Rect32 rect = _responseArea; if (_window) { CBPlatform::offsetRect(&rect, _window->_posX, _window->_posY); //_window->display(); diff --git a/engines/wintermute/Ad/AdResponseBox.h b/engines/wintermute/Ad/AdResponseBox.h index 31076c056c..86fe8ed947 100644 --- a/engines/wintermute/Ad/AdResponseBox.h +++ b/engines/wintermute/Ad/AdResponseBox.h @@ -74,7 +74,7 @@ public: CUIWindow *_window; CUIWindow *_shieldWindow; bool _horizontal; - Common::Rect _responseArea; + Rect32 _responseArea; int _verticalAlign; TTextAlign _align; ERRORCODE loadFile(const char *filename); diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index f674e92274..41b413cc14 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -818,7 +818,7 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_VIEWPORT: { - Common::Rect rc; + Rect32 rc; parser.scanStr((char *)params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); if (!_viewport) _viewport = new CBViewport(Game); if (_viewport) _viewport->setRect(rc.left, rc.top, rc.right, rc.bottom, true); @@ -1988,7 +1988,7 @@ ERRORCODE CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { // viewport if (_viewport) { - Common::Rect *rc = _viewport->getRect(); + Rect32 *rc = _viewport->getRect(); buffer->putTextIndent(indent + 2, "VIEWPORT { %d, %d, %d, %d }\n", rc->left, rc->top, rc->right, rc->bottom); } diff --git a/engines/wintermute/Ad/AdSentence.h b/engines/wintermute/Ad/AdSentence.h index 8ec0ca55e4..86a3c57c99 100644 --- a/engines/wintermute/Ad/AdSentence.h +++ b/engines/wintermute/Ad/AdSentence.h @@ -32,6 +32,7 @@ #include "engines/wintermute/Base/BBase.h" #include "engines/wintermute/persistent.h" +#include "engines/wintermute/Math/Rect32.h" #include "engines/wintermute/dctypes.h" // Added by ClassView #include "common/rect.h" @@ -56,7 +57,7 @@ public: TTextAlign _align; ERRORCODE display(); int _width; - Common::Point _pos; + Point32 _pos; CBFont *_font; char *getNextStance(); char *getCurrentStance(); diff --git a/engines/wintermute/Base/BActiveRect.cpp b/engines/wintermute/Base/BActiveRect.cpp index 5e1af264d9..be9c543469 100644 --- a/engines/wintermute/Base/BActiveRect.cpp +++ b/engines/wintermute/Base/BActiveRect.cpp @@ -86,7 +86,7 @@ CBActiveRect::~CBActiveRect() { ////////////////////////////////////////////////////////////////////////// void CBActiveRect::clipRect() { - Common::Rect rc; + Rect32 rc; bool customViewport; Game->getCurrentViewportRect(&rc, &customViewport); CBRenderer *Rend = Game->_renderer; diff --git a/engines/wintermute/Base/BActiveRect.h b/engines/wintermute/Base/BActiveRect.h index cbb617342c..abb00c301f 100644 --- a/engines/wintermute/Base/BActiveRect.h +++ b/engines/wintermute/Base/BActiveRect.h @@ -29,6 +29,7 @@ #ifndef WINTERMUTE_BACTIVERECT_H #define WINTERMUTE_BACTIVERECT_H +#include "engines/wintermute/Math/Rect32.h" #include "engines/wintermute/Base/BBase.h" namespace WinterMute { @@ -46,7 +47,7 @@ public: CBRegion *_region; int _offsetX; int _offsetY; - Common::Rect _rect; + Rect32 _rect; CBActiveRect(CBGame *inGameOwner = NULL); CBActiveRect(CBGame *inGameOwner, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX = 100, float zoomY = 100, bool precise = true); CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY); diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index 0af81f7ed4..b913eea3ee 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -221,7 +221,7 @@ void CBFontBitmap::drawChar(byte c, int x, int y) { row = c / _numColumns; col = c % _numColumns; - Common::Rect rect; + Rect32 rect; /* l t r b */ int tileWidth; if (_wholeCell) tileWidth = _tileWidth; diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 50cb8984d1..10d552d4e2 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -217,7 +217,7 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i // and paint it if (surface) { - Common::Rect rc; + Rect32 rc; CBPlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); for (int i = 0; i < _layers.getSize(); i++) { uint32 color = _layers[i]->_color; diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 7680671434..a0d7d5a1e0 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -159,7 +159,7 @@ ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { char *params; int cmd; CBParser parser(Game); - Common::Rect rect; + Rect32 rect; int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; int hotspotX = 0, hotspotY = 0; @@ -325,11 +325,11 @@ ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { ////////////////////////////////////////////////////////////////////////// -bool CBFrame::getBoundingRect(Common::Rect *rect, int x, int y, float scaleX, float scaleY) { +bool CBFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { if (!rect) return false; CBPlatform::setRectEmpty(rect); - Common::Rect subRect; + Rect32 subRect; for (int i = 0; i < _subframes.getSize(); i++) { _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); diff --git a/engines/wintermute/Base/BFrame.h b/engines/wintermute/Base/BFrame.h index 4c43db142d..715a97ea69 100644 --- a/engines/wintermute/Base/BFrame.h +++ b/engines/wintermute/Base/BFrame.h @@ -46,7 +46,7 @@ public: DECLARE_PERSISTENT(CBFrame, CBScriptable) CBSound *_sound; bool _editorExpanded; - bool getBoundingRect(Common::Rect *rect, int x, int y, float scaleX = 100, float scaleY = 100); + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); int _moveY; int _moveX; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 7ad692ad7f..bf1bc5c34b 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -1360,7 +1360,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi x = MIN(x, _renderer->_width); y = MAX(y, 0); y = MIN(y, _renderer->_height); - Common::Point p; + Point32 p; p.x = x + _renderer->_drawOffsetX; p.y = y + _renderer->_drawOffsetY; @@ -3963,7 +3963,7 @@ ERRORCODE CBGame::popViewport() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::getCurrentViewportRect(Common::Rect *rect, bool *custom) { +ERRORCODE CBGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { if (rect == NULL) return STATUS_FAILED; else { if (_viewportSP >= 0) { @@ -4044,7 +4044,7 @@ ERRORCODE CBGame::displayContentSimple() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::displayIndicator() { if (_saveLoadImage) { - Common::Rect rc; + Rect32 rc; CBPlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); if (_loadInProgress) _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); else _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); @@ -4205,7 +4205,7 @@ ERRORCODE CBGame::onActivate(bool activate, bool refreshMouse) { _renderer->_active = activate; if (refreshMouse) { - Common::Point p; + Point32 p; getMousePos(&p); setActiveObject(_renderer->getObjectAt(p.x, p.y)); } @@ -4403,7 +4403,7 @@ CBDebugger *CBGame::getDebugMgr() { ////////////////////////////////////////////////////////////////////////// -void CBGame::getMousePos(Common::Point *pos) { +void CBGame::getMousePos(Point32 *pos) { CBPlatform::getCursorPos(pos); pos->x -= _renderer->_drawOffsetX; @@ -4430,7 +4430,7 @@ void CBGame::getMousePos(Common::Point *pos) { pos->x = MIN(_mouseLockRect.right, pos->x); pos->y = MIN(_mouseLockRect.bottom, pos->y); - Common::Point newPos = *pos; + Point32 newPos = *pos; newPos.x += _renderer->_drawOffsetX; newPos.y += _renderer->_drawOffsetY; @@ -4477,7 +4477,7 @@ bool CBGame::isDoubleClick(int buttonIndex) { maxMoveY = 16; #endif - Common::Point pos; + Point32 pos; CBPlatform::getCursorPos(&pos); int moveX = abs(pos.x - _lastClick[buttonIndex].PosX); diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 6650767600..dc1e476134 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -34,6 +34,7 @@ #include "engines/wintermute/Base/BObject.h" #include "engines/wintermute/persistent.h" #include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/Math/Rect32.h" #include "common/events.h" namespace WinterMute { @@ -91,8 +92,8 @@ public: virtual ERRORCODE miniUpdate(); - void getMousePos(Common::Point *Pos); - Common::Rect _mouseLockRect; + void getMousePos(Point32 *Pos); + Rect32 _mouseLockRect; bool _shuttingDown; @@ -314,7 +315,7 @@ public: uint32 _liveTimerLast; CBObject *_capturedObject; - Common::Point _mousePos; + Point32 _mousePos; bool validObject(CBObject *object); ERRORCODE unregisterObject(CBObject *object); ERRORCODE registerObject(CBObject *object); @@ -338,7 +339,7 @@ public: virtual ERRORCODE windowLoadHook(CUIWindow *win, char **buf, char **params); virtual ERRORCODE windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); ERRORCODE getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); - ERRORCODE getCurrentViewportRect(Common::Rect *rect, bool *custom = NULL); + ERRORCODE getCurrentViewportRect(Rect32 *rect, bool *custom = NULL); ERRORCODE popViewport(); ERRORCODE pushViewport(CBViewport *Viewport); ERRORCODE setActiveObject(CBObject *Obj); diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h index 3a82cbe128..15ccdbef44 100644 --- a/engines/wintermute/Base/BObject.h +++ b/engines/wintermute/Base/BObject.h @@ -103,7 +103,7 @@ public: bool _registrable; bool _zoomable; bool _shadowable; - Common::Rect _rect; + Rect32 _rect; bool _rectSet; int _iD; bool _movable; diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 412aa88312..7308a8bbb7 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -671,7 +671,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, byte *val) { ////////////////////////////////////////////////////////////////////////// // RECT -ERRORCODE CBPersistMgr::transfer(const char *name, Common::Rect *val) { +ERRORCODE CBPersistMgr::transfer(const char *name, Rect32 *val) { if (_saving) { _saveStream->writeSint32LE(val->left); _saveStream->writeSint32LE(val->top); @@ -694,7 +694,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, Common::Rect *val) { ////////////////////////////////////////////////////////////////////////// // POINT -ERRORCODE CBPersistMgr::transfer(const char *name, Common::Point *val) { +ERRORCODE CBPersistMgr::transfer(const char *name, Point32 *val) { if (_saving) { _saveStream->writeSint32LE(val->x); _saveStream->writeSint32LE(val->y); diff --git a/engines/wintermute/Base/BPersistMgr.h b/engines/wintermute/Base/BPersistMgr.h index dc4c2173de..d2aca60cf9 100644 --- a/engines/wintermute/Base/BPersistMgr.h +++ b/engines/wintermute/Base/BPersistMgr.h @@ -31,6 +31,7 @@ #include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/Math/Rect32.h" #include "engines/savestate.h" #include "common/stream.h" #include "common/str.h" @@ -85,8 +86,8 @@ public: ERRORCODE transfer(const char *name, double *val); ERRORCODE transfer(const char *name, bool *val); ERRORCODE transfer(const char *name, byte *val); - ERRORCODE transfer(const char *name, Common::Rect *val); - ERRORCODE transfer(const char *name, Common::Point *val); + ERRORCODE transfer(const char *name, Rect32 *val); + ERRORCODE transfer(const char *name, Point32 *val); ERRORCODE transfer(const char *name, const char **val); ERRORCODE transfer(const char *name, char **val); ERRORCODE transfer(const char *name, Common::String *val); diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index 63e862a569..65ba2c8825 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -79,11 +79,11 @@ bool CBRegion::createRegion() { bool CBRegion::pointInRegion(int x, int y) { if (_points.getSize() < 3) return false; - Common::Point pt; + Point32 pt; pt.x = x; pt.y = y; - Common::Rect rect; + Rect32 rect; rect.left = x - 1; rect.right = x + 2; rect.top = y - 1; @@ -465,7 +465,7 @@ bool CBRegion::ptInPolygon(int x, int y) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRegion::getBoundingRect(Common::Rect *rect) { +ERRORCODE CBRegion::getBoundingRect(Rect32 *rect) { if (_points.getSize() == 0) CBPlatform::setRectEmpty(rect); else { int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; diff --git a/engines/wintermute/Base/BRegion.h b/engines/wintermute/Base/BRegion.h index 4aa491d7c9..6c79abc8f3 100644 --- a/engines/wintermute/Base/BRegion.h +++ b/engines/wintermute/Base/BRegion.h @@ -41,7 +41,7 @@ public: int _lastMimicY; void cleanup(); ERRORCODE mimic(CBRegion *region, float scale = 100.0f, int x = 0, int y = 0); - ERRORCODE getBoundingRect(Common::Rect *rect); + ERRORCODE getBoundingRect(Rect32 *rect); bool ptInPolygon(int x, int y); DECLARE_PERSISTENT(CBRegion, CBObject) bool _active; @@ -52,7 +52,7 @@ public: bool createRegion(); ERRORCODE loadFile(const char *filename); ERRORCODE loadBuffer(byte *buffer, bool complete = true); - Common::Rect _rect; + Rect32 _rect; CBArray _points; virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride = NULL); diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 26ae8c5787..c2319d1b7a 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -302,7 +302,7 @@ ERRORCODE CBRenderSDL::fadeToColor(uint32 Color, Common::Rect *rect) { fillRect.setWidth(rect->width()); fillRect.setHeight(rect->height()); } else { - Common::Rect rc; + Rect32 rc; Game->getCurrentViewportRect(&rc); fillRect.left = (int16)rc.left; fillRect.top = (int16)rc.top; @@ -505,7 +505,7 @@ ERRORCODE CBRenderSDL::drawLine(int x1, int y1, int x2, int y2, uint32 color) { //SDL_SetRenderDrawColor(_renderer, r, g, b, a); //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); - Common::Point point1, point2; + Point32 point1, point2; point1.x = x1; point1.y = y1; pointToScreen(&point1); @@ -609,7 +609,7 @@ void CBRenderSDL::modTargetRect(Common::Rect *rect) { } ////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::pointFromScreen(Common::Point *point) { +void CBRenderSDL::pointFromScreen(Point32 *point) { #if 0 SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); @@ -621,7 +621,7 @@ void CBRenderSDL::pointFromScreen(Common::Point *point) { ////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::pointToScreen(Common::Point *point) { +void CBRenderSDL::pointToScreen(Point32 *point) { #if 0 SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index aa5b390ede..1e7acf51f3 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -86,8 +86,8 @@ public: ERRORCODE setViewport(int left, int top, int right, int bottom); void modTargetRect(Common::Rect *rect); - void pointFromScreen(Common::Point *point); - void pointToScreen(Common::Point *point); + void pointFromScreen(Point32 *point); + void pointToScreen(Point32 *point); void dumpData(const char *filename); diff --git a/engines/wintermute/Base/BRenderer.cpp b/engines/wintermute/Base/BRenderer.cpp index b593161c41..d3d313faee 100644 --- a/engines/wintermute/Base/BRenderer.cpp +++ b/engines/wintermute/Base/BRenderer.cpp @@ -68,7 +68,7 @@ void CBRenderer::initLoop() { ////////////////////////////////////////////////////////////////////// CBObject *CBRenderer::getObjectAt(int x, int y) { - Common::Point point; + Point32 point; point.x = x; point.y = y; @@ -203,7 +203,7 @@ ERRORCODE CBRenderer::setScreenViewport() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderer::setViewport(Common::Rect *rect) { +ERRORCODE CBRenderer::setViewport(Rect32 *rect) { return setViewport(rect->left + _drawOffsetX, rect->top + _drawOffsetY, rect->right + _drawOffsetX, @@ -221,7 +221,7 @@ CBImage *CBRenderer::takeScreenshot() { ERRORCODE CBRenderer::clipCursor() { /* if (!_windowed) { - Common::Rect rc; + Rect32 rc; GetWindowRect(_window, &rc); // if "maintain aspect ratio" is in effect, lock mouse to visible area @@ -245,7 +245,7 @@ ERRORCODE CBRenderer::unclipCursor() { } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::pointInViewport(Common::Point *p) { +bool CBRenderer::pointInViewport(Point32 *p) { if (p->x < _drawOffsetX) return false; if (p->y < _drawOffsetY) return false; if (p->x > _drawOffsetX + _width) return false; diff --git a/engines/wintermute/Base/BRenderer.h b/engines/wintermute/Base/BRenderer.h index 43a2e14ea2..e7a9518c50 100644 --- a/engines/wintermute/Base/BRenderer.h +++ b/engines/wintermute/Base/BRenderer.h @@ -50,7 +50,7 @@ public: virtual void dumpData(const char *filename) {}; virtual CBImage *takeScreenshot(); virtual ERRORCODE setViewport(int left, int top, int right, int bottom); - virtual ERRORCODE setViewport(Common::Rect *Rect); + virtual ERRORCODE setViewport(Rect32 *Rect); virtual ERRORCODE setScreenViewport(); virtual ERRORCODE fade(uint16 Alpha); virtual ERRORCODE fadeToColor(uint32 Color, Common::Rect *rect = NULL); @@ -103,17 +103,17 @@ public: virtual ERRORCODE endSpriteBatch() { return STATUS_OK; }; - bool pointInViewport(Common::Point *P); + bool pointInViewport(Point32 *P); uint32 _forceAlphaColor; uint32 _window; uint32 _clipperWindow; bool _active; bool _ready; bool _windowed; - Common::Rect _windowRect; - Common::Rect _viewportRect; - Common::Rect _screenRect; - Common::Rect _monitorRect; + Rect32 _windowRect; + Rect32 _viewportRect; + Rect32 _screenRect; + Rect32 _monitorRect; int _bPP; int _height; int _width; diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 6fd5152d70..f33b5764c6 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -413,13 +413,13 @@ CBSurface *CBSprite::getSurface() { } ////////////////////////////////////////////////////////////////////////// -bool CBSprite::getBoundingRect(Common::Rect *rect, int x, int y, float scaleX, float scaleY) { +bool CBSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { if (!rect) return false; CBPlatform::setRectEmpty(rect); for (int i = 0; i < _frames.getSize(); i++) { - Common::Rect frame; - Common::Rect temp; + Rect32 frame; + Rect32 temp; CBPlatform::copyRect(&temp, rect); _frames[i]->getBoundingRect(&frame, x, y, scaleX, scaleY); CBPlatform::unionRect(rect, &temp, &frame); diff --git a/engines/wintermute/Base/BSprite.h b/engines/wintermute/Base/BSprite.h index 2b705b689a..bf40bbc6c6 100644 --- a/engines/wintermute/Base/BSprite.h +++ b/engines/wintermute/Base/BSprite.h @@ -53,7 +53,7 @@ public: DECLARE_PERSISTENT(CBSprite, CBScriptHolder) bool _editorAllFrames; - bool getBoundingRect(Common::Rect *rect, int x, int y, float scaleX = 100, float scaleY = 100); + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); int _moveY; int _moveX; ERRORCODE display(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); @@ -72,7 +72,7 @@ public: ERRORCODE draw(int x, int y, CBObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); bool _looping; int _currentFrame; - ERRORCODE addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Common::Rect *rect = NULL); + ERRORCODE addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = NULL); CBSprite(CBGame *inGame, CBObject *owner = NULL); virtual ~CBSprite(); CBArray _frames; diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index 33c6c32f8f..aa8ce926dc 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -110,7 +110,7 @@ ERRORCODE CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { char *params; int cmd; CBParser parser(Game); - Common::Rect rect; + Rect32 rect; int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; bool custoTrans = false; @@ -233,7 +233,7 @@ ERRORCODE CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, f ////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::getBoundingRect(Common::Rect *rect, int x, int y, float scaleX, float scaleY) { +bool CBSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { if (!rect) return false; float ratioX = scaleX / 100.0f; @@ -259,7 +259,7 @@ ERRORCODE CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) if (_transparent != 0xFFFF00FF) buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", RGBCOLGetR(_transparent), RGBCOLGetG(_transparent), RGBCOLGetB(_transparent)); - Common::Rect rect; + Rect32 rect; CBPlatform::setRectEmpty(&rect); if (_surface) CBPlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); if (!CBPlatform::equalRect(&rect, &_rect)) diff --git a/engines/wintermute/Base/BSubFrame.h b/engines/wintermute/Base/BSubFrame.h index a13a5fa196..46ee948e64 100644 --- a/engines/wintermute/Base/BSubFrame.h +++ b/engines/wintermute/Base/BSubFrame.h @@ -53,12 +53,12 @@ public: virtual ~CBSubFrame(); ERRORCODE loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); ERRORCODE draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - bool getBoundingRect(Common::Rect *rect, int x, int y, float scaleX = 100, float scaleY = 100); + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); int _hotspotX; int _hotspotY; uint32 _alpha; - Common::Rect _rect; + Rect32 _rect; bool _cKDefault; byte _cKRed; diff --git a/engines/wintermute/Base/BSurface.cpp b/engines/wintermute/Base/BSurface.cpp index f67808a47f..0d96a73d41 100644 --- a/engines/wintermute/Base/BSurface.cpp +++ b/engines/wintermute/Base/BSurface.cpp @@ -75,12 +75,12 @@ bool CBSurface::isTransparentAt(int x, int y) { } ////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurface::displayHalfTrans(int x, int y, Common::Rect rect) { +ERRORCODE CBSurface::displayHalfTrans(int x, int y, Rect32 rect) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurface::displayTransform(int x, int y, int hotX, int hotY, Common::Rect rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurface::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return displayTransZoom(x, y, rect, zoomX, zoomY, alpha, blendMode, mirrorX, mirrorY); } diff --git a/engines/wintermute/Base/BSurface.h b/engines/wintermute/Base/BSurface.h index a22f1d7606..cb19a23271 100644 --- a/engines/wintermute/Base/BSurface.h +++ b/engines/wintermute/Base/BSurface.h @@ -30,6 +30,7 @@ #define WINTERMUTE_BSURFACE_H #include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/Math/Rect32.h" #include "graphics/surface.h" namespace WinterMute { @@ -52,14 +53,14 @@ public: CBSurface(CBGame *inGame); virtual ~CBSurface(); - virtual ERRORCODE displayHalfTrans(int x, int y, Common::Rect rect); + virtual ERRORCODE displayHalfTrans(int x, int y, Rect32 rect); virtual bool isTransparentAt(int x, int y); - virtual ERRORCODE displayTransZoom(int x, int y, Common::Rect rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual ERRORCODE displayTrans(int x, int y, Common::Rect rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual ERRORCODE displayTransOffset(int x, int y, Common::Rect rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; - virtual ERRORCODE display(int x, int y, Common::Rect rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool MirrorY = false) = 0; - virtual ERRORCODE displayZoom(int x, int y, Common::Rect rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual ERRORCODE displayTransform(int x, int y, int hotX, int hotY, Common::Rect rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual ERRORCODE displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual ERRORCODE displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual ERRORCODE displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; + virtual ERRORCODE display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool MirrorY = false) = 0; + virtual ERRORCODE displayZoom(int x, int y, Rect32 rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual ERRORCODE displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual ERRORCODE restore(); virtual ERRORCODE create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; virtual ERRORCODE create(int Width, int Height); diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 07e552138c..bbdfeca3d7 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -403,40 +403,40 @@ ERRORCODE CBSurfaceSDL::endPixelOp() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::display(int x, int y, Common::Rect rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, 100, 100, 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayTrans(int x, int y, Common::Rect rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayTransOffset(int x, int y, Common::Rect rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { +ERRORCODE CBSurfaceSDL::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY, offsetX, offsetY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayTransZoom(int x, int y, Common::Rect rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayZoom(int x, int y, Common::Rect rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !Transparent, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayTransform(int x, int y, int hotX, int hotY, Common::Rect rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::drawSprite(int x, int y, Common::Rect *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { +ERRORCODE CBSurfaceSDL::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { CBRenderSDL *renderer = static_cast(Game->_renderer); if (!_loaded) { diff --git a/engines/wintermute/Base/BSurfaceSDL.h b/engines/wintermute/Base/BSurfaceSDL.h index 0bfda92866..289f75eaf3 100644 --- a/engines/wintermute/Base/BSurfaceSDL.h +++ b/engines/wintermute/Base/BSurfaceSDL.h @@ -53,12 +53,12 @@ public: ERRORCODE endPixelOp(); - ERRORCODE displayTransZoom(int x, int y, Common::Rect rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - ERRORCODE displayTrans(int x, int y, Common::Rect rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - ERRORCODE displayTransOffset(int x, int y, Common::Rect rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); - ERRORCODE display(int x, int y, Common::Rect rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - ERRORCODE displayZoom(int x, int y, Common::Rect rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - ERRORCODE displayTransform(int x, int y, int hotX, int hotY, Common::Rect Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + ERRORCODE displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + ERRORCODE displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + ERRORCODE displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); + ERRORCODE display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + ERRORCODE displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + ERRORCODE displayTransform(int x, int y, int hotX, int hotY, Rect32 Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); virtual ERRORCODE putSurface(const Graphics::Surface &surface, bool hasAlpha = false); /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); @@ -86,7 +86,7 @@ private: Graphics::Surface *_surface; bool _loaded; void finishLoad(); - ERRORCODE drawSprite(int x, int y, Common::Rect *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); + ERRORCODE drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); void genAlphaMask(Graphics::Surface *surface); uint32 getPixel(Graphics::Surface *surface, int x, int y); diff --git a/engines/wintermute/Base/BViewport.cpp b/engines/wintermute/Base/BViewport.cpp index ad89bc0697..f1f28bc78b 100644 --- a/engines/wintermute/Base/BViewport.cpp +++ b/engines/wintermute/Base/BViewport.cpp @@ -79,7 +79,7 @@ ERRORCODE CBViewport::setRect(int left, int top, int right, int bottom, bool noC ////////////////////////////////////////////////////////////////////////// -Common::Rect *CBViewport::getRect() { +Rect32 *CBViewport::getRect() { return &_rect; } diff --git a/engines/wintermute/Base/BViewport.h b/engines/wintermute/Base/BViewport.h index 0ace6791bc..83e89a6014 100644 --- a/engines/wintermute/Base/BViewport.h +++ b/engines/wintermute/Base/BViewport.h @@ -38,7 +38,7 @@ class CBViewport : public CBBase { public: int getHeight(); int getWidth(); - Common::Rect *getRect(); + Rect32 *getRect(); ERRORCODE setRect(int left, int top, int right, int bottom, bool noCheck = false); DECLARE_PERSISTENT(CBViewport, CBBase) int _offsetY; @@ -47,7 +47,7 @@ public: CBViewport(CBGame *inGame = NULL); virtual ~CBViewport(); private: - Common::Rect _rect; + Rect32 _rect; }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/PartEmitter.h b/engines/wintermute/Base/PartEmitter.h index 2f72d96103..e2de466e42 100644 --- a/engines/wintermute/Base/PartEmitter.h +++ b/engines/wintermute/Base/PartEmitter.h @@ -82,7 +82,7 @@ public: int _maxBatches; int _batchesGenerated; - Common::Rect _border; + Rect32 _border; int _borderThicknessLeft; int _borderThicknessRight; int _borderThicknessTop; diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index 3eaa546d29..f3a8de9ece 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -124,7 +124,7 @@ ERRORCODE CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint3 // particle hit the border if (!_isDead && !CBPlatform::isRectEmpty(&_border)) { - Common::Point p; + Point32 p; p.x = (int32)_pos.x; p.y = (int32)_pos.y; if (!CBPlatform::ptInRect(&_border, p)) diff --git a/engines/wintermute/Base/PartParticle.h b/engines/wintermute/Base/PartParticle.h index 229bc11935..aed559d337 100644 --- a/engines/wintermute/Base/PartParticle.h +++ b/engines/wintermute/Base/PartParticle.h @@ -31,6 +31,7 @@ #include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/Math/Rect32.h" #include "engines/wintermute/math/Vector2.h" namespace WinterMute { @@ -57,7 +58,7 @@ public: int _alpha1; int _alpha2; - Common::Rect _border; + Rect32 _border; Vector2 _pos; float _posZ; Vector2 _velocity; diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 175cb1d68a..9edd8f2152 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -181,7 +181,7 @@ uint32 CBPlatform::getTime() { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::getCursorPos(Common::Point *lpPoint) { +bool CBPlatform::getCursorPos(Point32 *lpPoint) { CBRenderSDL *renderer = static_cast(Game->_renderer); Common::Point p = g_system->getEventManager()->getMousePos(); @@ -197,7 +197,7 @@ bool CBPlatform::getCursorPos(Common::Point *lpPoint) { bool CBPlatform::setCursorPos(int X, int Y) { CBRenderSDL *renderer = static_cast(Game->_renderer); - Common::Point p; + Point32 p; p.x = X; p.y = Y; renderer->pointToScreen(&p); @@ -245,23 +245,23 @@ bool CBPlatform::setForegroundWindow() { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::setRectEmpty(Common::Rect *lprc) { +bool CBPlatform::setRectEmpty(Rect32 *lprc) { lprc->left = lprc->right = lprc->top = lprc->bottom = 0; return true; } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::isRectEmpty(const Common::Rect *lprc) { +bool CBPlatform::isRectEmpty(const Rect32 *lprc) { return (lprc->left >= lprc->right) || (lprc->top >= lprc->bottom); } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::ptInRect(Common::Rect *lprc, Common::Point p) { +bool CBPlatform::ptInRect(Rect32 *lprc, Point32 p) { return (p.x >= lprc->left) && (p.x < lprc->right) && (p.y >= lprc->top) && (p.y < lprc->bottom); } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::setRect(Common::Rect *lprc, int left, int top, int right, int bottom) { +bool CBPlatform::setRect(Rect32 *lprc, int left, int top, int right, int bottom) { lprc->left = left; lprc->top = top; lprc->right = right; @@ -271,7 +271,7 @@ bool CBPlatform::setRect(Common::Rect *lprc, int left, int top, int right, int b } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::intersectRect(Common::Rect *lprcDst, const Common::Rect *lprcSrc1, const Common::Rect *lprcSrc2) { +bool CBPlatform::intersectRect(Rect32 *lprcDst, const Rect32 *lprcSrc1, const Rect32 *lprcSrc2) { if (isRectEmpty(lprcSrc1) || isRectEmpty(lprcSrc2) || lprcSrc1->left >= lprcSrc2->right || lprcSrc2->left >= lprcSrc1->right || lprcSrc1->top >= lprcSrc2->bottom || lprcSrc2->top >= lprcSrc1->bottom) { @@ -287,7 +287,7 @@ bool CBPlatform::intersectRect(Common::Rect *lprcDst, const Common::Rect *lprcSr } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::unionRect(Common::Rect *lprcDst, Common::Rect *lprcSrc1, Common::Rect *lprcSrc2) { +bool CBPlatform::unionRect(Rect32 *lprcDst, Rect32 *lprcSrc1, Rect32 *lprcSrc2) { if (isRectEmpty(lprcSrc1)) { if (isRectEmpty(lprcSrc2)) { setRectEmpty(lprcDst); @@ -310,7 +310,7 @@ bool CBPlatform::unionRect(Common::Rect *lprcDst, Common::Rect *lprcSrc1, Common } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::copyRect(Common::Rect *lprcDst, Common::Rect *lprcSrc) { +bool CBPlatform::copyRect(Rect32 *lprcDst, Rect32 *lprcSrc) { if (lprcDst == NULL || lprcSrc == NULL) return false; *lprcDst = *lprcSrc; @@ -318,7 +318,7 @@ bool CBPlatform::copyRect(Common::Rect *lprcDst, Common::Rect *lprcSrc) { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::offsetRect(Common::Rect *lprc, int dx, int dy) { +bool CBPlatform::offsetRect(Rect32 *lprc, int dx, int dy) { if (lprc == NULL) return false; lprc->left += dx; @@ -330,7 +330,7 @@ bool CBPlatform::offsetRect(Common::Rect *lprc, int dx, int dy) { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::equalRect(Common::Rect *rect1, Common::Rect *rect2) { +bool CBPlatform::equalRect(Rect32 *rect1, Rect32 *rect2) { return rect1->left == rect2->left && rect1->right == rect2->right && rect1->top == rect2->top && rect1->bottom == rect2->bottom; } diff --git a/engines/wintermute/PlatformSDL.h b/engines/wintermute/PlatformSDL.h index fc2e60a7a4..547f6b81b1 100644 --- a/engines/wintermute/PlatformSDL.h +++ b/engines/wintermute/PlatformSDL.h @@ -30,7 +30,7 @@ #define WINTERMUTE_PLATFORMSDL_H #include "engines/wintermute/dctypes.h" - +#include "engines/wintermute/Math/Rect32.h" #include "engines/wintermute/wintypes.h" #include "common/events.h" @@ -50,7 +50,7 @@ public: // Win32 API bindings static void outputDebugString(const char *lpOutputString); static uint32 getTime(); - static bool getCursorPos(Common::Point *lpPoint); + static bool getCursorPos(Point32 *lpPoint); static bool setCursorPos(int X, int Y); static bool showWindow(int nCmdShow); static bool deleteFile(const char *lpFileName); @@ -59,15 +59,15 @@ public: static bool releaseCapture(); static bool setForegroundWindow(); - static bool setRectEmpty(Common::Rect *lprc); - static bool isRectEmpty(const Common::Rect *lprc); - static bool ptInRect(Common::Rect *lprc, Common::Point p); - static bool setRect(Common::Rect *lprc, int left, int top, int right, int bottom); - static bool intersectRect(Common::Rect *lprcDst, const Common::Rect *lprcSrc1, const Common::Rect *lprcSrc2); - static bool unionRect(Common::Rect *lprcDst, Common::Rect *lprcSrc1, Common::Rect *lprcSrc2); - static bool copyRect(Common::Rect *lprcDst, Common::Rect *lprcSrc); - static bool offsetRect(Common::Rect *lprc, int dx, int dy); - static bool equalRect(Common::Rect *rect1, Common::Rect *rect2); + static bool setRectEmpty(Rect32 *lprc); + static bool isRectEmpty(const Rect32 *lprc); + static bool ptInRect(Rect32 *lprc, Point32 p); + static bool setRect(Rect32 *lprc, int left, int top, int right, int bottom); + static bool intersectRect(Rect32 *lprcDst, const Rect32 *lprcSrc1, const Rect32 *lprcSrc2); + static bool unionRect(Rect32 *lprcDst, Rect32 *lprcSrc1, Rect32 *lprcSrc2); + static bool copyRect(Rect32 *lprcDst, Rect32 *lprcSrc); + static bool offsetRect(Rect32 *lprc, int dx, int dy); + static bool equalRect(Rect32 *rect1, Rect32 *rect2); // string functions diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 43e1262ce3..65a643b9d3 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -539,7 +539,7 @@ ERRORCODE CUIButton::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// void CUIButton::correctSize() { - Common::Rect rect; + Rect32 rect; CBSprite *img = NULL; if (_image) img = _image; @@ -623,7 +623,7 @@ ERRORCODE CUIButton::display(int offsetX, int offsetY) { int imageY = offsetY + _posY; if (image && _centerImage) { - Common::Rect rc; + Rect32 rc; image->getBoundingRect(&rc, 0, 0); imageX += (_width - (rc.right - rc.left)) / 2; imageY += (_height - (rc.bottom - rc.top)) / 2; diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 7af29a9eac..668d4eb234 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -113,7 +113,7 @@ void CUIObject::setListener(CBScriptHolder *object, CBScriptHolder *listenerObje ////////////////////////////////////////////////////////////////////////// void CUIObject::correctSize() { - Common::Rect rect; + Rect32 rect; if (_width <= 0) { if (_image) { diff --git a/engines/wintermute/UI/UITiledImage.h b/engines/wintermute/UI/UITiledImage.h index 297a868ed0..35083c15a8 100644 --- a/engines/wintermute/UI/UITiledImage.h +++ b/engines/wintermute/UI/UITiledImage.h @@ -47,15 +47,15 @@ public: CUITiledImage(CBGame *inGame = NULL); virtual ~CUITiledImage(); CBSubFrame *_image; - Common::Rect _upLeft; - Common::Rect _upMiddle; - Common::Rect _upRight; - Common::Rect _middleLeft; - Common::Rect _middleMiddle; - Common::Rect _middleRight; - Common::Rect _downLeft; - Common::Rect _downMiddle; - Common::Rect _downRight; + Rect32 _upLeft; + Rect32 _upMiddle; + Rect32 _upRight; + Rect32 _middleLeft; + Rect32 _middleMiddle; + Rect32 _middleRight; + Rect32 _downLeft; + Rect32 _downMiddle; + Rect32 _downRight; }; } // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index cc8d966bc2..de17966ac5 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -1135,7 +1135,7 @@ ERRORCODE CUIWindow::handleMouse(TMouseEvent event, TMouseButton button) { if (!CBPlatform::isRectEmpty(&_dragRect)) { // start drag if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { - Common::Rect dragRect = _dragRect; + Rect32 dragRect = _dragRect; int offsetX, offsetY; getTotalOffset(&offsetX, &offsetY); CBPlatform::offsetRect(&dragRect, _posX + offsetX, _posY + offsetY); diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index 79e1ce09be..e597debaaa 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -59,14 +59,14 @@ public: TWindowMode _mode; ERRORCODE moveFocus(bool forward = true); virtual ERRORCODE handleMouse(TMouseEvent Event, TMouseButton Button); - Common::Point _dragFrom; + Point32 _dragFrom; bool _dragging; DECLARE_PERSISTENT(CUIWindow, CUIObject) bool _transparent; ERRORCODE showWidget(const char *name, bool visible = true); ERRORCODE enableWidget(const char *name, bool enable = true); - Common::Rect _titleRect; - Common::Rect _dragRect; + Rect32 _titleRect; + Rect32 _dragRect; virtual ERRORCODE display(int offsetX = 0, int offsetY = 0); CUIWindow(CBGame *inGame); virtual ~CUIWindow(); diff --git a/engines/wintermute/math/Rect32.h b/engines/wintermute/math/Rect32.h new file mode 100644 index 0000000000..e0babcbbb9 --- /dev/null +++ b/engines/wintermute/math/Rect32.h @@ -0,0 +1,86 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef WINTERMUTE_RECT32_H +#define WINTERMUTE_RECT32_H + +#include "common/system.h" + +namespace WinterMute { + +struct Point32 { + int32 x; + int32 y; +}; + +struct Rect32 { + int32 top, left; ///< The point at the top left of the rectangle (part of the rect). + int32 bottom, right; ///< The point at the bottom right of the rectangle (not part of the rect). + + Rect32() : top(0), left(0), bottom(0), right(0) {} + Rect32(int16 w, int16 h) : top(0), left(0), bottom(h), right(w) {} + Rect32(int16 x1, int16 y1, int16 x2, int16 y2) : top(y1), left(x1), bottom(y2), right(x2) { + assert(isValidRect()); + } + bool operator==(const Rect32 &rhs) const { return equals(rhs); } + bool operator!=(const Rect32 &rhs) const { return !equals(rhs); } + + int16 width() const { return right - left; } + int16 height() const { return bottom - top; } + + void setWidth(int16 aWidth) { + right = left + aWidth; + } + + void setHeight(int16 aHeight) { + bottom = top + aHeight; + } + + void setEmpty() { + left = right = top = bottom = 0; + } + + void offsetRect(int dx, int dy) { + left += dx; + top += dy; + right += dx; + bottom += dy; + } + /** + * Check if the given rect is equal to this one. + * + * @param r The rectangle to check + * + * @return true if the given rect is equal, false otherwise + */ + bool equals(const Rect32 &r) const { + return (left == r.left) && (right == r.right) && (top == r.top) && (bottom == r.bottom); + } + + bool isValidRect() const { + return (left <= right && top <= bottom); + } +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_RECT32_H diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index ae64cd0686..9efc7b8935 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -45,7 +45,7 @@ static inline unsigned Sqr(int x) { ////////////////////////////////////////////////////////////////////////////////// -void CBUtils::clip(int *destX, int *destY, Common::Rect *srcRect, Common::Rect *destRect) { +void CBUtils::clip(int *destX, int *destY, Rect32 *srcRect, Rect32 *destRect) { // If it's partly off the right side of the screen if (*destX + (srcRect->right - srcRect->left) > destRect->right) srcRect->right -= *destX + (srcRect->right - srcRect->left) - destRect->right; diff --git a/engines/wintermute/utils/utils.h b/engines/wintermute/utils/utils.h index e178d35853..d75bb8c550 100644 --- a/engines/wintermute/utils/utils.h +++ b/engines/wintermute/utils/utils.h @@ -30,6 +30,7 @@ #define WINTERMUTE_UTILS_H #include "engines/wintermute/wintypes.h" +#include "engines/wintermute/Math/Rect32.h" namespace WinterMute { @@ -37,7 +38,7 @@ class CBGame; class CBUtils { public: - static void clip(int *destX, int *destY, Common::Rect *srcRect, Common::Rect *destRect); + static void clip(int *destX, int *destY, Rect32 *srcRect, Rect32 *destRect); static void swap(int *a, int *b); static bool strBeginsI(const char *string, const char *fragment); static float normalizeAngle(float angle); diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index c57049e177..99acdc24e4 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -652,7 +652,7 @@ void CVidTheoraPlayer::writeAlpha() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CVidTheoraPlayer::display(uint32 alpha) { - Common::Rect rc; + Rect32 rc; ERRORCODE res; if (_texture && _videoFrameReady) { -- cgit v1.2.3