LAB: Make processMap a bit more readable by using Rects

This commit is contained in:
Strangerke 2015-12-18 02:15:44 +01:00 committed by Willem Jan Palenstijn
parent b1fc785225
commit 15889e6fd2
3 changed files with 12 additions and 11 deletions

View file

@ -503,33 +503,29 @@ void LabEngine::processMap(uint16 curRoom) {
} }
} }
} else if (msgClass == kMessageLeftClick) { } else if (msgClass == kMessageLeftClick) {
if ((curFloor == kFloorLower) && (mouseX >= _utils->mapScaleX(538)) && (mouseY >= _utils->mapScaleY(277)) if ((curFloor == kFloorLower) && _utils->mapRectScale(538, 277, 633, 352).contains(mouseX, mouseY)
&& (mouseX <= _utils->mapScaleX(633)) && (mouseY <= _utils->mapScaleY(352))
&& floorVisited(kFloorSurMaze)) { && floorVisited(kFloorSurMaze)) {
curFloor = kFloorSurMaze; curFloor = kFloorSurMaze;
_graphics->fade(false, 0); _graphics->fade(false, 0);
drawMap(curRoom, curMsg, curFloor, false, false); drawMap(curRoom, curMsg, curFloor, false, false);
_graphics->fade(true, 0); _graphics->fade(true, 0);
} else if ((curFloor == kFloorMiddle) && (mouseX >= _utils->mapScaleX(358)) && (mouseY >= _utils->mapScaleY(71)) } else if ((curFloor == kFloorMiddle) && _utils->mapRectScale(358, 71, 452, 147).contains(mouseX, mouseY)
&& (mouseX <= _utils->mapScaleX(452)) && (mouseY <= _utils->mapScaleY(147)) && floorVisited(kFloorCarnival)) {
&& floorVisited(kFloorCarnival)) {
curFloor = kFloorCarnival; curFloor = kFloorCarnival;
_graphics->fade(false, 0); _graphics->fade(false, 0);
drawMap(curRoom, curMsg, curFloor, false, false); drawMap(curRoom, curMsg, curFloor, false, false);
_graphics->fade(true, 0); _graphics->fade(true, 0);
} else if ((curFloor == kFloorMiddle) && (mouseX >= _utils->mapScaleX(557)) && (mouseY >= _utils->mapScaleY(325)) } else if ((curFloor == kFloorMiddle) && _utils->mapRectScale(557, 325, 653, 401).contains(mouseX, mouseY)
&& (mouseX <= _utils->mapScaleX(653)) && (mouseY <= _utils->mapScaleY(401)) && floorVisited(kFloorMedMaze)) {
&& floorVisited(kFloorMedMaze)) {
curFloor = kFloorMedMaze; curFloor = kFloorMedMaze;
_graphics->fade(false, 0); _graphics->fade(false, 0);
drawMap(curRoom, curMsg, curFloor, false, false); drawMap(curRoom, curMsg, curFloor, false, false);
_graphics->fade(true, 0); _graphics->fade(true, 0);
} else if ((curFloor == kFloorUpper) && (mouseX >= _utils->mapScaleX(524)) && (mouseY >= _utils->mapScaleY(97)) } else if ((curFloor == kFloorUpper) && _utils->mapRectScale(524, 97, 645, 207).contains(mouseX, mouseY)
&& (mouseX <= _utils->mapScaleX(645)) && (mouseY <= _utils->mapScaleY(207)) && floorVisited(kFloorHedgeMaze)) {
&& floorVisited(kFloorHedgeMaze)) {
curFloor = kFloorHedgeMaze; curFloor = kFloorHedgeMaze;
_graphics->fade(false, 0); _graphics->fade(false, 0);

View file

@ -74,6 +74,10 @@ uint16 Utils::mapScaleY(uint16 y) {
return ((y - 35) >> 1) - (y >> 6); 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. * Scales the VGA coords to SVGA if necessary; otherwise, returns VGA coords.
*/ */

View file

@ -57,6 +57,7 @@ public:
uint16 svgaCord(uint16 cord); uint16 svgaCord(uint16 cord);
uint16 mapScaleX(uint16 x); uint16 mapScaleX(uint16 x);
uint16 mapScaleY(uint16 y); uint16 mapScaleY(uint16 y);
Common::Rect mapRectScale(int16 x1, int16 y1, int16 x2, int16 y2);
Common::Point vgaUnscale(Common::Point pos); Common::Point vgaUnscale(Common::Point pos);
void unDiff(byte *newBuf, byte *oldBuf, Common::File *sourceFile, uint16 bytesPerRow, bool isVertical); void unDiff(byte *newBuf, byte *oldBuf, Common::File *sourceFile, uint16 bytesPerRow, bool isVertical);
void runLengthDecode(byte *dest, Common::File *sourceFile); void runLengthDecode(byte *dest, Common::File *sourceFile);