[Structs] Rename Rom field "Game" to "Machine"

This commit is contained in:
Matt Nadareski
2016-08-29 13:42:27 -07:00
parent 5c0b5bfcbb
commit 19a210562e
8 changed files with 77 additions and 77 deletions

View File

@@ -21,7 +21,7 @@ namespace SabreTools.Helper
/// <param name="rom">RomData representing the new information</param>
public static void WriteToArchive(string input, string output, Rom rom)
{
string archiveFileName = Path.Combine(output, rom.Game + ".zip");
string archiveFileName = Path.Combine(output, rom.Machine + ".zip");
System.IO.Compression.ZipArchive outarchive = null;
try
@@ -71,7 +71,7 @@ namespace SabreTools.Helper
/// <param name="rom">RomData representing the new information</param>
public static void WriteToManagedArchive(string input, string output, Rom rom)
{
string archiveFileName = Path.Combine(output, rom.Game + ".zip");
string archiveFileName = Path.Combine(output, rom.Machine + ".zip");
// Delete an empty file first
if (File.Exists(archiveFileName) && new FileInfo(archiveFileName).Length == 0)
@@ -538,7 +538,7 @@ namespace SabreTools.Helper
{
Type = "rom",
Name = reader.Entry.Key,
Game = new Machine
Machine = new Machine
{
Name = gamename,
},
@@ -621,7 +621,7 @@ namespace SabreTools.Helper
Rom rom = new Rom
{
Type = "rom",
Game = new Machine
Machine = new Machine
{
Name = Path.GetFileNameWithoutExtension(input).ToLowerInvariant(),
},

View File

@@ -172,7 +172,7 @@ namespace SabreTools.Helper
Rom rom = new Rom
{
Game = new Machine
Machine = new Machine
{
Name = gamename,
Description = gamedesc,
@@ -568,7 +568,7 @@ namespace SabreTools.Helper
Rom rom = new Rom
{
Game = new Machine
Machine = new Machine
{
Name = rominfo[3],
Description = rominfo[4],
@@ -681,7 +681,7 @@ namespace SabreTools.Helper
{
Type = "rom",
Name = "null",
Game = new Machine
Machine = new Machine
{
Name = tempgame,
Description = tempgame,
@@ -1129,7 +1129,7 @@ namespace SabreTools.Helper
Rom rom = new Rom
{
Game = new Machine
Machine = new Machine
{
Name = tempname,
Description = gamedesc,
@@ -1190,7 +1190,7 @@ namespace SabreTools.Helper
{
Type = "rom",
Name = "null",
Game = new Machine
Machine = new Machine
{
Name = tempname,
Description = tempname,
@@ -1369,7 +1369,7 @@ namespace SabreTools.Helper
Rom rom = new Rom
{
Game = new Machine
Machine = new Machine
{
Name = tempname,
},
@@ -1474,9 +1474,9 @@ namespace SabreTools.Helper
: rom.Metadata.SystemID.ToString().PadLeft(10, '0')
+ "-"
+ rom.Metadata.SourceID.ToString().PadLeft(10, '0') + "-")
+ (String.IsNullOrEmpty(rom.Game.Name)
+ (String.IsNullOrEmpty(rom.Machine.Name)
? ""
: rom.Game.Name.ToLowerInvariant());
: rom.Machine.Name.ToLowerInvariant());
if (sortable.ContainsKey(newkey))
{
sortable[newkey].Add(rom);
@@ -1832,15 +1832,15 @@ namespace SabreTools.Helper
// Filter on game name
if (gamename != "")
{
if (gamename.StartsWith("*") && gamename.EndsWith("*") && !rom.Game.Name.ToLowerInvariant().Contains(gamename.ToLowerInvariant().Replace("*", "")))
if (gamename.StartsWith("*") && gamename.EndsWith("*") && !rom.Machine.Name.ToLowerInvariant().Contains(gamename.ToLowerInvariant().Replace("*", "")))
{
continue;
}
else if (gamename.StartsWith("*") && !rom.Game.Name.EndsWith(gamename.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
else if (gamename.StartsWith("*") && !rom.Machine.Name.EndsWith(gamename.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
{
continue;
}
else if (gamename.EndsWith("*") && !rom.Game.Name.StartsWith(gamename.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
else if (gamename.EndsWith("*") && !rom.Machine.Name.StartsWith(gamename.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
{
continue;
}
@@ -1940,14 +1940,14 @@ namespace SabreTools.Helper
// If we are in single game mode, rename all games
if (single)
{
rom.Game.Name = "!";
rom.Machine.Name = "!";
}
// If we are in NTFS trim mode, trim the game name
if (trim)
{
// Windows max name length is 260
int usableLength = 260 - rom.Game.Name.Length - root.Length;
int usableLength = 260 - rom.Machine.Name.Length - root.Length;
if (rom.Name.Length > usableLength)
{
string ext = Path.GetExtension(rom.Name);
@@ -2071,7 +2071,7 @@ namespace SabreTools.Helper
if ((diff & DiffMode.NoDupes) != 0)
{
Rom newrom = rom;
newrom.Game.Name += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
newrom.Machine.Name += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
if (outerDiffData.Roms.ContainsKey(key))
{
@@ -2093,7 +2093,7 @@ namespace SabreTools.Helper
if (rom.Dupe >= DupeType.ExternalHash)
{
Rom newrom = rom;
newrom.Game.Name += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
newrom.Machine.Name += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
if (dupeData.Roms.ContainsKey(key))
{
@@ -2265,9 +2265,9 @@ namespace SabreTools.Helper
rootpath += (rootpath == "" ? "" : Path.DirectorySeparatorChar.ToString());
filename = filename.Remove(0, rootpath.Length);
newrom.Game.Name = Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar
newrom.Machine.Name = Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar
+ Path.GetFileNameWithoutExtension(filename) + Path.DirectorySeparatorChar
+ newrom.Game.Name;
+ newrom.Machine.Name;
newroms.Add(newrom);
}
userData.Roms[key] = newroms;

View File

@@ -100,16 +100,16 @@ namespace SabreTools.Helper
for (int index = 0; index < roms.Count; index++)
{
Rom rom = roms[index];
List<string> newsplit = rom.Game.Name.Split('\\').ToList();
List<string> newsplit = rom.Machine.Name.Split('\\').ToList();
// If we have a different game and we're not at the start of the list, output the end of last item
if (lastgame != null && lastgame.ToLowerInvariant() != rom.Game.Name.ToLowerInvariant())
if (lastgame != null && lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
{
depth = WriteEndGame(sw, rom, splitpath, newsplit, lastgame, datdata, depth, out last, logger);
}
// If we have a new game, output the beginning of the new item
if (lastgame == null || lastgame.ToLowerInvariant() != rom.Game.Name.ToLowerInvariant())
if (lastgame == null || lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
{
depth = WriteStartGame(sw, rom, newsplit, lastgame, datdata, depth, last, logger);
}
@@ -117,7 +117,7 @@ namespace SabreTools.Helper
// If we have a "null" game (created by DATFromDir or something similar), log it to file
if (rom.Name == "null" && rom.HashData.Size == -1 && rom.HashData.CRC == "null" && rom.HashData.MD5 == "null" && rom.HashData.SHA1 == "null")
{
logger.Log("Empty folder found: " + rom.Game);
logger.Log("Empty folder found: " + rom.Machine);
// If we're in a mode that doesn't allow for actual empty folders, add the blank info
if (datdata.OutputFormat != OutputFormat.SabreDat && datdata.OutputFormat != OutputFormat.MissFile)
@@ -133,7 +133,7 @@ namespace SabreTools.Helper
else
{
splitpath = newsplit;
lastgame = rom.Game.Name;
lastgame = rom.Machine.Name;
continue;
}
}
@@ -143,7 +143,7 @@ namespace SabreTools.Helper
// Set the new data to compare against
splitpath = newsplit;
lastgame = rom.Game.Name;
lastgame = rom.Machine.Name;
}
}
@@ -290,17 +290,17 @@ namespace SabreTools.Helper
try
{
// No game should start with a path separator
if (rom.Game.Name.StartsWith(Path.DirectorySeparatorChar.ToString()))
if (rom.Machine.Name.StartsWith(Path.DirectorySeparatorChar.ToString()))
{
rom.Game.Name = rom.Game.Name.Substring(1);
rom.Machine.Name = rom.Machine.Name.Substring(1);
}
string state = "";
switch (datdata.OutputFormat)
{
case OutputFormat.ClrMamePro:
state += "game (\n\tname \"" + rom.Game + "\"\n" +
"\tdescription \"" + (String.IsNullOrEmpty(rom.Game.Description) ? rom.Game.Name : rom.Game.Description) + "\"\n";
state += "game (\n\tname \"" + rom.Machine + "\"\n" +
"\tdescription \"" + (String.IsNullOrEmpty(rom.Machine.Description) ? rom.Machine.Name : rom.Machine.Description) + "\"\n";
break;
case OutputFormat.SabreDat:
for (int i = (last == -1 ? 0 : last); i < newsplit.Count; i++)
@@ -315,8 +315,8 @@ namespace SabreTools.Helper
depth = depth - (last == -1 ? 0 : last) + newsplit.Count;
break;
case OutputFormat.Xml:
state += "\t<machine name=\"" + HttpUtility.HtmlEncode(rom.Game) + "\">\n" +
"\t\t<description>" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.Game.Description) ? rom.Game.Name : rom.Game.Description)) + "</description>\n";
state += "\t<machine name=\"" + HttpUtility.HtmlEncode(rom.Machine) + "\">\n" +
"\t\t<description>" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.Machine.Description) ? rom.Machine.Name : rom.Machine.Description)) + "</description>\n";
break;
}
@@ -452,7 +452,7 @@ namespace SabreTools.Helper
// If we're in TSV mode, similarly the state is consistent
else if (datdata.TSV == true)
{
string inline = "\"" + datdata.FileName + "\"\t\"" + datdata.Name + "\"\t\"" + datdata.Description + "\"\t\"" + rom.Game + "\"\t\"" + rom.Game + "\"\t\"" +
string inline = "\"" + datdata.FileName + "\"\t\"" + datdata.Name + "\"\t\"" + datdata.Description + "\"\t\"" + rom.Machine + "\"\t\"" + rom.Machine + "\"\t\"" +
rom.Type + "\"\t\"" + (rom.Type == "rom" ? rom.Name : "") + "\"\t\"" + (rom.Type == "disk" ? rom.Name : "") + "\"\t\"" + rom.HashData.Size + "\"\t\"" +
rom.HashData.CRC + "\"\t\"" + rom.HashData.MD5 + "\"\t\"" + rom.HashData.SHA1 + "\"\t" + (rom.Nodump ? "\"Nodump\"" : "\"\"");
state += pre + inline + post + "\n";
@@ -460,7 +460,7 @@ namespace SabreTools.Helper
// If we're in CSV mode, similarly the state is consistent
else if (datdata.TSV == false)
{
string inline = "\"" + datdata.FileName + "\",\"" + datdata.Name + "\",\"" + datdata.Description + "\",\"" + rom.Game + "\",\"" + rom.Game + "\",\"" +
string inline = "\"" + datdata.FileName + "\",\"" + datdata.Name + "\",\"" + datdata.Description + "\",\"" + rom.Machine + "\",\"" + rom.Machine + "\",\"" +
rom.Type + "\",\"" + (rom.Type == "rom" ? rom.Name : "") + "\",\"" + (rom.Type == "disk" ? rom.Name : "") + "\",\"" + rom.HashData.Size + "\",\"" +
rom.HashData.CRC + "\",\"" + rom.HashData.MD5 + "\",\"" + rom.HashData.SHA1 + "\"," + (rom.Nodump ? "\"Nodump\"" : "\"\"");
state += pre + inline + post + "\n";
@@ -468,7 +468,7 @@ namespace SabreTools.Helper
// Otherwise, use any flags
else
{
string name = (datdata.UseGame ? rom.Game.Name : rom.Name);
string name = (datdata.UseGame ? rom.Machine.Name : rom.Name);
if (datdata.RepExt != "")
{
string dir = Path.GetDirectoryName(name);
@@ -481,13 +481,13 @@ namespace SabreTools.Helper
}
if (!datdata.UseGame && datdata.GameName)
{
name = Path.Combine(rom.Game.Name, name);
name = Path.Combine(rom.Machine.Name, name);
}
if (datdata.UseGame && rom.Game.Name != lastgame)
if (datdata.UseGame && rom.Machine.Name != lastgame)
{
state += pre + name + post + "\n";
lastgame = rom.Game.Name;
lastgame = rom.Machine.Name;
}
else if (!datdata.UseGame)
{
@@ -496,8 +496,8 @@ namespace SabreTools.Helper
}
break;
case OutputFormat.RomCenter:
state += "¬¬¬" + HttpUtility.HtmlEncode(rom.Game) +
"¬" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.Game.Description) ? rom.Game.Name : rom.Game.Description)) +
state += "¬¬¬" + HttpUtility.HtmlEncode(rom.Machine) +
"¬" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.Machine.Description) ? rom.Machine.Name : rom.Machine.Description)) +
"¬" + HttpUtility.HtmlEncode(rom.Name) +
"¬" + rom.HashData.CRC.ToLowerInvariant() +
"¬" + (rom.HashData.Size != -1 ? rom.HashData.Size.ToString() : "") + "¬¬¬\n";

View File

@@ -147,7 +147,7 @@ namespace SabreTools.Helper
{
savedrom.Metadata.SystemID = rom.Metadata.SystemID;
savedrom.Metadata.System = rom.Metadata.System;
savedrom.Game.Name = rom.Game.Name;
savedrom.Machine.Name = rom.Machine.Name;
savedrom.Name = rom.Name;
}
@@ -156,7 +156,7 @@ namespace SabreTools.Helper
{
savedrom.Metadata.SourceID = rom.Metadata.SourceID;
savedrom.Metadata.Source = rom.Metadata.Source;
savedrom.Game.Name = rom.Game.Name;
savedrom.Machine.Name = rom.Machine.Name;
savedrom.Name = rom.Name;
}
@@ -287,7 +287,7 @@ namespace SabreTools.Helper
// If the duplicate is external already or should be, set it
if (lastrom.Dupe >= DupeType.ExternalHash || lastrom.Metadata.SystemID != rom.Metadata.SystemID || lastrom.Metadata.SourceID != rom.Metadata.SourceID)
{
if (lastrom.Game.Name == rom.Game.Name && lastrom.Name == rom.Name)
if (lastrom.Machine.Name == rom.Machine.Name && lastrom.Name == rom.Name)
{
output = DupeType.ExternalAll;
}
@@ -300,7 +300,7 @@ namespace SabreTools.Helper
// Otherwise, it's considered an internal dupe
else
{
if (lastrom.Game.Name == rom.Game.Name && lastrom.Name == rom.Name)
if (lastrom.Machine.Name == rom.Machine.Name && lastrom.Name == rom.Name)
{
output = DupeType.InternalAll;
}
@@ -327,15 +327,15 @@ namespace SabreTools.Helper
{
if (x.Metadata.SourceID == y.Metadata.SourceID)
{
if (x.Game.Name == y.Game.Name)
if (x.Machine.Name == y.Machine.Name)
{
return String.Compare(x.Name, y.Name);
}
return String.Compare(x.Game.Name, y.Game.Name);
return String.Compare(x.Machine.Name, y.Machine.Name);
}
return (norename ? String.Compare(x.Game.Name, y.Game.Name) : x.Metadata.SourceID - y.Metadata.SourceID);
return (norename ? String.Compare(x.Machine.Name, y.Machine.Name) : x.Metadata.SourceID - y.Metadata.SourceID);
}
return (norename ? String.Compare(x.Game.Name, y.Game.Name) : x.Metadata.SystemID - y.Metadata.SystemID);
return (norename ? String.Compare(x.Machine.Name, y.Machine.Name) : x.Metadata.SystemID - y.Metadata.SystemID);
});
return true;
}