mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
editor: added reload button for image and sound popups
This commit is contained in:
parent
6f62750833
commit
39223dfd8a
|
@ -3791,6 +3791,7 @@ static void ModifyIndexDeleted(int *pIndex)
|
|||
|
||||
int CEditor::PopupImage(CEditor *pEditor, CUIRect View, void *pContext)
|
||||
{
|
||||
static int s_ReloadButton = 0;
|
||||
static int s_ReplaceButton = 0;
|
||||
static int s_RemoveButton = 0;
|
||||
|
||||
|
@ -3821,6 +3822,18 @@ int CEditor::PopupImage(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
View.HSplitTop(12.0f, &Slot, &View);
|
||||
}
|
||||
|
||||
if(pEditor->DoButton_MenuItem(&s_ReloadButton, "Reload", 0, &Slot, 0, "Reloads the image from mapres folder"))
|
||||
{
|
||||
bool bIsExternal = pImg->m_External;
|
||||
char aBuffer[1024];
|
||||
str_format(aBuffer, sizeof(aBuffer), "mapres/%s.png", pImg->m_aName);
|
||||
pEditor->ReplaceImage(aBuffer, IStorage::TYPE_ALL, pEditor);
|
||||
pImg->m_External = bIsExternal;
|
||||
return 1;
|
||||
}
|
||||
|
||||
View.HSplitTop(5.0f, &Slot, &View);
|
||||
View.HSplitTop(12.0f, &Slot, &View);
|
||||
if(pEditor->DoButton_MenuItem(&s_ReplaceButton, "Replace", 0, &Slot, 0, "Replaces the image with a new one"))
|
||||
{
|
||||
pEditor->InvokeFileDialog(IStorage::TYPE_ALL, FILETYPE_IMG, "Replace Image", "Replace", "mapres", "", ReplaceImage, pEditor);
|
||||
|
@ -3843,12 +3856,25 @@ int CEditor::PopupImage(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
|
||||
int CEditor::PopupSound(CEditor *pEditor, CUIRect View, void *pContext)
|
||||
{
|
||||
static int s_ReloadButton = 0;
|
||||
static int s_ReplaceButton = 0;
|
||||
static int s_RemoveButton = 0;
|
||||
|
||||
CUIRect Slot;
|
||||
View.HSplitTop(2.0f, &Slot, &View);
|
||||
View.HSplitTop(12.0f, &Slot, &View);
|
||||
CEditorSound *pSound = pEditor->m_Map.m_vpSounds[pEditor->m_SelectedSound];
|
||||
|
||||
if(pEditor->DoButton_MenuItem(&s_ReloadButton, "Reload", 0, &Slot, 0, "Reloads the sound from mapres folder"))
|
||||
{
|
||||
char aBuffer[1024];
|
||||
str_format(aBuffer, sizeof(aBuffer), "mapres/%s.opus", pSound->m_aName);
|
||||
pEditor->ReplaceSound(aBuffer, IStorage::TYPE_ALL, pEditor);
|
||||
return 1;
|
||||
}
|
||||
|
||||
View.HSplitTop(5.0f, &Slot, &View);
|
||||
View.HSplitTop(12.0f, &Slot, &View);
|
||||
if(pEditor->DoButton_MenuItem(&s_ReplaceButton, "Replace", 0, &Slot, 0, "Replaces the sound with a new one"))
|
||||
{
|
||||
pEditor->InvokeFileDialog(IStorage::TYPE_ALL, FILETYPE_SOUND, "Replace sound", "Replace", "mapres", "", ReplaceSound, pEditor);
|
||||
|
@ -3857,7 +3883,6 @@ int CEditor::PopupSound(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
|
||||
View.HSplitTop(5.0f, &Slot, &View);
|
||||
View.HSplitTop(12.0f, &Slot, &View);
|
||||
CEditorSound *pSound = pEditor->m_Map.m_vpSounds[pEditor->m_SelectedSound];
|
||||
if(pEditor->DoButton_MenuItem(&s_RemoveButton, "Remove", 0, &Slot, 0, "Removes the sound from the map"))
|
||||
{
|
||||
delete pSound;
|
||||
|
@ -4045,9 +4070,9 @@ void CEditor::RenderImagesList(CUIRect ToolBox)
|
|||
CEditorImage *pImg = m_Map.m_vpImages[m_SelectedImage];
|
||||
int Height;
|
||||
if(pImg->m_External || IsVanillaImage(pImg->m_aName))
|
||||
Height = 60;
|
||||
Height = 73;
|
||||
else
|
||||
Height = 43;
|
||||
Height = 60;
|
||||
UiInvokePopupMenu(&s_PopupImageID, 0, UI()->MouseX(), UI()->MouseY(), 120, Height, PopupImage);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue