Skip to content

Commit

Permalink
Merge pull request #79069 from andrewhr/render-pocket-contents-for-nv…
Browse files Browse the repository at this point in the history
…g-overlays

Render WORN overlays for ablative pockets
  • Loading branch information
Maleclypse authored Jan 12, 2025
2 parents 866966f + 44c6f13 commit a759eda
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/character_attire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1818,19 +1818,28 @@ bool outfit::can_pickVolume( const item &it, const bool ignore_pkt_settings,
return false;
}

static void add_overlay_id_or_override( const item &item,
std::vector<std::pair<std::string, std::string>> &overlay_ids )
{
if( item.has_var( "sprite_override" ) ) {
overlay_ids.emplace_back( "worn_" + item.get_var( "sprite_override" ),
item.get_var( "sprite_override_variant", "" ) );
} else {
const std::string variant = item.has_itype_variant() ? item.itype_variant().id : "";
overlay_ids.emplace_back( "worn_" + item.typeId().str(), variant );
}
}

void outfit::get_overlay_ids( std::vector<std::pair<std::string, std::string>> &overlay_ids ) const
{
// TODO: worry about correct order of clothing overlays
for( const item &worn_item : worn ) {
if( worn_item.has_flag( json_flag_HIDDEN ) ) {
continue;
}
if( worn_item.has_var( "sprite_override" ) ) {
overlay_ids.emplace_back( "worn_" + worn_item.get_var( "sprite_override" ),
worn_item.get_var( "sprite_override_variant", "" ) );
} else {
const std::string variant = worn_item.has_itype_variant() ? worn_item.itype_variant().id : "";
overlay_ids.emplace_back( "worn_" + worn_item.typeId().str(), variant );
add_overlay_id_or_override( worn_item, overlay_ids );
for( const item *ablative : worn_item.all_ablative_armor() ) {
add_overlay_id_or_override( *ablative, overlay_ids );
}
}
}
Expand Down

0 comments on commit a759eda

Please sign in to comment.