Skip to content

Commit

Permalink
Rearrange panels
Browse files Browse the repository at this point in the history
  • Loading branch information
ymber committed Apr 22, 2020
1 parent afd5c72 commit 5671a96
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 100 deletions.
65 changes: 34 additions & 31 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5863,44 +5863,50 @@ void game::print_visibility_info( const catacurses::window &w_look, int column,
}

void game::print_terrain_info( const tripoint &lp, const catacurses::window &w_look,
const std::string &area_name, int column,
int &line )
const std::string &area_name, int column, int &line )
{
const int max_width = getmaxx( w_look ) - column - 1;

// Print OMT type and terrain type on first line.
std::string tile = m.tername( lp );
mvwprintz( w_look, point( column, line ), c_light_gray, _( "Place : " ) );
trim_and_print( w_look, point( column + 8, line ), max_width - 8, c_white, area_name );

mvwprintz( w_look, point( column, ++line ), c_light_gray, _( "Tile : " ) );
trim_and_print( w_look, point( column + 8, line ), max_width - 8, c_light_gray, tile );
trim_and_print( w_look, point( column, line ), max_width, c_white, area_name );
trim_and_print( w_look, point( column + utf8_width( area_name ) + 1, line ), max_width,
c_light_gray, tile );

// Furniture on second line if any.
if( m.has_furn( lp ) ) {
mvwprintz( w_look, point( column, ++line ), c_light_gray, _( "Decor : " ) );
mvwprintz( w_look, point( column + 8, line ), c_light_blue, m.furnname( lp ) );
mvwprintz( w_look, point( column, ++line ), c_light_blue, m.furnname( lp ) );
}

std::pair<std::string, nc_color> ll = get_light_level( std::max( 1.0,
LIGHT_AMBIENT_LIT - m.ambient_light_at( lp ) + 1.0 ) );
mvwprintz( w_look, point( column, ++line ), c_light_gray, _( "Light : " ) );
mvwprintz( w_look, point( column + 8, line ), ll.second, ll.first );
// Cover percentage from terrain and furniture next.
fold_and_print( w_look, point( column, ++line ), max_width, c_light_gray, _( "Cover: %d%%" ),
m.coverage( lp ) );
// Terrain and furniture flags next.
mvwprintz( w_look, point( column, ++line ), c_light_gray, "%s", m.features( lp ) );

mvwprintz( w_look, point( column, ++line ), c_light_gray, _( "Move : " ) );
// Move cost from terrain and furntiure and vehicle parts.
// Vehicle part information is printed in a different function.
if( m.impassable( lp ) ) {
mvwprintz( w_look, point( column + 8, line ), c_light_red, "Impassable" );
mvwprintz( w_look, point( column, ++line ), c_light_red, _( "Impassable" ) );
} else {
mvwprintz( w_look, point( column + 8, line ), c_light_gray, "%d", m.move_cost( lp ) * 50 );
mvwprintz( w_look, point( column, ++line ), c_light_gray, _( "Move cost: %d" ),
m.move_cost( lp ) * 50 );
}

// Next print the string on any SIGN flagged furniture if any.
std::string signage = m.get_signage( lp );
if( !signage.empty() ) {
mvwprintz( w_look, point( column, ++line ), c_light_gray, _( "Sign : " ) );
trim_and_print( w_look, point( column + 8, line ), max_width - 8, c_cyan,
u.has_trait( trait_ILLITERATE ) ? _( "???" ) : "%s", signage );
std::string sign_string = u.has_trait( trait_ILLITERATE ) ? "???" : signage;
mvwprintz( w_look, point( column, ++line ), c_light_gray, _( "Sign: %s" ), sign_string );
}

// Print light level on the selected tile.
std::pair<std::string, nc_color> ll = get_light_level( std::max( 1.0,
LIGHT_AMBIENT_LIT - m.ambient_light_at( lp ) + 1.0 ) );
mvwprintz( w_look, point( column, ++line ), ll.second, ll.first );

// Print the terrain and any furntiure on the tile below and whether it is walkable.
if( m.has_zlevels() && lp.z > -OVERMAP_DEPTH && !m.has_floor( lp ) ) {
// Print info about stuff below
tripoint below( lp.xy(), lp.z - 1 );
std::string tile_below = m.tername( below );
if( m.has_furn( below ) ) {
Expand All @@ -5909,19 +5915,13 @@ void game::print_terrain_info( const tripoint &lp, const catacurses::window &w_l

if( !m.has_floor_or_support( lp ) ) {
fold_and_print( w_look, point( column, ++line ), max_width, c_dark_gray,
_( "Below : %s; No support" ),
tile_below );
_( "Below: %s; No support" ), tile_below );
} else {
fold_and_print( w_look, point( column, ++line ), max_width, c_dark_gray,
_( "Below : %s; Walkable" ),
fold_and_print( w_look, point( column, ++line ), max_width, c_dark_gray, _( "Below: %s; Walkable" ),
tile_below );
}
}

fold_and_print( w_look, point( column, ++line ), max_width, c_light_gray, _( "Cover : %d%% \n" ),
m.coverage( lp ) );
mvwprintz( w_look, point( column, ++line ), c_light_gray, _( "Type : " ) );
trim_and_print( w_look, point( column + 8, line ), max_width - 8, c_light_gray, m.features( lp ) );
++line;
}

Expand Down Expand Up @@ -5980,8 +5980,11 @@ void game::print_vehicle_info( const vehicle *veh, int veh_part, const catacurse
const int column, int &line, const int last_line )
{
if( veh ) {
mvwprintz( w_look, point( column, ++line ), c_light_gray, _( "Auto : " ) );
mvwprintz( w_look, point( column + 8, line ), c_white, "%s", veh->name );
// Print the name of the vehicle.
mvwprintz( w_look, point( column, ++line ), c_light_gray, _( "Vehicle: " ) );
mvwprintz( w_look, point( column + utf8_width( _( "Vehicle: " ) ), line ), c_white, "%s",
veh->name );
// Then the list of parts on that tile.
line = veh->print_part_list( w_look, ++line, last_line, getmaxx( w_look ), veh_part );
}
}
Expand Down Expand Up @@ -6064,7 +6067,7 @@ void game::print_graffiti_info( const tripoint &lp, const catacurses::window &w_
const int max_width = getmaxx( w_look ) - column - 2;
if( m.has_graffiti_at( lp ) ) {
fold_and_print( w_look, point( column, ++line ), max_width, c_light_gray,
m.ter( lp ) == t_grave_new ? _( "Graff : %s" ) : _( "Note : %s" ),
m.ter( lp ) == t_grave_new ? _( "Graffiti: %s" ) : _( "inscription: %s" ),
m.graffiti_at( lp ) );
}
}
Expand Down
72 changes: 24 additions & 48 deletions src/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,70 +636,46 @@ static std::pair<std::string, nc_color> hp_description( int cur_hp, int max_hp )
int monster::print_info( const catacurses::window &w, int vStart, int vLines, int column ) const
{
const int vEnd = vStart + vLines;
const int max_width = getmaxx( w ) - column - 1;

mvwprintz( w, point( column, vStart ), c_light_gray, _( "Entity: " ) );
mvwprintz( w, point( column + 8, vStart ), c_white, name() );

std::string effects = get_effect_status();
size_t used_space = utf8_width( "Entity: " ) + utf8_width( name() ) + 3;
trim_and_print( w, point( used_space, vStart ), getmaxx( w ) - used_space - 2,
h_white, effects );

// Print health bar, monster name, then statuses on the first line.
nc_color color = c_white;
std::string sText;
get_HP_Bar( color, sText );
mvwprintz( w, point( column, ++vStart ), c_light_gray, _( "Health: " ) );
mvwprintz( w, point( column + 8, vStart ), color, sText );

std::string senses_str = "--";
if( sees( g->u ) ) {
senses_str = _( "It knows you're there" );
} else {
senses_str = _( "It hasn't detected you" );
}
mvwprintz( w, point( column, ++vStart ), c_light_gray, _( "Senses: " ) );
mvwprintz( w, point( column + 8, vStart ), sees( g->u ) ? c_red : c_green, senses_str );
std::string bar_str;
get_HP_Bar( color, bar_str );
mvwprintz( w, point( column, vStart ), color, bar_str );

std::pair<std::string, nc_color> att = get_attitude();
mvwprintz( w, point( column, ++vStart ), c_light_gray, _( "Stance: " ) );
mvwprintz( w, point( column + 8, vStart ), att.second, att.first );
mvwprintz( w, point( column + utf8_width( bar_str ) + 1, vStart ), c_white, name() );
trim_and_print( w, point( utf8_width( bar_str ) + utf8_width( name() ) + 1, vStart ),
max_width - utf8_width( bar_str ) - utf8_width( name() ) - 1, h_white, get_effect_status() );

int threatlvl = type->difficulty;
nc_color threatlvl_color = c_white;
if( threatlvl >= 20 ) {
threatlvl_color = c_red;
} else if( threatlvl >= 10 ) {
threatlvl_color = c_yellow;
} else if( threatlvl >= 0 ) {
threatlvl_color = c_blue;
}
mvwprintz( w, point( column, ++vStart ), c_light_gray, _( "Threat: " ) );
mvwprintz( w, point( column + 8, vStart ), threatlvl_color, to_string( threatlvl ) );

mvwprintz( w, point( column, ++vStart ), c_light_gray, _( "Aspect: " ) );
std::vector<std::string> line1 = foldstring( type->get_description(), getmaxx( w ) - 9 - column );

int offset = utf8_width( line1[0] );
std::string test = type->get_description().substr( offset );
std::vector<std::string> lines = foldstring( test, getmaxx( w ) - 2 - column );
// Hostility indicator on the second line.
std::pair<std::string, nc_color> att = get_attitude();
mvwprintz( w, point( column, ++vStart ), att.second, att.first );

mvwprintz( w, point( column + 8, vStart ), c_dark_gray, line1[0] );
// Awareness indicator in the third line.
std::string senses_str = sees( g->u ) ? _( "It knows you're there" ) :
_( "It hasn't detected you" );
mvwprintz( w, point( column, ++vStart ), sees( g->u ) ? c_red : c_green, senses_str );

// Monster description on following lines.
std::vector<std::string> lines = foldstring( type->get_description(), max_width );
int numlines = lines.size();
for( int i = 0; i < numlines && vStart <= vEnd; i++ ) {
mvwprintz( w, point( column, ++vStart ), c_dark_gray, lines[i] );
mvwprintz( w, point( column, ++vStart ), c_light_gray, lines[i] );
}
++vStart;

// Riding indicator on next line after description.
if( has_effect( effect_ridden ) && mounted_player ) {
mvwprintz( w, point( column, vStart++ ), c_white, _( "Rider : %s" ), mounted_player->disp_name() );
mvwprintz( w, point( column, ++vStart ), c_white, _( "Rider : %s" ), mounted_player->disp_name() );
}

// Show monster size on the last line
if( size_bonus > 0 ) {
wprintz( w, c_light_gray, _( " It is %s." ), size_names.at( get_size() ) );
mvwprintz( w, point( column, ++vStart ), c_light_gray, _( " It is %s." ),
size_names.at( get_size() ) );
}

return vStart;
return ++vStart;
}

std::string monster::extended_description() const
Expand Down
41 changes: 20 additions & 21 deletions src/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2218,37 +2218,35 @@ int npc::print_info( const catacurses::window &w, int line, int vLines, int colu
// is a blank line. w is 13 characters tall, and we can't use the last one
// because it's a border as well; so we have lines 6 through 11.
// w is also 48 characters wide - 2 characters for border = 46 characters for us
mvwprintz( w, point( column, line ), c_light_gray, _( "Entity: " ) );
trim_and_print( w, point( column + 8, line ), iWidth - 8, c_white, name );

mvwprintz( w, point( column, ++line ), c_light_gray, _( "Health: " ) );
mvwprintz( w, point( column + 8, line ),
get_hp_bar( hp_percentage(), 200 ).second,
get_hp_bar( hp_percentage(), 100 ).first );

if( sees( g->u ) ) {
mvwprintz( w, point( column, ++line ), c_light_gray, _( "Senses: " ) );
mvwprintz( w, point( column + 8, line ), c_yellow, _( "Aware of your presence" ) );
}else {
mvwprintz( w, point( column, ++line ), c_light_gray, _( "Senses: " ) );
mvwprintz( w, point( column + 8, line ), c_green, _( "Unaware of you" ) );
}
// Print health bar and NPC name on the first line.
std::pair<std::string, nc_color> bar = get_hp_bar( hp_percentage(), 100 );
mvwprintz( w, point( column, line ), bar.second, bar.first );
trim_and_print( w, point( column + bar.first.length() + 1, line ), iWidth, c_white, name );

// Hostility indicator in the second line.
Attitude att = attitude_to( g->u );
const std::pair<translation, nc_color> res = Creature::get_attitude_ui_data( att );
mvwprintz( w, point( column, ++line ), c_light_gray, _( "Stance: " ) );
mvwprintz( w, point( column + 8, line ), res.second, res.first.translated() );
mvwprintz( w, point( column, ++line ), res.second, res.first.translated() );

// Awareness indicator on the third line.
std::string senses_str = sees( g->u ) ? _( "Aware of your presence" ) :
_( "Unaware of you" );
mvwprintz( w, point( column, ++line ), sees( g->u ) ? c_yellow : c_green, senses_str );

// Print what item the NPC is holding if any on the fourth line.
if( is_armed() ) {
mvwprintz( w, point( column, ++line ), c_light_gray, _( "Wield : " ) );
trim_and_print( w, point( column + 8, line ), iWidth, c_red, weapon.tname() );
mvwprintz( w, point( column, ++line ), c_light_gray, _( "Wielding: " ) );
trim_and_print( w, point( column + utf8_width( _( "Wielding: " ) ), line ), iWidth, c_red,
weapon.tname() );
}

const auto enumerate_print = [ w, last_line, column, iWidth, &line ]( const std::string & str_in,
nc_color color ) {
// function to build a list of worn apparel, first line is shorter due to label taking space.
// build 1st line
const std::vector<std::string> shortlist = foldstring( str_in, iWidth - 8 );
const std::vector<std::string> shortlist = foldstring( str_in,
iWidth - utf8_width( _( "Wearing: " ) ) );
// calc how much we could cram into the first line
int offset = utf8_width( shortlist[0] );
// substract that from initial string
Expand All @@ -2257,7 +2255,8 @@ int npc::print_info( const catacurses::window &w, int line, int vLines, int colu
const std::vector<std::string> longlist = foldstring( test, iWidth );

// print 1st line, from shortlist with label offset
mvwprintz( w, point( column + 8, line++ ), color, shortlist[0] );
mvwprintz( w, point( column + utf8_width( _( "Wearing: " ) ), line++ ), color,
shortlist[0] );

// print the rest from longlist
for( auto it = longlist.begin(); it < longlist.end() && line < last_line; ++it, ++line ) {
Expand All @@ -2270,7 +2269,7 @@ int npc::print_info( const catacurses::window &w, int line, int vLines, int colu
} );
if( !worn_str.empty() ) {
const std::string wearing = worn_str;
mvwprintz( w, point( column, ++line ), c_light_gray, _( "Outfit: " ) );
mvwprintz( w, point( column, ++line ), c_light_gray, _( "Wearing: " ) );
enumerate_print( wearing, c_dark_gray );
}

Expand Down

0 comments on commit 5671a96

Please sign in to comment.