diff options
author | Strangerke | 2015-12-18 02:15:44 +0100 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-12-23 21:34:08 +0100 |
commit | 15889e6fd25dd0010dd2b5488cbabae46621954b (patch) | |
tree | a5b141bcbe811a66be92297358d865f1a5c22cc8 /engines | |
parent | b1fc7852253e372c931d674cd7e2c4cb56bfd5b6 (diff) | |
download | scummvm-rg350-15889e6fd25dd0010dd2b5488cbabae46621954b.tar.gz scummvm-rg350-15889e6fd25dd0010dd2b5488cbabae46621954b.tar.bz2 scummvm-rg350-15889e6fd25dd0010dd2b5488cbabae46621954b.zip |
LAB: Make processMap a bit more readable by using Rects
Diffstat (limited to 'engines')
-rw-r--r-- | engines/lab/map.cpp | 18 | ||||
-rw-r--r-- | engines/lab/utils.cpp | 4 | ||||
-rw-r--r-- | engines/lab/utils.h | 1 |
3 files changed, 12 insertions, 11 deletions
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 0d8b89a4f3..bdd9eaf75f 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -503,33 +503,29 @@ void LabEngine::processMap(uint16 curRoom) { } } } else if (msgClass == kMessageLeftClick) { - if ((curFloor == kFloorLower) && (mouseX >= _utils->mapScaleX(538)) && (mouseY >= _utils->mapScaleY(277)) - && (mouseX <= _utils->mapScaleX(633)) && (mouseY <= _utils->mapScaleY(352)) + if ((curFloor == kFloorLower) && _utils->mapRectScale(538, 277, 633, 352).contains(mouseX, mouseY) && floorVisited(kFloorSurMaze)) { curFloor = kFloorSurMaze; _graphics->fade(false, 0); drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); - } else if ((curFloor == kFloorMiddle) && (mouseX >= _utils->mapScaleX(358)) && (mouseY >= _utils->mapScaleY(71)) - && (mouseX <= _utils->mapScaleX(452)) && (mouseY <= _utils->mapScaleY(147)) - && floorVisited(kFloorCarnival)) { + } else if ((curFloor == kFloorMiddle) && _utils->mapRectScale(358, 71, 452, 147).contains(mouseX, mouseY) + && floorVisited(kFloorCarnival)) { curFloor = kFloorCarnival; _graphics->fade(false, 0); drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); - } else if ((curFloor == kFloorMiddle) && (mouseX >= _utils->mapScaleX(557)) && (mouseY >= _utils->mapScaleY(325)) - && (mouseX <= _utils->mapScaleX(653)) && (mouseY <= _utils->mapScaleY(401)) - && floorVisited(kFloorMedMaze)) { + } else if ((curFloor == kFloorMiddle) && _utils->mapRectScale(557, 325, 653, 401).contains(mouseX, mouseY) + && floorVisited(kFloorMedMaze)) { curFloor = kFloorMedMaze; _graphics->fade(false, 0); drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); - } else if ((curFloor == kFloorUpper) && (mouseX >= _utils->mapScaleX(524)) && (mouseY >= _utils->mapScaleY(97)) - && (mouseX <= _utils->mapScaleX(645)) && (mouseY <= _utils->mapScaleY(207)) - && floorVisited(kFloorHedgeMaze)) { + } else if ((curFloor == kFloorUpper) && _utils->mapRectScale(524, 97, 645, 207).contains(mouseX, mouseY) + && floorVisited(kFloorHedgeMaze)) { curFloor = kFloorHedgeMaze; _graphics->fade(false, 0); diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp index 1ddb454895..3bd3057510 100644 --- a/engines/lab/utils.cpp +++ b/engines/lab/utils.cpp @@ -74,6 +74,10 @@ uint16 Utils::mapScaleY(uint16 y) { return ((y - 35) >> 1) - (y >> 6); } +Common::Rect Utils::mapRectScale(int16 x1, int16 y1, int16 x2, int16 y2) { + return Common::Rect(mapScaleX(x1), mapScaleY(y1), mapScaleX(x2), mapScaleY(y2)); +} + /** * Scales the VGA coords to SVGA if necessary; otherwise, returns VGA coords. */ diff --git a/engines/lab/utils.h b/engines/lab/utils.h index 4bd29b906f..f9a36ba546 100644 --- a/engines/lab/utils.h +++ b/engines/lab/utils.h @@ -57,6 +57,7 @@ public: uint16 svgaCord(uint16 cord); uint16 mapScaleX(uint16 x); uint16 mapScaleY(uint16 y); + Common::Rect mapRectScale(int16 x1, int16 y1, int16 x2, int16 y2); Common::Point vgaUnscale(Common::Point pos); void unDiff(byte *newBuf, byte *oldBuf, Common::File *sourceFile, uint16 bytesPerRow, bool isVertical); void runLengthDecode(byte *dest, Common::File *sourceFile); |