std::string selection_column::get_entry_text( const inventory_entry &entry ) const { std::ostringstream res; if( entry.is_item() ) { if( OPTIONS["ITEM_SYMBOLS"] ) { res << entry.get_item().symbol() << ' '; } const size_t available_count = entry.get_available_count(); if( entry.chosen_count > 0 && entry.chosen_count < available_count ) { res << string_format( _( "%d of %d"), entry.chosen_count, available_count ) << ' '; } else if( available_count != 1 ) { res << available_count << ' '; } res << entry.get_item().display_name( available_count ); } else { res << inventory_column::get_entry_text( entry ) << ' '; if( entries.size() > 1 ) { res << string_format( "(%d)", entries.size() - 1 ); } else { res << _( "(NONE)" ); } } return res.str(); }
std::string selection_column::get_entry_text( const inventory_entry &entry ) const { std::ostringstream res; if( entry.is_item() ) { if( OPTIONS["ITEM_SYMBOLS"] ) { res << entry.it->symbol() << ' '; } size_t count; if( entry.chosen_count > 0 && entry.chosen_count < entry.get_available_count() ) { count = entry.get_available_count(); res << string_format( _( "%d of %d"), entry.chosen_count, count ) << ' '; } else { count = ( entry.slice != nullptr ) ? entry.slice->size() : 1; if( count > 1 ) { res << count << ' '; } } res << entry.it->display_name( count ); } else { res << inventory_column::get_entry_text( entry ) << ' '; if( entries.size() > 1 ) { res << string_format( "(%d)", entries.size() - 1 ); } else { res << _( "(NONE)" ); } } return res.str(); }
std::string inventory_column::get_entry_text( const inventory_entry &entry ) const { std::ostringstream res; if( entry.is_item() ) { if( OPTIONS["ITEM_SYMBOLS"] ) { res << entry.it->symbol() << ' '; } if( multiselect ) { if( entry.chosen_count == 0 ) { res << "<color_c_dkgray>-"; } else if( entry.chosen_count >= entry.get_available_count() ) { res << "<color_c_ltgreen>+"; } else { res << "<color_c_ltgreen>#"; } res << " </color>"; } const size_t count = ( entry.slice != nullptr ) ? entry.slice->size() : 1; if( count > 1 ) { res << count << ' '; } res << entry.it->display_name( count ); } else if( entry.category != nullptr ) { res << entry.category->name; } return res.str(); }
void inventory_column::add_entry( const inventory_entry &entry ) { if( entry.is_item() ) { const auto iter = std::find_if( entries.rbegin(), entries.rend(), [ &entry ]( const inventory_entry &cur ) { return cur.get_category_ptr() == entry.get_category_ptr() || cur.get_category_ptr()->sort_rank <= entry.get_category_ptr()->sort_rank; } ); entries.insert( iter.base(), entry ); } }
nc_color inventory_column::get_entry_color( const inventory_entry &entry ) const { if( entry.is_item() ) { return ( active && is_selected( entry ) ) ? h_white : ( custom_colors && entry.custom_color != c_unset ) ? entry.custom_color : entry.get_item().color_in_inventory(); } else { return c_magenta; } }
void inventory_drop_selector::set_drop_count( inventory_entry &entry, size_t count ) { const auto iter = dropping.find( &entry.get_item() ); if( count == 0 && iter != dropping.end() ) { entry.chosen_count = 0; dropping.erase( iter ); } else { entry.chosen_count = ( count == 0 ) ? entry.get_available_count() : std::min( count, entry.get_available_count() ); dropping[&entry.get_item()] = entry.chosen_count; } on_change( entry ); }
nc_color inventory_column::get_entry_color( const inventory_entry &entry ) const { if( entry.is_item() ) { return ( active && is_selected( entry ) ) ? h_white : entry.it->color_in_inventory(); } else { return c_magenta; } }
nc_color selection_column::get_entry_color( const inventory_entry &entry ) const { if( !entry.is_item() || is_selected( entry ) ) { return inventory_column::get_entry_color( entry ); } else if( entry.item_pos == -1 ) { return c_ltblue; } else if( entry.item_pos <= -2 ) { return c_cyan; } return entry.it->color_in_inventory(); }
size_t inventory_column::get_entry_indent( const inventory_entry &entry ) const { return entry.is_item() ? 2 : 0; }
bool inventory_entry::operator == ( const inventory_entry &other ) const { return get_category_ptr() == other.get_category_ptr() && location == other.location; }
bool inventory_column::is_selected_by_category( const inventory_entry &entry ) const { return entry.is_item() && mode == navigation_mode::CATEGORY && entry.get_category_ptr() == get_selected().get_category_ptr() && page_of( entry ) == page_index(); }