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 #ifndef SLUDGE_REGION_H
23 #define SLUDGE_REGION_H
24 
25 #include "sludge/objtypes.h"
26 #include "sludge/freeze.h"
27 
28 namespace Sludge {
29 
30 struct ScreenRegion {
31 	int x1, y1, x2, y2, sX, sY, di;
32 	ObjectType *thisType;
33 };
34 typedef Common::List<ScreenRegion *> ScreenRegionList;
35 
36 class RegionManager {
37 public:
38 	RegionManager(SludgeEngine *vm);
39 	~RegionManager();
40 
41 	// Kill
42 	void kill();
43 
44 	// Add & remove region
45 	bool addScreenRegion(int x1, int y1, int x2, int y2, int, int, int, int objectNum);
46 	void removeScreenRegion(int objectNum);
47 
48 	// Save & load
49 	void loadRegions(Common::SeekableReadStream *stream);
50 	void saveRegions(Common::WriteStream *stream);
51 
52 	// Draw
53 	void showBoxes();
54 
55 	// Setter & getter
56 	ScreenRegion *getRegionForObject(int obj);
getOverRegion()57 	ScreenRegion *getOverRegion() const { return _overRegion; }
setOverRegion(ScreenRegion * newRegion)58 	void setOverRegion(ScreenRegion *newRegion) { _overRegion = newRegion; }
59 	void updateOverRegion();
isRegionChanged()60 	bool isRegionChanged() const { return _lastRegion != _overRegion; }
updateLastRegion()61 	void updateLastRegion() { _lastRegion = _overRegion; }
resetOverRegion()62 	void resetOverRegion() { _overRegion = nullptr; }
resetLastRegion()63 	void resetLastRegion() { _lastRegion = nullptr; }
64 
65 	// Freeze
66 	void freeze(FrozenStuffStruct *frozenStuff);
67 	void resotre(FrozenStuffStruct *frozenStuff);
68 
69 private:
70 	SludgeEngine *_vm;
71 
72 	ScreenRegionList *_allScreenRegions;
73 	ScreenRegion *_overRegion;
74 	ScreenRegion *_lastRegion;
75 };
76 
77 } // End of namespace Sludge
78 
79 #endif
80