Add editor properties for rectangle shaped sources and visualize falloff distance

This commit is contained in:
BeaR 2014-11-29 13:20:04 +01:00
parent fbcd560eb0
commit 485aa4ce54
2 changed files with 35 additions and 1 deletions

View file

@ -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;
}
}

View file

@ -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;
}
}