45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
using Godot;
|
|
using System;
|
|
namespace Cosmobox
|
|
{
|
|
public partial class BagItemUI : Button
|
|
{
|
|
[Export] public TextureRect icon;
|
|
[Export] public Label count, itemName;
|
|
[Export] public Control itemNamePanel;
|
|
[Export] public Texture2D emptyIcon;
|
|
|
|
public override void _Ready()
|
|
{
|
|
itemNamePanel.Visible = false;
|
|
}
|
|
|
|
public void SetItem(BagItem bagItem)
|
|
{
|
|
if (bagItem == null || bagItem.itemResource == null)
|
|
{
|
|
SetEmpty();
|
|
return;
|
|
}
|
|
itemName.Text = bagItem.itemResource.ItemName;
|
|
icon.Texture = bagItem.itemResource.Icon ?? emptyIcon;
|
|
count.Text = bagItem.amount > 0 ? bagItem.amount.ToString() : "空";
|
|
}
|
|
|
|
public void SetEmpty()
|
|
{
|
|
icon.Texture = emptyIcon;
|
|
count.Text = "空";
|
|
}
|
|
void _on_mouse_entered()
|
|
{
|
|
itemNamePanel.Visible = true;
|
|
// GD.Print("鼠标进入");
|
|
}
|
|
void _on_mouse_exited()
|
|
{
|
|
itemNamePanel.Visible = false;
|
|
}
|
|
}
|
|
|
|
} |