From f9ecaa3109e169453dfeb28eb4e6c3942c1dce65 Mon Sep 17 00:00:00 2001 From: Daniel Brooks Date: Wed, 14 Aug 2024 19:28:01 -0700 Subject: [PATCH] provide a desired_bounds for the vehicle appliance interaction menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So that it doesn’t overlap with the vehicle appliance information view above it. Fixes #75671 --- src/veh_appliance.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/veh_appliance.cpp b/src/veh_appliance.cpp index fa43ddb3c5c4f..77d43359b8d1f 100644 --- a/src/veh_appliance.cpp +++ b/src/veh_appliance.cpp @@ -1,5 +1,6 @@ #include "game.h" #include "handle_liquid.h" +#include "imgui/imgui.h" #include "inventory.h" #include "itype.h" #include "map_iterator.h" @@ -173,14 +174,24 @@ void veh_app_interact::init_ui_windows() } const int width_info = win_width - 2; const int height_input = app_actions.size(); - const int height = height_info + height_input + 2; + const int win_height = height_info + 2; + const int full_height = win_height + height_input; // Center the UI - point topleft( TERMX / 2 - win_width / 2, TERMY / 2 - height / 2 ); - w_border = catacurses::newwin( height, win_width, topleft ); + point topleft( TERMX / 2 - win_width / 2, TERMY / 2 - full_height / 2 ); + w_border = catacurses::newwin( win_height, win_width, topleft ); //NOLINTNEXTLINE(cata-use-named-point-constants) w_info = catacurses::newwin( height_info, width_info, topleft + point( 1, 1 ) ); + ImVec2 text_metrics = { ImGui::CalcTextSize( "X" ).x, ImGui::GetTextLineHeight() }; + ImVec2 origin = text_metrics * ImVec2{ static_cast( topleft.x ), static_cast( topleft.y + win_height ) }; + ImVec2 size = text_metrics * ImVec2{ static_cast( win_width ), static_cast( height_input ) }; + imenu.desired_bounds = { origin.x, + origin.y, + size.x, + size.y + 4.0f * ( ImGui::GetStyle().FramePadding.y + ImGui::GetStyle().WindowBorderSize ) + }; + imenu.allow_cancel = true; imenu.border_color = c_white; imenu.setup();