Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't hardcode help text: Autopickup Manager #79564

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 37 additions & 52 deletions src/auto_pickup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -344,22 +367,19 @@ 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, _( "<A>dd" ) ) + 2;
tmpx += shortcut_print( w_header, point( tmpx, 0 ), c_white, c_light_green, _( "<R>emove" ) ) + 2;
tmpx += shortcut_print( w_header, point( tmpx, 0 ), c_white, c_light_green, _( "<C>opy" ) ) + 2;
tmpx += shortcut_print( w_header, point( tmpx, 0 ), c_white, c_light_green, _( "<M>ove" ) ) + 2;
tmpx += shortcut_print( w_header, point( tmpx, 0 ), c_white, c_light_green, _( "<E>nable" ) ) + 2;
tmpx += shortcut_print( w_header, point( tmpx, 0 ), c_white, c_light_green, _( "<D>isable" ) ) + 2;
if( !player_character.name.empty() ) {
shortcut_print( w_header, point( tmpx, 0 ), c_white, c_light_green, _( "<T>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,
_( "<Enter>-Edit" ) ) + 2;
shortcut_print( w_header, point( tmpx, 1 ), c_white, c_light_green, _( "<Tab>-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<bool>( "AUTO_PICKUP" ) ? c_light_green : c_light_red ), c_white,
( get_option<bool>( "AUTO_PICKUP" ) ? _( "True" ) : _( "False" ) ) );
std::string desc = string_format( " %s ", ctxt.get_desc( "SWITCH_AUTO_PICKUP_OPTION",
_( "Switch" ) ) );
fold_and_print( w_header, point( locx + 1, 0 ), 0, c_white, desc );

std::string desc_2 = string_format( "%s", ctxt.get_desc( "HELP_KEYBINDINGS", _( "Display keybindings" ) ) );
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 );
Expand All @@ -375,21 +395,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<bool>( "AUTO_PICKUP" ) ? c_light_green : c_light_red, c_white,
get_option<bool>( "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, _( "<S>witch" ) );
shortcut_print( w_header, point( locx, 1 ), c_white, c_light_green, " " );

wnoutrefresh( w_header );

// Clear the lines
Expand Down Expand Up @@ -432,32 +443,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;

Expand Down
Loading