ScummVM API documentation
context.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 MEDIASTATION_CONTEXT_H
23 #define MEDIASTATION_CONTEXT_H
24 
25 #include "common/str.h"
26 #include "common/path.h"
27 #include "common/hashmap.h"
28 #include "graphics/palette.h"
29 
30 #include "mediastation/datafile.h"
31 #include "mediastation/actor.h"
32 
33 namespace MediaStation {
34 
35 enum StreamType {
36  kDocumentDefStream = 0x01,
37  kControlCommandsStream = 0x0D,
38 };
39 
40 enum ContextSectionType {
41  kEndOfContextData = 0x00,
42  kContextCreateData = 0x0e,
43  kContextDestroyData = 0x0f,
44  kContextLoadCompleteSection = 0x10,
45  kContextCreateActorData = 0x11,
46  kContextDestroyActorData = 0x12,
47  kContextActorLoadComplete = 0x13,
48  kContextCreateVariableData = 0x14,
49  kContextFunctionSection = 0x31,
50  kContextNameData = 0xbb8
51 };
52 
53 class ScreenActor;
54 
55 class Context : public Datafile {
56 public:
57  Context(const Common::Path &path);
58  ~Context();
59 
60  uint32 _unk1;
61  uint32 _subfileCount;
62  uint32 _fileSize;
63  ScreenActor *_screenActor = nullptr;
64 
65  Actor *getActorById(uint actorId);
66  Actor *getActorByChunkReference(uint chunkReference);
67  ScriptValue *getVariable(uint variableId);
68 
69 private:
70  // This is not an internal file ID, but the number of the file
71  // as it appears in the filename. For instance, the context in
72  // "100.cxt" would have file number 100.
73  uint _id = 0;
74  Common::String _contextName;
75 
77  Common::HashMap<uint, Actor *> _actorsByChunkReference;
79 
80  void readHeaderSections(Subfile &subfile, Chunk &chunk);
81 
82  void readControlCommands(Chunk &chunk);
83  void readCommandFromStream(ContextSectionType sectionType, Chunk &chunk);
84  void readCreateContextData(Chunk &chunk);
85  void readDestroyContextData(Chunk &chunk);
86  void readCreateActorData(Chunk &chunk);
87  void readDestroyActorData(Chunk &chunk);
88  void readActorLoadComplete(Chunk &chunk);
89  void readCreateVariableData(Chunk &chunk);
90  void readContextNameData(Chunk &chunk);
91 
92  void readActorFromLaterSubfile(Subfile &subfile);
93 };
94 
95 } // End of namespace MediaStation
96 
97 #endif
Definition: str.h:59
Definition: datafile.h:144
Definition: actor.h:33
Definition: context.h:55
Definition: datafile.h:102
Definition: path.h:52
Definition: hashmap.h:85
Definition: screen.h:34
Definition: datafile.h:128
Definition: actor.h:155
Definition: scriptvalue.h:36