mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 18:18:18 +00:00
Start adding support for custom shaped audio fields
Add version check for sound layers
This commit is contained in:
parent
7b4111749a
commit
d1327742e7
|
@ -63,6 +63,9 @@ void CMapSounds::OnMapLoad()
|
||||||
{
|
{
|
||||||
CMapItemLayerSounds *pSoundLayer = (CMapItemLayerSounds *)pLayer;
|
CMapItemLayerSounds *pSoundLayer = (CMapItemLayerSounds *)pLayer;
|
||||||
|
|
||||||
|
if(pSoundLayer->m_Version < 1 || pSoundLayer->m_Version > CMapItemLayerSounds::CURRENT_VERSION)
|
||||||
|
continue;
|
||||||
|
|
||||||
if(pSoundLayer->m_Sound == -1)
|
if(pSoundLayer->m_Sound == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -150,6 +153,9 @@ void CMapSounds::OnRender()
|
||||||
{
|
{
|
||||||
CMapItemLayerSounds *pSoundLayer = (CMapItemLayerSounds *)pLayer;
|
CMapItemLayerSounds *pSoundLayer = (CMapItemLayerSounds *)pLayer;
|
||||||
|
|
||||||
|
if(pSoundLayer->m_Version < 1 || pSoundLayer->m_Version > CMapItemLayerSounds::CURRENT_VERSION)
|
||||||
|
continue;
|
||||||
|
|
||||||
CSoundSource *pSources = (CSoundSource *)Layers()->Map()->GetDataSwapped(pSoundLayer->m_Data);
|
CSoundSource *pSources = (CSoundSource *)Layers()->Map()->GetDataSwapped(pSoundLayer->m_Data);
|
||||||
|
|
||||||
if(!pSources)
|
if(!pSources)
|
||||||
|
|
|
@ -996,6 +996,9 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
|
||||||
else if(pLayerItem->m_Type == LAYERTYPE_SOUNDS)
|
else if(pLayerItem->m_Type == LAYERTYPE_SOUNDS)
|
||||||
{
|
{
|
||||||
CMapItemLayerSounds *pSoundsItem = (CMapItemLayerSounds *)pLayerItem;
|
CMapItemLayerSounds *pSoundsItem = (CMapItemLayerSounds *)pLayerItem;
|
||||||
|
if(pSoundsItem->m_Version < 1 || pSoundsItem->m_Version > CMapItemLayerSounds::CURRENT_VERSION)
|
||||||
|
continue;
|
||||||
|
|
||||||
CLayerSounds *pSounds = new CLayerSounds;
|
CLayerSounds *pSounds = new CLayerSounds;
|
||||||
pSounds->m_pEditor = m_pEditor;
|
pSounds->m_pEditor = m_pEditor;
|
||||||
pLayer = pSounds;
|
pLayer = pSounds;
|
||||||
|
|
|
@ -18,6 +18,7 @@ enum
|
||||||
LAYERTYPE_SPEEDUP,
|
LAYERTYPE_SPEEDUP,
|
||||||
LAYERTYPE_SWITCH,
|
LAYERTYPE_SWITCH,
|
||||||
LAYERTYPE_TUNE,
|
LAYERTYPE_TUNE,
|
||||||
|
LAYERTYPE_SOUNDS_DEPRECATED, // deprecated! do not use this, this is just for compatibility reasons
|
||||||
LAYERTYPE_SOUNDS,
|
LAYERTYPE_SOUNDS,
|
||||||
|
|
||||||
MAPITEMTYPE_VERSION=0,
|
MAPITEMTYPE_VERSION=0,
|
||||||
|
@ -329,23 +330,55 @@ struct CMapItemEnvelope : public CMapItemEnvelope_v1
|
||||||
int m_Synchronized;
|
int m_Synchronized;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct CSoundShape
|
||||||
|
{
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
SHAPE_RECTANGLE,
|
||||||
|
SHAPE_CIRCLE,
|
||||||
|
NUM_SHAPES,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CRectangle
|
||||||
|
{
|
||||||
|
int m_PosX, m_PosY; // fxp 22.10
|
||||||
|
int m_Width, m_Height; // fxp 22.10
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CCircle
|
||||||
|
{
|
||||||
|
int m_PosX, m_PosY; // fxp 22.10
|
||||||
|
int m_Radius; // fxp 22.10
|
||||||
|
};
|
||||||
|
|
||||||
|
int m_Type;
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
CRectangle m_Rectangle;
|
||||||
|
CCircle m_Circle;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
struct CSoundSource
|
struct CSoundSource
|
||||||
{
|
{
|
||||||
CPoint m_Position;
|
CPoint m_Position;
|
||||||
int m_Loop;
|
int m_Loop;
|
||||||
int m_TimeDelay; // in s
|
int m_TimeDelay; // in s
|
||||||
int m_FalloffDistance;
|
int m_FalloffDistance;
|
||||||
|
int m_Falloff; // [0,255] // 0 - No falloff, 255 - full
|
||||||
|
|
||||||
int m_PosEnv;
|
int m_PosEnv;
|
||||||
int m_PosEnvOffset;
|
int m_PosEnvOffset;
|
||||||
int m_SoundEnv;
|
int m_SoundEnv;
|
||||||
int m_SoundEnvOffset;
|
int m_SoundEnvOffset;
|
||||||
|
|
||||||
|
CSoundShape m_Shape;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CMapItemLayerSounds
|
struct CMapItemLayerSounds
|
||||||
{
|
{
|
||||||
enum { CURRENT_VERSION=1 };
|
enum { CURRENT_VERSION=2 };
|
||||||
|
|
||||||
CMapItemLayer m_Layer;
|
CMapItemLayer m_Layer;
|
||||||
int m_Version;
|
int m_Version;
|
||||||
|
|
Loading…
Reference in a new issue