mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-14 03:58: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);
|
TB_Bottom.HSplitTop(2.5f, 0, &TB_Bottom);
|
||||||
|
|
||||||
// ctrl+o to open
|
// 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())
|
if(HasUnsavedData())
|
||||||
{
|
{
|
||||||
m_PopupEventType = POPEVENT_LOAD;
|
if(!m_PopupEventWasActivated)
|
||||||
m_PopupEventActivated = true;
|
{
|
||||||
|
m_PopupEventType = POPEVENT_LOAD;
|
||||||
|
m_PopupEventActivated = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
InvokeFileDialog(IStorage::TYPE_ALL, FILETYPE_MAP, "Load map", "Load", "maps", "", CallbackOpenMap, this);
|
InvokeFileDialog(IStorage::TYPE_ALL, FILETYPE_MAP, "Load map", "Load", "maps", "", CallbackOpenMap, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ctrl+s to save
|
// 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)
|
if(m_aFileName[0] && m_ValidSaveFilename)
|
||||||
{
|
{
|
||||||
str_copy(m_aFileSaveName, m_aFileName, sizeof(m_aFileSaveName));
|
if(!m_PopupEventWasActivated)
|
||||||
m_PopupEventType = POPEVENT_SAVE;
|
{
|
||||||
m_PopupEventActivated = true;
|
str_copy(m_aFileSaveName, m_aFileName, sizeof(m_aFileSaveName));
|
||||||
|
m_PopupEventType = POPEVENT_SAVE;
|
||||||
|
m_PopupEventActivated = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
InvokeFileDialog(IStorage::TYPE_SAVE, FILETYPE_MAP, "Save map", "Save", "maps", "", CallbackSaveMap, this);
|
InvokeFileDialog(IStorage::TYPE_SAVE, FILETYPE_MAP, "Save map", "Save", "maps", "", CallbackSaveMap, this);
|
||||||
|
@ -3420,6 +3426,7 @@ void CEditor::Render()
|
||||||
static int s_PopupID = 0;
|
static int s_PopupID = 0;
|
||||||
UiInvokePopupMenu(&s_PopupID, 0, Width/2.0f-200.0f, Height/2.0f-100.0f, 400.0f, 200.0f, PopupEvent);
|
UiInvokePopupMenu(&s_PopupID, 0, Width/2.0f-200.0f, Height/2.0f-100.0f, 400.0f, 200.0f, PopupEvent);
|
||||||
m_PopupEventActivated = false;
|
m_PopupEventActivated = false;
|
||||||
|
m_PopupEventWasActivated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -486,6 +486,7 @@ public:
|
||||||
m_ValidSaveFilename = false;
|
m_ValidSaveFilename = false;
|
||||||
|
|
||||||
m_PopupEventActivated = false;
|
m_PopupEventActivated = false;
|
||||||
|
m_PopupEventWasActivated = false;
|
||||||
|
|
||||||
m_FileDialogStorageType = 0;
|
m_FileDialogStorageType = 0;
|
||||||
m_pFileDialogTitle = 0;
|
m_pFileDialogTitle = 0;
|
||||||
|
@ -579,6 +580,7 @@ public:
|
||||||
|
|
||||||
int m_PopupEventType;
|
int m_PopupEventType;
|
||||||
int m_PopupEventActivated;
|
int m_PopupEventActivated;
|
||||||
|
int m_PopupEventWasActivated;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
|
@ -684,13 +684,17 @@ int CEditor::PopupEvent(CEditor *pEditor, CUIRect View)
|
||||||
}
|
}
|
||||||
else if(pEditor->m_PopupEventType == POPEVENT_SAVE)
|
else if(pEditor->m_PopupEventType == POPEVENT_SAVE)
|
||||||
pEditor->CallbackSaveMap(pEditor->m_aFileSaveName, IStorage::TYPE_SAVE, pEditor);
|
pEditor->CallbackSaveMap(pEditor->m_aFileSaveName, IStorage::TYPE_SAVE, pEditor);
|
||||||
|
pEditor->m_PopupEventWasActivated = false;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
ButtonBar.VSplitRight(30.0f, &ButtonBar, 0);
|
ButtonBar.VSplitRight(30.0f, &ButtonBar, 0);
|
||||||
ButtonBar.VSplitRight(110.0f, &ButtonBar, &Label);
|
ButtonBar.VSplitRight(110.0f, &ButtonBar, &Label);
|
||||||
static int s_AbortButton = 0;
|
static int s_AbortButton = 0;
|
||||||
if(pEditor->DoButton_Editor(&s_AbortButton, "Abort", 0, &Label, 0, 0))
|
if(pEditor->DoButton_Editor(&s_AbortButton, "Abort", 0, &Label, 0, 0))
|
||||||
|
{
|
||||||
|
pEditor->m_PopupEventWasActivated = false;
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue