Skip to content

Commit

Permalink
refactor inventory_item_menu (#36206)
Browse files Browse the repository at this point in the history
  • Loading branch information
KorGgenT authored and kevingranade committed Dec 31, 2019
1 parent 1e3f85e commit 521066c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/advanced_inv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,7 @@ void advanced_inventory::display()
if( spane.get_area() == AIM_INVENTORY || spane.get_area() == AIM_WORN ) {
int idx = spane.get_area() == AIM_INVENTORY ? sitem->idx :
player::worn_position_to_index( sitem->idx );
item_location loc( g->u, &g->u.i_at( idx ) );
// Setup a "return to AIM" activity. If examining the item creates a new activity
// (e.g. reading, reloading, activating), the new activity will be put on top of
// "return to AIM". Once the new activity is finished, "return to AIM" comes back
Expand All @@ -1401,7 +1402,7 @@ void advanced_inventory::display()
// "return to AIM".
do_return_entry();
assert( g->u.has_activity( activity_id( "ACT_ADV_INVENTORY" ) ) );
ret = g->inventory_item_menu( idx, info_startx, info_width,
ret = g->inventory_item_menu( loc, info_startx, info_width,
src == advanced_inventory::side::left ? game::LEFT_OF_INFO : game::RIGHT_OF_INFO );
if( !g->u.has_activity( activity_id( "ACT_ADV_INVENTORY" ) ) ) {
exit = true;
Expand Down
7 changes: 3 additions & 4 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1956,18 +1956,17 @@ void game::handle_key_blocking_activity()
/* item submenu for 'i' and '/'
* It use draw_item_info to draw item info and action menu
*
* @param pos position of item in inventory
* @param locThisItem the item
* @param iStartX Left coordinate of the item info window
* @param iWidth width of the item info window (height = height of terminal)
* @return getch
*/
int game::inventory_item_menu( int pos, int iStartX, int iWidth,
int game::inventory_item_menu( item_location locThisItem, int iStartX, int iWidth,
const inventory_item_menu_positon position )
{
int cMenu = static_cast<int>( '+' );

item &oThisItem = u.i_at( pos );
item_location locThisItem( u, &oThisItem );
item &oThisItem = *locThisItem;
if( u.has_item( oThisItem ) ) {
#if defined(__ANDROID__)
if( get_option<bool>( "ANDROID_INVENTORY_AUTOADD" ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ class game
RIGHT_OF_INFO,
LEFT_TERMINAL_EDGE,
};
int inventory_item_menu( int pos, int startx = 0, int width = 50,
int inventory_item_menu( item_location locThisItem, int startx = 0, int width = 50,
inventory_item_menu_positon position = RIGHT_OF_INFO );

/** Custom-filtered menu for inventory and nearby items and those that within specified radius */
Expand Down
2 changes: 1 addition & 1 deletion src/game_inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void game_menus::inv::common( avatar &you )
}

g->refresh_all();
res = g->inventory_item_menu( you.get_item_position( location.get_item() ) );
res = g->inventory_item_menu( location );
g->refresh_all();

} while( loop_options.count( res ) != 0 );
Expand Down

0 comments on commit 521066c

Please sign in to comment.