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