diff --git a/src/engine/client/sound.cpp b/src/engine/client/sound.cpp index f94797bc0..f803c066c 100644 --- a/src/engine/client/sound.cpp +++ b/src/engine/client/sound.cpp @@ -206,10 +206,13 @@ static void Mix(short *pFinalOut, unsigned Frames) if(InVoiceField) { // panning - if(dx > 0) - Lvol = ((RangeX-p)*Lvol)/RangeX; - else - Rvol = ((RangeX-p)*Rvol)/RangeX; + if(!(v->m_Flags&ISound::FLAG_NO_PANNING)) + { + if(dx > 0) + Lvol = ((RangeX-p)*Lvol)/RangeX; + else + Rvol = ((RangeX-p)*Rvol)/RangeX; + } { Lvol *= FalloffX; diff --git a/src/engine/sound.h b/src/engine/sound.h index dddea910f..db69a9fc8 100644 --- a/src/engine/sound.h +++ b/src/engine/sound.h @@ -11,9 +11,10 @@ class ISound : public IInterface public: enum { - FLAG_LOOP=1, - FLAG_POS=2, - FLAG_ALL=3 + FLAG_LOOP=1<<0, + FLAG_POS=1<<1, + FLAG_NO_PANNING=1<<2, + FLAG_ALL=FLAG_LOOP|FLAG_POS|FLAG_NO_PANNING, }; enum diff --git a/src/game/client/components/mapsounds.cpp b/src/game/client/components/mapsounds.cpp index 369348cf8..1097502da 100644 --- a/src/game/client/components/mapsounds.cpp +++ b/src/game/client/components/mapsounds.cpp @@ -120,6 +120,7 @@ void CMapSounds::OnRender() // need to enqueue int Flags = 0; if(pSource->m_pSource->m_Loop) Flags |= ISound::FLAG_LOOP; + if(!pSource->m_pSource->m_Pan) Flags |= ISound::FLAG_NO_PANNING; pSource->m_Voice = m_pClient->m_pSounds->PlaySampleAt(CSounds::CHN_MAPSOUND, m_aSounds[pSource->m_Sound], 1.0f, vec2(fx2f(pSource->m_pSource->m_Position.x), fx2f(pSource->m_pSource->m_Position.y)), Flags); Sound()->SetVoiceTimeOffset(pSource->m_Voice, offset); diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index dc629b80a..81d36f858 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -1230,7 +1230,7 @@ void CEditor::DoSoundSource(CSoundSource *pSource, int Index) m_Map.m_UndoModified++; static int s_SourcePopupID = 0; - UiInvokePopupMenu(&s_SourcePopupID, 0, UI()->MouseX(), UI()->MouseY(), 120, 180, PopupSource); + UiInvokePopupMenu(&s_SourcePopupID, 0, UI()->MouseX(), UI()->MouseY(), 120, 200, PopupSource); m_LockMouse = false; s_Operation = OP_NONE; UI()->SetActiveItem(0); diff --git a/src/game/editor/layer_sounds.cpp b/src/game/editor/layer_sounds.cpp index a3fe4cb75..1b00d0d4e 100644 --- a/src/game/editor/layer_sounds.cpp +++ b/src/game/editor/layer_sounds.cpp @@ -109,6 +109,7 @@ CSoundSource *CLayerSounds::NewSource() pSource->m_Position.y = 0; pSource->m_Loop = 1; + pSource->m_Pan = 1; pSource->m_TimeDelay = 0; pSource->m_PosEnv = -1; @@ -116,15 +117,16 @@ CSoundSource *CLayerSounds::NewSource() pSource->m_SoundEnv = -1; pSource->m_SoundEnvOffset = 0; - pSource->m_Falloff = 255; - /* + pSource->m_Falloff = 80; + pSource->m_Shape.m_Type = CSoundShape::SHAPE_CIRCLE; pSource->m_Shape.m_Circle.m_Radius = 1500; - */ + /* pSource->m_Shape.m_Type = CSoundShape::SHAPE_RECTANGLE; pSource->m_Shape.m_Rectangle.m_Width = f2fx(1500.0f); pSource->m_Shape.m_Rectangle.m_Height = f2fx(1000.0f); + */ return pSource; } diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index f142a3c53..3967e5086 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -635,6 +635,8 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View) "Circle" }; + pSource->m_Shape.m_Type = pSource->m_Shape.m_Type%CSoundShape::NUM_SHAPES; // prevent out of array errors + if(pEditor->DoButton_Editor(&s_ShapeTypeButton, s_aShapeNames[pSource->m_Shape.m_Type], 0, &ShapeButton, 0, "Change shape")) { pSource->m_Shape.m_Type = (pSource->m_Shape.m_Type+1)%CSoundShape::NUM_SHAPES; @@ -662,6 +664,7 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View) PROP_POS_X=0, PROP_POS_Y, PROP_LOOP, + PROP_PAN, PROP_TIME_DELAY, PROP_FALLOFF, PROP_POS_ENV, @@ -675,6 +678,7 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View) {"Pos X", pSource->m_Position.x/1000, PROPTYPE_INT_SCROLL, -1000000, 1000000}, {"Pos Y", pSource->m_Position.y/1000, PROPTYPE_INT_SCROLL, -1000000, 1000000}, {"Loop", pSource->m_Loop, PROPTYPE_BOOL, 0, 1}, + {"Pan", pSource->m_Pan, PROPTYPE_BOOL, 0, 1}, {"Delay", pSource->m_TimeDelay, PROPTYPE_INT_SCROLL, 0, 1000000}, {"Falloff", pSource->m_Falloff, PROPTYPE_INT_SCROLL, 0, 255}, {"Pos. Env", pSource->m_PosEnv+1, PROPTYPE_INT_STEP, 0, pEditor->m_Map.m_lEnvelopes.size()+1}, @@ -696,6 +700,7 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View) if(Prop == PROP_POS_X) pSource->m_Position.x = NewVal*1000; if(Prop == PROP_POS_Y) pSource->m_Position.y = NewVal*1000; if(Prop == PROP_LOOP) pSource->m_Loop = NewVal; + if(Prop == PROP_PAN) pSource->m_Pan = NewVal; if(Prop == PROP_TIME_DELAY) pSource->m_TimeDelay = NewVal; if(Prop == PROP_FALLOFF) pSource->m_Falloff = NewVal; if(Prop == PROP_POS_ENV) diff --git a/src/game/mapitems.h b/src/game/mapitems.h index 3158c6541..6d8b06855 100644 --- a/src/game/mapitems.h +++ b/src/game/mapitems.h @@ -362,6 +362,7 @@ struct CSoundSource { CPoint m_Position; int m_Loop; + int m_Pan; // 0 - no panning, 1 - panning int m_TimeDelay; // in s int m_Falloff; // [0,255] // 0 - No falloff, 255 - full