ScummVM API documentation
scene.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 ALG_SCENE_H
23 #define ALG_SCENE_H
24 
25 #include "common/array.h"
26 #include "common/file.h"
27 #include "common/path.h"
28 #include "common/rect.h"
29 #include "common/str.h"
30 
31 namespace Alg {
32 
33 struct TokenEntry {
34  const char *name;
35  uint8 value;
36 };
37 
38 const TokenEntry _mainTokens[] = {
39  {"ZONE", 1},
40  {"SCENE", 2},
41  {"MSG", 3},
42  {"START", 4},
43  {"GLOBAL", 5},
44  {"END", 6},
45  {nullptr, 0}};
46 
47 const TokenEntry _zoneTokens[] = {
48  {"NEXT", 1},
49  {"PTRFB", 2},
50  {"RECT", 3},
51  {";", 4},
52  {nullptr, 0}};
53 
54 const TokenEntry _sceneTokens[] = {
55  {"NEXT", 1},
56  {"ZONES", 2},
57  {"PREOP", 3},
58  {"SHOWMSG", 4},
59  {"SCNMSG", 4},
60  {"INSOP", 5},
61  {"WEPDWN", 6},
62  {"SCNSCR", 7},
63  {"NXTFRM", 8},
64  {"NXTSCN", 9},
65  {"DATA", 10},
66  {"DIFF", 11},
67  {"MISSEDRECTS", 12},
68  {"DIFFICULTY_MOD", 13},
69  {";", 14},
70  {nullptr, 0}};
71 
72 class Rect : public Common::Rect {
73 public:
74  Common::String _scene;
75  uint32 _score;
76  Common::String _rectHit;
77  Common::String _unknown;
78  bool _isMoving = false;
79  Common::Rect _dest;
80  void center(int16 cx, int16 cy, int16 w, int16 h) {
81  right = cx + (w / 2);
82  left = cx - (w / 2);
83  top = cy - (h / 2);
84  bottom = cy + (h / 2);
85  }
86 };
87 
88 class Zone {
89 public:
90  Zone(const Common::String &name, uint32 startFrame, uint32 endFrame);
91  Zone(const Common::String &name, const Common::String &ptrfb);
92  ~Zone();
93  Common::String _name;
94  uint32 _startFrame = 0;
95  uint32 _endFrame = 0;
96  Common::String _ptrfb;
97  Common::Array<Rect *> _rects;
98  Common::String _next;
99  void addRect(int16 left, int16 top, int16 right, int16 bottom, const Common::String &scene, uint32 score, const Common::String &rectHit, const Common::String &unknown);
100 };
101 
102 class Scene {
103 public:
104  Scene(const Common::String &name, uint32 startFrame, uint32 endFrame);
105  ~Scene() = default;
106  Common::String _name;
107  uint32 _startFrame;
108  uint32 _endFrame;
109  Common::String _next;
110  Common::String _zonesStart;
111  Common::String _zonesStart2;
112  Common::String _zonesStart3;
113  Common::String _preop;
114  Common::String _preopParam;
115  Common::String _insop;
116  Common::String _insopParam;
117  Common::String _scnmsg;
118  Common::String _scnmsgParam;
119  Common::String _wepdwn;
120  Common::String _scnscr;
121  int32 _scnscrParam;
122  Common::String _nxtfrm;
123  Common::String _nxtscn;
124  int32 _dataParam1;
125  int32 _dataParam2;
126  int32 _dataParam3;
127  int32 _dataParam4;
128  Common::String _dataParam5;
129  Common::String _dataParam6;
130  uint32 _diff;
131  Common::String _missedRects;
132  uint32 _difficultyMod;
133  Common::Array<Zone *> _zones;
134 };
135 
136 class SceneInfo {
137 
138 public:
139  SceneInfo();
140  ~SceneInfo();
141  void loadScnFile(const Common::Path &path);
142  Common::String getStartScene() { return _startScene; }
143  Common::Array<Scene *> *getScenes() { return &_scenes; }
144  Scene *findScene(const Common::String &sceneName);
145  void addScene(Scene *scene);
146 
147 private:
148  Common::File _scnFile;
149  Common::String _startScene;
150  Common::Array<Scene *> _scenes;
151  Common::Array<Zone *> _zones;
152 
153  void parseScene(const Common::String &sceneName, uint32 startFrame, uint32 endFrame);
154  void parseZone(const Common::String &zoneName, uint32 startFrame, uint32 endFrame);
155  void addZonesToScenes();
156  Zone *findZone(const Common::String &zoneName);
157  int8 getToken(const TokenEntry *tokenList, const Common::String &token);
158  bool ignoreScriptLine(const Common::String &line);
159 };
160 
161 } // End of namespace Alg
162 
163 #endif
Definition: scene.h:72
Definition: scene.h:102
Definition: str.h:59
Definition: array.h:52
Definition: rect.h:524
Definition: path.h:52
Definition: file.h:47
Definition: alg.h:30
Definition: scene.h:88
Definition: scene.h:33
Definition: scene.h:136