diff --git a/src/advanced_inv.cpp b/src/advanced_inv.cpp index 16665021e71ce..4d13dc71d1530 100644 --- a/src/advanced_inv.cpp +++ b/src/advanced_inv.cpp @@ -2038,7 +2038,8 @@ int advanced_inventory::add_item( aim_location destarea, item &new_item, int cou // @todo: Make it use same exact methods as regular pickup if( ( destarea == AIM_INVENTORY || destarea == AIM_WORN || panes[dest].in_vehicle() ) && new_item.is_bucket_nonempty() && - !query_yn( _( "Spill contents of %s?" ), new_item.tname().c_str() ) ) { + !query_yn( _( "Spill contents of %s?" ), + colorize( new_item.tname(), new_item.color_in_inventory() ) ) ) { break; } else if( destarea == AIM_INVENTORY ) { const item &added = g->u.i_add( new_item ); diff --git a/src/armor_layers.cpp b/src/armor_layers.cpp index a1f1123a61d05..1d4e642ac7596 100644 --- a/src/armor_layers.cpp +++ b/src/armor_layers.cpp @@ -698,7 +698,9 @@ void player::sort_armor() } } else if( action == "CHANGE_SIDE" ) { if( leftListIndex < static_cast( tmp_worn.size() ) && tmp_worn[leftListIndex]->is_sided() ) { - if( g->u.query_yn( _( "Swap side for %s?" ), tmp_worn[leftListIndex]->tname().c_str() ) ) { + if( g->u.query_yn( _( "Swap side for %s?" ), + colorize( tmp_worn[leftListIndex]->tname(), + tmp_worn[leftListIndex]->color_in_inventory() ) ) ) { change_side( *tmp_worn[leftListIndex] ); wrefresh( w_sort_armor ); } diff --git a/src/bionics.cpp b/src/bionics.cpp index eb166cef20613..93a6acbeaba56 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -407,7 +407,9 @@ bool player::activate_bionic( int b, bool eff_only ) static const auto volume_per_water_charge = units::from_milliliter( 500 ); if( it->is_corpse() ) { const int avail = it->get_var( "remaining_water", it->volume() / volume_per_water_charge ); - if( avail > 0 && query_yn( _( "Extract water from the %s" ), it->tname().c_str() ) ) { + if( avail > 0 && + query_yn( _( "Extract water from the %s" ), + colorize( it->tname(), it->color_in_inventory() ) ) ) { item water( "water_clean", calendar::turn, avail ); if( g->consume_liquid( water ) ) { extracted = true; diff --git a/src/consumption.cpp b/src/consumption.cpp index 334daeb2fd2f8..dc95fb2aee616 100644 --- a/src/consumption.cpp +++ b/src/consumption.cpp @@ -511,12 +511,14 @@ ret_val player::will_eat( const item &food, bool interactive ) co } const bool eat_verb = food.has_flag( "USE_EAT_VERB" ); + std::string food_tame = food.tname(); + const nc_color food_color = food.color_in_inventory(); if( eat_verb || comest->comesttype == "FOOD" ) { - req << string_format( _( "Eat your %s anyway?" ), food.tname().c_str() ); + req << string_format( _( "Eat your %s anyway?" ), colorize( food_tame, food_color ) ); } else if( !eat_verb && comest->comesttype == "DRINK" ) { - req << string_format( _( "Drink your %s anyway?" ), food.tname().c_str() ); + req << string_format( _( "Drink your %s anyway?" ), colorize( food_tame, food_color ) ); } else { - req << string_format( _( "Consume your %s anyway?" ), food.tname().c_str() ); + req << string_format( _( "Consume your %s anyway?" ), colorize( food_tame, food_color ) ); } if( !query_yn( req.str() ) ) { diff --git a/src/crafting.cpp b/src/crafting.cpp index da2632dd582ac..5b1ce13862c9c 100644 --- a/src/crafting.cpp +++ b/src/crafting.cpp @@ -1231,13 +1231,13 @@ bool player::disassemble( item &obj, int pos, bool ground, bool interactive ) if( !r.learn_by_disassembly.empty() && !knows_recipe( &r ) && can_decomp_learn( r ) ) { if( !query_yn( _( "Disassembling the %s may yield:\n%s\nReally disassemble?\nYou feel you may be able to understand this object's construction.\n" ), - obj.tname().c_str(), - list.str().c_str() ) ) { + colorize( obj.tname(), obj.color_in_inventory() ), + list.str() ) ) { return false; } } else if( !query_yn( _( "Disassembling the %s may yield:\n%s\nReally disassemble?" ), - obj.tname().c_str(), - list.str().c_str() ) ) { + colorize( obj.tname(), obj.color_in_inventory() ), + list.str() ) ) { return false; } } diff --git a/src/iuse.cpp b/src/iuse.cpp index ea848b90bd8ec..1584801f27e0a 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -1237,7 +1237,7 @@ int iuse::marloss( player *p, item *it, bool, const tripoint & ) int iuse::marloss_seed( player *p, item *it, bool, const tripoint & ) { if( !query_yn( _( "Sure you want to eat the %s? You could plant it in a mound of dirt." ), - it->tname().c_str() ) ) { + colorize( it->tname(), it->color_in_inventory() ) ) ) { return 0; // Save the seed for later! } @@ -3961,7 +3961,8 @@ int iuse::blood_draw( player *p, item *it, bool, const tripoint & ) bool acid_blood = false; for( auto &map_it : g->m.i_at( p->posx(), p->posy() ) ) { if( map_it.is_corpse() && - query_yn( _( "Draw blood from %s?" ), map_it.tname().c_str() ) ) { + query_yn( _( "Draw blood from %s?" ), + colorize( map_it.tname(), map_it.color_in_inventory() ) ) ) { p->add_msg_if_player( m_info, _( "You drew blood from the %s..." ), map_it.tname().c_str() ); drew_blood = true; auto bloodtype( map_it.get_mtype()->bloodType() ); @@ -4789,7 +4790,8 @@ static bool heat_item( player &p ) target.apply_freezerburn(); if( target.has_flag( "EATEN_COLD" ) && - !query_yn( _( "%s is best served cold. Heat beyond defrosting?" ), target.tname() ) ) { + !query_yn( _( "%s is best served cold. Heat beyond defrosting?" ), + colorize( target.tname(), target.color_in_inventory() ) ) ) { // assume environment is warm; heat less to keep COLD longer int counter_mod = 550; @@ -5333,7 +5335,7 @@ int iuse::seed( player *p, item *it, bool, const tripoint & ) { if( p->is_npc() || query_yn( _( "Sure you want to eat the %s? You could plant it in a mound of dirt." ), - it->tname().c_str() ) ) { + colorize( it->tname(), it->color_in_inventory() ) ) ) { return it->type->charges_to_use(); //This eats the seed object. } return 0; diff --git a/src/output.cpp b/src/output.cpp index 21525b36cdcac..5d9fc09089492 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -605,11 +605,12 @@ bool query_yn( const std::string &text ) return query_popup() .context( "YESNO" ) .message( force_uc ? - pgettext( "query_yn", "%s (Case Sensitive)" ) : - pgettext( "query_yn", "%s" ), text ) + pgettext( "query_yn", "%s (Case Sensitive)" ) : + pgettext( "query_yn", "%s" ), text ) .option( "YES", allow_key ) .option( "NO", allow_key ) .cursor( 1 ) + .default_color( c_light_red ) .query() .action == "YES"; } diff --git a/src/player.cpp b/src/player.cpp index 800887b54ad65..039acd5511746 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -7170,7 +7170,8 @@ bool player::has_mission_item(int mission_id) const //Returns the amount of charges that were consumed by the player int player::drink_from_hands(item& water) { int charges_consumed = 0; - if( query_yn( _("Drink %s from your hands?"), water.type_name().c_str() ) ) + if( query_yn( _( "Drink %s from your hands?" ), + colorize( water.type_name(), water.color_in_inventory() ) ) ) { // Create a dose of water no greater than the amount of water remaining. item water_temp( water ); @@ -8493,7 +8494,8 @@ bool player::takeoff( const item &it, std::list *res ) if( res == nullptr ) { if( volume_carried() + it.volume() > volume_capacity_reduced_by( it.get_storage() ) ) { - if( is_npc() || query_yn( _( "No room in inventory for your %s. Drop it?" ), it.tname().c_str() ) ) { + if( is_npc() || query_yn( _( "No room in inventory for your %s. Drop it?" ), + colorize( it.tname(), it.color_in_inventory() ) ) ) { drop( get_item_position( &it ), pos() ); return true; // the drop activity ends up taking off the item anyway so shouldn't try to do it again here } else { @@ -9185,8 +9187,9 @@ void player::gunmod_add( item &gun, item &mod ) int qty = 0; if( mod.is_irremovable() ) { - if( !query_yn( _( "Permanently install your %1$s in your %2$s?" ), mod.tname().c_str(), - gun.tname().c_str() ) ) { + if( !query_yn( _( "Permanently install your %1$s in your %2$s?" ), + colorize( mod.tname(), mod.color_in_inventory() ), + colorize( gun.tname(), gun.color_in_inventory() ) ) ) { add_msg_if_player( _( "Never mind." ) ); return; // player canceled installation } @@ -9252,8 +9255,9 @@ void player::toolmod_add( item_location tool, item_location mod ) return; } - if( !query_yn( _( "Permanently install your %1$s in your %2$s?" ), mod->tname().c_str(), - tool->tname().c_str() ) ) { + if( !query_yn( _( "Permanently install your %1$s in your %2$s?" ), + colorize( mod->tname().c_str(), mod->color_in_inventory() ), + colorize( tool->tname().c_str(), tool->color_in_inventory() ) ) ) { add_msg_if_player( _( "Never mind." ) ); return; // player canceled installation } diff --git a/src/popup.cpp b/src/popup.cpp index 133c511e6c14b..16fa59c0428b0 100644 --- a/src/popup.cpp +++ b/src/popup.cpp @@ -6,7 +6,8 @@ extern bool test_mode; query_popup::query_popup() - : cur( 0 ), anykey( false ), cancel( false ), ontop( false ), fullscr( false ) + : cur( 0 ), default_text_color( c_white ), anykey( false ), cancel( false ), ontop( false ), + fullscr( false ) { } @@ -69,6 +70,12 @@ query_popup &query_popup::cursor( size_t pos ) return *this; } +query_popup &query_popup::default_color( const nc_color &d_color ) +{ + default_text_color = d_color; + return *this; +} + std::vector> query_popup::fold_query( const std::string &category, const std::vector &options, @@ -206,7 +213,7 @@ void query_popup::show() const draw_border( win ); for( size_t line = 0; line < folded_msg.size(); ++line ) { - nc_color col = c_white; + nc_color col = default_text_color; print_colored_text( win, border_width + line, border_width, col, col, folded_msg[line] ); } diff --git a/src/popup.h b/src/popup.h index ce6ad776e5ff4..fb1f33ed293f9 100644 --- a/src/popup.h +++ b/src/popup.h @@ -8,8 +8,7 @@ #include "cursesdef.h" #include "input.h" - -class nc_color; +#include "color.h" /** * UI class for displaying messages or querying player input with popups. @@ -163,6 +162,10 @@ class query_popup * Specify starting cursor position. **/ query_popup &cursor( size_t pos ); + /** + * Specify the default message color. + **/ + query_popup &default_color( const nc_color &d_color ); /** * Draw the UI. An input context should be provided using `context()` @@ -194,6 +197,7 @@ class query_popup std::string text; std::vector options; size_t cur; + nc_color default_text_color; bool anykey; bool cancel; bool ontop;