2012-04-15 15:52:39 +00:00
|
|
|
#ifndef MGUI_CONTAINER_H
|
|
|
|
#define MGUI_CONTAINER_H
|
|
|
|
|
|
|
|
#include <components/esm_store/store.hpp>
|
|
|
|
#include "../mwclass/container.hpp"
|
|
|
|
#include <sstream>
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
#include "window_base.hpp"
|
|
|
|
#include "../mwworld/ptr.hpp"
|
|
|
|
#include "../mwworld/containerstore.hpp"
|
2012-05-06 09:04:07 +00:00
|
|
|
#include <vector>
|
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:
|
2012-05-15 16:05:53 +00:00
|
|
|
DragAndDrop() :
|
|
|
|
mWasInInventory(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-04-30 11:01:18 +00:00
|
|
|
bool mIsOnDragAndDrop;
|
|
|
|
MyGUI::Widget* mDraggedWidget;
|
|
|
|
MyGUI::Widget* mDragAndDropWidget;
|
2012-05-11 10:50:30 +00:00
|
|
|
MWWorld::ContainerStore mStore;
|
2012-05-15 16:05:53 +00:00
|
|
|
bool mWasInInventory; // was the item in inventory before it was dragged
|
2012-04-30 11:01:18 +00:00
|
|
|
};
|
2012-04-15 15:52:39 +00:00
|
|
|
|
2012-05-12 20:44:12 +00:00
|
|
|
class ContainerBase
|
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
|
|
|
|
2012-05-12 19:28:04 +00:00
|
|
|
enum Filter
|
|
|
|
{
|
|
|
|
Filter_All = 0x01,
|
|
|
|
Filter_Weapon = 0x02,
|
|
|
|
Filter_Apparel = 0x03,
|
|
|
|
Filter_Magic = 0x04,
|
|
|
|
Filter_Misc = 0x05
|
|
|
|
};
|
|
|
|
|
2012-05-15 18:33:34 +00:00
|
|
|
enum ItemState
|
|
|
|
{
|
|
|
|
ItemState_Normal = 0x01,
|
|
|
|
ItemState_Equipped = 0x02,
|
|
|
|
|
|
|
|
// unimplemented
|
|
|
|
ItemState_Barter = 0x03
|
|
|
|
};
|
|
|
|
|
2012-05-12 20:44:12 +00:00
|
|
|
void setWidgets(MyGUI::Widget* containerWidget, MyGUI::ScrollView* itemView); ///< only call once
|
|
|
|
|
|
|
|
void openContainer(MWWorld::Ptr container);
|
2012-05-12 19:28:04 +00:00
|
|
|
void setFilter(Filter filter); ///< set category filter
|
2012-04-30 11:01:18 +00:00
|
|
|
void Update();
|
2012-04-15 15:52:39 +00:00
|
|
|
|
2012-05-12 11:12:37 +00:00
|
|
|
protected:
|
|
|
|
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;
|
|
|
|
MWWorld::Ptr mContainer;
|
|
|
|
|
2012-05-12 19:28:04 +00:00
|
|
|
Filter mFilter;
|
2012-05-12 18:35:50 +00:00
|
|
|
|
2012-05-12 11:12:37 +00:00
|
|
|
void onSelectedItem(MyGUI::Widget* _sender);
|
2012-05-15 09:02:50 +00:00
|
|
|
void onSelectedItemImpl(MyGUI::Widget* _sender, int count);
|
2012-05-12 11:12:37 +00:00
|
|
|
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-15 09:02:50 +00:00
|
|
|
std::string getCountString(const int count);
|
|
|
|
|
2012-05-15 18:33:34 +00:00
|
|
|
// to be reimplemented by InventoryWindow
|
2012-05-15 16:05:53 +00:00
|
|
|
virtual bool isInventory() { return false; }
|
2012-05-15 18:33:34 +00:00
|
|
|
virtual std::vector<MWWorld::Ptr> getEquippedItems() { return std::vector<MWWorld::Ptr>(); }
|
|
|
|
virtual void _unequipItem(MWWorld::Ptr item) { ; }
|
2012-05-15 16:05:53 +00:00
|
|
|
|
2012-05-12 11:12:37 +00:00
|
|
|
void drawItems();
|
|
|
|
};
|
|
|
|
|
2012-05-12 20:44:12 +00:00
|
|
|
class ContainerWindow : public ContainerBase, public WindowBase
|
2012-05-12 11:12:37 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
ContainerWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop);
|
|
|
|
|
2012-04-30 11:01:18 +00:00
|
|
|
virtual ~ContainerWindow();
|
2012-04-15 15:52:39 +00:00
|
|
|
|
2012-05-12 20:44:12 +00:00
|
|
|
void open(MWWorld::Ptr container);
|
|
|
|
|
2012-04-30 11:01:18 +00:00
|
|
|
protected:
|
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);
|
2012-04-15 15:52:39 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif // CONTAINER_H
|