Skip to content

Commit

Permalink
Allow ebooks in read command
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhilkinSerg committed Aug 13, 2024
1 parent b8dba37 commit 81a9e78
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/game_inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ static item_location inv_internal( Character &u, const inventory_selector_preset
const std::string &title, int radius,
const std::string &none_message,
const std::string &hint = std::string(),
item_location container = item_location() )
item_location container = item_location(),
bool add_ebooks = false )
{
inventory_pick_selector inv_s( u, preset );

Expand All @@ -156,6 +157,9 @@ static item_location inv_internal( Character &u, const inventory_selector_preset
// Default behavior.
inv_s.add_character_items( u );
inv_s.add_nearby_items( radius );
if( add_ebooks ) {
inv_s.add_character_ebooks( u );
}
}

if( u.has_activity( consuming ) ) {
Expand Down Expand Up @@ -1560,7 +1564,8 @@ item_location game_menus::inv::read( Character &you )
{
const std::string msg = you.is_avatar() ? _( "You have nothing to read." ) :
string_format( _( "%s has nothing to read." ), you.disp_name() );
return inv_internal( you, read_inventory_preset( you ), _( "Read" ), 1, msg );
return inv_internal( you, read_inventory_preset( you ), _( "Read" ), 1, msg, "", item_location(),
true );
}

item_location game_menus::inv::ebookread( Character &you, item_location &ereader )
Expand Down
7 changes: 7 additions & 0 deletions src/inventory_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2097,6 +2097,13 @@ void inventory_selector::add_character_items( Character &character )
}
}

void inventory_selector::add_character_ebooks( Character &character )

Check failure on line 2100 in src/inventory_ui.cpp

View workflow job for this annotation

GitHub Actions / Basic Build and Test (Clang 10, Ubuntu, Curses)

unused parameter 'character' [-Werror,-Wunused-parameter]
{
for( auto &ereader : u.all_items_loc() ) {
this->add_contained_ebooks( ereader );
}
}

void inventory_selector::add_map_items( const tripoint &target )
{
map &here = get_map();
Expand Down
1 change: 1 addition & 0 deletions src/inventory_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ class inventory_selector
void add_contained_gunmods( Character &you, item &gun );
void add_contained_ebooks( item_location &container );
void add_character_items( Character &character );
void add_character_ebooks( Character &character );
void add_map_items( const tripoint &target );
void add_vehicle_items( const tripoint &target );
void add_nearby_items( int radius = 1 );
Expand Down

0 comments on commit 81a9e78

Please sign in to comment.