diff --git a/src/item.cpp b/src/item.cpp index 4d5d3a848a292..7c41ae4cbda6a 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -4024,16 +4024,31 @@ std::string item::display_name( unsigned int quantity ) const max_amount = to_joule( type->battery->max_capacity ); } + std::string ammotext; + if( ( ( is_gun() && ammo_required() ) || is_magazine() ) && get_option( "AMMO_IN_NAMES" ) ) { + if( ammo_current() != "null" ) { + ammotext = find_type( ammo_current() )->ammo->type->name(); + } else { + ammotext = ammotype( *ammo_types().begin() )->name(); + } + } + if( amount || show_amt ) { if( is_money() ) { amt = string_format( " $%.2f", amount / 100.0 ); } else { + if( ammotext != "" ) { + ammotext = " " + ammotext; + } + if( max_amount != 0 ) { - amt = string_format( " (%i/%i)", amount, max_amount ); + amt = string_format( " (%i/%i%s)", amount, max_amount, ammotext ); } else { - amt = string_format( " (%i)", amount ); + amt = string_format( " (%i%s)", amount, ammotext ); } } + } else if( ammotext != "" ) { + amt = " (" + ammotext + ")"; } // This is a hack to prevent possible crashing when displaying maps as items during character creation diff --git a/src/options.cpp b/src/options.cpp index 1f8c6a6a81e59..a317848681e83 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -1544,6 +1544,10 @@ void options_manager::add_options_interface() translate_marker( "If true, show item symbols in inventory and pick up menu." ), false ); + add( "AMMO_IN_NAMES", "interface", translate_marker( "Add ammo to weapon/magazine names" ), + translate_marker( "If true, the default ammo is added to weapon and magazine names. For example \"Mosin-Nagant M44 (4/5)\" becomes \"Mosin-Nagant M44 (4/5 7.62x54mm)\"." ), + true + ); mOptionsSort["interface"]++;