diff --git a/plugins/libimhex/source/views/view.cpp b/plugins/libimhex/source/views/view.cpp index 316a38337..5d0349ace 100644 --- a/plugins/libimhex/source/views/view.cpp +++ b/plugins/libimhex/source/views/view.cpp @@ -36,19 +36,17 @@ namespace hex { } void View::drawCommonInterfaces() { + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20, 10)); if (ImGui::BeginPopupModal("Error", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { + ImGui::Text("%s", SharedData::errorPopupMessage.c_str()); ImGui::NewLine(); - if (ImGui::BeginChild("##scrolling", ImVec2(300, 100))) { - ImGui::SetCursorPosX((300 - ImGui::CalcTextSize(SharedData::errorPopupMessage.c_str(), nullptr, false).x) / 2.0F); - ImGui::TextWrapped("%s", SharedData::errorPopupMessage.c_str()); - ImGui::EndChild(); - } - ImGui::NewLine(); - ImGui::SetCursorPosX(75); - if (ImGui::Button("Okay", ImVec2(150, 20)) || ImGui::IsKeyDown(ImGuiKey_Escape)) + ImGui::Separator(); + if (ImGui::Button("Okay") || ImGui::IsKeyDown(ImGuiKey_Escape)) ImGui::CloseCurrentPopup(); + ImGui::EndPopup(); } + ImGui::PopStyleVar(); if (SharedData::fileBrowser.showFileDialog(SharedData::fileBrowserTitle, SharedData::fileBrowserDialogMode, ImVec2(0, 0), SharedData::fileBrowserValidExtensions)) { SharedData::fileBrowserCallback(SharedData::fileBrowser.selected_path); diff --git a/source/views/view_hexeditor.cpp b/source/views/view_hexeditor.cpp index 4f0b7d36b..5d1a1de21 100644 --- a/source/views/view_hexeditor.cpp +++ b/source/views/view_hexeditor.cpp @@ -505,17 +505,25 @@ namespace hex { delete provider; provider = new prv::FileProvider(path); - this->m_memoryEditor.ReadOnly = !provider->isWritable(); + if (!provider->isWritable()) { + this->m_memoryEditor.ReadOnly = true; + View::showErrorPopup("Couldn't get write access. File opened in read-only mode."); + } else { + this->m_memoryEditor.ReadOnly = false; + } - if (provider->isAvailable()) - ProjectFile::setFilePath(path); + if (!provider->isAvailable()) { + View::showErrorPopup("Failed to open file!"); + return; + } + + ProjectFile::setFilePath(path); this->getWindowOpenState() = true; View::postEvent(Events::FileLoaded); View::postEvent(Events::DataChanged); View::postEvent(Events::PatternChanged); - ProjectFile::markDirty(); } bool ViewHexEditor::saveToFile(std::string path, const std::vector& data) {