Skip to content

Commit

Permalink
inv_ui: never hide entries in the selection column (#64720)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei8l authored Mar 31, 2023
1 parent 4d53a1c commit d176ab8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/inventory_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1234,9 +1234,9 @@ void inventory_column::on_change( const inventory_entry &/* entry */ )
inventory_entry *inventory_column::add_entry( const inventory_entry &entry )
{
entries_t &dest = entry.is_hidden( hide_entries_override ) ? entries_hidden : entries;
if( std::find( dest.begin(), dest.end(), entry ) != dest.end() ) {
if( auto it = std::find( dest.begin(), dest.end(), entry ); it != dest.end() ) {
debugmsg( "Tried to add a duplicate entry." );
return nullptr;
return &*it;
}
paging_is_valid = false;
if( entry.is_item() ) {
Expand Down Expand Up @@ -1738,7 +1738,10 @@ size_t inventory_column::visible_cells() const

selection_column::selection_column( const std::string &id, const std::string &name ) :
inventory_column( selection_preset ),
selected_cat( id, no_translation( name ), 0 ) {}
selected_cat( id, no_translation( name ), 0 )
{
hide_entries_override = { false };
}

selection_column::~selection_column() = default;

Expand Down Expand Up @@ -2784,6 +2787,11 @@ void inventory_column::cycle_hide_override()
}
}

void selection_column::cycle_hide_override()
{
// never hide entries
}

void inventory_selector::on_input( const inventory_input &input )
{
if( input.action == "CATEGORY_SELECTION" ) {
Expand Down
5 changes: 3 additions & 2 deletions src/inventory_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ class inventory_column
void toggle_skip_unselectable( bool skip );
void collate();
void uncollate();
void cycle_hide_override();
virtual void cycle_hide_override();

protected:
/**
Expand Down Expand Up @@ -545,6 +545,7 @@ class inventory_column
size_t entries_per_page = std::numeric_limits<size_t>::max();
size_t height = std::numeric_limits<size_t>::max();
size_t reserved_width = 0;
std::optional<bool> hide_entries_override = std::nullopt;

private:
struct cell_t {
Expand All @@ -563,7 +564,6 @@ class inventory_column
std::vector<cell_t> cells;

std::optional<bool> indent_entries_override = std::nullopt;
std::optional<bool> hide_entries_override = std::nullopt;
/** @return Number of visible cells */
size_t visible_cells() const;
void _get_entries( get_entries_t *res, entries_t const &ent,
Expand Down Expand Up @@ -599,6 +599,7 @@ class selection_column : public inventory_column
}

void set_filter( const std::string &filter ) override;
void cycle_hide_override() override;

private:
const pimpl<item_category> selected_cat;
Expand Down

0 comments on commit d176ab8

Please sign in to comment.