ScummVM API documentation
grid.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef QUEEN_GRID_H
23 #define QUEEN_GRID_H
24 
25 #include "common/util.h"
26 #include "queen/structs.h"
27 
28 namespace Queen {
29 
30 enum GridScreen {
31  GS_ROOM = 0,
32  GS_PANEL = 1,
33  GS_COUNT = 2
34 };
35 
36 class QueenEngine;
37 
38 class Grid {
39 public:
40 
41  Grid(QueenEngine *vm);
42  ~Grid();
43 
45  void readDataFrom(uint16 numObjects, uint16 numRooms, byte *&ptr);
46 
48  void setZone(GridScreen screen, uint16 zoneNum, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
49 
51  void setZone(GridScreen screen, uint16 zoneNum, const Box &box);
52 
54  uint16 findZoneForPos(GridScreen screen, uint16 x, uint16 y) const;
55 
57  uint16 findAreaForPos(GridScreen screen, uint16 x, uint16 y) const;
58 
60  void clear(GridScreen screen);
61 
63  void setupNewRoom(uint16 room, uint16 firstRoomObjNum);
64 
66  void setupPanel();
67 
69  void drawZones();
70 
72  const Box *zone(GridScreen screen, uint16 index) const;
73 
75  Verb findVerbUnderCursor(int16 cursorx, int16 cursory) const;
76 
78  uint16 findObjectUnderCursor(int16 cursorx, int16 cursory) const;
79 
81  uint16 findObjectNumber(uint16 zoneNum) const;
82 
84  uint16 findScale(uint16 x, uint16 y) const;
85 
87  Area *area(int room, int num) const { return &_area[room][num]; }
88 
90  uint16 areaMax(int room) const { return _areaMax[room]; }
91 
93  uint16 objMax(int room) const { return _objMax[room]; }
94 
95  void saveState(byte *&ptr);
96  void loadState(uint32 ver, byte *&ptr);
97 
98  enum {
99  MAX_ZONES_NUMBER = 32,
100  MAX_AREAS_NUMBER = 11
101  };
102 
103 
104 private:
105 
106  struct ZoneSlot {
107  bool valid;
108  Box box;
109  };
110 
112  ZoneSlot _zones[GS_COUNT][MAX_ZONES_NUMBER];
113 
115  int16 *_objMax;
116 
118  int16 *_areaMax;
119 
121  Area (*_area)[MAX_AREAS_NUMBER];
122 
124  uint16 _numRoomAreas;
125 
127  Box *_objectBox;
128 
129  QueenEngine *_vm;
130 };
131 
132 
133 } // End of namespace Queen
134 
135 #endif
void setupPanel()
setup panel zones
uint16 areaMax(int room) const
returns the number of areas in this room
Definition: grid.h:90
uint16 findObjectNumber(uint16 zoneNum) const
get the object for the specified zone number
Definition: grid.h:38
Definition: structs.h:30
Definition: queen.h:62
uint16 findScale(uint16 x, uint16 y) const
get scale for the specified position
void clear(GridScreen screen)
clear the zones for current room
Verb findVerbUnderCursor(int16 cursorx, int16 cursory) const
get the verb for the specified cursor position
void setupNewRoom(uint16 room, uint16 firstRoomObjNum)
setup objects zones for the specified room
uint16 findZoneForPos(GridScreen screen, uint16 x, uint16 y) const
find the zone number containing the specified point
Area * area(int room, int num) const
returns a reference to the specfied room area
Definition: grid.h:87
Definition: structs.h:77
Definition: bankman.h:28
uint16 findAreaForPos(GridScreen screen, uint16 x, uint16 y) const
find the area number containing the specified point
uint16 objMax(int room) const
returns the number of objects in this room
Definition: grid.h:93
void setZone(GridScreen screen, uint16 zoneNum, uint16 x1, uint16 y1, uint16 x2, uint16 y2)
defines a new zone
void readDataFrom(uint16 numObjects, uint16 numRooms, byte *&ptr)
read areas data from specified stream
uint16 findObjectUnderCursor(int16 cursorx, int16 cursory) const
get the object for the specified cursor position
void drawZones()
draw the zones for current room (debug only)
const Box * zone(GridScreen screen, uint16 index) const
retuns a reference to the specified zone