Skip to content

Commit

Permalink
Migrate inventory_ui.cpp and game_inventory.cpp to ui_adaptor
Browse files Browse the repository at this point in the history
  • Loading branch information
Qrox committed May 4, 2020
1 parent cb7d243 commit 92c76c8
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 154 deletions.
41 changes: 8 additions & 33 deletions src/game_inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,26 +159,21 @@ static item_location inv_internal( player &u, const inventory_selector_preset &p
has_init_filter = true;
}

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

inv_s.clear_items();
inv_s.add_character_items( u );
inv_s.add_nearby_items( radius );

if( init_selection || has_init_filter ) {
inv_s.update( need_refresh );
if( has_init_filter ) {
inv_s.set_filter( init_filter );
has_init_filter = false;
inv_s.update( need_refresh );
}
// Set position after filter to keep cursor at the right position
if( init_selection ) {
inv_s.select_position( init_pair );
init_selection = false;
}
if( has_init_filter ) {
inv_s.set_filter( init_filter );
has_init_filter = false;
}
// Set position after filter to keep cursor at the right position
if( init_selection ) {
inv_s.select_position( init_pair );
init_selection = false;
}

if( inv_s.empty() ) {
Expand Down Expand Up @@ -224,12 +219,10 @@ 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( need_refresh );

const item_location &location = inv_s.execute();

Expand Down Expand Up @@ -1589,22 +1582,13 @@ static item_location autodoc_internal( player &u, player &patient,
inv_s.set_hint( hint );
inv_s.set_display_stats( false );

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

inv_s.clear_items();
inv_s.add_character_items( u );
inv_s.add_nearby_items( radius );

if( init_selection ) {
inv_s.update( need_refresh );
inv_s.select_position( init_pair );
init_selection = false;
}

if( inv_s.empty() ) {
popup( _( "You don't have any bionics to install." ), PF_GET_KEY );
return item_location();
Expand Down Expand Up @@ -1964,22 +1948,13 @@ static item_location autoclave_internal( player &u,
inv_s.set_hint( _( "<color_yellow>Select one CBM to sterilize</color>" ) );
inv_s.set_display_stats( false );

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

inv_s.clear_items();
inv_s.add_character_items( u );
inv_s.add_nearby_items( radius );

if( init_selection ) {
inv_s.update( need_refresh );
inv_s.select_position( init_pair );
init_selection = false;
}

if( inv_s.empty() ) {
popup( _( "You don't have any CBM to sterilize." ), PF_GET_KEY );
return item_location();
Expand Down
Loading

0 comments on commit 92c76c8

Please sign in to comment.