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