class_name GameMenuItemsTab extends Control

func refresh() -> void:
  var container = $ScrollContainer/ItemContainer
  for child in container.get_children():
    child.queue_free()

  var items = PARTY.BACKPACK.items
  if items.is_empty():
    var empty = Label.new()
    empty.text = "No items."
    container.add_child(empty)
    return

  for stack in items:
    container.add_child(_makeItemRow(stack))

func _makeItemRow(stack:ItemStack) -> Control:
  var panel = PanelContainer.new()
  var hbox = HBoxContainer.new()
  panel.add_child(hbox)

  var nameLabel = Label.new()
  nameLabel.text = Item.getItemHandle(stack.item).capitalize()
  nameLabel.size_flags_horizontal = Control.SIZE_EXPAND_FILL
  hbox.add_child(nameLabel)

  var qtyLabel = Label.new()
  qtyLabel.text = "x%d" % stack.quantity
  hbox.add_child(qtyLabel)

  return panel
