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  * Additional copyright for this file:
8  * Copyright (C) 1995-1997 Presto Studios, Inc.
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23  *
24  */
25 
26 #ifndef PEGASUS_NEIGHBORHOOD_CALDORIA_CALDORIABOMB_H
27 #define PEGASUS_NEIGHBORHOOD_CALDORIA_CALDORIABOMB_H
28 
29 #include "pegasus/interaction.h"
30 #include "pegasus/notification.h"
31 #include "pegasus/surface.h"
32 
33 namespace Pegasus {
34 
35 /*
36 	Edge list is arranged as follows:
37 
38 	all values in the edge list are bytes.
39 
40 	all vertices are numbers between 0 and 24. x coordinate of vertex is vertex % 5,
41 	and y coordinate is vertex / 5.
42 
43 	an edge is
44 		a direction code
45 		a number of vertices in the edge
46 		an array of vertices -- all vertices along the edge, whether or not they're
47 			clickable.
48 		an array of bools (bytes) indicating that a portion of the edge is
49 			traversed (and should be drawn). the number of bools is one less than
50 			the number of vertices.
51 
52 	an edge list is
53 		an array of 25 bools indicating which vertex is clickable.
54 		an array of 25 bools indicating which vertex is used (drawn).
55 		a number of edges
56 		an array of edges.
57 
58 	a hot vertex list is
59 		a number of vertices
60 		an array of 25 vertices
61 
62 */
63 
64 typedef int8 VertexType;
65 typedef VertexType *BombEdgeList;
66 
67 static const VertexType kEdgeOneSixteenth = 0;
68 static const VertexType kEdgeOneEighth = 1;
69 static const VertexType kEdgeThreeSixteenths = 2;
70 static const VertexType kEdgeOneFourth = 3;
71 static const VertexType kEdgeFiveSixteenths = 4;
72 static const VertexType kEdgeThreeEighths = 5;
73 static const VertexType kEdgeSevenSixteenths = 6;
74 static const VertexType kEdgeOneHalf = 7;
75 
76 class BombTimer : public IdlerAnimation {
77 public:
78 	BombTimer(const DisplayElementID);
~BombTimer()79 	virtual ~BombTimer() {}
80 
81 	void draw(const Common::Rect &);
82 
83 protected:
84 	void timeChanged(const TimeValue);
85 
86 	int _middle;
87 	Surface _leftImage, _rightImage;
88 };
89 
90 class BombGrid : public Picture {
91 public:
92 	BombGrid(const DisplayElementID);
~BombGrid()93 	virtual ~BombGrid() {}
94 
95 	void drawEdges(BombEdgeList);
96 
97 protected:
98 	Frame _yellowDot;
99 	Frame _yellowOneSixteenth;
100 	Frame _yellowOneEighth;
101 	Frame _yellowThreeSixteenths;
102 	Frame _yellowOneFourth;
103 	Frame _yellowFiveSixteenths;
104 	Frame _yellowThreeEighths;
105 	Frame _yellowSevenSixteenths;
106 	Frame _yellowOneHalf;
107 	Frame _redDot;
108 	Frame _redOneSixteenth;
109 	Frame _redOneEighth;
110 	Frame _redThreeSixteenths;
111 	Frame _redOneFourth;
112 	Frame _redFiveSixteenths;
113 	Frame _redThreeEighths;
114 	Frame _redSevenSixteenths;
115 	Frame _redOneHalf;
116 };
117 
118 class Hotspot;
119 
120 class CaldoriaBomb : public GameInteraction, public NotificationReceiver {
121 public:
122 	CaldoriaBomb(Neighborhood *, NotificationManager *);
123 	virtual ~CaldoriaBomb();
124 
125 	void setSoundFXLevel(const uint16);
126 	void setAmbienceLevel(const uint16);
127 
128 	long getNumHints();
129 	Common::String getHintMovie(uint);
130 	void doSolve();
131 	bool canSolve();
132 
133 protected:
134 	void openInteraction();
135 	void initInteraction();
136 	void closeInteraction();
137 	void receiveNotification(Notification *, const NotificationFlags);
138 	void activateHotspots();
139 	void clickInHotspot(const Input &, const Hotspot *);
140 	void handleInput(const Input &, const Hotspot *);
141 	InputBits getInputFilter();
142 	void startBombAmbient(Common::String);
143 
144 	Notification *_neighborhoodNotification;
145 	BombGrid _grid;
146 	BombTimer _timer;
147 	BombEdgeList _bombLevel[6];
148 	int _currentLevel, _flashTime;
149 	Hotspot *_vertexHotspot[25];
150 	VertexType _lastVertex;
151 	Notification _timerNotification;
152 	NotificationCallBack _timerCallBack;
153 
154 	TimeValue _readTime;
155 };
156 
157 } // End of namespace Pegasus
158 
159 #endif
160