From 273f51063c1c1cf254c9ad0184655418f4126535 Mon Sep 17 00:00:00 2001 From: richardnlarge Date: Wed, 24 Jan 2024 20:23:11 -0500 Subject: [PATCH] fix: Fix overlapping text in look-around. (#4156) * Prevent overlapping lines in look-around panel. Lines were being drawn on top of one another, making text unreadable. fixes #4140, fixes #3945 * Fix cursor placement for printing visibility text. "point" constructor takes (x, y) and was being fed (y, x). --- src/game.cpp | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 9d68459be86b..47c2c92b1898 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -5863,7 +5863,7 @@ void game::print_visibility_info( const catacurses::window &w_look, int column, break; } - mvwprintw( w_look, point( line, column ), visibility_message ); + mvwprintw( w_look, point( column, line ), visibility_message ); line += 2; } @@ -5872,7 +5872,6 @@ void game::print_terrain_info( const tripoint &lp, const catacurses::window &w_l int &line ) { const int max_width = getmaxx( w_look ) - column - 1; - int lines; const auto fmt_tile_info = []( const tripoint & lp ) { map &here = get_map(); @@ -5897,23 +5896,23 @@ void game::print_terrain_info( const tripoint &lp, const catacurses::window &w_l std::string tile = string_format( "(%s) %s", area_name, fmt_tile_info( lp ) ); if( m.impassable( lp ) ) { - lines = fold_and_print( w_look, point( column, line ), max_width, c_light_gray, + line += fold_and_print( w_look, point( column, line ), max_width, c_light_gray, _( "%s; Impassable" ), tile ); } else { - lines = fold_and_print( w_look, point( column, line ), max_width, c_light_gray, + line += fold_and_print( w_look, point( column, line ), max_width, c_light_gray, _( "%s; Movement cost %d" ), tile, m.move_cost( lp ) * 50 ); const auto ll = get_light_level( std::max( 1.0, LIGHT_AMBIENT_LIT - m.ambient_light_at( lp ) + 1.0 ) ); - mvwprintw( w_look, point( column, ++lines ), _( "Lighting: " ) ); + mvwprintw( w_look, point( column, line++ ), _( "Lighting: " ) ); wprintz( w_look, ll.second, ll.first ); } std::string signage = m.get_signage( lp ); if( !signage.empty() ) { - trim_and_print( w_look, point( column, ++lines ), max_width, c_dark_gray, + trim_and_print( w_look, point( column, line++ ), max_width, c_dark_gray, // NOLINTNEXTLINE(cata-text-style): the question mark does not end a sentence u.has_trait( trait_ILLITERATE ) ? _( "Sign: ???" ) : _( "Sign: %s" ), signage ); } @@ -5924,23 +5923,21 @@ void game::print_terrain_info( const tripoint &lp, const catacurses::window &w_l std::string tile_below = fmt_tile_info( below ); if( !m.has_floor_or_support( lp ) ) { - fold_and_print( w_look, point( column, ++lines ), max_width, c_dark_gray, - _( "Below: %s; No support" ), - tile_below ); + line += fold_and_print( w_look, point( column, line ), max_width, c_dark_gray, + _( "Below: %s; No support" ), + tile_below ); } else { - fold_and_print( w_look, point( column, ++lines ), max_width, c_dark_gray, - _( "Below: %s; Walkable" ), - tile_below ); + line += fold_and_print( w_look, point( column, line ), max_width, c_dark_gray, + _( "Below: %s; Walkable" ), + tile_below ); } } - int map_features = fold_and_print( w_look, point( column, ++lines ), max_width, c_dark_gray, - m.features( lp ) ); - fold_and_print( w_look, point( column, ++lines ), max_width, c_light_gray, _( "Coverage: %d%%" ), - m.coverage( lp ) ); - if( line < lines ) { - line = lines + map_features - 1; - } + line += fold_and_print( w_look, point( column, line ), max_width, c_dark_gray, + m.features( lp ) ); + line += fold_and_print( w_look, point( column, line ), max_width, c_light_gray, + _( "Coverage: %d%%" ), + m.coverage( lp ) ); } void game::print_fields_info( const tripoint &lp, const catacurses::window &w_look, int column,