Пример #1
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();
}
Пример #2
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();
}
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();
}
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;
    }
}
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.category == entry.category || cur.category->sort_rank <= entry.category->sort_rank;
            } );
        entries.insert( iter.base(), entry );
    }
}
Пример #6
0
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;
    }
}
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();
}
Пример #8
0
size_t inventory_column::get_entry_indent( const inventory_entry &entry ) const {
    return entry.is_item() ? 2 : 0;
}
Пример #9
0
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();
}