Skip to content

Commit

Permalink
Compass widgets: Minor formatting adjustments
Browse files Browse the repository at this point in the history
Co-authored-by: Eric Pierce <[email protected]>
  • Loading branch information
dseguin and wapcaplet committed Jan 7, 2022
1 parent 43013c3 commit f3fb0fe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
19 changes: 15 additions & 4 deletions src/panels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2251,9 +2251,19 @@ std::string display::colorized_compass_legend_text_color( int width, int height
}
}
for( const auto &m : mlist ) {
nc_color danger = c_dark_gray;
if( m.first->difficulty >= 30 ) {
danger = c_red;
} else if( m.first->difficulty >= 16 ) {
danger = c_light_red;
} else if( m.first->difficulty >= 8 ) {
danger = c_white;
} else if( m.first->agro > 0 ) {
danger = c_light_gray;
}
std::string name = m.second > 1 ? string_format( "%d ", m.second ) : "";
name += string_format( name_fmt, colorize( m.first->sym, m.first->color ),
m.first->nname( m.second ) );
name = colorize( name + m.first->nname( m.second ), danger );
name = string_format( name_fmt, colorize( m.first->sym, m.first->color ), name );
names.emplace_back( name );
}
// Split names into X lines, where X = height.
Expand All @@ -2273,7 +2283,8 @@ std::string display::colorized_compass_legend_text_color( int width, int height
if( nidx < nsize ) {
nwidth = utf8_width( names[nidx], true );
if( wavail > nwidth ) {
ret += " ";
ret += " ";
wavail -= 2;
}
}
}
Expand Down Expand Up @@ -3251,7 +3262,7 @@ static std::vector<window_panel> initialize_default_custom_panels( const widget
#endif // TILES
ret.emplace_back( window_panel( draw_compass_padding_compact, "Compass",
to_translation( "Compass" ),
5, width, true ) );
5, width, false ) );
ret.emplace_back( window_panel( draw_overmap, "Overmap", to_translation( "Overmap" ),
7, width, false ) );

Expand Down
8 changes: 4 additions & 4 deletions tests/widget_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ TEST_CASE( "radiation badge widget", "[widget][radiation]" )
CHECK( rads_w.layout( ava ) == "RADIATION: <color_c_pink> black </color>" );
}

TEST_CASE( "compass widget", "[widget]" )
TEST_CASE( "compass widget", "[widget][compass]" )
{
const int sidebar_width = 36;
widget c5s_N = widget_test_compass_N.obj();
Expand Down Expand Up @@ -619,11 +619,11 @@ TEST_CASE( "compass widget", "[widget]" )
CHECK( c5s_N_nodir_nowidth.layout( ava, sidebar_width ) ==
"N: " );
CHECK( c5s_legend1.layout( ava, sidebar_width ) ==
"3 <color_c_white>B</color> monster producing CBMs when dissected" );
"<color_c_white>B</color> 3 monster producing CBMs when dissected" );
CHECK( c5s_legend3.layout( ava, sidebar_width ) ==
"3 <color_c_white>B</color> monster producing CBMs when dissected\n" );
"<color_c_white>B</color> 3 monster producing CBMs when dissected\n" );
CHECK( c5s_legend5.layout( ava, sidebar_width ) ==
"3 <color_c_white>B</color> monster producing CBMs when dissected\n" );
"<color_c_white>B</color> 3 monster producing CBMs when dissected\n" );
}

SECTION( "3 different monsters N" ) {
Expand Down

0 comments on commit f3fb0fe

Please sign in to comment.