using ColdMint.scripts.inventory;
using Godot;
namespace ColdMint.scripts.loader.uiLoader;
///
/// Backpack UI
/// 背包UI
///
public partial class PacksackUi : UiLoaderTemplate
{
private IItemContainer? _itemContainer;
private PackedScene? _packedScene;
private HFlowContainer? _hFlowContainer;
private Label? _titleLabel;
private string? _title;
private Button? _exitButton;
private IItemContainerDisplay? _itemContainerDisplay;
///
/// title
/// 标题
///
public string? Title
{
get => _title;
set
{
_title = value;
SetTile(value);
}
}
///
/// Packsack
/// 背包
///
public IItemContainer? ItemContainer
{
get => _itemContainer;
set
{
_itemContainer = value;
BindItemContainer();
}
}
///
/// SetTile
/// 设置标题
///
///
private void SetTile(string? title)
{
if (_titleLabel == null)
{
return;
}
_titleLabel.Text = title;
}
public override void InitializeData()
{
_packedScene = ResourceLoader.Load("res://prefab/ui/ItemSlot.tscn");
}
private void BindItemContainer()
{
if (ItemContainer == null)
{
return;
}
_itemContainerDisplay?.BindItemContainer(ItemContainer);
}
public override void InitializeUi()
{
_hFlowContainer = GetNode("HFlowContainer");
_titleLabel = GetNode