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();
}
Exemplo n.º 2
0
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 );
}
Exemplo n.º 3
0
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();
}
Exemplo n.º 4
0
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.get_item().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.get_stack_size();
        if( count > 1 ) {
            res << count << ' ';
        }
        res << entry.get_item().display_name( count );
    } else if( entry.get_category_ptr() != nullptr ) {
        res << entry.get_category_ptr()->name;
    }
    return res.str();
}