1
0
mirror of synced 2024-11-12 02:00:52 +01:00

Added default error message window

This commit is contained in:
WerWolv 2020-11-27 13:45:27 +01:00
parent 015ec12215
commit d43bd23e1a
3 changed files with 27 additions and 0 deletions

View File

@ -30,6 +30,28 @@ namespace hex {
View::s_eventManager.post(eventType, userData);
}
static void drawCommonInterfaces() {
if (ImGui::BeginPopupModal("Error", nullptr, ImGuiWindowFlags_NoResize)) {
ImGui::NewLine();
if (ImGui::BeginChild("##scrolling", ImVec2(300, 100))) {
ImGui::SetCursorPosX((300 - ImGui::CalcTextSize(View::s_errorMessage.c_str(), nullptr, false).x) / 2.0F);
ImGui::TextWrapped("%s", View::s_errorMessage.c_str());
ImGui::EndChild();
}
ImGui::NewLine();
ImGui::SetCursorPosX(75);
if (ImGui::Button("Okay", ImVec2(150, 20)))
ImGui::CloseCurrentPopup();
ImGui::EndPopup();
}
}
static void showErrorPopup(std::string_view errorMessage) {
View::s_errorMessage = errorMessage;
ImGui::OpenPopup("Error");
}
bool& getWindowOpenState() {
return this->m_windowOpen;
}
@ -59,6 +81,8 @@ namespace hex {
static inline EventManager s_eventManager;
static inline std::vector<std::function<void()>> s_deferedCalls;
static inline std::string s_errorMessage;
};
}

View File

@ -262,6 +262,7 @@ namespace hex {
this->m_dataProvider = new prv::FileProvider(path);
this->m_memoryEditor.ReadOnly = !this->m_dataProvider->isWritable();
View::postEvent(Events::FileLoaded);
View::postEvent(Events::DataChanged);
}

View File

@ -88,6 +88,8 @@ namespace hex {
view->createView();
}
View::drawCommonInterfaces();
#ifdef DEBUG
if (this->m_demoWindowOpen)
ImGui::ShowDemoWindow(&this->m_demoWindowOpen);