Refactor CEditor::PopupImage

This commit is contained in:
Robert Müller 2023-04-01 23:20:11 +02:00
parent e09a771937
commit 7289f7d504
2 changed files with 11 additions and 9 deletions

View file

@ -4445,16 +4445,12 @@ void CEditor::RenderImagesList(CUIRect ToolBox)
{
m_SelectedImage = i;
static int s_PopupImageID = 0;
if(Result == 2)
{
CEditorImage *pImg = m_Map.m_vpImages[m_SelectedImage];
int Height;
if(pImg->m_External || IsVanillaImage(pImg->m_aName))
Height = 73;
else
Height = 56;
UiInvokePopupMenu(&s_PopupImageID, 0, UI()->MouseX(), UI()->MouseY(), 120, Height, PopupImage);
const CEditorImage *pImg = m_Map.m_vpImages[m_SelectedImage];
const int Height = pImg->m_External || IsVanillaImage(pImg->m_aName) ? 73 : 56;
static int s_PopupImageId;
UiInvokePopupMenu(&s_PopupImageId, 0, UI()->MouseX(), UI()->MouseY(), 120, Height, PopupImage);
}
}
}

View file

@ -1282,7 +1282,7 @@ int CEditor::PopupImage(CEditor *pEditor, CUIRect View, void *pContext)
}
if(s_SelectionPopupContext.m_pSelection != nullptr)
{
bool WasExternal = pImg->m_External;
const bool WasExternal = pImg->m_External;
ReplaceImage(s_SelectionPopupContext.m_pSelection->c_str(), IStorage::TYPE_ALL, pEditor);
pImg->m_External = WasExternal;
s_SelectionPopupContext.Reset();
@ -1546,11 +1546,17 @@ int CEditor::PopupEvent(CEditor *pEditor, CUIRect View, void *pContext)
if(pEditor->DoButton_Editor(&s_OkButton, "Ok", 0, &Label, 0, nullptr) || pEditor->Input()->KeyPress(KEY_RETURN) || pEditor->Input()->KeyPress(KEY_KP_ENTER))
{
if(pEditor->m_PopupEventType == POPEVENT_EXIT)
{
g_Config.m_ClEditor = 0;
}
else if(pEditor->m_PopupEventType == POPEVENT_LOAD)
{
pEditor->InvokeFileDialog(IStorage::TYPE_ALL, FILETYPE_MAP, "Load map", "Load", "maps", "", CEditor::CallbackOpenMap, pEditor);
}
else if(pEditor->m_PopupEventType == POPEVENT_LOADCURRENT)
{
pEditor->LoadCurrentMap();
}
else if(pEditor->m_PopupEventType == POPEVENT_NEW)
{
pEditor->Reset();