2019-08-29 19:45:32 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
2019-09-23 22:16:50 +00:00
|
|
|
|
using Toolbox.Library;
|
2019-08-29 19:45:32 +00:00
|
|
|
|
using Toolbox.Library.Forms;
|
2019-09-01 17:02:48 +00:00
|
|
|
|
using LayoutBXLYT.Cafe;
|
2020-02-15 02:14:53 +00:00
|
|
|
|
using FirstPlugin.Forms;
|
2019-08-29 19:45:32 +00:00
|
|
|
|
|
2019-08-29 20:33:23 +00:00
|
|
|
|
namespace LayoutBXLYT
|
2019-08-29 19:45:32 +00:00
|
|
|
|
{
|
2019-08-29 23:01:47 +00:00
|
|
|
|
public partial class LayoutHierarchy : LayoutDocked
|
2019-08-29 19:45:32 +00:00
|
|
|
|
{
|
2019-09-23 22:16:50 +00:00
|
|
|
|
private LayoutEditor ParentEditor;
|
2019-09-05 20:24:03 +00:00
|
|
|
|
private STContextMenuStrip ContexMenu;
|
|
|
|
|
|
2019-09-23 22:16:50 +00:00
|
|
|
|
public LayoutHierarchy(LayoutEditor layoutEditor)
|
2019-08-29 19:45:32 +00:00
|
|
|
|
{
|
2019-09-23 22:16:50 +00:00
|
|
|
|
ParentEditor = layoutEditor;
|
|
|
|
|
|
2019-08-29 19:45:32 +00:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
treeView1.BackColor = FormThemes.BaseTheme.FormBackColor;
|
|
|
|
|
treeView1.ForeColor = FormThemes.BaseTheme.FormForeColor;
|
|
|
|
|
|
|
|
|
|
var imgList = new ImageList();
|
2019-09-05 20:24:03 +00:00
|
|
|
|
imgList.ColorDepth = ColorDepth.Depth32Bit;
|
2019-09-02 01:36:58 +00:00
|
|
|
|
imgList.Images.Add("folder", Toolbox.Library.Properties.Resources.Folder);
|
2019-08-29 20:33:23 +00:00
|
|
|
|
imgList.Images.Add("AlignmentPane", FirstPlugin.Properties.Resources.AlignmentPane);
|
|
|
|
|
imgList.Images.Add("WindowPane", FirstPlugin.Properties.Resources.WindowPane);
|
|
|
|
|
imgList.Images.Add("ScissorPane", FirstPlugin.Properties.Resources.ScissorPane);
|
|
|
|
|
imgList.Images.Add("BoundryPane", FirstPlugin.Properties.Resources.BoundryPane);
|
|
|
|
|
imgList.Images.Add("NullPane", FirstPlugin.Properties.Resources.NullPane);
|
|
|
|
|
imgList.Images.Add("PicturePane", FirstPlugin.Properties.Resources.PicturePane);
|
2019-09-02 01:36:58 +00:00
|
|
|
|
imgList.Images.Add("QuickAcess", FirstPlugin.Properties.Resources.QuickAccess);
|
2019-09-03 22:58:58 +00:00
|
|
|
|
imgList.Images.Add("TextPane", FirstPlugin.Properties.Resources.TextPane);
|
2019-09-05 20:24:03 +00:00
|
|
|
|
imgList.Images.Add("material", Toolbox.Library.Properties.Resources.materialSphere);
|
|
|
|
|
imgList.Images.Add("texture", Toolbox.Library.Properties.Resources.Texture);
|
|
|
|
|
imgList.Images.Add("font", Toolbox.Library.Properties.Resources.Font);
|
2019-09-02 01:36:58 +00:00
|
|
|
|
|
2019-08-29 19:45:32 +00:00
|
|
|
|
imgList.ImageSize = new Size(22,22);
|
|
|
|
|
treeView1.ImageList = imgList;
|
2019-09-05 20:24:03 +00:00
|
|
|
|
|
|
|
|
|
BackColor = FormThemes.BaseTheme.FormBackColor;
|
|
|
|
|
ForeColor = FormThemes.BaseTheme.FormForeColor;
|
|
|
|
|
|
|
|
|
|
ContexMenu = new STContextMenuStrip();
|
2019-08-29 19:45:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool isLoaded = false;
|
|
|
|
|
private EventHandler OnProperySelected;
|
2019-09-10 22:42:48 +00:00
|
|
|
|
private BxlytHeader ActiveLayout;
|
2019-08-30 22:53:45 +00:00
|
|
|
|
public void LoadLayout(BxlytHeader bxlyt, EventHandler onPropertySelected)
|
2019-08-29 19:45:32 +00:00
|
|
|
|
{
|
|
|
|
|
isLoaded = false;
|
|
|
|
|
OnProperySelected = onPropertySelected;
|
|
|
|
|
|
2019-09-10 22:42:48 +00:00
|
|
|
|
ActiveLayout = bxlyt;
|
|
|
|
|
|
2019-09-02 01:36:58 +00:00
|
|
|
|
treeView1.BeginUpdate();
|
2019-08-29 21:17:24 +00:00
|
|
|
|
treeView1.Nodes.Clear();
|
|
|
|
|
|
2019-09-02 01:36:58 +00:00
|
|
|
|
CreateQuickAccess(bxlyt);
|
2019-09-05 20:24:03 +00:00
|
|
|
|
treeView1.Nodes.Add(new TreeNode("File Settings") {Tag = bxlyt });
|
|
|
|
|
LoadTextures(bxlyt.Textures);
|
|
|
|
|
LoadFonts(bxlyt.Fonts);
|
2020-02-12 00:19:23 +00:00
|
|
|
|
LoadMaterials(bxlyt.Materials);
|
2020-01-19 01:59:49 +00:00
|
|
|
|
treeView1.Nodes.Add(new AnimatedPaneFolder(ParentEditor, "Animated Pane List") { Tag = bxlyt });
|
|
|
|
|
|
2019-08-30 22:53:45 +00:00
|
|
|
|
LoadPane(bxlyt.RootGroup);
|
|
|
|
|
LoadPane(bxlyt.RootPane);
|
2019-08-29 19:45:32 +00:00
|
|
|
|
|
2019-09-02 01:36:58 +00:00
|
|
|
|
treeView1.EndUpdate();
|
|
|
|
|
|
2019-08-29 19:45:32 +00:00
|
|
|
|
isLoaded = true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-19 01:59:49 +00:00
|
|
|
|
public class AnimatedPaneFolder : TreeNodeCustom
|
|
|
|
|
{
|
|
|
|
|
private LayoutEditor ParentEditor;
|
|
|
|
|
private bool Expanded = false;
|
|
|
|
|
|
|
|
|
|
public AnimatedPaneFolder(LayoutEditor editor, string text) {
|
|
|
|
|
ParentEditor = editor;
|
|
|
|
|
Text = text;
|
|
|
|
|
|
|
|
|
|
Nodes.Add("Empty");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnExpand()
|
|
|
|
|
{
|
|
|
|
|
if (Expanded) return;
|
|
|
|
|
|
|
|
|
|
var layoutFile = (BxlytHeader)Tag;
|
|
|
|
|
|
|
|
|
|
Nodes.Clear();
|
|
|
|
|
|
|
|
|
|
Expanded = true;
|
|
|
|
|
|
|
|
|
|
var animations = ParentEditor.AnimationFiles;
|
|
|
|
|
|
|
|
|
|
foreach (var pane in layoutFile.PaneLookup.Values) {
|
|
|
|
|
string matName = "";
|
|
|
|
|
|
|
|
|
|
//Find materials
|
|
|
|
|
var mat = pane.TryGetActiveMaterial();
|
|
|
|
|
if (mat != null) matName = mat.Name;
|
|
|
|
|
|
|
|
|
|
//search archive
|
|
|
|
|
var archive = layoutFile.FileInfo.IFileInfo.ArchiveParent;
|
|
|
|
|
if (archive != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var file in archive.Files)
|
|
|
|
|
{
|
|
|
|
|
if (Utils.GetExtension(file.FileName) == ".bflan" &&
|
|
|
|
|
!animations.Any(x => x.FileName == file.FileName))
|
|
|
|
|
{
|
|
|
|
|
if (BxlanHeader.ContainsEntry(file.FileData, new string[2] { pane.Name, matName }))
|
|
|
|
|
{
|
|
|
|
|
var paneNode = CreatePaneWrapper(pane);
|
|
|
|
|
Nodes.Add(paneNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Search opened animations
|
|
|
|
|
for (int i = 0; i < animations?.Count; i++) {
|
|
|
|
|
if (animations[i].ContainsEntry(pane.Name) || animations[i].ContainsEntry(matName))
|
|
|
|
|
{
|
|
|
|
|
var paneNode = CreatePaneWrapper(pane);
|
|
|
|
|
Nodes.Add(paneNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-05 17:25:28 +00:00
|
|
|
|
public void SelectNode(TreeNode node)
|
2019-09-23 22:16:50 +00:00
|
|
|
|
{
|
2019-10-05 17:25:28 +00:00
|
|
|
|
treeView1.SelectedNode = node;
|
|
|
|
|
treeView1.Refresh();
|
2019-09-10 22:42:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-05 22:37:28 +00:00
|
|
|
|
public void UpdateTree()
|
|
|
|
|
{
|
|
|
|
|
treeView1.Refresh();
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 23:01:47 +00:00
|
|
|
|
public void Reset()
|
|
|
|
|
{
|
|
|
|
|
treeView1.Nodes.Clear();
|
|
|
|
|
isLoaded = false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 00:54:50 +00:00
|
|
|
|
public List<BasePane> GetSelectedPanes()
|
|
|
|
|
{
|
|
|
|
|
List<BasePane> nodes = new List<BasePane>();
|
|
|
|
|
foreach (var node in treeView1.SelectedNodes) {
|
|
|
|
|
if (node.Tag != null && node.Tag is BasePane)
|
|
|
|
|
nodes.Add((BasePane)node.Tag);
|
|
|
|
|
}
|
|
|
|
|
return nodes;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-05 20:24:03 +00:00
|
|
|
|
private void LoadTextures(List<string> textures)
|
|
|
|
|
{
|
2019-10-14 01:02:39 +00:00
|
|
|
|
ActiveLayout.TextureFolder = new TreeNode("Textures");
|
|
|
|
|
treeView1.Nodes.Add(ActiveLayout.TextureFolder);
|
2019-09-05 20:24:03 +00:00
|
|
|
|
for (int i = 0; i < textures.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
TreeNode matNode = new TreeNode(textures[i]);
|
2019-09-10 22:42:48 +00:00
|
|
|
|
matNode.Tag = i;
|
|
|
|
|
matNode.ContextMenuStrip = new ContextMenuStrip();
|
|
|
|
|
var menu = new STToolStipMenuItem("Rename");
|
|
|
|
|
menu.Click += RenameTextureAction;
|
|
|
|
|
matNode.ContextMenuStrip.Items.Add(menu);
|
2019-09-05 20:24:03 +00:00
|
|
|
|
matNode.ImageKey = "texture";
|
|
|
|
|
matNode.SelectedImageKey = "texture";
|
2019-10-14 01:02:39 +00:00
|
|
|
|
ActiveLayout.TextureFolder.Nodes.Add(matNode);
|
2019-09-05 20:24:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-10 22:42:48 +00:00
|
|
|
|
private void RenameTextureAction(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var selectedNode = treeView1.SelectedNode;
|
|
|
|
|
if (selectedNode == null) return;
|
|
|
|
|
|
|
|
|
|
int index = (int)selectedNode.Tag;
|
|
|
|
|
string activeTex = ActiveLayout.Textures[index];
|
|
|
|
|
|
|
|
|
|
RenameDialog dlg = new RenameDialog();
|
|
|
|
|
dlg.SetString(activeTex);
|
|
|
|
|
|
|
|
|
|
if (dlg.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
ActiveLayout.Textures[index] = dlg.textBox1.Text;
|
|
|
|
|
selectedNode.Text = dlg.textBox1.Text;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-05 20:24:03 +00:00
|
|
|
|
private void LoadFonts(List<string> fonts)
|
|
|
|
|
{
|
2019-10-14 01:02:39 +00:00
|
|
|
|
ActiveLayout.FontFolder = new TreeNode("Fonts");
|
|
|
|
|
treeView1.Nodes.Add(ActiveLayout.FontFolder);
|
2019-09-05 20:24:03 +00:00
|
|
|
|
for (int i = 0; i < fonts.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
TreeNode matNode = new TreeNode(fonts[i]);
|
|
|
|
|
matNode.ImageKey = "font";
|
|
|
|
|
matNode.SelectedImageKey = "font";
|
2019-10-14 01:02:39 +00:00
|
|
|
|
ActiveLayout.FontFolder.Nodes.Add(matNode);
|
2019-09-05 20:24:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadMaterials(List<BxlytMaterial> materials)
|
|
|
|
|
{
|
2019-10-14 01:02:39 +00:00
|
|
|
|
ActiveLayout.MaterialFolder = new TreeNode("Materials");
|
|
|
|
|
treeView1.Nodes.Add(ActiveLayout.MaterialFolder);
|
2019-09-05 20:24:03 +00:00
|
|
|
|
for (int i = 0; i < materials.Count; i++)
|
|
|
|
|
{
|
2019-10-14 01:02:39 +00:00
|
|
|
|
MatWrapper matNode = new MatWrapper(materials[i].Name);
|
|
|
|
|
materials[i].NodeWrapper = matNode;
|
2019-09-05 20:24:03 +00:00
|
|
|
|
matNode.Tag = materials[i];
|
|
|
|
|
matNode.ImageKey = "material";
|
|
|
|
|
matNode.SelectedImageKey = "material";
|
2019-10-14 01:02:39 +00:00
|
|
|
|
ActiveLayout.MaterialFolder.Nodes.Add(matNode);
|
2019-09-05 20:24:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 01:02:39 +00:00
|
|
|
|
|
|
|
|
|
|
2019-09-02 01:36:58 +00:00
|
|
|
|
private void CreateQuickAccess(BxlytHeader bxlyt)
|
|
|
|
|
{
|
|
|
|
|
var panes = new List<BasePane>();
|
|
|
|
|
var groupPanes = new List<BasePane>();
|
|
|
|
|
GetPanes(bxlyt.RootPane,ref panes);
|
|
|
|
|
GetGroupPanes(bxlyt.RootGroup,ref groupPanes);
|
|
|
|
|
|
|
|
|
|
TreeNode node = new TreeNode("Quick Access");
|
|
|
|
|
node.ImageKey = "QuickAcess";
|
|
|
|
|
node.SelectedImageKey = "QuickAcess";
|
|
|
|
|
treeView1.Nodes.Add(node);
|
|
|
|
|
|
|
|
|
|
TreeNode nullFolder = new TreeNode("Null Panes");
|
2019-09-03 22:58:58 +00:00
|
|
|
|
TreeNode textFolder = new TreeNode("Text Boxes");
|
2019-09-02 01:36:58 +00:00
|
|
|
|
TreeNode windowFolder = new TreeNode("Window Panes");
|
|
|
|
|
TreeNode pictureFolder = new TreeNode("Picture Panes");
|
|
|
|
|
TreeNode boundryFolder = new TreeNode("Boundry Panes");
|
|
|
|
|
TreeNode partsFolder = new TreeNode("Part Panes");
|
|
|
|
|
TreeNode groupFolder = new TreeNode("Groups");
|
|
|
|
|
|
|
|
|
|
node.Nodes.Add(nullFolder);
|
2019-09-03 22:58:58 +00:00
|
|
|
|
node.Nodes.Add(textFolder);
|
2019-09-02 01:36:58 +00:00
|
|
|
|
node.Nodes.Add(windowFolder);
|
|
|
|
|
node.Nodes.Add(pictureFolder);
|
|
|
|
|
node.Nodes.Add(boundryFolder);
|
|
|
|
|
node.Nodes.Add(partsFolder);
|
|
|
|
|
node.Nodes.Add(groupFolder);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < panes.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var paneNode = CreatePaneWrapper(panes[i]);
|
2020-02-12 00:19:23 +00:00
|
|
|
|
if (panes[i] is IWindowPane) windowFolder.Nodes.Add(paneNode);
|
|
|
|
|
else if (panes[i] is IPicturePane) pictureFolder.Nodes.Add(paneNode);
|
|
|
|
|
else if (panes[i] is IBoundryPane) boundryFolder.Nodes.Add(paneNode);
|
|
|
|
|
else if (panes[i] is IPartPane) partsFolder.Nodes.Add(paneNode);
|
|
|
|
|
else if (panes[i] is ITextPane) textFolder.Nodes.Add(paneNode);
|
2019-09-02 01:36:58 +00:00
|
|
|
|
else nullFolder.Nodes.Add(paneNode);
|
2020-01-29 21:08:29 +00:00
|
|
|
|
|
2020-02-12 00:19:23 +00:00
|
|
|
|
if (panes[i] is Cafe.PRT1)
|
2020-01-29 21:08:29 +00:00
|
|
|
|
{
|
2020-02-12 00:19:23 +00:00
|
|
|
|
var partPane = (Cafe.PRT1)panes[i];
|
2020-01-29 21:08:29 +00:00
|
|
|
|
foreach (var property in partPane.Properties)
|
|
|
|
|
{
|
|
|
|
|
if (property.Property != null)
|
|
|
|
|
{
|
|
|
|
|
var propertyNode = CreatePaneWrapper(property.Property);
|
|
|
|
|
paneNode.Nodes.Add(propertyNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-09-02 01:36:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < groupPanes.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var paneNode = CreatePaneWrapper(groupPanes[i]);
|
|
|
|
|
groupFolder.Nodes.Add(paneNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GetPanes(BasePane pane, ref List<BasePane> panes)
|
|
|
|
|
{
|
|
|
|
|
panes.Add(pane);
|
|
|
|
|
foreach (var childPane in pane.Childern)
|
|
|
|
|
GetPanes(childPane,ref panes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GetGroupPanes(BasePane pane, ref List<BasePane> panes)
|
|
|
|
|
{
|
|
|
|
|
panes.Add(pane);
|
|
|
|
|
foreach (var childPane in pane.Childern)
|
|
|
|
|
GetPanes(childPane,ref panes);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-06 01:15:19 +00:00
|
|
|
|
public static PaneTreeWrapper CreatePaneWrapper(BasePane pane)
|
2019-08-29 19:45:32 +00:00
|
|
|
|
{
|
|
|
|
|
PaneTreeWrapper paneNode = new PaneTreeWrapper();
|
|
|
|
|
paneNode.Text = pane.Name;
|
|
|
|
|
paneNode.Tag = pane;
|
2019-09-05 20:24:03 +00:00
|
|
|
|
paneNode.Checked = true;
|
2019-08-29 19:45:32 +00:00
|
|
|
|
|
|
|
|
|
string imageKey = "";
|
2020-02-12 00:19:23 +00:00
|
|
|
|
if (pane is IWindowPane) imageKey = "WindowPane";
|
|
|
|
|
else if (pane is IPicturePane) imageKey = "PicturePane";
|
|
|
|
|
else if (pane is IBoundryPane) imageKey = "BoundryPane";
|
|
|
|
|
else if (pane is ITextPane) imageKey = "TextPane";
|
2019-08-29 19:45:32 +00:00
|
|
|
|
else imageKey = "NullPane";
|
|
|
|
|
|
|
|
|
|
paneNode.ImageKey = imageKey;
|
|
|
|
|
paneNode.SelectedImageKey = imageKey;
|
|
|
|
|
|
2019-09-02 01:36:58 +00:00
|
|
|
|
return paneNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadPane(BasePane pane, TreeNode parent = null)
|
|
|
|
|
{
|
|
|
|
|
var paneNode = CreatePaneWrapper(pane);
|
2019-10-05 17:25:28 +00:00
|
|
|
|
pane.NodeWrapper = paneNode;
|
|
|
|
|
|
2019-08-29 19:45:32 +00:00
|
|
|
|
if (parent == null)
|
|
|
|
|
treeView1.Nodes.Add(paneNode);
|
|
|
|
|
else
|
|
|
|
|
parent.Nodes.Add(paneNode);
|
|
|
|
|
|
|
|
|
|
foreach (var childPane in pane.Childern)
|
|
|
|
|
LoadPane(childPane, paneNode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (isLoaded)
|
|
|
|
|
OnProperySelected.Invoke("Select", e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void treeView1_AfterCheck(object sender, TreeViewEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (isLoaded)
|
2019-09-05 20:24:03 +00:00
|
|
|
|
{
|
|
|
|
|
if (!e.Node.Checked)
|
|
|
|
|
e.Node.ForeColor = FormThemes.BaseTheme.DisabledItemColor;
|
|
|
|
|
else
|
|
|
|
|
e.Node.ForeColor = treeView1.ForeColor;
|
|
|
|
|
|
2019-08-29 19:45:32 +00:00
|
|
|
|
OnProperySelected.Invoke("Checked", e);
|
2019-09-05 20:24:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void treeView1_MouseClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TogglePane(object sender, EventArgs e)
|
|
|
|
|
{
|
2020-02-18 00:54:50 +00:00
|
|
|
|
foreach (TreeNode node in treeView1.SelectedNodes)
|
|
|
|
|
TogglePane(node);
|
2019-09-05 20:24:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TogglePane(TreeNode node)
|
|
|
|
|
{
|
|
|
|
|
if (node == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (node.Checked)
|
|
|
|
|
node.Checked = false;
|
|
|
|
|
else
|
|
|
|
|
node.Checked = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void treeView1_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
2020-02-18 00:54:50 +00:00
|
|
|
|
foreach (var node in treeView1.SelectedNodes) {
|
|
|
|
|
if (node == null || node.Tag == null)
|
|
|
|
|
continue;
|
2019-09-05 20:24:03 +00:00
|
|
|
|
|
2020-02-18 00:54:50 +00:00
|
|
|
|
if (e.KeyCode == Keys.H)
|
|
|
|
|
{
|
|
|
|
|
if (node.Tag is BasePane)
|
|
|
|
|
TogglePane(node);
|
|
|
|
|
}
|
2019-09-05 20:24:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Node.Tag == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (e.Button == MouseButtons.Right)
|
|
|
|
|
{
|
2020-03-10 23:39:17 +00:00
|
|
|
|
treeView1.SelectedNode = e.Node;
|
2019-09-05 20:24:03 +00:00
|
|
|
|
|
|
|
|
|
if (e.Node.Tag is BasePane)
|
|
|
|
|
{
|
|
|
|
|
ContexMenu.Items.Clear();
|
|
|
|
|
ContexMenu.Items.Add(new STToolStipMenuItem("Display Panes", null, TogglePane, Keys.Control | Keys.H));
|
|
|
|
|
// ContexMenu.Items.Add(new STToolStipMenuItem("Display Children Panes", null, TogglePane, Keys.Control | Keys.H));
|
|
|
|
|
ContexMenu.Show(Cursor.Position);
|
|
|
|
|
}
|
2020-02-15 02:14:53 +00:00
|
|
|
|
|
|
|
|
|
//Check fonts to open editor if possible
|
|
|
|
|
if (e.Node.ImageKey == "font") {
|
|
|
|
|
ContexMenu.Items.Clear();
|
|
|
|
|
ContexMenu.Items.Add(new STToolStipMenuItem("Load Font File", null, loadFontFile, Keys.Control | Keys.L));
|
|
|
|
|
ContexMenu.Show(Cursor.Position);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void loadFontFile(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
OpenFileDialog ofd = new OpenFileDialog();
|
|
|
|
|
ofd.Multiselect = true;
|
|
|
|
|
ofd.Filter = Utils.GetAllFilters(new Type[] { typeof(FirstPlugin.BXFNT ), });
|
|
|
|
|
if (ofd.ShowDialog() == DialogResult.OK) {
|
|
|
|
|
var fileFormat = Toolbox.Library.IO.STFileLoader.OpenFileFormat(ofd.FileName);
|
|
|
|
|
if (fileFormat is IArchiveFile)
|
|
|
|
|
{
|
|
|
|
|
foreach (var file in ((IArchiveFile)fileFormat).Files) {
|
|
|
|
|
var archiveFile = file.OpenFile();
|
|
|
|
|
if (archiveFile is FirstPlugin.BXFNT) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ParentEditor.UpdateViewport();
|
2019-09-05 20:24:03 +00:00
|
|
|
|
}
|
2019-08-29 19:45:32 +00:00
|
|
|
|
}
|
2019-09-23 22:16:50 +00:00
|
|
|
|
|
|
|
|
|
private void treeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//Create and expand a file format, then update the tag
|
|
|
|
|
//Allows for faster loading
|
|
|
|
|
if (e.Node.Tag is ArchiveFileInfo)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2020-01-19 01:59:49 +00:00
|
|
|
|
|
|
|
|
|
if (e.Node is TreeNodeCustom)
|
|
|
|
|
((TreeNodeCustom)e.Node).OnExpand();
|
2019-09-23 22:16:50 +00:00
|
|
|
|
}
|
2019-10-05 17:25:28 +00:00
|
|
|
|
|
|
|
|
|
private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Node.Tag == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-10-14 01:02:39 +00:00
|
|
|
|
if (e.Button == MouseButtons.Left) {
|
|
|
|
|
if (e.Node.Tag is BasePane)
|
|
|
|
|
ParentEditor.ShowPaneEditor(e.Node.Tag as BasePane);
|
2020-02-15 02:14:53 +00:00
|
|
|
|
|
|
|
|
|
//Check fonts to open editor if possible
|
|
|
|
|
if (e.Node.ImageKey == "font")
|
|
|
|
|
{
|
|
|
|
|
foreach (var file in FirstPlugin.PluginRuntime.BxfntFiles) {
|
|
|
|
|
if (file.FileName == e.Node.Text)
|
|
|
|
|
{
|
|
|
|
|
Form frm = new Form();
|
|
|
|
|
|
|
|
|
|
BffntEditor editor = new BffntEditor();
|
|
|
|
|
editor.Text = "Font Editor";
|
|
|
|
|
editor.Dock = DockStyle.Fill;
|
|
|
|
|
editor.LoadFontFile(file);
|
|
|
|
|
editor.OnFontEdited += bxfntEditor_FontEdited;
|
|
|
|
|
frm.Controls.Add(editor);
|
|
|
|
|
|
|
|
|
|
frm.Show(ParentEditor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-05 17:25:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-15 22:45:51 +00:00
|
|
|
|
|
2019-10-27 00:28:56 +00:00
|
|
|
|
#region NodeDragDrop
|
|
|
|
|
|
|
|
|
|
private string NodeMap;
|
|
|
|
|
|
2019-10-15 22:45:51 +00:00
|
|
|
|
private void treeView1_DragDrop(object sender, DragEventArgs e)
|
|
|
|
|
{
|
2019-11-07 02:03:34 +00:00
|
|
|
|
/* if (e.Data.GetDataPresent(typeof(PaneTreeWrapper)))
|
2019-10-27 00:28:56 +00:00
|
|
|
|
{
|
|
|
|
|
Point targetPoint = treeView1.PointToClient(new Point(e.X, e.Y));
|
|
|
|
|
TreeNode NodeOver = treeView1.GetNodeAt(targetPoint);
|
|
|
|
|
TreeNode NodeMoving = (PaneTreeWrapper)e.Data.GetData(typeof(PaneTreeWrapper));
|
|
|
|
|
|
|
|
|
|
if (NodeOver != null && (NodeOver != NodeMoving || (NodeOver.Parent != null && NodeOver.Index == (NodeOver.Parent.Nodes.Count - 1))))
|
|
|
|
|
{
|
|
|
|
|
int OffsetY = this.treeView1.PointToClient(Cursor.Position).Y - NodeOver.Bounds.Top;
|
|
|
|
|
int NodeOverImageWidth = this.treeView1.ImageList.Images[NodeOver.ImageIndex].Size.Width + 8;
|
|
|
|
|
Graphics g = this.treeView1.CreateGraphics();
|
|
|
|
|
|
|
|
|
|
//Folder node
|
|
|
|
|
|
|
|
|
|
if (OffsetY < (NodeOver.Bounds.Height / 3))
|
|
|
|
|
{
|
|
|
|
|
TreeNode tnParadox = NodeOver;
|
|
|
|
|
while (tnParadox.Parent != null)
|
|
|
|
|
{
|
|
|
|
|
if (tnParadox.Parent == NodeMoving)
|
|
|
|
|
{
|
|
|
|
|
this.NodeMap = "";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tnParadox = tnParadox.Parent;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-07 02:03:34 +00:00
|
|
|
|
}*/
|
2019-10-27 00:28:56 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2019-11-07 02:03:34 +00:00
|
|
|
|
|
2019-10-15 22:45:51 +00:00
|
|
|
|
if (e.Data.GetDataPresent(typeof(PaneTreeWrapper)))
|
|
|
|
|
{
|
|
|
|
|
Point targetPoint = treeView1.PointToClient(new Point(e.X, e.Y));
|
|
|
|
|
|
|
|
|
|
TreeNode targetNode = treeView1.GetNodeAt(targetPoint);
|
|
|
|
|
TreeNode draggedNode = (PaneTreeWrapper)e.Data.GetData(typeof(PaneTreeWrapper));
|
|
|
|
|
|
|
|
|
|
var draggedPane = draggedNode.Tag as BasePane;
|
|
|
|
|
if (draggedPane == null || draggedPane.IsRoot)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
TreeNode parentNode = targetNode;
|
|
|
|
|
|
|
|
|
|
if (targetNode != null && targetNode.Parent != null)
|
|
|
|
|
{
|
|
|
|
|
bool canDrop = true;
|
|
|
|
|
while (canDrop && (parentNode != null))
|
|
|
|
|
{
|
|
|
|
|
canDrop = !Object.ReferenceEquals(draggedNode, parentNode);
|
|
|
|
|
parentNode = parentNode.Parent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!canDrop) return;
|
|
|
|
|
|
|
|
|
|
bool isTargetParent = targetNode.Equals(draggedNode.Parent);
|
|
|
|
|
|
|
|
|
|
//Remove it's previous parent
|
|
|
|
|
draggedPane.Parent.Childern.Remove(draggedPane);
|
|
|
|
|
draggedNode.Remove();
|
|
|
|
|
|
|
|
|
|
//Adjust the parent to the parent's parent
|
|
|
|
|
Console.WriteLine("isTargetParent " + isTargetParent);
|
|
|
|
|
if (isTargetParent)
|
|
|
|
|
{
|
|
|
|
|
var parentPane = targetNode.Tag as BasePane;
|
|
|
|
|
if (parentPane.IsRoot) return;
|
|
|
|
|
|
|
|
|
|
var upperParentNode = targetNode.Parent;
|
|
|
|
|
var upperParentPane = upperParentNode.Tag as BasePane;
|
|
|
|
|
|
2019-10-15 23:26:58 +00:00
|
|
|
|
draggedPane.ResetParentTransform(upperParentPane);
|
2019-10-15 22:45:51 +00:00
|
|
|
|
draggedPane.Parent = upperParentPane;
|
2019-10-15 23:26:58 +00:00
|
|
|
|
|
2019-10-15 22:45:51 +00:00
|
|
|
|
upperParentPane.Childern.Add(draggedPane);
|
|
|
|
|
|
|
|
|
|
upperParentNode.Nodes.Add(draggedNode);
|
|
|
|
|
upperParentNode.Expand();
|
|
|
|
|
}
|
|
|
|
|
else //Set the target node as the parent
|
|
|
|
|
{
|
|
|
|
|
var parentPane = targetNode.Tag as BasePane;
|
2019-10-15 23:26:58 +00:00
|
|
|
|
draggedPane.ResetParentTransform(parentPane);
|
2019-10-15 22:45:51 +00:00
|
|
|
|
draggedPane.Parent = parentPane;
|
2019-10-15 23:26:58 +00:00
|
|
|
|
|
2019-10-15 22:45:51 +00:00
|
|
|
|
parentPane.Childern.Add(draggedPane);
|
|
|
|
|
|
|
|
|
|
targetNode.Nodes.Add(draggedNode);
|
|
|
|
|
targetNode.Expand();
|
|
|
|
|
}
|
2019-10-15 23:26:58 +00:00
|
|
|
|
|
|
|
|
|
ParentEditor.UpdateViewport();
|
2019-10-15 22:45:51 +00:00
|
|
|
|
}
|
2019-11-07 02:03:34 +00:00
|
|
|
|
}
|
2019-10-15 22:45:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-15 02:14:53 +00:00
|
|
|
|
private void bxfntEditor_FontEdited(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-15 22:45:51 +00:00
|
|
|
|
private void treeView1_DragEnter(object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
e.Effect = DragDropEffects.Move;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void treeView1_ItemDrag(object sender, ItemDragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DoDragDrop(e.Item, DragDropEffects.Move);
|
|
|
|
|
}
|
2019-08-29 19:45:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|