Skip to content

ItemSlotUI ​

Inherits: Control

Fully Unified Slot UI - handles ALL slot types (inventory, equipment, vendor) No need for separate InventorySlotUI, EquipmentSlotUI, etc.

Variables ​

SlotInstanceslot_data
SlotVisualStatecurrent_visual_stateSlotVisualState.EMPTY
boolallow_dragtrue
boolallow_droptrue
boolallow_right_click_usetrue
booldrag_enabledtrue
boolinteraction_enabledtrue
Colordefault_colorColor(0.25, 0.25, 0.25)
Colorlocked_colorColor(0.1, 0.1, 0.1, 0.8)
Colorhover_colorColor(1.2, 1.2, 1.2, 1.0)
floatlast_click_time0.0
floatdouble_click_threshold0.3
boolneeds_display_updatefalse
Stringslot_type"inventory"
Stringgroup_name""
boolis_showing_cooldownfalse
EquipmentSlotDefinitionequipment_slot_definition
intslot_instance_index0

Methods ​

voidset_slot_type( type: String )
voidsetup_for_equipment_slot( slot_def: EquipmentSlotDefinition, instance_index: int = 0 )
voidset_drag_enabled( enabled: bool )
voidset_slot_data( new_slot_data: SlotInstance )
voidupdate_display()
voidset_visual_state( new_state: SlotVisualState )
boolshould_show_quantity()
ItemInstanceget_equipped_item_instance()
EquipmentSlotDefinitionget_equipment_slot_definition()
boolis_slot_empty()
boolis_slot_locked()
ItemInstanceget_item_instance()
intget_quantity()
boolhas_item()
SlotInstanceget_slot_data()
voidset_interaction_permissions( drag: bool, drop: bool, right_click: bool )

Signals ​

item_right_clicked( slot: ItemSlotUI ) ​

Emitted when the slot is right clicked.

item_left_clicked( slot: ItemSlotUI ) ​

Emitted when the slot is left clicked.

item_double_clicked( slot: ItemSlotUI ) ​

Emitted when the slot is double clicked.

item_hovered( slot: ItemSlotUI, is_hovering: bool ) ​

Emitted when the mouse enters or leaves the slot.

socket_panel_requested( equipment_item: ItemInstance, slot: ItemSlotUI ) ​

Emitted to open the socket window of the item in the slot.

drag_requested( item: ItemInstance, quantity: int, slot_data: SlotInstance, slot_type: String ) ​

========== DRAG SIGNALS ==========

split_drag_requested( item: ItemInstance, split_amount: int, slot_data: SlotInstance, slot_type: String ) ​

Asks the interface to start dragging part of a stack.

Enumerations ​

enum SlotVisualState ​

The options of slot visual state: empty, occupied, locked, hover, dragging, disabled.

  • EMPTY = 0
  • OCCUPIED = 1
  • LOCKED = 2
  • HOVER = 3
  • DRAGGING = 4
  • DISABLED = 5

Variable descriptions ​

SlotInstance slot_data ​

The slot the control shows (an inventory slot or an equipment slot).

SlotVisualState current_visual_state = SlotVisualState.EMPTY ​

How the slot looks now (empty, filled, locked, hovered ...).

bool allow_drag = true ​

Enhanced interaction controls

bool allow_drop = true ​

True when items can be dropped on the slot.

bool allow_right_click_use = true ​

True when a right click uses the item.

bool drag_enabled = true ​

True when the item can be dragged out.

bool interaction_enabled = true ​

True when the slot reacts to the mouse.

Color default_color = Color(0.25, 0.25, 0.25) ​

Visual colors

Color locked_color = Color(0.1, 0.1, 0.1, 0.8) ​

The color of a locked slot.

Color hover_color = Color(1.2, 1.2, 1.2, 1.0) ​

The color of the slot under the mouse.

float last_click_time = 0.0 ​

Double-click detection

float double_click_threshold = 0.3 ​

The most seconds between two clicks of a double click.

bool needs_display_update = false ​

Fix for display update timing

String slot_type = "inventory" ​

Slot type configuration

String group_name = "" ​

The group of the slot (for the layout).

bool is_showing_cooldown = false ​

Cooldown tracking

EquipmentSlotDefinition equipment_slot_definition ​

The equipment slot the control stands for.

int slot_instance_index = 0 ​

Which of the slots of this kind it is (an entity can have several).

Method descriptions ​

void set_slot_type( type: String ) ​

Set the slot type (affects grouping and default behavior)

void setup_for_equipment_slot( slot_def: EquipmentSlotDefinition, instance_index: int = 0 ) ​

Setup equipment slot with definition (replaces EquipmentSlotUI.setup_for_slot_definition)

void set_drag_enabled( enabled: bool ) ​

Enable or disable drag functionality

void set_slot_data( new_slot_data: SlotInstance ) ​

Shows another slot (the control follows its changes).

void update_display() ​

Draws the item, the quantity and the state again.

void set_visual_state( new_state: SlotVisualState ) ​

Sets how the slot looks.

bool should_show_quantity() ​

Does the slot show a quantity (equipment slots do not)?

ItemInstance get_equipped_item_instance() ​

The item in the slot.

EquipmentSlotDefinition get_equipment_slot_definition() ​

The equipment slot the control stands for.

bool is_slot_empty() ​

Is the slot empty?

bool is_slot_locked() ​

Is the slot locked?

ItemInstance get_item_instance() ​

The item in the slot, or null.

int get_quantity() ​

How many items are in the slot.

bool has_item() ​

Does the slot hold an item?

SlotInstance get_slot_data() ​

The slot the control shows.

void set_interaction_permissions( drag: bool, drop: bool, right_click: bool ) ​

Sets whether the item can be dragged, dropped on, and used with a right click.