diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index bc31f42bd66b1..52ae6d28dfcb5 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -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 ); @@ -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; } @@ -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(); @@ -1541,7 +1543,7 @@ static item_location autodoc_internal( player &u, player &patient, std::pair init_pair; bool init_selection = false; - + bool need_refresh = true; do { u.inv.restack( u ); @@ -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; } @@ -1951,6 +1953,7 @@ static item_location autoclave_internal( player &u, std::pair init_pair; bool init_selection = false; + bool need_refresh = true; do { u.inv.restack( u ); @@ -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; } diff --git a/src/inventory_ui.cpp b/src/inventory_ui.cpp index 7fbf60b189378..beecd808dc5e1 100644 --- a/src/inventory_ui.cpp +++ b/src/inventory_ui.cpp @@ -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(); } @@ -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 ) { @@ -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; } } } @@ -1872,8 +1876,9 @@ inventory_compare_selector::inventory_compare_selector( player &p ) : std::pair inventory_compare_selector::execute() { + bool need_refresh = true; while( true ) { - update(); + update( need_refresh ); const inventory_input input = get_input(); @@ -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(); @@ -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(); @@ -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 { diff --git a/src/inventory_ui.h b/src/inventory_ui.h index 104929bf6f003..e5f7c8c732af4 100644 --- a/src/inventory_ui.h +++ b/src/inventory_ui.h @@ -531,7 +531,7 @@ class inventory_selector public: - void update(); + void update( bool &need_refresh ); /** * Select a location