Inventory Grid Widgets with Items that span more than one space
I am trying to do an inventory grid system that allows me to represent items within more than one grid square, i.e. it could occupy multiple grid squares. At the moment I have a simple system with one widget that represents each inventory slot (it has a variable for a texture) and then a widget for the inventory as a whole that basically creates a load of the slot widgets and then uses the players array of items (structs with parameters for name and the inventory texture etc). However, this approach only lets me have each item as a single grid square, as the items texture is essentially set as the image in the grid square.
I am trying to setup a grid for the inventory (lets say 8*4) and then each item could be a different size (1*2 or 2*2) and then these are represented within the grid.
Obviously the grid itself needs to be a matrix of some kind, and I figured that in the struct for the item I would store int values for width and height and also an array of int's to store which slots it occupies in the inventory grid.
However, I am a bit lost in terms of how to represent the inventory within the actual widgets, because the individual slots with an item texture wont work.
Any help/advice would be greatly appreciated.
I'd imagine you could have bigger items occupy more inventory slots, even in a single slot inventory.
For example, a 2x2 hat could occupy 4 single slots in your array inventory system. The default texture size for this 2x2 hat would then also be 2x2, taking 4 spaces but representing one item.
answered Jul 03 '16 at 10:02 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here