Skip to content

Commit

Permalink
Fix save copy callback not called when confirmation popup used
Browse files Browse the repository at this point in the history
When using "Save Copy" to save a copy of the current map to a new file and selecting a file that already exists, a confirmation popup is shown. However, this confirmation popup did not differentiate between regular saving and saving a copy, so the regular save callback was always called.
  • Loading branch information
Robyt3 committed Jun 25, 2023
1 parent e04eee9 commit 72fbfaa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/game/editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4907,7 +4907,7 @@ void CEditor::RenderFileDialog()
{
if(Storage()->FileExists(m_aFileSaveName, IStorage::TYPE_SAVE))
{
m_PopupEventType = POPEVENT_SAVE;
m_PopupEventType = m_pfnFileDialogFunc == &CallbackSaveCopyMap ? POPEVENT_SAVE_COPY : POPEVENT_SAVE;
m_PopupEventActivated = true;
}
else if(m_pfnFileDialogFunc)
Expand Down Expand Up @@ -6240,7 +6240,7 @@ void CEditor::Render()
}
}

// ctrl+shift+alt+s to save as
// ctrl+shift+alt+s to save copy
if(Input()->KeyPress(KEY_S) && ModPressed && ShiftPressed && AltPressed)
InvokeFileDialog(IStorage::TYPE_SAVE, FILETYPE_MAP, "Save map", "Save", "maps", "", CallbackSaveCopyMap, this);
// ctrl+shift+s to save as
Expand Down
1 change: 1 addition & 0 deletions src/game/editor/editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ class CEditor : public IEditor
POPEVENT_LOADCURRENT,
POPEVENT_NEW,
POPEVENT_SAVE,
POPEVENT_SAVE_COPY,
POPEVENT_LARGELAYER,
POPEVENT_PREVENTUNUSEDTILES,
POPEVENT_IMAGEDIV16,
Expand Down
7 changes: 6 additions & 1 deletion src/game/editor/popups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupEvent(void *pContext, CUIRect View,
pTitle = "New map";
pMessage = "The map contains unsaved data, you might want to save it before you create a new map.\n\nContinue anyway?";
}
else if(pEditor->m_PopupEventType == POPEVENT_SAVE)
else if(pEditor->m_PopupEventType == POPEVENT_SAVE || pEditor->m_PopupEventType == POPEVENT_SAVE_COPY)
{
pTitle = "Save map";
pMessage = "The file already exists.\n\nDo you want to overwrite the map?";
Expand Down Expand Up @@ -1677,6 +1677,11 @@ CUI::EPopupMenuFunctionResult CEditor::PopupEvent(void *pContext, CUIRect View,
CallbackSaveMap(pEditor->m_aFileSaveName, IStorage::TYPE_SAVE, pEditor);
return CUI::POPUP_CLOSE_CURRENT;
}
else if(pEditor->m_PopupEventType == POPEVENT_SAVE_COPY)
{
CallbackSaveCopyMap(pEditor->m_aFileSaveName, IStorage::TYPE_SAVE, pEditor);
return CUI::POPUP_CLOSE_CURRENT;
}
else if(pEditor->m_PopupEventType == POPEVENT_PLACE_BORDER_TILES)
{
pEditor->PlaceBorderTiles();
Expand Down

0 comments on commit 72fbfaa

Please sign in to comment.