peter-kish / gloot

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

`CtrlInventoryGridEx` Missing signals; Lack of parity #198

Closed QueenOfSquiggles closed 4 months ago

QueenOfSquiggles commented 4 months ago

It looks like the code might be a bit off (unless I'm misunderstanding which is entirely possible). CtrlInventoryGridEx doesn't have signals such as selection_changed like the documentation would suggest.

@tool
@icon("res://addons/gloot/images/icon_ctrl_inventory_grid.svg")
class_name CtrlInventoryGridEx
extends Control

signal item_mouse_entered(item)
signal item_mouse_exited(item)

const Verify = preload("res://addons/gloot/core/verify.gd")
const CtrlInventoryGridBasic = preload("res://addons/gloot/ui/ctrl_inventory_grid_basic.gd")
const CtrlDragable = preload("res://addons/gloot/ui/ctrl_dragable.gd")

I am really loving the customizeability of this plugin, but I would definitely want as much parity between -Ex and non-Ex nodes as possible (without watering down the reason they are separated in the first place).

QueenOfSquiggles commented 4 months ago

Having taken a deeper look into the code, I really admire the design of this. I really like using a common script for handling common features. I've figured out this less-than-ergonomic workaround for v2.4.7

@onready var inv := %InventoryGuiDisplay

# Load type for accessing signals
const CtrlInventoryGridBasic = preload("res://addons/gloot/ui/ctrl_inventory_grid_basic.gd")

func _ready() -> void:
  await RenderingServer.frame_post_draw # needed only because this script readys before the inventory grid
  var basic: CtrlInventoryGridBasic = inv._ctrl_inventory_grid_basic # technically accessing a private field
  basic.selection_changed.connect(_on_selection) # connecting signals works as normal
peter-kish commented 4 months ago

Hi! The missing signals have been fixed in the meantime, it's just that the fix is not part of the 2.4.7 release. It will be included in 2.4.8, but you can also just take the latest changes from the master brach.

QueenOfSquiggles commented 4 months ago

That's good to hear. I'll switch to the latest commit version ❤️