diff --git a/Project/Panels/EditProjectManifestPanel.Designer.cs b/Project/Panels/EditProjectManifestPanel.Designer.cs index 27ceb93..81fc0f4 100644 --- a/Project/Panels/EditProjectManifestPanel.Designer.cs +++ b/Project/Panels/EditProjectManifestPanel.Designer.cs @@ -30,21 +30,13 @@ { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditProjectManifestPanel)); - this.label162 = new System.Windows.Forms.Label(); this.ProjectManifestGenerateButton = new System.Windows.Forms.Button(); this.ProjectManifestTextBox = new FastColoredTextBoxNS.FastColoredTextBox(); + this.SaveManifestButton = new System.Windows.Forms.Button(); + this.SaveFileDialog = new System.Windows.Forms.SaveFileDialog(); ((System.ComponentModel.ISupportInitialize)(this.ProjectManifestTextBox)).BeginInit(); this.SuspendLayout(); // - // label162 - // - this.label162.AutoSize = true; - this.label162.Location = new System.Drawing.Point(96, 7); - this.label162.Name = "label162"; - this.label162.Size = new System.Drawing.Size(111, 13); - this.label162.TabIndex = 5; - this.label162.Text = "XML for _manifest.ymf"; - // // ProjectManifestGenerateButton // this.ProjectManifestGenerateButton.Location = new System.Drawing.Point(3, 2); @@ -95,27 +87,41 @@ this.ProjectManifestTextBox.TabIndex = 3; this.ProjectManifestTextBox.Zoom = 100; // - // ProjectManifestPanel + // SaveManifestButton + // + this.SaveManifestButton.Location = new System.Drawing.Point(94, 2); + this.SaveManifestButton.Name = "SaveManifestButton"; + this.SaveManifestButton.Size = new System.Drawing.Size(113, 23); + this.SaveManifestButton.TabIndex = 6; + this.SaveManifestButton.Text = "Save _manifest.ymf"; + this.SaveManifestButton.UseVisualStyleBackColor = true; + this.SaveManifestButton.Click += new System.EventHandler(this.SaveManifestButton_Click); + // + // SaveFileDialog + // + this.SaveFileDialog.FileName = "_manifest.ymf"; + this.SaveFileDialog.Filter = "Manifest files|*.ymf"; + // + // EditProjectManifestPanel // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(605, 451); - this.Controls.Add(this.label162); + this.Controls.Add(this.SaveManifestButton); this.Controls.Add(this.ProjectManifestGenerateButton); this.Controls.Add(this.ProjectManifestTextBox); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Name = "ProjectManifestPanel"; + this.Name = "EditProjectManifestPanel"; this.Text = "_manifest.ymf"; ((System.ComponentModel.ISupportInitialize)(this.ProjectManifestTextBox)).EndInit(); this.ResumeLayout(false); - this.PerformLayout(); } #endregion - - private System.Windows.Forms.Label label162; private System.Windows.Forms.Button ProjectManifestGenerateButton; private FastColoredTextBoxNS.FastColoredTextBox ProjectManifestTextBox; + private System.Windows.Forms.Button SaveManifestButton; + private System.Windows.Forms.SaveFileDialog SaveFileDialog; } } \ No newline at end of file diff --git a/Project/Panels/EditProjectManifestPanel.cs b/Project/Panels/EditProjectManifestPanel.cs index a253983..60acbb9 100644 --- a/Project/Panels/EditProjectManifestPanel.cs +++ b/Project/Panels/EditProjectManifestPanel.cs @@ -4,10 +4,12 @@ using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using System.Xml; using WeifenLuo.WinFormsUI.Docking; namespace CodeWalker.Project.Panels @@ -87,46 +89,113 @@ namespace CodeWalker.Project.Panels }); - if ((CurrentProjectFile != null) && (CurrentProjectFile.YmapFiles.Count > 0)) + if (CurrentProjectFile != null) { - sb.AppendLine(" "); - foreach (var ymap in CurrentProjectFile.YmapFiles) + if (CurrentProjectFile.YmapFiles.Count > 0) { - var ymapname = ymap.RpfFileEntry?.NameLower; - if (string.IsNullOrEmpty(ymapname)) + sb.AppendLine(" "); + foreach (var ymap in CurrentProjectFile.YmapFiles) { - ymapname = ymap.Name.ToLowerInvariant(); - } - if (ymapname.EndsWith(".ymap")) - { - ymapname = ymapname.Substring(0, ymapname.Length - 5); - } - - mapdeps.Clear(); - if (ymap.AllEntities != null) - { - foreach (var ent in ymap.AllEntities) + var ymapname = ymap.RpfFileEntry?.NameLower; + if (string.IsNullOrEmpty(ymapname)) { - var ytyp = ent.Archetype?.Ytyp; - var ytypname = getYtypName(ytyp); - if (ytyp != null) - { - mapdeps[ytypname] = ytyp; - } + ymapname = ymap.Name.ToLowerInvariant(); + } + if (ymapname.EndsWith(".ymap")) + { + ymapname = ymapname.Substring(0, ymapname.Length - 5); + } - if (ent.IsMlo) + mapdeps.Clear(); + if (ymap.AllEntities != null) + { + foreach (var ent in ymap.AllEntities) { - if (ent.MloInstance?.Entities != null) + var ytyp = ent.Archetype?.Ytyp; + var ytypname = getYtypName(ytyp); + if (ytyp != null) { - Dictionary typdepdict; - if (!typdeps.TryGetValue(ytypname, out typdepdict)) + mapdeps[ytypname] = ytyp; + } + + if (ent.IsMlo) + { + if (ent.MloInstance?.Entities != null) { - typdepdict = new Dictionary(); - typdeps[ytypname] = typdepdict; + Dictionary typdepdict; + if (!typdeps.TryGetValue(ytypname, out typdepdict)) + { + typdepdict = new Dictionary(); + typdeps[ytypname] = typdepdict; + } + foreach (var ient in ent.MloInstance.Entities) + { + var iytyp = ient.Archetype?.Ytyp; + var iytypname = getYtypName(iytyp); + if ((iytyp != null) && (iytypname != ytypname)) + { + typdepdict[iytypname] = iytyp; + } + } } - foreach (var ient in ent.MloInstance.Entities) + } + + } + } + if (ymap.GrassInstanceBatches != null) + { + foreach (var batch in ymap.GrassInstanceBatches) + { + var ytyp = batch.Archetype?.Ytyp; + var ytypname = getYtypName(ytyp); + if (ytyp != null) + { + mapdeps[ytypname] = ytyp; + } + } + } + + sb.AppendLine(" "); + sb.AppendLine(" " + ymapname + ""); + sb.AppendLine(" "); + sb.AppendLine(" "); + foreach (var kvp in mapdeps) + { + sb.AppendLine(" " + kvp.Key + ""); + } + sb.AppendLine(" "); + sb.AppendLine(" "); + } + sb.AppendLine(" "); + } + else + { + sb.AppendLine(" "); + } + + if ((CurrentProjectFile.YtypFiles.Count > 0) && (ProjectForm?.GameFileCache != null)) + { + foreach (var ytyp in CurrentProjectFile.YtypFiles) + { + var ytypname = getYtypName(ytyp); + foreach (var archm in ytyp.AllArchetypes) + { + var mloa = archm as MloArchetype; + if (mloa != null) + { + Dictionary typdepdict; + if (!typdeps.TryGetValue(ytypname, out typdepdict)) + { + typdepdict = new Dictionary(); + typdeps[ytypname] = typdepdict; + } + if (mloa.entities != null) + { + foreach (var ent in mloa.entities) { - var iytyp = ient.Archetype?.Ytyp; + var archname = ent._Data.archetypeName; + var arch = ProjectForm.GameFileCache.GetArchetype(archname); + var iytyp = arch?.Ytyp; var iytypname = getYtypName(iytyp); if ((iytyp != null) && (iytypname != ytypname)) { @@ -134,39 +203,31 @@ namespace CodeWalker.Project.Panels } } } - } - - } - } - if (ymap.GrassInstanceBatches != null) - { - foreach (var batch in ymap.GrassInstanceBatches) - { - var ytyp = batch.Archetype?.Ytyp; - var ytypname = getYtypName(ytyp); - if (ytyp != null) - { - mapdeps[ytypname] = ytyp; + if (mloa.entitySets != null) + { + foreach (var entset in mloa.entitySets) + { + if (entset.Entities != null) + { + foreach (var ent in entset.Entities) + { + var archname = ent._Data.archetypeName; + var arch = ProjectForm.GameFileCache.GetArchetype(archname); + var iytyp = arch?.Ytyp; + var iytypname = getYtypName(iytyp); + if ((iytyp != null) && (iytypname != ytypname)) + { + typdepdict[iytypname] = iytyp; + } + } + } + } + } } } } - - sb.AppendLine(" "); - sb.AppendLine(" " + ymapname + ""); - sb.AppendLine(" "); - sb.AppendLine(" "); - foreach (var kvp in mapdeps) - { - sb.AppendLine(" " + kvp.Key + ""); - } - sb.AppendLine(" "); - sb.AppendLine(" "); } - sb.AppendLine(" "); - } - else - { - sb.AppendLine(" "); + } if (typdeps.Count > 0) @@ -204,5 +265,27 @@ namespace CodeWalker.Project.Panels CurrentProjectFile = ProjectForm.CurrentProjectFile; GenerateProjectManifest(); } + + private void SaveManifestButton_Click(object sender, EventArgs e) + { + + if (SaveFileDialog.ShowDialog() != DialogResult.OK) return; + + try + { + var filename = SaveFileDialog.FileName; + var xml = ProjectManifestTextBox.Text; + var xmldoc = new XmlDocument(); + xmldoc.LoadXml(xml); + var pso = XmlPso.GetPso(xmldoc); + var bytes = pso.Save(); + File.WriteAllBytes(filename, bytes); + } + catch (Exception ex) + { + MessageBox.Show("Error saving _manifest.ymf file:\n" + ex.ToString()); + } + + } } } diff --git a/Project/Panels/EditProjectManifestPanel.resx b/Project/Panels/EditProjectManifestPanel.resx index 538e8fc..06842f2 100644 --- a/Project/Panels/EditProjectManifestPanel.resx +++ b/Project/Panels/EditProjectManifestPanel.resx @@ -119,7 +119,7 @@ - AAEAAAD/////AQAAAAAAAAAMAgAAAFdGYXN0Q29sb3JlZFRleHRCb3gsIFZlcnNpb249Mi4xNi4yMS4w + AAEAAAD/////AQAAAAAAAAAMAgAAAFdGYXN0Q29sb3JlZFRleHRCb3gsIFZlcnNpb249Mi4xNi4yNC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWZiOGFhMTJiOTk0ZWY2MWIMAwAAAFFTeXN0 ZW0uRHJhd2luZywgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2Vu PWIwM2Y1ZjdmMTFkNTBhM2EFAQAAACJGYXN0Q29sb3JlZFRleHRCb3hOUy5TZXJ2aWNlQ29sb3JzBgAA @@ -135,6 +135,9 @@ CgAAAAAAAAAAjQABAAH4/////P///woAAAAAAAAAAKQAAQAB9/////z///8KAAAAAAAAAACWAAEACw== + + 17, 17 +