From 6a16075912d016926ee0361fb85f9979c119be52 Mon Sep 17 00:00:00 2001 From: Ilya Zhuravlev Date: Mon, 20 Aug 2012 01:29:56 +0400 Subject: Add InventoryList width property & allow custom crafting grids. --- src/inventory.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/inventory.cpp') diff --git a/src/inventory.cpp b/src/inventory.cpp index 0a0a29cd5..fda11e40f 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -431,6 +431,7 @@ InventoryList::InventoryList(std::string name, u32 size, IItemDefManager *itemde { m_name = name; m_size = size; + m_width = 0; m_itemdef = itemdef; clearItems(); //m_dirty = false; @@ -459,6 +460,11 @@ void InventoryList::setSize(u32 newsize) m_size = newsize; } +void InventoryList::setWidth(u32 newwidth) +{ + m_width = newwidth; +} + void InventoryList::setName(const std::string &name) { m_name = name; @@ -468,6 +474,8 @@ void InventoryList::serialize(std::ostream &os) const { //os.imbue(std::locale("C")); + os<<"Width "<> m_width; + if (iss.fail()) + throw SerializationError("incorrect width property"); + } else if(name == "Item") { if(item_i > getSize() - 1) @@ -543,6 +558,7 @@ InventoryList & InventoryList::operator = (const InventoryList &other) { m_items = other.m_items; m_size = other.m_size; + m_width = other.m_width; m_name = other.m_name; m_itemdef = other.m_itemdef; //setDirty(true); @@ -560,6 +576,11 @@ u32 InventoryList::getSize() const return m_items.size(); } +u32 InventoryList::getWidth() const +{ + return m_width; +} + u32 InventoryList::getUsedSlots() const { u32 num = 0; -- cgit v1.2.3