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

Fix drawing artifacts in some inventory menus #37125

Merged
merged 1 commit into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
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
13 changes: 8 additions & 5 deletions src/game_inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ static item_location inv_internal( player &u, const inventory_selector_preset &p
init_selection = true;
}

bool need_refresh = true;
do {
u.inv.restack( u );

Expand All @@ -137,7 +138,7 @@ static item_location inv_internal( player &u, const inventory_selector_preset &p
inv_s.add_nearby_items( radius );

if( init_selection ) {
inv_s.update();
inv_s.update( need_refresh );
inv_s.select_position( init_pair );
init_selection = false;
}
Expand Down Expand Up @@ -183,11 +184,12 @@ void game_menus::inv::common( avatar &you )

int res = 0;

bool need_refresh = true;
do {
you.inv.restack( you );
inv_s.clear_items();
inv_s.add_character_items( you );
inv_s.update();
inv_s.update( need_refresh );

const item_location &location = inv_s.execute();

Expand Down Expand Up @@ -1541,7 +1543,7 @@ static item_location autodoc_internal( player &u, player &patient,

std::pair<size_t, size_t> init_pair;
bool init_selection = false;

bool need_refresh = true;
do {
u.inv.restack( u );

Expand All @@ -1550,7 +1552,7 @@ static item_location autodoc_internal( player &u, player &patient,
inv_s.add_nearby_items( radius );

if( init_selection ) {
inv_s.update();
inv_s.update( need_refresh );
inv_s.select_position( init_pair );
init_selection = false;
}
Expand Down Expand Up @@ -1951,6 +1953,7 @@ static item_location autoclave_internal( player &u,

std::pair<size_t, size_t> init_pair;
bool init_selection = false;
bool need_refresh = true;
do {
u.inv.restack( u );

Expand All @@ -1959,7 +1962,7 @@ static item_location autoclave_internal( player &u,
inv_s.add_nearby_items( radius );

if( init_selection ) {
inv_s.update();
inv_s.update( need_refresh );
inv_s.select_position( init_pair );
init_selection = false;
}
Expand Down
26 changes: 17 additions & 9 deletions src/inventory_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1516,8 +1516,14 @@ void inventory_selector::set_filter()
layout_is_valid = false;
}

void inventory_selector::update()
void inventory_selector::update( bool &need_refresh )
{
if( need_refresh ) {
g->draw_ter();
wrefresh( g->w_terrain );
g->draw_panels( true );
need_refresh = false;
}
prepare_layout();
refresh_window();
}
Expand Down Expand Up @@ -1803,9 +1809,9 @@ const navigation_mode_data &inventory_selector::get_navigation_data( navigation_

item_location inventory_pick_selector::execute()
{
bool need_refresh = true;
while( true ) {
update();

update( need_refresh );
const inventory_input input = get_input();

if( input.entry != nullptr ) {
Expand All @@ -1831,9 +1837,7 @@ item_location inventory_pick_selector::execute()
}

if( input.action == "HELP_KEYBINDINGS" || input.action == "INVENTORY_FILTER" ) {
g->draw_ter();
wrefresh( g->w_terrain );
g->draw_panels( true );
need_refresh = true;
}
}
}
Expand Down Expand Up @@ -1872,8 +1876,9 @@ inventory_compare_selector::inventory_compare_selector( player &p ) :

std::pair<const item *, const item *> inventory_compare_selector::execute()
{
bool need_refresh = true;
while( true ) {
update();
update( need_refresh );

const inventory_input input = get_input();

Expand Down Expand Up @@ -1949,8 +1954,9 @@ inventory_iuse_selector::inventory_iuse_selector(
drop_locations inventory_iuse_selector::execute()
{
int count = 0;
bool need_refresh = true;
while( true ) {
update();
update( need_refresh );

const inventory_input input = get_input();

Expand Down Expand Up @@ -2070,8 +2076,9 @@ void inventory_drop_selector::process_selected( int &count,
drop_locations inventory_drop_selector::execute()
{
int count = 0;
bool need_refresh = true;
while( true ) {
update();
update( need_refresh );

const inventory_input input = get_input();

Expand Down Expand Up @@ -2142,6 +2149,7 @@ drop_locations inventory_drop_selector::execute()
return drop_locations();
} else if( input.action == "INVENTORY_FILTER" ) {
set_filter();
need_refresh = true;
} else if( input.action == "TOGGLE_FAVORITE" ) {
// TODO: implement favoriting in multi selection menus while maintaining selection
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/inventory_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ class inventory_selector

public:

void update();
void update( bool &need_refresh );

/**
* Select a location
Expand Down