Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inv_ui: fix category toggle of disabled entries #62226

Merged
merged 1 commit into from
Nov 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/inventory_ui.cpp
Original file line number Diff line number Diff line change
@@ -1010,13 +1010,19 @@ bool inventory_column::has_available_choices() const
}

bool inventory_column::is_selected( const inventory_entry &entry ) const
{
return ( entry.is_selectable() && entry == get_highlighted() ) || ( multiselect &&
is_selected_by_category( entry ) );
}

bool inventory_column::is_highlighted( const inventory_entry &entry ) const
{
return entry == get_highlighted() || ( multiselect && is_selected_by_category( entry ) );
}

bool inventory_column::is_selected_by_category( const inventory_entry &entry ) const
{
return entry.is_item() && mode == navigation_mode::CATEGORY
return entry.is_selectable() && mode == navigation_mode::CATEGORY
&& entry.get_category_ptr() == get_highlighted().get_category_ptr()
&& page_of( entry ) == page_index();
}
@@ -1427,7 +1433,7 @@ void inventory_column::draw( const catacurses::window &win, const point &p,
int x2 = p.x + std::max( static_cast<int>( reserved_width - get_cells_width() ), 0 );
int yy = p.y + line;

const bool selected = active && is_selected( entry );
const bool selected = active && is_highlighted( entry );

const int hx_max = p.x + get_width();
inclusive_rectangle<point> rect = inclusive_rectangle<point>( point( x1, yy ),
1 change: 1 addition & 0 deletions src/inventory_ui.h
Original file line number Diff line number Diff line change
@@ -328,6 +328,7 @@ class inventory_column

bool has_available_choices() const;
bool is_selected( const inventory_entry &entry ) const;
bool is_highlighted( const inventory_entry &entry ) const;

/**
* Does this entry belong to the selected category?