initial commit
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user