1 #pragma once 2 #ifndef CATA_SRC_ADVANCED_INV_AREA_H 3 #define CATA_SRC_ADVANCED_INV_AREA_H 4 5 #include <array> 6 #include <iosfwd> 7 #include <vector> 8 9 #include "item_location.h" 10 #include "point.h" 11 #include "units.h" // IWYU pragma: keep 12 13 enum aim_location : char { 14 AIM_INVENTORY = 0, 15 AIM_SOUTHWEST, 16 AIM_SOUTH, 17 AIM_SOUTHEAST, 18 AIM_WEST, 19 AIM_CENTER, 20 AIM_EAST, 21 AIM_NORTHWEST, 22 AIM_NORTH, 23 AIM_NORTHEAST, 24 AIM_DRAGGED, 25 AIM_ALL, 26 AIM_CONTAINER, 27 AIM_WORN, 28 NUM_AIM_LOCATIONS, 29 // only useful for AIM_ALL 30 AIM_AROUND_BEGIN = AIM_SOUTHWEST, 31 AIM_AROUND_END = AIM_NORTHEAST 32 }; 33 34 class advanced_inv_listitem; 35 class item; 36 class vehicle; 37 38 /** 39 * Defines the source of item stacks. 40 */ 41 class advanced_inv_area 42 { 43 public: 44 // roll our own, to handle moving stacks better 45 using itemstack = std::vector<std::vector<item *> >; 46 47 const aim_location id; 48 // Used for the small overview 3x3 grid 49 point hscreen = point_zero; 50 // relative (to the player) position of the map point 51 tripoint off; 52 /** Long name, displayed, translated */ 53 const std::string name = "fake"; 54 /** Shorter name (2 letters) */ 55 // FK in my coffee 56 const std::string shortname = "FK"; 57 // absolute position of the map point. 58 tripoint pos; 59 /** Can we put items there? Only checks if location is valid, not if 60 selected container in pane is. For full check use canputitems() **/ 61 bool canputitemsloc = false; 62 // vehicle pointer and cargo part index 63 vehicle *veh = nullptr; 64 int vstor = 0; 65 // description, e.g. vehicle name, label, or terrain 66 std::array<std::string, 2> desc; 67 // flags, e.g. FIRE, TRAP, WATER 68 std::string flags; 69 // total volume and weight of items currently there 70 units::volume volume; 71 units::volume volume_veh; 72 units::mass weight; 73 units::mass weight_veh; 74 // maximal count / volume of items there. 75 int max_size = 0; 76 // appears as part of the legend at the top right 77 const std::string minimapname; 78 // user command that corresponds to this location 79 const std::string actionname; 80 // used for isometric view 81 const aim_location relative_location; 82 83 // NOLINTNEXTLINE(google-explicit-constructor) advanced_inv_area(aim_location id)84 advanced_inv_area( aim_location id ) : id( id ), relative_location( id ) {} 85 advanced_inv_area( 86 aim_location id, const point &hscreen, tripoint off, const std::string &name, 87 const std::string &shortname, std::string minimapname, std::string actionname, 88 aim_location relative_location ); 89 90 void init(); 91 92 template <typename T> 93 advanced_inv_area::itemstack i_stacked( T items ); 94 // if you want vehicle cargo, specify so via `in_vehicle' 95 units::volume free_volume( bool in_vehicle = false ) const; 96 int get_item_count() const; 97 // Other area is actually the same item source, e.g. dragged vehicle to the south and AIM_SOUTH 98 bool is_same( const advanced_inv_area &other ) const; 99 // does _not_ check vehicle storage, do that with `can_store_in_vehicle()' below 100 bool canputitems( const advanced_inv_listitem *advitem = nullptr ); 101 // if you want vehicle cargo, specify so via `in_vehicle' 102 item_location get_container( bool in_vehicle = false ); 103 void set_container( const advanced_inv_listitem *advitem ); 104 bool is_container_valid( const item *it ) const; 105 void set_container_position(); 106 aim_location offset_to_location() const; 107 bool can_store_in_vehicle() const; 108 }; 109 #endif // CATA_SRC_ADVANCED_INV_AREA_H 110