mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatTools] Add even more things to read
This commit is contained in:
@@ -205,6 +205,12 @@ namespace SabreTools.Helper
|
|||||||
public string Date;
|
public string Date;
|
||||||
public SourceMetadata Metadata;
|
public SourceMetadata Metadata;
|
||||||
|
|
||||||
|
// Non rom or disk
|
||||||
|
public string Region;
|
||||||
|
public string Language;
|
||||||
|
public bool? Default;
|
||||||
|
public string Description;
|
||||||
|
|
||||||
public int CompareTo(object obj)
|
public int CompareTo(object obj)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|||||||
@@ -280,9 +280,31 @@ namespace SabreTools.Helper
|
|||||||
block = true;
|
block = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the line is a rom or disk and we're in a block
|
// If the line is a rom-like item and we're in a block
|
||||||
else if ((line.Trim().StartsWith("rom (") || line.Trim().StartsWith("disk (") || line.Trim().StartsWith("file (")) && block)
|
else if ((line.Trim().StartsWith("rom (")
|
||||||
|
|| line.Trim().StartsWith("disk (")
|
||||||
|
|| line.Trim().StartsWith("file (")
|
||||||
|
|| (line.Trim().StartsWith("sample") && !line.Trim().StartsWith("sampleof"))
|
||||||
|
) && block)
|
||||||
{
|
{
|
||||||
|
ItemType temptype = ItemType.Rom;
|
||||||
|
if (line.Trim().StartsWith("rom ("))
|
||||||
|
{
|
||||||
|
temptype = ItemType.Rom;
|
||||||
|
}
|
||||||
|
else if (line.Trim().StartsWith("disk ("))
|
||||||
|
{
|
||||||
|
temptype = ItemType.Disk;
|
||||||
|
}
|
||||||
|
else if (line.Trim().StartsWith("file ("))
|
||||||
|
{
|
||||||
|
temptype = ItemType.Rom;
|
||||||
|
}
|
||||||
|
else if (line.Trim().StartsWith("sample"))
|
||||||
|
{
|
||||||
|
temptype = ItemType.Sample;
|
||||||
|
}
|
||||||
|
|
||||||
Rom rom = new Rom
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Machine = new Machine
|
Machine = new Machine
|
||||||
@@ -295,10 +317,20 @@ namespace SabreTools.Helper
|
|||||||
Manufacturer = manufacturer,
|
Manufacturer = manufacturer,
|
||||||
Year = year,
|
Year = year,
|
||||||
},
|
},
|
||||||
Type = (line.Trim().StartsWith("disk (") ? ItemType.Disk : ItemType.Rom),
|
Type = temptype,
|
||||||
Metadata = new SourceMetadata { SystemID = sysid, SourceID = srcid },
|
Metadata = new SourceMetadata { SystemID = sysid, SourceID = srcid },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// If we have a sample, treat it special
|
||||||
|
if (temptype == ItemType.Sample)
|
||||||
|
{
|
||||||
|
line = line.Trim().Remove(0, 6).Trim().Replace("\"", ""); // Remove "sample" from the input string
|
||||||
|
rom.Name = line;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, process the rest of the line
|
||||||
|
else
|
||||||
|
{
|
||||||
string[] gc = line.Trim().Split(' ');
|
string[] gc = line.Trim().Split(' ');
|
||||||
|
|
||||||
// Loop over all attributes and add them if possible
|
// Loop over all attributes and add them if possible
|
||||||
@@ -348,7 +380,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "date":
|
case "date":
|
||||||
rom.Date = gc[i].Replace("\"", "") + " " + gc[i+1].Replace("\"", "");
|
rom.Date = gc[i].Replace("\"", "") + " " + gc[i + 1].Replace("\"", "");
|
||||||
i++;
|
i++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -419,6 +451,7 @@ namespace SabreTools.Helper
|
|||||||
val = "";
|
val = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Now process and add the rom
|
// Now process and add the rom
|
||||||
string key = "";
|
string key = "";
|
||||||
@@ -529,7 +562,15 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "forcezipping":
|
case "forcezipping":
|
||||||
datdata.ForcePacking = (itemval == "yes" ? ForcePacking.Zip : ForcePacking.Unzip);
|
switch (itemval)
|
||||||
|
{
|
||||||
|
case "yes":
|
||||||
|
datdata.ForcePacking = ForcePacking.Zip;
|
||||||
|
break;
|
||||||
|
case "no":
|
||||||
|
datdata.ForcePacking = ForcePacking.Unzip;
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -962,10 +1003,15 @@ namespace SabreTools.Helper
|
|||||||
superdat = superdat || content.Contains("SuperDAT");
|
superdat = superdat || content.Contains("SuperDAT");
|
||||||
break;
|
break;
|
||||||
case "clrmamepro":
|
case "clrmamepro":
|
||||||
|
case "romcenter":
|
||||||
if (headreader.GetAttribute("header") != null)
|
if (headreader.GetAttribute("header") != null)
|
||||||
{
|
{
|
||||||
datdata.Header = (String.IsNullOrEmpty(datdata.Header) ? headreader.GetAttribute("header") : datdata.Header);
|
datdata.Header = (String.IsNullOrEmpty(datdata.Header) ? headreader.GetAttribute("header") : datdata.Header);
|
||||||
}
|
}
|
||||||
|
if (headreader.GetAttribute("plugin") != null)
|
||||||
|
{
|
||||||
|
datdata.Header = (String.IsNullOrEmpty(datdata.Header) ? headreader.GetAttribute("plugin") : datdata.Header);
|
||||||
|
}
|
||||||
if (headreader.GetAttribute("forcemerging") != null)
|
if (headreader.GetAttribute("forcemerging") != null)
|
||||||
{
|
{
|
||||||
switch (headreader.GetAttribute("forcemerging"))
|
switch (headreader.GetAttribute("forcemerging"))
|
||||||
@@ -1172,6 +1218,101 @@ namespace SabreTools.Helper
|
|||||||
case "manufacturer":
|
case "manufacturer":
|
||||||
manufacturer = subreader.ReadElementContentAsString();
|
manufacturer = subreader.ReadElementContentAsString();
|
||||||
break;
|
break;
|
||||||
|
case "release":
|
||||||
|
bool? defaultrel = null;
|
||||||
|
if (subreader.GetAttribute("default") != null)
|
||||||
|
{
|
||||||
|
if (subreader.GetAttribute("default") == "yes")
|
||||||
|
{
|
||||||
|
defaultrel = true;
|
||||||
|
}
|
||||||
|
else if (subreader.GetAttribute("default") == "no")
|
||||||
|
{
|
||||||
|
defaultrel = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rom relrom = new Rom
|
||||||
|
{
|
||||||
|
Machine = new Machine
|
||||||
|
{
|
||||||
|
Name = tempname,
|
||||||
|
Description = gamedesc,
|
||||||
|
RomOf = romof,
|
||||||
|
CloneOf = cloneof,
|
||||||
|
SampleOf = sampleof,
|
||||||
|
},
|
||||||
|
Name = subreader.GetAttribute("name"),
|
||||||
|
Type = ItemType.Release,
|
||||||
|
Region = subreader.GetAttribute("region"),
|
||||||
|
Language = subreader.GetAttribute("language"),
|
||||||
|
Default = defaultrel,
|
||||||
|
Metadata = new SourceMetadata { SystemID = sysid, System = filename, SourceID = srcid },
|
||||||
|
};
|
||||||
|
|
||||||
|
// Now process and add the rom
|
||||||
|
datdata = ParseAddHelper(relrom, datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, clean, logger, out key);
|
||||||
|
|
||||||
|
subreader.Read();
|
||||||
|
break;
|
||||||
|
case "biosset":
|
||||||
|
bool? defaultbios = null;
|
||||||
|
if (subreader.GetAttribute("default") != null)
|
||||||
|
{
|
||||||
|
if (subreader.GetAttribute("default") == "yes")
|
||||||
|
{
|
||||||
|
defaultbios = true;
|
||||||
|
}
|
||||||
|
else if (subreader.GetAttribute("default") == "no")
|
||||||
|
{
|
||||||
|
defaultbios = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rom biosrom = new Rom
|
||||||
|
{
|
||||||
|
Machine = new Machine
|
||||||
|
{
|
||||||
|
Name = tempname,
|
||||||
|
Description = gamedesc,
|
||||||
|
RomOf = romof,
|
||||||
|
CloneOf = cloneof,
|
||||||
|
SampleOf = sampleof,
|
||||||
|
},
|
||||||
|
Name = subreader.GetAttribute("name"),
|
||||||
|
Type = ItemType.BiosSet,
|
||||||
|
Description = subreader.GetAttribute("description"),
|
||||||
|
Default = defaultbios,
|
||||||
|
Metadata = new SourceMetadata { SystemID = sysid, System = filename, SourceID = srcid },
|
||||||
|
};
|
||||||
|
|
||||||
|
// Now process and add the rom
|
||||||
|
datdata = ParseAddHelper(biosrom, datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, clean, logger, out key);
|
||||||
|
|
||||||
|
subreader.Read();
|
||||||
|
break;
|
||||||
|
case "archive":
|
||||||
|
case "sample":
|
||||||
|
Rom samplerom = new Rom
|
||||||
|
{
|
||||||
|
Machine = new Machine
|
||||||
|
{
|
||||||
|
Name = tempname,
|
||||||
|
Description = gamedesc,
|
||||||
|
RomOf = romof,
|
||||||
|
CloneOf = cloneof,
|
||||||
|
SampleOf = sampleof,
|
||||||
|
},
|
||||||
|
Name = subreader.GetAttribute("name"),
|
||||||
|
Type = (subreader.Name == "sample" ? ItemType.Sample : ItemType.Archive),
|
||||||
|
Metadata = new SourceMetadata { SystemID = sysid, System = filename, SourceID = srcid },
|
||||||
|
};
|
||||||
|
|
||||||
|
// Now process and add the rom
|
||||||
|
datdata = ParseAddHelper(samplerom, datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, clean, logger, out key);
|
||||||
|
|
||||||
|
subreader.Read();
|
||||||
|
break;
|
||||||
case "rom":
|
case "rom":
|
||||||
case "disk":
|
case "disk":
|
||||||
empty = false;
|
empty = false;
|
||||||
@@ -3071,7 +3212,9 @@ namespace SabreTools.Helper
|
|||||||
state += rom.HashData.SHA1 + " *" + rom.Name + "\n";
|
state += rom.HashData.SHA1 + " *" + rom.Name + "\n";
|
||||||
break;
|
break;
|
||||||
case OutputFormat.RomCenter:
|
case OutputFormat.RomCenter:
|
||||||
state += "¬¬¬" + HttpUtility.HtmlEncode(rom.Machine) +
|
state += "¬" + (String.IsNullOrEmpty(rom.Machine.CloneOf) ? "" : HttpUtility.HtmlEncode(rom.Machine.CloneOf)) +
|
||||||
|
"¬" + (String.IsNullOrEmpty(rom.Machine.CloneOf) ? "" : HttpUtility.HtmlEncode(rom.Machine.CloneOf)) +
|
||||||
|
"¬" + HttpUtility.HtmlEncode(rom.Machine.Name) +
|
||||||
"¬" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.Machine.Description) ? rom.Machine.Name : rom.Machine.Description)) +
|
"¬" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.Machine.Description) ? rom.Machine.Name : rom.Machine.Description)) +
|
||||||
"¬" + HttpUtility.HtmlEncode(rom.Name) +
|
"¬" + HttpUtility.HtmlEncode(rom.Name) +
|
||||||
"¬" + rom.HashData.CRC.ToLowerInvariant() +
|
"¬" + rom.HashData.CRC.ToLowerInvariant() +
|
||||||
|
|||||||
Reference in New Issue
Block a user