1
0
mirror of synced 2024-11-27 17:00:50 +01:00

A few fixes and additions

Files can be dragged out of and dropped within archives if adding is supported..
Fixed some archive issues with it updating, and removing improperly.
Adjustments to default transform bone settings for bfres to prevent any deform issues if a new skeleton is created.
This commit is contained in:
KillzXGaming 2019-08-14 15:27:45 -04:00
parent a251892b1f
commit 00e9c6506f
13 changed files with 168 additions and 30 deletions

1
.gitignore vendored
View File

@ -10,4 +10,5 @@ Debug/
Release/
BrawlboxHelper/BrawlHelperTest2.cs
BrawlboxHelper/BrawlHelperTest2.zip
Switch_Toolbox_StreamOverhaul.zip
Toolbox/Lib.zip

Binary file not shown.

View File

@ -707,7 +707,7 @@ namespace Bfres.Structs
public void SetTransforms()
{
if (BoneU != null)
/* if (BoneU != null)
{
BoneU.TransformRotateZero = BoneU.Rotation == Syroot.Maths.Vector4F.Zero;
BoneU.TransformScaleOne = BoneU.Scale == Syroot.Maths.Vector3F.One;
@ -718,7 +718,7 @@ namespace Bfres.Structs
Bone.TransformRotateZero = Bone.Rotation == Syroot.Maths.Vector4F.Zero;
Bone.TransformScaleOne = Bone.Scale == Syroot.Maths.Vector3F.One;
Bone.TransformTranslateZero = Bone.Position == Syroot.Maths.Vector3F.Zero;
}
}*/
}
public ResFile GetResFile()

View File

@ -133,6 +133,7 @@
//
// treeViewCustom1
//
this.treeViewCustom1.AllowDrop = true;
this.treeViewCustom1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.treeViewCustom1.CheckBoxes = true;
this.treeViewCustom1.Dock = System.Windows.Forms.DockStyle.Fill;
@ -146,10 +147,14 @@
this.treeViewCustom1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeViewCustom1_AfterCheck);
this.treeViewCustom1.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeViewCustom1_BeforeExpand);
this.treeViewCustom1.DrawNode += new System.Windows.Forms.DrawTreeNodeEventHandler(this.treeViewCustom1_DrawNode);
this.treeViewCustom1.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeView_ItemDrag);
this.treeViewCustom1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeViewCustom1_AfterSelect);
this.treeViewCustom1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeViewCustom1_MouseClick);
this.treeViewCustom1.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeViewCustom1_DragDrop);
this.treeViewCustom1.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeViewCustom1_DragEnter);
this.treeViewCustom1.DragOver += new System.Windows.Forms.DragEventHandler(this.treeViewCustom1_DragOver);
this.treeViewCustom1.DragLeave += new System.EventHandler(this.treeViewCustom1_DragLeave);
this.treeViewCustom1.GiveFeedback += new System.Windows.Forms.GiveFeedbackEventHandler(this.treeViewCustom1_GiveFeedback);
this.treeViewCustom1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeViewCustom1_KeyPress);
this.treeViewCustom1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.treeViewCustom1_DoubleClick);
//

View File

@ -3,9 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Windows.Forms;
using GL_EditorFramework.Interfaces;
using GL_EditorFramework.EditorDrawables;
@ -589,38 +587,92 @@ namespace Toolbox.Library.Forms
Console.WriteLine("AddFilesToActiveObjectEditor " + Runtime.AddFilesToActiveObjectEditor);
}
private void treeViewCustom1_DragDrop(object sender, DragEventArgs e)
private void treeViewCustom1_DragEnter(object sender, DragEventArgs e)
{
Point pt = treeViewCustom1.PointToClient(new Point(e.X, e.Y));
treeViewCustom1.SelectedNode = treeViewCustom1.GetNodeAt(pt.X, pt.Y);
bool IsFile = treeViewCustom1.SelectedNode is ArchiveFileWrapper && treeViewCustom1.SelectedNode.Parent != null;
var archiveFile = GetActiveArchive();
//Use the parent folder for files if it has any
if (IsFile)
TreeHelper.AddFiles(treeViewCustom1.SelectedNode.Parent, archiveFile, e.Data.GetData(DataFormats.FileDrop) as string[]);
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.All;
else
TreeHelper.AddFiles(treeViewCustom1.SelectedNode, archiveFile, e.Data.GetData(DataFormats.FileDrop) as string[]);
{
String[] strGetFormats = e.Data.GetFormats();
e.Effect = DragDropEffects.None;
}
}
private void treeView_ItemDrag(object sender, ItemDragEventArgs e)
{
var node = treeViewCustom1.SelectedNode;
if (node != null && node is ArchiveFileWrapper)
{
string fullPath = Write2TempAndGetFullPath(((ArchiveFileWrapper)node).ArchiveFileInfo);
DataObject dragObj = new DataObject();
dragObj.SetFileDropList(new System.Collections.Specialized.StringCollection() { fullPath });
treeViewCustom1.DoDragDrop(dragObj, DragDropEffects.Copy);
}
}
private string Write2TempAndGetFullPath(ArchiveFileInfo file)
{
string tempFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), file.FileName);
using (var writer = new FileStream(tempFilePath,
FileMode.Create, FileAccess.Write, FileShare.Write))
{
new MemoryStream(file.FileData).CopyTo(writer);
}
return tempFilePath;
}
private void treeViewCustom1_DragLeave(object sender, EventArgs e)
{
}
private void treeViewCustom1_DragOver(object sender, DragEventArgs e)
{
}
private void treeViewCustom1_GiveFeedback(object sender, GiveFeedbackEventArgs e)
{
var root = GetActiveArchive();
if (root == null || !root.ArchiveFile.CanReplaceFiles)
return;
}
private void treeViewCustom1_DragDrop(object sender, DragEventArgs e)
{
Point pt = treeViewCustom1.PointToClient(new Point(e.X, e.Y));
TreeNode node = treeViewCustom1.GetNodeAt(pt.X, pt.Y);
treeViewCustom1.SelectedNode = node;
bool IsRoot = node is ArchiveRootNodeWrapper;
bool IsFolder = node is ArchiveFolderNodeWrapper;
bool IsFile = node is ArchiveFileWrapper && node.Parent != null;
var node = treeViewCustom1.GetNodeAt(pt.X, pt.Y);
if (IsFolder || IsRoot || IsFile)
e.Effect = DragDropEffects.Link;
// else
// e.Effect = DragDropEffects.None;
if (node != null)
{
treeViewCustom1.SelectedNode = node;
bool IsRoot = node is ArchiveRootNodeWrapper;
bool IsFolder = node is ArchiveFolderNodeWrapper;
bool IsFile = node is ArchiveFileWrapper && node.Parent != null;
if (IsRoot || IsFolder || IsFile)
{
var archiveFile = GetActiveArchive();
//Use the parent folder for files if it has any
if (IsFile)
TreeHelper.AddFiles(treeViewCustom1.SelectedNode.Parent, archiveFile, e.Data.GetData(DataFormats.FileDrop) as string[]);
else
TreeHelper.AddFiles(treeViewCustom1.SelectedNode, archiveFile, e.Data.GetData(DataFormats.FileDrop) as string[]);
}
}
else
{
Cursor.Current = Cursors.WaitCursor;
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string filename in files)
{
((IMainForm)Runtime.MainForm).OpenFile(filename, Runtime.ObjectEditor.OpenModelsOnOpen);
}
Cursor.Current = Cursors.Default;
}
}
private ArchiveRootNodeWrapper GetActiveArchive()

View File

@ -123,6 +123,9 @@
<metadata name="objectEditorMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="objectEditorMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="treeNodeContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>166, 17</value>
</metadata>

View File

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace Toolbox.Library
{
public class DragHelper
{
[DllImport("comctl32.dll")]
public static extern bool InitCommonControls();
[DllImport("comctl32.dll", CharSet = CharSet.Auto)]
public static extern bool ImageList_BeginDrag(
IntPtr himlTrack, // Handler of the image list containing the image to drag
int iTrack, // Index of the image to drag
int dxHotspot, // x-delta between mouse position and drag image
int dyHotspot // y-delta between mouse position and drag image
);
[DllImport("comctl32.dll", CharSet = CharSet.Auto)]
public static extern bool ImageList_DragMove(
int x, // X-coordinate (relative to the form,
// not the treeview) at which to display the drag image.
int y // Y-coordinate (relative to the form,
// not the treeview) at which to display the drag image.
);
[DllImport("comctl32.dll", CharSet = CharSet.Auto)]
public static extern void ImageList_EndDrag();
[DllImport("comctl32.dll", CharSet = CharSet.Auto)]
public static extern bool ImageList_DragEnter(
IntPtr hwndLock, // Handle to the control that owns the drag image.
int x, // X-coordinate (relative to the treeview)
// at which to display the drag image.
int y // Y-coordinate (relative to the treeview)
// at which to display the drag image.
);
[DllImport("comctl32.dll", CharSet = CharSet.Auto)]
public static extern bool ImageList_DragLeave(
IntPtr hwndLock // Handle to the control that owns the drag image.
);
[DllImport("comctl32.dll", CharSet = CharSet.Auto)]
public static extern bool ImageList_DragShowNolock(
bool fShow // False to hide, true to show the image
);
static DragHelper()
{
InitCommonControls();
}
}
}

View File

@ -214,9 +214,11 @@ namespace Toolbox.Library
bool HasAddedFile = archiveFile.AddFile(File.ArchiveFileInfo);
if (HasAddedFile)
{
//Re apply the newly added archive info
File.ArchiveFileInfo = archiveFile.Files.LastOrDefault();
parentNode.Nodes.Add(File);
if (parentNode is ArchiveRootNodeWrapper)

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Toolbox.Library
{
/// <summary>
/// An interface specifically used for MainForm.cs for plugins to communicate to
/// </summary>
public interface IMainForm
{
void OpenFile(string FileName, bool InActiveEditor = false);
}
}

View File

@ -281,9 +281,11 @@
</Compile>
<Compile Include="Generics\Texture\ImageParameters.cs" />
<Compile Include="Generics\Texture\STTextureFolder.cs" />
<Compile Include="Helpers\DragHelper.cs" />
<Compile Include="Interfaces\FileFormatting\ILeaveOpenOnLoad.cs" />
<Compile Include="Interfaces\FileFormatting\IPropertyContainer.cs" />
<Compile Include="Interfaces\FileFormatting\ISaveOpenedFileStream.cs" />
<Compile Include="Interfaces\IMainForm.cs" />
<Compile Include="Interfaces\Textures\ITextureIconLoader.cs" />
<Compile Include="Interfaces\Utility\ICloneableNode.cs" />
<Compile Include="Interfaces\ModelData\IMeshContainer.cs" />

View File

@ -20,7 +20,7 @@ using Toolbox.Library.Rendering;
namespace Toolbox
{
public partial class MainForm : Form, IMdiContainer, IUpdateForm
public partial class MainForm : Form, IMdiContainer, IUpdateForm, IMainForm
{
private static MainForm _instance;
public static MainForm Instance { get { return _instance == null ? _instance = new MainForm() : _instance; } }