diff --git a/src/auto_pickup.cpp b/src/auto_pickup.cpp index 4d2351c09610c..28fc32e9fdfdd 100644 --- a/src/auto_pickup.cpp +++ b/src/auto_pickup.cpp @@ -326,6 +326,29 @@ void user_interface::show() bool bLeftColumn = true; int iStartPos = 0; Character &player_character = get_player_character(); + bStuffChanged = false; + input_context ctxt( "AUTO_PICKUP" ); + ctxt.register_navigate_ui_list(); + ctxt.register_leftright(); + ctxt.register_action( "CONFIRM" ); + ctxt.register_action( "QUIT" ); + if( tabs.size() > 1 ) { + ctxt.register_action( "NEXT_TAB" ); + } + ctxt.register_action( "ADD_RULE" ); + ctxt.register_action( "REMOVE_RULE" ); + ctxt.register_action( "COPY_RULE" ); + ctxt.register_action( "ENABLE_RULE" ); + ctxt.register_action( "DISABLE_RULE" ); + ctxt.register_action( "MOVE_RULE_UP" ); + ctxt.register_action( "MOVE_RULE_DOWN" ); + ctxt.register_action( "TEST_RULE" ); + ctxt.register_action( "HELP_KEYBINDINGS" ); + ctxt.register_action( "SWITCH_AUTO_PICKUP_OPTION" ); + const bool allow_swapping = tabs.size() == 2; + if( allow_swapping ) { + ctxt.register_action( "SWAP_RULE_GLOBAL_CHAR" ); + } ui.on_redraw( [&]( const ui_adaptor & ) { // Redraw the border @@ -344,22 +367,17 @@ void user_interface::show() wnoutrefresh( w_border ); // Redraw the header - int tmpx = 0; - tmpx += shortcut_print( w_header, point( tmpx, 0 ), c_white, c_light_green, _( "dd" ) ) + 2; - tmpx += shortcut_print( w_header, point( tmpx, 0 ), c_white, c_light_green, _( "emove" ) ) + 2; - tmpx += shortcut_print( w_header, point( tmpx, 0 ), c_white, c_light_green, _( "opy" ) ) + 2; - tmpx += shortcut_print( w_header, point( tmpx, 0 ), c_white, c_light_green, _( "ove" ) ) + 2; - tmpx += shortcut_print( w_header, point( tmpx, 0 ), c_white, c_light_green, _( "nable" ) ) + 2; - tmpx += shortcut_print( w_header, point( tmpx, 0 ), c_white, c_light_green, _( "isable" ) ) + 2; - if( !player_character.name.empty() ) { - shortcut_print( w_header, point( tmpx, 0 ), c_white, c_light_green, _( "est" ) ); - } - tmpx = 0; - tmpx += shortcut_print( w_header, point( tmpx, 1 ), c_white, c_light_green, - _( "<+-> Move up/down" ) ) + 2; - tmpx += shortcut_print( w_header, point( tmpx, 1 ), c_white, c_light_green, - _( "-Edit" ) ) + 2; - shortcut_print( w_header, point( tmpx, 1 ), c_white, c_light_green, _( "-Switch Page" ) ); + int locx = 0; + const std::string autopickup_enabled_text = _( "Auto pickup enabled:" ); + mvwprintz( w_header, point( locx, 0 ), c_white, autopickup_enabled_text ); + locx += utf8_width( autopickup_enabled_text ); + locx += shortcut_print( w_header, point( locx + 1, 0 ), + ( get_option( "AUTO_PICKUP" ) ? c_light_green : c_light_red ), c_white, + ( get_option( "AUTO_PICKUP" ) ? _( "True" ) : _( "False" ) ) ); + std::string desc_2 = string_format( "%s", ctxt.get_desc( "HELP_KEYBINDINGS", + _( "Display keybindings" ) ) ); + // NOLINTNEXTLINE(cata-use-named-point-constants) + fold_and_print( w_header, point( 0, 1 ), 0, c_white, desc_2 ); wattron( w_header, c_light_gray ); mvwhline( w_header, point( 0, 2 ), LINE_OXOX, 78 ); @@ -375,21 +393,12 @@ void user_interface::show() mvwprintz( w_header, point( 52, 3 ), c_white, _( "Inc/Exc" ) ); rule_list &cur_rules = tabs[iTab].new_rules; - int locx = 17; + locx = 17; for( size_t i = 0; i < tabs.size(); i++ ) { const nc_color color = iTab == i ? hilite( c_white ) : c_white; locx += shortcut_print( w_header, point( locx, 2 ), c_white, color, tabs[i].title ) + 1; } - locx = 55; - mvwprintz( w_header, point( locx, 0 ), c_white, _( "Auto pickup enabled:" ) ); - locx += shortcut_print( w_header, point( locx, 1 ), - get_option( "AUTO_PICKUP" ) ? c_light_green : c_light_red, c_white, - get_option( "AUTO_PICKUP" ) ? _( "True" ) : _( "False" ) ); - locx += shortcut_print( w_header, point( locx, 1 ), c_white, c_light_green, " " ); - locx += shortcut_print( w_header, point( locx, 1 ), c_white, c_light_green, _( "witch" ) ); - shortcut_print( w_header, point( locx, 1 ), c_white, c_light_green, " " ); - wnoutrefresh( w_header ); // Clear the lines @@ -432,32 +441,6 @@ void user_interface::show() wnoutrefresh( w ); } ); - bStuffChanged = false; - input_context ctxt( "AUTO_PICKUP" ); - ctxt.register_navigate_ui_list(); - ctxt.register_leftright(); - ctxt.register_action( "CONFIRM" ); - ctxt.register_action( "QUIT" ); - if( tabs.size() > 1 ) { - ctxt.register_action( "NEXT_TAB" ); - ctxt.register_action( "PREV_TAB" ); - } - ctxt.register_action( "ADD_RULE" ); - ctxt.register_action( "REMOVE_RULE" ); - ctxt.register_action( "COPY_RULE" ); - ctxt.register_action( "ENABLE_RULE" ); - ctxt.register_action( "DISABLE_RULE" ); - ctxt.register_action( "MOVE_RULE_UP" ); - ctxt.register_action( "MOVE_RULE_DOWN" ); - ctxt.register_action( "TEST_RULE" ); - ctxt.register_action( "HELP_KEYBINDINGS" ); - ctxt.register_action( "SWITCH_AUTO_PICKUP_OPTION" ); - - const bool allow_swapping = tabs.size() == 2; - if( allow_swapping ) { - ctxt.register_action( "SWAP_RULE_GLOBAL_CHAR" ); - } - while( true ) { rule_list &cur_rules = tabs[iTab].new_rules;