ASYLUM: Rename puzzle classes

git-svn-id: http://asylumengine.googlecode.com/svn/trunk@665 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
This commit is contained in:
Julien Templier 2010-12-07 02:52:44 +00:00 committed by Eugene Sandulenko
parent 730105912f
commit 436a6f3ef2
No known key found for this signature in database
GPG key ID: 014D387312D34F08
7 changed files with 48 additions and 41 deletions

View file

@ -411,7 +411,7 @@ EventHandler *AsylumEngine::getPuzzle(uint32 index) {
} }
void AsylumEngine::initPuzzles() { void AsylumEngine::initPuzzles() {
_puzzles[0] = new BlowUpPuzzleVCR(this); _puzzles[0] = new PuzzleVCR(this);
_puzzles[1] = NULL; _puzzles[1] = NULL;
_puzzles[2] = NULL; _puzzles[2] = NULL;
_puzzles[3] = NULL; _puzzles[3] = NULL;

View file

@ -64,7 +64,7 @@ namespace Asylum {
// If defined, will show the scene update times on the debugger output // If defined, will show the scene update times on the debugger output
//#define DEBUG_SCENE_TIMES //#define DEBUG_SCENE_TIMES
class BlowUpPuzzle; class Puzzle;
class Cursor; class Cursor;
class Encounter; class Encounter;
class MainMenu; class MainMenu;
@ -228,7 +228,7 @@ private:
// Current EventHandler class instance // Current EventHandler class instance
EventHandler *_handler; EventHandler *_handler;
BlowUpPuzzle *_puzzles[16]; Puzzle *_puzzles[16];
// Game data // Game data
SharedData _data; SharedData _data;

View file

@ -36,18 +36,18 @@
namespace Asylum { namespace Asylum {
BlowUpPuzzle::BlowUpPuzzle(AsylumEngine *engine): _vm(engine), Puzzle::Puzzle(AsylumEngine *engine): _vm(engine),
_cursor(NULL), _bgResource(NULL), _cursor(NULL), _bgResource(NULL),
_leftClickUp(false), _leftClickDown(false), _rightClickDown(false), _active(false) { _leftClickUp(false), _leftClickDown(false), _rightClickDown(false), _active(false) {
} }
void BlowUpPuzzle::init() { void Puzzle::init() {
// setup cursor & background // setup cursor & background
_cursor = new Cursor(_vm); _cursor = new Cursor(_vm);
_bgResource = new GraphicResource(_vm, getWorld()->graphicResourceIds[0]); _bgResource = new GraphicResource(_vm, getWorld()->graphicResourceIds[0]);
} }
BlowUpPuzzle::~BlowUpPuzzle() { Puzzle::~Puzzle() {
delete _cursor; delete _cursor;
delete _bgResource; delete _bgResource;

View file

@ -41,23 +41,28 @@ class Cursor;
class GraphicResource; class GraphicResource;
struct GraphicQueueItem; struct GraphicQueueItem;
class BlowUpPuzzle : public EventHandler { class Puzzle : public EventHandler {
public: public:
BlowUpPuzzle(AsylumEngine *engine); Puzzle(AsylumEngine *engine);
virtual ~BlowUpPuzzle(); virtual ~Puzzle();
void init();
virtual void open() = 0;
virtual void close() = 0;
virtual void reset() {} virtual void reset() {}
//////////////////////////////////////////////////////////////////////////
// TODO remove
void init();
virtual void open() = 0;
virtual void close() = 0;
bool isActive() { return _active; } bool isActive() { return _active; }
//////////////////////////////////////////////////////////////////////////
protected: protected:
AsylumEngine *_vm; AsylumEngine *_vm;
//////////////////////////////////////////////////////////////////////////
// TODO remove
Cursor *_cursor; Cursor *_cursor;
GraphicResource *_bgResource; GraphicResource *_bgResource;
@ -68,6 +73,7 @@ protected:
virtual void update() {}; virtual void update() {};
void playSound(ResourceId resourceId, bool loop = false); void playSound(ResourceId resourceId, bool loop = false);
//////////////////////////////////////////////////////////////////////////
}; };
} // End of namespace Asylum } // End of namespace Asylum

View file

@ -41,7 +41,7 @@
namespace Asylum { namespace Asylum {
BlowUpPuzzleVCR::BlowUpPuzzleVCR(AsylumEngine *engine): BlowUpPuzzle(engine) { PuzzleVCR::PuzzleVCR(AsylumEngine *engine): Puzzle(engine) {
// reset all states // reset all states
memset(&_jacksState, 0, sizeof(_jacksState)); memset(&_jacksState, 0, sizeof(_jacksState));
memset(&_holesState, 0, sizeof(_holesState)); memset(&_holesState, 0, sizeof(_holesState));
@ -51,12 +51,12 @@ BlowUpPuzzleVCR::BlowUpPuzzleVCR(AsylumEngine *engine): BlowUpPuzzle(engine) {
_isAccomplished = false; _isAccomplished = false;
} }
BlowUpPuzzleVCR::~BlowUpPuzzleVCR() { PuzzleVCR::~PuzzleVCR() {
delete _cursor; delete _cursor;
delete _bgResource; delete _bgResource;
} }
void BlowUpPuzzleVCR::open() { void PuzzleVCR::open() {
_active = true; _active = true;
getSound()->stopAll(); getSound()->stopAll();
@ -76,12 +76,12 @@ void BlowUpPuzzleVCR::open() {
_rightClickDown = false; _rightClickDown = false;
} }
void BlowUpPuzzleVCR::close() { void PuzzleVCR::close() {
_active = false; _active = false;
// TODO Switch back to scene event handler // TODO Switch back to scene event handler
} }
bool BlowUpPuzzleVCR::handleEvent(const AsylumEvent &ev) { bool PuzzleVCR::handleEvent(const AsylumEvent &ev) {
switch (ev.type) { switch (ev.type) {
case Common::EVENT_MOUSEMOVE: case Common::EVENT_MOUSEMOVE:
//_cursor->move(ev.mouse.x, ev.mouse.y); //_cursor->move(ev.mouse.x, ev.mouse.y);
@ -105,16 +105,16 @@ bool BlowUpPuzzleVCR::handleEvent(const AsylumEvent &ev) {
return true; return true;
} }
void BlowUpPuzzle::playSound(ResourceId resourceId, bool loop) { void Puzzle::playSound(ResourceId resourceId, bool loop) {
getSound()->playSound(resourceId, loop, Config.sfxVolume, 0); getSound()->playSound(resourceId, loop, Config.sfxVolume, 0);
} }
int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) const { int PuzzleVCR::inPolyRegion(int x, int y, int polyIdx) const {
return x >= BlowUpPuzzleVCRPolies[polyIdx].left && x <= BlowUpPuzzleVCRPolies[polyIdx].right && return x >= BlowUpPuzzleVCRPolies[polyIdx].left && x <= BlowUpPuzzleVCRPolies[polyIdx].right &&
y >= BlowUpPuzzleVCRPolies[polyIdx].top && y <= BlowUpPuzzleVCRPolies[polyIdx].bottom; y >= BlowUpPuzzleVCRPolies[polyIdx].top && y <= BlowUpPuzzleVCRPolies[polyIdx].bottom;
} }
void BlowUpPuzzleVCR::update() { void PuzzleVCR::update() {
getScreen()->clearGraphicsInQueue(); getScreen()->clearGraphicsInQueue();
if (_rightClickDown) { // quits BlowUp Puzzle if (_rightClickDown) { // quits BlowUp Puzzle
@ -170,7 +170,7 @@ void BlowUpPuzzleVCR::update() {
} }
} }
GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(int32 index) { GraphicQueueItem PuzzleVCR::getGraphicJackItem(int32 index) {
GraphicQueueItem jackItemOnHand; GraphicQueueItem jackItemOnHand;
int jackY = _cursor->position().y; int jackY = _cursor->position().y;
@ -186,7 +186,7 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(int32 index) {
return jackItemOnHand; return jackItemOnHand;
} }
GraphicQueueItem BlowUpPuzzleVCR::getGraphicShadowItem() { GraphicQueueItem PuzzleVCR::getGraphicShadowItem() {
GraphicQueueItem shadowItem; GraphicQueueItem shadowItem;
int shadowY = (_cursor->position().y - 356) / 4; int shadowY = (_cursor->position().y - 356) / 4;
@ -201,7 +201,7 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicShadowItem() {
return shadowItem; return shadowItem;
} }
void BlowUpPuzzleVCR::updateJack(Jack jack, const VCRDrawInfo &onTable, const VCRDrawInfo &pluggedOnRed, const VCRDrawInfo &pluggedOnYellow, const VCRDrawInfo &pluggedOnBlack, int32 resourceOnHandIndex) { void PuzzleVCR::updateJack(Jack jack, const VCRDrawInfo &onTable, const VCRDrawInfo &pluggedOnRed, const VCRDrawInfo &pluggedOnYellow, const VCRDrawInfo &pluggedOnBlack, int32 resourceOnHandIndex) {
GraphicQueueItem item; GraphicQueueItem item;
switch (_jacksState[jack]) { switch (_jacksState[jack]) {
@ -250,7 +250,7 @@ void BlowUpPuzzleVCR::updateJack(Jack jack, const VCRDrawInfo &onTable, const VC
getScreen()->addGraphicToQueue(item); getScreen()->addGraphicToQueue(item);
} }
void BlowUpPuzzleVCR::updateBlackJack() { void PuzzleVCR::updateBlackJack() {
VCRDrawInfo onTable; VCRDrawInfo onTable;
onTable.resourceId = 1; onTable.resourceId = 1;
onTable.point = Common::Point(0, 411); onTable.point = Common::Point(0, 411);
@ -267,7 +267,7 @@ void BlowUpPuzzleVCR::updateBlackJack() {
updateJack(kBlack, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 27); updateJack(kBlack, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 27);
} }
void BlowUpPuzzleVCR::updateRedJack() { void PuzzleVCR::updateRedJack() {
VCRDrawInfo onTable; VCRDrawInfo onTable;
onTable.resourceId = 2; onTable.resourceId = 2;
onTable.point = Common::Point(76, 428); onTable.point = Common::Point(76, 428);
@ -284,7 +284,7 @@ void BlowUpPuzzleVCR::updateRedJack() {
updateJack(kRed, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 25); updateJack(kRed, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 25);
} }
void BlowUpPuzzleVCR::updateYellowJack() { void PuzzleVCR::updateYellowJack() {
VCRDrawInfo onTable; VCRDrawInfo onTable;
onTable.resourceId = 3; onTable.resourceId = 3;
onTable.point = Common::Point(187, 439); onTable.point = Common::Point(187, 439);
@ -303,7 +303,7 @@ void BlowUpPuzzleVCR::updateYellowJack() {
// common function to set and unset the jack on holes for each type of jack // common function to set and unset the jack on holes for each type of jack
int BlowUpPuzzleVCR::setJackOnHole(int jackType, JackState plugged) { int PuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
if (!_holesState[plugged-1]) { if (!_holesState[plugged-1]) {
if (_jacksState[jackType-1] == kOnHand) { if (_jacksState[jackType-1] == kOnHand) {
_jacksState[jackType-1] = plugged; _jacksState[jackType-1] = plugged;
@ -320,7 +320,7 @@ int BlowUpPuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
return 1; return 1;
} }
void BlowUpPuzzleVCR::updateButton(Button button, const VCRDrawInfo &btON, const VCRDrawInfo &btDown) { void PuzzleVCR::updateButton(Button button, const VCRDrawInfo &btON, const VCRDrawInfo &btDown) {
GraphicQueueItem item; GraphicQueueItem item;
switch (_buttonsState[button]) { switch (_buttonsState[button]) {
@ -347,7 +347,7 @@ void BlowUpPuzzleVCR::updateButton(Button button, const VCRDrawInfo &btON, const
} }
void BlowUpPuzzleVCR::updatePowerButton() { void PuzzleVCR::updatePowerButton() {
VCRDrawInfo btON; VCRDrawInfo btON;
btON.resourceId = 17; btON.resourceId = 17;
btON.point = Common::Point(512, 347); btON.point = Common::Point(512, 347);
@ -359,7 +359,7 @@ void BlowUpPuzzleVCR::updatePowerButton() {
updateButton(kPower, btON, btDown); updateButton(kPower, btON, btDown);
} }
void BlowUpPuzzleVCR::updateRewindButton() { void PuzzleVCR::updateRewindButton() {
VCRDrawInfo btON; VCRDrawInfo btON;
btON.resourceId = 14; btON.resourceId = 14;
btON.point = Common::Point(248, 347); btON.point = Common::Point(248, 347);
@ -371,7 +371,7 @@ void BlowUpPuzzleVCR::updateRewindButton() {
updateButton(kRewind, btON, btDown); updateButton(kRewind, btON, btDown);
} }
void BlowUpPuzzleVCR::updatePlayButton() { void PuzzleVCR::updatePlayButton() {
VCRDrawInfo btON; VCRDrawInfo btON;
btON.resourceId = 16; btON.resourceId = 16;
btON.point = Common::Point(401, 359); btON.point = Common::Point(401, 359);
@ -383,7 +383,7 @@ void BlowUpPuzzleVCR::updatePlayButton() {
updateButton(kPlay, btON, btDown); updateButton(kPlay, btON, btDown);
} }
void BlowUpPuzzleVCR::updateStopButton() { void PuzzleVCR::updateStopButton() {
VCRDrawInfo btON; VCRDrawInfo btON;
btON.resourceId = 15; btON.resourceId = 15;
btON.point = Common::Point(330, 354); btON.point = Common::Point(330, 354);
@ -396,7 +396,7 @@ void BlowUpPuzzleVCR::updateStopButton() {
} }
void BlowUpPuzzleVCR::updateCursorInPolyRegion() { void PuzzleVCR::updateCursorInPolyRegion() {
int showCursor = 0; int showCursor = 0;
if (_jacksState[kBlack] == kOnHand) { if (_jacksState[kBlack] == kOnHand) {
@ -438,7 +438,7 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
} }
} }
void BlowUpPuzzleVCR::handleMouseDown() { void PuzzleVCR::handleMouseDown() {
if (_isAccomplished) if (_isAccomplished)
return; return;
@ -541,7 +541,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
} }
} }
void BlowUpPuzzleVCR::handleMouseUp() { void PuzzleVCR::handleMouseUp() {
if (_isAccomplished) if (_isAccomplished)
return; return;

View file

@ -58,14 +58,15 @@ const Common::Rect BlowUpPuzzleVCRPolies[10] = {
Common::Rect(0x0BB, 0x1B7, 0x0F0, 0x1E0) // yellow jack on table region Common::Rect(0x0BB, 0x1B7, 0x0F0, 0x1E0) // yellow jack on table region
}; };
class BlowUpPuzzleVCR : public BlowUpPuzzle { class PuzzleVCR : public Puzzle {
public: public:
BlowUpPuzzleVCR(AsylumEngine *engine); PuzzleVCR(AsylumEngine *engine);
~BlowUpPuzzleVCR(); ~PuzzleVCR();
bool handleEvent(const AsylumEvent &event); bool handleEvent(const AsylumEvent &event);
void open(); void open();
void close(); void close();
private: private:
enum Jack { enum Jack {
kBlack = 0, kBlack = 0,

View file

@ -41,7 +41,7 @@ namespace Asylum {
class Actor; class Actor;
class AsylumEngine; class AsylumEngine;
class BlowUpPuzzle; class Puzzle;
class Cursor; class Cursor;
class GraphicResource; class GraphicResource;
class Polygons; class Polygons;