66 lines
1.3 KiB
C#
66 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using Godot;
|
|
using Learn.Models;
|
|
|
|
namespace Learn.Inspector;
|
|
|
|
public partial class ParsedInfoPanel : Tree
|
|
{
|
|
private TreeNode _node;
|
|
|
|
#region Columns Definitions
|
|
private const int NotesColumn = 0;
|
|
private const int KeyColumn = 1;
|
|
private const int ValueColumn = 2;
|
|
#endregion
|
|
|
|
public override void _Ready()
|
|
{
|
|
Columns = 3;
|
|
SetColumnTitlesVisible(true);
|
|
|
|
SetColumnTitle(NotesColumn, "备注");
|
|
SetColumnCustomMinimumWidth(NotesColumn, 80);
|
|
SetColumnExpand(NotesColumn, false);
|
|
|
|
SetColumnTitle(KeyColumn, "键");
|
|
SetColumnCustomMinimumWidth(KeyColumn, 100);
|
|
SetColumnExpand(KeyColumn, false);
|
|
|
|
SetColumnTitle(ValueColumn, "值");
|
|
SetColumnExpand(ValueColumn, true);
|
|
}
|
|
|
|
public void SetNode(TreeNode node)
|
|
{
|
|
_node = node;
|
|
OnNodeChanged();
|
|
}
|
|
|
|
public void OnNodeChanged()
|
|
{
|
|
Clear();
|
|
if (_node == null) return;
|
|
|
|
var root = CreateItem();
|
|
var keys = new HashSet<string>();
|
|
var curr = _node;
|
|
|
|
while (curr != null)
|
|
{
|
|
foreach (var kv in curr.Info.Info)
|
|
{
|
|
if(!keys.Add(kv.Key)) continue;
|
|
var node = CreateItem(root);
|
|
if (curr != _node)
|
|
{
|
|
node.SetText(NotesColumn, "(继承)");
|
|
}
|
|
node.SetText(KeyColumn, kv.Key);
|
|
node.SetText(ValueColumn, kv.Value);
|
|
}
|
|
curr = curr.Parent;
|
|
}
|
|
}
|
|
|
|
} |