2012-04-15 15:52:39 +00:00
|
|
|
#ifndef MGUI_CONTAINER_H
|
|
|
|
#define MGUI_CONTAINER_H
|
|
|
|
|
2013-04-10 04:32:05 +00:00
|
|
|
#include "windowbase.hpp"
|
2012-05-26 23:14:33 +00:00
|
|
|
#include "referenceinterface.hpp"
|
|
|
|
|
|
|
|
#include "../mwclass/container.hpp"
|
2012-04-15 15:52:39 +00:00
|
|
|
#include "../mwworld/containerstore.hpp"
|
2012-05-26 23:14:33 +00:00
|
|
|
|
2012-04-15 15:52:39 +00:00
|
|
|
|
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
class Environment;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace MyGUI
|
|
|
|
{
|
2012-04-30 11:01:18 +00:00
|
|
|
class Gui;
|
|
|
|
class Widget;
|
2012-04-15 15:52:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace MWGui
|
|
|
|
{
|
|
|
|
class WindowManager;
|
2012-04-30 11:01:18 +00:00
|
|
|
class ContainerWindow;
|
2012-05-12 11:12:37 +00:00
|
|
|
class ContainerBase;
|
2012-04-15 15:52:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace MWGui
|
|
|
|
{
|
2012-04-30 11:01:18 +00:00
|
|
|
class DragAndDrop
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool mIsOnDragAndDrop;
|
|
|
|
MyGUI::Widget* mDraggedWidget;
|
|
|
|
MyGUI::Widget* mDragAndDropWidget;
|
2012-05-15 19:44:57 +00:00
|
|
|
ContainerBase* mDraggedFrom;
|
|
|
|
int mDraggedCount;
|
2012-04-30 11:01:18 +00:00
|
|
|
};
|
2012-04-15 15:52:39 +00:00
|
|
|
|
2012-05-26 23:14:33 +00:00
|
|
|
class ContainerBase : public ReferenceInterface
|
2012-04-15 15:52:39 +00:00
|
|
|
{
|
2012-04-30 11:01:18 +00:00
|
|
|
public:
|
2012-05-12 20:44:12 +00:00
|
|
|
ContainerBase(DragAndDrop* dragAndDrop);
|
2012-05-12 11:12:37 +00:00
|
|
|
virtual ~ContainerBase();
|
2012-04-15 15:52:39 +00:00
|
|
|
|
2013-03-16 18:00:14 +00:00
|
|
|
// basic types (inclusive)
|
|
|
|
static const int Filter_All = (1<<0);
|
|
|
|
static const int Filter_Weapon = (1<<1);
|
|
|
|
static const int Filter_Apparel = (1<<2);
|
|
|
|
static const int Filter_Ingredients = (1<<3);
|
|
|
|
static const int Filter_Misc = (1<<4);
|
|
|
|
|
|
|
|
// special filtering (exclusive)
|
|
|
|
static const int Filter_Magic = (1<<5);
|
|
|
|
static const int Filter_NoMagic = (1<<6);
|
|
|
|
static const int Filter_ChargedSoulstones = (1<<7);
|
2012-05-12 19:28:04 +00:00
|
|
|
|
2012-05-15 18:33:34 +00:00
|
|
|
enum ItemState
|
|
|
|
{
|
|
|
|
ItemState_Normal = 0x01,
|
|
|
|
ItemState_Equipped = 0x02,
|
|
|
|
ItemState_Barter = 0x03
|
|
|
|
};
|
|
|
|
|
2012-05-12 20:44:12 +00:00
|
|
|
void setWidgets(MyGUI::Widget* containerWidget, MyGUI::ScrollView* itemView); ///< only call once
|
|
|
|
|
2012-05-18 18:53:24 +00:00
|
|
|
void addBarteredItem(MWWorld::Ptr item, int count);
|
|
|
|
void addItem(MWWorld::Ptr item, int count);
|
|
|
|
|
|
|
|
void transferBoughtItems(); ///< transfer bought items into the inventory
|
|
|
|
void returnBoughtItems(MWWorld::ContainerStore& store); ///< return bought items into the specified ContainerStore
|
|
|
|
|
|
|
|
MWWorld::ContainerStore& getContainerStore();
|
2012-05-18 20:06:25 +00:00
|
|
|
MWWorld::ContainerStore& getBoughtItems() { return mBoughtItems; }
|
2012-05-18 15:27:55 +00:00
|
|
|
|
2012-05-12 20:44:12 +00:00
|
|
|
void openContainer(MWWorld::Ptr container);
|
2013-03-16 18:00:14 +00:00
|
|
|
void setFilter(int filter); ///< set category filter
|
2012-05-15 19:44:57 +00:00
|
|
|
void drawItems();
|
|
|
|
|
2013-03-31 11:13:46 +00:00
|
|
|
/// fired when an item was moved by drag&drop. \n
|
|
|
|
/// if it was removed from this container, count will be negative.
|
|
|
|
virtual void notifyItemDragged(MWWorld::Ptr item, int count) {}
|
|
|
|
|
2012-05-12 11:12:37 +00:00
|
|
|
protected:
|
2013-03-07 13:00:13 +00:00
|
|
|
bool mDisplayEquippedItems;
|
|
|
|
bool mHighlightEquippedItems;
|
|
|
|
|
2012-05-12 11:12:37 +00:00
|
|
|
MyGUI::ScrollView* mItemView;
|
|
|
|
MyGUI::Widget* mContainerWidget;
|
|
|
|
|
2012-05-15 10:51:51 +00:00
|
|
|
MyGUI::Widget* mSelectedItem;
|
|
|
|
|
2012-05-12 11:12:37 +00:00
|
|
|
DragAndDrop* mDragAndDrop;
|
|
|
|
|
2013-03-16 18:00:14 +00:00
|
|
|
int mFilter;
|
2012-05-12 18:35:50 +00:00
|
|
|
|
2012-05-18 18:53:24 +00:00
|
|
|
// bought items are put in a separate ContainerStore so that they don't stack with other (not bought) items.
|
|
|
|
MWWorld::ContainerStore mBoughtItems;
|
2012-05-18 15:27:55 +00:00
|
|
|
|
2012-05-12 11:12:37 +00:00
|
|
|
void onSelectedItem(MyGUI::Widget* _sender);
|
|
|
|
void onContainerClicked(MyGUI::Widget* _sender);
|
2012-05-12 23:27:17 +00:00
|
|
|
void onMouseWheel(MyGUI::Widget* _sender, int _rel);
|
2012-05-12 11:12:37 +00:00
|
|
|
|
2012-05-18 15:27:55 +00:00
|
|
|
/// start dragging an item (drag & drop)
|
|
|
|
void startDragItem(MyGUI::Widget* _sender, int count);
|
|
|
|
|
|
|
|
/// sell an item from this container
|
|
|
|
void sellItem(MyGUI::Widget* _sender, int count);
|
|
|
|
|
|
|
|
/// sell an item from this container, that was previously just bought
|
|
|
|
void sellAlreadyBoughtItem(MyGUI::Widget* _sender, int count);
|
|
|
|
|
2012-05-15 09:02:50 +00:00
|
|
|
std::string getCountString(const int count);
|
|
|
|
|
2012-05-18 15:27:55 +00:00
|
|
|
virtual bool isTradeWindow() { return false; }
|
2012-05-15 16:05:53 +00:00
|
|
|
virtual bool isInventory() { return false; }
|
2013-03-07 13:00:13 +00:00
|
|
|
virtual std::vector<MWWorld::Ptr> getEquippedItems();
|
2012-05-15 18:33:34 +00:00
|
|
|
virtual void _unequipItem(MWWorld::Ptr item) { ; }
|
2012-05-17 19:56:16 +00:00
|
|
|
|
2012-05-18 15:27:55 +00:00
|
|
|
virtual bool isTrading() { return false; }
|
|
|
|
|
2012-05-25 13:24:33 +00:00
|
|
|
virtual void onSelectedItemImpl(MWWorld::Ptr item) { ; }
|
|
|
|
|
2012-05-18 13:51:33 +00:00
|
|
|
virtual std::vector<MWWorld::Ptr> itemsToIgnore() { return std::vector<MWWorld::Ptr>(); }
|
2012-05-29 10:35:03 +00:00
|
|
|
|
|
|
|
virtual void notifyContentChanged() { ; }
|
2012-05-12 11:12:37 +00:00
|
|
|
};
|
|
|
|
|
2012-05-12 20:44:12 +00:00
|
|
|
class ContainerWindow : public ContainerBase, public WindowBase
|
2012-05-12 11:12:37 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-04-10 18:46:21 +00:00
|
|
|
ContainerWindow(DragAndDrop* dragAndDrop);
|
2012-05-12 11:12:37 +00:00
|
|
|
|
2012-04-30 11:01:18 +00:00
|
|
|
virtual ~ContainerWindow();
|
2012-04-15 15:52:39 +00:00
|
|
|
|
2013-03-07 13:00:13 +00:00
|
|
|
void open(MWWorld::Ptr container, bool loot=false);
|
2012-05-12 20:44:12 +00:00
|
|
|
|
2012-04-30 11:01:18 +00:00
|
|
|
protected:
|
2013-03-07 13:00:13 +00:00
|
|
|
MyGUI::Button* mDisposeCorpseButton;
|
2012-05-12 11:12:37 +00:00
|
|
|
MyGUI::Button* mTakeButton;
|
|
|
|
MyGUI::Button* mCloseButton;
|
2012-04-15 15:52:39 +00:00
|
|
|
|
2012-05-12 11:46:03 +00:00
|
|
|
void onWindowResize(MyGUI::Window* window);
|
2012-05-11 14:34:36 +00:00
|
|
|
void onCloseButtonClicked(MyGUI::Widget* _sender);
|
2012-05-11 14:58:07 +00:00
|
|
|
void onTakeAllButtonClicked(MyGUI::Widget* _sender);
|
2013-03-07 13:00:13 +00:00
|
|
|
void onDisposeCorpseButtonClicked(MyGUI::Widget* sender);
|
2012-05-26 23:14:33 +00:00
|
|
|
|
|
|
|
virtual void onReferenceUnavailable();
|
2012-04-15 15:52:39 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif // CONTAINER_H
|