Mana
Loading...
Searching...
No Matches
inventoryhandler.h
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include "equipment.h"
25#include "position.h"
26
27#include <string>
28
29namespace Net {
30
31// Default positions of the boxes, 2nd dimension is X and Y respectively.
33 { 90, 40 }, // EQUIP_TORSO_SLOT
34 { 8, 78 }, // EQUIP_GLOVES_SLOT
35 { 70, 0 }, // EQUIP_HEAD_SLOT
36 { 50, 208 }, // EQUIP_LEGS_SLOT
37 { 90, 208 }, // EQUIP_FEET_SLOT
38 { 8, 168 }, // EQUIP_RING1_SLOT
39 { 129, 168 }, // EQUIP_RING2_SLOT
40 { 50, 40 }, // EQUIP_NECK_SLOT
41 { 8, 123 }, // EQUIP_FIGHT1_SLOT
42 { 129, 123 }, // EQUIP_FIGHT2_SLOT
43 { 129, 78 } // EQUIP_PROJECTILE_SLOT
44};
45
46const std::string fallBackBoxIcons[] = {
47 "equip-box-chest",
48 "equip-box-hands",
49 "equip-box-head",
50 "equip-box-legs",
51 "equip-box-feet",
52 "equip-box-ring",
53 "equip-box-ring",
54 "equip-box-neck",
55 "equip-box-weapon",
56 "equip-box-shield",
57 "equip-box-ammo"
58};
59
60static const std::string empty;
61
63{
64 public:
65 virtual ~InventoryHandler() {}
66
67 // TODO: fix/remove me
68 virtual size_t getSize(int type) const = 0;
69
70 virtual bool isWeaponSlot(unsigned int slotTypeId) const = 0;
71
72 virtual bool isAmmoSlot(unsigned int slotTypeId) const = 0;
73
74 virtual unsigned int getVisibleSlotsNumber() const
75 { return 0; }
76
78
79 virtual Position getBoxPosition(unsigned int slotIndex) const
80 {
81 if (slotIndex < sizeof(fallBackBoxPositions) / sizeof(fallBackBoxPositions[0]))
82 return fallBackBoxPositions[slotIndex];
83 return Position(0,0);
84 }
85
86 virtual const std::string& getBoxIcon(unsigned int slotIndex) const
87 {
88 if (slotIndex < sizeof(fallBackBoxIcons) / sizeof(fallBackBoxIcons[0]))
89 return fallBackBoxIcons[slotIndex];
90 return empty; // The empty string
91 }
92};
93
94} // namespace Net
virtual Position getBoxPosition(unsigned int slotIndex) const
virtual const std::string & getBoxIcon(unsigned int slotIndex) const
virtual bool isAmmoSlot(unsigned int slotTypeId) const =0
virtual Equipment::Backend * getEquipmentBackend()=0
virtual unsigned int getVisibleSlotsNumber() const
virtual bool isWeaponSlot(unsigned int slotTypeId) const =0
virtual size_t getSize(int type) const =0
The network communication layer.
const std::string fallBackBoxIcons[]
constexpr Position fallBackBoxPositions[]
A position along a being's path.
Definition position.h:31