Skip to content

Commit

Permalink
Draw item in third column of item action menu
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhilkinSerg authored Nov 27, 2024
1 parent 9edfa14 commit d916229
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/item_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,27 +339,20 @@ void game::item_action_menu( item_location loc )
auto iter = menu_items.begin();
std::advance( iter, iactions.size() );
sort_menu( iter, menu_items.end() );
// Determine max lengths, to print the menu nicely.
std::pair<int, int> max_len;
for( const auto &elem : menu_items ) {
max_len.first = std::max( max_len.first, utf8_width( std::get<1>( elem ), true ) );
max_len.second = std::max( max_len.second, utf8_width( std::get<2>( elem ), true ) );
}
// Fill the menu.
for( const auto &elem : menu_items ) {
std::string ss;
ss += std::get<1>( elem );
ss += std::string( max_len.first - utf8_width( std::get<1>( elem ), true ), ' ' );
ss += std::string( 4, ' ' );

ss += std::get<2>( elem );
ss += std::string( max_len.second - utf8_width( std::get<2>( elem ), true ), ' ' );
std::string ss_ctxt;
ss_ctxt += std::get<2>( elem );

const std::optional<input_event> bind = key_bound_to( ctxt, std::get<0>( elem ) );
const bool enabled = assigned_action( std::get<0>( elem ) );
const std::string desc = std::get<3>( elem ) ;

kmenu.addentry_desc( num, enabled, bind, ss, desc );
kmenu.entries[num].ctxt = ss_ctxt;
num++;
}

Expand Down

0 comments on commit d916229

Please sign in to comment.