From 485aa4ce54658a6246106d52d01620e00ea09e94 Mon Sep 17 00:00:00 2001 From: BeaR Date: Sat, 29 Nov 2014 13:20:04 +0100 Subject: [PATCH] Add editor properties for rectangle shaped sources and visualize falloff distance --- src/game/editor/layer_sounds.cpp | 10 ++++++++++ src/game/editor/popups.cpp | 26 +++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/game/editor/layer_sounds.cpp b/src/game/editor/layer_sounds.cpp index fea83c517..a3fe4cb75 100644 --- a/src/game/editor/layer_sounds.cpp +++ b/src/game/editor/layer_sounds.cpp @@ -46,6 +46,11 @@ void CLayerSounds::Render() { m_pEditor->RenderTools()->DrawCircle(fx2f(pSource->m_Position.x)+OffsetX, fx2f(pSource->m_Position.y)+OffsetY, pSource->m_Shape.m_Circle.m_Radius, 32); + + float Falloff = ((float)pSource->m_Falloff/255.0f); + if(Falloff > 0.0f) + m_pEditor->RenderTools()->DrawCircle(fx2f(pSource->m_Position.x)+OffsetX, fx2f(pSource->m_Position.y)+OffsetY, + pSource->m_Shape.m_Circle.m_Radius*Falloff, 32); break; } case CSoundShape::SHAPE_RECTANGLE: @@ -54,6 +59,11 @@ void CLayerSounds::Render() float Height = fx2f(pSource->m_Shape.m_Rectangle.m_Height); m_pEditor->RenderTools()->DrawRoundRect(fx2f(pSource->m_Position.x)+OffsetX - Width/2, fx2f(pSource->m_Position.y)+OffsetY - Height/2, Width, Height, 0.0f); + + float Falloff = ((float)pSource->m_Falloff/255.0f); + if(Falloff > 0.0f) + m_pEditor->RenderTools()->DrawRoundRect(fx2f(pSource->m_Position.x)+OffsetX - Falloff*Width/2, fx2f(pSource->m_Position.y)+OffsetY - Falloff*Height/2, + Width*Falloff, Height*Falloff, 0.0f); break; } } diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index 34a0175b9..ddb1b6423 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -626,7 +626,7 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View) // Sound shape button CUIRect ShapeButton; - View.HSplitBottom(5.0f, &View, 0x0); + View.HSplitBottom(3.0f, &View, 0x0); View.HSplitBottom(12.0f, &View, &ShapeButton); static int s_ShapeTypeButton = 0; @@ -760,6 +760,30 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View) case CSoundShape::SHAPE_RECTANGLE: { + enum + { + PROP_RECTANGLE_WIDTH=0, + PROP_RECTANGLE_HEIGHT, + NUM_RECTANGLE_PROPS, + }; + + CProperty aRectangleProps[] = { + {"Width", pSource->m_Shape.m_Rectangle.m_Width/1024, PROPTYPE_INT_SCROLL, 0, 1000000}, + {"Height", pSource->m_Shape.m_Rectangle.m_Height/1024, PROPTYPE_INT_SCROLL, 0, 1000000}, + + {0}, + }; + + static int s_aRectangleIds[NUM_RECTANGLE_PROPS] = {0}; + + NewVal = 0; + Prop = pEditor->DoProperties(&View, aRectangleProps, s_aRectangleIds, &NewVal); + if(Prop != -1) + pEditor->m_Map.m_Modified = true; + + if(Prop == PROP_RECTANGLE_WIDTH) pSource->m_Shape.m_Rectangle.m_Width = NewVal*1024; + //if(Prop == PROP_RECTANGLE_HEIGHT) pSource->m_Shape.m_Rectangle.m_Height = NewVal*1024; + break; } }