ScummVM API documentation
ItemSlot.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 /*
23  * This code is based on the CRAB engine
24  *
25  * Copyright (c) Arvind Raja Yadav
26  *
27  * Licensed under MIT
28  *
29  */
30 
31 #ifndef CRAB_ITEMSLOT_H
32 #define CRAB_ITEMSLOT_H
33 
34 #include "crab/item/Item.h"
35 #include "crab/ui/StateButton.h"
36 
37 namespace Crab {
38 
39 namespace pyrodactyl {
40 namespace item {
41 enum SlotType {
42  SLOT_EQUIP,
43  SLOT_STORAGE
44 };
45 
47  // Ignore the type of item check
48  bool _noType;
49 
50 public:
51  // The type of item allowed in this slot (can be overridden by item_type)
52  Common::String _itemType;
53 
54  // Is the slot empty?
55  bool _empty;
56 
57  // Is the slot enabled? (used for stat calculation)
58  bool _enabled;
59 
60  // Is this a new item? Draw the unread notification icon if so
61  bool _unread;
62 
63  // The type of the item slot
64  SlotType _category;
65 
66  // The item contained in the slot
67  Item _item;
68 
69  ItemSlot() {
70  _empty = true;
71  _enabled = true;
72  _category = SLOT_STORAGE;
73  _noType = false;
74  _unread = false;
75  }
76  ~ItemSlot() {}
77 
78  void init(const ItemSlot &ref, const int &xOffset = 0, const int &yOffset = 0);
79  void load(rapidxml::xml_node<char> *node);
80 
81  void draw();
82 
83  pyrodactyl::ui::ButtonAction handleEvents(const Common::Event &event, const int &xOffset = 0, const int &yOffset = 0);
84 
85  bool canSwap(ItemSlot &target) {
86  return target._noType || _item._type == target._itemType;
87  }
88 
89  bool swap(ItemSlot &target);
90  bool equip(Item &i);
91 
92  void statChange(pyrodactyl::people::Person &obj, bool increase);
93 
94  void saveState(rapidxml::xml_document<> &doc, rapidxml::xml_node<char> *root);
95  void loadState(rapidxml::xml_node<char> *node);
96 };
97 } // End of namespace item
98 } // End of namespace pyrodactyl
99 
100 } // End of namespace Crab
101 
102 #endif // CRAB_ITEMSLOT_H
Definition: StateButton.h:66
Definition: str.h:59
Definition: Item.h:42
Definition: person.h:43
Definition: ItemSlot.h:46
Definition: events.h:199
Definition: moveeffect.h:37