forked from mirror/openmw-tes3mp
another step towards drand and drop.
This commit is contained in:
parent
5f8c08b18b
commit
60ad6f01d4
2 changed files with 81 additions and 31 deletions
|
@ -22,12 +22,29 @@
|
||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
using namespace Widgets;
|
using namespace Widgets;
|
||||||
|
class ItemWidget: public MyGUI::ImageBox
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ItemWidget()
|
||||||
|
:ImageBox()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ItemWidget()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPtr(MWWorld::Ptr &ptr,int pos){mPtr = ptr;mPos = pos;}
|
||||||
|
|
||||||
|
MWWorld::Ptr mPtr;
|
||||||
|
int mPos;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
ContainerWindow::ContainerWindow(WindowManager& parWindowManager,MWWorld::Environment& environment,DragAndDrop* dragAndDrop)
|
ContainerWindow::ContainerWindow(WindowManager& parWindowManager,MWWorld::Environment& environment,DragAndDrop* dragAndDrop)
|
||||||
: WindowBase("openmw_container_window_layout.xml", parWindowManager),
|
: WindowBase("openmw_container_window_layout.xml", parWindowManager),
|
||||||
mEnvironment(environment),
|
mEnvironment(environment),
|
||||||
mDragAndDrop(dragAndDrop)
|
mDragAndDrop(dragAndDrop),
|
||||||
|
mContainer()
|
||||||
{
|
{
|
||||||
setText("_Main", "Name of Container");
|
setText("_Main", "Name of Container");
|
||||||
|
|
||||||
|
@ -52,7 +69,8 @@ ContainerWindow::ContainerWindow(WindowManager& parWindowManager,MWWorld::Enviro
|
||||||
ContainerWindow::ContainerWindow(WindowManager& parWindowManager,MWWorld::Environment& environment,DragAndDrop* dragAndDrop,std::string guiFile)
|
ContainerWindow::ContainerWindow(WindowManager& parWindowManager,MWWorld::Environment& environment,DragAndDrop* dragAndDrop,std::string guiFile)
|
||||||
: WindowBase(guiFile, parWindowManager),
|
: WindowBase(guiFile, parWindowManager),
|
||||||
mEnvironment(environment),
|
mEnvironment(environment),
|
||||||
mDragAndDrop(dragAndDrop)
|
mDragAndDrop(dragAndDrop),
|
||||||
|
mContainer()
|
||||||
{
|
{
|
||||||
setText("_Main", "Name of Container");
|
setText("_Main", "Name of Container");
|
||||||
//center();
|
//center();
|
||||||
|
@ -81,11 +99,18 @@ void ContainerWindow::setName(std::string contName)
|
||||||
|
|
||||||
void ContainerWindow::open(MWWorld::Ptr& container)
|
void ContainerWindow::open(MWWorld::Ptr& container)
|
||||||
{
|
{
|
||||||
|
mContainer = container;
|
||||||
setName(MWWorld::Class::get(container).getName(container));
|
setName(MWWorld::Class::get(container).getName(container));
|
||||||
//MWWorld::ContainerStore* containerStore = container.getContainerStore();
|
//MWWorld::ContainerStore* containerStore = container.getContainerStore();
|
||||||
|
drawItems();
|
||||||
|
setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
MWWorld::ContainerStore& containerStore = MWWorld::Class::get(container).getContainerStore(container);
|
void ContainerWindow::drawItems()
|
||||||
|
{
|
||||||
|
MyGUI::Gui::getInstance().destroyWidgets(mContainerWidget->getEnumerator());
|
||||||
|
MWWorld::ContainerStore& containerStore = MWWorld::Class::get(mContainer).getContainerStore(mContainer);
|
||||||
|
//mContainerWidget->
|
||||||
|
|
||||||
/*MWWorld::ManualRef furRef (mWindowManager.getStore(), "fur_cuirass");
|
/*MWWorld::ManualRef furRef (mWindowManager.getStore(), "fur_cuirass");
|
||||||
furRef.getPtr().getRefData().setCount (5);
|
furRef.getPtr().getRefData().setCount (5);
|
||||||
|
@ -121,32 +146,36 @@ void ContainerWindow::open(MWWorld::Ptr& container)
|
||||||
|
|
||||||
// ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref = iter->get<ESM::Armor>();
|
// ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref = iter->get<ESM::Armor>();
|
||||||
|
|
||||||
|
|
||||||
int x = 4;
|
int x = 4;
|
||||||
int y = 4;
|
int y = 4;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
|
||||||
for (MWWorld::ContainerStoreIterator iter (containerStore.begin()); iter!=containerStore.end(); ++iter)
|
for (MWWorld::ContainerStoreIterator iter (containerStore.begin()); iter!=containerStore.end(); ++iter)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
if(iter->getRefData().getCount() > 0)
|
||||||
{
|
{
|
||||||
std::string path = std::string("icons\\");
|
std::string path = std::string("icons\\");
|
||||||
path+=MWWorld::Class::get(*iter).getInventoryIcon(*iter);
|
path+=MWWorld::Class::get(*iter).getInventoryIcon(*iter);
|
||||||
count++;
|
ItemWidget* image = mContainerWidget->createWidget<ItemWidget>("ImageBox", MyGUI::IntCoord(x, y, 32, 32), MyGUI::Align::Default);
|
||||||
|
|
||||||
MyGUI::ImageBox* image = mContainerWidget->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(x, y, 32, 32), MyGUI::Align::Default);
|
|
||||||
MyGUI::TextBox* text = image->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::IntCoord(x, y, 18, 18), MyGUI::Align::Default, std::string("Label"));
|
MyGUI::TextBox* text = image->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::IntCoord(x, y, 18, 18), MyGUI::Align::Default, std::string("Label"));
|
||||||
image->eventMouseButtonClick += MyGUI::newDelegate(this,&ContainerWindow::onSelectedItem);
|
image->eventMouseButtonClick += MyGUI::newDelegate(this,&ContainerWindow::onSelectedItem);
|
||||||
|
//image->setPtr(*iter,count);
|
||||||
|
image->mPos = count;
|
||||||
|
|
||||||
|
//image->mPtr = *iter;
|
||||||
//image->eventMouseMove += MyGUI::newDelegate(this,&ContainerWindow::onMouseMove);
|
//image->eventMouseMove += MyGUI::newDelegate(this,&ContainerWindow::onMouseMove);
|
||||||
x += 36;
|
/*x += 36;
|
||||||
if(count % 20 == 0)
|
if(count % 20 == 0)
|
||||||
{
|
{
|
||||||
y += 36;
|
y += 36;
|
||||||
x = 4;
|
x = 4;
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if(iter->getRefData().getCount() > 1)
|
if(iter->getRefData().getCount() > 1)
|
||||||
text->setCaption(boost::lexical_cast<std::string>(iter->getRefData().getCount()));
|
text->setCaption(boost::lexical_cast<std::string>(iter->getRefData().getCount()));
|
||||||
|
|
||||||
//mContainerWidgets
|
//mContainerWidgets
|
||||||
|
|
||||||
int pos = path.rfind(".");
|
int pos = path.rfind(".");
|
||||||
|
@ -155,11 +184,7 @@ void ContainerWindow::open(MWWorld::Ptr& container)
|
||||||
//std::cout << path << std::endl;
|
//std::cout << path << std::endl;
|
||||||
image->setImageTexture(path);
|
image->setImageTexture(path);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setVisible(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContainerWindow::Update()
|
void ContainerWindow::Update()
|
||||||
|
@ -188,10 +213,26 @@ void ContainerWindow::onSelectedItem(MyGUI::Widget* _sender)
|
||||||
mDragAndDrop->mIsOnDragAndDrop = true;
|
mDragAndDrop->mIsOnDragAndDrop = true;
|
||||||
_sender->detachFromWidget();
|
_sender->detachFromWidget();
|
||||||
_sender->attachToWidget(mDragAndDrop->mDragAndDropWidget);
|
_sender->attachToWidget(mDragAndDrop->mDragAndDropWidget);
|
||||||
|
|
||||||
|
ItemWidget* item = static_cast<ItemWidget*>(_sender);
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
MWWorld::ContainerStore& containerStore = MWWorld::Class::get(mContainer).getContainerStore(mContainer);
|
||||||
|
for (MWWorld::ContainerStoreIterator iter (containerStore.begin()); iter!=containerStore.end(); ++iter)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
if(count == item->mPos)
|
||||||
|
{
|
||||||
|
iter->getRefData().setCount(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//containerStore.
|
||||||
//std::cout << mContainerWidget->getParent()->getParent()->getName();
|
//std::cout << mContainerWidget->getParent()->getParent()->getName();
|
||||||
_sender->setUserString("drag","on");
|
_sender->setUserString("drag","on");
|
||||||
mDragAndDrop->mDraggedWidget = _sender;
|
mDragAndDrop->mDraggedWidget = _sender;
|
||||||
mDragAndDrop->mContainerWindow = const_cast<MWGui::ContainerWindow*>(this);
|
mDragAndDrop->mContainerWindow = const_cast<MWGui::ContainerWindow*>(this);
|
||||||
|
drawItems();
|
||||||
std::cout << "selected!";
|
std::cout << "selected!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,6 +251,7 @@ void ContainerWindow::onContainerClicked(MyGUI::Widget* _sender)
|
||||||
std::cout << "container clicked";
|
std::cout << "container clicked";
|
||||||
if(mDragAndDrop->mIsOnDragAndDrop) //drop widget here
|
if(mDragAndDrop->mIsOnDragAndDrop) //drop widget here
|
||||||
{
|
{
|
||||||
|
//mContainer.getContainerStore()->add(mDragAndDrop->mDraggedWidget->
|
||||||
mDragAndDrop->mIsOnDragAndDrop = false;
|
mDragAndDrop->mIsOnDragAndDrop = false;
|
||||||
mDragAndDrop->mDraggedWidget->detachFromWidget();
|
mDragAndDrop->mDraggedWidget->detachFromWidget();
|
||||||
mDragAndDrop->mDraggedWidget->attachToWidget(mContainerWidget);
|
mDragAndDrop->mDraggedWidget->attachToWidget(mContainerWidget);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "window_base.hpp"
|
#include "window_base.hpp"
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/containerstore.hpp"
|
#include "../mwworld/containerstore.hpp"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
|
@ -38,6 +39,8 @@ namespace MWGui
|
||||||
ContainerWindow* mContainerWindow;
|
ContainerWindow* mContainerWindow;
|
||||||
MyGUI::Widget* mDraggedWidget;
|
MyGUI::Widget* mDraggedWidget;
|
||||||
MyGUI::Widget* mDragAndDropWidget;
|
MyGUI::Widget* mDragAndDropWidget;
|
||||||
|
|
||||||
|
MWWorld::Ptr mItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ContainerWindow : public WindowBase
|
class ContainerWindow : public WindowBase
|
||||||
|
@ -63,6 +66,11 @@ namespace MWGui
|
||||||
MyGUI::ButtonPtr closeButton;
|
MyGUI::ButtonPtr closeButton;
|
||||||
DragAndDrop* mDragAndDrop;
|
DragAndDrop* mDragAndDrop;
|
||||||
|
|
||||||
|
MWWorld::Ptr mContainer;
|
||||||
|
bool mIsValid;//is in the right GUI Mode
|
||||||
|
|
||||||
|
void drawItems();
|
||||||
|
|
||||||
void onByeClicked(MyGUI::Widget* _sender);
|
void onByeClicked(MyGUI::Widget* _sender);
|
||||||
void onSelectedItem(MyGUI::Widget* _sender);
|
void onSelectedItem(MyGUI::Widget* _sender);
|
||||||
void onContainerClicked(MyGUI::Widget* _sender);
|
void onContainerClicked(MyGUI::Widget* _sender);
|
||||||
|
|
Loading…
Reference in a new issue