aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2015-12-27 01:42:20 +0200
committerFilippos Karapetis2015-12-27 01:42:45 +0200
commit3215d14e8265f6ad901272f3dd1d3f44ec09eaf5 (patch)
tree03ba5d3a981ee97b9316793ad34a9d590409b3c7
parent428f9acdcf5eda6d852c664b81905dc7e31a3a57 (diff)
downloadscummvm-rg350-3215d14e8265f6ad901272f3dd1d3f44ec09eaf5.tar.gz
scummvm-rg350-3215d14e8265f6ad901272f3dd1d3f44ec09eaf5.tar.bz2
scummvm-rg350-3215d14e8265f6ad901272f3dd1d3f44ec09eaf5.zip
LAB: Rename TilePuzzle to SpecialLocks, to better reflect its purpose
This class handles two different special locks, the tile puzzle and the combination door
-rw-r--r--engines/lab/engine.cpp36
-rw-r--r--engines/lab/lab.cpp8
-rw-r--r--engines/lab/lab.h4
-rw-r--r--engines/lab/module.mk2
-rw-r--r--engines/lab/savegame.cpp6
-rw-r--r--engines/lab/speciallocks.cpp (renamed from engines/lab/tilepuzzle.cpp)66
-rw-r--r--engines/lab/speciallocks.h (renamed from engines/lab/tilepuzzle.h)32
7 files changed, 71 insertions, 83 deletions
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 59d5ff1070..2d45ab6ac0 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -39,18 +39,20 @@
#include "lab/music.h"
#include "lab/processroom.h"
#include "lab/resource.h"
-#include "lab/tilepuzzle.h"
+#include "lab/speciallocks.h"
#include "lab/utils.h"
namespace Lab {
-// LAB: Labyrinth specific code for the special puzzles
-#define SPECIALLOCK 100
-#define SPECIALBRICK 101
-#define SPECIALBRICKNOMOUSE 102
-
#define CRUMBSWIDTH 24
#define CRUMBSHEIGHT 24
+
+enum SpecialLock {
+ kLockCombination = 100,
+ kLockTiles = 101,
+ kLockTileSolution = 102
+};
+
enum Items {
kItemHelmet = 1,
kItemBelt = 3,
@@ -442,16 +444,14 @@ void LabEngine::mainGameLoop() {
_roomsFound->inclElement(_roomNum);
_curFileName = _nextFileName;
- if (_closeDataPtr) {
+ if (_closeDataPtr && _mainDisplay) {
switch (_closeDataPtr->_closeUpType) {
- case SPECIALLOCK:
- if (_mainDisplay)
- _tilePuzzle->showCombination(_curFileName);
+ case kLockCombination:
+ _specialLocks->showCombinationLock(_curFileName);
break;
- case SPECIALBRICK:
- case SPECIALBRICKNOMOUSE:
- if (_mainDisplay)
- _tilePuzzle->showTile(_curFileName, (_closeDataPtr->_closeUpType == SPECIALBRICKNOMOUSE));
+ case kLockTiles:
+ case kLockTileSolution:
+ _specialLocks->showTileLock(_curFileName, (_closeDataPtr->_closeUpType == kLockTileSolution));
break;
default:
_graphics->readPict(_curFileName, false);
@@ -571,10 +571,10 @@ bool LabEngine::processEvent(MessageClass tmpClass, uint16 code, uint16 qualifie
interfaceOff();
_mainDisplay = true;
- if (_closeDataPtr && _closeDataPtr->_closeUpType == SPECIALLOCK)
- _tilePuzzle->mouseCombination(curPos);
- else if (_closeDataPtr && _closeDataPtr->_closeUpType == SPECIALBRICK)
- _tilePuzzle->mouseTile(curPos);
+ if (_closeDataPtr && _closeDataPtr->_closeUpType == kLockCombination)
+ _specialLocks->combinationClick(curPos);
+ else if (_closeDataPtr && _closeDataPtr->_closeUpType == kLockTiles)
+ _specialLocks->tileClick(curPos);
else
performAction(actionMode, curPos, curInv);
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 815053e71e..be299a8236 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -44,7 +44,7 @@
#include "lab/music.h"
#include "lab/processroom.h"
#include "lab/resource.h"
-#include "lab/tilepuzzle.h"
+#include "lab/speciallocks.h"
#include "lab/utils.h"
namespace Lab {
@@ -85,7 +85,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
_graphics = nullptr;
_rooms = nullptr;
_roomsFound = nullptr;
- _tilePuzzle = nullptr;
+ _specialLocks = nullptr;
_utils = nullptr;
_console = nullptr;
_journalBackImage = nullptr;
@@ -151,7 +151,7 @@ LabEngine::~LabEngine() {
delete _music;
delete _anim;
delete _graphics;
- delete _tilePuzzle;
+ delete _specialLocks;
delete _utils;
delete _console;
delete _journalBackImage;
@@ -168,7 +168,7 @@ Common::Error LabEngine::run() {
_music = new Music(this);
_graphics = new DisplayMan(this);
_anim = new Anim(this);
- _tilePuzzle = new TilePuzzle(this);
+ _specialLocks = new SpecialLocks(this);
_utils = new Utils(this);
_console = new Console(this);
_journalBackImage = new Image(this);
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 8f20538963..fd09db0a37 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -63,7 +63,7 @@ class EventManager;
class Image;
class Music;
class Resource;
-class TilePuzzle;
+class SpecialLocks;
class Utils;
struct SaveGameHeader {
@@ -193,7 +193,7 @@ public:
Resource *_resource;
RoomData *_rooms;
TextFont *_msgFont;
- TilePuzzle *_tilePuzzle;
+ SpecialLocks *_specialLocks;
Utils *_utils;
Console *_console;
GUI::Debugger *getDebugger() { return _console; }
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index a619cba6ed..7bb86c8c1e 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -18,7 +18,7 @@ MODULE_OBJS := \
resource.o \
savegame.o \
special.o \
- tilepuzzle.o \
+ speciallocks.o \
utils.o
# This module can be built as a plugin
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index beeae8dae0..1564babfc8 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -43,7 +43,7 @@
#include "lab/labsets.h"
#include "lab/music.h"
#include "lab/processroom.h"
-#include "lab/tilepuzzle.h"
+#include "lab/speciallocks.h"
namespace Lab {
@@ -144,7 +144,7 @@ bool LabEngine::saveGame(int slot, const Common::String desc) {
for (int i = 0; i < _roomsFound->_lastElement / (8 * 2); i++)
file->writeUint16LE(_roomsFound->_array[i]);
- _tilePuzzle->save(file);
+ _specialLocks->save(file);
// Breadcrumbs
for (uint i = 0; i < MAX_CRUMBS; i++) {
@@ -181,7 +181,7 @@ bool LabEngine::loadGame(int slot) {
for (int i = 0; i < _roomsFound->_lastElement / (8 * 2); i++)
_roomsFound->_array[i] = file->readUint16LE();
- _tilePuzzle->load(file);
+ _specialLocks->load(file);
// Breadcrumbs
for (int i = 0; i < MAX_CRUMBS; i++) {
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/speciallocks.cpp
index fe37ee4d9e..fe70b0f111 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/speciallocks.cpp
@@ -38,7 +38,7 @@
#include "lab/image.h"
#include "lab/labsets.h"
#include "lab/resource.h"
-#include "lab/tilepuzzle.h"
+#include "lab/speciallocks.h"
#include "lab/utils.h"
namespace Lab {
@@ -69,7 +69,7 @@ const uint16 SOLUTION[4][4] = {
const int COMBINATION_X[6] = { 45, 83, 129, 166, 211, 248 };
-TilePuzzle::TilePuzzle(LabEngine *vm) : _vm(vm) {
+SpecialLocks::SpecialLocks(LabEngine *vm) : _vm(vm) {
for (int i = 0; i < 16; i++)
_tiles[i] = nullptr;
@@ -85,7 +85,7 @@ TilePuzzle::TilePuzzle(LabEngine *vm) : _vm(vm) {
_numberImages[i] = nullptr;
}
-TilePuzzle::~TilePuzzle() {
+SpecialLocks::~SpecialLocks() {
for (int i = 0; i < 16; i++)
delete _tiles[i];
@@ -95,7 +95,7 @@ TilePuzzle::~TilePuzzle() {
}
}
-void TilePuzzle::mouseTile(Common::Point pos) {
+void SpecialLocks::tileClick(Common::Point pos) {
Common::Point realPos = _vm->_utils->vgaUnscale(pos);
if ((realPos.x < 101) || (realPos.y < 26))
@@ -108,7 +108,7 @@ void TilePuzzle::mouseTile(Common::Point pos) {
changeTile(tileX, tileY);
}
-void TilePuzzle::changeTile(uint16 col, uint16 row) {
+void SpecialLocks::changeTile(uint16 col, uint16 row) {
int16 scrolltype = -1;
if (row > 0) {
@@ -174,7 +174,7 @@ void TilePuzzle::changeTile(uint16 col, uint16 row) {
}
}
-void TilePuzzle::mouseCombination(Common::Point pos) {
+void SpecialLocks::combinationClick(Common::Point pos) {
Common::Point realPos = _vm->_utils->vgaUnscale(pos);
if (!Common::Rect(44, 63, 285, 99).contains(realPos))
@@ -197,7 +197,7 @@ void TilePuzzle::mouseCombination(Common::Point pos) {
changeCombination(number);
}
-void TilePuzzle::doTile(bool showsolution) {
+void SpecialLocks::doTile(bool showsolution) {
uint16 row = 0, col = 0, rowm, colm, num;
int16 rows, cols;
@@ -235,7 +235,7 @@ void TilePuzzle::doTile(bool showsolution) {
}
}
-void TilePuzzle::showTile(const Common::String filename, bool showSolution) {
+void SpecialLocks::showTileLock(const Common::String filename, bool showSolution) {
_vm->_anim->_doBlack = true;
_vm->_anim->_noPalChange = true;
_vm->_graphics->readPict(filename);
@@ -255,7 +255,7 @@ void TilePuzzle::showTile(const Common::String filename, bool showSolution) {
_vm->_graphics->setPalette(_vm->_anim->_diffPalette, 256);
}
-void TilePuzzle::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
+void SpecialLocks::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
int16 dX = 0, dY = 0, dx = 0, dy = 0, sx = 0, sy = 0;
int last = 0;
@@ -296,7 +296,15 @@ void TilePuzzle::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
delete[] buffer;
}
-void TilePuzzle::changeCombination(uint16 number) {
+void SpecialLocks::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
+ if (dx)
+ _vm->_graphics->scrollDisplayX(dx, x1, y1, x2, y2, buffer);
+
+ if (dy)
+ _vm->_graphics->scrollDisplayY(dy, x1, y1, x2, y2, buffer);
+}
+
+void SpecialLocks::changeCombination(uint16 number) {
const int solution[6] = { 0, 4, 0, 8, 7, 2 };
Image display(_vm);
@@ -309,8 +317,8 @@ void TilePuzzle::changeCombination(uint16 number) {
uint16 combnum = _combination[number];
display.setData(_vm->_graphics->getCurrentDrawingBuffer(), false);
- display._width = _vm->_graphics->_screenWidth;
- display._height = _vm->_graphics->_screenHeight;
+ display._width = _vm->_graphics->_screenWidth;
+ display._height = _vm->_graphics->_screenHeight;
byte *buffer = new byte[_numberImages[1]->_width * _numberImages[1]->_height * 2];
@@ -318,7 +326,8 @@ void TilePuzzle::changeCombination(uint16 number) {
if (_vm->_isHiRes) {
if (i & 1)
_vm->waitTOF();
- } else
+ }
+ else
_vm->waitTOF();
display.setData(_vm->_graphics->getCurrentDrawingBuffer(), false);
@@ -338,20 +347,7 @@ void TilePuzzle::changeCombination(uint16 number) {
_vm->_conditions->exclElement(COMBINATIONUNLOCKED);
}
-void TilePuzzle::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
- if (dx)
- _vm->_graphics->scrollDisplayX(dx, x1, y1, x2, y2, buffer);
-
- if (dy)
- _vm->_graphics->scrollDisplayY(dy, x1, y1, x2, y2, buffer);
-}
-
-void TilePuzzle::doCombination() {
- for (int i = 0; i <= 5; i++)
- _numberImages[_combination[i]]->drawImage(_vm->_utils->vgaScaleX(COMBINATION_X[i]), _vm->_utils->vgaScaleY(65));
-}
-
-void TilePuzzle::showCombination(const Common::String filename) {
+void SpecialLocks::showCombinationLock(const Common::String filename) {
_vm->_anim->_doBlack = true;
_vm->_anim->_noPalChange = true;
_vm->_graphics->readPict(filename);
@@ -361,18 +357,20 @@ void TilePuzzle::showCombination(const Common::String filename) {
Common::File *numFile = _vm->_resource->openDataFile("P:Numbers");
- for (int CurBit = 0; CurBit < 10; CurBit++)
- _numberImages[CurBit] = new Image(numFile, _vm);
+ for (int i = 0; i < 10; i++) {
+ _numberImages[i] = new Image(numFile, _vm);
+ }
delete numFile;
- doCombination();
+ for (int i = 0; i <= 5; i++)
+ _numberImages[_combination[i]]->drawImage(_vm->_utils->vgaScaleX(COMBINATION_X[i]), _vm->_utils->vgaScaleY(65));
_vm->_graphics->setPalette(_vm->_anim->_diffPalette, 256);
}
-void TilePuzzle::save(Common::OutSaveFile *file) {
- // Combination lock and tile stuff
+void SpecialLocks::save(Common::OutSaveFile *file) {
+ // Combination lock
for (int i = 0; i < 6; i++)
file->writeByte(_combination[i]);
@@ -382,8 +380,8 @@ void TilePuzzle::save(Common::OutSaveFile *file) {
file->writeUint16LE(_curTile[i][j]);
}
-void TilePuzzle::load(Common::InSaveFile *file) {
- // Combination lock and tile stuff
+void SpecialLocks::load(Common::InSaveFile *file) {
+ // Combination lock
for (int i = 0; i < 6; i++)
_combination[i] = file->readByte();
diff --git a/engines/lab/tilepuzzle.h b/engines/lab/speciallocks.h
index 948df9ddcd..424eba242a 100644
--- a/engines/lab/tilepuzzle.h
+++ b/engines/lab/speciallocks.h
@@ -37,7 +37,7 @@ namespace Lab {
class LabEngine;
-class TilePuzzle {
+class SpecialLocks {
private:
LabEngine *_vm;
Image *_tiles[16];
@@ -46,28 +46,23 @@ private:
byte _combination[6];
public:
- TilePuzzle(LabEngine *vm);
- ~TilePuzzle();
+ SpecialLocks(LabEngine *vm);
+ ~SpecialLocks();
- /**
- * Processes mouse clicks and changes the combination.
- */
- void mouseTile(Common::Point pos);
+ void showTileLock(const Common::String filename, bool showSolution);
/**
- * Processes mouse clicks and changes the combination.
+ * Processes mouse clicks and changes tile positions.
*/
- void mouseCombination(Common::Point pos);
+ void tileClick(Common::Point pos);
- /**
- * Reads in a backdrop picture.
- */
- void showCombination(const Common::String filename);
+ void showCombinationLock(const Common::String filename);
/**
- * Reads in a backdrop picture.
+ * Processes mouse clicks and changes the door combination.
*/
- void showTile(const Common::String filename, bool showSolution);
+ void combinationClick(Common::Point pos);
+
void save(Common::OutSaveFile *file);
void load(Common::InSaveFile *file);
@@ -78,18 +73,13 @@ private:
void changeCombination(uint16 number);
/**
- * Changes the combination number of one of the slots
+ * Changes the tile positions in the tile puzzle
*/
void changeTile(uint16 col, uint16 row);
/**
* Draws the images of the combination lock to the display bitmap.
*/
- void doCombination();
-
- /**
- * Draws the images of the combination lock to the display bitmap.
- */
void doTile(bool showsolution);
/**