From 487230cbf17ed77be56dd8007a9cef2bd29635d0 Mon Sep 17 00:00:00 2001 From: Dreas Date: Tue, 17 May 2022 22:40:40 +0200 Subject: [PATCH] Fixed an issue with the DAT File save as functionality where the DAT header was not being written in the new file. --- DROMsM/Forms/DATFileViewerForm.cs | 9 +++++++++ DROMsM/U8XMLDATFileHandler.cs | 3 +++ DRomsMUtils/Entities/DATFileHeader.cs | 14 ++++++++------ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/DROMsM/Forms/DATFileViewerForm.cs b/DROMsM/Forms/DATFileViewerForm.cs index 5077026..cbbb6db 100644 --- a/DROMsM/Forms/DATFileViewerForm.cs +++ b/DROMsM/Forms/DATFileViewerForm.cs @@ -192,6 +192,15 @@ private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) var rootNodeXMLOpeningTag = currentDATFile.GetRootNodeXMLOpeningTag(); fullXMLFileStringBuilder.AppendLine(rootNodeXMLOpeningTag); + // If this file has a header, write the header now + var datFileHeader = currentDATFile.Header; + if (datFileHeader != null) + { + var headerXMLValue = datFileHeader.XMLValue; + fullXMLFileStringBuilder.Append("\t"); + fullXMLFileStringBuilder.AppendLine(headerXMLValue); + } + // Write all the filtered nodes var filteredObjectList = datFileMachineVirtualListDataSource.FilteredObjectList; foreach (DATFileMachine datFileMachine in filteredObjectList) diff --git a/DROMsM/U8XMLDATFileHandler.cs b/DROMsM/U8XMLDATFileHandler.cs index 807c2de..7aac31f 100644 --- a/DROMsM/U8XMLDATFileHandler.cs +++ b/DROMsM/U8XMLDATFileHandler.cs @@ -139,6 +139,9 @@ public DATFile ParseDATFile(string filePath, out HashSet us } } + // Save the header XML node + datFileHeader.XMLValue = firstMachineNode.AsRawString().ToString(); + datFile.Header = datFileHeader; // Skip the first node since we've now already processed it and determined it's a header node diff --git a/DRomsMUtils/Entities/DATFileHeader.cs b/DRomsMUtils/Entities/DATFileHeader.cs index 908c53a..37fb427 100644 --- a/DRomsMUtils/Entities/DATFileHeader.cs +++ b/DRomsMUtils/Entities/DATFileHeader.cs @@ -1,9 +1,11 @@ public class DATFileHeader { - public string Name { get; set; } - public string Description { get; set; } - public string Version { get; set; } - public string Author { get; set; } - public string Homepage { get; set; } - public string URL { get; set; } + public string Name;// { get; set; } + public string Description;// { get; set; } + public string Version;// { get; set; } + public string Author;// { get; set; } + public string Homepage;// { get; set; } + public string URL;// { get; set; } + + public string XMLValue;// { get; set; } } \ No newline at end of file