tibia-client/src/client/container.h

72 lines
2.4 KiB
C
Raw Normal View History

2011-11-20 21:38:35 +01:00
/*
* Copyright (c) 2010-2013 OTClient <https://github.com/edubart/otclient>
2011-11-20 21:38:35 +01:00
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef CONTAINER_H
#define CONTAINER_H
2011-11-20 21:38:35 +01:00
#include "declarations.h"
2012-07-29 14:04:47 +02:00
#include "item.h"
2011-11-20 21:38:35 +01:00
#include <framework/luaengine/luaobject.h>
2012-06-22 05:14:13 +02:00
// @bindclass
class Container : public LuaObject
2011-11-20 21:38:35 +01:00
{
2012-06-05 21:21:11 +02:00
protected:
Container(int id, int capacity, const std::string& name, const ItemPtr& containerItem, bool hasParent);
2012-06-05 21:21:11 +02:00
public:
ItemPtr getItem(int slot);
2012-06-05 18:59:32 +02:00
std::deque<ItemPtr> getItems() { return m_items; }
2012-06-05 21:21:11 +02:00
int getItemsCount() { return m_items.size(); }
Position getSlotPosition(int slot) { return Position(0xffff, m_id | 0x40, slot); }
int getId() { return m_id; }
int getCapacity() { return m_capacity; }
ItemPtr getContainerItem() { return m_containerItem; }
2012-06-05 21:21:11 +02:00
std::string getName() { return m_name; }
bool hasParent() { return m_hasParent; }
2012-06-05 21:21:11 +02:00
bool isClosed() { return m_closed; }
2012-06-05 18:59:32 +02:00
protected:
void onOpen(const ContainerPtr& previousContainer);
void onClose();
void onAddItem(const ItemPtr& item);
void onAddItems(const std::vector<ItemPtr>& items);
void onUpdateItem(int slot, const ItemPtr& item);
void onRemoveItem(int slot);
friend class Game;
private:
void updateItemsPositions();
int m_id;
int m_capacity;
ItemPtr m_containerItem;
std::string m_name;
bool m_hasParent;
2012-06-05 21:21:11 +02:00
bool m_closed;
std::deque<ItemPtr> m_items;
2011-11-20 21:38:35 +01:00
};
#endif