| 21 | #include <limits> |
| 22 | |
| 23 | CUi::EPopupMenuFunctionResult CEditor::PopupMenuFile(void *pContext, CUIRect View, bool Active) |
| 24 | { |
| 25 | CEditor *pEditor = static_cast<CEditor *>(pContext); |
| 26 | |
| 27 | static int s_NewMapButton = 0; |
| 28 | static int s_SaveButton = 0; |
| 29 | static int s_SaveAsButton = 0; |
| 30 | static int s_SaveCopyButton = 0; |
| 31 | static int s_OpenButton = 0; |
| 32 | static int s_OpenCurrentMapButton = 0; |
| 33 | static int s_AppendButton = 0; |
| 34 | static int s_TestMapLocallyButton = 0; |
| 35 | static int s_ExitButton = 0; |
| 36 | |
| 37 | CUIRect Slot; |
| 38 | View.HSplitTop(12.0f, &Slot, &View); |
| 39 | if(pEditor->DoButton_MenuItem(&s_NewMapButton, "New", 0, &Slot, BUTTONFLAG_LEFT, "[Ctrl+N] Create a new map.")) |
| 40 | { |
| 41 | if(pEditor->HasUnsavedData()) |
| 42 | { |
| 43 | pEditor->m_PopupEventType = POPEVENT_NEW; |
| 44 | pEditor->m_PopupEventActivated = true; |
| 45 | } |
| 46 | else |
| 47 | { |
| 48 | pEditor->Reset(); |
| 49 | } |
| 50 | return CUi::POPUP_CLOSE_CURRENT; |
| 51 | } |
| 52 | |
| 53 | View.HSplitTop(10.0f, nullptr, &View); |
| 54 | View.HSplitTop(12.0f, &Slot, &View); |
| 55 | if(pEditor->DoButton_MenuItem(&s_OpenButton, "Load", 0, &Slot, BUTTONFLAG_LEFT, "[Ctrl+L] Open a map for editing.")) |
| 56 | { |
| 57 | if(pEditor->HasUnsavedData()) |
| 58 | { |
| 59 | pEditor->m_PopupEventType = POPEVENT_LOAD; |
| 60 | pEditor->m_PopupEventActivated = true; |
| 61 | } |
| 62 | else |
| 63 | pEditor->m_FileBrowser.ShowFileDialog(IStorage::TYPE_ALL, CFileBrowser::EFileType::MAP, "Load map", "Load", "maps", "", CallbackOpenMap, pEditor); |
| 64 | return CUi::POPUP_CLOSE_CURRENT; |
| 65 | } |
| 66 | |
| 67 | View.HSplitTop(2.0f, nullptr, &View); |
| 68 | View.HSplitTop(12.0f, &Slot, &View); |
| 69 | if(pEditor->DoButton_MenuItem(&s_OpenCurrentMapButton, pEditor->m_QuickActionLoadCurrentMap.Label(), pEditor->m_QuickActionLoadCurrentMap.Disabled() ? -1 : 0, &Slot, BUTTONFLAG_LEFT, pEditor->m_QuickActionLoadCurrentMap.Description())) |
| 70 | { |
| 71 | pEditor->m_QuickActionLoadCurrentMap.Call(); |
| 72 | return CUi::POPUP_CLOSE_CURRENT; |
| 73 | } |
| 74 | |
| 75 | View.HSplitTop(10.0f, nullptr, &View); |
| 76 | View.HSplitTop(12.0f, &Slot, &View); |
| 77 | if(pEditor->DoButton_MenuItem(&s_AppendButton, "Append", 0, &Slot, BUTTONFLAG_LEFT, "[Ctrl+A] Open a map and add everything from that map to the current one.")) |
| 78 | { |
| 79 | pEditor->m_FileBrowser.ShowFileDialog(IStorage::TYPE_ALL, CFileBrowser::EFileType::MAP, "Append map", "Append", "maps", "", CallbackAppendMap, pEditor); |
| 80 | return CUi::POPUP_CLOSE_CURRENT; |
nothing calls this directly
no test coverage detected