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