[DatFile, DatItem] Make items cloneable, fix nonmerged output again

This commit is contained in:
Matt Nadareski
2017-01-09 14:37:41 -08:00
parent 9403277551
commit 4b211c4597
9 changed files with 250 additions and 58 deletions

View File

@@ -1,8 +1,9 @@
using SabreTools.Helper.Data; using System;
using SabreTools.Helper.Data;
namespace SabreTools.Helper.Dats namespace SabreTools.Helper.Dats
{ {
public class Archive : DatItem public class Archive : DatItem, ICloneable
{ {
#region Constructors #region Constructors
@@ -17,6 +18,36 @@ namespace SabreTools.Helper.Dats
#endregion #endregion
#region Cloning Methods
public object Clone()
{
return new Archive()
{
Name = this.Name,
Type = this.Type,
Dupe = this.Dupe,
Machine = this.Machine,
Supported = this.Supported,
Publisher = this.Publisher,
Infos = this.Infos,
PartName = this.PartName,
PartInterface = this.PartInterface,
Features = this.Features,
AreaName = this.AreaName,
AreaSize = this.AreaSize,
SystemID = this.SystemID,
System = this.System,
SourceID = this.SourceID,
Source = this.Source,
};
}
#endregion
#region Comparision Methods #region Comparision Methods
public override bool Equals(DatItem other) public override bool Equals(DatItem other)

View File

@@ -1,8 +1,9 @@
using SabreTools.Helper.Data; using System;
using SabreTools.Helper.Data;
namespace SabreTools.Helper.Dats namespace SabreTools.Helper.Dats
{ {
public class BiosSet : DatItem public class BiosSet : DatItem, ICloneable
{ {
#region Private instance variables #region Private instance variables
@@ -39,6 +40,39 @@ namespace SabreTools.Helper.Dats
#endregion #endregion
#region Cloning Methods
public object Clone()
{
return new BiosSet()
{
Name = this.Name,
Type = this.Type,
Dupe = this.Dupe,
Machine = this.Machine,
Supported = this.Supported,
Publisher = this.Publisher,
Infos = this.Infos,
PartName = this.PartName,
PartInterface = this.PartInterface,
Features = this.Features,
AreaName = this.AreaName,
AreaSize = this.AreaSize,
SystemID = this.SystemID,
System = this.System,
SourceID = this.SourceID,
Source = this.Source,
Description = this.Description,
Default = this.Default,
};
}
#endregion
#region Comparision Methods #region Comparision Methods
public override bool Equals(DatItem other) public override bool Equals(DatItem other)

View File

@@ -4,7 +4,7 @@ using SabreTools.Helper.Data;
namespace SabreTools.Helper.Dats namespace SabreTools.Helper.Dats
{ {
public class Disk : DatItem public class Disk : DatItem, ICloneable
{ {
#region Private instance variables #region Private instance variables
@@ -52,6 +52,40 @@ namespace SabreTools.Helper.Dats
#endregion #endregion
#region Cloning Methods
public object Clone()
{
return new Disk()
{
Name = this.Name,
Type = this.Type,
Dupe = this.Dupe,
Machine = this.Machine,
Supported = this.Supported,
Publisher = this.Publisher,
Infos = this.Infos,
PartName = this.PartName,
PartInterface = this.PartInterface,
Features = this.Features,
AreaName = this.AreaName,
AreaSize = this.AreaSize,
SystemID = this.SystemID,
System = this.System,
SourceID = this.SourceID,
Source = this.Source,
MD5 = this.MD5,
SHA1 = this.SHA1,
ItemStatus = this.ItemStatus,
};
}
#endregion
#region Comparision Methods #region Comparision Methods
public override bool Equals(DatItem other) public override bool Equals(DatItem other)

View File

@@ -377,13 +377,6 @@ namespace SabreTools.Helper.Dats
/// <param name="logger">Logger object for file and console output</param> /// <param name="logger">Logger object for file and console output</param>
/// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param> /// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param>
public void CreateFullyMergedSets(bool mergeroms, Logger logger, bool output = true) public void CreateFullyMergedSets(bool mergeroms, Logger logger, bool output = true)
{
// For sake of ease, the first thing we want to do is sort by game
BucketByGame(mergeroms, false, logger, output);
// Now we want to loop through all of the games and set the correct information
List<string> games = Keys.ToList();
foreach (string game in games)
{ {
// First, we try to add all device items first // First, we try to add all device items first
/* /*
@@ -392,36 +385,35 @@ namespace SabreTools.Helper.Dats
order to get this working correctly. At least this is a good placeholder for now. order to get this working correctly. At least this is a good placeholder for now.
*/ */
// For sake of ease, the first thing we want to do is sort by game
BucketByGame(mergeroms, true, logger, output);
_sortedBy = SortedBy.Default;
// Now we want to loop through all of the games and set the correct information
List<string> games = Keys.ToList();
foreach (string game in games)
{
// Determine if the game has a parent or not // Determine if the game has a parent or not
string parent = null; string parent = null;
if (this[game][0].Machine.CloneOf != null) if (!String.IsNullOrEmpty(this[game][0].Machine.CloneOf))
{ {
parent = this[game][0].Machine.CloneOf; parent = this[game][0].Machine.CloneOf;
} }
else if (this[game][0].Machine.RomOf != null)
{
parent = this[game][0].Machine.RomOf;
}
// If there is no parent, then we continue // If there is no parent, then we continue
if (parent == null) if (String.IsNullOrEmpty(parent))
{
continue;
}
// If the parent doesn't exist, then we continue
if (this[parent].Count == 0)
{ {
continue; continue;
} }
// Otherwise, move the items from the current game to a subfolder of the parent game // Otherwise, move the items from the current game to a subfolder of the parent game
Machine parentMachine = this[parent][0].Machine; Machine parentMachine = this[parent].Count == 0 ? new Machine { Name = parent, Description = parent } : this[parent][0].Machine;
List<DatItem> items = this[game]; List<DatItem> items = this[game];
foreach (DatItem item in items) foreach (DatItem item in items)
{ {
item.Name = item.Machine.Name + "\\" + item.Name; item.Name = item.Machine.Name + "\\" + item.Name;
item.Machine = parentMachine; item.Machine = parentMachine;
this[parent].Add(item);
} }
// Finally, remove the old game so it's not picked up by the writer // Finally, remove the old game so it's not picked up by the writer
@@ -438,7 +430,8 @@ namespace SabreTools.Helper.Dats
public void CreateMergedSets(bool mergeroms, Logger logger, bool output = true) public void CreateMergedSets(bool mergeroms, Logger logger, bool output = true)
{ {
// For sake of ease, the first thing we want to do is sort by game // For sake of ease, the first thing we want to do is sort by game
BucketByGame(mergeroms, false, logger, output); BucketByGame(mergeroms, true, logger, output);
_sortedBy = SortedBy.Default;
// Now we want to loop through all of the games and set the correct information // Now we want to loop through all of the games and set the correct information
List<string> games = Keys.ToList(); List<string> games = Keys.ToList();
@@ -446,34 +439,25 @@ namespace SabreTools.Helper.Dats
{ {
// Determine if the game has a parent or not // Determine if the game has a parent or not
string parent = null; string parent = null;
if (this[game][0].Machine.CloneOf != null) if (!String.IsNullOrEmpty(this[game][0].Machine.CloneOf))
{ {
parent = this[game][0].Machine.CloneOf; parent = this[game][0].Machine.CloneOf;
} }
else if (this[game][0].Machine.RomOf != null)
{
parent = this[game][0].Machine.RomOf;
}
// If there is no parent, then we continue // If there is no parent, then we continue
if (parent == null) if (String.IsNullOrEmpty(parent))
{
continue;
}
// If the parent doesn't exist, then we continue
if (this[parent].Count == 0)
{ {
continue; continue;
} }
// Otherwise, move the items from the current game to a subfolder of the parent game // Otherwise, move the items from the current game to a subfolder of the parent game
Machine parentMachine = this[parent][0].Machine; Machine parentMachine = this[parent].Count == 0 ? new Machine { Name = parent, Description = parent } : this[parent][0].Machine;
List<DatItem> items = this[game]; List<DatItem> items = this[game];
foreach (DatItem item in items) foreach (DatItem item in items)
{ {
item.Name = item.Machine.Name + "\\" + item.Name; item.Name = item.Machine.Name + "\\" + item.Name;
item.Machine = parentMachine; item.Machine = parentMachine;
this[parent].Add(item);
} }
// Finally, remove the old game so it's not picked up by the writer // Finally, remove the old game so it's not picked up by the writer
@@ -482,15 +466,16 @@ namespace SabreTools.Helper.Dats
} }
/// <summary> /// <summary>
/// Use cloneof tags to create split sets and remove the tags /// Use cloneof tags to create non-merged sets and remove the tags
/// </summary> /// </summary>
/// <param name="mergeroms">True if roms should be deduped, false otherwise</param> /// <param name="mergeroms">True if roms should be deduped, false otherwise</param>
/// <param name="logger">Logger object for file and console output</param> /// <param name="logger">Logger object for file and console output</param>
/// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param> /// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param>
public void CreateSplitSets(bool mergeroms, Logger logger, bool output = true) public void CreateNonMergedSets(bool mergeroms, Logger logger, bool output = true)
{ {
// For sake of ease, the first thing we want to do is sort by game // For sake of ease, the first thing we want to do is sort by game
BucketByGame(mergeroms, false, logger, output); BucketByGame(mergeroms, true, logger, output);
_sortedBy = SortedBy.Default;
// Now we want to loop through all of the games and set the correct information // Now we want to loop through all of the games and set the correct information
List<string> games = Keys.ToList(); List<string> games = Keys.ToList();
@@ -498,17 +483,17 @@ namespace SabreTools.Helper.Dats
{ {
// Determine if the game has a parent or not // Determine if the game has a parent or not
string parent = null; string parent = null;
if (this[game][0].Machine.CloneOf != null) if (!String.IsNullOrEmpty(this[game][0].Machine.CloneOf))
{ {
parent = this[game][0].Machine.CloneOf; parent = this[game][0].Machine.CloneOf;
} }
else if (this[game][0].Machine.RomOf != null) else if (!String.IsNullOrEmpty(this[game][0].Machine.RomOf))
{ {
parent = this[game][0].Machine.RomOf; parent = this[game][0].Machine.RomOf;
} }
// If there is no parent, then we continue // If there is no parent, then we continue
if (parent == null) if (String.IsNullOrEmpty(parent))
{ {
continue; continue;
} }
@@ -522,6 +507,7 @@ namespace SabreTools.Helper.Dats
item.Machine.CloneOf = null; item.Machine.CloneOf = null;
item.Machine.RomOf = null; item.Machine.RomOf = null;
} }
continue; continue;
} }
@@ -534,32 +520,32 @@ namespace SabreTools.Helper.Dats
switch (item.Type) switch (item.Type)
{ {
case ItemType.Archive: case ItemType.Archive:
Archive archive = (Archive)item; Archive archive = ((Archive)item).Clone() as Archive;
archive.Machine = currentMachine; archive.Machine = currentMachine;
this[game].Add(archive); this[game].Add(archive);
break; break;
case ItemType.BiosSet: case ItemType.BiosSet:
BiosSet biosSet = (BiosSet)item; BiosSet biosSet = ((BiosSet)item).Clone() as BiosSet;
biosSet.Machine = currentMachine; biosSet.Machine = currentMachine;
this[game].Add(biosSet); this[game].Add(biosSet);
break; break;
case ItemType.Disk: case ItemType.Disk:
Disk disk = (Disk)item; Disk disk = ((Disk)item).Clone() as Disk;
disk.Machine = currentMachine; disk.Machine = currentMachine;
this[game].Add(disk); this[game].Add(disk);
break; break;
case ItemType.Release: case ItemType.Release:
Release release = (Release)item; Release release = ((Release)item).Clone() as Release;
release.Machine = currentMachine; release.Machine = currentMachine;
this[game].Add(release); this[game].Add(release);
break; break;
case ItemType.Rom: case ItemType.Rom:
Rom rom = (Rom)item; Rom rom = ((Rom)item).Clone() as Rom;
rom.Machine = currentMachine; rom.Machine = currentMachine;
this[game].Add(rom); this[game].Add(rom);
break; break;
case ItemType.Sample: case ItemType.Sample:
Sample sample = (Sample)item; Sample sample = ((Sample)item).Clone() as Sample;
sample.Machine = currentMachine; sample.Machine = currentMachine;
this[game].Add(sample); this[game].Add(sample);
break; break;

View File

@@ -129,7 +129,7 @@ namespace SabreTools.Helper.Dats
// Now we pre-process the DAT with the splitting/merging mode // Now we pre-process the DAT with the splitting/merging mode
if (splitType == SplitType.NonMerged) if (splitType == SplitType.NonMerged)
{ {
CreateSplitSets(false, logger, output: false); CreateNonMergedSets(false, logger, output: false);
} }
else if (splitType == SplitType.Merged) else if (splitType == SplitType.Merged)
{ {

View File

@@ -1,8 +1,10 @@
using SabreTools.Helper.Data; using System;
using SabreTools.Helper.Data;
namespace SabreTools.Helper.Dats namespace SabreTools.Helper.Dats
{ {
public class Release : DatItem public class Release : DatItem, ICloneable
{ {
#region Private instance variables #region Private instance variables
@@ -55,6 +57,41 @@ namespace SabreTools.Helper.Dats
#endregion #endregion
#region Cloning Methods
public object Clone()
{
return new Release()
{
Name = this.Name,
Type = this.Type,
Dupe = this.Dupe,
Machine = this.Machine,
Supported = this.Supported,
Publisher = this.Publisher,
Infos = this.Infos,
PartName = this.PartName,
PartInterface = this.PartInterface,
Features = this.Features,
AreaName = this.AreaName,
AreaSize = this.AreaSize,
SystemID = this.SystemID,
System = this.System,
SourceID = this.SourceID,
Source = this.Source,
Region = this.Region,
Language = this.Language,
Date = this.Date,
Default = this.Default,
};
}
#endregion
#region Comparision Methods #region Comparision Methods
public override bool Equals(DatItem other) public override bool Equals(DatItem other)

View File

@@ -4,7 +4,7 @@ using SabreTools.Helper.Data;
namespace SabreTools.Helper.Dats namespace SabreTools.Helper.Dats
{ {
public class Rom : Disk public class Rom : Disk, ICloneable
{ {
#region Private instance variables #region Private instance variables
@@ -74,6 +74,43 @@ namespace SabreTools.Helper.Dats
#endregion #endregion
#region Cloning Methods
public new object Clone()
{
return new Rom()
{
Name = this.Name,
Type = this.Type,
Dupe = this.Dupe,
Machine = this.Machine,
Supported = this.Supported,
Publisher = this.Publisher,
Infos = this.Infos,
PartName = this.PartName,
PartInterface = this.PartInterface,
Features = this.Features,
AreaName = this.AreaName,
AreaSize = this.AreaSize,
SystemID = this.SystemID,
System = this.System,
SourceID = this.SourceID,
Source = this.Source,
MD5 = this.MD5,
SHA1 = this.SHA1,
ItemStatus = this.ItemStatus,
Size = this.Size,
CRC = this.CRC,
Date = this.Date,
};
}
#endregion
#region Comparision Methods #region Comparision Methods
public override bool Equals(DatItem other) public override bool Equals(DatItem other)

View File

@@ -1,8 +1,10 @@
using SabreTools.Helper.Data; using System;
using SabreTools.Helper.Data;
namespace SabreTools.Helper.Dats namespace SabreTools.Helper.Dats
{ {
public class Sample : DatItem public class Sample : DatItem, ICloneable
{ {
#region Constructors #region Constructors
@@ -17,6 +19,36 @@ namespace SabreTools.Helper.Dats
#endregion #endregion
#region Cloning Methods
public object Clone()
{
return new Sample()
{
Name = this.Name,
Type = this.Type,
Dupe = this.Dupe,
Machine = this.Machine,
Supported = this.Supported,
Publisher = this.Publisher,
Infos = this.Infos,
PartName = this.PartName,
PartInterface = this.PartInterface,
Features = this.Features,
AreaName = this.AreaName,
AreaSize = this.AreaSize,
SystemID = this.SystemID,
System = this.System,
SourceID = this.SourceID,
Source = this.Source,
};
}
#endregion
#region Comparision Methods #region Comparision Methods
public override bool Equals(DatItem other) public override bool Equals(DatItem other)

1
debug.log Normal file
View File

@@ -0,0 +1 @@
[0109/130254.459:ERROR:exception_handler_server.cc(524)] ConnectNamedPipe: The pipe is being closed. (0xE8)