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