2011-11-20 21:38:35 +01:00
|
|
|
/*
|
2013-01-08 19:21:54 +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.
|
|
|
|
*/
|
|
|
|
|
2012-03-18 14:34:39 +01:00
|
|
|
#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
|
|
|
|
2012-07-14 03:10:24 +02:00
|
|
|
#include <framework/luaengine/luaobject.h>
|
2012-03-23 14:48:05 +01:00
|
|
|
|
2012-06-22 05:14:13 +02:00
|
|
|
// @bindclass
|
2012-03-23 14:48:05 +01:00
|
|
|
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-03-18 14:34:39 +01:00
|
|
|
|
2012-06-05 21:21:11 +02:00
|
|
|
public:
|
2012-04-03 01:09:47 +02:00
|
|
|
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(); }
|
2012-04-03 01:09:47 +02:00
|
|
|
Position getSlotPosition(int slot) { return Position(0xffff, m_id | 0x40, slot); }
|
|
|
|
int getId() { return m_id; }
|
|
|
|
int getCapacity() { return m_capacity; }
|
2012-05-12 06:52:16 +02:00
|
|
|
ItemPtr getContainerItem() { return m_containerItem; }
|
2012-06-05 21:21:11 +02:00
|
|
|
std::string getName() { return m_name; }
|
2012-04-03 01:09:47 +02:00
|
|
|
bool hasParent() { return m_hasParent; }
|
2012-06-05 21:21:11 +02:00
|
|
|
bool isClosed() { return m_closed; }
|
2012-04-03 01:09:47 +02:00
|
|
|
|
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;
|
|
|
|
|
2012-04-03 01:09:47 +02:00
|
|
|
private:
|
|
|
|
void updateItemsPositions();
|
|
|
|
|
|
|
|
int m_id;
|
|
|
|
int m_capacity;
|
2012-05-12 06:52:16 +02:00
|
|
|
ItemPtr m_containerItem;
|
2012-04-03 01:09:47 +02:00
|
|
|
std::string m_name;
|
|
|
|
bool m_hasParent;
|
2012-06-05 21:21:11 +02:00
|
|
|
bool m_closed;
|
2012-04-03 01:09:47 +02:00
|
|
|
std::deque<ItemPtr> m_items;
|
2011-11-20 21:38:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|