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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef MUTATIONOFJB_INVENTORY_H
24 #define MUTATIONOFJB_INVENTORY_H
25 
26 #include "common/array.h"
27 #include "common/serializer.h"
28 #include "common/scummsys.h"
29 #include "common/str.h"
30 
31 namespace MutationOfJB {
32 
33 class Game;
34 
35 class InventoryObserver {
36 public:
37 	virtual void onInventoryChanged() = 0;
~InventoryObserver()38 	virtual ~InventoryObserver() {}
39 };
40 
41 class Inventory : public Common::Serializable {
42 public:
43 	enum {
44 		VISIBLE_ITEMS = 6
45 	};
46 
47 	typedef Common::Array<Common::String> Items;
48 
Inventory()49 	Inventory() : _observer(nullptr) {}
50 
51 	const Items &getItems() const;
52 	bool hasItem(const Common::String &item) const;
53 	void addItem(const Common::String &item);
54 	void removeItem(const Common::String &item);
55 	void removeAllItems();
56 	void renameItem(const Common::String &oldName, const Common::String &newName);
57 
58 	void scrollLeft();
59 	void scrollRight();
60 
61 	void setObserver(InventoryObserver *observer);
62 
63 	virtual void saveLoadWithSerializer(Common::Serializer &sz) override;
64 
65 private:
66 	void rotateItemsRight(uint n);
67 	void rotateItemsLeft(uint n);
68 	void reverseItems(uint from, uint to);
69 
70 	Items _items;
71 	InventoryObserver *_observer;
72 };
73 
74 }
75 
76 #endif
77