From 7dda255d61656f47845478a033c05c02f6e3279a Mon Sep 17 00:00:00 2001 From: Kilvoctu Date: Tue, 21 Jan 2025 19:34:54 -0600 Subject: [PATCH 1/2] don't hardcode zone manager helptext --- src/game.cpp | 72 ++++++++++++++++++++++------------------------------ 1 file changed, 31 insertions(+), 41 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 706d1b7930651..2248a581a3c11 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -6860,51 +6860,41 @@ bool game::is_zones_manager_open() const } static void zones_manager_shortcuts( const catacurses::window &w_info, faction_id const &faction, - bool show_all_zones ) + bool show_all_zones, const input_context &ctxt, const int width ) { werase( w_info ); - int tmpx = 1; - tmpx += shortcut_print( w_info, point( tmpx, 1 ), c_white, c_light_green, _( "dd" ) ) + 2; - tmpx += shortcut_print( w_info, point( tmpx, 1 ), c_white, c_light_green, _( "

ersonal" ) ) + 2; - tmpx += shortcut_print( w_info, point( tmpx, 1 ), c_white, c_light_green, _( "emove" ) ) + 2; - tmpx += shortcut_print( w_info, point( tmpx, 1 ), c_white, c_light_green, _( "nable" ) ) + 2; - shortcut_print( w_info, point( tmpx, 1 ), c_white, c_light_green, _( "isable" ) ); - - tmpx = 1; - shortcut_print( w_info, point( tmpx, 2 ), c_white, c_light_green, - _( "-Toggle zone display" ) ); - - tmpx += shortcut_print( w_info, point( tmpx, 3 ), c_white, c_light_green, - _( "-Enable personal" ) ) + 2; - shortcut_print( w_info, point( tmpx, 3 ), c_white, c_light_green, - _( "-Disable personal" ) ); - - tmpx = 1; - tmpx += shortcut_print( w_info, point( tmpx, 4 ), c_white, c_light_green, - _( "<+-> Move up/down" ) ) + 2; - shortcut_print( w_info, point( tmpx, 4 ), c_white, c_light_green, _( "-Edit" ) ); - - tmpx = 1; - std::string all_zones = _( "how all" ); - std::string distant_zones = _( "Hide distant" ); - std::array selection_color = { c_dark_gray, c_dark_gray }; - selection_color[int( !show_all_zones )] = c_yellow; - - nc_color current_color = selection_color[0]; - tmpx += shortcut_print( w_info, point( tmpx, 5 ), current_color, c_light_green, all_zones ); - current_color = c_white; - print_colored_text( w_info, point( tmpx, 5 ), current_color, current_color, " / " ); - tmpx += 3; - current_color = selection_color[1]; - print_colored_text( w_info, point( tmpx, 5 ), current_color, current_color, distant_zones ); - tmpx += utf8_width( distant_zones ) + 2; - - shortcut_print( w_info, point( tmpx, 5 ), c_white, c_light_green, _( "ap" ) ); + std::vector keybinding_tips; + std::vector act_descs; + + std::string show_zones_text = show_all_zones ? "Hide distant zones" : "Show all zones"; + std::string zone_faction = string_format( _( "Shown faction: %s" ), faction.str() ); + const auto add_action_desc = [&]( const std::string & act, const std::string & txt ) { + act_descs.emplace_back( ctxt.get_desc( act, txt, input_context::allow_all_keys ) ); + }; + add_action_desc( "ADD_ZONE", pgettext( "zones manager", "Add" ) ); + add_action_desc( "ADD_PERSONAL_ZONE", pgettext( "zones manager", "Personal" ) ); + add_action_desc( "REMOVE_ZONE", pgettext( "zones manager", "Remove" ) ); + add_action_desc( "ENABLE_ZONE", pgettext( "zones manager", "Enable" ) ); + add_action_desc( "DISABLE_ZONE", pgettext( "zones manager", "Disable zone" ) ); + add_action_desc( "TOGGLE_ZONE_DISPLAY", pgettext( "zones manager", "Toggle zone display" ) ); + add_action_desc( "ENABLE_PERSONAL_ZONES", pgettext( "zones manager", "Enable personal" ) ); + add_action_desc( "DISABLE_PERSONAL_ZONES", pgettext( "zones manager", "Disable personal" ) ); + add_action_desc( "MOVE_ZONE_UP", pgettext( "zones manager", "Move up" ) ); + add_action_desc( "MOVE_ZONE_DOWN", pgettext( "zones manager", "Move down" ) ); + add_action_desc( "CONFIRM", pgettext( "zones manager", "Edit" ) ); + add_action_desc( "SHOW_ALL_ZONES", pgettext( "zones manager", show_zones_text.c_str() ) ); + add_action_desc( "SHOW_ZONE_ON_MAP", pgettext( "zones manager", "Map" ) ); if( debug_mode ) { - shortcut_print( w_info, point( 1, 6 ), c_light_red, c_light_green, - string_format( _( "Shown action: %s" ), faction.str() ) ); + add_action_desc( "CHANGE_FACTION", pgettext( "zones manager", zone_faction.c_str() ) ); + } + keybinding_tips = foldstring( enumerate_as_string( act_descs, enumeration_conjunction::none ), + width - 2 ); + + for( size_t i = 0; i < keybinding_tips.size(); ++i ) { + nc_color dummy = c_white; + print_colored_text( w_info, point( 1, 1 + i ), dummy, c_white, keybinding_tips[i] ); } wnoutrefresh( w_info ); @@ -7197,7 +7187,7 @@ void game::zones_manager() return; } zones_manager_draw_borders( w_zones_border, w_zones_info_border, zone_ui_height, width ); - zones_manager_shortcuts( w_zones_info, zones_faction, show_all_zones ); + zones_manager_shortcuts( w_zones_info, zones_faction, show_all_zones, ctxt, width ); if( zone_cnt == 0 ) { werase( w_zones ); From 15bc466a6463f3a34cf8c6f234ae61fc81fbb5a8 Mon Sep 17 00:00:00 2001 From: Kilvoctu Date: Tue, 21 Jan 2025 20:28:29 -0600 Subject: [PATCH 2/2] reword show_all_zones string to be more intuitive also squash in rename "Disable zone" to "Disable" for consistency fix move zone up/down being reversed github bot suggestions Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/game.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 2248a581a3c11..6d7e722ccf1b9 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -6866,9 +6866,8 @@ static void zones_manager_shortcuts( const catacurses::window &w_info, faction_i std::vector keybinding_tips; std::vector act_descs; - - std::string show_zones_text = show_all_zones ? "Hide distant zones" : "Show all zones"; - std::string zone_faction = string_format( _( "Shown faction: %s" ), faction.str() ); + std::string show_zones_text = show_all_zones ? "Showing all zones" : "Hiding distant zones"; + std::string zone_faction = string_format( _( "Shown faction: %s" ), faction.str() ); const auto add_action_desc = [&]( const std::string & act, const std::string & txt ) { act_descs.emplace_back( ctxt.get_desc( act, txt, input_context::allow_all_keys ) ); }; @@ -6877,7 +6876,7 @@ static void zones_manager_shortcuts( const catacurses::window &w_info, faction_i add_action_desc( "ADD_PERSONAL_ZONE", pgettext( "zones manager", "Personal" ) ); add_action_desc( "REMOVE_ZONE", pgettext( "zones manager", "Remove" ) ); add_action_desc( "ENABLE_ZONE", pgettext( "zones manager", "Enable" ) ); - add_action_desc( "DISABLE_ZONE", pgettext( "zones manager", "Disable zone" ) ); + add_action_desc( "DISABLE_ZONE", pgettext( "zones manager", "Disable" ) ); add_action_desc( "TOGGLE_ZONE_DISPLAY", pgettext( "zones manager", "Toggle zone display" ) ); add_action_desc( "ENABLE_PERSONAL_ZONES", pgettext( "zones manager", "Enable personal" ) ); add_action_desc( "DISABLE_PERSONAL_ZONES", pgettext( "zones manager", "Disable personal" ) ); @@ -6891,7 +6890,6 @@ static void zones_manager_shortcuts( const catacurses::window &w_info, faction_i } keybinding_tips = foldstring( enumerate_as_string( act_descs, enumeration_conjunction::none ), width - 2 ); - for( size_t i = 0; i < keybinding_tips.size(); ++i ) { nc_color dummy = c_white; print_colored_text( w_info, point( 1, 1 + i ), dummy, c_white, keybinding_tips[i] ); @@ -7522,7 +7520,7 @@ void game::zones_manager() } blink = false; - } else if( action == "MOVE_ZONE_UP" && zone_cnt > 1 ) { + } else if( action == "MOVE_ZONE_DOWN" && zone_cnt > 1 ) { if( active_index < zone_cnt - 1 ) { mgr.swap( zones[active_index], zones[active_index + 1] ); zones = get_zones(); @@ -7531,7 +7529,7 @@ void game::zones_manager() blink = false; stuff_changed = true; - } else if( action == "MOVE_ZONE_DOWN" && zone_cnt > 1 ) { + } else if( action == "MOVE_ZONE_UP" && zone_cnt > 1 ) { if( active_index > 0 ) { mgr.swap( zones[active_index], zones[active_index - 1] ); zones = get_zones();