ScummVM API documentation
clients.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_CLIENTS_H
23#define MEDIASTATION_CLIENTS_H
24
25#include "common/array.h"
26#include "common/hashmap.h"
27
28#include "mediastation/datafile.h"
29
30namespace MediaStation {
31
32class ScreenActor;
33
35public:
37 virtual ~ParameterClient();
38
39 virtual bool attemptToReadFromStream(Chunk &chunk, uint sectionType) = 0;
40};
41
42enum DeviceOwnerSectionType {
43 kDeviceOwnerAllowMultipleSounds = 0x35,
44 kDeviceOwnerAllowMultipleStreams = 0x36,
45};
46
47enum ImtDeviceType {
48 kImtDeviceTypeSound = 2,
49 kImtDeviceTypeStream = 3,
50};
51
53public:
54 virtual ~ImtDeviceUser() {};
55 virtual bool giveUpDevice() = 0;
56
57 void grantDevice(ImtDeviceType type);
58 void releaseDevice(ImtDeviceType type);
59};
60
61// Pooh scripts rely on a sound mutex to stop overlapping sounds/movies.
62// Pooh is the only known title that relies on this behavior, and no known
63// titles rely on the stream mutex behavior, but it is present in the original
64// so is implemnted here.
66public:
68 virtual bool attemptToReadFromStream(Chunk &chunk, uint sectionType) override;
69
70 bool hasExclusiveAccessTo(ImtDeviceType type);
71 bool grantDevice(ImtDeviceUser *user, ImtDeviceType type);
72 void releaseDevice(ImtDeviceUser *user, ImtDeviceType type);
73 bool releaseAll();
74
75 void setMultipleSounds(bool allowMultipleSounds);
76 void setMultipleStreams(bool allowMultipleStreams);
77
78private:
79 bool _exclusiveAccessToSounds = true;
80 bool _exclusiveAccessToStreams = true;
81
82 void forceReleaseDevice(ImtDeviceType type);
83
85};
86
87enum DocumentSectionType {
88 kDocumentContextLoadComplete = 0x10,
89 kDocumentStartupInformation = 0x2e,
90 kDocumentEntryScreen = 0x2f,
91};
92
93class Document : public ParameterClient, public ImtDeviceUser {
94friend class Debugger;
95
96public:
97 virtual bool attemptToReadFromStream(Chunk &chunk, uint sectionType) override;
98 virtual bool giveUpDevice() override;
99 void readStartupInformation(Chunk &chunk);
100 void readContextLoadComplete(Chunk &chunk);
101
102 void beginTitle();
103 void startContextLoad(uint contextId);
104 bool isContextLoadInProgress(uint contextId);
105 void branchToScreen(uint screenId, bool disableScreenAutoUpdate);
106
107 void streamDidClose(uint streamId);
108 void streamDidFinish(uint streamId);
109 // These implementations are left empty because they are empty in the original,
110 // but they are kept because they are technically still defined in the original.
111 void streamDidOpen(uint streamId) {};
112 void streamWillRead(uint streamId) {};
113
114 uint contextIdForScreenActorId(uint screenActorId);
115 void addToContextLoadQueue(uint contextId);
116 void removeFromContextLoadQueue(uint contextId);
117 bool isContextLoadQueued(uint contextId);
118 void contextReleaseComplete(uint contextId);
119 void contextAlreadyReleased(uint contextId);
120
121 Common::String getDebugString();
122
123private:
124 uint _currentScreenActorId = 0;
125 StreamFeed *_currentStreamFeed = nullptr;
126 Common::Array<uint> _contextLoadQueue;
127 bool _entryPointScreenIdWasOverridden = false;
128 uint _entryPointScreenId = 0;
129 uint _entryPointStreamId = 0;
130 uint _loadingContextId = 0;
131 uint _loadingScreenActorId = 0;
132 uint _disabledScreenAutoUpdateToken = 0;
133
134 void contextLoadDidComplete();
135 void screenLoadDidComplete();
136 void startFeed(uint streamId);
137 // This is named stopFeed in the original, but it is a bit of a misnomer
138 // because it also closes the stream feed. In the lower-level stream feed manager
139 // and stream feeds themselves, stopping the stream feed and closing it is
140 // two separate operations.
141 void stopFeed();
142 void blowAwayCurrentScreen();
143 void preloadParentContexts(uint contextId);
144 void checkQueuedContextLoads();
145};
146
147} // End of namespace MediaStation
148
149#endif
Definition: hashmap.h:85
Definition: str.h:59
Definition: datafile.h:99
Definition: debugger.h:31
Definition: clients.h:93
Definition: clients.h:65
Definition: clients.h:52
Definition: clients.h:34
Definition: datafile.h:176