| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
#include "GUIComponent.h" |
| 12 |
#include "cores/AudioEngine/Interfaces/AESound.h" |
| 13 |
#include "settings/lib/ISettingCallback.h" |
| 14 |
#include "threads/CriticalSection.h" |
| 15 |
|
| 16 |
#include <map> |
| 17 |
#include <memory> |
| 18 |
#include <string> |
| 19 |
|
| 20 |
|
| 21 |
class CAction; |
| 22 |
class CSettings; |
| 23 |
class TiXmlNode; |
| 24 |
class IAESound; |
| 25 |
|
| 26 |
enum WINDOW_SOUND { SOUND_INIT = 0, SOUND_DEINIT }; |
| 27 |
|
| 28 |
class CGUIAudioManager : public ISettingCallback |
| 29 |
{ |
| 30 |
class CWindowSounds |
| 31 |
{ |
| 32 |
public: |
| 33 |
std::shared_ptr<IAESound> initSound; |
| 34 |
std::shared_ptr<IAESound> deInitSound; |
| 35 |
}; |
| 36 |
|
| 37 |
struct IAESoundDeleter |
| 38 |
{ |
| 39 |
void operator()(IAESound* s); |
| 40 |
}; |
| 41 |
|
| 42 |
public: |
| 43 |
CGUIAudioManager(); |
| 44 |
~CGUIAudioManager() override; |
| 45 |
|
| 46 |
void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override; |
| 47 |
bool OnSettingUpdate(const std::shared_ptr<CSetting>& setting, |
| 48 |
const char* oldSettingId, |
| 49 |
const TiXmlNode* oldSettingNode) override; |
| 50 |
|
| 51 |
void Initialize(); |
| 52 |
void DeInitialize(); |
| 53 |
|
| 54 |
bool Load(); |
| 55 |
void UnLoad(); |
| 56 |
|
| 57 |
|
| 58 |
void PlayActionSound(const CAction& action); |
| 59 |
void PlayWindowSound(int id, WINDOW_SOUND event); |
| 60 |
void PlayPythonSound(const std::string& strFileName, bool useCached = true); |
| 61 |
|
| 62 |
void Enable(bool bEnable); |
| 63 |
void SetVolume(float level); |
| 64 |
void Stop(); |
| 65 |
|
| 66 |
private: |
| 67 |
|
| 68 |
std::shared_ptr<CSettings> m_settings; |
| 69 |
|
| 70 |
typedef std::map<const std::string, std::weak_ptr<IAESound>> soundCache; |
| 71 |
typedef std::map<int, std::shared_ptr<IAESound>> actionSoundMap; |
| 72 |
typedef std::map<int, CWindowSounds> windowSoundMap; |
| 73 |
typedef std::map<const std::string, std::shared_ptr<IAESound>> pythonSoundsMap; |
| 74 |
|
| 75 |
soundCache m_soundCache; |
| 76 |
actionSoundMap m_actionSoundMap; |
| 77 |
windowSoundMap m_windowSoundMap; |
| 78 |
pythonSoundsMap m_pythonSounds; |
| 79 |
|
| 80 |
std::string m_strMediaDir; |
| 81 |
bool m_bEnabled; |
| 82 |
|
| 83 |
CCriticalSection m_cs; |
| 84 |
|
| 85 |
std::shared_ptr<IAESound> LoadSound(const std::string& filename); |
| 86 |
std::shared_ptr<IAESound> LoadWindowSound(TiXmlNode* pWindowNode, |
| 87 |
const std::string& strIdentifier); |
| 88 |
}; |
| 89 |
|