[XAM] Don't allow an empty title.

[XAM] Don't allow an empty titles because ImGui explodes otherwise.
This commit is contained in:
gibbed 2020-02-20 01:08:48 -06:00 committed by Rick Gibbed
parent b12554c5af
commit 8d5d70c77f
1 changed files with 17 additions and 2 deletions

View File

@ -38,6 +38,9 @@ class MessageBoxDialog : public xe::ui::ImGuiDialog {
buttons_(std::move(buttons)),
default_button_(default_button),
out_chosen_button_(out_chosen_button) {
if (!title_.size()) {
title_ = "Message Box";
}
if (out_chosen_button) {
*out_chosen_button = default_button;
}
@ -52,7 +55,9 @@ class MessageBoxDialog : public xe::ui::ImGuiDialog {
}
if (ImGui::BeginPopupModal(title_.c_str(), nullptr,
ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::Text("%s", description_.c_str());
if (description_.size()) {
ImGui::Text("%s", description_.c_str());
}
if (first_draw) {
ImGui::SetKeyboardFocusHere();
}
@ -170,6 +175,14 @@ class KeyboardInputDialog : public xe::ui::ImGuiDialog {
default_text_(xe::to_string(default_text)),
out_text_(out_text),
max_length_(max_length) {
if (!title_.size()) {
if (!description_.size()) {
title_ = "Keyboard Input";
} else {
title_ = description_;
description_ = "";
}
}
if (out_text_) {
*out_text_ = default_text;
}
@ -187,7 +200,9 @@ class KeyboardInputDialog : public xe::ui::ImGuiDialog {
}
if (ImGui::BeginPopupModal(title_.c_str(), nullptr,
ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::TextWrapped("%s", description_.c_str());
if (description_.size()) {
ImGui::TextWrapped("%s", description_.c_str());
}
if (first_draw) {
ImGui::SetKeyboardFocusHere();
}