Add drag drop support for layout editor. Load textures per layout file
This commit is contained in:
parent
cb5be622b8
commit
1e4b18844f
@ -80,7 +80,7 @@ namespace LayoutBXLYT
|
||||
((LayoutEditor)control).LoadBflyt(header, FileName);
|
||||
}
|
||||
|
||||
private Header header;
|
||||
public Header header;
|
||||
public void Load(System.IO.Stream stream)
|
||||
{
|
||||
CanSave = false;
|
||||
|
@ -136,6 +136,7 @@
|
||||
//
|
||||
// LayoutEditor
|
||||
//
|
||||
this.AllowDrop = true;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(549, 398);
|
||||
@ -146,6 +147,8 @@
|
||||
this.Controls.Add(this.stMenuStrip1);
|
||||
this.IsMdiContainer = true;
|
||||
this.Name = "LayoutEditor";
|
||||
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.LayoutEditor_DragDrop);
|
||||
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.LayoutEditor_DragEnter);
|
||||
this.ParentChanged += new System.EventHandler(this.LayoutEditor_ParentChanged);
|
||||
((System.ComponentModel.ISupportInitialize)(this.backColorDisplay)).EndInit();
|
||||
this.stToolStrip1.ResumeLayout(false);
|
||||
|
@ -12,6 +12,7 @@ using WeifenLuo.WinFormsUI.Docking;
|
||||
using WeifenLuo.WinFormsUI.ThemeVS2015;
|
||||
using Toolbox.Library.IO;
|
||||
using Toolbox.Library;
|
||||
using FirstPlugin;
|
||||
|
||||
namespace LayoutBXLYT
|
||||
{
|
||||
@ -55,6 +56,7 @@ namespace LayoutBXLYT
|
||||
private List<LayoutViewer> Viewports = new List<LayoutViewer>();
|
||||
private LayoutViewer ActiveViewport;
|
||||
private LayoutHierarchy LayoutHierarchy;
|
||||
private LayoutTextureList LayoutTextureList;
|
||||
|
||||
private bool isLoaded = false;
|
||||
public void LoadBflyt(BFLYT.Header header, string fileName)
|
||||
@ -87,8 +89,8 @@ namespace LayoutBXLYT
|
||||
{
|
||||
if (LayoutHierarchy != null)
|
||||
LayoutHierarchy.LoadLayout(activeLayout, ObjectSelected);
|
||||
if (LayoutHierarchy != null)
|
||||
LayoutHierarchy.LoadLayout(activeLayout, ObjectSelected);
|
||||
if (LayoutTextureList != null)
|
||||
LayoutTextureList.LoadTextures(activeLayout);
|
||||
}
|
||||
|
||||
private void OnObjectChanged(object sender, EventArgs e)
|
||||
@ -200,9 +202,9 @@ namespace LayoutBXLYT
|
||||
|
||||
private void ShowTextureList()
|
||||
{
|
||||
LayoutTextureList textureListForm = new LayoutTextureList();
|
||||
textureListForm.LoadTextures(ActiveLayout);
|
||||
TextureListDock = DockShow(textureListForm, "Texture List", DockState.DockRight);
|
||||
LayoutTextureList = new LayoutTextureList();
|
||||
LayoutTextureList.LoadTextures(ActiveLayout);
|
||||
TextureListDock = DockShow(LayoutTextureList, "Texture List", DockState.DockRight);
|
||||
}
|
||||
|
||||
private void stComboBox1_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
@ -269,5 +271,79 @@ namespace LayoutBXLYT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LayoutEditor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
|
||||
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
foreach (string filename in files)
|
||||
OpenFile(filename);
|
||||
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
|
||||
private void OpenFile(string fileName)
|
||||
{
|
||||
//Todo if an image is dropped, we should make a picture pane if a viewer is active
|
||||
|
||||
var file = STFileLoader.OpenFileFormat(fileName);
|
||||
if (file == null) return;
|
||||
|
||||
if (file is BFLYT)
|
||||
LoadBflyt(((BFLYT)file).header, file.FileName);
|
||||
else if (file is IArchiveFile)
|
||||
SearchLayoutFiles((IArchiveFile)file);
|
||||
else if (file is BFLAN)
|
||||
{
|
||||
|
||||
}
|
||||
else if (file is BNTX)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void SearchLayoutFiles(IArchiveFile archiveFile)
|
||||
{
|
||||
foreach (var file in archiveFile.Files)
|
||||
{
|
||||
if (Utils.GetExtension(file.FileName) == ".bflyt")
|
||||
{
|
||||
var fileFormat = file.OpenFile();
|
||||
fileFormat.IFileInfo.ArchiveParent = archiveFile;
|
||||
|
||||
if (fileFormat is BFLYT)
|
||||
LoadBflyt(((BFLYT)fileFormat).header, file.FileName);
|
||||
}
|
||||
else if (Utils.GetExtension(file.FileName) == ".bntx")
|
||||
{
|
||||
|
||||
}
|
||||
else if (Utils.GetExtension(file.FileName) == ".bflim")
|
||||
{
|
||||
|
||||
}
|
||||
else if (Utils.GetExtension(file.FileName) == ".lyarc")
|
||||
{
|
||||
var fileFormat = file.OpenFile();
|
||||
fileFormat.IFileInfo.ArchiveParent = archiveFile;
|
||||
|
||||
if (fileFormat is IArchiveFile)
|
||||
SearchLayoutFiles((IArchiveFile)fileFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LayoutEditor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||
e.Effect = DragDropEffects.All;
|
||||
else
|
||||
{
|
||||
String[] strGetFormats = e.Data.GetFormats();
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ namespace LayoutBXLYT
|
||||
}
|
||||
|
||||
private bool isLoaded = false;
|
||||
private Thread Thread;
|
||||
public void LoadTextures(BxlytHeader header)
|
||||
{
|
||||
listViewCustom1.Items.Clear();
|
||||
@ -60,24 +61,23 @@ namespace LayoutBXLYT
|
||||
|
||||
//Load textures after on a seperate thread
|
||||
|
||||
Thread Thread = new Thread((ThreadStart)(() =>
|
||||
if (Thread != null && Thread.IsAlive)
|
||||
Thread.Abort();
|
||||
|
||||
Thread = new Thread((ThreadStart)(() =>
|
||||
{
|
||||
foreach (ListViewItem item in listViewCustom1.Items)
|
||||
int index = 0;
|
||||
foreach (var texture in header.Textures)
|
||||
{
|
||||
if (textureList.ContainsKey(item.Text))
|
||||
if (textureList.ContainsKey(texture))
|
||||
{
|
||||
LoadTextureIcon(item, textureList[item.Text]);
|
||||
LoadTextureIcon(index, textureList[texture]);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}));
|
||||
Thread.Start();
|
||||
|
||||
foreach (ListViewItem item in listViewCustom1.Items)
|
||||
{
|
||||
if (textureList.ContainsKey(item.Text))
|
||||
LoadTextureIcon(item, textureList[item.Text]);
|
||||
}
|
||||
|
||||
listViewCustom1.EndUpdate();
|
||||
|
||||
isLoaded = true;
|
||||
@ -88,7 +88,7 @@ namespace LayoutBXLYT
|
||||
listViewCustom1.View = (View)listViewTpyeCB.SelectedItem;
|
||||
}
|
||||
|
||||
private void LoadTextureIcon(ListViewItem item, STGenericTexture texture)
|
||||
private void LoadTextureIcon(int index, STGenericTexture texture)
|
||||
{
|
||||
Bitmap temp = texture.GetBitmap();
|
||||
temp = texture.GetComponentBitmap(temp, true);
|
||||
@ -96,6 +96,7 @@ namespace LayoutBXLYT
|
||||
if (listViewCustom1.InvokeRequired)
|
||||
{
|
||||
listViewCustom1.Invoke((MethodInvoker)delegate {
|
||||
var item = listViewCustom1.Items[index];
|
||||
item.ImageIndex = imgList.Images.Count;
|
||||
item.SubItems.Add(texture.Format.ToString());
|
||||
item.SubItems.Add(texture.Width.ToString());
|
||||
|
Loading…
Reference in New Issue
Block a user