ItemBox (drag-and-drop demo) problem

Celebrien

12-07-2008 15:10:18

Hi all,

I absolutely love the drag-and-drop demo and it's exactly what I need for the inventory in the game I'm busy working on. But now I suddenly started having problems with it :(

MyGUI was recently updated, and before I switched to v2.2.0 i worked with v2.0.1 for a long time. Since the drag-and-drop demo has been developed for that version already, I embedded it in my game and it worked perfectly. But after switching to v2.2.0 I tested the game and the drag-an-drop inventory refused to work and threw and exception at me. I suppose there should've been some changes made somewhere in the new version, but I can't figure out where.

I'll give you my code that I use for the inventory. If you check in the DemoKeeper.cpp - it's exactly the same! But maybe I'm making a stupid mistake somewhere... I hope someone would be able to help me out because the damn inventory starts frustrating me :x

The code that invokes the inventory to appear:

void GuiManager::showInventory(Player * player){
//... lots of widgets...

MyGUI::SkinManager::getInstance().load("WM.skin");
MyGUI::SkinManager::getInstance().load("RF.skin");
MyGUI::PointerManager::getInstance().load("RF.pointer");
MyGUI::FontManager::getInstance().load("RF.font");

MyGUI::IntCoord renderCoord;
renderCoord = character->getCoord();
MyGUI::IntCoord coord2;
coord2.set((renderCoord.left+200), renderCoord.top, 350, 398);

MyGUI::ItemBoxPtr box = sheet->createWidget<MyGUI::ItemBox>("RF_ItemBoxV", coord2, MyGUI::ALIGN_STRETCH);
MyGUI::ItemBoxPtr box = MyGUI::Gui::getInstance().findWidget<MyGUI::ItemBox>("itemBox");
box->requestCreateWidgetItem = MyGUI::newDelegate(requestCreateWidgetItem);
box->requestCoordWidgetItem = MyGUI::newDelegate(requestCoordWidgetItem);
box->requestUpdateWidgetItem = MyGUI::newDelegate(requestUpdateWidgetItem);
box->eventStartDrop = MyGUI::newDelegate(eventStartDrop);
box->eventRequestDrop = MyGUI::newDelegate(eventRequestDrop);
box->eventEndDrop = MyGUI::newDelegate(eventEndDrop);
box->eventDropState = MyGUI::newDelegate(eventDropState);*/

size_t num = 0;
while (num < 50) {
box->addItem((void*) new ItemData(num%9, (num%9 == 0) ? 0 : 5));
num ++;
}

}


The "helper" code, taken directly from DemoKeeper:

struct ItemData
{
ItemData(size_t _type, size_t _count) :
type(_type),
count(_count)
{
}
size_t type;
size_t count;
};

// Ñ

Celebrien

18-07-2008 19:37:55

help! pleeease! :(