ddnet/src/game/client/components/sounds.h

68 lines
1.5 KiB
C
Raw Normal View History

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
#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>
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,
};
struct QueueEntry
{
int m_Channel;
int m_SetId;
} m_aQueue[QUEUE_SIZE];
2010-05-29 07:25:38 +00:00
int m_QueuePos;
int64 m_QueueWaitTime;
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
2014-10-23 13:53:23 +00:00
float m_MapSoundVolume;
float m_BackgroundMusicVolume;
2014-10-12 15:02:47 +00:00
2010-05-29 07:25:38 +00:00
public:
// sound channels
enum
{
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();
virtual void OnStateChange(int NewState, int OldState);
2010-05-29 07:25:38 +00:00
virtual void OnRender();
2010-05-29 07:25:38 +00:00
void ClearQueue();
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);
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