Files
ReEdit/Main.cs
T
2026-08-05 14:45:08 -05:00

95 lines
1.9 KiB
C#
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Godot;
using System;
public partial class Main : Control
{
public MenuButton File;
public FileTree tree;
public FileBar bar;
public CodeEdit EditWnd;
public FileDialog OpenFolder;
public FileDialog OpenFile;
public override void _Ready()
{
DisplayServer.WindowSetFlag(DisplayServer.WindowFlags.Transparent, true);
File = GetNode<MenuButton>("titlebar/HBoxContainer/ActionButtons/MenuButton");
OpenFolder = GetNode<FileDialog>("OpenFolder");
OpenFile = GetNode<FileDialog>("OpenFile");
tree = GetNode<FileTree>("HBoxContainer/TreeView/VBoxContainer/Tree");
bar = GetNode<FileBar>("HBoxContainer/VSplitContainer/PanelContainer2/VBoxContainer/TabBar");
EditWnd = GetNode<CodeEdit>("HBoxContainer/VSplitContainer/PanelContainer2/VBoxContainer/CodeEdit");
bar.EditorWindow = EditWnd;
PopupMenu FileP = File.GetPopup();
FileP.IdPressed += _OnItemPressed;
tree.bar = bar;
}
public override void _Draw()
{
base._Draw();
}
internal void OpenFolderC()
{
void selected(string dirpath)
{
tree.Clear();
TreeItem Rootitem = tree.CreateItem();
Rootitem.SetText(0, "Root");
tree.PopulateTree(dirpath, Rootitem);
}
OpenFolder.DirSelected += selected;
OpenFolder.PopupCentered();
}
internal void OpenFileC()
{
void selected(string filepath)
{
bar.OpenFileAsTab(filepath);
}
OpenFile.FileSelected += selected;
OpenFile.PopupCentered();
}
private void _OnItemPressed(long id)
{
switch (id)
{
case 0:
OpenFolderC();
break;
case 1:
OpenFileC();
break;
case 2:
break;
}
}
public override void _Process(double delta)
{
if (EditWnd.Text != "Create or open a file to use the editor! ")
{
EditWnd.Editable = true;
}
else
{
EditWnd.Editable = false;
}
}
}