[Structs] Add GameDescription to Rom

This commit is contained in:
Matt Nadareski
2016-08-29 12:02:25 -07:00
parent 9d8c012317
commit 220b898c83
3 changed files with 18 additions and 5 deletions

View File

@@ -9,6 +9,7 @@ namespace SabreTools.Helper
public struct Rom : IComparable, IEquatable<Rom>
{
public string Game;
public string GameDescription;
public string Name;
public string Type;
public long Size;

View File

@@ -140,7 +140,7 @@ namespace SabreTools.Helper
StreamReader sr = new StreamReader(File.OpenRead(filename));
bool block = false, superdat = false;
string blockname = "", gamename = "";
string blockname = "", gamename = "", gamedesc = "";
while (!sr.EndOfStream)
{
string line = sr.ReadLine();
@@ -173,6 +173,7 @@ namespace SabreTools.Helper
Rom rom = new Rom
{
Game = gamename,
GameDescription = gamedesc,
Type = (line.Trim().StartsWith("disk (") ? "disk" : "rom"),
Metadata = new SourceMetadata { SystemID = sysid, SourceID = srcid },
};
@@ -347,6 +348,10 @@ namespace SabreTools.Helper
{
gamename = gc[2].Value.Replace("\"", "");
}
else if (gc[1].Value == "description" && blockname != "header")
{
gamedesc = gc[2].Value.Replace("\"", "");
}
else
{
string itemval = gc[2].Value.Replace("\"", "");
@@ -561,6 +566,7 @@ namespace SabreTools.Helper
Rom rom = new Rom
{
Game = rominfo[3],
GameDescription = rominfo[4],
Name = rominfo[5],
CRC = rominfo[6].ToLowerInvariant(),
Size = Int64.Parse(rominfo[7]),
@@ -667,6 +673,7 @@ namespace SabreTools.Helper
Type = "rom",
Name = "null",
Game = tempgame,
GameDescription = tempgame,
Size = -1,
CRC = "null",
MD5 = "null",
@@ -965,7 +972,7 @@ namespace SabreTools.Helper
case "game":
case "software":
string temptype = xtr.Name;
string tempname = "";
string tempname = "", gamedesc = "";
// We want to process the entire subtree of the game
subreader = xtr.ReadSubtree();
@@ -1021,6 +1028,9 @@ namespace SabreTools.Helper
// Get the roms from the machine
switch (subreader.Name)
{
case "description":
gamedesc = subreader.ReadElementContentAsString();
break;
case "rom":
case "disk":
empty = false;
@@ -1105,6 +1115,7 @@ namespace SabreTools.Helper
Rom rom = new Rom
{
Game = tempname,
GameDescription = gamedesc,
Name = subreader.GetAttribute("name"),
Type = subreader.Name,
Size = size,
@@ -1159,6 +1170,7 @@ namespace SabreTools.Helper
Type = "rom",
Name = "null",
Game = tempname,
GameDescription = tempname,
Size = -1,
CRC = "null",
MD5 = "null",

View File

@@ -300,7 +300,7 @@ namespace SabreTools.Helper
{
case OutputFormat.ClrMamePro:
state += "game (\n\tname \"" + rom.Game + "\"\n" +
"\tdescription \"" + rom.Game + "\"\n";
"\tdescription \"" + (String.IsNullOrEmpty(rom.GameDescription) ? rom.Game : rom.GameDescription) + "\"\n";
break;
case OutputFormat.SabreDat:
for (int i = (last == -1 ? 0 : last); i < newsplit.Count; i++)
@@ -316,7 +316,7 @@ namespace SabreTools.Helper
break;
case OutputFormat.Xml:
state += "\t<machine name=\"" + HttpUtility.HtmlEncode(rom.Game) + "\">\n" +
"\t\t<description>" + HttpUtility.HtmlEncode(rom.Game) + "</description>\n";
"\t\t<description>" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.GameDescription) ? rom.Game : rom.GameDescription)) + "</description>\n";
break;
}
@@ -497,7 +497,7 @@ namespace SabreTools.Helper
break;
case OutputFormat.RomCenter:
state += "¬¬¬" + HttpUtility.HtmlEncode(rom.Game) +
"¬" + HttpUtility.HtmlEncode(rom.Game) +
"¬" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.GameDescription) ? rom.Game : rom.GameDescription)) +
"¬" + HttpUtility.HtmlEncode(rom.Name) +
"¬" + rom.CRC.ToLowerInvariant() +
"¬" + (rom.Size != -1 ? rom.Size.ToString() : "") + "¬¬¬\n";