ScummVM API documentation
inventory.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef NGI_INVENTORY_H
23 #define NGI_INVENTORY_H
24 
25 namespace NGI {
26 
27 class Scene;
28 class BigPicture;
29 
31  int16 id;
32  int16 pictureObjectNormal;
33  int16 pictureObjectId1;
34  int16 pictureObjectHover;
35  int16 pictureObjectSelected;
36  int16 field_A;
37  int field_C;
38  int obj;
39  int flags;
40 };
41 
43 
44 class Inventory : public CObject {
45  protected:
46  int16 _sceneId;
47  InventoryPoolItems _itemsPool;
48 
49  public:
50  Inventory() { _sceneId = 0; }
51 
52  bool load(MfcArchive &file) override;
53 
54  int getInventoryPoolItemIndexById(int itemId);
55  uint getItemsPoolCount() { return _itemsPool.size(); }
56  bool setItemFlags(int itemId, int flags);
57 };
58 
59 struct InventoryItem {
60  int16 itemId;
61  int16 count;
62 
63  InventoryItem() { itemId = count = 0; }
64  InventoryItem(int id, int cnt) : itemId(id), count(cnt) {}
65 };
66 
67 class PictureObject;
68 
69 struct InventoryIcon {
70  PictureObject *pictureObjectNormal;
71  PictureObject *pictureObjectHover;
72  PictureObject *pictureObjectSelected;
73  int x1;
74  int y1;
75  int x2;
76  int y2;
77  int16 inventoryItemId;
78  bool isSelected;
79  bool isMouseHover;
80 };
81 
82 class Inventory2 : public Inventory {
83  Common::Array<InventoryItem> _inventoryItems;
84  Common::Array<InventoryIcon> _inventoryIcons;
85  int _selectedId;
86  int _field_48;
87  bool _isInventoryOut;
88  bool _isLocked;
89  int _topOffset;
90  Scene *_scene;
91  BigPicture *_picture;
92 
93  public:
94  Inventory2();
95  ~Inventory2() override;
96 
97  bool loadPartial(MfcArchive &file);
98  bool savePartial(MfcArchive &file);
99  void addItem(int itemId, int count);
100  void addItem2(StaticANIObject *obj);
101  void removeItem(int itemId, int count);
102  void removeItem2(Scene *sceneObj, int itemId, int x, int y, int priority);
103 
104  int getInventoryItemIndexById(int itemId);
105  int getInventoryPoolItemIdAtIndex(int itemId);
106  int getInventoryPoolItemFieldCById(int itemId);
107  int getCountItemsWithId(int itemId);
108  int getItemFlags(int itemId);
109 
110  void rebuildItemRects();
111 
112  Scene *getScene() { return _scene; }
113  bool getIsLocked() { return _isLocked; }
114  void setIsLocked(bool val) { _isLocked = val; }
115  bool getIsInventoryOut() { return _isInventoryOut; }
116 
117  int getSelectedItemId() { return _selectedId < 0 ? 0 : _selectedId; }
118  int getHoveredItem(Common::Point *point);
119  void slideIn();
120  void slideOut();
121 
122  bool handleLeftClick(ExCommand *cmd);
123  int selectItem(int itemId);
124  bool unselectItem(bool flag);
125 
126  void draw();
127 
128  void clear();
129 };
130 
131 } // End of namespace NGI
132 
133 #endif /* NGI_INVENTORY_H */
Definition: utils.h:39
Definition: inventory.h:82
Definition: gfx.h:166
Definition: gfx.h:128
Definition: inventory.h:69
Definition: inventory.h:44
Definition: rect.h:45
size_type size() const
Definition: array.h:275
Definition: statics.h:172
Definition: messages.h:59
Definition: scene.h:32
Definition: anihandler.h:25
Definition: inventory.h:30
Definition: utils.h:106
Definition: inventory.h:59