From 7e7afc6377601559a0daf6b839abd33f95e25ca9 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Thu, 29 Aug 2019 19:21:47 -0400 Subject: [PATCH] Add layout file list for dragged archives to editor --- .../File_Format_Library.csproj | 9 ++ .../GUI/BFLYT/FileSelector.Designer.cs | 96 ++++++++++++++ File_Format_Library/GUI/BFLYT/FileSelector.cs | 46 +++++++ .../GUI/BFLYT/FileSelector.resx | 120 ++++++++++++++++++ File_Format_Library/GUI/BFLYT/LayoutEditor.cs | 46 ++++--- 5 files changed, 302 insertions(+), 15 deletions(-) create mode 100644 File_Format_Library/GUI/BFLYT/FileSelector.Designer.cs create mode 100644 File_Format_Library/GUI/BFLYT/FileSelector.cs create mode 100644 File_Format_Library/GUI/BFLYT/FileSelector.resx diff --git a/File_Format_Library/File_Format_Library.csproj b/File_Format_Library/File_Format_Library.csproj index 149f8b3a..a0079805 100644 --- a/File_Format_Library/File_Format_Library.csproj +++ b/File_Format_Library/File_Format_Library.csproj @@ -315,6 +315,12 @@ + + Form + + + FileSelector.cs + UserControl @@ -1099,6 +1105,9 @@ BffntEditor.cs + + FileSelector.cs + LayoutEditor.cs diff --git a/File_Format_Library/GUI/BFLYT/FileSelector.Designer.cs b/File_Format_Library/GUI/BFLYT/FileSelector.Designer.cs new file mode 100644 index 00000000..3f0ecd55 --- /dev/null +++ b/File_Format_Library/GUI/BFLYT/FileSelector.Designer.cs @@ -0,0 +1,96 @@ +namespace LayoutBXLYT +{ + partial class FileSelector + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.stButton1 = new Toolbox.Library.Forms.STButton(); + this.listViewCustom1 = new Toolbox.Library.Forms.ListViewCustom(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.contentContainer.SuspendLayout(); + this.SuspendLayout(); + // + // contentContainer + // + this.contentContainer.Controls.Add(this.listViewCustom1); + this.contentContainer.Controls.Add(this.stButton1); + this.contentContainer.Size = new System.Drawing.Size(274, 393); + this.contentContainer.Controls.SetChildIndex(this.stButton1, 0); + this.contentContainer.Controls.SetChildIndex(this.listViewCustom1, 0); + // + // stButton1 + // + this.stButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.stButton1.DialogResult = System.Windows.Forms.DialogResult.OK; + this.stButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.stButton1.Location = new System.Drawing.Point(190, 361); + this.stButton1.Name = "stButton1"; + this.stButton1.Size = new System.Drawing.Size(75, 23); + this.stButton1.TabIndex = 11; + this.stButton1.Text = "Ok"; + this.stButton1.UseVisualStyleBackColor = false; + // + // listViewCustom1 + // + this.listViewCustom1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewCustom1.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.listViewCustom1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1}); + this.listViewCustom1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; + this.listViewCustom1.Location = new System.Drawing.Point(5, 31); + this.listViewCustom1.Name = "listViewCustom1"; + this.listViewCustom1.OwnerDraw = true; + this.listViewCustom1.Size = new System.Drawing.Size(260, 324); + this.listViewCustom1.TabIndex = 12; + this.listViewCustom1.UseCompatibleStateImageBehavior = false; + this.listViewCustom1.View = System.Windows.Forms.View.Details; + this.listViewCustom1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listViewCustom1_MouseDoubleClick); + // + // columnHeader1 + // + this.columnHeader1.Width = 256; + // + // FileSelector + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(280, 398); + this.Name = "FileSelector"; + this.contentContainer.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private Toolbox.Library.Forms.STButton stButton1; + private Toolbox.Library.Forms.ListViewCustom listViewCustom1; + private System.Windows.Forms.ColumnHeader columnHeader1; + } +} diff --git a/File_Format_Library/GUI/BFLYT/FileSelector.cs b/File_Format_Library/GUI/BFLYT/FileSelector.cs new file mode 100644 index 00000000..62b1ebe7 --- /dev/null +++ b/File_Format_Library/GUI/BFLYT/FileSelector.cs @@ -0,0 +1,46 @@ +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; +using Toolbox.Library.Forms; +using Toolbox.Library; +using FirstPlugin; + +namespace LayoutBXLYT +{ + public partial class FileSelector : STForm + { + public FileSelector() + { + InitializeComponent(); + + listViewCustom1.MultiSelect = true; + } + + public List SelectedIndices() + { + List indices = new List(); + foreach (int index in listViewCustom1.SelectedIndices) + indices.Add(index); + + return indices; + } + + public void LoadLayoutFiles(List layoutFiles) + { + listViewCustom1.BeginUpdate(); + foreach (var file in layoutFiles) + listViewCustom1.Items.Add(file.FileName); + listViewCustom1.EndUpdate(); + } + + private void listViewCustom1_MouseDoubleClick(object sender, MouseEventArgs e) + { + } + } +} diff --git a/File_Format_Library/GUI/BFLYT/FileSelector.resx b/File_Format_Library/GUI/BFLYT/FileSelector.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/File_Format_Library/GUI/BFLYT/FileSelector.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/File_Format_Library/GUI/BFLYT/LayoutEditor.cs b/File_Format_Library/GUI/BFLYT/LayoutEditor.cs index ee540f4e..67602822 100644 --- a/File_Format_Library/GUI/BFLYT/LayoutEditor.cs +++ b/File_Format_Library/GUI/BFLYT/LayoutEditor.cs @@ -248,17 +248,13 @@ namespace LayoutBXLYT private void dockPanel1_ActiveDocumentChanged(object sender, EventArgs e) { - var dockContent = dockPanel1.ActiveDocument as DockContent; - if (dockContent != null && dockContent.Controls.Count > 0) + var dockContent = dockPanel1.ActiveDocument as LayoutViewer; + if (dockContent != null) { - var control = dockContent.Controls[0]; - if (control is LayoutViewer) - { - var file = ((LayoutViewer)control).LayoutFile; - ReloadEditors(file); + var file = (dockContent).LayoutFile; + ReloadEditors(file); - ((LayoutViewer)control).UpdateViewport(); - } + dockContent.UpdateViewport(); } } @@ -283,7 +279,25 @@ namespace LayoutBXLYT if (file is BFLYT) LoadBflyt(((BFLYT)file).header, file.FileName); else if (file is IArchiveFile) - SearchLayoutFiles((IArchiveFile)file); + { + var layouts = SearchLayoutFiles((IArchiveFile)file); + if (layouts.Count > 1) + { + var form = new FileSelector(); + form.LoadLayoutFiles(layouts); + if (form.ShowDialog() == DialogResult.OK) + { + foreach (var index in form.SelectedIndices()) + { + LoadBflyt(layouts[index].header, file.FileName); + } + } + } + else if (layouts.Count > 0) + { + LoadBflyt(layouts[0].header, file.FileName); + } + } else if (file is BFLAN) { @@ -294,8 +308,10 @@ namespace LayoutBXLYT } } - private void SearchLayoutFiles(IArchiveFile archiveFile) + private List SearchLayoutFiles(IArchiveFile archiveFile) { + List layouts = new List(); + foreach (var file in archiveFile.Files) { var fileFormat = STFileLoader.OpenFileFormat(file.FileName, @@ -304,9 +320,7 @@ namespace LayoutBXLYT if (fileFormat is BFLYT) { fileFormat.IFileInfo.ArchiveParent = archiveFile; - - if (fileFormat is BFLYT) - LoadBflyt(((BFLYT)fileFormat).header, file.FileName); + layouts.Add((BFLYT)fileFormat); } else if (Utils.GetExtension(file.FileName) == ".bntx") { @@ -321,9 +335,11 @@ namespace LayoutBXLYT fileFormat.IFileInfo.ArchiveParent = archiveFile; if (fileFormat is IArchiveFile) - SearchLayoutFiles((IArchiveFile)fileFormat); + return SearchLayoutFiles((IArchiveFile)fileFormat); } } + + return layouts; } private void LayoutEditor_DragEnter(object sender, DragEventArgs e)