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  Common::Rect getInterpolatedRect(uint32 startFrame, uint32 endFrame, uint32 currentFrame);
82  Rect *clone();
83 };
84 
85 class Zone {
86 public:
87  Zone(const Common::String &name, uint32 startFrame, uint32 endFrame);
88  Zone(const Common::String &name, const Common::String &ptrfb);
89  ~Zone();
90  Common::String _name;
91  uint32 _startFrame = 0;
92  uint32 _endFrame = 0;
93  Common::String _ptrfb;
94  Common::Array<Rect *> _rects;
95  Common::String _next;
96  uint8 _difficulty = 0;
97  void addRect(int16 left, int16 top, int16 right, int16 bottom, const Common::String scene, uint32 score, const Common::String rectHit, const Common::String unknown);
98  Zone *clone();
99 };
100 
101 class Scene {
102 public:
103  Scene(const Common::String &name, uint32 startFrame, uint32 endFrame);
104  ~Scene();
105  Common::String _name;
106  uint32 _startFrame;
107  uint32 _endFrame;
108  Common::String _next;
109  Common::String _zonesStart;
110  Common::String _zonesStart2;
111  Common::String _zonesStart3;
112  Common::String _preop;
113  Common::String _preopParam;
114  Common::String _insop;
115  Common::String _insopParam;
116  Common::String _scnmsg;
117  Common::String _scnmsgParam;
118  Common::String _wepdwn;
119  Common::String _scnscr;
120  int32 _scnscrParam;
121  Common::String _nxtfrm;
122  Common::String _nxtscn;
123  int32 _dataParam1;
124  int32 _dataParam2;
125  int32 _dataParam3;
126  int32 _dataParam4;
127  Common::String _dataParam5;
128  Common::String _dataParam6;
129  uint32 _diff;
130  Common::String _missedRects;
131  uint32 _difficultyMod;
132  Common::Array<Zone *> _zones;
133 };
134 
135 class SceneInfo {
136 
137 public:
138  SceneInfo();
139  ~SceneInfo();
140  void loadScnFile(const Common::Path &path);
141  Common::String getStartScene() { return _startScene; }
142  Common::Array<Scene *> *getScenes() { return &_scenes; }
143  Scene *findScene(const Common::String &sceneName);
144  void addScene(Scene *scene);
145 
146 private:
147  Common::File _scnFile;
148  Common::String _startScene;
149  Common::Array<Scene *> _scenes;
150  Common::Array<Zone *> _zones;
151 
152  void parseScene(const Common::String &sceneName, uint32 startFrame, uint32 endFrame);
153  void parseZone(const Common::String &zoneName, uint32 startFrame, uint32 endFrame);
154  void addZonesToScenes();
155  Zone *findZone(const Common::String &zoneName);
156  int8 getToken(const TokenEntry *tokenList, const Common::String &token);
157  bool ignoreScriptLine(const Common::String &line);
158 };
159 
160 } // End of namespace Alg
161 
162 #endif
Definition: scene.h:72
Definition: scene.h:101
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:85
Definition: scene.h:33
Definition: scene.h:135