From c38c632d067702454f1f706eeefcbfaa0043b738 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 13 Aug 2011 19:22:01 +0200 Subject: [PATCH] fixed multiple popup creation in the editor. Closes #836 --- src/game/editor/editor.cpp | 21 ++++++++++++++------- src/game/editor/editor.h | 2 ++ src/game/editor/popups.cpp | 4 ++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 0b638aeb9..3d655e718 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -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; } diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index db99a78cf..bdabd43fe 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -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 { diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index a97146aa1..c19adb825 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -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; }