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/detection.h"
39 #include "mediastation/datafile.h"
40 #include "mediastation/boot.h"
41 #include "mediastation/context.h"
42 #include "mediastation/asset.h"
43 #include "mediastation/cursors.h"
44 #include "mediastation/graphics.h"
45 
46 namespace MediaStation {
47 
48 struct MediaStationGameDescription;
49 class Hotspot;
50 class Bitmap;
51 
52 // Most Media Station titles follow this file structure from the root directory
53 // of the CD-ROM:
54 // - [TITLE].EXE (main game executable, name vares based on game)
55 // - DATA/ (subdirectory that holds actual game data including bytecode)
56 // - 100.CXT
57 // - ... other CXTs, varies per title
58 static const char *const directoryGlobs[] = {
59  "DATA", // For most titles
60  "program", // For D.W. the Picky Eater
61  "PZDATA", // For Puzzle Castle demo
62  nullptr
63 };
64 
65 class MediaStationEngine : public Engine {
66 public:
67  MediaStationEngine(OSystem *syst, const ADGameDescription *gameDesc);
68  ~MediaStationEngine() override;
69 
70  uint32 getFeatures() const;
71  Common::String getGameId() const;
72  Common::Platform getPlatform() const;
73  const char *getAppName() const;
74  bool hasFeature(EngineFeature f) const override {
75  return
77  };
78 
79  bool isFirstGenerationEngine();
80  void processEvents();
81  void refreshActiveHotspot();
82  void addDirtyRect(const Common::Rect &rect) { _dirtyRects.push_back(rect); }
83  void draw();
84 
85  void registerAsset(Asset *assetToAdd);
86  void scheduleScreenBranch(uint screenId);
87  void scheduleContextRelease(uint contextId);
88 
89  Asset *getAssetById(uint assetId);
90  Asset *getAssetByChunkReference(uint chunkReference);
91  Function *getFunctionById(uint functionId);
92  ScriptValue *getVariable(uint variableId);
93  VideoDisplayManager *getDisplayManager() { return _displayManager; }
94 
95  ScriptValue callBuiltInFunction(BuiltInFunction function, Common::Array<ScriptValue> &args);
96  Common::RandomSource _randomSource;
97 
98  Context *_currentContext = nullptr;
99 
100  Common::Point _mousePos;
101  bool _needsHotspotRefresh = false;
102 
103 protected:
104  Common::Error run() override;
105 
106 private:
107  Common::Event _event;
108  Common::FSNode _gameDataDir;
109  const ADGameDescription *_gameDescription;
110  Common::Array<Common::Rect> _dirtyRects;
111 
112  // In Media Station, only the cursors are stored in the executable; everything
113  // else is in the Context (*.CXT) data files.
114  CursorManager *_cursor;
115  void setCursor(uint id);
116 
117  VideoDisplayManager *_displayManager = nullptr;
118 
119  Boot *_boot = nullptr;
120  Common::Array<Asset *> _assets;
122  Common::HashMap<uint, Context *> _loadedContexts;
123  Asset *_currentHotspot = nullptr;
124  uint _requestedScreenBranchId = 0;
125  Common::Array<uint> _requestedContextReleaseId;
126 
127  void doBranchToScreen();
128  Context *loadContext(uint32 contextId);
129  void releaseContext(uint32 contextId);
130  Asset *findAssetToAcceptMouseEvents();
131 
132  static int compareAssetByZIndex(const SpatialEntity *a, const SpatialEntity *b);
133 };
134 
136 #define SHOULD_QUIT ::MediaStation::g_engine->shouldQuit()
137 
138 } // End of namespace MediaStation
139 
140 #endif // MEDIASTATION_H
Definition: str.h:59
EngineFeature
Definition: engine.h:260
Definition: asset.h:167
Definition: graphics.h:64
Definition: asset.h:32
Definition: error.h:81
Definition: context.h:58
Definition: advancedDetector.h:164
Definition: random.h:44
Definition: rect.h:524
Definition: cursors.h:35
Definition: asset.h:122
Engine * g_engine
Definition: engine.h:274
bool hasFeature(EngineFeature f) const override
Definition: mediastation.h:74
Definition: function.h:32
Definition: boot.h:168
void push_back(const T &element)
Definition: array.h:183
Definition: hashmap.h:85
Definition: events.h:210
Definition: fs.h:69
Definition: mediastation.h:65
Definition: rect.h:144
Definition: array.h:561
Definition: system.h:163
Definition: engine.h:146
Common::Error run() override
Definition: scriptvalue.h:36
Platform
Definition: platform.h:46