diff --git a/src/faction.cpp b/src/faction.cpp index 98c2ba29701ba..fe398f136810b 100644 --- a/src/faction.cpp +++ b/src/faction.cpp @@ -891,11 +891,12 @@ void faction_manager::display() const for( size_t i = top_of_page; i < active_vec_size && i < top_of_page + entries_per_page; i++ ) { const int y = i - top_of_page + 3; trim_and_print( w_missions, point( 1, y ), 28, selection == i ? hilite( col ) : col, - creatures[i]->nname() ); + string_format( "%s %s", colorize( creatures[i]->sym, + selection == i ? hilite( creatures[i]->color ) : creatures[i]->color ), + creatures[i]->nname() ) ); } if( !cur_creature.is_null() ) { - int y = 2; - fold_and_print( w_missions, point( 31, ++y ), w, c_light_gray, cur_creature->get_description() ); + cur_creature->faction_display( w_missions, point( 31, 3 ), w ); } else { fold_and_print( w_missions, point( 31, 4 ), w, c_light_red, no_creatures ); } diff --git a/src/mtype.cpp b/src/mtype.cpp index 66d9b829b24b3..d5cc636b9ae67 100644 --- a/src/mtype.cpp +++ b/src/mtype.cpp @@ -10,8 +10,10 @@ #include "field_type.h" #include "item.h" #include "itype.h" +#include "mod_manager.h" #include "mondeath.h" #include "monstergenerator.h" +#include "output.h" #include "translations.h" #include "units.h" #include "weakpoint.h" @@ -279,3 +281,97 @@ const behavior::node_t *mtype::get_goals() const { return &goals; } + +void mtype::faction_display( catacurses::window &w, const point &top_left, const int width ) const +{ + int y = 0; + // Name & symbol + trim_and_print( w, top_left + point( 2, y ), width, c_white, string_format( "%s %s", colorize( sym, + color ), nname() ) ); + y++; + // Difficulty + std::string diff_str; + if( difficulty < 3 ) { + diff_str = _( "<color_light_gray>Minimal threat.</color>" ); + } else if( difficulty < 10 ) { + diff_str = _( "<color_light_gray>Mildly dangerous.</color>" ); + } else if( difficulty < 20 ) { + diff_str = _( "<color_light_red>Dangerous.</color>" ); + } else if( difficulty < 30 ) { + diff_str = _( "<color_red>Very dangerous.</color>" ); + } else if( difficulty < 50 ) { + diff_str = _( "<color_red>Extremely dangerous.</color>" ); + } else { + diff_str = _( "<color_red>Fatally dangerous!</color>" ); + } + trim_and_print( w, top_left + point( 0, ++y ), width, c_light_gray, + string_format( "%s: %s", colorize( _( "Difficulty" ), c_white ), diff_str ) ); + // Origin + std::vector<std::string> origin_list = + foldstring( string_format( "%s: %s", colorize( _( "Origin" ), c_white ), + enumerate_as_string( src.begin(), src.end(), + []( const std::pair<mtype_id, mod_id> &source ) { + return string_format( "'%s'", source.second->name() ); + }, enumeration_conjunction::arrow ) ), width ); + for( const std::string &org : origin_list ) { + trim_and_print( w, top_left + point( 0, ++y ), width, c_light_gray, org ); + } + // Size + const std::map<creature_size, std::string> size_map = { + {creature_size::tiny, translate_marker( "Tiny" )}, + {creature_size::small, translate_marker( "Small" )}, + {creature_size::medium, translate_marker( "Medium" )}, + {creature_size::large, translate_marker( "Large" )}, + {creature_size::huge, translate_marker( "Huge" )} + }; + auto size_iter = size_map.find( size ); + trim_and_print( w, top_left + point( 0, ++y ), width, c_light_gray, + string_format( "%s: %s", colorize( _( "Size" ), c_white ), + size_iter == size_map.end() ? _( "Unknown" ) : _( size_iter->second ) ) ); + // Species + std::vector<std::string> species_list = + foldstring( string_format( "%s: %s", colorize( _( "Species" ), c_white ), + enumerate_as_string( species_descriptions(), []( const std::string & sp ) { + return colorize( sp, c_yellow ); + } ) ), width ); + for( const std::string &sp : species_list ) { + trim_and_print( w, top_left + point( 0, ++y ), width, c_light_gray, sp ); + } + // Senses + std::vector<std::string> senses_str; + if( has_flag( MF_HEARS ) ) { + senses_str.emplace_back( colorize( _( "hearing" ), c_yellow ) ); + } + if( has_flag( MF_SEES ) ) { + senses_str.emplace_back( colorize( _( "sight" ), c_yellow ) ); + } + if( has_flag( MF_SMELLS ) ) { + senses_str.emplace_back( colorize( _( "smell" ), c_yellow ) ); + } + trim_and_print( w, top_left + point( 0, ++y ), width, c_light_gray, + string_format( "%s: %s", colorize( _( "Senses" ), c_white ), enumerate_as_string( senses_str ) ) ); + // Abilities + if( has_flag( MF_SWIMS ) ) { + trim_and_print( w, top_left + point( 0, ++y ), width, c_white, _( "It can swim." ) ); + } + if( has_flag( MF_FLIES ) ) { + trim_and_print( w, top_left + point( 0, ++y ), width, c_white, _( "It can fly." ) ); + } + if( has_flag( MF_DIGS ) ) { + trim_and_print( w, top_left + point( 0, ++y ), width, c_white, _( "It can burrow underground." ) ); + } + if( has_flag( MF_CLIMBS ) ) { + trim_and_print( w, top_left + point( 0, ++y ), width, c_white, _( "It can climb." ) ); + } + if( has_flag( MF_GRABS ) ) { + trim_and_print( w, top_left + point( 0, ++y ), width, c_white, _( "It can grab." ) ); + } + if( has_flag( MF_VENOM ) ) { + trim_and_print( w, top_left + point( 0, ++y ), width, c_white, _( "It can inflict poison." ) ); + } + if( has_flag( MF_PARALYZE ) ) { + trim_and_print( w, top_left + point( 0, ++y ), width, c_white, _( "It can inflict paralysis." ) ); + } + // Description + fold_and_print( w, top_left + point( 0, y + 2 ), width, c_light_gray, get_description() ); +} diff --git a/src/mtype.h b/src/mtype.h index 1296c514796fd..9e360f6eb59fa 100644 --- a/src/mtype.h +++ b/src/mtype.h @@ -484,6 +484,7 @@ struct mtype { void set_strategy(); void add_goal( const std::string &goal_id ); const behavior::node_t *get_goals() const; + void faction_display( catacurses::window &w, const point &top_left, const int width ) const; // Historically located in monstergenerator.cpp void load( const JsonObject &jo, const std::string &src );