mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-26 06:20:24 +00:00
Add layout file list for dragged archives to editor
This commit is contained in:
parent
7724a056f5
commit
7e7afc6377
5 changed files with 302 additions and 15 deletions
|
@ -315,6 +315,12 @@
|
|||
<Compile Include="GL\GXToOpenGL.cs" />
|
||||
<Compile Include="GL\KCL_Render.cs" />
|
||||
<Compile Include="GL\LM2_Render.cs" />
|
||||
<Compile Include="GUI\BFLYT\FileSelector.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GUI\BFLYT\FileSelector.Designer.cs">
|
||||
<DependentUpon>FileSelector.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GUI\BFLYT\LayoutHierarchy.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
|
@ -1099,6 +1105,9 @@
|
|||
<EmbeddedResource Include="GUI\BFFNT\BffntEditor.resx">
|
||||
<DependentUpon>BffntEditor.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="GUI\BFLYT\FileSelector.resx">
|
||||
<DependentUpon>FileSelector.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="GUI\BFLYT\LayoutEditor.resx">
|
||||
<DependentUpon>LayoutEditor.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
|
96
File_Format_Library/GUI/BFLYT/FileSelector.Designer.cs
generated
Normal file
96
File_Format_Library/GUI/BFLYT/FileSelector.Designer.cs
generated
Normal file
|
@ -0,0 +1,96 @@
|
|||
namespace LayoutBXLYT
|
||||
{
|
||||
partial class FileSelector
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
46
File_Format_Library/GUI/BFLYT/FileSelector.cs
Normal file
46
File_Format_Library/GUI/BFLYT/FileSelector.cs
Normal file
|
@ -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<int> SelectedIndices()
|
||||
{
|
||||
List<int> indices = new List<int>();
|
||||
foreach (int index in listViewCustom1.SelectedIndices)
|
||||
indices.Add(index);
|
||||
|
||||
return indices;
|
||||
}
|
||||
|
||||
public void LoadLayoutFiles(List<BFLYT> layoutFiles)
|
||||
{
|
||||
listViewCustom1.BeginUpdate();
|
||||
foreach (var file in layoutFiles)
|
||||
listViewCustom1.Items.Add(file.FileName);
|
||||
listViewCustom1.EndUpdate();
|
||||
}
|
||||
|
||||
private void listViewCustom1_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
120
File_Format_Library/GUI/BFLYT/FileSelector.resx
Normal file
120
File_Format_Library/GUI/BFLYT/FileSelector.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -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<BFLYT> SearchLayoutFiles(IArchiveFile archiveFile)
|
||||
{
|
||||
List<BFLYT> layouts = new List<BFLYT>();
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue