I'm in the early stages of making an inventory system for my game, and I've hit a snag.
I have a ScrollablePane with it's content window subscribed to drag and drop event handlers, and that's all working just fine. The problem is that the StaticImages I drop into the ScrollablePane are all stacking on top of eachother.
I have code in DropEventHandler() that checks the number of children in the content window and rearanged them by calling setPosition with the appropriate offsets, but to no avail. They're always drawn at 0,0 and it's driving me insane!
I create the scrollable pane like this:
Code: Select all
ScrollablePane* slot =
(ScrollablePane*)WindowManager::getSingleton().createWindow("TaharezLook/ScrollablePane");
parent->addChildWindow(slot);
slot->setMetricsMode(CEGUI::Absolute);
slot->setWindowPosition(position);
slot->setContentPaneAutoSized(false);
slot->setWindowSize(UVector2(cegui_reldim(0.6f), cegui_reldim(0.6f)));
slot->setVisible(true);
slot->setContentPaneArea(
CEGUI::Rect(CEGUI::Point(0.0f, 0.00f),
CEGUI::Size(slot->getAbsoluteWidth()*2,
slot->getAbsoluteHeight()*2)));
const Window * constwin = slot->getContentPane();
const String name = constwin->getName();
Window* content = WindowManager::getSingleton().getWindow(name);
content->subscribeEvent(Window::EventDragDropItemEnters, &handleDragEnter);
content->subscribeEvent(Window::EventDragDropItemLeaves, &handleDragLeave);
content->subscribeEvent(Window::EventDragDropItemDropped, &handleBigDragDropped);
and I drop StaticImages in with this:
Code: Select all
int t,numkids;
float x,y;
const DragDropEventArgs& ddea = static_cast<const DragDropEventArgs&>(args);
ddea.dragDropItem->setSize(Size(0.5f,0.5f));
ddea.window->addChildWindow(ddea.dragDropItem);
numkids =ddea.window->getChildCount();
Window* child= NULL;
for(t=0;t<numkids;t++){
child=ddea.window->getChildAtIdx(t);
if(child==NULL) break;
x=t*50.0f;
y=0.0f;
child->setPosition(Absolute, Point(x,y));
}
Any idea what I'm doing wrong?
Thanks in advance.
