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 PARALLACTION_INVENTORY_H
23#define PARALLACTION_INVENTORY_H
24
25
26#include "graphics/surface.h"
27
28namespace Parallaction {
29
30class Parallaction;
31
33 uint32 _id; // object name (lowest 16 bits are always zero)
34 uint16 _index; // index to frame in objs file
35};
36
38 uint _itemPitch;
39 uint _itemWidth;
40 uint _itemHeight;
41
42 int _maxItems;
43
44 int _itemsPerLine;
45 int _maxLines;
46
47 int _width;
48 int _height;
49};
50
51#define MAKE_INVENTORY_ID(x) (((x) & 0xFFFF) << 16)
52
53typedef int16 ItemPosition;
54typedef uint16 ItemName;
55
56class Inventory {
57
58protected:
59 uint16 _numVerbs;
60
61 InventoryItem *_items;
62 uint16 _numItems;
63 int _maxItems;
64
65public:
66 Inventory(int maxItems, InventoryItem *verbs);
67 virtual ~Inventory();
68
69 ItemPosition addItem(ItemName name, uint32 value);
70 ItemPosition addItem(ItemName item);
71 void removeItem(ItemName name);
72 void clear(bool keepVerbs = true);
73
74 const InventoryItem* getItem(ItemPosition pos) const;
75 ItemName getItemName(ItemPosition pos) const;
76
77 ItemPosition findItem(ItemName name) const;
78
79 int16 getNumItems() const { return _numItems; }
80};
81
82
83
85 Parallaction *_vm;
86 InventoryProperties *_props;
87
88 Inventory *_inv;
89 Common::Point _pos;
90
92
93protected:
94 void getItemRect(ItemPosition pos, Common::Rect &r);
95
96 void drawItem(ItemPosition pos, ItemName name);
97 void refresh();
98
99public:
101 virtual ~InventoryRenderer();
102
103 void setInventory(Inventory *inventory);
104
105 void showInventory();
106 void hideInventory();
107
108 ItemPosition hitTest(const Common::Point &p) const;
109 void highlightItem(ItemPosition pos, byte color);
110 void drawItem(ItemName name, byte *buffer, uint pitch);
111
112 byte *getData() { return (byte *)_surf.getPixels(); }
113
114 void getRect(Common::Rect &r) const;
115 int16 getNumLines() const;
116};
117
118} // namespace Parallaction
119
120#endif
Definition: inventory.h:56
Definition: inventory.h:84
Definition: debug.h:8
Definition: rect.h:144
Definition: rect.h:536
Definition: surface.h:67
const void * getPixels() const
Definition: surface.h:110
Definition: inventory.h:32
Definition: inventory.h:37