mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
fixed multiple popup creation in the editor. Closes #836
This commit is contained in:
parent
4e830a71a1
commit
c38c632d06
|
@ -749,25 +749,31 @@ void CEditor::DoToolbar(CUIRect ToolBar)
|
|||
TB_Bottom.HSplitTop(2.5f, 0, &TB_Bottom);
|
||||
|
||||
// ctrl+o to open
|
||||
if(Input()->KeyDown('o') && (Input()->KeyPressed(KEY_LCTRL) || Input()->KeyPressed(KEY_RCTRL)))
|
||||
if(Input()->KeyDown('o') && (Input()->KeyPressed(KEY_LCTRL) || Input()->KeyPressed(KEY_RCTRL)) && m_Dialog == DIALOG_NONE)
|
||||
{
|
||||
if(HasUnsavedData())
|
||||
{
|
||||
m_PopupEventType = POPEVENT_LOAD;
|
||||
m_PopupEventActivated = true;
|
||||
if(!m_PopupEventWasActivated)
|
||||
{
|
||||
m_PopupEventType = POPEVENT_LOAD;
|
||||
m_PopupEventActivated = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
InvokeFileDialog(IStorage::TYPE_ALL, FILETYPE_MAP, "Load map", "Load", "maps", "", CallbackOpenMap, this);
|
||||
}
|
||||
|
||||
// ctrl+s to save
|
||||
if(Input()->KeyDown('s') && (Input()->KeyPressed(KEY_LCTRL) || Input()->KeyPressed(KEY_RCTRL)))
|
||||
if(Input()->KeyDown('s') && (Input()->KeyPressed(KEY_LCTRL) || Input()->KeyPressed(KEY_RCTRL)) && m_Dialog == DIALOG_NONE)
|
||||
{
|
||||
if(m_aFileName[0] && m_ValidSaveFilename)
|
||||
{
|
||||
str_copy(m_aFileSaveName, m_aFileName, sizeof(m_aFileSaveName));
|
||||
m_PopupEventType = POPEVENT_SAVE;
|
||||
m_PopupEventActivated = true;
|
||||
if(!m_PopupEventWasActivated)
|
||||
{
|
||||
str_copy(m_aFileSaveName, m_aFileName, sizeof(m_aFileSaveName));
|
||||
m_PopupEventType = POPEVENT_SAVE;
|
||||
m_PopupEventActivated = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
InvokeFileDialog(IStorage::TYPE_SAVE, FILETYPE_MAP, "Save map", "Save", "maps", "", CallbackSaveMap, this);
|
||||
|
@ -3420,6 +3426,7 @@ void CEditor::Render()
|
|||
static int s_PopupID = 0;
|
||||
UiInvokePopupMenu(&s_PopupID, 0, Width/2.0f-200.0f, Height/2.0f-100.0f, 400.0f, 200.0f, PopupEvent);
|
||||
m_PopupEventActivated = false;
|
||||
m_PopupEventWasActivated = true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -486,6 +486,7 @@ public:
|
|||
m_ValidSaveFilename = false;
|
||||
|
||||
m_PopupEventActivated = false;
|
||||
m_PopupEventWasActivated = false;
|
||||
|
||||
m_FileDialogStorageType = 0;
|
||||
m_pFileDialogTitle = 0;
|
||||
|
@ -579,6 +580,7 @@ public:
|
|||
|
||||
int m_PopupEventType;
|
||||
int m_PopupEventActivated;
|
||||
int m_PopupEventWasActivated;
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -684,13 +684,17 @@ int CEditor::PopupEvent(CEditor *pEditor, CUIRect View)
|
|||
}
|
||||
else if(pEditor->m_PopupEventType == POPEVENT_SAVE)
|
||||
pEditor->CallbackSaveMap(pEditor->m_aFileSaveName, IStorage::TYPE_SAVE, pEditor);
|
||||
pEditor->m_PopupEventWasActivated = false;
|
||||
return 1;
|
||||
}
|
||||
ButtonBar.VSplitRight(30.0f, &ButtonBar, 0);
|
||||
ButtonBar.VSplitRight(110.0f, &ButtonBar, &Label);
|
||||
static int s_AbortButton = 0;
|
||||
if(pEditor->DoButton_Editor(&s_AbortButton, "Abort", 0, &Label, 0, 0))
|
||||
{
|
||||
pEditor->m_PopupEventWasActivated = false;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue