Projectiles+

This commit is contained in:
dingo
2026-01-18 20:45:48 -05:00
parent 32fb57fa75
commit 718a8ecb3b
14 changed files with 455 additions and 19 deletions
+55 -9
View File
@@ -5,17 +5,36 @@ extends CanvasLayer
@onready var inventory_grid = $PanelContainer/VBoxContainer/Content/BagSection/InventoryGrid
@onready var gold_label = $PanelContainer/VBoxContainer/Footer/GoldLabel
const EQUIPMENT_SLOTS = ["weapon", "offhand", "helm", "chest", "gloves", "legs", "boots", "ring1", "ring2"]
const EQUIPMENT_SLOTS = ["weapon", "offhand", "helm", "chest", "gloves", "legs", "boots", "necklace", "ring1", "ring2", "quiver"]
# Emoji fallbacks for equipment slots (used when CDN texture not available)
const EQUIPMENT_ICONS = {
"weapon": "⚔️",
"offhand": "🛡️",
"offhand": "🛡️",
"helm": "🎩",
"chest": "👕",
"gloves": "🧤",
"legs": "👖",
"boots": "👢",
"necklace": "📿",
"ring1": "💍",
"ring2": "💍"
"ring2": "💍",
"quiver": "🏹"
}
# CDN paths for equipment slot background icons
const EQUIPMENT_SLOT_TEXTURES = {
"weapon": "textures/ui/slots/mainhand.png",
"offhand": "textures/ui/slots/offhand.png",
"helm": "textures/ui/slots/head.png",
"chest": "textures/ui/slots/chest.png",
"gloves": "textures/ui/slots/gloves.png",
"legs": "textures/ui/slots/legs.png",
"boots": "textures/ui/slots/boots.png",
"necklace": "textures/ui/slots/neck.png",
"ring1": "textures/ui/slots/ring.png",
"ring2": "textures/ui/slots/ring.png",
"quiver": "textures/ui/slots/back.png"
}
const RARITY_COLORS = {
@@ -165,18 +184,39 @@ func _refresh_inventory():
for slot_name in EQUIPMENT_SLOTS:
if equipment_slots.has(slot_name):
var item = GameState.equipment.get(slot_name)
_update_slot(equipment_slots[slot_name], item, EQUIPMENT_ICONS.get(slot_name, "?"))
_update_slot(equipment_slots[slot_name], item, EQUIPMENT_ICONS.get(slot_name, "?"), slot_name)
func _update_slot(slot: Button, item, default_text: String = ""):
func _update_slot(slot: Button, item, default_text: String = "", slot_name: String = ""):
# Clear any existing children (sprites, labels)
for child in slot.get_children():
child.queue_free()
if item == null or (item is Dictionary and item.is_empty()):
slot.text = default_text
# Empty slot: try to load CDN slot texture, fall back to emoji
slot.set_meta("item", null)
slot.add_theme_stylebox_override("normal", _create_slot_style(Color(0.15, 0.15, 0.2)))
# Try to load slot icon from CDN if this is an equipment slot
if slot_name != "" and EQUIPMENT_SLOT_TEXTURES.has(slot_name) and UpdateManager:
var slot_texture_path = EQUIPMENT_SLOT_TEXTURES.get(slot_name)
var texture = UpdateManager.load_texture(slot_texture_path)
if texture:
var sprite = TextureRect.new()
sprite.texture = texture
sprite.expand_mode = TextureRect.EXPAND_FIT_WIDTH_PROPORTIONAL
sprite.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
sprite.custom_minimum_size = Vector2(32, 32)
sprite.anchors_preset = Control.PRESET_CENTER
sprite.position = Vector2(8, 8) # Center in 48x48 slot
sprite.modulate = Color(1, 1, 1, 0.3) # Dim the slot icon to show it's empty
slot.add_child(sprite)
slot.text = "" # Clear emoji text since we have a texture
return
# Fall back to emoji if CDN texture not available
slot.text = default_text
else:
# Equipped item: show the item's sprite, NOT the slot icon
slot.text = "" # Clear text, we'll use sprite instead
slot.set_meta("item", item)
@@ -207,9 +247,15 @@ func _update_slot(slot: Button, item, default_text: String = ""):
if not has_sprite:
slot.text = _get_item_emoji(item)
# Add stack count label if quantity > 1
# Add stack count label if quantity > 1 OR if this is equipped ammunition/quiver
var quantity = item.get("quantity", item.get("Quantity", 1))
if quantity > 1:
var show_count = quantity > 1
# Always show count for equipped quiver or ammunition slots
if slot_name == "quiver" and quantity >= 1:
show_count = true
if show_count:
var count_label = Label.new()
count_label.text = str(quantity)
count_label.add_theme_font_size_override("font_size", 10)