Skip to content

Commit

Permalink
Merge pull request #75692 from db48x/vehicle-appliance-menu-offset
Browse files Browse the repository at this point in the history
provide a desired_bounds for the vehicle appliance interaction menu
  • Loading branch information
akrieger authored Aug 15, 2024
2 parents e9f72b0 + f9ecaa3 commit 336c7a3
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/veh_appliance.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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<float>( topleft.x ), static_cast<float>( topleft.y + win_height ) };
ImVec2 size = text_metrics * ImVec2{ static_cast<float>( win_width ), static_cast<float>( 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();
Expand Down

0 comments on commit 336c7a3

Please sign in to comment.