2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#ifndef GAME_CLIENT_COMPONENTS_SOUNDS_H
|
|
|
|
#define GAME_CLIENT_COMPONENTS_SOUNDS_H
|
2017-11-23 14:47:38 +00:00
|
|
|
#include <engine/engine.h>
|
2014-10-12 14:12:13 +00:00
|
|
|
#include <engine/sound.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/client/component.h>
|
|
|
|
|
2017-11-23 14:47:38 +00:00
|
|
|
class CSoundLoading : public IJob
|
|
|
|
{
|
|
|
|
CGameClient *m_pGameClient;
|
|
|
|
bool m_Render;
|
|
|
|
|
|
|
|
public:
|
|
|
|
CSoundLoading(CGameClient *pGameClient, bool Render);
|
|
|
|
void Run();
|
|
|
|
};
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
class CSounds : public CComponent
|
|
|
|
{
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
QUEUE_SIZE = 32,
|
|
|
|
};
|
2011-04-13 18:00:54 +00:00
|
|
|
struct QueueEntry
|
|
|
|
{
|
|
|
|
int m_Channel;
|
|
|
|
int m_SetId;
|
|
|
|
} m_aQueue[QUEUE_SIZE];
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_QueuePos;
|
2021-06-23 05:05:49 +00:00
|
|
|
int64_t m_QueueWaitTime;
|
2017-11-23 14:47:38 +00:00
|
|
|
std::shared_ptr<CSoundLoading> m_pSoundJob;
|
2011-02-27 16:56:03 +00:00
|
|
|
bool m_WaitForSoundJob;
|
2015-07-09 00:08:14 +00:00
|
|
|
|
2012-01-06 18:38:40 +00:00
|
|
|
int GetSampleId(int SetId);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2020-10-09 21:14:20 +00:00
|
|
|
float m_GuiSoundVolume;
|
|
|
|
float m_GameSoundVolume;
|
2014-10-23 13:53:23 +00:00
|
|
|
float m_MapSoundVolume;
|
2020-09-30 08:06:54 +00:00
|
|
|
float m_BackgroundMusicVolume;
|
2014-10-12 15:02:47 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
public:
|
|
|
|
// sound channels
|
|
|
|
enum
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CHN_GUI = 0,
|
2010-05-29 07:25:38 +00:00
|
|
|
CHN_MUSIC,
|
|
|
|
CHN_WORLD,
|
|
|
|
CHN_GLOBAL,
|
2014-10-23 13:53:23 +00:00
|
|
|
CHN_MAPSOUND,
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
virtual void OnInit();
|
|
|
|
virtual void OnReset();
|
2011-06-27 21:26:01 +00:00
|
|
|
virtual void OnStateChange(int NewState, int OldState);
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void OnRender();
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void ClearQueue();
|
2011-04-13 18:00:54 +00:00
|
|
|
void Enqueue(int Channel, int SetId);
|
2012-01-06 18:38:40 +00:00
|
|
|
void Play(int Channel, int SetId, float Vol);
|
|
|
|
void PlayAt(int Channel, int SetId, float Vol, vec2 Pos);
|
2010-05-29 07:25:38 +00:00
|
|
|
void PlayAndRecord(int Channel, int SetId, float Vol, vec2 Pos);
|
2011-04-13 18:00:54 +00:00
|
|
|
void Stop(int SetId);
|
2014-10-10 17:10:57 +00:00
|
|
|
|
2014-10-12 14:12:13 +00:00
|
|
|
ISound::CVoiceHandle PlaySample(int Channel, int SampleId, float Vol, int Flags = 0);
|
|
|
|
ISound::CVoiceHandle PlaySampleAt(int Channel, int SampleId, float Vol, vec2 Pos, int Flags = 0);
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|