Skip to content

Commit edb6a36

Browse files
committed
make errors display in UI like warnings, fix positioning
1 parent b103e7f commit edb6a36

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/messages.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ void buildErrorUI(std::string message, bool fatal) {
3434
ImVec2 errorTextSize = ImGui::CalcTextSize(message.c_str());
3535
ImVec2 errorModalSize(std::max(view::windowWidth / 5.0f, std::min(errorTextSize.x + 50, view::windowWidth / 2.0f)),
3636
0);
37+
ImVec2 errorModalPos((view::windowWidth - errorModalSize.x) / 2, view::windowHeight / 3);
3738

3839
ImGui::SetNextWindowSize(errorModalSize);
40+
ImGui::SetNextWindowPos(errorModalPos, ImGuiCond_Always);
3941
ImGui::PushStyleColor(ImGuiCol_TitleBgActive, ImVec4(170. / 255., 0, 0, 1.0));
4042
if (ImGui::BeginPopupModal(errorPopupString.c_str(), NULL, ImGuiWindowFlags_NoMove)) {
4143

@@ -212,6 +214,12 @@ void error(std::string message) {
212214
std::cout << options::printPrefix << "[ERROR] " << message << std::endl;
213215
}
214216

217+
// Enter a modal UI loop showing the error
218+
if (options::displayMessagePopups && !isHeadless()) {
219+
auto func = std::bind(buildErrorUI, message, false);
220+
pushContext(func, false);
221+
}
222+
215223
if (options::errorsThrowExceptions) {
216224
throw std::logic_error(options::printPrefix + message);
217225
}

0 commit comments

Comments
 (0)