diff --git a/src/iexamine.cpp b/src/iexamine.cpp index ff4419644fa7f..93bbb824507e3 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -1176,45 +1176,47 @@ void iexamine::locked_object( player &p, const tripoint &examp ) return; } - uilist selection_menu; - - selection_menu.text = string_format( _( "The %s is locked..." ), g->m.tername( examp ) ); - auto prying_items = p.crafting_inventory().items_with( []( const item & it ) -> bool { return it.has_quality( quality_id( "PRY" ), 2 ); } ); iuse dummy; - if( prying_items.size() == 1 ) { - item temporary_item( prying_items[0]->type ); - // They only had one item anyway, so just use it. - dummy.crowbar( &p, &temporary_item, false, examp ); - return; - } // Sort by their quality level. std::sort( prying_items.begin(), prying_items.end(), []( const item * a, const item * b ) -> int { return a->get_quality( quality_id( "PRY" ) ) > b->get_quality( quality_id( "PRY" ) ); } ); - // Then display the items - int i = 0; - selection_menu.addentry( i++, true, MENU_AUTOASSIGN, _( "Leave it alone" ) ); - for( auto iter : prying_items ) { - selection_menu.addentry( i++, true, MENU_AUTOASSIGN, string_format( _( "Use the %s" ), - iter->tname() ) ); - } + if (get_option("AUTO_PRY_LOCKED")) { + // user has elected to never have an 'are you sure' prompt to pop open non-crate pryables while examining, just use the best prying tool available + auto selected_tool = prying_items[0]; + item temporary_item(selected_tool->type); + dummy.crowbar(&p, &temporary_item, false, examp); + } else { + // original prying-tool list behavior + // Prepare and display menu for choice of tool (or none) + uilist selection_menu; - selection_menu.query(); - auto index = selection_menu.ret; + selection_menu.text = string_format(_("The %s is locked..."), g->m.tername(examp)); - if( index == 0 || index == UILIST_CANCEL ) { - none( p, examp ); - return; - } + int i = 0; + selection_menu.addentry(i++, true, MENU_AUTOASSIGN, _("Leave it alone")); + for (auto iter : prying_items) { + selection_menu.addentry(i++, true, MENU_AUTOASSIGN, string_format(_("Use the %s"), + iter->tname())); + } + + selection_menu.query(); + auto index = selection_menu.ret; - item temporary_item( prying_items[index - 1]->type ); - dummy.crowbar( &p, &temporary_item, false, examp ); + if (index == 0 || index == UILIST_CANCEL) { + none(p, examp); + return; + } + + item temporary_item(prying_items[index - 1]->type); + dummy.crowbar(&p, &temporary_item, false, examp); + } } void iexamine::bulletin_board(player &, const tripoint &examp) diff --git a/src/options.cpp b/src/options.cpp index 1f123cb75e64e..f0a9721193195 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -1049,6 +1049,12 @@ void options_manager::add_options_general() add("AUTO_PRY", "general", translate_marker("Auto-pry crates on examine"), translate_marker("If disabled, examining a crate will ask you which tool to use (or to leave the crate alone). Enable to always bypass this prompt and immediately use the best available prying tool."), + true + ); + + // separate option because locks can be far more dangerous than crates to pry open. todo: does examine try picking first, or just jump straight to prying? former is more ideal + add("AUTO_PRY_LOCKED", "general", translate_marker("Auto-pry locks on examine"), + translate_marker("If disabled, examining a non-crate locked object will ask you which tool to use (or to leave the crate alone). Enable to always bypass this prompt and immediately use the best available prying tool."), false );