ItemSlotUI ​
Inherits: Control
Fully Unified Slot UI - handles ALL slot types (inventory, equipment, vendor) No need for separate InventorySlotUI, EquipmentSlotUI, etc.
Variables ​
SlotInstance | slot_data | |
SlotVisualState | current_visual_state | SlotVisualState.EMPTY |
bool | allow_drag | true |
bool | allow_drop | true |
bool | allow_right_click_use | true |
bool | drag_enabled | true |
bool | interaction_enabled | true |
Color | default_color | Color(0.25, 0.25, 0.25) |
Color | locked_color | Color(0.1, 0.1, 0.1, 0.8) |
Color | hover_color | Color(1.2, 1.2, 1.2, 1.0) |
float | last_click_time | 0.0 |
float | double_click_threshold | 0.3 |
bool | needs_display_update | false |
String | slot_type | "inventory" |
String | group_name | "" |
bool | is_showing_cooldown | false |
EquipmentSlotDefinition | equipment_slot_definition | |
int | slot_instance_index | 0 |
Methods ​
void | set_slot_type( type: String ) |
void | setup_for_equipment_slot( slot_def: EquipmentSlotDefinition, instance_index: int = 0 ) |
void | set_drag_enabled( enabled: bool ) |
void | set_slot_data( new_slot_data: SlotInstance ) |
void | update_display() |
void | set_visual_state( new_state: SlotVisualState ) |
bool | should_show_quantity() |
ItemInstance | get_equipped_item_instance() |
EquipmentSlotDefinition | get_equipment_slot_definition() |
bool | is_slot_empty() |
bool | is_slot_locked() |
ItemInstance | get_item_instance() |
int | get_quantity() |
bool | has_item() |
SlotInstance | get_slot_data() |
void | set_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.