mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Split Modification class functionality
This had the potential to cause a lot of issues the way it was. Moving the actual functionality for cleaning, filtering, and applying extras to their appropriate classes allows for less redirection when calling into the code. Modification as a class was essentially a shell around things that should have just been a single call.
This commit is contained in:
@@ -14,7 +14,7 @@ namespace SabreTools.DatTools
|
||||
/// <summary>
|
||||
/// Helper methods for updating and converting DatFiles
|
||||
/// </summary>
|
||||
public class DatFileTool
|
||||
public static class DatFileTool
|
||||
{
|
||||
#region Logging
|
||||
|
||||
@@ -25,6 +25,40 @@ namespace SabreTools.DatTools
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Apply SuperDAT naming logic to a merged DatFile
|
||||
/// </summary>
|
||||
/// <param name="datFile">Current DatFile object to run operations on</param>
|
||||
/// <param name="inputs">List of inputs to use for renaming</param>
|
||||
public static void ApplySuperDAT(DatFile datFile, List<ParentablePath> inputs)
|
||||
{
|
||||
List<string> keys = datFile.Items.Keys.ToList();
|
||||
Parallel.ForEach(keys, Globals.ParallelOptions, key =>
|
||||
{
|
||||
List<DatItem> items = datFile.Items[key].ToList();
|
||||
List<DatItem> newItems = new List<DatItem>();
|
||||
foreach (DatItem item in items)
|
||||
{
|
||||
DatItem newItem = item;
|
||||
string filename = inputs[newItem.Source.Index].CurrentPath;
|
||||
string rootpath = inputs[newItem.Source.Index].ParentPath;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(rootpath))
|
||||
rootpath += Path.DirectorySeparatorChar.ToString();
|
||||
|
||||
filename = filename.Remove(0, rootpath.Length);
|
||||
newItem.Machine.Name = Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar
|
||||
+ Path.GetFileNameWithoutExtension(filename) + Path.DirectorySeparatorChar
|
||||
+ newItem.Machine.Name;
|
||||
|
||||
newItems.Add(newItem);
|
||||
}
|
||||
|
||||
datFile.Items.Remove(key);
|
||||
datFile.Items.AddRange(key, newItems);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replace item values from the base set represented by the current DAT
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user