Skip to content

Commit

Permalink
fix: Fix overlapping text in look-around. (#4156)
Browse files Browse the repository at this point in the history
* 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).
  • Loading branch information
richardnlarge authored Jan 25, 2024
1 parent ac5742f commit 273f510
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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();
Expand All @@ -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 );
}
Expand All @@ -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,
Expand Down

0 comments on commit 273f510

Please sign in to comment.