| 4778 | ////////////////////////////////////////////////////////////////////////////// |
| 4779 | |
| 4780 | bool IGFD::FileDialog::m_Confirm_Or_OpenOverWriteFileDialog_IfNeeded(bool vLastAction, ImGuiWindowFlags vFlags) { |
| 4781 | // if confirmation => return true for confirm the overwrite et quit the dialog |
| 4782 | // if cancel => return false && set IsOk to false for keep inside the dialog |
| 4783 | |
| 4784 | // if IsOk == false => return false for quit the dialog |
| 4785 | if (!m_FileDialogInternal.isOk && vLastAction) { |
| 4786 | m_QuitFrame(); |
| 4787 | return true; |
| 4788 | } |
| 4789 | |
| 4790 | // if IsOk == true && no check of overwrite => return true for confirm the dialog |
| 4791 | if (m_FileDialogInternal.isOk && vLastAction && !(m_FileDialogInternal.getDialogConfig().flags & ImGuiFileDialogFlags_ConfirmOverwrite)) { |
| 4792 | m_QuitFrame(); |
| 4793 | return true; |
| 4794 | } |
| 4795 | |
| 4796 | // if IsOk == true && check of overwrite => return false and show confirm to overwrite dialog |
| 4797 | if ((m_FileDialogInternal.okResultToConfirm || (m_FileDialogInternal.isOk && vLastAction)) && (m_FileDialogInternal.getDialogConfig().flags & ImGuiFileDialogFlags_ConfirmOverwrite)) { |
| 4798 | if (m_FileDialogInternal.isOk) // catched only one time |
| 4799 | { |
| 4800 | if (!m_FileDialogInternal.fileManager.GetFileSystemInstance()->IsFileExist(GetFilePathName())) // not existing => quit dialog |
| 4801 | { |
| 4802 | m_QuitFrame(); |
| 4803 | return true; |
| 4804 | } else // existing => confirm dialog to open |
| 4805 | { |
| 4806 | m_FileDialogInternal.isOk = false; |
| 4807 | m_FileDialogInternal.okResultToConfirm = true; |
| 4808 | } |
| 4809 | } |
| 4810 | |
| 4811 | std::string name = OverWriteDialogTitleString "##" + m_FileDialogInternal.dLGtitle + m_FileDialogInternal.dLGkey + "OverWriteDialog"; |
| 4812 | |
| 4813 | bool res = false; |
| 4814 | |
| 4815 | ImGui::OpenPopup(name.c_str()); |
| 4816 | if (ImGui::BeginPopupModal(name.c_str(), (bool*)0, vFlags | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove)) { |
| 4817 | ImGui::SetWindowPos(m_FileDialogInternal.dialogCenterPos - ImGui::GetWindowSize() * 0.5f); // next frame needed for GetWindowSize to work |
| 4818 | |
| 4819 | ImGui::Text("%s", OverWriteDialogMessageString); |
| 4820 | |
| 4821 | if (IMGUI_BUTTON(OverWriteDialogConfirmButtonString)) { |
| 4822 | m_FileDialogInternal.okResultToConfirm = false; |
| 4823 | m_FileDialogInternal.isOk = true; |
| 4824 | res = true; |
| 4825 | ImGui::CloseCurrentPopup(); |
| 4826 | } |
| 4827 | |
| 4828 | ImGui::SameLine(); |
| 4829 | |
| 4830 | if (IMGUI_BUTTON(OverWriteDialogCancelButtonString)) { |
| 4831 | m_FileDialogInternal.okResultToConfirm = false; |
| 4832 | m_FileDialogInternal.isOk = false; |
| 4833 | res = false; |
| 4834 | ImGui::CloseCurrentPopup(); |
| 4835 | } |
| 4836 | |
| 4837 | ImGui::EndPopup(); |
nothing calls this directly
no test coverage detected