Added save manifest file button to manifest generator, improved manifest generator accuracy for interior ytyps

This commit is contained in:
dexy 2019-01-13 09:03:27 +11:00
parent 987d121cc0
commit 37bbea4607
3 changed files with 168 additions and 76 deletions

View File

@ -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;
}
}

View File

@ -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(" <imapDependencies_2>");
foreach (var ymap in CurrentProjectFile.YmapFiles)
if (CurrentProjectFile.YmapFiles.Count > 0)
{
var ymapname = ymap.RpfFileEntry?.NameLower;
if (string.IsNullOrEmpty(ymapname))
sb.AppendLine(" <imapDependencies_2>");
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<string, YtypFile> typdepdict;
if (!typdeps.TryGetValue(ytypname, out typdepdict))
mapdeps[ytypname] = ytyp;
}
if (ent.IsMlo)
{
if (ent.MloInstance?.Entities != null)
{
typdepdict = new Dictionary<string, YtypFile>();
typdeps[ytypname] = typdepdict;
Dictionary<string, YtypFile> typdepdict;
if (!typdeps.TryGetValue(ytypname, out typdepdict))
{
typdepdict = new Dictionary<string, YtypFile>();
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(" <Item>");
sb.AppendLine(" <imapName>" + ymapname + "</imapName>");
sb.AppendLine(" <manifestFlags/>");
sb.AppendLine(" <itypDepArray>");
foreach (var kvp in mapdeps)
{
sb.AppendLine(" <Item>" + kvp.Key + "</Item>");
}
sb.AppendLine(" </itypDepArray>");
sb.AppendLine(" </Item>");
}
sb.AppendLine(" </imapDependencies_2>");
}
else
{
sb.AppendLine(" <imapDependencies_2/>");
}
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<string, YtypFile> typdepdict;
if (!typdeps.TryGetValue(ytypname, out typdepdict))
{
typdepdict = new Dictionary<string, YtypFile>();
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(" <Item>");
sb.AppendLine(" <imapName>" + ymapname + "</imapName>");
sb.AppendLine(" <manifestFlags/>");
sb.AppendLine(" <itypDepArray>");
foreach (var kvp in mapdeps)
{
sb.AppendLine(" <Item>" + kvp.Key + "</Item>");
}
sb.AppendLine(" </itypDepArray>");
sb.AppendLine(" </Item>");
}
sb.AppendLine(" </imapDependencies_2>");
}
else
{
sb.AppendLine(" <imapDependencies_2/>");
}
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());
}
}
}
}

View File

@ -119,7 +119,7 @@
</resheader>
<data name="ProjectManifestTextBox.ServiceColors" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdGYXN0Q29sb3JlZFRleHRCb3gsIFZlcnNpb249Mi4xNi4yMS4w
AAEAAAD/////AQAAAAAAAAAMAgAAAFdGYXN0Q29sb3JlZFRleHRCb3gsIFZlcnNpb249Mi4xNi4yNC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWZiOGFhMTJiOTk0ZWY2MWIMAwAAAFFTeXN0
ZW0uRHJhd2luZywgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2Vu
PWIwM2Y1ZjdmMTFkNTBhM2EFAQAAACJGYXN0Q29sb3JlZFRleHRCb3hOUy5TZXJ2aWNlQ29sb3JzBgAA
@ -135,6 +135,9 @@
CgAAAAAAAAAAjQABAAH4/////P///woAAAAAAAAAAKQAAQAB9/////z///8KAAAAAAAAAACWAAEACw==
</value>
</data>
<metadata name="SaveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>