working on items and inventory

This commit is contained in:
2023-02-08 22:55:54 -05:00
parent 836a0e4a93
commit 03402abb6c
24 changed files with 617 additions and 117 deletions

View File

@@ -5,13 +5,17 @@ extends Control
@onready var ammo_label := $AmmoLabel
@onready var image_slot := $ItemImage
@onready var reload_bar := $ReloadBar
@onready var item_selecter := $ItemSelector
@onready var toolbar_slot := $ToolbarSlot
@rpc("call_local")
func slot_selected():
item_selecter.set_visible(true)
toolbar_slot.set_modulate(Color("4f58d8"))
slot_label.show()
@rpc("call_local")
func slot_deselected():
item_selecter.set_visible(false)
toolbar_slot.set_modulate(Color("ffffff"))
slot_label.hide()
func reload_item(cooldown: float):
reload_bar.set_visible(true)
@@ -24,24 +28,26 @@ func reload_item(cooldown: float):
func clear_slot():
image_slot.set_texture(null)
slot_label.set_text("")
ammo_label.set_text("")
ammo_label.set_visible(false)
func setup_slot(item_details: Dictionary):
clear_slot()
slot_label.set_text(item_details.item_name)
var picNode = TextureRect.new()
image_slot.add_child(picNode)
picNode.set_mouse_filter(2)
#picNode.set_mouse_filter(2)
picNode.set_name("inv_texture")
picNode.set_texture(item_details.item_texture)
picNode.set_stretch_mode(TextureRect.STRETCH_KEEP)
picNode.size = Vector2(16, 16)
picNode.position = Vector2(-8, -8)
picNode.set_anchors_preset(Control.PRESET_BOTTOM_WIDE)
picNode.set_anchors_preset(Control.PRESET_FULL_RECT)
# picNode.set_stretch_mode(TextureRect.STRETCH_KEEP)
picNode.size = Vector2(64, 64)
picNode.position = Vector2(-32, -32)
if item_details.item_type == 0: # is weapon
set_ammo_label(str(item_details.item_ammo))
func set_slot_label(slot_index: String):
slot_label.set_text(slot_index)
func set_ammo_label(ammo_value: String):
ammo_label.set_visible(true)