feat: implement InventoryBackpack FSM and InventoryOverlay

- InventoryBackpack: Control-based FSM with IDLE/OPEN/SELECTED/ACQUIRE/REMOVE
  states, Tween-based animations, guard condition checks, signal connections
  to InventoryManager for item_acquired/item_removed reactions
- InventoryOverlay: Full-screen overlay with fade-in/out, item grid via
  GridContainer, drag-and-drop item selection, combination via drag-to-slot,
  hover labels, right-click inspect
- InventorySlot: Individual slot with colored box placeholder, hover highlight,
  click/right-click/hover signals
This commit is contained in:
2026-04-26 21:09:50 -07:00
parent dee6216873
commit afcf92dbfd
12 changed files with 629 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
extends Control
class_name InventorySlot
signal clicked(item_id: String)
signal right_clicked(item_id: String)
signal hovered(item_id: String)
signal unhovered(item_id: String)
var item_id: String = ""
var is_hovered: bool = false
@onready var item_box: ColorRect = $ItemBox
@onready var hover_highlight: ColorRect = $HoverHighlight
func _ready() -> void:
hover_highlight.visible = false
func set_item(item_def: ItemDefinition) -> void:
item_id = item_def.id
item_box.color = Color(1, 0.6, 0.2, 1)
func set_item_color(color: Color) -> void:
item_box.color = color
func set_hover(hovered: bool) -> void:
is_hovered = hovered
hover_highlight.visible = hovered
if hovered:
item_box.color = item_box.color.lightened(0.2)
else:
var def = InventoryManager.get_item_definition(item_id)
if def:
item_box.color = Color(1, 0.6, 0.2, 1)
else:
item_box.color = Color(0.8, 0.8, 0.8, 1)
func _gui_input(event: InputEvent) -> void:
if event is InputEventMouseButton:
if event.button_index == 1 and event.pressed:
clicked.emit(item_id)
elif event.button_index == 2:
right_clicked.emit(item_id)
func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
var rect = get_global_rect()
var mouse_pos = get_global_mouse_position()
var was_hovered = is_hovered
is_hovered = rect.has_point(mouse_pos)
if is_hovered != was_hovered:
set_hover(is_hovered)
if is_hovered:
hovered.emit(item_id)
else:
unhovered.emit(item_id)