mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 18:18:18 +00:00
Add editor properties for rectangle shaped sources and visualize falloff distance
This commit is contained in:
parent
fbcd560eb0
commit
485aa4ce54
|
@ -46,6 +46,11 @@ void CLayerSounds::Render()
|
||||||
{
|
{
|
||||||
m_pEditor->RenderTools()->DrawCircle(fx2f(pSource->m_Position.x)+OffsetX, fx2f(pSource->m_Position.y)+OffsetY,
|
m_pEditor->RenderTools()->DrawCircle(fx2f(pSource->m_Position.x)+OffsetX, fx2f(pSource->m_Position.y)+OffsetY,
|
||||||
pSource->m_Shape.m_Circle.m_Radius, 32);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case CSoundShape::SHAPE_RECTANGLE:
|
case CSoundShape::SHAPE_RECTANGLE:
|
||||||
|
@ -54,6 +59,11 @@ void CLayerSounds::Render()
|
||||||
float Height = fx2f(pSource->m_Shape.m_Rectangle.m_Height);
|
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,
|
m_pEditor->RenderTools()->DrawRoundRect(fx2f(pSource->m_Position.x)+OffsetX - Width/2, fx2f(pSource->m_Position.y)+OffsetY - Height/2,
|
||||||
Width, Height, 0.0f);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -626,7 +626,7 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View)
|
||||||
|
|
||||||
// Sound shape button
|
// Sound shape button
|
||||||
CUIRect ShapeButton;
|
CUIRect ShapeButton;
|
||||||
View.HSplitBottom(5.0f, &View, 0x0);
|
View.HSplitBottom(3.0f, &View, 0x0);
|
||||||
View.HSplitBottom(12.0f, &View, &ShapeButton);
|
View.HSplitBottom(12.0f, &View, &ShapeButton);
|
||||||
static int s_ShapeTypeButton = 0;
|
static int s_ShapeTypeButton = 0;
|
||||||
|
|
||||||
|
@ -760,6 +760,30 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View)
|
||||||
|
|
||||||
case CSoundShape::SHAPE_RECTANGLE:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue