ScummVM API documentation
media_manager.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 HARVESTER_MEDIA_MANAGER_H
23 #define HARVESTER_MEDIA_MANAGER_H
24 
25 #include "audio/mixer.h"
26 #include "common/array.h"
27 #include "common/str.h"
28 
29 namespace Graphics {
30 class Screen;
31 }
32 
33 namespace Harvester {
34 
35 class Art;
36 class ResourceManager;
37 class EntityManager;
38 struct AudioCommand;
39 class Text;
40 
41 class MediaManager {
42 public:
43  explicit MediaManager(ResourceManager &resources);
44  ~MediaManager();
45 
46  EntityManager *getRuntimeEntities() const { return _entityManager; }
47  Graphics::Screen *getScreen() const { return _screen; }
48  int getDisplayWidth() const { return _displayWidth; }
49  int getDisplayHeight() const { return _displayHeight; }
50  Art *getArt() const { return _art; }
51  Text *getText() const { return _text; }
52  const Common::String &getMusicPath() const { return _musicPath; }
53 
54  static float mapGammaLevelToBrightnessScale(int level);
55 
56  void resetScreen(int width, int height);
57  bool loadArt();
58  bool loadText();
59  bool loadQuickTipsResources();
60  void drawWaitFrame() const;
61  void applyMixerLevels(int fxLevel, int musicLevel);
62  bool isMusicPlaying() const;
63  bool playMusic(const Common::String &path);
64  void pauseMusic(bool paused);
65  void stopMusic();
66  bool executeAudioCommand(const AudioCommand &command);
67  bool playSound(const Common::String &path);
68  bool playSingleSound(const Common::String &path);
69  void stopSingleSound();
70  bool isSingleSoundPlaying() const;
71  bool playSpeech(const Common::String &path);
72  void stopSpeech();
73  bool isSpeechPlaying() const;
74  bool loadSound(int slot, const Common::String &path);
75  bool playLoadedSound(int slot);
76  bool deleteLoadedSound(int slot);
77  void stopSound();
78 
79 private:
80  void stopSoundHandle(Audio::SoundHandle &handle);
81  bool validateLoadedSoundSlot(int slot) const;
82 
83  ResourceManager &_resources;
84  EntityManager *_entityManager = nullptr;
85  Graphics::Screen *_screen = nullptr;
86  int _displayWidth = 0;
87  int _displayHeight = 0;
88  Art *_art = nullptr;
89  Text *_text = nullptr;
90  Audio::SoundHandle _musicHandle;
91  Audio::SoundHandle _singleSoundHandle;
92  Audio::SoundHandle _speechHandle;
93  Common::String _musicPath;
94  int _soundSlotIndex = -1;
95  Common::String _soundPaths[8];
96  Audio::SoundHandle _soundHandles[8];
97  Common::String _loadedSoundPaths[4];
98  Common::Array<byte> _loadedSoundData[4];
99  Audio::SoundHandle _loadedSoundHandles[4];
100 };
101 
102 } // End of namespace Harvester
103 
104 #endif // HARVESTER_MEDIA_MANAGER_H
Definition: str.h:59
Definition: art.h:31
Definition: atari-screen.h:58
Definition: text.h:47
Definition: screen.h:47
Definition: media_manager.h:41
Definition: mixer.h:49
Definition: runtime_entity.h:180
Definition: art.h:50
Definition: formatinfo.h:28
Definition: script.h:231
Definition: resources.h:32