mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add db export Archive fields
This commit is contained in:
@@ -594,6 +594,12 @@ namespace SabreTools.Core
|
||||
// Analog
|
||||
Analog_Mask,
|
||||
|
||||
// Archive
|
||||
Number,
|
||||
Clone,
|
||||
RegParent,
|
||||
Languages,
|
||||
|
||||
// BiosSet
|
||||
Description,
|
||||
|
||||
|
||||
@@ -18,6 +18,41 @@ namespace SabreTools.DatItems.Formats
|
||||
[JsonProperty("name"), XmlElement("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Archive ID number
|
||||
/// </summary>
|
||||
/// <remarks>No-Intro database export only</remarks>
|
||||
[JsonProperty("number"), XmlElement("number")]
|
||||
public string Number { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Clone
|
||||
/// </summary>
|
||||
/// <remarks>No-Intro database export only</remarks>
|
||||
[JsonProperty("clone"), XmlElement("clone")]
|
||||
public string Clone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Regional parent
|
||||
/// </summary>
|
||||
/// <remarks>No-Intro database export only</remarks>
|
||||
[JsonProperty("regparent"), XmlElement("regparent")]
|
||||
public string RegParent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Region
|
||||
/// </summary>
|
||||
/// <remarks>No-Intro database export only</remarks>
|
||||
[JsonProperty("region"), XmlElement("region")]
|
||||
public string Region { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Region
|
||||
/// </summary>
|
||||
/// <remarks>No-Intro database export only</remarks>
|
||||
[JsonProperty("languages"), XmlElement("languages")]
|
||||
public string Languages { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Accessors
|
||||
@@ -57,6 +92,11 @@ namespace SabreTools.DatItems.Formats
|
||||
Remove = this.Remove,
|
||||
|
||||
Name = this.Name,
|
||||
Number = this.Number,
|
||||
Clone = this.Clone,
|
||||
RegParent = this.RegParent,
|
||||
Region = this.Region,
|
||||
Languages = this.Languages,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -75,7 +115,12 @@ namespace SabreTools.DatItems.Formats
|
||||
Archive newOther = other as Archive;
|
||||
|
||||
// If the archive information matches
|
||||
return (Name == newOther.Name);
|
||||
return (Name == newOther.Name
|
||||
&& Number == newOther.Number
|
||||
&& Clone == newOther.Clone
|
||||
&& RegParent == newOther.RegParent
|
||||
&& Region == newOther.Region
|
||||
&& Languages = newOther.Languages);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -83,6 +83,12 @@ namespace SabreTools.Filtering
|
||||
// Analog
|
||||
public FilterItem<string> Analog_Mask { get; private set; } = new FilterItem<string>();
|
||||
|
||||
// Archive
|
||||
public FilterItem<string> Number { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<string> Clone { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<string> RegParent { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<string> Languages { get; private set; } = new FilterItem<string>();
|
||||
|
||||
// BiosSet
|
||||
public FilterItem<string> Description { get; private set; } = new FilterItem<string>();
|
||||
|
||||
@@ -434,6 +440,23 @@ namespace SabreTools.Filtering
|
||||
SetStringFilter(Analog_Mask, value, negate);
|
||||
break;
|
||||
|
||||
// Archive
|
||||
case DatItemField.Number:
|
||||
SetStringFilter(Number, value, negate);
|
||||
break;
|
||||
|
||||
case DatItemField.Clone:
|
||||
SetStringFilter(Clone, value, negate);
|
||||
break;
|
||||
|
||||
case DatItemField.RegParent:
|
||||
SetStringFilter(RegParent, value, negate);
|
||||
break;
|
||||
|
||||
case DatItemField.Languages:
|
||||
SetStringFilter(Languages, value, negate);
|
||||
break;
|
||||
|
||||
// BiosSet
|
||||
case DatItemField.Description:
|
||||
SetStringFilter(Description, value, negate);
|
||||
@@ -859,6 +882,7 @@ namespace SabreTools.Filtering
|
||||
{
|
||||
Adjuster adjuster => PassesFilters(adjuster),
|
||||
Analog analog => PassesFilters(analog),
|
||||
Archive archive => PassesFilters(archive),
|
||||
BiosSet biosSet => PassesFilters(biosSet),
|
||||
Chip chip => PassesFilters(chip),
|
||||
Condition condition => PassesFilters(condition),
|
||||
@@ -934,6 +958,36 @@ namespace SabreTools.Filtering
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if an Archive passes the filters
|
||||
/// </summary>
|
||||
/// <param name="archive">Archive to check</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
private bool PassesFilters(Archive archive)
|
||||
{
|
||||
// Filter on number
|
||||
if (!PassStringFilter(Number, archive.Number))
|
||||
return false;
|
||||
|
||||
// Filter on clone
|
||||
if (!PassStringFilter(Clone, analog.Clone))
|
||||
return false;
|
||||
|
||||
// Filter on regional parent
|
||||
if (!PassStringFilter(RegParent, analog.RegParent))
|
||||
return false;
|
||||
|
||||
// Filter on region
|
||||
if (!PassStringFilter(Region, analog.Region))
|
||||
return false;
|
||||
|
||||
// Filter on languages
|
||||
if (!PassStringFilter(Languages, analog.Languages))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a BiosSet passes the filters
|
||||
/// </summary>
|
||||
|
||||
@@ -88,6 +88,7 @@ namespace SabreTools.Filtering
|
||||
|
||||
if (datItem is Adjuster) RemoveFields(datItem as Adjuster);
|
||||
else if (datItem is Analog) RemoveFields(datItem as Analog);
|
||||
else if (datItem is Archive) RemoveFields(datItem as Archive);
|
||||
else if (datItem is BiosSet) RemoveFields(datItem as BiosSet);
|
||||
else if (datItem is Chip) RemoveFields(datItem as Chip);
|
||||
else if (datItem is Condition) RemoveFields(datItem as Condition);
|
||||
@@ -300,6 +301,28 @@ namespace SabreTools.Filtering
|
||||
analog.Mask = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields with given values
|
||||
/// </summary>
|
||||
/// <param name="archive">Archive to remove fields from</param>
|
||||
private void RemoveFields(Archive archive)
|
||||
{
|
||||
if (DatItemFields.Contains(DatItemField.Number))
|
||||
archive.Number = null;
|
||||
|
||||
if (DatItemFields.Contains(DatItemField.Clone))
|
||||
archive.Clone = null;
|
||||
|
||||
if (DatItemFields.Contains(DatItemField.RegParent))
|
||||
archive.RegParent = null;
|
||||
|
||||
if (DatItemFields.Contains(DatItemField.Region))
|
||||
archive.Region = null;
|
||||
|
||||
if (DatItemFields.Contains(DatItemField.Languages))
|
||||
archive.Languages = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields with given values
|
||||
/// </summary>
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace SabreTools.Filtering
|
||||
|
||||
if (datItem is Adjuster) ReplaceFields(datItem as Adjuster, repDatItem as Adjuster, datItemFields);
|
||||
else if (datItem is Analog) ReplaceFields(datItem as Analog, repDatItem as Analog, datItemFields);
|
||||
else if (datItem is Archive) ReplaceFields(datItem as Archive, repDatItem as Archive, datItemFields);
|
||||
else if (datItem is BiosSet) ReplaceFields(datItem as BiosSet, repDatItem as BiosSet, datItemFields);
|
||||
else if (datItem is Chip) ReplaceFields(datItem as Chip, repDatItem as Chip, datItemFields);
|
||||
else if (datItem is Condition) ReplaceFields(datItem as Condition, repDatItem as Condition, datItemFields);
|
||||
@@ -254,6 +255,30 @@ namespace SabreTools.Filtering
|
||||
analog.Mask = newItem.Mask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields with given values
|
||||
/// </summary>
|
||||
/// <param name="archive">Archive to remove replace fields in</param>
|
||||
/// <param name="newItem">Archive to pull new information from</param>
|
||||
/// <param name="datItemFields">List of fields representing what should be updated</param>
|
||||
private static void ReplaceFields(Archive archive, Archive newItem, List<DatItemField> datItemFields)
|
||||
{
|
||||
if (datItemFields.Contains(DatItemField.Number))
|
||||
archive.Number = newItem.Number;
|
||||
|
||||
if (datItemFields.Contains(DatItemField.Clone))
|
||||
archive.Clone = newItem.Clone;
|
||||
|
||||
if (datItemFields.Contains(DatItemField.RegParent))
|
||||
archive.RegParent = newItem.RegParent;
|
||||
|
||||
if (datItemFields.Contains(DatItemField.Region))
|
||||
archive.Region = newItem.Region;
|
||||
|
||||
if (datItemFields.Contains(DatItemField.Languages))
|
||||
archive.Languages = newItem.Languages;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields with given values
|
||||
/// </summary>
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<rom name="rom.bin" size="1024" crc="deadbeef" md5="c41d8cd98f00b204e9800998ecf8427e" sha1="ca39a3ee5e6b4b0d3255bfef95601890afd80709" sha256="ca7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" sha384="ab00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7" sha512="cdaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f" spamsum="QXXZ" merge="rom2.bin" status="good" date="1980-01-01" inverted="true" mia="yes" />
|
||||
</machine>
|
||||
<game name="game2">
|
||||
<archive name="archive" />
|
||||
<archive name="archive" number="0001" clone="X" regparent="(PARENT)" region="World" langauges="Xx,Yy,Zz" />
|
||||
<biosset name="biosset" description="Described" default="yes" />
|
||||
<release name="release" region="World" Language="English" date="1900-01-01" default="yes" />
|
||||
</game>
|
||||
|
||||
Reference in New Issue
Block a user