1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef ASYLUM_PUZZLES_BOARD_H
24 #define ASYLUM_PUZZLES_BOARD_H
25 
26 #include "asylum/puzzles/puzzle.h"
27 
28 #include "asylum/shared.h"
29 
30 namespace Asylum {
31 
32 class AsylumEngine;
33 
34 class PuzzleBoard : public Puzzle {
35 public:
36 	struct SoundResource {
37 		int32 index;
38 		bool played;
39 	};
40 
41 	struct CharMap {
42 		char character;
43 		int16 posX, posY;
44 	};
45 
46 	struct PuzzleData {
47 		uint32 backgroundIndex;
48 		GameFlag gameFlag;
49 		uint32 maxWidth;
50 		uint32 soundResourceSize;
51 		SoundResource soundResources[3];
52 		uint32 charMapSize;
53 		CharMap charMap[10];
54 		bool checkForSpace;
55 		char solvedText[28];
56 	};
57 
58 	PuzzleBoard(AsylumEngine *engine, const PuzzleData &data);
59 
60 	void reset();
61 
62 protected:
63 	bool _solved;
64 	Common::String _text;
65 	bool _charUsed[20];
66 	char _solvedText[28]; // KeyHidesTo uses 28 chars, the other puzzles 20
67 	uint32 _position;
68 	int32 _rectIndex;
69 	int32 _selectedSlot;
70 	ResourceId _soundResourceId;
71 
72 	//////////////////////////////////////////////////////////////////////////
73 	// Helpers
74 	//////////////////////////////////////////////////////////////////////////
75 	void updateScreen();
76 	int32 findRect();
77 	bool stopSound();
78 	void checkSlots();
79 
80 private:
81 	PuzzleData _data;
82 
83 	//////////////////////////////////////////////////////////////////////////
84 	// Event Handling
85 	//////////////////////////////////////////////////////////////////////////
86 	bool init(const AsylumEvent &evt);
activate(const AsylumEvent & evt)87 	bool activate(const AsylumEvent &evt) { return updateScreen(), true; }
88 	bool update(const AsylumEvent &evt);
89 	virtual bool mouseRightDown(const AsylumEvent &evt);
90 
91 	//////////////////////////////////////////////////////////////////////////
92 	// Helpers
93 	//////////////////////////////////////////////////////////////////////////
94 	void drawText();
95 	void playSound();
96 	int32 checkMouse();
97 	void updateCursor();
98 };
99 
100 } // End of namespace Asylum
101 
102 #endif // ASYLUM_PUZZLES_BOARD_H
103