initial commit

This commit is contained in:
2026-08-05 14:45:08 -05:00
commit 08cae96a16
747 changed files with 10169 additions and 0 deletions
+97
View File
@@ -0,0 +1,97 @@
using Godot;
using System;
using System.Collections.Generic;
public partial class FileTree : Tree
{
public FileBar bar;
public Dictionary<string, string> icons = new Dictionary<string, string>
{
};
public override void _Ready()
{
HideRoot = false;
Columns = 1;
ItemSelected += OnItemClicked;
}
public override void _Process(double delta)
{
}
public void OnItemClicked()
{
TreeItem selectedItem = GetSelected();
bar.OpenFileAsTab((string)selectedItem.GetMetadata(0));
}
public void PopulateTree(string path, TreeItem RootItem)
{
var dir = DirAccess.Open(path);
if (dir == null)
{
return;
}
dir.ListDirBegin();
var itemName = dir.GetNext();
while (itemName != "")
{
if (itemName != "." && itemName != "..")
{
var fullPath = path.PathJoin(itemName);
if (dir.CurrentIsDir())
{
var folderItem = CreateItem(RootItem);
folderItem.SetText(0, itemName);
PopulateTree(fullPath, folderItem);
}
else
{
string icp = "";
switch (itemName.GetExtension())
{
default: icp = "default"; break;
case "py" or "pyc": icp = "python"; break;
case "png" or "jpg": icp = "image"; break;
case "mp3" or "wav" or "mcx" or "acx" or "wma": icp = "audio"; break;
case "lua" or "clua" or "luau": icp = "lua"; break;
case "json" or "jsonc" or "jsonl": icp = "json"; break;
}
var fileItem = CreateItem(RootItem);
fileItem.SetText(0, itemName);
fileItem.SetIcon(0, GD.Load<Texture2D>($"res://Icons/{icp}.svg"));
fileItem.SetIconMaxWidth(0, 32);
fileItem.SetMetadata(0, fullPath);
}
}
itemName = dir.GetNext();
}
dir.ListDirEnd();
}
}