Crafting v2

This commit is contained in:
dingo
2025-12-23 13:41:30 -05:00
parent 6a4a64e39e
commit 2a5f4b9b78
10 changed files with 1091 additions and 17 deletions
+50
View File
@@ -37,6 +37,18 @@ func _connect_gamestate():
GameState.inventory_updated.connect(_update_hotbar)
GameState.dungeon_entered.connect(_on_dungeon_entered)
GameState.loot_received.connect(_on_loot_received)
if UpdateManager:
UpdateManager.file_downloaded.connect(_on_file_downloaded)
UpdateManager.update_completed.connect(_on_updates_completed)
func _on_file_downloaded(file_path: String):
# If an item texture was downloaded, refresh hotbar to show it
if file_path.begins_with("textures/items/"):
_update_hotbar()
func _on_updates_completed(_count: int):
# Refresh hotbar after all updates complete
_update_hotbar()
func _on_dungeon_entered():
_generate_minimap()
@@ -49,6 +61,7 @@ func _setup_hotbar():
var slot = Button.new()
slot.custom_minimum_size = Vector2(48, 48)
slot.text = str(i + 1)
slot.set_meta("hotbar_slot", i)
var style = StyleBoxFlat.new()
style.bg_color = Color(0.15, 0.15, 0.2, 0.9)
@@ -58,8 +71,45 @@ func _setup_hotbar():
slot.add_theme_stylebox_override("normal", style)
slot.pressed.connect(_on_hotbar_pressed.bind(i))
slot.gui_input.connect(_on_hotbar_slot_input.bind(i))
hotbar_container.add_child(slot)
hotbar_slots.append(slot)
# Connect to DragManager for drops
if DragManager:
DragManager.item_dropped.connect(_on_item_dropped)
func _on_hotbar_slot_input(event: InputEvent, slot_index: int):
if not event is InputEventMouseButton:
return
# Check if dropping from DragManager
if event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
if DragManager and DragManager.is_dragging:
DragManager.drop_on("hotbar", slot_index)
# Right click to clear hotbar slot
elif event.button_index == MOUSE_BUTTON_RIGHT and event.pressed:
GameState.assign_hotbar(slot_index, -1) # -1 to clear
_update_hotbar()
func _on_item_dropped(data: Dictionary, target_type: String, target_slot: int):
if target_type != "hotbar":
return
var item = data.get("item", {})
var source_slot = data.get("source_slot", -1)
# Only consumables can go in hotbar
var item_type = item.get("type", item.get("Type", ""))
if item_type != "Consumable":
print("Only consumables can be assigned to hotbar")
return
if source_slot >= 0:
GameState.assign_hotbar(target_slot, source_slot)
_update_hotbar()
print("Assigned inventory slot %d to hotbar slot %d" % [source_slot, target_slot])
func _setup_minimap():
minimap_image = Image.create(MINIMAP_SIZE, MINIMAP_SIZE, false, Image.FORMAT_RGBA8)