ScummVM API documentation
rooms.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 M4_CORE_ROOMS_H
23 #define M4_CORE_ROOMS_H
24 
25 #include "common/hashmap.h"
26 #include "common/serializer.h"
27 #include "m4/adv_r/adv.h"
28 #include "m4/adv_r/adv_control.h"
29 #include "m4/adv_r/adv_hotspot.h"
30 
31 namespace M4 {
32 
33 class Room {
34 public:
35  Room() {}
36  virtual ~Room() {}
37 
38  virtual void preload();
39  virtual void init() {}
40  virtual void daemon() {}
41  virtual void pre_parser() {}
42  virtual void parser();
43  virtual void roomError() {}
44  virtual void shutdown() {}
45  virtual void syncGame(Common::Serializer &s) {}
46 
50  virtual HotSpotRec *custom_hotspot_which(int32 x, int32 y) {
51  return nullptr;
52  }
53 };
54 
55 class Section {
56 private:
58 protected:
59  // Add a room to the section
60  void add(int roomNum, Room *room) {
61  _rooms[roomNum] = room;
62  }
63 
64 public:
65  Section() {}
66  virtual ~Section() {}
67 
68  virtual void preLoad() {}
69 
73  virtual void init() {}
74 
78  Room *operator[](uint roomNum);
79 
80  virtual void global_room_init() {}
81  virtual void daemon() = 0;
82  virtual void tick() {}
83  virtual void pre_parser() {}
84  virtual void parser() {}
85 };
86 
87 class Sections {
88 private:
89  int32 _cameraShiftAmount = 0;
90  int32 _cameraShift_vert_Amount = 0;
91  int32 camera_pan_step = 10;
92 
93  void get_ipl();
94  void get_walker();
95 
96  void game_control_cycle();
97 
98 protected:
99  Common::Array<Section *> _sections;
100 
101 public:
102  Section *_activeSection = nullptr;
103  Room *_activeRoom = nullptr;
104 public:
105  Sections() {}
106  virtual ~Sections() {}
107 
108  void global_section_constructor();
109  void section_room_constructor();
110  void game_daemon_code();
111  void parse_player_command_now();
112 
113  void section_init() {
114  _activeSection->init();
115  }
116  void daemon() {
117  _activeSection->daemon();
118  }
119  void global_room_init() {
120  _activeSection->global_room_init();
121  }
122  void tick() {
123  _activeSection->tick();
124  }
125  void section_parser() {
126  _activeSection->parser();
127  }
128 
129  void room_preload() {
130  _activeRoom->preload();
131  }
132  void room_init() {
133  _activeRoom->init();
134  }
135  void room_daemon() {
136  _activeRoom->daemon();
137  }
138  void room_pre_parser() {
139  _activeRoom->pre_parser();
140  }
141  void room_parser() {
142  _activeRoom->parser();
143  }
144  void room_error() {
145  _activeRoom->roomError();
146  }
147  void room_shutdown() {
148  _activeRoom->shutdown();
149  }
150  HotSpotRec *custom_hotspot_which(int x, int y) {
151  return _activeRoom->custom_hotspot_which(x, y);
152  }
153  Room *getRoom(int room) const;
154 
155  void m4SceneLoad();
156  void m4RunScene();
157  void m4EndScene();
158 
159  void pal_game_task();
160  void camera_shift_xy(int32 x, int32 y);
161  void adv_camera_pan_step(int32 step);
162  bool game_camera_panning() const {
163  return _cameraShiftAmount != 0 || _cameraShift_vert_Amount != 0;
164  }
165 
166  virtual void global_daemon() = 0;
167  virtual void global_pre_parser() {}
168  virtual void global_parser() = 0;
169 
170  void global_error_code() {
171  // No implementation
172  }
173 };
174 
175 } // namespace M4
176 
177 #endif
Definition: array.h:52
Definition: serializer.h:79
Definition: hashmap.h:85
Definition: database.h:28
virtual void init()
Definition: rooms.h:73
Definition: rooms.h:33
virtual HotSpotRec * custom_hotspot_which(int32 x, int32 y)
Definition: rooms.h:50
Definition: adv_hotspot.h:30
Definition: rooms.h:55
Definition: rooms.h:87