Skip to content

Commit

Permalink
equip filter by slot in armor layer inventory (CleverRaven#45600)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nirnael authored Nov 25, 2020
1 parent 41d013b commit 303ac98
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/armor_layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ void player::sort_armor()
}
} else if( action == "EQUIP_ARMOR_HERE" ) {
// filter inventory for all items that are armor/clothing
item_location loc = game_menus::inv::wear( *this );
item_location loc = game_menus::inv::wear( *this, armor_cat[tabindex] );

// only equip if something valid selected!
if( loc ) {
Expand Down
15 changes: 10 additions & 5 deletions src/game_inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,13 @@ class armor_inventory_preset: public inventory_selector_preset
class wear_inventory_preset: public armor_inventory_preset
{
public:
wear_inventory_preset( player &p, const std::string &color ) :
armor_inventory_preset( p, color )
wear_inventory_preset( player &p, const std::string &color, const bodypart_id &bp ) :
armor_inventory_preset( p, color ), bp( bp )
{}

bool is_shown( const item_location &loc ) const override {
return loc->is_armor() && !p.is_worn( *loc );
return loc->is_armor() && !p.is_worn( *loc ) &&
( bp != bodypart_id( "bp_null" ) ? loc->covers( bp ) : true );
}

std::string get_denial( const item_location &loc ) const override {
Expand All @@ -336,11 +337,15 @@ class wear_inventory_preset: public armor_inventory_preset

return std::string();
}

private:
const bodypart_id &bp;

};

item_location game_menus::inv::wear( player &p )
item_location game_menus::inv::wear( player &p, const bodypart_id &bp )
{
return inv_internal( p, wear_inventory_preset( p, "color_yellow" ), _( "Wear item" ), 1,
return inv_internal( p, wear_inventory_preset( p, "color_yellow", bp ), _( "Wear item" ), 1,
_( "You have nothing to wear." ) );
}

Expand Down
2 changes: 1 addition & 1 deletion src/game_inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void insert_items( avatar &you, item_location &holster );
/** Choosing a gun to saw down it's barrel. */
item_location saw_barrel( player &p, item &tool );
/** Choose item to wear. */
item_location wear( player &p );
item_location wear( player &p, const bodypart_id &bp = bodypart_id( "bp_null" ) );
/** Choose item to take off. */
item_location take_off( avatar &you );
/** Item cut up menu. */
Expand Down

0 comments on commit 303ac98

Please sign in to comment.