Editor: Support up/down for images/sounds

This commit is contained in:
def 2020-08-08 12:21:27 +02:00
parent 4c9d03c063
commit 1ad43a76dd

View file

@ -4029,6 +4029,53 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect View)
Graphics()->LinesEnd();
}
if(Input()->KeyPress(KEY_DOWN) && m_Dialog == DIALOG_NONE)
{
int OldImage = m_SelectedImage;
for(int i = m_SelectedImage + 1; i < m_Map.m_lImages.size(); i++)
{
if(m_Map.m_lImages[i]->m_External == m_Map.m_lImages[m_SelectedImage]->m_External)
{
m_SelectedImage = i;
break;
}
}
if(m_SelectedImage == OldImage && !m_Map.m_lImages[m_SelectedImage]->m_External)
{
for(int i = 0; i < m_Map.m_lImages.size(); i++)
{
if(m_Map.m_lImages[i]->m_External)
{
m_SelectedImage = i;
break;
}
}
}
}
if(Input()->KeyPress(KEY_UP) && m_Dialog == DIALOG_NONE)
{
int OldImage = m_SelectedImage;
for(int i = m_SelectedImage - 1; i >= 0; i--)
{
if(m_Map.m_lImages[i]->m_External == m_Map.m_lImages[m_SelectedImage]->m_External)
{
m_SelectedImage = i;
break;
}
}
if(m_SelectedImage == OldImage && m_Map.m_lImages[m_SelectedImage]->m_External)
{
for(int i = m_Map.m_lImages.size() - 1; i >= 0; i--)
{
if(!m_Map.m_lImages[i]->m_External)
{
m_SelectedImage = i;
break;
}
}
}
}
// render image
int i = m_SelectedImage;
if(i < m_Map.m_lImages.size())
@ -4183,6 +4230,53 @@ void CEditor::RenderSounds(CUIRect ToolBox, CUIRect View)
Graphics()->LinesEnd();
}
if(Input()->KeyPress(KEY_DOWN) && m_Dialog == DIALOG_NONE)
{
int OldSound = m_SelectedSound;
for(int i = m_SelectedSound + 1; i < m_Map.m_lSounds.size(); i++)
{
if(m_Map.m_lSounds[i]->m_External == m_Map.m_lSounds[m_SelectedSound]->m_External)
{
m_SelectedSound = i;
break;
}
}
if(m_SelectedSound == OldSound && !m_Map.m_lSounds[m_SelectedSound]->m_External)
{
for(int i = 0; i < m_Map.m_lSounds.size(); i++)
{
if(m_Map.m_lSounds[i]->m_External)
{
m_SelectedSound = i;
break;
}
}
}
}
if(Input()->KeyPress(KEY_UP) && m_Dialog == DIALOG_NONE)
{
int OldSound = m_SelectedSound;
for(int i = m_SelectedSound - 1; i >= 0; i--)
{
if(m_Map.m_lSounds[i]->m_External == m_Map.m_lSounds[m_SelectedSound]->m_External)
{
m_SelectedSound = i;
break;
}
}
if(m_SelectedSound == OldSound && m_Map.m_lSounds[m_SelectedSound]->m_External)
{
for(int i = m_Map.m_lSounds.size() - 1; i >= 0; i--)
{
if(!m_Map.m_lSounds[i]->m_External)
{
m_SelectedSound = i;
break;
}
}
}
}
CUIRect Slot;
ToolBox.HSplitTop(5.0f, &Slot, &ToolBox);