void inventory_selector::print_inv_weight_vol(int weight_carried, int vol_carried, int vol_capacity) const { // Print weight mvwprintw(w_inv, 0, 32, _("Weight (%s): "), weight_units()); nc_color weight_color; if (weight_carried > g->u.weight_capacity()) { weight_color = c_red; } else { weight_color = c_ltgray; } wprintz(w_inv, weight_color, "%6.1f", convert_weight(weight_carried) + 0.05 ); // +0.05 to round up; wprintz(w_inv, c_ltgray, "/%-6.1f", convert_weight(g->u.weight_capacity())); // Print volume mvwprintw(w_inv, 0, 61, _("Volume: ")); if (vol_carried > vol_capacity) { wprintz(w_inv, c_red, "%3d", vol_carried); } else { wprintz(w_inv, c_ltgray, "%3d", vol_carried); } wprintw(w_inv, "/%-3d", vol_capacity); }
int vpart_info::format_description( std::ostringstream &msg, const std::string &format_color, int width ) const { int lines = 1; msg << _( "<color_white>Description</color>\n" ); msg << "> " << format_color; class::item base( item ); std::ostringstream long_descrip; if( ! description.empty() ) { long_descrip << _( description.c_str() ); } for( const auto &flagid : flags ) { if( flagid == "ALARMCLOCK" || flagid == "WATCH" ) { continue; } json_flag flag = json_flag::get( flagid ); if( ! flag.info().empty() ) { if( ! long_descrip.str().empty() ) { long_descrip << " "; } long_descrip << _( flag.info().c_str() ); } } if( ( has_flag( "SEAT" ) || has_flag( "BED" ) ) && ! has_flag( "BELTABLE" ) ) { json_flag nobelt = json_flag::get( "NONBELTABLE" ); long_descrip << " " << _( nobelt.info().c_str() ); } if( has_flag( "BOARDABLE" ) && has_flag( "OPENABLE" ) ) { json_flag nobelt = json_flag::get( "DOOR" ); long_descrip << " " << _( nobelt.info().c_str() ); } if( has_flag( "TURRET" ) ) { long_descrip << string_format( _( "\nRange: %1$5d Damage: %2$5.0f" ), base.gun_range( true ), base.gun_damage().total_damage() ); } if( ! long_descrip.str().empty() ) { const auto wrap_descrip = foldstring( long_descrip.str(), width ); msg << wrap_descrip[0]; for( size_t i = 1; i < wrap_descrip.size(); i++ ) { msg << "\n " << wrap_descrip[i]; } msg << "</color>\n"; lines += wrap_descrip.size(); } // borrowed from item.cpp and adjusted const quality_id quality_jack( "JACK" ); const quality_id quality_lift( "LIFT" ); for( const auto &qual : qualities ) { msg << "> " << format_color << string_format( _( "Has level %1$d %2$s quality" ), qual.second, qual.first.obj().name.c_str() ); if( qual.first == quality_jack || qual.first == quality_lift ) { msg << string_format( _( " and is rated at %1$d %2$s" ), static_cast<int>( convert_weight( qual.second * TOOL_LIFT_FACTOR ) ), weight_units() ); } msg << ".</color>\n"; lines += 1; } return lines; }