| 59 | } |
| 60 | |
| 61 | auto Sorcery::Message::display(bool &is_yes) -> void { |
| 62 | |
| 63 | _id = _component.name + "##outer"; |
| 64 | const auto continue_lbl{_ctx.get_string("MESSAGE_CONTINUE")}; |
| 65 | const auto rounding{_ctx.ui->frame_rd}; |
| 66 | const auto width{_ctx.ui->grid_sz() * _component.w}; |
| 67 | const auto height{(6 + _strings.size()) * _ctx.ui->grid_sz()}; |
| 68 | |
| 69 | // Work out where to draw the image |
| 70 | const auto y{std::invoke([&] { |
| 71 | if (_component.y == -1) { |
| 72 | return 0.5f; |
| 73 | } else |
| 74 | return static_cast<float>(_ctx.ui->grid_sz() * _component.y); |
| 75 | })}; |
| 76 | const auto pivot_y{std::invoke([&] { |
| 77 | if (_component.y == -1) { |
| 78 | return 0.5f; |
| 79 | } else |
| 80 | return 0.0f; |
| 81 | })}; |
| 82 | |
| 83 | ImVec2 centre{ImGui::GetMainViewport()->GetCenter()}; |
| 84 | ImGui::SetNextWindowPos(ImVec2{centre.x, y}, ImGuiCond_Appearing, |
| 85 | ImVec2(0.5f, pivot_y)); |
| 86 | ImGui::SetNextWindowSize(ImVec2{width, height}); |
| 87 | ImGui::SetNextWindowBgAlpha(1.0f); |
| 88 | |
| 89 | const auto col{_ctx.ui->get_hl_colour(_ctx.animation->lerp)}; |
| 90 | set_StyleVar(ImGuiStyleVar_WindowPadding, ImVec2{0, 0}); |
| 91 | set_StyleVar(ImGuiStyleVar_WindowBorderSize, 0); |
| 92 | set_StyleVar(ImGuiStyleVar_WindowRounding, _component.background); |
| 93 | set_StyleColor(ImGuiCol_PopupBg, _component.background); |
| 94 | set_StyleColor(ImGuiCol_ButtonHovered, (ImVec4)col); |
| 95 | UIStyle::set_faded(_ctx); |
| 96 | |
| 97 | set_Font(_ctx.ui->fontstore->get_current_font(_component.font).value(), |
| 98 | _ctx.ui->font_sz()); |
| 99 | if (show) |
| 100 | ImGui::OpenPopup(CSTR(_id)); |
| 101 | |
| 102 | with_PopupModal(CSTR(_id), nullptr, ImGuiWindowFlags_NoDecoration) { |
| 103 | const auto p_min{ImGui::GetWindowPos()}; |
| 104 | const auto p_max{ImVec2{ImGui::GetWindowPos().x + width, |
| 105 | ImGui::GetWindowPos().y + height}}; |
| 106 | |
| 107 | _ctx.ui->draw_frame(p_min, p_max, |
| 108 | ImVec4{_ctx.ui->ui_colour.x, _ctx.ui->ui_colour.y, |
| 109 | _ctx.ui->ui_colour.z, _ctx.animation->fade}, |
| 110 | rounding); |
| 111 | |
| 112 | #pragma GCC diagnostic push |
| 113 | #pragma GCC diagnostic ignored "-Wformat-security" |
| 114 | auto y_pos{_ctx.ui->grid_sz() * 2}; |
| 115 | for (const auto &string : _strings) { |
| 116 | ImGui::SetCursorPos(ImVec2{_ctx.ui->grid_sz() * 2, y_pos}); |
| 117 | auto str{_ctx.get_string(string)}; |
| 118 | ImGui::Text(str.c_str()); |
nothing calls this directly
no test coverage detected