mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Working on adding editor UI support for sound shapes
This commit is contained in:
parent
a045a20fba
commit
fbcd560eb0
|
@ -624,13 +624,46 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View)
|
|||
return 1;
|
||||
}
|
||||
|
||||
// Sound shape button
|
||||
CUIRect ShapeButton;
|
||||
View.HSplitBottom(5.0f, &View, 0x0);
|
||||
View.HSplitBottom(12.0f, &View, &ShapeButton);
|
||||
static int s_ShapeTypeButton = 0;
|
||||
|
||||
static const char *s_aShapeNames[] = {
|
||||
"Rectangle",
|
||||
"Circle"
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
// set default values
|
||||
switch(pSource->m_Shape.m_Type)
|
||||
{
|
||||
case CSoundShape::SHAPE_CIRCLE:
|
||||
{
|
||||
pSource->m_Shape.m_Circle.m_Radius = 1000.0f;
|
||||
break;
|
||||
}
|
||||
case CSoundShape::SHAPE_RECTANGLE:
|
||||
{
|
||||
pSource->m_Shape.m_Rectangle.m_Width = f2fx(1000.0f);
|
||||
pSource->m_Shape.m_Rectangle.m_Height = f2fx(800.0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_POS_X=0,
|
||||
PROP_POS_Y,
|
||||
PROP_LOOP,
|
||||
PROP_TIME_DELAY,
|
||||
PROP_DISTANCE,
|
||||
PROP_FALLOFF,
|
||||
PROP_POS_ENV,
|
||||
PROP_POS_ENV_OFFSET,
|
||||
PROP_SOUND_ENV,
|
||||
|
@ -643,6 +676,7 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View)
|
|||
{"Pos Y", pSource->m_Position.y/1000, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
||||
{"Loop", pSource->m_Loop, 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},
|
||||
{"Pos. TO", pSource->m_PosEnvOffset, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
||||
{"Sound Env", pSource->m_SoundEnv+1, PROPTYPE_INT_STEP, 0, pEditor->m_Map.m_lEnvelopes.size()+1},
|
||||
|
@ -651,6 +685,8 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View)
|
|||
{0},
|
||||
};
|
||||
|
||||
|
||||
|
||||
static int s_aIds[NUM_PROPS] = {0};
|
||||
int NewVal = 0;
|
||||
int Prop = pEditor->DoProperties(&View, aProps, s_aIds, &NewVal);
|
||||
|
@ -661,6 +697,7 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View)
|
|||
if(Prop == PROP_POS_Y) pSource->m_Position.y = NewVal*1000;
|
||||
if(Prop == PROP_LOOP) pSource->m_Loop = NewVal;
|
||||
if(Prop == PROP_TIME_DELAY) pSource->m_TimeDelay = NewVal;
|
||||
if(Prop == PROP_FALLOFF) pSource->m_Falloff = NewVal;
|
||||
if(Prop == PROP_POS_ENV)
|
||||
{
|
||||
int Index = clamp(NewVal-1, -1, pEditor->m_Map.m_lEnvelopes.size()-1);
|
||||
|
@ -692,6 +729,42 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View)
|
|||
}
|
||||
if(Prop == PROP_SOUND_ENV_OFFSET) pSource->m_SoundEnvOffset = NewVal;
|
||||
|
||||
// source shape properties
|
||||
switch(pSource->m_Shape.m_Type)
|
||||
{
|
||||
case CSoundShape::SHAPE_CIRCLE:
|
||||
{
|
||||
enum
|
||||
{
|
||||
PROP_CIRCLE_RADIUS=0,
|
||||
NUM_CIRCLE_PROPS,
|
||||
};
|
||||
|
||||
CProperty aCircleProps[] = {
|
||||
{"Radius", pSource->m_Shape.m_Circle.m_Radius, PROPTYPE_INT_SCROLL, 0, 1000000},
|
||||
|
||||
{0},
|
||||
};
|
||||
|
||||
static int s_aCircleIds[NUM_CIRCLE_PROPS] = {0};
|
||||
|
||||
NewVal = 0;
|
||||
Prop = pEditor->DoProperties(&View, aCircleProps, s_aCircleIds, &NewVal);
|
||||
if(Prop != -1)
|
||||
pEditor->m_Map.m_Modified = true;
|
||||
|
||||
if(Prop == PROP_CIRCLE_RADIUS) pSource->m_Shape.m_Circle.m_Radius = NewVal;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CSoundShape::SHAPE_RECTANGLE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -334,7 +334,7 @@ struct CSoundShape
|
|||
{
|
||||
enum
|
||||
{
|
||||
SHAPE_RECTANGLE,
|
||||
SHAPE_RECTANGLE = 0,
|
||||
SHAPE_CIRCLE,
|
||||
NUM_SHAPES,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue