Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refresh look_around appearance #36324

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1ad1d52
refresh look_around appearance
captnblood Dec 21, 2019
dfa1412
fix astyle regressions
captnblood Dec 21, 2019
4212753
fix astyle regressions
captnblood Dec 21, 2019
4b184b4
Update src/monster.cpp
Dec 21, 2019
c2bcda6
Update src/monster.cpp
Dec 21, 2019
f255056
Update src/monster.cpp
Dec 21, 2019
223ceeb
Update src/monster.cpp
Dec 21, 2019
e8197de
Update src/monster.cpp
Dec 21, 2019
de27a2e
Update src/monster.cpp
Dec 21, 2019
b8ad97f
Update src/monster.cpp
Dec 21, 2019
63b375d
Update src/monster.cpp
Dec 21, 2019
52fe0c2
Update game.cpp
Dec 21, 2019
1f388fe
fix translation symbols
captnblood Dec 21, 2019
80bd778
Update src/game.cpp
Dec 22, 2019
fac609d
item labels in colors
captnblood Dec 22, 2019
fa620f4
correct item colors
captnblood Dec 23, 2019
3b3e1eb
some cleanup and astyle
captnblood Dec 23, 2019
bd814f6
fix monster description
captnblood Dec 23, 2019
66e6ae1
monster desc
captnblood Dec 23, 2019
8310289
monster effect
captnblood Dec 24, 2019
cc30675
Merge remote-tracking branch 'upstream/master' into look_around_refresh
captnblood Dec 24, 2019
01a5458
Merge branch 'master' of https://github.com/CleverRaven/Cataclysm-DDA…
captnblood Dec 25, 2019
52ed7be
fixing some offsets
captnblood Dec 27, 2019
e40928a
astyle..
captnblood Dec 27, 2019
da84371
various cleanups, added npc
captnblood Dec 31, 2019
d5e7ca4
better display on narrow panel themes
captnblood Dec 31, 2019
5621cc1
prevent line overflow
captnblood Dec 31, 2019
5245f2b
Merge branch 'master' into look_around_refresh
Apr 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 29 additions & 26 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5803,33 +5803,35 @@ 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;

std::string tile = m.tername( lp );
tile = _( "Place : " ) + area_name + _( "\nTile : " ) + tile;
mvwprintz( w_look, point( column, line ), c_light_gray, _( "Place : " ) );
trim_and_print( w_look, point( column + 9, line ), max_width - 9, c_white, area_name );

mvwprintz( w_look, point( column, ++line ), c_light_gray, _( "Tile : " ) );
trim_and_print( w_look, point( column + 9, line ), max_width - 9, c_light_gray, tile );

if( m.has_furn( lp ) ) {
tile += "\n";
tile += _( "Decor : " ) + m.furnname( lp );
mvwprintz( w_look, point( column, ++line ), c_light_gray, _( "Decor : " ) );
mvwprintz( w_look, point( column + 9, line ), c_light_blue, m.furnname( lp ) );
}
const auto 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 + 9, line ), ll.second, ll.first );

if( m.impassable( lp ) ) {
lines = fold_and_print( w_look, point( column, line ), max_width, c_light_gray,
_( "%s, Impassable" ),
tile );
mvwprintz( w_look, point( column, ++line ), c_light_gray, _( "Move : " ) );
mvwprintz( w_look, point( column + 9, line ), c_light_red, "Impassable" );
} else {
lines = fold_and_print( w_look, point( column, line ), max_width, c_light_gray,
_( "%s\nMove : %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 ) );
mvwprintz( w_look, point( column, ++lines ), c_light_gray, _( "Light : " ) );
mvwprintz( w_look, point( column + 9, lines ), ll.second, ll.first );
mvwprintz( w_look, point( column, ++line ), c_light_gray, _( "Move : " ) );
mvwprintz( w_look, point( column + 9, line ), c_light_gray, "%d", m.move_cost( lp ) * 50 );
}

std::string signage = m.get_signage( lp );
if( !signage.empty() ) {
mvwprintz( w_look, point( column, ++lines ), c_light_gray, _( "Sign : " ) );
trim_and_print( w_look, point( column + 9, lines ), max_width, c_cyan,
mvwprintz( w_look, point( column, ++line ), c_light_gray, _( "Sign : " ) );
trim_and_print( w_look, point( column + 9, line ), max_width, c_cyan,
// NOLINTNEXTLINE(cata-text-style): the question mark does not end a sentence
u.has_trait( trait_ILLITERATE ) ? _( "???" ) : "%s", signage );
}
Expand All @@ -5843,22 +5845,21 @@ 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, ++lines ), max_width, c_dark_gray,
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,
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, ++lines ), max_width, c_light_gray, _( "Cover : %d%% \n" ),
fold_and_print( w_look, point( column, ++line ), max_width, c_light_gray, _( "Cover : %d%% \n" ),
m.coverage( lp ) );
fold_and_print( w_look, point( column, ++lines ), max_width, c_light_gray,
_( "Type : " ) + m.features( lp ) );
if( line < lines ) {
line = lines + 1;
}

mvwprintz( w_look, point( column, ++line ), c_light_gray, _( "Type : " ) );
trim_and_print( w_look, point( column + 9, line ), max_width - 9, c_light_gray, m.features( lp ) );
++line;
}

void game::print_fields_info( const tripoint &lp, const catacurses::window &w_look, int column,
Expand Down Expand Up @@ -5918,7 +5919,9 @@ void game::print_vehicle_info( const vehicle *veh, int veh_part, const catacurse
const int column, int &line, const int last_line )
{
if( veh ) {
mvwprintw( w_look, point( column, ++line ), _( "There is a %s there. Parts:" ), veh->name );
// display vehicle
mvwprintz( w_look, point( column, ++line ), c_light_gray, _( "Vehicle: " ) );
mvwprintz( w_look, point( column + 9, line ), c_white, "%s", veh->name );
line = veh->print_part_list( w_look, ++line, last_line, getmaxx( w_look ), veh_part );
}
}
Expand Down
27 changes: 16 additions & 11 deletions src/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,6 @@ int monster::print_info( const catacurses::window &w, int vStart, int vLines, in
mvwprintz( w, point( column, vStart ), c_light_gray, _( "Entity : " ) );
mvwprintz( w, point( column + 9, vStart ), c_white, name() );

const auto att = get_attitude();
std::string effects = get_effect_status();
//size_t used_space = utf8_width( att.first ) + utf8_width( name() ) + 3;
size_t used_space = utf8_width( "Entity : " ) + utf8_width( name() ) + 3;
Expand All @@ -618,24 +617,25 @@ int monster::print_info( const catacurses::window &w, int vStart, int vLines, in
// display sense
std::string senses_str = "--";
if( sees( g->u ) ) {
senses_str = _( "It is aware of your presence" );
senses_str = _( "Aware of your presence" );
} else {
senses_str = _( "It hasn't noticed you" );
senses_str = _( "Unaware of your presence" );
This conversation was marked as resolved.
Show resolved Hide resolved
}

mvwprintz( w, point( column, ++vStart ), c_light_gray, _( "Senses : " ) );
mvwprintz( w, point( column + 9, vStart ), sees( g->u ) ? c_red : c_green, senses_str );

// display stance
const auto att = get_attitude();
mvwprintz( w, point( column, ++vStart ), c_light_gray, _( "Stance : " ) );
mvwprintz( w, point( column + 9, vStart ), att.second, att.first );

// display threat
int threatlvl = type->difficulty;
nc_color threatlvl_color = c_white;
if( threatlvl >= 8 ) {
if( threatlvl >= 20 ) {
threatlvl_color = c_red;
} else if( threatlvl >= 4 ) {
} else if( threatlvl >= 10 ) {
threatlvl_color = c_yellow;
} else if( threatlvl >= 0 ) {
threatlvl_color = c_blue;
Expand All @@ -645,16 +645,21 @@ int monster::print_info( const catacurses::window &w, int vStart, int vLines, in
mvwprintz( w, point( column + 9, vStart ), threatlvl_color, to_string( threatlvl ) );

// dipslay aspect
//mvwprintz( w, point( column, ++vStart ), c_light_gray, _( "Aspect :" ) );
vStart++;
std::vector<std::string> lines = foldstring( type->get_description(), getmaxx( w ) - 1 - column );
mvwprintz( w, point( column, ++vStart ), c_light_gray, _( "Aspect :" ) );
std::vector<std::string> line1 = foldstring( type->get_description(), getmaxx( w ) - 10 - 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 );

mvwprintz( w, point( column + 9, vStart ), c_dark_gray, line1[0] );
int numlines = lines.size();
for( int i = 0; i < numlines && vStart <= vEnd; i++ ) {
mvwprintz( w, point( column, ++vStart ), c_white, lines[i] );
mvwprintz( w, point( column, ++vStart ), c_dark_gray, lines[i] );
}

++vStart;
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() );
}

if( size_bonus > 0 ) {
Expand Down
53 changes: 45 additions & 8 deletions src/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2196,20 +2196,55 @@ 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_white, _( "NPC: %s" ), name );

// display name
mvwprintz( w, point( column, line ), c_light_gray, _( "Entity : " ) );
mvwprintz( w, point( column + 9, line ), c_white, name );

// display health bars
mvwprintz( w, point( column, ++line ), c_light_gray, _( "Health : " ) );
mvwprintz( w, point( column + 9, line ),
get_hp_bar( hp_percentage(), 200 ).second,
get_hp_bar( hp_percentage(), 100 ).first );

// display senses
if( sees( g->u ) ) {
mvwprintz( w, point( column, line++ ), c_yellow, _( "Aware of your presence!" ) );
mvwprintz( w, point( column, ++line ), c_light_gray, _( "Senses : " ) );
mvwprintz( w, point( column + 9, line ), c_yellow, _( "Aware of your presence!" ) );
} else {
mvwprintz( w, point( column, ++line ), c_light_gray, _( "Senses : " ) );
mvwprintz( w, point( column + 9, line ), c_green, _( "Ignoring your presence" ) );
}

// display stance
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 + 9, line ), res.second, res.first.translated() );

// display weapon
if( is_armed() ) {
trim_and_print( w, point( column, line++ ), iWidth, c_red, _( "Wielding a %s" ), weapon.tname() );
mvwprintz( w, point( column, ++line ), c_light_gray, _( "Wield : " ) );
trim_and_print( w, point( column + 9, line ), iWidth, c_red, weapon.tname() );
}

const auto enumerate_print = [ w, last_line, column, iWidth, &line ]( const std::string & str_in,
nc_color color ) {
const std::vector<std::string> folded = foldstring( str_in, iWidth );
for( auto it = folded.begin(); it < folded.end() && line < last_line; ++it, ++line ) {
// 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 - 9 );
// calc how much we could cram into the first line
int offset = utf8_width( shortlist[0] );
// substract that from initial string
std::string test = str_in.substr( offset );
// build new vector of strings without the portion we've already put on 1st line
const std::vector<std::string> longlist = foldstring( test, iWidth );

// print 1st line, from shortlist with label offset
mvwprintz( w, point( column + 9, line++ ), color, shortlist[0] );

// print the rest from longlist
for( auto it = longlist.begin(); it < longlist.end() && line < last_line; ++it, ++line ) {
trim_and_print( w, point( column, line ), iWidth, color, *it );
}
};
Expand All @@ -2218,8 +2253,10 @@ int npc::print_info( const catacurses::window &w, int line, int vLines, int colu
return it.tname();
} );
if( !worn_str.empty() ) {
const std::string wearing = _( "Wearing: " ) + worn_str;
enumerate_print( wearing, c_light_blue );
// display worn apparel
const std::string wearing = worn_str;
mvwprintz( w, point( column, ++line ), c_light_gray, _( "Apparel: " ) );
enumerate_print( wearing, c_dark_gray );
}

// as of now, visibility of mutations is between 0 and 10
Expand All @@ -2239,7 +2276,7 @@ int npc::print_info( const catacurses::window &w, int line, int vLines, int colu

const auto trait_str = visible_mutations( visibility_cap );
if( !trait_str.empty() ) {
const std::string mutations = _( "Traits: " ) + trait_str;
const std::string mutations = _( "Traits : " ) + trait_str;
enumerate_print( mutations, c_green );
}

Expand Down