ScummVM API documentation
mediastation.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_H
23 #define MEDIASTATION_H
24 
25 #include "audio/mixer.h"
26 #include "common/scummsys.h"
27 #include "common/system.h"
28 #include "common/error.h"
29 #include "common/fs.h"
30 #include "common/hash-str.h"
31 #include "common/random.h"
32 #include "common/serializer.h"
33 #include "common/events.h"
34 #include "common/util.h"
35 #include "engines/engine.h"
36 #include "engines/savestate.h"
37 
38 #include "mediastation/clients.h"
39 #include "mediastation/detection.h"
40 #include "mediastation/datafile.h"
41 #include "mediastation/boot.h"
42 #include "mediastation/context.h"
43 #include "mediastation/actor.h"
44 #include "mediastation/cursors.h"
45 #include "mediastation/graphics.h"
46 #include "mediastation/mediascript/function.h"
47 #include "mediastation/actors/stage.h"
48 
49 namespace MediaStation {
50 
51 struct MediaStationGameDescription;
52 class HotspotActor;
53 class RootStage;
54 class Bitmap;
55 
56 // Most Media Station titles follow this file structure from the root directory
57 // of the CD-ROM:
58 // - [TITLE].EXE (main game executable, name vares based on game)
59 // - DATA/ (subdirectory that holds actual game data including bytecode)
60 // - 100.CXT
61 // - ... other CXTs, varies per title
62 static const char *const directoryGlobs[] = {
63  "DATA", // For most titles
64  "program", // For D.W. the Picky Eater
65  "PZDATA", // For Puzzle Castle demo
66  nullptr
67 };
68 
69 class MediaStationEngine : public Engine {
70 public:
71  MediaStationEngine(OSystem *syst, const ADGameDescription *gameDesc);
72  ~MediaStationEngine() override;
73 
74  uint32 getFeatures() const;
75  Common::String getGameId() const;
76  Common::Platform getPlatform() const;
77  const char *getAppName() const;
78  bool hasFeature(EngineFeature f) const override {
79  return
81  };
82 
83  bool isFirstGenerationEngine();
84  void processEvents();
85  void addDirtyRect(const Common::Rect &rect);
86  void draw(bool dirtyOnly = true);
87 
88  void registerActor(Actor *actorToAdd);
89  void destroyActor(uint actorId);
90 
91  void scheduleScreenBranch(uint screenId);
92  void scheduleContextRelease(uint contextId);
93  void readUnrecognizedFromStream(Chunk &chunk, uint sectionType);
94  void releaseContext(uint32 contextId);
95 
96  Actor *getActorById(uint actorId);
97  SpatialEntity *getSpatialEntityById(uint spatialEntityId);
98  Actor *getActorByChunkReference(uint chunkReference);
99  ScriptValue *getVariable(uint variableId);
100  VideoDisplayManager *getDisplayManager() { return _displayManager; }
101  CursorManager *getCursorManager() { return _cursorManager; }
102  FunctionManager *getFunctionManager() { return _functionManager; }
103  RootStage *getRootStage() { return _stageDirector->getRootStage(); }
104 
105  Common::Array<ParameterClient *> _parameterClients;
106 
107  SpatialEntity *getMouseInsideHotspot() { return _mouseInsideHotspot; }
108  void setMouseInsideHotspot(SpatialEntity *entity) { _mouseInsideHotspot = entity; }
109  void clearMouseInsideHotspot() { _mouseInsideHotspot = nullptr; }
110 
111  SpatialEntity *getMouseDownHotspot() { return _mouseDownHotspot; }
112  void setMouseDownHotspot(SpatialEntity *entity) { _mouseDownHotspot = entity; }
113  void clearMouseDownHotspot() { _mouseDownHotspot = nullptr; }
114 
115  Common::RandomSource _randomSource;
116 
117  Context *_currentContext = nullptr;
118 
119  static const uint SCREEN_WIDTH = 640;
120  static const uint SCREEN_HEIGHT = 480;
121 
122 protected:
123  Common::Error run() override;
124 
125 private:
126  Common::Event _event;
127  Common::FSNode _gameDataDir;
128  const ADGameDescription *_gameDescription;
129 
130  VideoDisplayManager *_displayManager = nullptr;
131  CursorManager *_cursorManager = nullptr;
132  FunctionManager *_functionManager = nullptr;
133  Document *_document = nullptr;
134  DeviceOwner *_deviceOwner = nullptr;
135  StageDirector *_stageDirector = nullptr;
136 
137  Boot *_boot = nullptr;
139  Common::HashMap<uint, Context *> _loadedContexts;
140  SpatialEntity *_mouseInsideHotspot = nullptr;
141  SpatialEntity *_mouseDownHotspot = nullptr;
142  uint _requestedScreenBranchId = 0;
143  Common::Array<uint> _requestedContextReleaseId;
144 
145  void initDisplayManager();
146  void initCursorManager();
147  void initFunctionManager();
148  void initDocument();
149  void initDeviceOwner();
150  void initStageDirector();
151 
152  void doBranchToScreen();
153  Context *loadContext(uint32 contextId);
154 };
155 
157 #define SHOULD_QUIT ::MediaStation::g_engine->shouldQuit()
158 
159 } // End of namespace MediaStation
160 
161 #endif // MEDIASTATION_H
Definition: str.h:59
Definition: stage.h:115
EngineFeature
Definition: engine.h:258
Definition: actor.h:202
Definition: graphics.h:73
Definition: actor.h:33
Definition: error.h:81
Definition: context.h:55
Definition: array.h:52
Definition: advancedDetector.h:164
Definition: random.h:44
Definition: datafile.h:102
Definition: stage.h:83
Definition: rect.h:524
Definition: cursors.h:51
Definition: function.h:48
Engine * g_engine
Definition: engine.h:272
bool hasFeature(EngineFeature f) const override
Definition: mediastation.h:78
Definition: boot.h:164
Definition: clients.h:56
Definition: hashmap.h:85
Definition: events.h:210
Definition: fs.h:69
Definition: mediastation.h:69
Definition: system.h:163
Definition: actor.h:155
Definition: engine.h:144
Common::Error run() override
Definition: scriptvalue.h:36
Platform
Definition: platform.h:93
Definition: clients.h:42