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 TEENAGENT_INVENTORY_H
23 #define TEENAGENT_INVENTORY_H
24 
25 #include "teenagent/surface.h"
26 #include "teenagent/animation.h"
27 #include "common/events.h"
28 #include "common/array.h"
29 #include "teenagent/objects.h"
30 
31 namespace TeenAgent {
32 
33 struct InventoryObject;
34 class TeenAgentEngine;
35 
36 // Maximum number of items found within game
37 const uint8 kNumInventoryItems = 92;
38 
39 // Inventory Item Ids
40 enum {
41  kInvItemNoItem = 0, // No item i.e. empty inventory slot
42  kInvItemFeather = 1,
43  kInvItemShotgun = 2,
44  kInvItemToolboxFull = 3, // Contains Car Jack and Spanner
45  kInvItemToolboxHalfEmpty = 4, // Contains Spanner
46  kInvItemSpanner = 5,
47  kInvItemComb = 6,
48  kInvItemFan = 7,
49  kInvItemBrokenPaddle = 8,
50  kInvItemPaddle = 9, // Repaired - BrokenPaddle combined with Branch (with Glue)
51  kInvItemFirstFlower = 10, // Smells nice
52  kInvItemSecondFlower = 11, // Really beautiful
53  kInvItemFeatherDusterClean = 12,
54  kInvItemChainsaw = 13, // Unfueled
55  kInvItemDrunkenChainsaw = 14, // Fueled with Whisky (Chainsaw combined with Whiskey)
56  kInvItemBranch = 15,
57  kInvItemWhisky = 16,
58  kInvItemNeedle = 17,
59  kInvItemWrapper = 18,
60  kInvItemChocCandy = 19,
61  kInvItemPotato = 20,
62  kInvItemRakeBroken = 21,
63  kInvItemHeartShapedCandy = 22,
64  kInvItemWrappedCandy = 23, // HeartShapedCandy combined with Wrapper
65  kInvItemRibbon = 24,
66  kInvItemRakeFixed = 25, // Rake combined with Ribbon
67  kInvItemNut = 26,
68  kInvItemPlasticApple = 27,
69  kInvItemCone = 28,
70  kInvItemSuperGlue = 29,
71  kInvItemConeAndNeedle = 30, // Cone combined with Needle
72  kInvItemConeAndFeather = 31, // Cone combined with Feather
73  kInvItemDart = 32, // Needle combined with ConeAndFeather or Feather combined with ConeAndNeedle
74  kInvItemFeatherDusterDirty = 33,
75  kInvItemPaintedPotato = 34, // Potato combined with Dirty Feather Duster (Soot)
76  kInvItemCarJack = 35,
77  kInvItemBone = 36,
78  kInvItemShovelAct2 = 37,
79  kInvItemRopeAct2 = 38,
80  kInvItemMask = 39,
81  kInvItemFins = 40,
82  kInvItemDiveEquipment = 41, // Mask combined with Fins
83  kInvItemAnchor = 42,
84  kInvItemGrapplingHook = 43,
85  kInvItemSickleBlunt = 44,
86  kInvItemCheese = 45,
87  kInvItemSickleSharp = 46,
88  kInvItemHandkerchief = 47,
89  kInvItemMouse = 48,
90  kInvItemRock = 49,
91  kInvItemNugget = 50,
92  kInvItemBanknote = 51,
93  kInvItemDictaphoneNoBatteries = 52,
94  kInvItemPolaroidCamera = 53,
95  kInvItemVideoTape = 54,
96  kInvItemSheetOfPaper = 55,
97  kInvItemCognac = 56,
98  kInvItemRemoteControl = 57,
99  kInvItemIceTongs = 58,
100  kInvItemCork = 59,
101  kInvItemWrappedCork = 60, // Cork combined with Sheet Of Paper
102  kInvItemPhoto = 61,
103  kInvItemChilliWithLabel = 62,
104  kInvItemPastryRoller = 63,
105  kInvItemFakeChilli = 64,
106  kInvItemLabel = 65,
107  kInvItemBatteries = 66,
108  kInvItemDictaphoneWithBatteries = 67, // Dictaphone combined with Batteries
109  kInvItemBurningPaper = 68,
110  kInvItemMeat = 69,
111  kInvItemPlasticBag = 70,
112  kInvItemSocks = 71,
113  kInvItemTimePills = 72,
114  kInvItemHandle = 73,
115  kInvItemChilliNoLabel = 74,
116  kInvItemPass = 75,
117  kInvItemBulb = 76,
118  kInvItemJailKey = 77,
119  kInvItemDelicatePlant = 78,
120  kInvItemSwissArmyKnife = 79,
121  kInvItemSpring = 80,
122  kInvItemShovelAct1 = 81,
123  kInvItemKaleidoscope = 82,
124  kInvItemSoldierNews = 83,
125  kInvItemGrenade = 84,
126  kInvItemMug = 85, // Empty
127  kInvItemMugOfMud = 86, // Full of mud
128  kInvItemCrumbs = 87,
129  kInvItemRopeAct1 = 88,
130  kInvItemRopeAndGrenade = 89, // Rope combined with Grenade
131  kInvItemMedicine = 90,
132  kInvItemDruggedFood = 91, // Crumbs combined with Medicine
133  kInvItemBird = 92
134 };
135 
136 // Maximum number of inventory items held by Ego (Mark)
137 const uint8 kInventorySize = 24;
138 
139 class Inventory {
140 public:
142  ~Inventory();
143 
144  void render(Graphics::Surface *surface, int delta);
145 
146  void clear();
147  void reload();
148  void add(byte item);
149  bool has(byte item) const;
150  void remove(byte item);
151 
152  void activate(bool a) { _active = a; }
153  bool active() const { return _active; }
154 
155  bool processEvent(const Common::Event &event);
156 
157  InventoryObject *selectedObject() { return _selectedObj; }
158  void resetSelectedObject() { _selectedObj = NULL; }
159 
160 private:
161  TeenAgentEngine *_vm;
162  Surface _background;
163  byte *_items;
164  uint _offset[kNumInventoryItems+1];
165 
167  byte *_inventory;
168 
169  struct Item {
170  Animation _animation;
171  Surface _surface;
172  Rect _rect;
173  bool _hovered;
174 
175  Item() : _hovered(false) {}
176  void free();
177  void load(Inventory *inventory, uint itemId);
178  void backgroundEffect(Graphics::Surface *s);
179  void render(Inventory *inventory, uint itemId, Graphics::Surface *surface, int delta);
180  };
181 
182  Item _graphics[kInventorySize];
183 
184  bool _active;
185  Common::Point _mouse;
186 
187  bool tryObjectCallback(InventoryObject *obj);
188 
189  InventoryObject *_hoveredObj;
190  InventoryObject *_selectedObj;
191 };
192 
193 } // End of namespace TeenAgent
194 
195 #endif
Definition: surface.h:67
Definition: teenagent.h:83
Definition: objects.h:180
Definition: objects.h:35
Definition: animation.h:30
Definition: events.h:199
Definition: rect.h:45
Definition: actor.h:29
Definition: surface.h:34
Definition: inventory.h:139