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

Migrate inventory_ui.cpp and game_inventory.cpp to ui_adaptor #40094

Merged
merged 1 commit into from
May 4, 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
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 @@ -1623,22 +1614,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 @@ -1998,22 +1980,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