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 DRAGONS_INVENTORY_H
23 #define DRAGONS_INVENTORY_H
24 
25 namespace Dragons {
26 
27 class Actor;
28 class ActorManager;
29 class BackgroundResourceLoader;
30 class Background;
31 class Bag;
32 class DragonINIResource;
33 
34 #define DRAGONS_MAX_INVENTORY_ITEMS 0x29
35 
36 #define ACTOR_INVENTORY_OFFSET 0x17
37 
38 enum InventoryState {
39  Closed = 0,
40  InventoryOpen = 1,
41  InventionBookOpen = 2
42 };
43 
44 class Inventory {
45 public:
46  InventoryState _previousState;
47 private:
48  DragonsEngine *_vm;
49  int32 _sequenceId;
50  int16 _screenPositionIndex;
51  Actor *_actor;
52  InventoryState _state;
53  Bag *_bag;
54 
55  void (*_inventionBookPrevSceneUpdateFunc)();
56  uint16 _inventionBookPrevSceneId;
57  uint16 _inventionBookPrevFlickerINISceneId;
58  Common::Point _inventionBookPrevFlickerINIPosition;
59 
60  uint16 _inventoryItemTbl[DRAGONS_MAX_INVENTORY_ITEMS];
61 
62 public:
64 
65  void init(ActorManager *actorManager, BackgroundResourceLoader *backgroundResourceLoader, Bag *bag, DragonINIResource *dragonIniResource);
66  void loadScene(uint32 sceneId);
67  bool isActorSet() { return true; }
68 
69  int32 getSequenceId() {
70  return _sequenceId;
71  }
72  void setActorSequenceId(int32 sequenceId);
73  void updateActorSequenceId(int32 sequenceId);
74  void resetSequenceId();
75 
76  InventoryState getState() { return _state; }
77  void setState(InventoryState newState) { _state = newState; }
78  void setPreviousState();
79 
80  int16 getPositionIndex() { return _screenPositionIndex; }
81  Common::Point getPosition();
82 
83  bool isOpen() {
84  return _state != Closed;
85  }
86 
87  void close() { _state = Closed; }
88 
89  void updateVisibility();
90  void setActorFlag400();
91  void clearActorFlag400();
92  void setPriority(uint16 priority);
93 
94  void openInventory();
95  void closeInventory();
96 
97  void draw();
98  uint16 getIniAtPosition(int16 x, int16 y);
99  void loadInventoryItemsFromSave();
100 
101  void openInventionBook();
102  void closeInventionBook();
103 
104  bool addItem(uint16 iniId);
105  bool addItemIfPositionIsEmpty(uint16 iniId, uint16 x, uint16 y);
106  void replaceItem(uint16 existingIniId, uint16 newIniId);
107  bool clearItem(uint16 iniId);
108  bool hasItem(uint16 iniId);
109 
110  Actor *getInventoryItemActor(uint16 iniId);
111  void inventoryMissing();
112 
113 private:
114  void setPositionFromSceneId(uint32 sceneId);
115  void animateBagIn();
116  void animateBagOut();
117 };
118 
119 } // End of namespace Dragons
120 
121 #endif //DRAGONS_INVENTORY_H
Definition: background.h:36
Definition: dragonini.h:63
Definition: actor.h:86
Definition: bag.h:33
Definition: inventory.h:44
Definition: rect.h:144
Definition: actor.h:28
Definition: actor.h:61
Definition: dragons.h:166