mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Simplify GetKey implementations for DatItem
This commit is contained in:
@@ -689,8 +689,12 @@ namespace SabreTools.DatFiles
|
||||
if (bucketBy == ItemKey.NULL)
|
||||
bucketBy = ItemKey.Machine;
|
||||
|
||||
// Get the machine and source
|
||||
var machine = datItem.GetFieldValue<Machine>(DatItem.MachineKey);
|
||||
var source = datItem.GetFieldValue<Source?>(DatItem.SourceKey);
|
||||
|
||||
// Get the bucket key
|
||||
return datItem.GetKey(bucketBy, lower, norename);
|
||||
return datItem.GetKey(bucketBy, machine, source, lower, norename);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -726,8 +730,12 @@ namespace SabreTools.DatFiles
|
||||
if (item == null || item.GetBoolFieldValue(DatItem.RemoveKey) == true)
|
||||
continue;
|
||||
|
||||
// Get the machine and source
|
||||
var machine = item.GetFieldValue<Machine>(DatItem.MachineKey);
|
||||
var source = item.GetFieldValue<Source?>(DatItem.SourceKey);
|
||||
|
||||
// We want to get the key most appropriate for the given sorting type
|
||||
string newkey = item.GetKey(bucketBy, lower, norename);
|
||||
string newkey = item.GetKey(bucketBy, machine, source, lower, norename);
|
||||
|
||||
// If the key is different, move the item to the new key
|
||||
if (newkey != key)
|
||||
|
||||
@@ -735,7 +735,9 @@ namespace SabreTools.DatFiles
|
||||
|
||||
// We want to get the proper key for the DatItem, ignoring the index
|
||||
_ = SortAndGetKey(datItem, sorted);
|
||||
string key = datItem.Value.GetKey(_bucketedBy);
|
||||
var machine = GetMachineForItem(datItem.Key);
|
||||
var source = GetSourceForItem(datItem.Key);
|
||||
string key = datItem.Value.GetKey(_bucketedBy, machine.Value, source.Value);
|
||||
|
||||
// If the key doesn't exist, return the empty list
|
||||
var items = GetItemsForBucket(key);
|
||||
@@ -776,7 +778,9 @@ namespace SabreTools.DatFiles
|
||||
|
||||
// We want to get the proper key for the DatItem, ignoring the index
|
||||
_ = SortAndGetKey(datItem, sorted);
|
||||
string key = datItem.Value.GetKey(_bucketedBy);
|
||||
var machine = GetMachineForItem(datItem.Key);
|
||||
var source = GetSourceForItem(datItem.Key);
|
||||
string key = datItem.Value.GetKey(_bucketedBy, machine.Value, source.Value);
|
||||
|
||||
// If the key doesn't exist
|
||||
var roms = GetItemsForBucket(key);
|
||||
@@ -976,7 +980,7 @@ namespace SabreTools.DatFiles
|
||||
bucketBy = ItemKey.Machine;
|
||||
|
||||
// Get the bucket key
|
||||
return datItem.GetKeyDB(bucketBy, machine.Value, source.Value, lower, norename);
|
||||
return datItem.GetKey(bucketBy, machine.Value, source.Value, lower, norename);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user