mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Start adding a sound envelope
This commit is contained in:
parent
dfea1e9e71
commit
655c2466b9
|
@ -3872,6 +3872,17 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
|||
CUIRect Button;
|
||||
CEnvelope *pNewEnv = 0;
|
||||
|
||||
|
||||
ToolBar.VSplitRight(50.0f, &ToolBar, &Button);
|
||||
static int s_NewSoundButton = 0;
|
||||
if(DoButton_Editor(&s_NewSoundButton, "Sound.+", 0, &Button, 0, "Creates a new sound envelope"))
|
||||
{
|
||||
m_Map.m_Modified = true;
|
||||
m_Map.m_UndoModified++;
|
||||
pNewEnv = m_Map.NewEnvelope(2);
|
||||
}
|
||||
|
||||
ToolBar.VSplitRight(5.0f, &ToolBar, &Button);
|
||||
ToolBar.VSplitRight(50.0f, &ToolBar, &Button);
|
||||
static int s_New4dButton = 0;
|
||||
if(DoButton_Editor(&s_New4dButton, "Color+", 0, &Button, 0, "Creates a new color envelope"))
|
||||
|
@ -3979,12 +3990,14 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
|||
|
||||
ToolBar.VSplitLeft(15.0f, &Button, &ToolBar);
|
||||
|
||||
static const char *s_paNames[2][4] = {
|
||||
static const char *s_paNames[3][4] = {
|
||||
{"V", "D", "", ""},
|
||||
{"X", "Y", "R", ""},
|
||||
{"R", "G", "B", "A"},
|
||||
};
|
||||
|
||||
const char *paDescriptions[2][4] = {
|
||||
const char *paDescriptions[3][4] = {
|
||||
{"Volume of the envelope", "Distance value of the envelope", "", ""},
|
||||
{"X-axis of the envelope", "Y-axis of the envelope", "Rotation of the envelope", ""},
|
||||
{"Red value of the envelope", "Green value of the envelope", "Blue value of the envelope", "Alpha value of the envelope"},
|
||||
};
|
||||
|
@ -4001,7 +4014,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
|||
else if(i == envelope->channels-1) draw_func = draw_editor_button_r;
|
||||
else draw_func = draw_editor_button_m;*/
|
||||
|
||||
if(DoButton_Editor(&s_aChannelButtons[i], s_paNames[pEnvelope->m_Channels-3][i], s_ActiveChannels&Bit, &Button, 0, paDescriptions[pEnvelope->m_Channels-3][i]))
|
||||
if(DoButton_Editor(&s_aChannelButtons[i], s_paNames[pEnvelope->m_Channels-2][i], s_ActiveChannels&Bit, &Button, 0, paDescriptions[pEnvelope->m_Channels-2][i]))
|
||||
s_ActiveChannels ^= Bit;
|
||||
}
|
||||
|
||||
|
|
|
@ -505,7 +505,7 @@ public:
|
|||
|
||||
void MakePalette();
|
||||
virtual void Render();
|
||||
|
||||
|
||||
int ConvertX(float x) const;
|
||||
int ConvertY(float y) const;
|
||||
void Convert(CUIRect Rect, RECTi *pOut);
|
||||
|
@ -1103,6 +1103,7 @@ public:
|
|||
|
||||
virtual int RenderProperties(CUIRect *pToolbox);
|
||||
|
||||
virtual void ModifyEnvelopeIndex(INDEX_MODIFY_FUNC pfnFunc);
|
||||
virtual void ModifySoundIndex(INDEX_MODIFY_FUNC pfnFunc);
|
||||
|
||||
int m_Sound;
|
||||
|
|
|
@ -47,6 +47,8 @@ CSoundSource *CLayerSounds::NewSource()
|
|||
pSource->m_Loop = 1;
|
||||
pSource->m_TimeDelay = 0;
|
||||
|
||||
pSource->m_SoundEnv = -1;
|
||||
|
||||
return pSource;
|
||||
}
|
||||
|
||||
|
@ -139,7 +141,13 @@ int CLayerSounds::RenderProperties(CUIRect *pToolBox)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void CLayerSounds::ModifySoundIndex(INDEX_MODIFY_FUNC pfnFunc)
|
||||
void CLayerSounds::ModifySoundIndex(INDEX_MODIFY_FUNC Func)
|
||||
{
|
||||
|
||||
Func(&m_Sound);
|
||||
}
|
||||
|
||||
void CLayerSounds::ModifyEnvelopeIndex(INDEX_MODIFY_FUNC Func)
|
||||
{
|
||||
for(int i = 0; i < m_lSources.size(); i++)
|
||||
Func(&m_lSources[i].m_SoundEnv);
|
||||
}
|
|
@ -631,6 +631,7 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View)
|
|||
PROP_GLOBAL,
|
||||
PROP_LOOP,
|
||||
PROP_TIME_DELAY,
|
||||
PROP_SOUND_ENV,
|
||||
NUM_PROPS,
|
||||
};
|
||||
|
||||
|
@ -640,6 +641,7 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View)
|
|||
{"Global", pSource->m_Global, PROPTYPE_BOOL, 0, 1},
|
||||
{"Loop", pSource->m_Loop, PROPTYPE_BOOL, 0, 1},
|
||||
{"Delay", pSource->m_TimeDelay, PROPTYPE_INT_SCROLL, 0, 1000000},
|
||||
{"Sound Env", pSource->m_SoundEnv+1, PROPTYPE_INT_STEP, 0, pEditor->m_Map.m_lEnvelopes.size()+1},
|
||||
|
||||
{0},
|
||||
};
|
||||
|
@ -655,6 +657,20 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View)
|
|||
if(Prop == PROP_GLOBAL) pSource->m_Global = NewVal;
|
||||
if(Prop == PROP_LOOP) pSource->m_Loop = NewVal;
|
||||
if(Prop == PROP_TIME_DELAY) pSource->m_TimeDelay = NewVal;
|
||||
if(Prop == PROP_SOUND_ENV)
|
||||
{
|
||||
int Index = clamp(NewVal-1, -1, pEditor->m_Map.m_lEnvelopes.size()-1);
|
||||
int Step = (Index-pSource->m_SoundEnv)%2;
|
||||
if(Step != 0)
|
||||
{
|
||||
for(; Index >= -1 && Index < pEditor->m_Map.m_lEnvelopes.size(); Index += Step)
|
||||
if(Index == -1 || pEditor->m_Map.m_lEnvelopes[Index]->m_Channels == 2)
|
||||
{
|
||||
pSource->m_SoundEnv = Index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -335,6 +335,8 @@ struct CSoundSource
|
|||
int m_Global;
|
||||
int m_Loop;
|
||||
int m_TimeDelay; // in s
|
||||
|
||||
int m_SoundEnv;
|
||||
};
|
||||
|
||||
struct CMapItemLayerSounds
|
||||
|
|
Loading…
Reference in a new issue