Skip to content

Commit

Permalink
Merge pull request #40094 from Qrox/migrate-ui-12
Browse files Browse the repository at this point in the history
Migrate inventory_ui.cpp and game_inventory.cpp to ui_adaptor
  • Loading branch information
ZhilkinSerg authored May 4, 2020
2 parents 6d444b8 + 8cc6f88 commit 6f79dc9
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 154 deletions.
43 changes: 8 additions & 35 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 @@ -263,11 +256,9 @@ void game_menus::inv::common( item_location loc, avatar &you )

int res = 0;

bool need_refresh = true;
do {
inv_s.clear_items();
inv_s.add_contained_items( loc );
inv_s.update( need_refresh );

const item_location &location = inv_s.execute();

Expand Down Expand Up @@ -1615,22 +1606,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 @@ -1990,22 +1972,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 6f79dc9

Please sign in to comment.