Skip to content

Commit 1afac80

Browse files
committed
Inventory_UI: Hide installed gunmods but show loose ones
1 parent a59c263 commit 1afac80

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/inventory_ui.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#include "uistate.h"
5959
#include "units.h"
6060
#include "units_utility.h"
61+
#include "value_ptr.h"
6162
#include "vehicle.h"
6263
#include "vehicle_selector.h"
6364
#include "vpart_position.h"
@@ -703,6 +704,18 @@ inventory_selector_preset::inventory_selector_preset()
703704
} ) );
704705
}
705706

707+
bool inventory_selector_preset::is_shown( const item_location &loc ) const
708+
{
709+
if( loc->is_gunmod() ) {
710+
item_location parent = loc.parent_item();
711+
const bool installed = parent && parent->is_gun();
712+
if( installed && !loc->type->gunmod->is_visible_when_installed ) {
713+
return false;
714+
}
715+
}
716+
return true;
717+
}
718+
706719
bool inventory_selector_preset::sort_compare( const inventory_entry &lhs,
707720
const inventory_entry &rhs ) const
708721
{

src/inventory_ui.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@
2626
#include "input_context.h"
2727
#include "item.h"
2828
#include "item_location.h"
29-
#include "itype.h"
3029
#include "memory_fast.h"
3130
#include "pimpl.h"
3231
#include "pocket_type.h"
3332
#include "point.h"
3433
#include "translations.h"
3534
#include "units.h"
36-
#include "value_ptr.h"
3735

3836
class Character;
3937
class JsonObject;
@@ -241,12 +239,8 @@ class inventory_selector_preset
241239
virtual ~inventory_selector_preset() = default;
242240

243241
/** Does this entry satisfy the basic preset conditions? */
244-
virtual bool is_shown( const item_location &loc ) const {
245-
if( loc->is_gunmod() && !loc->type->gunmod->is_visible_when_installed ) {
246-
return false;
247-
}
248-
return true;
249-
}
242+
virtual bool is_shown( const item_location &loc ) const;
243+
250244

251245
/**
252246
* The reason why this entry cannot be selected.

0 commit comments

Comments
 (0)