I am working on a grid inventory system using Blueprint and UMG; unfortunately I’ve run into a problem setting the location of a Widget which shows an image of the stored objects
The set up so far is thus;
I have a **InventoryScreen **Widget which sets up the general view. It has controls like transfer all and close etc; it also has two sockets for **InventoryGrid **Widgets. Two of these are spawned, each relating to world objects (the player, a box, the ground etc)
The **InventoryGrid **Widget Itself contains several bits of information such as name and weight info. It also has a UniformGrid Panel; in it into which I spawn and place a number of InventoryCell widgets creating a grid of the required size. The InventoryCell widget is just a sizebox, an image, and some state data.
I have wrapped a vertical scroll box around the uniform grid and locked it to a fixed size with a sizebox. ‘Filled’ cells are being rendered with a different texture atm so I can tell where things are. This may stay but I’m not sure yet.
Each inventory has a Vector2d/Actor Map which denotes the location of each stored object in the grid, based from the top left. For objects bigger than 1x1 I do a series of lookups to determine where objects can and can’t be placed depending on what cells are filled or not.
The result is this:
My aim is to allow the player to drag and drop objects between inventory grids, and update the inventory data on a drop. For that I need an image for each stored object placed on top of the correct grid cells. Sadly this has proved extremely difficult.
So far, along other things, I’ve tried using both GetCachedGeometry based on the cell, along with various methods of adding a canvas widget and using GetPosition on that with no luck. While I think one of these methods is probably the right direction I can’t seem to get it to work. Either the widget doesn’t respond to being set, or it doesn’t grab the correct data.
Things I have thus far tried, and discounted due to limitations;
- Adding the image directly to the InventoryCell widget - Works as long as all objects are 1x1, which they are not. Makes drag and drop tricky as each object image should be it’s own widget (in theory?)
- Adding the image to the **InventoryGrid **UniformGrid as an overlap to the same grid location. Again works as long as all objects are 1x1. Results in a misshapen grid.
Anyone got any advice here? I’m sure I’ve missed some information but frankly I’ve been staring at this for hours and my brain is melting atm.