mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFile] Get all logic in for split and merge. Create most of logic for full merge
This commit is contained in:
@@ -370,6 +370,65 @@ namespace SabreTools.Helper.Dats
|
|||||||
_files = sortable;
|
_files = sortable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Use cloneof tags to create merged sets and remove the tags plus using the device_ref tags to get full sets
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mergeroms">True if roms should be deduped, false otherwise</param>
|
||||||
|
/// <param name="logger">Logger object for file and console output</param>
|
||||||
|
/// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param>
|
||||||
|
public void CreateFullyMergedSets(bool mergeroms, Logger logger, bool output = true)
|
||||||
|
{
|
||||||
|
// For sake of ease, the first thing we want to do is sort by game
|
||||||
|
BucketByGame(mergeroms, false, logger, output);
|
||||||
|
|
||||||
|
// Now we want to loop through all of the games and set the correct information
|
||||||
|
List<string> games = Keys.ToList();
|
||||||
|
foreach (string game in games)
|
||||||
|
{
|
||||||
|
// First, we try to add all device items first
|
||||||
|
/*
|
||||||
|
Here, we require that device_ref tags got read first, and then we can add them accordingly.
|
||||||
|
As of right now, those tags are NOT being read into the machine. We'd have to do this in
|
||||||
|
order to get this working correctly. At least this is a good placeholder for now.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Determine if the game has a parent or not
|
||||||
|
string parent = null;
|
||||||
|
if (this[game][0].Machine.CloneOf != null)
|
||||||
|
{
|
||||||
|
parent = this[game][0].Machine.CloneOf;
|
||||||
|
}
|
||||||
|
else if (this[game][0].Machine.RomOf != null)
|
||||||
|
{
|
||||||
|
parent = this[game][0].Machine.RomOf;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there is no parent, then we continue
|
||||||
|
if (parent == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the parent doesn't exist, then we continue
|
||||||
|
if (this[parent].Count == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, move the items from the current game to a subfolder of the parent game
|
||||||
|
Machine parentMachine = this[parent][0].Machine;
|
||||||
|
List<DatItem> items = this[game];
|
||||||
|
foreach (DatItem item in items)
|
||||||
|
{
|
||||||
|
item.Name = item.Machine.Name + "\\" + item.Name;
|
||||||
|
item.Machine = parentMachine;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally, remove the old game so it's not picked up by the writer
|
||||||
|
Remove(game);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Use cloneof tags to create merged sets and remove the tags
|
/// Use cloneof tags to create merged sets and remove the tags
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -460,18 +519,53 @@ namespace SabreTools.Helper.Dats
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Okay, so here actual copies of the roms need to be copied into the current game, so
|
|
||||||
* you need to make sure that you make a copy and don't ruin the original version since the original
|
|
||||||
* parnt is still a valid piece of set
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Otherwise, copy the items from the parent to the current game
|
// Otherwise, copy the items from the parent to the current game
|
||||||
Machine parentMachine = this[game][0].Machine;
|
Machine currentMachine = this[game][0].Machine;
|
||||||
List<DatItem> items = this[parent];
|
List<DatItem> items = this[parent];
|
||||||
foreach (DatItem item in items)
|
foreach (DatItem item in items)
|
||||||
{
|
{
|
||||||
|
// Figure out the type of the item and add it accordingly
|
||||||
|
switch (item.Type)
|
||||||
|
{
|
||||||
|
case ItemType.Archive:
|
||||||
|
Archive archive = (Archive)item;
|
||||||
|
archive.Machine = currentMachine;
|
||||||
|
this[parent].Add(archive);
|
||||||
|
break;
|
||||||
|
case ItemType.BiosSet:
|
||||||
|
BiosSet biosSet = (BiosSet)item;
|
||||||
|
biosSet.Machine = currentMachine;
|
||||||
|
this[parent].Add(biosSet);
|
||||||
|
break;
|
||||||
|
case ItemType.Disk:
|
||||||
|
Disk disk = (Disk)item;
|
||||||
|
disk.Machine = currentMachine;
|
||||||
|
this[parent].Add(disk);
|
||||||
|
break;
|
||||||
|
case ItemType.Release:
|
||||||
|
Release release = (Release)item;
|
||||||
|
release.Machine = currentMachine;
|
||||||
|
this[parent].Add(release);
|
||||||
|
break;
|
||||||
|
case ItemType.Rom:
|
||||||
|
Rom rom = (Rom)item;
|
||||||
|
rom.Machine = currentMachine;
|
||||||
|
this[parent].Add(rom);
|
||||||
|
break;
|
||||||
|
case ItemType.Sample:
|
||||||
|
Sample sample = (Sample)item;
|
||||||
|
sample.Machine = currentMachine;
|
||||||
|
this[parent].Add(sample);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally, remove the romof and cloneof tags so it's not picked up by the manager
|
||||||
|
items = this[game];
|
||||||
|
foreach (DatItem item in items)
|
||||||
|
{
|
||||||
|
item.Machine.CloneOf = null;
|
||||||
|
item.Machine.RomOf = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ namespace SabreTools.Helper.Dats
|
|||||||
}
|
}
|
||||||
else if (splitType == SplitType.MergedWithDevice)
|
else if (splitType == SplitType.MergedWithDevice)
|
||||||
{
|
{
|
||||||
logger.User("Full merging is not yet available. Sorry for the inconvenience");
|
CreateFullyMergedSets(false, logger, output: false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user