[ALL] Overhaul to internal system

This massive change replaces the old "Rom" struct system with a new one that have different objects for each major item type. This required a lot of work and a lot of changes and has unfortunately been untested. But this is the first step in moving away from using structs. The next major step is converting Dat over to this as well.
This commit is contained in:
Matt Nadareski
2016-09-19 18:04:24 -07:00
parent f059b5389c
commit 902070c542
22 changed files with 1615 additions and 3017 deletions

View File

@@ -188,14 +188,14 @@ namespace SabreTools
List<string> keys = datdata.Files.Keys.ToList();
foreach (string key in keys)
{
List<Rom> temp = new List<Rom>();
List<Rom> newroms = datdata.Files[key];
List<DatItem> temp = new List<DatItem>();
List<DatItem> newroms = datdata.Files[key];
for (int i = 0; i < newroms.Count; i++)
{
Rom rom = newroms[i];
Rom rom = (Rom)newroms[i];
// In the case that the RomData is incomplete, skip it
if (rom.Name == null || rom.Machine.Name == null)
if (rom.Name == null || rom.MachineName == null)
{
continue;
}
@@ -209,27 +209,27 @@ namespace SabreTools
rom.Name = Regex.Replace(rom.Name, @"(.*) \.(.*)", "$1.$2");
// Run the name through the filters to make sure that it's correct
rom.Machine.Name = Style.NormalizeChars(rom.Machine.Name);
rom.Machine.Name = Style.RussianToLatin(rom.Machine.Name);
rom.Machine.Name = Style.SearchPattern(rom.Machine.Name);
rom.MachineName = Style.NormalizeChars(rom.MachineName);
rom.MachineName = Style.RussianToLatin(rom.MachineName);
rom.MachineName = Style.SearchPattern(rom.MachineName);
// 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.Machine.Name);
rom.Machine.Name = stripMatch.Groups[1].Value;
Match stripMatch = stripRegex.Match(rom.MachineName);
rom.MachineName = stripMatch.Groups[1].Value;
rom.Machine.Name = rom.Machine.Name.TrimEnd().TrimStart();
rom.MachineName = rom.MachineName.TrimEnd().TrimStart();
if (!_norename)
{
rom.Machine.Name += " [" + sources[rom.Metadata.SourceID] + "]";
rom.MachineName += " [" + sources[rom.SourceID] + "]";
}
// If a game has source "0" it's Default. Make this Int32.MaxValue for sorting purposes
if (rom.Metadata.SourceID == 0)
if (rom.SourceID == 0)
{
rom.Metadata.SourceID = Int32.MaxValue;
rom.SourceID = Int32.MaxValue;
}
temp.Add(rom);