diff --git a/File_Format_Library/FileFormats/Archives/SARC.cs b/File_Format_Library/FileFormats/Archives/SARC.cs index cf700308..b852708b 100644 --- a/File_Format_Library/FileFormats/Archives/SARC.cs +++ b/File_Format_Library/FileFormats/Archives/SARC.cs @@ -8,6 +8,7 @@ using SARCExt; using Toolbox.Library; using Toolbox.Library.IO; using Toolbox.Library.Forms; +using Toolbox.Library.Security.Cryptography; namespace FirstPlugin { @@ -126,9 +127,13 @@ namespace FirstPlugin foreach (var file in SzsFiles.Files) { string fileName = file.Key; + string Hash = string.Empty; if (SzsFiles.HashOnly) + { fileName = SARCExt.SARC.TryGetNameFromHashTable(fileName); - files.Add(SetupFileEntry(fileName, file.Value)); + Hash = file.Key; + } + files.Add(SetupFileEntry(fileName, file.Value, Hash)); } sarcData.Files.Clear(); @@ -244,8 +249,28 @@ namespace FirstPlugin sarcData.Files.Clear(); foreach (var file in files) { + Console.WriteLine("sarc file name " + file.FileName); file.SaveFileFormat(); - sarcData.Files.Add(file.FileName, file.FileData); + + if (sarcData.HashOnly) + { + sarcData.Files.Add(file.HashName, file.FileData); + + /* + uint hash = 0; + bool IsHash = uint.TryParse(file.FileName, out hash); + if (IsHash && file.FileName.Length == 8) + { + sarcData.Files.Add(file.FileName, file.FileData); + } + else + { + string Hash = Crc32.Compute(file.FileName).ToString(); + sarcData.Files.Add(Hash, file.FileData); + }*/ + } + else + sarcData.Files.Add(file.FileName, file.FileData); } Tuple sarc = SARCExt.SARC.PackN(sarcData); @@ -258,6 +283,8 @@ namespace FirstPlugin { public SARC sarc; //Sarc file the entry is located in + public string HashName; + public SarcEntry() { @@ -279,11 +306,12 @@ namespace FirstPlugin } } - public SarcEntry SetupFileEntry(string fullName, byte[] data) + public SarcEntry SetupFileEntry(string fullName, byte[] data, string HashName) { SarcEntry sarcEntry = new SarcEntry(); sarcEntry.FileName = fullName; sarcEntry.FileData = data; + sarcEntry.HashName = HashName; return sarcEntry; } } diff --git a/File_Format_Library/File_Format_Library.csproj b/File_Format_Library/File_Format_Library.csproj index 6fb95661..448cd057 100644 --- a/File_Format_Library/File_Format_Library.csproj +++ b/File_Format_Library/File_Format_Library.csproj @@ -158,6 +158,7 @@ ..\Toolbox\Lib\Syroot.NintenTools.MarioKart8.dll + False ..\Toolbox\Lib\Syroot.NintenTools.NSW.Bfres.dll @@ -165,6 +166,7 @@ ..\Toolbox\Lib\Syroot.NintenTools.NSW.Bntx.dll + False diff --git a/File_Format_Library/GL/BFRES_Render.cs b/File_Format_Library/GL/BFRES_Render.cs index a039fa30..9d35ec43 100644 --- a/File_Format_Library/GL/BFRES_Render.cs +++ b/File_Format_Library/GL/BFRES_Render.cs @@ -19,7 +19,7 @@ using SF = SFGraphics.GLObjects.Shaders; namespace FirstPlugin { - public class BFRESRender : AbstractGlDrawable + public class BFRESRender : AbstractGlDrawable, IMeshContainer { private bool Disposing = false; @@ -38,6 +38,20 @@ namespace FirstPlugin int vbo_position; int ibo_elements; + public List Meshes + { + get + { + List meshes = new List(); + for (int m =0; m < models.Count; m++) + { + for (int s = 0; s < models[m].shapes.Count; s++) + meshes.Add(models[m].shapes[s]); + } + return meshes; + } + } + private List _models = new List(); public List models { diff --git a/File_Format_Library/GUI/BFRES/Materials/BfresMaterialEditor.Designer.cs b/File_Format_Library/GUI/BFRES/Materials/BfresMaterialEditor.Designer.cs index 391db85c..a784b67f 100644 --- a/File_Format_Library/GUI/BFRES/Materials/BfresMaterialEditor.Designer.cs +++ b/File_Format_Library/GUI/BFRES/Materials/BfresMaterialEditor.Designer.cs @@ -37,8 +37,6 @@ this.stTabControl1 = new Toolbox.Library.Forms.STTabControl(); this.tabPage2 = new System.Windows.Forms.TabPage(); this.samplerEditor1 = new Forms.SamplerEditor(); - this.tabPage1 = new System.Windows.Forms.TabPage(); - this.uvEditor1 = new Toolbox.Library.Forms.UVEditor(); this.tabPage3 = new System.Windows.Forms.TabPage(); this.shaderParamEditor1 = new Forms.ShaderParamEditor(); this.tabPage4 = new System.Windows.Forms.TabPage(); @@ -61,7 +59,6 @@ this.stLabel4 = new Toolbox.Library.Forms.STLabel(); this.stTabControl1.SuspendLayout(); this.tabPage2.SuspendLayout(); - this.tabPage1.SuspendLayout(); this.tabPage3.SuspendLayout(); this.tabPage4.SuspendLayout(); this.tabPage5.SuspendLayout(); @@ -120,7 +117,6 @@ | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.stTabControl1.Controls.Add(this.tabPage2); - this.stTabControl1.Controls.Add(this.tabPage1); this.stTabControl1.Controls.Add(this.tabPage3); this.stTabControl1.Controls.Add(this.tabPage4); this.stTabControl1.Controls.Add(this.tabPage5); @@ -151,27 +147,6 @@ this.samplerEditor1.Size = new System.Drawing.Size(524, 504); this.samplerEditor1.TabIndex = 0; // - // tabPage1 - // - this.tabPage1.Controls.Add(this.uvEditor1); - this.tabPage1.Location = new System.Drawing.Point(4, 25); - this.tabPage1.Name = "tabPage1"; - this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(530, 510); - this.tabPage1.TabIndex = 6; - this.tabPage1.Text = "UV View"; - this.tabPage1.UseVisualStyleBackColor = true; - // - // uvEditor1 - // - this.uvEditor1.Dock = System.Windows.Forms.DockStyle.Fill; - this.uvEditor1.Location = new System.Drawing.Point(3, 3); - this.uvEditor1.Name = "uvEditor1"; - this.uvEditor1.Size = new System.Drawing.Size(524, 504); - this.uvEditor1.TabIndex = 0; - this.uvEditor1.Load += new System.EventHandler(this.uvEditor1_Load); - this.uvEditor1.Click += new System.EventHandler(this.uvEditor1_Click); - // // tabPage3 // this.tabPage3.Controls.Add(this.shaderParamEditor1); @@ -384,7 +359,6 @@ this.Size = new System.Drawing.Size(538, 644); this.stTabControl1.ResumeLayout(false); this.tabPage2.ResumeLayout(false); - this.tabPage1.ResumeLayout(false); this.tabPage3.ResumeLayout(false); this.tabPage4.ResumeLayout(false); this.tabPage5.ResumeLayout(false); @@ -416,8 +390,6 @@ private ShaderParamEditor shaderParamEditor1; private RenderInfoEditor renderInfoEditor1; private ShaderOptionsEditor shaderOptionsEditor1; - private System.Windows.Forms.TabPage tabPage1; - private Toolbox.Library.Forms.UVEditor uvEditor1; private Toolbox.Library.Forms.STLabel stLabel1; private Toolbox.Library.Forms.STButton btnViotileFlags; private Toolbox.Library.Forms.STButton btnSamplerInputEditor; diff --git a/File_Format_Library/GUI/BFRES/Materials/BfresMaterialEditor.cs b/File_Format_Library/GUI/BFRES/Materials/BfresMaterialEditor.cs index cadb5062..7779cfc0 100644 --- a/File_Format_Library/GUI/BFRES/Materials/BfresMaterialEditor.cs +++ b/File_Format_Library/GUI/BFRES/Materials/BfresMaterialEditor.cs @@ -74,43 +74,6 @@ namespace FirstPlugin.Forms chkboxVisible.Bind(material, "Enabled"); FillForm(); - - uvEditor1.ActiveObjects.Clear(); - uvEditor1.Textures.Clear(); - - foreach (var shp in ((FMDL)material.Parent.Parent).shapes) - { - if (shp.GetMaterial().Text == material.Text) - { - uvEditor1.ActiveObjects.Add(shp); - } - } - - foreach (var ftexContainer in PluginRuntime.ftexContainers) - { - foreach (var texmap in material.TextureMaps) - { - if (ftexContainer.ResourceNodes.ContainsKey(texmap.Name)) - { - uvEditor1.Textures.Add(LoadTextureUvMap(texmap, (FTEX)ftexContainer.ResourceNodes[texmap.Name])); - } - } - } - - foreach (var bntx in PluginRuntime.bntxContainers) - { - foreach (var texmap in material.TextureMaps) - { - if (bntx.Textures.ContainsKey(texmap.Name)) - { - uvEditor1.Textures.Add(LoadTextureUvMap(texmap, bntx.Textures[texmap.Name])); - } - } - } - - uvEditor1.Reset(); - uvEditor1.ActiveMaterial = material; - uvEditor1.Refresh(); } private UVEditor.ActiveTexture LoadTextureUvMap(STGenericMatTexture texmap, STGenericTexture genericTexture) { diff --git a/Switch_Toolbox_Library/Forms/Editors/UV/UVEditor.Designer.cs b/Switch_Toolbox_Library/Forms/Editors/UV/UVEditor.Designer.cs index e4be9bf9..cd0e0667 100644 --- a/Switch_Toolbox_Library/Forms/Editors/UV/UVEditor.Designer.cs +++ b/Switch_Toolbox_Library/Forms/Editors/UV/UVEditor.Designer.cs @@ -42,22 +42,27 @@ this.comboBox2 = new Toolbox.Library.Forms.STComboBox(); this.comboBox1 = new Toolbox.Library.Forms.STComboBox(); this.stLabel1 = new Toolbox.Library.Forms.STLabel(); + this.stPanel2 = new Toolbox.Library.Forms.STPanel(); + this.stComboBox1 = new Toolbox.Library.Forms.STComboBox(); + this.splitter1 = new System.Windows.Forms.Splitter(); + this.stPanel3 = new Toolbox.Library.Forms.STPanel(); + this.stButton1 = new Toolbox.Library.Forms.STButton(); ((System.ComponentModel.ISupportInitialize)(this.scaleYUD)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.transYUD)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.transXUD)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.scaleXUD)).BeginInit(); this.stPanel1.SuspendLayout(); + this.stPanel2.SuspendLayout(); + this.stPanel3.SuspendLayout(); this.SuspendLayout(); // // gL_ControlLegacy2D1 // - this.gL_ControlLegacy2D1.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.gL_ControlLegacy2D1.BackColor = System.Drawing.Color.Black; - this.gL_ControlLegacy2D1.Location = new System.Drawing.Point(0, 70); + this.gL_ControlLegacy2D1.Dock = System.Windows.Forms.DockStyle.Fill; + this.gL_ControlLegacy2D1.Location = new System.Drawing.Point(0, 0); this.gL_ControlLegacy2D1.Name = "gL_ControlLegacy2D1"; - this.gL_ControlLegacy2D1.Size = new System.Drawing.Size(605, 454); + this.gL_ControlLegacy2D1.Size = new System.Drawing.Size(443, 454); this.gL_ControlLegacy2D1.TabIndex = 2; this.gL_ControlLegacy2D1.VSync = false; this.gL_ControlLegacy2D1.Paint += new System.Windows.Forms.PaintEventHandler(this.gL_ControlLegacy2D1_Paint); @@ -74,7 +79,7 @@ 0, 0, 196608}); - this.scaleYUD.Location = new System.Drawing.Point(135, 43); + this.scaleYUD.Location = new System.Drawing.Point(75, 32); this.scaleYUD.Maximum = new decimal(new int[] { 1000000000, 0, @@ -98,7 +103,7 @@ 0, 0, 196608}); - this.transYUD.Location = new System.Drawing.Point(360, 43); + this.transYUD.Location = new System.Drawing.Point(75, 102); this.transYUD.Maximum = new decimal(new int[] { 1000000000, 0, @@ -122,7 +127,7 @@ 0, 0, 196608}); - this.transXUD.Location = new System.Drawing.Point(281, 43); + this.transXUD.Location = new System.Drawing.Point(5, 102); this.transXUD.Maximum = new decimal(new int[] { 1000000000, 0, @@ -141,7 +146,7 @@ // stLabel4 // this.stLabel4.AutoSize = true; - this.stLabel4.Location = new System.Drawing.Point(205, 45); + this.stLabel4.Location = new System.Drawing.Point(3, 66); this.stLabel4.Name = "stLabel4"; this.stLabel4.Size = new System.Drawing.Size(51, 13); this.stLabel4.TabIndex = 5; @@ -150,7 +155,7 @@ // stLabel3 // this.stLabel3.AutoSize = true; - this.stLabel3.Location = new System.Drawing.Point(25, 45); + this.stLabel3.Location = new System.Drawing.Point(3, 11); this.stLabel3.Name = "stLabel3"; this.stLabel3.Size = new System.Drawing.Size(34, 13); this.stLabel3.TabIndex = 4; @@ -164,7 +169,7 @@ 0, 0, 196608}); - this.scaleXUD.Location = new System.Drawing.Point(65, 43); + this.scaleXUD.Location = new System.Drawing.Point(5, 32); this.scaleXUD.Maximum = new decimal(new int[] { 1000000000, 0, @@ -182,17 +187,11 @@ // // stPanel1 // - this.stPanel1.Controls.Add(this.btnApplyTransform); - this.stPanel1.Controls.Add(this.scaleYUD); + this.stPanel1.Controls.Add(this.stComboBox1); this.stPanel1.Controls.Add(this.barSlider1); - this.stPanel1.Controls.Add(this.transYUD); this.stPanel1.Controls.Add(this.stLabel2); - this.stPanel1.Controls.Add(this.transXUD); this.stPanel1.Controls.Add(this.comboBox2); - this.stPanel1.Controls.Add(this.stLabel4); this.stPanel1.Controls.Add(this.comboBox1); - this.stPanel1.Controls.Add(this.stLabel3); - this.stPanel1.Controls.Add(this.scaleXUD); this.stPanel1.Controls.Add(this.stLabel1); this.stPanel1.Dock = System.Windows.Forms.DockStyle.Top; this.stPanel1.Location = new System.Drawing.Point(0, 0); @@ -203,7 +202,7 @@ // btnApplyTransform // this.btnApplyTransform.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnApplyTransform.Location = new System.Drawing.Point(430, 41); + this.btnApplyTransform.Location = new System.Drawing.Point(3, 138); this.btnApplyTransform.Name = "btnApplyTransform"; this.btnApplyTransform.Size = new System.Drawing.Size(119, 23); this.btnApplyTransform.TabIndex = 9; @@ -243,7 +242,8 @@ this.barSlider1.TickDivide = 0F; this.barSlider1.TickStyle = System.Windows.Forms.TickStyle.None; this.barSlider1.ValueChanged += new System.EventHandler(this.barSlider1_ValueChanged); - this.barSlider1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.barSlider1_Scroll);// + this.barSlider1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.barSlider1_Scroll); + // // stLabel2 // this.stLabel2.AutoSize = true; @@ -255,13 +255,13 @@ // // comboBox2 // - this.comboBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.comboBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.comboBox2.BorderColor = System.Drawing.Color.Empty; this.comboBox2.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid; this.comboBox2.ButtonColor = System.Drawing.Color.Empty; this.comboBox2.FormattingEnabled = true; - this.comboBox2.Location = new System.Drawing.Point(290, 7); + this.comboBox2.Location = new System.Drawing.Point(290, 34); this.comboBox2.Name = "comboBox2"; this.comboBox2.ReadOnly = true; this.comboBox2.Size = new System.Drawing.Size(166, 21); @@ -292,11 +292,70 @@ this.stLabel1.TabIndex = 4; this.stLabel1.Text = "Active Channel:"; // + // stPanel2 + // + this.stPanel2.Controls.Add(this.stButton1); + this.stPanel2.Controls.Add(this.btnApplyTransform); + this.stPanel2.Controls.Add(this.stLabel3); + this.stPanel2.Controls.Add(this.scaleYUD); + this.stPanel2.Controls.Add(this.transYUD); + this.stPanel2.Controls.Add(this.scaleXUD); + this.stPanel2.Controls.Add(this.transXUD); + this.stPanel2.Controls.Add(this.stLabel4); + this.stPanel2.Dock = System.Windows.Forms.DockStyle.Left; + this.stPanel2.Location = new System.Drawing.Point(0, 70); + this.stPanel2.Name = "stPanel2"; + this.stPanel2.Size = new System.Drawing.Size(159, 454); + this.stPanel2.TabIndex = 3; + // + // stComboBox1 + // + this.stComboBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.stComboBox1.BorderColor = System.Drawing.Color.Empty; + this.stComboBox1.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid; + this.stComboBox1.ButtonColor = System.Drawing.Color.Empty; + this.stComboBox1.FormattingEnabled = true; + this.stComboBox1.Location = new System.Drawing.Point(290, 7); + this.stComboBox1.Name = "stComboBox1"; + this.stComboBox1.ReadOnly = true; + this.stComboBox1.Size = new System.Drawing.Size(166, 21); + this.stComboBox1.TabIndex = 19; + // + // splitter1 + // + this.splitter1.Location = new System.Drawing.Point(159, 70); + this.splitter1.Name = "splitter1"; + this.splitter1.Size = new System.Drawing.Size(3, 454); + this.splitter1.TabIndex = 4; + this.splitter1.TabStop = false; + // + // stPanel3 + // + this.stPanel3.Controls.Add(this.gL_ControlLegacy2D1); + this.stPanel3.Dock = System.Windows.Forms.DockStyle.Fill; + this.stPanel3.Location = new System.Drawing.Point(162, 70); + this.stPanel3.Name = "stPanel3"; + this.stPanel3.Size = new System.Drawing.Size(443, 454); + this.stPanel3.TabIndex = 5; + // + // stButton1 + // + this.stButton1.Dock = System.Windows.Forms.DockStyle.Right; + this.stButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.stButton1.Location = new System.Drawing.Point(145, 0); + this.stButton1.Name = "stButton1"; + this.stButton1.Size = new System.Drawing.Size(14, 454); + this.stButton1.TabIndex = 10; + this.stButton1.UseVisualStyleBackColor = false; + // // UVEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.gL_ControlLegacy2D1); + this.Controls.Add(this.stPanel3); + this.Controls.Add(this.splitter1); + this.Controls.Add(this.stPanel2); this.Controls.Add(this.stPanel1); this.Name = "UVEditor"; this.Size = new System.Drawing.Size(605, 524); @@ -306,6 +365,9 @@ ((System.ComponentModel.ISupportInitialize)(this.scaleXUD)).EndInit(); this.stPanel1.ResumeLayout(false); this.stPanel1.PerformLayout(); + this.stPanel2.ResumeLayout(false); + this.stPanel2.PerformLayout(); + this.stPanel3.ResumeLayout(false); this.ResumeLayout(false); } @@ -325,5 +387,10 @@ private NumericUpDownFloat scaleYUD; private ColorSlider.ColorSlider barSlider1; private STButton btnApplyTransform; + private STPanel stPanel2; + private STComboBox stComboBox1; + private System.Windows.Forms.Splitter splitter1; + private STPanel stPanel3; + private STButton stButton1; } } \ No newline at end of file diff --git a/Switch_Toolbox_Library/Forms/Editors/UV/UVEditor.cs b/Switch_Toolbox_Library/Forms/Editors/UV/UVEditor.cs index 71e136c3..cdb07f5f 100644 --- a/Switch_Toolbox_Library/Forms/Editors/UV/UVEditor.cs +++ b/Switch_Toolbox_Library/Forms/Editors/UV/UVEditor.cs @@ -46,9 +46,9 @@ namespace Toolbox.Library.Forms public float brightness = 0.5f; //To see uv maps easier public int UvChannelIndex = 0; - public STGenericMaterial ActiveMaterial; public List ActiveObjects = new List(); + public List ActiveMaterials = new List(); public List Textures = new List(); @@ -241,7 +241,7 @@ namespace Toolbox.Library.Forms private void gL_ControlLegacy2D1_Paint(object sender, PaintEventArgs e) { - if (ActiveObjects.Count <= 0 || ActiveMaterial == null || Runtime.OpenTKInitialized == false) + if (!Runtime.OpenTKInitialized) return; gL_ControlLegacy2D1.MakeCurrent(); @@ -289,7 +289,8 @@ namespace Toolbox.Library.Forms //Params include Amount to repeat DrawTexturedPlane(5); - DrawUVs(ActiveObjects); + if (ActiveObjects.Count > 0) + DrawUVs(ActiveObjects); GL.PopMatrix(); diff --git a/Switch_Toolbox_Library/Forms/Editors/UV/UVEditorForm.Designer.cs b/Switch_Toolbox_Library/Forms/Editors/UV/UVEditorForm.Designer.cs new file mode 100644 index 00000000..3ff75f43 --- /dev/null +++ b/Switch_Toolbox_Library/Forms/Editors/UV/UVEditorForm.Designer.cs @@ -0,0 +1,68 @@ +namespace Toolbox.Library.Forms +{ + partial class UVEditorForm + { + /// + /// 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 Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.uvEditor1 = new Toolbox.Library.Forms.UVEditor(); + this.contentContainer.SuspendLayout(); + this.SuspendLayout(); + // + // contentContainer + // + this.contentContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left))); + this.contentContainer.Controls.Add(this.uvEditor1); + this.contentContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.contentContainer.Location = new System.Drawing.Point(0, 0); + this.contentContainer.Size = new System.Drawing.Size(595, 468); + this.contentContainer.Controls.SetChildIndex(this.uvEditor1, 0); + // + // uvEditor1 + // + this.uvEditor1.Dock = System.Windows.Forms.DockStyle.Fill; + this.uvEditor1.Location = new System.Drawing.Point(0, 25); + this.uvEditor1.Name = "uvEditor1"; + this.uvEditor1.Size = new System.Drawing.Size(595, 443); + this.uvEditor1.TabIndex = 11; + // + // UVEditorForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(595, 468); + this.Name = "UVEditorForm"; + this.Text = "UV Editor"; + this.contentContainer.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private UVEditor uvEditor1; + } +} \ No newline at end of file diff --git a/Switch_Toolbox_Library/Forms/Editors/UV/UVEditorForm.cs b/Switch_Toolbox_Library/Forms/Editors/UV/UVEditorForm.cs new file mode 100644 index 00000000..066cab32 --- /dev/null +++ b/Switch_Toolbox_Library/Forms/Editors/UV/UVEditorForm.cs @@ -0,0 +1,38 @@ +using System; +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.Windows.Forms; + +namespace Toolbox.Library.Forms +{ + public partial class UVEditorForm : STForm + { + public UVEditorForm() + { + InitializeComponent(); + } + + public void LoadEditor(List Meshes) + { + List materials = new List(); + for (int i =0; i < Meshes.Count; i++) + { + if (Meshes[i].GetMaterial() != null) + { + materials.Add(Meshes[i].GetMaterial()); + } + } + + uvEditor1.ActiveObjects = Meshes; + uvEditor1.ActiveMaterials = materials; + uvEditor1.Textures.Clear(); + uvEditor1.Reset(); + uvEditor1.Refresh(); + } + } +} diff --git a/Switch_Toolbox_Library/Forms/Editors/UV/UVEditorForm.resx b/Switch_Toolbox_Library/Forms/Editors/UV/UVEditorForm.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/Switch_Toolbox_Library/Forms/Editors/UV/UVEditorForm.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/Switch_Toolbox_Library/Forms/Viewport.Designer.cs b/Switch_Toolbox_Library/Forms/Viewport.Designer.cs index 77ce5998..8a98422b 100644 --- a/Switch_Toolbox_Library/Forms/Viewport.Designer.cs +++ b/Switch_Toolbox_Library/Forms/Viewport.Designer.cs @@ -29,6 +29,9 @@ private void InitializeComponent() { this.normalsShadingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.stPanel1 = new Toolbox.Library.Forms.STPanel(); + this.chkDisplayAllModels = new Toolbox.Library.Forms.STCheckBox(); + this.stLabel1 = new Toolbox.Library.Forms.STLabel(); this.drawContainersCB = new Toolbox.Library.Forms.STComboBox(); this.panelViewport = new Toolbox.Library.Forms.STPanel(); this.stContextMenuStrip1 = new Toolbox.Library.Forms.STMenuStrip(); @@ -51,11 +54,9 @@ this.resetPoseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.reloadShadersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.stPanel1 = new Toolbox.Library.Forms.STPanel(); - this.stLabel1 = new Toolbox.Library.Forms.STLabel(); - this.chkDisplayAllModels = new Toolbox.Library.Forms.STCheckBox(); - this.stContextMenuStrip1.SuspendLayout(); + this.uVViewerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.stPanel1.SuspendLayout(); + this.stContextMenuStrip1.SuspendLayout(); this.SuspendLayout(); // // normalsShadingToolStripMenuItem @@ -68,6 +69,38 @@ this.normalsShadingToolStripMenuItem.Text = "Normals Shading"; this.normalsShadingToolStripMenuItem.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; // + // stPanel1 + // + this.stPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.stPanel1.Controls.Add(this.chkDisplayAllModels); + this.stPanel1.Controls.Add(this.stLabel1); + this.stPanel1.Controls.Add(this.drawContainersCB); + this.stPanel1.Location = new System.Drawing.Point(0, 26); + this.stPanel1.Name = "stPanel1"; + this.stPanel1.Size = new System.Drawing.Size(778, 24); + this.stPanel1.TabIndex = 5; + // + // chkDisplayAllModels + // + this.chkDisplayAllModels.AutoSize = true; + this.chkDisplayAllModels.Location = new System.Drawing.Point(282, 2); + this.chkDisplayAllModels.Name = "chkDisplayAllModels"; + this.chkDisplayAllModels.Size = new System.Drawing.Size(74, 17); + this.chkDisplayAllModels.TabIndex = 2; + this.chkDisplayAllModels.Text = "Display All"; + this.chkDisplayAllModels.UseVisualStyleBackColor = true; + this.chkDisplayAllModels.CheckedChanged += new System.EventHandler(this.chkDisplayAllModels_CheckedChanged); + // + // stLabel1 + // + this.stLabel1.AutoSize = true; + this.stLabel1.Location = new System.Drawing.Point(3, 3); + this.stLabel1.Name = "stLabel1"; + this.stLabel1.Size = new System.Drawing.Size(83, 13); + this.stLabel1.TabIndex = 1; + this.stLabel1.Text = "Active Model(s):"; + // // drawContainersCB // this.drawContainersCB.BorderColor = System.Drawing.Color.Empty; @@ -99,7 +132,8 @@ this.shadingToolStripMenuItem, this.resetCameraToolStripMenuItem, this.resetPoseToolStripMenuItem, - this.optionsToolStripMenuItem}); + this.optionsToolStripMenuItem, + this.uVViewerToolStripMenuItem}); this.stContextMenuStrip1.Location = new System.Drawing.Point(0, 0); this.stContextMenuStrip1.Name = "stContextMenuStrip1"; this.stContextMenuStrip1.Size = new System.Drawing.Size(781, 24); @@ -249,41 +283,16 @@ // reloadShadersToolStripMenuItem // this.reloadShadersToolStripMenuItem.Name = "reloadShadersToolStripMenuItem"; - this.reloadShadersToolStripMenuItem.Size = new System.Drawing.Size(154, 22); + this.reloadShadersToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.reloadShadersToolStripMenuItem.Text = "Reload Shaders"; this.reloadShadersToolStripMenuItem.Click += new System.EventHandler(this.reloadShadersToolStripMenuItem_Click); // - // stPanel1 + // uVViewerToolStripMenuItem // - this.stPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.stPanel1.Controls.Add(this.chkDisplayAllModels); - this.stPanel1.Controls.Add(this.stLabel1); - this.stPanel1.Controls.Add(this.drawContainersCB); - this.stPanel1.Location = new System.Drawing.Point(0, 26); - this.stPanel1.Name = "stPanel1"; - this.stPanel1.Size = new System.Drawing.Size(778, 24); - this.stPanel1.TabIndex = 5; - // - // stLabel1 - // - this.stLabel1.AutoSize = true; - this.stLabel1.Location = new System.Drawing.Point(3, 3); - this.stLabel1.Name = "stLabel1"; - this.stLabel1.Size = new System.Drawing.Size(83, 13); - this.stLabel1.TabIndex = 1; - this.stLabel1.Text = "Active Model(s):"; - // - // chkDisplayAllModels - // - this.chkDisplayAllModels.AutoSize = true; - this.chkDisplayAllModels.Location = new System.Drawing.Point(282, 2); - this.chkDisplayAllModels.Name = "chkDisplayAllModels"; - this.chkDisplayAllModels.Size = new System.Drawing.Size(74, 17); - this.chkDisplayAllModels.TabIndex = 2; - this.chkDisplayAllModels.Text = "Display All"; - this.chkDisplayAllModels.UseVisualStyleBackColor = true; - this.chkDisplayAllModels.CheckedChanged += new System.EventHandler(this.chkDisplayAllModels_CheckedChanged); + this.uVViewerToolStripMenuItem.Name = "uVViewerToolStripMenuItem"; + this.uVViewerToolStripMenuItem.Size = new System.Drawing.Size(72, 20); + this.uVViewerToolStripMenuItem.Text = "UV Viewer"; + this.uVViewerToolStripMenuItem.Click += new System.EventHandler(this.uVViewerToolStripMenuItem_Click); // // Viewport // @@ -295,10 +304,10 @@ this.Controls.Add(this.stContextMenuStrip1); this.Name = "Viewport"; this.Size = new System.Drawing.Size(781, 522); - this.stContextMenuStrip1.ResumeLayout(false); - this.stContextMenuStrip1.PerformLayout(); this.stPanel1.ResumeLayout(false); this.stPanel1.PerformLayout(); + this.stContextMenuStrip1.ResumeLayout(false); + this.stContextMenuStrip1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -331,5 +340,6 @@ private Forms.STPanel stPanel1; private Forms.STLabel stLabel1; private Forms.STCheckBox chkDisplayAllModels; + private System.Windows.Forms.ToolStripMenuItem uVViewerToolStripMenuItem; } } \ No newline at end of file diff --git a/Switch_Toolbox_Library/Forms/Viewport.cs b/Switch_Toolbox_Library/Forms/Viewport.cs index 2e72337a..a6faa042 100644 --- a/Switch_Toolbox_Library/Forms/Viewport.cs +++ b/Switch_Toolbox_Library/Forms/Viewport.cs @@ -90,6 +90,14 @@ namespace Toolbox.Library } } + public DrawableContainer GetActiveContainer() + { + if (drawContainersCB.SelectedIndex - 1 < 0) + return null; + + return DrawableContainers[drawContainersCB.SelectedIndex - 1]; + } + //Reloads drawable containers with the active container selected public void ReloadDrawables(DrawableContainer ActiveContainer) { @@ -546,5 +554,33 @@ namespace Toolbox.Library DrawAllActive(); } } + + private void uVViewerToolStripMenuItem_Click(object sender, EventArgs e) + { + if (!Runtime.UseOpenGL) + return; + + var container = GetActiveContainer(); + if (container == null) return; + + List meshes = new List(); + for (int i = 0; i < container.Drawables.Count; i++) + { + if (container.Drawables[i] is IMeshContainer) + { + for (int m = 0; m < ((IMeshContainer)container.Drawables[i]).Meshes.Count; m++) + meshes.Add(((IMeshContainer)container.Drawables[i]).Meshes[m]); + } + } + + Console.WriteLine($"MeshCount " + meshes.Count); + + if (meshes.Count > 0) + { + UVEditorForm uvEditor1 = new UVEditorForm(); + uvEditor1.LoadEditor(meshes); + uvEditor1.Show(); + } + } } } diff --git a/Switch_Toolbox_Library/IO/Extensions/IOExtensions.cs b/Switch_Toolbox_Library/IO/Extensions/IOExtensions.cs index 635d08b6..afa99966 100644 --- a/Switch_Toolbox_Library/IO/Extensions/IOExtensions.cs +++ b/Switch_Toolbox_Library/IO/Extensions/IOExtensions.cs @@ -4,7 +4,7 @@ using System.Text; using System.IO; using System.Threading.Tasks; using System.Text.RegularExpressions; -using System.Security.Cryptography; +using Toolbox.Library.Security.Cryptography; namespace Toolbox.Library.IO { diff --git a/Switch_Toolbox_Library/Interfaces/IArchiveFile.cs b/Switch_Toolbox_Library/Interfaces/IArchiveFile.cs index 7e322dcf..85643bd5 100644 --- a/Switch_Toolbox_Library/Interfaces/IArchiveFile.cs +++ b/Switch_Toolbox_Library/Interfaces/IArchiveFile.cs @@ -251,14 +251,17 @@ namespace Toolbox.Library for (int i = 0; i < FileNodes.Count; i++) { - FileNodes[i].Item1.FileName = SetFullPath(FileNodes[i].Item2, this); + string NewName = SetFullPath(FileNodes[i].Item2, this); + if (NewName != string.Empty) + FileNodes[i].Item1.FileName = NewName; } } private static string SetFullPath(TreeNode node, TreeNode root) { - if (node.TreeView == null) - return node.Text; + if (node.TreeView == null) { + return string.Empty; + } string nodePath = node.FullPath; int startIndex = nodePath.IndexOf(root.Text); @@ -269,7 +272,11 @@ namespace Toolbox.Library string slashAlt = Path.AltDirectorySeparatorChar.ToString(); string SetPath = nodePath.Replace(root.Text + slash, string.Empty).Replace(slash ?? "", slashAlt); - return !(SetPath == string.Empty) ? SetPath : node.Text; + + Console.WriteLine($"FullPath { node.FullPath}"); + Console.WriteLine($"SetPath {SetPath}"); + + return SetPath; } private void EnableContextMenu(ToolStripItemCollection Items, string Key, bool Enabled) @@ -286,7 +293,7 @@ namespace Toolbox.Library Save("", true); } - public void Save(string FileName, bool UseDialog) + private void Save(string FileName, bool UseDialog) { UpdateFileNames(); @@ -882,12 +889,13 @@ namespace Toolbox.Library node.Nodes.RemoveAt(index); node.Nodes.Insert(index, NewNode); - rootNode.FileNodes.RemoveAt(index); - rootNode.FileNodes.Insert(index, Tuple.Create(fileInfo, NewNode)); NewNode.ImageKey = replaceNode.ImageKey; NewNode.SelectedImageKey = replaceNode.SelectedImageKey; NewNode.Text = replaceNode.Text; + + rootNode.FileNodes.RemoveAt(index); + rootNode.FileNodes.Insert(index, Tuple.Create(fileInfo, NewNode)); } private void RenameAction(object sender, EventArgs args) diff --git a/Switch_Toolbox_Library/Interfaces/IMeshContainer.cs b/Switch_Toolbox_Library/Interfaces/IMeshContainer.cs new file mode 100644 index 00000000..bc708705 --- /dev/null +++ b/Switch_Toolbox_Library/Interfaces/IMeshContainer.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Toolbox.Library +{ + public interface IMeshContainer + { + List Meshes { get; } + } +} diff --git a/Switch_Toolbox_Library/Security/Cryptography/crc32.cs b/Switch_Toolbox_Library/Security/Cryptography/crc32.cs index c2240717..17316888 100644 --- a/Switch_Toolbox_Library/Security/Cryptography/crc32.cs +++ b/Switch_Toolbox_Library/Security/Cryptography/crc32.cs @@ -5,7 +5,7 @@ using System.Text; -namespace System.Security.Cryptography +namespace Toolbox.Library.Security.Cryptography { /// /// Computes a CRC32 checksum. diff --git a/Switch_Toolbox_Library/Toolbox_Library.csproj b/Switch_Toolbox_Library/Toolbox_Library.csproj index bbf2ceee..ee82108b 100644 --- a/Switch_Toolbox_Library/Toolbox_Library.csproj +++ b/Switch_Toolbox_Library/Toolbox_Library.csproj @@ -213,6 +213,12 @@ + + Form + + + UVEditorForm.cs + UserControl @@ -225,6 +231,7 @@ SceneSelector.cs + @@ -908,6 +915,9 @@ UVEditor2.cs + + UVEditorForm.cs + FileTableViewTPHD.cs diff --git a/Toolbox/Program.cs b/Toolbox/Program.cs index 2f81cb4c..ab764a6b 100644 --- a/Toolbox/Program.cs +++ b/Toolbox/Program.cs @@ -54,6 +54,24 @@ namespace Toolbox Application.Run(form); } + private static bool TryLoadZSTD() + { + try + { + String folder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + String filePath = Path.Combine(folder, Environment.Is64BitProcess ? "x64" : "x86", "libzstd.dll"); + if (File.Exists(filePath)) + { + Assembly assembly = Assembly.LoadFile(filePath); + return true; + } + } + catch (Exception ex) + { + } + return false; + } + private static bool TryLoadDirectXTex() { try diff --git a/Toolbox/Toolbox.csproj b/Toolbox/Toolbox.csproj index 3b26e7eb..c51b19e9 100644 --- a/Toolbox/Toolbox.csproj +++ b/Toolbox/Toolbox.csproj @@ -315,9 +315,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest @@ -507,6 +504,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + diff --git a/Toolbox/x64/libzstd.dll b/Toolbox/x64/libzstd.dll new file mode 100644 index 00000000..a836692f Binary files /dev/null and b/Toolbox/x64/libzstd.dll differ diff --git a/Toolbox/libzstd.dll b/Toolbox/x86/libzstd.dll similarity index 100% rename from Toolbox/libzstd.dll rename to Toolbox/x86/libzstd.dll