mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Structs] Add Machine struct
This commit is contained in:
@@ -46,8 +46,7 @@ namespace SabreTools.Helper
|
||||
/// </summary>
|
||||
public struct Rom : IComparable, IEquatable<Rom>
|
||||
{
|
||||
public string Game;
|
||||
public string GameDescription;
|
||||
public Machine Game;
|
||||
public string Name;
|
||||
public string Type;
|
||||
public HashData HashData;
|
||||
@@ -67,7 +66,7 @@ namespace SabreTools.Helper
|
||||
{
|
||||
Rom comp = (Rom)obj;
|
||||
|
||||
if (this.Game == comp.Game)
|
||||
if (this.Game.Name == comp.Game.Name)
|
||||
{
|
||||
if (this.Name == comp.Name)
|
||||
{
|
||||
@@ -75,7 +74,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
ret = String.Compare(this.Name, comp.Name);
|
||||
}
|
||||
ret = String.Compare(this.Game, comp.Game);
|
||||
ret = String.Compare(this.Game.Name, comp.Game.Name);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -93,7 +92,7 @@ namespace SabreTools.Helper
|
||||
bool isdupe = RomTools.IsDuplicate(this, other, temp);
|
||||
temp.Close();
|
||||
|
||||
return (this.Game == other.Game &&
|
||||
return (this.Game.Name == other.Game.Name &&
|
||||
this.Name == other.Name &&
|
||||
isdupe);
|
||||
}
|
||||
@@ -110,6 +109,25 @@ namespace SabreTools.Helper
|
||||
public string Source;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intermediate struct for holding and processing Rom/Machine data
|
||||
/// </summary>
|
||||
public struct Machine
|
||||
{
|
||||
public string Name;
|
||||
public string Comment;
|
||||
public string Description;
|
||||
public string Year;
|
||||
public string Manufacturer;
|
||||
public string RomOf;
|
||||
public string CloneOf;
|
||||
public string SampleOf;
|
||||
public string SourceFile;
|
||||
public bool IsBios;
|
||||
public string Board;
|
||||
public string RebuildTo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intermediate struct for holding DAT information
|
||||
/// </summary>
|
||||
|
||||
@@ -538,7 +538,10 @@ namespace SabreTools.Helper
|
||||
{
|
||||
Type = "rom",
|
||||
Name = reader.Entry.Key,
|
||||
Game = gamename,
|
||||
Game = new Machine
|
||||
{
|
||||
Name = gamename,
|
||||
},
|
||||
HashData = new HashData
|
||||
{
|
||||
Size = (size == 0 ? reader.Entry.Size : size),
|
||||
@@ -618,7 +621,10 @@ namespace SabreTools.Helper
|
||||
Rom rom = new Rom
|
||||
{
|
||||
Type = "rom",
|
||||
Game = Path.GetFileNameWithoutExtension(input).ToLowerInvariant(),
|
||||
Game = new Machine
|
||||
{
|
||||
Name = Path.GetFileNameWithoutExtension(input).ToLowerInvariant(),
|
||||
},
|
||||
Name = Path.GetFileNameWithoutExtension(input).ToLowerInvariant(),
|
||||
HashData = new HashData
|
||||
{
|
||||
|
||||
@@ -172,8 +172,11 @@ namespace SabreTools.Helper
|
||||
|
||||
Rom rom = new Rom
|
||||
{
|
||||
Game = gamename,
|
||||
GameDescription = gamedesc,
|
||||
Game = new Machine
|
||||
{
|
||||
Name = gamename,
|
||||
Description = gamedesc,
|
||||
},
|
||||
Type = (line.Trim().StartsWith("disk (") ? "disk" : "rom"),
|
||||
Metadata = new SourceMetadata { SystemID = sysid, SourceID = srcid },
|
||||
};
|
||||
@@ -565,8 +568,11 @@ namespace SabreTools.Helper
|
||||
|
||||
Rom rom = new Rom
|
||||
{
|
||||
Game = rominfo[3],
|
||||
GameDescription = rominfo[4],
|
||||
Game = new Machine
|
||||
{
|
||||
Name = rominfo[3],
|
||||
Description = rominfo[4],
|
||||
},
|
||||
Name = rominfo[5],
|
||||
HashData = new HashData
|
||||
{
|
||||
@@ -675,8 +681,11 @@ namespace SabreTools.Helper
|
||||
{
|
||||
Type = "rom",
|
||||
Name = "null",
|
||||
Game = tempgame,
|
||||
GameDescription = tempgame,
|
||||
Game = new Machine
|
||||
{
|
||||
Name = tempgame,
|
||||
Description = tempgame,
|
||||
},
|
||||
HashData = new HashData
|
||||
{
|
||||
Size = -1,
|
||||
@@ -1120,8 +1129,11 @@ namespace SabreTools.Helper
|
||||
|
||||
Rom rom = new Rom
|
||||
{
|
||||
Game = tempname,
|
||||
GameDescription = gamedesc,
|
||||
Game = new Machine
|
||||
{
|
||||
Name = tempname,
|
||||
Description = gamedesc,
|
||||
},
|
||||
Name = subreader.GetAttribute("name"),
|
||||
Type = subreader.Name,
|
||||
HashData = new HashData
|
||||
@@ -1178,8 +1190,11 @@ namespace SabreTools.Helper
|
||||
{
|
||||
Type = "rom",
|
||||
Name = "null",
|
||||
Game = tempname,
|
||||
GameDescription = tempname,
|
||||
Game = new Machine
|
||||
{
|
||||
Name = tempname,
|
||||
Description = tempname,
|
||||
},
|
||||
HashData = new HashData
|
||||
{
|
||||
Size = -1,
|
||||
@@ -1354,7 +1369,10 @@ namespace SabreTools.Helper
|
||||
|
||||
Rom rom = new Rom
|
||||
{
|
||||
Game = tempname,
|
||||
Game = new Machine
|
||||
{
|
||||
Name = tempname,
|
||||
},
|
||||
Name = xtr.GetAttribute("name"),
|
||||
Type = xtr.GetAttribute("type"),
|
||||
HashData = new HashData
|
||||
@@ -1452,7 +1470,13 @@ namespace SabreTools.Helper
|
||||
foreach (Rom rom in roms)
|
||||
{
|
||||
count++;
|
||||
string newkey = (norename ? "" : rom.Metadata.SystemID.ToString().PadLeft(10, '0') + "-" + rom.Metadata.SourceID.ToString().PadLeft(10, '0') + "-") + (String.IsNullOrEmpty(rom.Game) ? "" : rom.Game.ToLowerInvariant());
|
||||
string newkey = (norename ? ""
|
||||
: rom.Metadata.SystemID.ToString().PadLeft(10, '0')
|
||||
+ "-"
|
||||
+ rom.Metadata.SourceID.ToString().PadLeft(10, '0') + "-")
|
||||
+ (String.IsNullOrEmpty(rom.Game.Name)
|
||||
? ""
|
||||
: rom.Game.Name.ToLowerInvariant());
|
||||
if (sortable.ContainsKey(newkey))
|
||||
{
|
||||
sortable[newkey].Add(rom);
|
||||
@@ -1808,15 +1832,15 @@ namespace SabreTools.Helper
|
||||
// Filter on game name
|
||||
if (gamename != "")
|
||||
{
|
||||
if (gamename.StartsWith("*") && gamename.EndsWith("*") && !rom.Game.ToLowerInvariant().Contains(gamename.ToLowerInvariant().Replace("*", "")))
|
||||
if (gamename.StartsWith("*") && gamename.EndsWith("*") && !rom.Game.Name.ToLowerInvariant().Contains(gamename.ToLowerInvariant().Replace("*", "")))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (gamename.StartsWith("*") && !rom.Game.EndsWith(gamename.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
||||
else if (gamename.StartsWith("*") && !rom.Game.Name.EndsWith(gamename.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (gamename.EndsWith("*") && !rom.Game.StartsWith(gamename.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
||||
else if (gamename.EndsWith("*") && !rom.Game.Name.StartsWith(gamename.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -1916,14 +1940,14 @@ namespace SabreTools.Helper
|
||||
// If we are in single game mode, rename all games
|
||||
if (single)
|
||||
{
|
||||
rom.Game = "!";
|
||||
rom.Game.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.Length - root.Length;
|
||||
int usableLength = 260 - rom.Game.Name.Length - root.Length;
|
||||
if (rom.Name.Length > usableLength)
|
||||
{
|
||||
string ext = Path.GetExtension(rom.Name);
|
||||
@@ -2047,7 +2071,7 @@ namespace SabreTools.Helper
|
||||
if ((diff & DiffMode.NoDupes) != 0)
|
||||
{
|
||||
Rom newrom = rom;
|
||||
newrom.Game += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
||||
newrom.Game.Name += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
||||
|
||||
if (outerDiffData.Roms.ContainsKey(key))
|
||||
{
|
||||
@@ -2069,7 +2093,7 @@ namespace SabreTools.Helper
|
||||
if (rom.Dupe >= DupeType.ExternalHash)
|
||||
{
|
||||
Rom newrom = rom;
|
||||
newrom.Game += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
||||
newrom.Game.Name += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
||||
|
||||
if (dupeData.Roms.ContainsKey(key))
|
||||
{
|
||||
@@ -2241,9 +2265,9 @@ namespace SabreTools.Helper
|
||||
|
||||
rootpath += (rootpath == "" ? "" : Path.DirectorySeparatorChar.ToString());
|
||||
filename = filename.Remove(0, rootpath.Length);
|
||||
newrom.Game = Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar
|
||||
newrom.Game.Name = Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar
|
||||
+ Path.GetFileNameWithoutExtension(filename) + Path.DirectorySeparatorChar
|
||||
+ newrom.Game;
|
||||
+ newrom.Game.Name;
|
||||
newroms.Add(newrom);
|
||||
}
|
||||
userData.Roms[key] = newroms;
|
||||
|
||||
@@ -100,16 +100,16 @@ namespace SabreTools.Helper
|
||||
for (int index = 0; index < roms.Count; index++)
|
||||
{
|
||||
Rom rom = roms[index];
|
||||
List<string> newsplit = rom.Game.Split('\\').ToList();
|
||||
List<string> newsplit = rom.Game.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.ToLowerInvariant())
|
||||
if (lastgame != null && lastgame.ToLowerInvariant() != rom.Game.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.ToLowerInvariant())
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.Game.Name.ToLowerInvariant())
|
||||
{
|
||||
depth = WriteStartGame(sw, rom, newsplit, lastgame, datdata, depth, last, logger);
|
||||
}
|
||||
@@ -133,7 +133,7 @@ namespace SabreTools.Helper
|
||||
else
|
||||
{
|
||||
splitpath = newsplit;
|
||||
lastgame = rom.Game;
|
||||
lastgame = rom.Game.Name;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -143,7 +143,7 @@ namespace SabreTools.Helper
|
||||
|
||||
// Set the new data to compare against
|
||||
splitpath = newsplit;
|
||||
lastgame = rom.Game;
|
||||
lastgame = rom.Game.Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,9 +290,9 @@ namespace SabreTools.Helper
|
||||
try
|
||||
{
|
||||
// No game should start with a path separator
|
||||
if (rom.Game.StartsWith(Path.DirectorySeparatorChar.ToString()))
|
||||
if (rom.Game.Name.StartsWith(Path.DirectorySeparatorChar.ToString()))
|
||||
{
|
||||
rom.Game = rom.Game.Substring(1);
|
||||
rom.Game.Name = rom.Game.Name.Substring(1);
|
||||
}
|
||||
|
||||
string state = "";
|
||||
@@ -300,7 +300,7 @@ namespace SabreTools.Helper
|
||||
{
|
||||
case OutputFormat.ClrMamePro:
|
||||
state += "game (\n\tname \"" + rom.Game + "\"\n" +
|
||||
"\tdescription \"" + (String.IsNullOrEmpty(rom.GameDescription) ? rom.Game : rom.GameDescription) + "\"\n";
|
||||
"\tdescription \"" + (String.IsNullOrEmpty(rom.Game.Description) ? rom.Game.Name : rom.Game.Description) + "\"\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((String.IsNullOrEmpty(rom.GameDescription) ? rom.Game : rom.GameDescription)) + "</description>\n";
|
||||
"\t\t<description>" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.Game.Description) ? rom.Game.Name : rom.Game.Description)) + "</description>\n";
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -468,7 +468,7 @@ namespace SabreTools.Helper
|
||||
// Otherwise, use any flags
|
||||
else
|
||||
{
|
||||
string name = (datdata.UseGame ? rom.Game : rom.Name);
|
||||
string name = (datdata.UseGame ? rom.Game.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 = Path.Combine(rom.Game.Name, name);
|
||||
}
|
||||
|
||||
if (datdata.UseGame && rom.Game != lastgame)
|
||||
if (datdata.UseGame && rom.Game.Name != lastgame)
|
||||
{
|
||||
state += pre + name + post + "\n";
|
||||
lastgame = rom.Game;
|
||||
lastgame = rom.Game.Name;
|
||||
}
|
||||
else if (!datdata.UseGame)
|
||||
{
|
||||
@@ -497,7 +497,7 @@ namespace SabreTools.Helper
|
||||
break;
|
||||
case OutputFormat.RomCenter:
|
||||
state += "¬¬¬" + HttpUtility.HtmlEncode(rom.Game) +
|
||||
"¬" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.GameDescription) ? rom.Game : rom.GameDescription)) +
|
||||
"¬" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.Game.Description) ? rom.Game.Name : rom.Game.Description)) +
|
||||
"¬" + HttpUtility.HtmlEncode(rom.Name) +
|
||||
"¬" + rom.HashData.CRC.ToLowerInvariant() +
|
||||
"¬" + (rom.HashData.Size != -1 ? rom.HashData.Size.ToString() : "") + "¬¬¬\n";
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace SabreTools.Helper
|
||||
{
|
||||
savedrom.Metadata.SystemID = rom.Metadata.SystemID;
|
||||
savedrom.Metadata.System = rom.Metadata.System;
|
||||
savedrom.Game = rom.Game;
|
||||
savedrom.Game.Name = rom.Game.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 = rom.Game;
|
||||
savedrom.Game.Name = rom.Game.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 == rom.Game && lastrom.Name == rom.Name)
|
||||
if (lastrom.Game.Name == rom.Game.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 == rom.Game && lastrom.Name == rom.Name)
|
||||
if (lastrom.Game.Name == rom.Game.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 == y.Game)
|
||||
if (x.Game.Name == y.Game.Name)
|
||||
{
|
||||
return String.Compare(x.Name, y.Name);
|
||||
}
|
||||
return String.Compare(x.Game, y.Game);
|
||||
return String.Compare(x.Game.Name, y.Game.Name);
|
||||
}
|
||||
return (norename ? String.Compare(x.Game, y.Game) : x.Metadata.SourceID - y.Metadata.SourceID);
|
||||
return (norename ? String.Compare(x.Game.Name, y.Game.Name) : x.Metadata.SourceID - y.Metadata.SourceID);
|
||||
}
|
||||
return (norename ? String.Compare(x.Game, y.Game) : x.Metadata.SystemID - y.Metadata.SystemID);
|
||||
return (norename ? String.Compare(x.Game.Name, y.Game.Name) : x.Metadata.SystemID - y.Metadata.SystemID);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -173,11 +173,14 @@ namespace SabreTools
|
||||
Rom rom = new Rom
|
||||
{
|
||||
Name = "null",
|
||||
Game = (_datdata.Type == "SuperDAT" ?
|
||||
(actualroot != "" && !actualroot.StartsWith(Path.DirectorySeparatorChar.ToString()) ?
|
||||
Path.DirectorySeparatorChar.ToString() :
|
||||
"") + actualroot :
|
||||
actualroot),
|
||||
Game = new Machine
|
||||
{
|
||||
Name = (_datdata.Type == "SuperDAT" ?
|
||||
(actualroot != "" && !actualroot.StartsWith(Path.DirectorySeparatorChar.ToString()) ?
|
||||
Path.DirectorySeparatorChar.ToString() :
|
||||
"") + actualroot :
|
||||
actualroot),
|
||||
},
|
||||
HashData = new HashData
|
||||
{
|
||||
Size = -1,
|
||||
@@ -209,11 +212,14 @@ namespace SabreTools
|
||||
Rom rom = new Rom
|
||||
{
|
||||
Name = "null",
|
||||
Game = (_datdata.Type == "SuperDAT" ?
|
||||
(actualroot != "" && !actualroot.StartsWith(Path.DirectorySeparatorChar.ToString()) ?
|
||||
Path.DirectorySeparatorChar.ToString() :
|
||||
"") + actualroot :
|
||||
actualroot),
|
||||
Game = new Machine
|
||||
{
|
||||
Name = (_datdata.Type == "SuperDAT" ?
|
||||
(actualroot != "" && !actualroot.StartsWith(Path.DirectorySeparatorChar.ToString()) ?
|
||||
Path.DirectorySeparatorChar.ToString() :
|
||||
"") + actualroot :
|
||||
actualroot),
|
||||
},
|
||||
HashData = new HashData
|
||||
{
|
||||
Size = -1,
|
||||
@@ -287,13 +293,13 @@ namespace SabreTools
|
||||
{
|
||||
// If we have a different game and we're not at the start of the list, output the end of last item
|
||||
int last = 0;
|
||||
if (lastparent != null && lastparent.ToLowerInvariant() != rom.Game.ToLowerInvariant())
|
||||
if (lastparent != null && lastparent.ToLowerInvariant() != rom.Game.Name.ToLowerInvariant())
|
||||
{
|
||||
Output.WriteEndGame(sw, rom, new List<string>(), new List<string>(), lastparent, _datdata, 0, out last, _logger);
|
||||
}
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastparent == null || lastparent.ToLowerInvariant() != rom.Game.ToLowerInvariant())
|
||||
if (lastparent == null || lastparent.ToLowerInvariant() != rom.Game.Name.ToLowerInvariant())
|
||||
{
|
||||
Output.WriteStartGame(sw, rom, new List<string>(), lastparent, _datdata, 0, last, _logger);
|
||||
}
|
||||
@@ -305,7 +311,7 @@ namespace SabreTools
|
||||
}
|
||||
}
|
||||
|
||||
lastparent = rom.Game;
|
||||
lastparent = rom.Game.Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,7 +380,7 @@ namespace SabreTools
|
||||
}
|
||||
|
||||
_logger.User("File added: " + Path.GetFileNameWithoutExtension(item) + Environment.NewLine);
|
||||
return rom.Game;
|
||||
return rom.Game.Name;
|
||||
}
|
||||
|
||||
// If both deep hash skip flags are set, do a quickscan
|
||||
@@ -511,12 +517,15 @@ namespace SabreTools
|
||||
_logger.Log("Actual item added: " + actualitem);
|
||||
|
||||
// Update rom information
|
||||
rom.Game = (datdata.Type == "SuperDAT" ?
|
||||
rom.Game = new Machine
|
||||
{
|
||||
Name = (datdata.Type == "SuperDAT" ?
|
||||
(actualroot != "" && !actualroot.StartsWith(Path.DirectorySeparatorChar.ToString()) ?
|
||||
Path.DirectorySeparatorChar.ToString() :
|
||||
"") + actualroot :
|
||||
actualroot);
|
||||
rom.Game = rom.Game.Replace(Path.DirectorySeparatorChar.ToString() + Path.DirectorySeparatorChar.ToString(), Path.DirectorySeparatorChar.ToString());
|
||||
actualroot),
|
||||
};
|
||||
rom.Game.Name = rom.Game.Name.Replace(Path.DirectorySeparatorChar.ToString() + Path.DirectorySeparatorChar.ToString(), Path.DirectorySeparatorChar.ToString());
|
||||
rom.Name = actualitem;
|
||||
|
||||
if (_nowrite)
|
||||
@@ -537,13 +546,13 @@ namespace SabreTools
|
||||
{
|
||||
// If we have a different game and we're not at the start of the list, output the end of last item
|
||||
int last = 0;
|
||||
if (lastparent != null && lastparent.ToLowerInvariant() != rom.Game.ToLowerInvariant())
|
||||
if (lastparent != null && lastparent.ToLowerInvariant() != rom.Game.Name.ToLowerInvariant())
|
||||
{
|
||||
Output.WriteEndGame(sw, rom, new List<string>(), new List<string>(), lastparent, datdata, 0, out last, _logger);
|
||||
}
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastparent == null || lastparent.ToLowerInvariant() != rom.Game.ToLowerInvariant())
|
||||
if (lastparent == null || lastparent.ToLowerInvariant() != rom.Game.Name.ToLowerInvariant())
|
||||
{
|
||||
Output.WriteStartGame(sw, rom, new List<string>(), lastparent, datdata, 0, last, _logger);
|
||||
}
|
||||
@@ -553,7 +562,7 @@ namespace SabreTools
|
||||
}
|
||||
_logger.User("File added: " + actualitem + Environment.NewLine);
|
||||
|
||||
return rom.Game;
|
||||
return rom.Game.Name;
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
|
||||
@@ -195,7 +195,7 @@ namespace SabreTools
|
||||
Rom rom = newroms[i];
|
||||
|
||||
// In the case that the RomData is incomplete, skip it
|
||||
if (rom.Name == null || rom.Game == null)
|
||||
if (rom.Name == null || rom.Game.Name == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -209,21 +209,21 @@ namespace SabreTools
|
||||
rom.Name = Regex.Replace(rom.Name, @"(.*) \.(.*)", "$1.$2");
|
||||
|
||||
// Run the name through the filters to make sure that it's correct
|
||||
rom.Game = Style.NormalizeChars(rom.Game);
|
||||
rom.Game = Style.RussianToLatin(rom.Game);
|
||||
rom.Game = Style.SearchPattern(rom.Game);
|
||||
rom.Game.Name = Style.NormalizeChars(rom.Game.Name);
|
||||
rom.Game.Name = Style.RussianToLatin(rom.Game.Name);
|
||||
rom.Game.Name = Style.SearchPattern(rom.Game.Name);
|
||||
|
||||
// WoD gets rid of anything past the first "(" or "[" as the name, we will do the same
|
||||
string stripPattern = @"(([[(].*[\)\]] )?([^([]+))";
|
||||
Regex stripRegex = new Regex(stripPattern);
|
||||
Match stripMatch = stripRegex.Match(rom.Game);
|
||||
rom.Game = stripMatch.Groups[1].Value;
|
||||
Match stripMatch = stripRegex.Match(rom.Game.Name);
|
||||
rom.Game.Name = stripMatch.Groups[1].Value;
|
||||
|
||||
rom.Game = rom.Game.TrimEnd().TrimStart();
|
||||
rom.Game.Name = rom.Game.Name.TrimEnd().TrimStart();
|
||||
|
||||
if (!_norename)
|
||||
{
|
||||
rom.Game += " [" + sources[rom.Metadata.SourceID] + "]";
|
||||
rom.Game.Name += " [" + sources[rom.Metadata.SourceID] + "]";
|
||||
}
|
||||
|
||||
// If a game has source "0" it's Default. Make this Int32.MaxValue for sorting purposes
|
||||
|
||||
@@ -523,7 +523,7 @@ namespace SabreTools
|
||||
if (_toFolder)
|
||||
{
|
||||
// Copy file to output directory
|
||||
string gamedir = Path.Combine(_outdir, found.Game);
|
||||
string gamedir = Path.Combine(_outdir, found.Game.Name);
|
||||
if (!Directory.Exists(gamedir))
|
||||
{
|
||||
Directory.CreateDirectory(gamedir);
|
||||
@@ -590,7 +590,7 @@ namespace SabreTools
|
||||
if (_toFolder)
|
||||
{
|
||||
// Copy file to output directory
|
||||
string gamedir = Path.Combine(_outdir, found.Game);
|
||||
string gamedir = Path.Combine(_outdir, found.Game.Name);
|
||||
if (!Directory.Exists(gamedir))
|
||||
{
|
||||
Directory.CreateDirectory(gamedir);
|
||||
@@ -635,7 +635,7 @@ namespace SabreTools
|
||||
if (_toFolder)
|
||||
{
|
||||
// Copy file to output directory
|
||||
string gamedir = Path.Combine(_outdir, found.Game);
|
||||
string gamedir = Path.Combine(_outdir, found.Game.Name);
|
||||
if (!Directory.Exists(gamedir))
|
||||
{
|
||||
Directory.CreateDirectory(gamedir);
|
||||
@@ -714,7 +714,7 @@ namespace SabreTools
|
||||
string outfile = ArchiveTools.ExtractSingleItemFromArchive(input, rom.Name, _tempdir, _logger);
|
||||
if (File.Exists(outfile))
|
||||
{
|
||||
string gamedir = Path.Combine(_outdir, found.Game);
|
||||
string gamedir = Path.Combine(_outdir, found.Game.Name);
|
||||
if (!Directory.Exists(gamedir))
|
||||
{
|
||||
Directory.CreateDirectory(gamedir);
|
||||
|
||||
Reference in New Issue
Block a user