Init
This commit is contained in:
33
scripts/production/ResourceGrid.cs
Normal file
33
scripts/production/ResourceGrid.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class ResourceGrid : GridContainer
|
||||
{
|
||||
[Export]
|
||||
public PackedScene ItemPanelScene;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
// 获取基础资源分类的所有物品
|
||||
var items = ResourceCategoryManager.Instance.GetItemsByCategory("基础资源");
|
||||
|
||||
foreach (var item in items.Values)
|
||||
{
|
||||
var panel = (Panel)ItemPanelScene.Instantiate();
|
||||
|
||||
// 设置图标为白色底色
|
||||
var icon = panel.GetNode<TextureRect>("HBoxContainer/Icon");
|
||||
icon.Texture = null;
|
||||
icon.Modulate = new Color(1, 1, 1, 1); // 白色
|
||||
|
||||
// 设置名称
|
||||
var nameLabel = panel.GetNode<Label>("HBoxContainer/VBoxContainer/TopRow/NameLabel");
|
||||
nameLabel.Text = item.Name;
|
||||
|
||||
// 其余内容可根据需要设置
|
||||
// ...
|
||||
|
||||
AddChild(panel);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user