Machine stands alone

This commit is contained in:
Matt Nadareski
2020-08-20 13:17:14 -07:00
parent 80a28539bc
commit 2da51628a4
33 changed files with 1117 additions and 1488 deletions

View File

@@ -12,8 +12,8 @@
/// </summary>
public Archive()
{
this.Name = string.Empty;
this.ItemType = ItemType.Archive;
Name = string.Empty;
ItemType = ItemType.Archive;
}
#endregion
@@ -28,33 +28,15 @@
ItemType = this.ItemType,
DupeType = this.DupeType,
Supported = this.Supported,
Publisher = this.Publisher,
Category = this.Category,
Infos = this.Infos,
PartName = this.PartName,
PartInterface = this.PartInterface,
Features = this.Features,
AreaName = this.AreaName,
AreaSize = this.AreaSize,
MachineName = this.MachineName,
Comment = this.Comment,
MachineDescription = this.MachineDescription,
Year = this.Year,
Manufacturer = this.Manufacturer,
RomOf = this.RomOf,
CloneOf = this.CloneOf,
SampleOf = this.SampleOf,
SourceFile = this.SourceFile,
Runnable = this.Runnable,
Board = this.Board,
RebuildTo = this.RebuildTo,
Devices = this.Devices,
MachineType = this.MachineType,
IndexId = this.IndexId,
IndexSource = this.IndexSource,
Machine = this.Machine.Clone() as Machine,
Source = this.Source.Clone() as Source,
Remove = this.Remove,
};
}
@@ -65,14 +47,14 @@
public override bool Equals(DatItem other)
{
// If we don't have an archive, return false
if (this.ItemType != other.ItemType)
if (ItemType != other.ItemType)
return false;
// Otherwise, treat it as an archive
Archive newOther = other as Archive;
// If the archive information matches
return (this.Name == newOther.Name);
return (Name == newOther.Name);
}
#endregion

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using SabreTools.Library.Filtering;
using Newtonsoft.Json;
@@ -9,7 +10,7 @@ namespace SabreTools.Library.DatItems
/// </summary>
public class BiosSet : DatItem
{
#region Publicly facing variables
#region Fields
/// <summary>
/// Description of the BIOS
@@ -68,8 +69,8 @@ namespace SabreTools.Library.DatItems
/// </summary>
public BiosSet()
{
this.Name = string.Empty;
this.ItemType = ItemType.BiosSet;
Name = string.Empty;
ItemType = ItemType.BiosSet;
}
#endregion
@@ -84,33 +85,15 @@ namespace SabreTools.Library.DatItems
ItemType = this.ItemType,
DupeType = this.DupeType,
Supported = this.Supported,
Publisher = this.Publisher,
Category = this.Category,
Infos = this.Infos,
PartName = this.PartName,
PartInterface = this.PartInterface,
Features = this.Features,
AreaName = this.AreaName,
AreaSize = this.AreaSize,
MachineName = this.MachineName,
Comment = this.Comment,
MachineDescription = this.MachineDescription,
Year = this.Year,
Manufacturer = this.Manufacturer,
RomOf = this.RomOf,
CloneOf = this.CloneOf,
SampleOf = this.SampleOf,
SourceFile = this.SourceFile,
Runnable = this.Runnable,
Board = this.Board,
RebuildTo = this.RebuildTo,
Devices = this.Devices,
MachineType = this.MachineType,
IndexId = this.IndexId,
IndexSource = this.IndexSource,
Machine = this.Machine.Clone() as Machine,
Source = this.Source.Clone() as Source,
Remove = this.Remove,
Description = this.Description,
Default = this.Default,
@@ -124,14 +107,14 @@ namespace SabreTools.Library.DatItems
public override bool Equals(DatItem other)
{
// If we don't have a biosset, return false
if (this.ItemType != other.ItemType)
if (ItemType != other.ItemType)
return false;
// Otherwise, treat it as a biosset
BiosSet newOther = other as BiosSet;
// If the archive information matches
return (this.Name == newOther.Name && this.Description == newOther.Description && this.Default == newOther.Default);
return (Name == newOther.Name && Description == newOther.Description && Default == newOther.Default);
}
#endregion

View File

@@ -1,6 +1,4 @@
using SabreTools.Library.Data;
namespace SabreTools.Library.DatItems
namespace SabreTools.Library.DatItems
{
/// <summary>
/// Represents a blank set from an input DAT
@@ -14,8 +12,8 @@ namespace SabreTools.Library.DatItems
/// </summary>
public Blank()
{
this.Name = string.Empty;
this.ItemType = ItemType.Blank;
Name = string.Empty;
ItemType = ItemType.Blank;
}
#endregion
@@ -30,33 +28,15 @@ namespace SabreTools.Library.DatItems
ItemType = this.ItemType,
DupeType = this.DupeType,
Supported = this.Supported,
Publisher = this.Publisher,
Category = this.Category,
Infos = this.Infos,
PartName = this.PartName,
PartInterface = this.PartInterface,
Features = this.Features,
AreaName = this.AreaName,
AreaSize = this.AreaSize,
MachineName = this.MachineName,
Comment = this.Comment,
MachineDescription = this.MachineDescription,
Year = this.Year,
Manufacturer = this.Manufacturer,
RomOf = this.RomOf,
CloneOf = this.CloneOf,
SampleOf = this.SampleOf,
SourceFile = this.SourceFile,
Runnable = this.Runnable,
Board = this.Board,
RebuildTo = this.RebuildTo,
Devices = this.Devices,
MachineType = this.MachineType,
IndexId = this.IndexId,
IndexSource = this.IndexSource,
Machine = this.Machine.Clone() as Machine,
Source = this.Source.Clone() as Source,
Remove = this.Remove,
};
}
@@ -67,14 +47,14 @@ namespace SabreTools.Library.DatItems
public override bool Equals(DatItem other)
{
// If we don't have a blank, return false
if (this.ItemType != other.ItemType)
if (ItemType != other.ItemType)
return false;
// Otherwise, treat it as a Blank
Blank newOther = other as Blank;
// If the archive information matches
return (_machine == newOther._machine);
return (Machine == newOther.Machine);
}
#endregion

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using SabreTools.Library.DatFiles;
using SabreTools.Library.FileTypes;
using SabreTools.Library.Filtering;
@@ -25,7 +26,7 @@ namespace SabreTools.Library.DatItems
#endregion
#region Publicly facing variables
#region Fields
/// <summary>
/// Data MD5 hash
@@ -202,10 +203,10 @@ namespace SabreTools.Library.DatItems
/// </summary>
public Disk()
{
this.Name = string.Empty;
this.ItemType = ItemType.Disk;
this.DupeType = 0x00;
this.ItemStatus = ItemStatus.None;
Name = string.Empty;
ItemType = ItemType.Disk;
DupeType = 0x00;
ItemStatus = ItemStatus.None;
}
/// <summary>
@@ -214,7 +215,7 @@ namespace SabreTools.Library.DatItems
/// <param name="baseFile"></param>
public Disk(BaseFile baseFile)
{
this.Name = baseFile.Filename;
Name = baseFile.Filename;
_md5 = baseFile.MD5;
#if NET_FRAMEWORK
_ripemd160 = baseFile.RIPEMD160;
@@ -224,9 +225,9 @@ namespace SabreTools.Library.DatItems
_sha384 = baseFile.SHA384;
_sha512 = baseFile.SHA512;
this.ItemType = ItemType.Disk;
this.DupeType = 0x00;
this.ItemStatus = ItemStatus.None;
ItemType = ItemType.Disk;
DupeType = 0x00;
ItemStatus = ItemStatus.None;
}
#endregion
@@ -241,33 +242,15 @@ namespace SabreTools.Library.DatItems
ItemType = this.ItemType,
DupeType = this.DupeType,
Supported = this.Supported,
Publisher = this.Publisher,
Category = this.Category,
Infos = this.Infos,
PartName = this.PartName,
PartInterface = this.PartInterface,
Features = this.Features,
AreaName = this.AreaName,
AreaSize = this.AreaSize,
MachineName = this.MachineName,
Comment = this.Comment,
MachineDescription = this.MachineDescription,
Year = this.Year,
Manufacturer = this.Manufacturer,
RomOf = this.RomOf,
CloneOf = this.CloneOf,
SampleOf = this.SampleOf,
SourceFile = this.SourceFile,
Runnable = this.Runnable,
Board = this.Board,
RebuildTo = this.RebuildTo,
Devices = this.Devices,
MachineType = this.MachineType,
IndexId = this.IndexId,
IndexSource = this.IndexSource,
Machine = this.Machine.Clone() as Machine,
Source = this.Source.Clone() as Source,
Remove = this.Remove,
_md5 = this._md5,
#if NET_FRAMEWORK
@@ -277,7 +260,12 @@ namespace SabreTools.Library.DatItems
_sha256 = this._sha256,
_sha384 = this._sha384,
_sha512 = this._sha512,
MergeTag = this.MergeTag,
Region = this.Region,
Index = this.Index,
Writable = this.Writable,
ItemStatus = this.ItemStatus,
Optional = this.Optional,
};
}
@@ -293,6 +281,21 @@ namespace SabreTools.Library.DatItems
ItemType = ItemType.Rom,
DupeType = this.DupeType,
PartName = this.PartName,
PartInterface = this.PartInterface,
Features = this.Features,
AreaName = this.AreaName,
AreaSize = this.AreaSize,
Machine = this.Machine.Clone() as Machine,
Source = this.Source.Clone() as Source,
Remove = this.Remove,
MergeTag = this.MergeTag,
Region = this.Region,
ItemStatus = this.ItemStatus,
Optional = this.Optional,
CRC = null,
MD5 = this.MD5,
#if NET_FRAMEWORK
@@ -302,41 +305,6 @@ namespace SabreTools.Library.DatItems
SHA256 = this.SHA256,
SHA384 = this.SHA384,
SHA512 = this.SHA512,
MergeTag = this.MergeTag,
Region = this.Region,
ItemStatus = this.ItemStatus,
Optional = this.Optional,
MachineName = this.MachineName,
Comment = this.Comment,
MachineDescription = this.MachineDescription,
Year = this.Year,
Manufacturer = this.Manufacturer,
Publisher = this.Publisher,
Category = this.Category,
RomOf = this.RomOf,
CloneOf = this.CloneOf,
SampleOf = this.SampleOf,
Supported = this.Supported,
SourceFile = this.SourceFile,
Runnable = this.Runnable,
Board = this.Board,
RebuildTo = this.RebuildTo,
Devices = this.Devices,
SlotOptions = this.SlotOptions,
Infos = this.Infos,
MachineType = this.MachineType,
PartName = this.PartName,
PartInterface = this.PartInterface,
Features = this.Features,
AreaName = this.AreaName,
AreaSize = this.AreaSize,
IndexId = this.IndexId,
IndexSource = this.IndexSource,
Remove = this.Remove,
};
return rom;

View File

@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using SabreTools.Library.Data;
using SabreTools.Library.Filtering;
using Newtonsoft.Json;
namespace SabreTools.Library.DatItems
@@ -11,7 +12,7 @@ namespace SabreTools.Library.DatItems
/// </summary>
public class Machine : ICloneable
{
#region Publicly facing variables
#region Fields
/// <summary>
/// Name of the machine
@@ -131,6 +132,91 @@ namespace SabreTools.Library.DatItems
#endregion
#region Accessors
/// <summary>
/// Get the value of that field as a string, if possible
/// </summary>
public string GetField(Field field, List<Field> excludeFields)
{
// If the field is to be excluded, return empty string
if (excludeFields.Contains(field))
return string.Empty;
string fieldValue = null;
switch (field)
{
case Field.MachineName:
fieldValue = Name;
break;
case Field.Comment:
fieldValue = Comment;
break;
case Field.Description:
fieldValue = Description;
break;
case Field.Year:
fieldValue = Year;
break;
case Field.Manufacturer:
fieldValue = Manufacturer;
break;
case Field.Publisher:
fieldValue = Publisher;
break;
case Field.Category:
fieldValue = Category;
break;
case Field.RomOf:
fieldValue = RomOf;
break;
case Field.CloneOf:
fieldValue = CloneOf;
break;
case Field.SampleOf:
fieldValue = SampleOf;
break;
case Field.Supported:
fieldValue = Supported?.ToString();
break;
case Field.SourceFile:
fieldValue = SourceFile;
break;
case Field.Runnable:
fieldValue = Runnable?.ToString();
break;
case Field.Board:
fieldValue = Board;
break;
case Field.RebuildTo:
fieldValue = RebuildTo;
break;
case Field.Devices:
fieldValue = string.Join(";", Devices ?? new List<string>());
break;
case Field.SlotOptions:
fieldValue = string.Join(";", SlotOptions ?? new List<string>());
break;
case Field.Infos:
fieldValue = string.Join(";", (Infos ?? new List<KeyValuePair<string, string>>()).Select(i => $"{i.Key}={i.Value}"));
break;
case Field.MachineType:
fieldValue = MachineType.ToString();
break;
default:
return null;
}
// Make sure we don't return null
if (string.IsNullOrEmpty(fieldValue))
fieldValue = string.Empty;
return fieldValue;
}
#endregion
#region Constructors
/// <summary>
@@ -222,5 +308,291 @@ namespace SabreTools.Library.DatItems
}
#endregion
#region Filtering
/// <summary>
/// Check to see if a Machine passes the filter
/// </summary>
/// <param name="filter">Filter to check against</param>
/// <returns>True if the item passed the filter, false otherwise</returns>
public bool PassesFilter(Filter filter)
{
// Filter on machine name
bool? machineNameFound = filter.MachineName.MatchesPositiveSet(Name);
if (filter.IncludeOfInGame)
{
machineNameFound |= (filter.MachineName.MatchesPositiveSet(CloneOf) == true);
machineNameFound |= (filter.MachineName.MatchesPositiveSet(RomOf) == true);
}
if (machineNameFound == false)
return false;
machineNameFound = filter.MachineName.MatchesNegativeSet(Name);
if (filter.IncludeOfInGame)
{
machineNameFound |= (filter.MachineName.MatchesNegativeSet(CloneOf) == true);
machineNameFound |= (filter.MachineName.MatchesNegativeSet(RomOf) == true);
}
if (machineNameFound == false)
return false;
// Filter on comment
if (filter.Comment.MatchesPositiveSet(Comment) == false)
return false;
if (filter.Comment.MatchesNegativeSet(Comment) == true)
return false;
// Filter on machine description
if (filter.MachineDescription.MatchesPositiveSet(Description) == false)
return false;
if (filter.MachineDescription.MatchesNegativeSet(Description) == true)
return false;
// Filter on year
if (filter.Year.MatchesPositiveSet(Year) == false)
return false;
if (filter.Year.MatchesNegativeSet(Year) == true)
return false;
// Filter on manufacturer
if (filter.Manufacturer.MatchesPositiveSet(Manufacturer) == false)
return false;
if (filter.Manufacturer.MatchesNegativeSet(Manufacturer) == true)
return false;
// Filter on publisher
if (filter.Publisher.MatchesPositiveSet(Publisher) == false)
return false;
if (filter.Publisher.MatchesNegativeSet(Publisher) == true)
return false;
// Filter on category
if (filter.Category.MatchesPositiveSet(Category) == false)
return false;
if (filter.Category.MatchesNegativeSet(Category) == true)
return false;
// Filter on romof
if (filter.RomOf.MatchesPositiveSet(RomOf) == false)
return false;
if (filter.RomOf.MatchesNegativeSet(RomOf) == true)
return false;
// Filter on cloneof
if (filter.CloneOf.MatchesPositiveSet(CloneOf) == false)
return false;
if (filter.CloneOf.MatchesNegativeSet(CloneOf) == true)
return false;
// Filter on sampleof
if (filter.SampleOf.MatchesPositiveSet(SampleOf) == false)
return false;
if (filter.SampleOf.MatchesNegativeSet(SampleOf) == true)
return false;
// Filter on supported
if (filter.Supported.MatchesNeutral(null, Supported) == false)
return false;
// Filter on source file
if (filter.SourceFile.MatchesPositiveSet(SourceFile) == false)
return false;
if (filter.SourceFile.MatchesNegativeSet(SourceFile) == true)
return false;
// Filter on runnable
if (filter.Runnable.MatchesNeutral(null, Runnable) == false)
return false;
// Filter on board
if (filter.Board.MatchesPositiveSet(Board) == false)
return false;
if (filter.Board.MatchesNegativeSet(Board) == true)
return false;
// Filter on rebuildto
if (filter.RebuildTo.MatchesPositiveSet(RebuildTo) == false)
return false;
if (filter.RebuildTo.MatchesNegativeSet(RebuildTo) == true)
return false;
// Filter on devices
if (Devices != null && Devices.Any())
{
bool anyPositiveDevice = false;
bool anyNegativeDevice = false;
foreach (string device in Devices)
{
anyPositiveDevice |= filter.Devices.MatchesPositiveSet(device) != false;
anyNegativeDevice |= filter.Devices.MatchesNegativeSet(device) == false;
}
if (!anyPositiveDevice || anyNegativeDevice)
return false;
}
// Filter on slot options
if (SlotOptions != null && SlotOptions.Any())
{
bool anyPositiveSlotOption = false;
bool anyNegativeSlotOption = false;
foreach (string slotOption in SlotOptions)
{
anyPositiveSlotOption |= filter.SlotOptions.MatchesPositiveSet(slotOption) != false;
anyNegativeSlotOption |= filter.SlotOptions.MatchesNegativeSet(slotOption) == false;
}
if (!anyPositiveSlotOption || anyNegativeSlotOption)
return false;
}
// Filter on machine type
if (filter.MachineTypes.MatchesPositive(MachineType.NULL, MachineType) == false)
return false;
if (filter.MachineTypes.MatchesNegative(MachineType.NULL, MachineType) == true)
return false;
return true;
}
/// <summary>
/// Remove fields from the Machine
/// </summary>
/// <param name="fields">List of Fields to remove</param>
public void RemoveFields(List<Field> fields)
{
if (fields.Contains(Field.MachineName))
Name = null;
if (fields.Contains(Field.Comment))
Comment = null;
if (fields.Contains(Field.Description))
Description = null;
if (fields.Contains(Field.Year))
Year = null;
if (fields.Contains(Field.Manufacturer))
Manufacturer = null;
if (fields.Contains(Field.Publisher))
Publisher = null;
if (fields.Contains(Field.Category))
Category = null;
if (fields.Contains(Field.RomOf))
RomOf = null;
if (fields.Contains(Field.CloneOf))
CloneOf = null;
if (fields.Contains(Field.SampleOf))
SampleOf = null;
if (fields.Contains(Field.Supported))
Supported = null;
if (fields.Contains(Field.SourceFile))
SourceFile = null;
if (fields.Contains(Field.Runnable))
Runnable = null;
if (fields.Contains(Field.Board))
Board = null;
if (fields.Contains(Field.RebuildTo))
RebuildTo = null;
if (fields.Contains(Field.Devices))
Devices = null;
if (fields.Contains(Field.SlotOptions))
SlotOptions = null;
if (fields.Contains(Field.Infos))
Infos = null;
if (fields.Contains(Field.MachineType))
MachineType = MachineType.NULL;
}
#endregion
#region Sorting and Merging
/// <summary>
/// Replace machine fields from another item
/// </summary>
/// <param name="item">DatItem to pull new information from</param>
/// <param name="fields">List of Fields representing what should be updated</param>
/// <param name="onlySame">True if descriptions should only be replaced if the game name is the same, false otherwise</param>
public void ReplaceFields(Machine machine, List<Field> fields, bool onlySame)
{
if (fields.Contains(Field.MachineName))
Name = machine.Name;
if (fields.Contains(Field.Comment))
Comment = machine.Comment;
if (fields.Contains(Field.Description))
{
if (!onlySame || (onlySame && Name == Description))
Description = machine.Description;
}
if (fields.Contains(Field.Year))
Year = machine.Year;
if (fields.Contains(Field.Manufacturer))
Manufacturer = machine.Manufacturer;
if (fields.Contains(Field.Publisher))
Publisher = machine.Publisher;
if (fields.Contains(Field.Category))
Category = machine.Category;
if (fields.Contains(Field.RomOf))
RomOf = machine.RomOf;
if (fields.Contains(Field.CloneOf))
CloneOf = machine.CloneOf;
if (fields.Contains(Field.SampleOf))
SampleOf = machine.SampleOf;
if (fields.Contains(Field.Supported))
Supported = machine.Supported;
if (fields.Contains(Field.SourceFile))
SourceFile = machine.SourceFile;
if (fields.Contains(Field.Runnable))
Runnable = machine.Runnable;
if (fields.Contains(Field.Board))
Board = machine.Board;
if (fields.Contains(Field.RebuildTo))
RebuildTo = machine.RebuildTo;
if (fields.Contains(Field.Devices))
Devices = machine.Devices;
if (fields.Contains(Field.SlotOptions))
SlotOptions = machine.SlotOptions;
if (fields.Contains(Field.Infos))
Infos = machine.Infos;
if (fields.Contains(Field.MachineType))
MachineType = machine.MachineType;
}
#endregion
}
}

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using SabreTools.Library.Filtering;
using Newtonsoft.Json;
@@ -9,7 +10,7 @@ namespace SabreTools.Library.DatItems
/// </summary>
public class Release : DatItem
{
#region Publicly facing variables
#region Fields
/// <summary>
/// Release region(s)
@@ -86,12 +87,12 @@ namespace SabreTools.Library.DatItems
/// </summary>
public Release()
{
this.Name = string.Empty;
this.ItemType = ItemType.Release;
this.Region = string.Empty;
this.Language = string.Empty;
this.Date = string.Empty;
this.Default = null;
Name = string.Empty;
ItemType = ItemType.Release;
Region = string.Empty;
Language = string.Empty;
Date = string.Empty;
Default = null;
}
#endregion
@@ -106,33 +107,15 @@ namespace SabreTools.Library.DatItems
ItemType = this.ItemType,
DupeType = this.DupeType,
Supported = this.Supported,
Publisher = this.Publisher,
Category = this.Category,
Infos = this.Infos,
PartName = this.PartName,
PartInterface = this.PartInterface,
Features = this.Features,
AreaName = this.AreaName,
AreaSize = this.AreaSize,
MachineName = this.MachineName,
Comment = this.Comment,
MachineDescription = this.MachineDescription,
Year = this.Year,
Manufacturer = this.Manufacturer,
RomOf = this.RomOf,
CloneOf = this.CloneOf,
SampleOf = this.SampleOf,
SourceFile = this.SourceFile,
Runnable = this.Runnable,
Board = this.Board,
RebuildTo = this.RebuildTo,
Devices = this.Devices,
MachineType = this.MachineType,
IndexId = this.IndexId,
IndexSource = this.IndexSource,
Machine = this.Machine.Clone() as Machine,
Source = this.Source.Clone() as Source,
Remove = this.Remove,
Region = this.Region,
Language = this.Language,
@@ -148,18 +131,18 @@ namespace SabreTools.Library.DatItems
public override bool Equals(DatItem other)
{
// If we don't have a release return false
if (this.ItemType != other.ItemType)
if (ItemType != other.ItemType)
return false;
// Otherwise, treat it as a Release
Release newOther = other as Release;
// If the archive information matches
return (this.Name == newOther.Name
&& this.Region == newOther.Region
&& this.Language == newOther.Language
&& this.Date == newOther.Date
&& this.Default == newOther.Default);
return (Name == newOther.Name
&& Region == newOther.Region
&& Language == newOther.Language
&& Date == newOther.Date
&& Default == newOther.Default);
}
#endregion

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using SabreTools.Library.Data;
using SabreTools.Library.DatFiles;
using SabreTools.Library.FileTypes;
@@ -27,7 +28,7 @@ namespace SabreTools.Library.DatItems
#endregion
#region Publicly facing variables
#region Fields
/// <summary>
/// What BIOS is required for this rom
@@ -244,11 +245,11 @@ namespace SabreTools.Library.DatItems
/// </summary>
public Rom()
{
this.Name = string.Empty;
this.ItemType = ItemType.Rom;
this.DupeType = 0x00;
this.ItemStatus = ItemStatus.None;
this.Date = string.Empty;
Name = string.Empty;
ItemType = ItemType.Rom;
DupeType = 0x00;
ItemStatus = ItemStatus.None;
Date = string.Empty;
}
/// <summary>
@@ -259,12 +260,12 @@ namespace SabreTools.Library.DatItems
/// <param name="omitFromScan"></param>
public Rom(string name, string machineName)
{
this.Name = name;
this.ItemType = ItemType.Rom;
this.Size = -1;
this.ItemStatus = ItemStatus.None;
Name = name;
ItemType = ItemType.Rom;
Size = -1;
ItemStatus = ItemStatus.None;
_machine = new Machine
Machine = new Machine
{
Name = machineName,
Description = machineName,
@@ -277,8 +278,8 @@ namespace SabreTools.Library.DatItems
/// <param name="baseFile"></param>
public Rom(BaseFile baseFile)
{
this.Name = baseFile.Filename;
this.Size = baseFile.Size ?? -1;
Name = baseFile.Filename;
Size = baseFile.Size ?? -1;
_crc = baseFile.CRC;
_md5 = baseFile.MD5;
#if NET_FRAMEWORK
@@ -289,10 +290,10 @@ namespace SabreTools.Library.DatItems
_sha384 = baseFile.SHA384;
_sha512 = baseFile.SHA512;
this.ItemType = ItemType.Rom;
this.DupeType = 0x00;
this.ItemStatus = ItemStatus.None;
this.Date = baseFile.Date;
ItemType = ItemType.Rom;
DupeType = 0x00;
ItemStatus = ItemStatus.None;
Date = baseFile.Date;
}
#endregion
@@ -307,34 +308,17 @@ namespace SabreTools.Library.DatItems
ItemType = this.ItemType,
DupeType = this.DupeType,
Supported = this.Supported,
Publisher = this.Publisher,
Category = this.Category,
Infos = this.Infos,
PartName = this.PartName,
PartInterface = this.PartInterface,
Features = this.Features,
AreaName = this.AreaName,
AreaSize = this.AreaSize,
MachineName = this.MachineName,
Comment = this.Comment,
MachineDescription = this.MachineDescription,
Year = this.Year,
Manufacturer = this.Manufacturer,
RomOf = this.RomOf,
CloneOf = this.CloneOf,
SampleOf = this.SampleOf,
SourceFile = this.SourceFile,
Runnable = this.Runnable,
Board = this.Board,
RebuildTo = this.RebuildTo,
Devices = this.Devices,
MachineType = this.MachineType,
IndexId = this.IndexId,
IndexSource = this.IndexSource,
Machine = this.Machine.Clone() as Machine,
Source = this.Source.Clone() as Source,
Remove = this.Remove,
Bios = this.Bios,
Size = this.Size,
_crc = this._crc,
_md5 = this._md5,
@@ -345,8 +329,13 @@ namespace SabreTools.Library.DatItems
_sha256 = this._sha256,
_sha384 = this._sha384,
_sha512 = this._sha512,
ItemStatus = this.ItemStatus,
MergeTag = this.MergeTag,
Region = this.Region,
Offset = this.Offset,
Date = this.Date,
ItemStatus = this.ItemStatus,
Optional = this.Optional,
Inverted = this.Inverted,
};
}

View File

@@ -12,8 +12,8 @@
/// </summary>
public Sample()
{
this.Name = string.Empty;
this.ItemType = ItemType.Sample;
Name = string.Empty;
ItemType = ItemType.Sample;
}
#endregion
@@ -28,33 +28,15 @@
ItemType = this.ItemType,
DupeType = this.DupeType,
Supported = this.Supported,
Publisher = this.Publisher,
Category = this.Category,
Infos = this.Infos,
PartName = this.PartName,
PartInterface = this.PartInterface,
Features = this.Features,
AreaName = this.AreaName,
AreaSize = this.AreaSize,
MachineName = this.MachineName,
Comment = this.Comment,
MachineDescription = this.MachineDescription,
Year = this.Year,
Manufacturer = this.Manufacturer,
RomOf = this.RomOf,
CloneOf = this.CloneOf,
SampleOf = this.SampleOf,
SourceFile = this.SourceFile,
Runnable = this.Runnable,
Board = this.Board,
RebuildTo = this.RebuildTo,
Devices = this.Devices,
MachineType = this.MachineType,
IndexId = this.IndexId,
IndexSource = this.IndexSource,
Machine = this.Machine.Clone() as Machine,
Source = this.Source.Clone() as Source,
Remove = this.Remove,
};
}
@@ -65,14 +47,14 @@
public override bool Equals(DatItem other)
{
// If we don't have a sample, return false
if (this.ItemType != other.ItemType)
if (ItemType != other.ItemType)
return false;
// Otherwise, treat it as a Sample
Sample newOther = other as Sample;
// If the archive information matches
return (this.Name == newOther.Name);
return (Name == newOther.Name);
}
#endregion

View File

@@ -0,0 +1,43 @@
using System;
namespace SabreTools.Library.DatItems
{
/// <summary>
/// Source information wrapper
/// </summary>
public class Source : ICloneable
{
/// <summary>
/// Source index
/// </summary>
public int Index { get; set; }
/// <summary>
/// Source name
/// </summary>
public string Name { get; set; }
/// <summary>
/// Constructor
/// </summary>
/// <param name="id">Source ID, default 0</param>
/// <param name="source">Source name, default null</param>
public Source(int id = 0, string source = null)
{
Index = id;
Name = source;
}
#region Cloning
/// <summary>
/// Clone the current object
/// </summary>
public object Clone()
{
return new Source(Index, Name);
}
#endregion
}
}