peter-kish / gloot

A universal inventory system for the Godot game engine.
MIT License
561 stars 20 forks source link

The size of an item dragged from an `CtrlItemSlot` is not the same as when dragged from an `CtrlInventoryGrid` #176

Closed peter-kish closed 6 months ago

peter-kish commented 6 months ago

When dragging your item from slot to slot, or back to the inventory grid I think the size of the item should be what is set (width and height) in the protoset (.i.e the same as when dragging item from the inventory grid).

(Original issue: https://github.com/peter-kish/gloot/issues/167)

peter-kish commented 6 months ago

Yeah, the dragged item sizes are a bit messed up, and should mostly be fixed in 2.4.4.

But making them always have the same size is not really possible because their global size (in pixels) depends on the field_dimensions of a CtrlInventoryGrid or on the size of a CtrlItemSlot.

E.g. you could have two CtrlInventoryGrid nodes with different field_dimensions and thus the size of the dragged item will depend on which CtrlInventoryGrid you are dragging it from.

But what I can do is to introduce field_dimentions to CtrlItemSlot and make it work similar to CtrlInventoryGrid. Then the size of the slot would depend in the item size (from the protoset) and the field dimensions (which could make the icon behavior modes obsolete).

LeeWannacott commented 6 months ago

But what I can do is to introduce field_dimentions to CtrlItemSlot and make it work similar to CtrlInventoryGrid. Then the size of the slot would depend in the item size (from the protoset) and the field dimensions (which could make the icon behavior modes obsolete).

You could do that, however I think what you have done is good (provided you don't want to do the extra work to make that happen). Because now I can just calculate the slot sizes as multiples of a single cells height and width in the inventoryGrid and it should be roughly the same...

peter-kish commented 6 months ago

Alright, then I'm closing this for now. I'll reconsider introducing CtrlItemSlot.field_dimensions in v3.0 (right now I'm mostly focusing on making v2.x more stable).

LeeWannacott commented 6 months ago

@peter-kish After more thought:

Then the size of the slot would depend in the item size (from the protoset) and the field dimensions (which could make the icon behavior modes obsolete).

Nah, I wouldn't do this (item should still scale its image to the size of the slot; icon scaling is not in vain). Just use the field dimension for the size whilst dragging away from the slot (maybe with a more descriptive name). So basically field dimensions x width and height of the item in protoset with some sort of fall through if width and height are missing.

Field dimensions whilst dragging would be useful for the case in which you have differently sized weapons for example a one handed might be 1wx3h and two handed might be 2wx3h and shield might be 4x4. Where as you wouldn't want the slot size changing based on the item size, but while dragging you would want to match size when dragging from InventoryGrid.

the size of the dragged item will depend on which CtrlInventoryGrid you are dragging it from.

True, however I think its unlikely someone would have differently sized InventoryGrids. But, yeah set the field dimension on the slot is probably the wiser way to do it...

(right now I'm mostly focusing on making v2.x more stable).

Yeah, stability is probably more important. maybe reopen this issue or make a different issue and slap it with low priority. It would be a nice to have eventually.

Cheers.