17-03-2009 18:18:11

From what I can see there is a class ItemBox in the namespace MyGUI. However the demo uses a framework from the wraps namespace. So is MyGUI::ItemBox useless without the "wraps framework" ? Or maybe is there any example how to use it without wraps ?


19-03-2009 18:45:49

Ok got something working, but now is another question:
Can I use non square images ?

works fine for my 20x20 or 60x60 images, by changing:
cellview.layout to <?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="Widget" skin="Default" position="0 0 20 20" align="Stretch" name="_Main">
<Property key="Widget_NeedMouse" value="false"/>
<Property key="Widget_NeedKey" value="false"/>
<Widget type="StaticImage" skin="Demo_StaticImage" position="0 0 20 20" align="Stretch" name="image_Back">
<Widget type="StaticImage" skin="Demo_StaticImage" position="0 0 20 20" align="Stretch" name="image_Border">
<Widget type="StaticImage" skin="Demo_StaticImage" position="0 0 20 20" align="Stretch" name="image_Item">
<Widget type="StaticText" skin="StaticText" position="0 0 18 18" align="Stretch" name="text_Back">
<Property key="Widget_AlignText" value="Right Bottom"/>
<Property key="Widget_Colour" value="0 0 0"/>
<Widget type="StaticText" skin="StaticText" position="0 0 17 17" align="Stretch" name="text_Front">
<Property key="Widget_AlignText" value="Right Bottom"/>
<Property key="Widget_Colour" value="1 1 1"/>
or 60x60

and the function getCellDimensionstatic void getCellDimension(MyGUI::WidgetPtr _sender, MyGUI::IntCoord & _coord, bool _drop)
if (_drop) _coord.set(0, 0, 20, 20);
else _coord.set(0, 0, 20, 20);
or 60x60

but when I try to get 60x80 or 60x20 then the image is scaled and trimmed in a weired way I don't understand.

The resource image has the size of 60x80. How should I set up the getCellDimension function, and cellview.layout ?
Also is it possible to add some spacing between the 2 rows of items at the bottom ?


19-03-2009 20:09:35

Ok. Got it working. ItemBoxV behaves much better than ItemBoxH...
Another question: How do I dissable image stretching ? mImageItem->setAlign(MyGUI::Align::Center); Doesn't work. Same thing goes for the cellview.layout align="Center" Still get's scaled / stretched

19-03-2009 22:30:10



20-03-2009 00:20:50

Does not work. To demonstrate:

The item has a circle shape:

After draging the item to the bigger slot ...

The item has an elipse shape:

The best thing I would like to achieve is to enable only proportional downscale (when a larger armor/weapon/shield item gets into the smaller "bag"), else show the oryginal size (for example a ring should be small in the "bag").
If this is impossible, then I would like all the items have their oryginal size. (the issue would be a cropped image of larger items in the bag, but I can live with that)


20-03-2009 00:58:26

Very interesting! I wonder if this is a good design, allowing large images to be cropped and small ones to take up a lot of space. (ie a ring would look so tiny in the bigger boxes at the bottom, and a big shield would hardly be visible inside the ring slot) I think not stretching the image is probably the right thing to do, was just wondering how you decided on your drag n drop system. (vs Diablo style one, for example)


20-03-2009 07:02:05

Dropping a shield into a ring item slot will not be allowed. Oh and Baldurs Gate had this 1 slot per item inventory style - just every item had the same size. Maybe I could make 4 small items (rings, amu, potions, etc) fit into one bag slot ?


20-03-2009 12:04:11

Actually you should do one of the following things: 1) make smaller/not squared copy of your image for rings/shields or
2) all images have different sizes (ring is small, shield is not square) and just make all item box items not so simple: make StaticImage that have size == size of picture and put this StaticImage in center of Item widget.