Skip to content

Commit

Permalink
better merge assets
Browse files Browse the repository at this point in the history
  • Loading branch information
igorseabra4 committed Apr 15, 2019
1 parent a8eab5b commit b7320b9
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 74 deletions.
8 changes: 0 additions & 8 deletions IndustrialPark/ArchiveEditor/ArchiveEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -843,14 +843,6 @@ private void importHIPArchiveToolStripMenuItem_Click(object sender, EventArgs e)
PopulateLayerComboBox();
}

private void exportTXDArchiveToolStripMenuItem_Click(object sender, EventArgs e)
{
}

private void importTXDArchiveToolStripMenuItem1_Click(object sender, EventArgs e)
{
}

private void checkedListBoxAssets_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.I && e.Modifiers == Keys.Control)
Expand Down
8 changes: 7 additions & 1 deletion IndustrialPark/Assets/Binary/AssetCOLL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,15 @@ public EntryCOLL[] COLL_Entries
public void Merge(AssetCOLL assetCOLL)
{
List<EntryCOLL> entriesCOLL = COLL_Entries.ToList();
List<uint> assetIDsAlreadyPresent = new List<uint>();

foreach (EntryCOLL entryCOLL in entriesCOLL)
assetIDsAlreadyPresent.Add(entryCOLL.ModelAssetID);

foreach (EntryCOLL entryCOLL in assetCOLL.COLL_Entries)
if (!entriesCOLL.Contains(entryCOLL))
if (!assetIDsAlreadyPresent.Contains(entryCOLL.ModelAssetID))
entriesCOLL.Add(entryCOLL);

COLL_Entries = entriesCOLL.ToArray();
}
}
Expand Down
8 changes: 7 additions & 1 deletion IndustrialPark/Assets/Binary/AssetJAW.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,15 @@ public void RemoveEntry(uint assetID)
public void Merge(AssetJAW assetJAW)
{
List<EntryJAW> entriesJAW = JAW_Entries.ToList();
List<uint> assetIDsAlreadyPresent = new List<uint>();

foreach (EntryJAW entryJAW in entriesJAW)
assetIDsAlreadyPresent.Add(entryJAW.SoundAssetID);

foreach (EntryJAW entryJAW in assetJAW.JAW_Entries)
if (!entriesJAW.Contains(entryJAW))
if (!assetIDsAlreadyPresent.Contains(entryJAW.SoundAssetID))
entriesJAW.Add(entryJAW);

JAW_Entries = entriesJAW.ToArray();
}
}
Expand Down
8 changes: 7 additions & 1 deletion IndustrialPark/Assets/Binary/AssetLODT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,15 @@ public EntryLODT[] LODT_Entries
public void Merge(AssetLODT assetLODT)
{
List<EntryLODT> entriesLODT = LODT_Entries.ToList();
List<uint> assetIDsAlreadyPresent = new List<uint>();

foreach (EntryLODT entryLODT in entriesLODT)
assetIDsAlreadyPresent.Add(entryLODT.ModelAssetID);

foreach (EntryLODT entryLODT in assetLODT.LODT_Entries)
if (!entriesLODT.Contains(entryLODT))
if (!assetIDsAlreadyPresent.Contains(entryLODT.ModelAssetID))
entriesLODT.Add(entryLODT);

LODT_Entries = entriesLODT.ToArray();
}
}
Expand Down
10 changes: 7 additions & 3 deletions IndustrialPark/Assets/Binary/AssetPIPT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ public AssetPIPT(Section_AHDR AHDR) : base(AHDR)
public override bool HasReference(uint assetID)
{
foreach (EntryPIPT a in PIPT_Entries)
{
if (a.ModelAssetID == assetID)
return true;
}

return base.HasReference(assetID);
}
Expand Down Expand Up @@ -104,9 +102,15 @@ public EntryPIPT[] PIPT_Entries
public void Merge(AssetPIPT assetPIPT)
{
List<EntryPIPT> entriesPIPT = PIPT_Entries.ToList();
List<uint> assetIDsAlreadyPresent = new List<uint>();

foreach (EntryPIPT entryPIPT in entriesPIPT)
assetIDsAlreadyPresent.Add(entryPIPT.ModelAssetID);

foreach (EntryPIPT entryPIPT in assetPIPT.PIPT_Entries)
if (!entriesPIPT.Contains(entryPIPT))
if (!assetIDsAlreadyPresent.Contains(entryPIPT.ModelAssetID))
entriesPIPT.Add(entryPIPT);

PIPT_Entries = entriesPIPT.ToArray();
}
}
Expand Down
8 changes: 7 additions & 1 deletion IndustrialPark/Assets/Binary/AssetSHDW.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,15 @@ public EntrySHDW[] SHDW_Entries
public void Merge(AssetSHDW assetSHDW)
{
List<EntrySHDW> entriesSHDW = SHDW_Entries.ToList();
List<uint> assetIDsAlreadyPresent = new List<uint>();

foreach (EntrySHDW entrySHDW in entriesSHDW)
assetIDsAlreadyPresent.Add(entrySHDW.ModelAssetID);

foreach (EntrySHDW entrySHDW in assetSHDW.SHDW_Entries)
if (!entriesSHDW.Contains(entrySHDW))
if (!assetIDsAlreadyPresent.Contains(entrySHDW.ModelAssetID))
entriesSHDW.Add(entrySHDW);

SHDW_Entries = entriesSHDW.ToArray();
}
}
Expand Down
48 changes: 39 additions & 9 deletions IndustrialPark/Assets/Binary/AssetSNDI_GCN_V1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ public byte[] GetHeader(uint assetID, AssetType assetType)
else
entries = Entries_SNDS.ToList();

for (int i = 0; i < entries.Count; i++)
if (entries[i].SoundAssetID == assetID)
return entries[i].SoundHeader;

entries = Entries_Sound_CIN.ToList();

for (int i = 0; i < entries.Count; i++)
if (entries[i].SoundAssetID == assetID)
return entries[i].SoundHeader;
Expand All @@ -271,15 +277,39 @@ public byte[] GetHeader(uint assetID, AssetType assetType)

public void Merge(AssetSNDI_GCN_V1 assetSNDI)
{
List<EntrySoundInfo_GCN_V1> entriesSND = Entries_SND.ToList();
entriesSND.AddRange(assetSNDI.Entries_SND);
Entries_SND = entriesSND.ToArray();
List<EntrySoundInfo_GCN_V1> entriesSNDS = Entries_SNDS.ToList();
entriesSNDS.AddRange(assetSNDI.Entries_SNDS);
Entries_SNDS = entriesSNDS.ToArray();
List<EntrySoundInfo_GCN_V1> entriesSoundCIN = Entries_Sound_CIN.ToList();
entriesSoundCIN.AddRange(assetSNDI.Entries_Sound_CIN);
Entries_Sound_CIN = entriesSoundCIN.ToArray();
{
// SND
List<EntrySoundInfo_GCN_V1> entriesSND = Entries_SND.ToList();
List<uint> assetIDsAlreadyPresentSND = new List<uint>();
foreach (EntrySoundInfo_GCN_V1 entrySND in entriesSND)
assetIDsAlreadyPresentSND.Add(entrySND.SoundAssetID);
foreach (EntrySoundInfo_GCN_V1 entrySND in assetSNDI.Entries_SND)
if (!assetIDsAlreadyPresentSND.Contains(entrySND.SoundAssetID))
entriesSND.Add(entrySND);
Entries_SND = entriesSND.ToArray();
}
{
// SNDS
List<EntrySoundInfo_GCN_V1> entriesSNDS = Entries_SNDS.ToList();
List<uint> assetIDsAlreadyPresentSNDS = new List<uint>();
foreach (EntrySoundInfo_GCN_V1 entrySNDS in entriesSNDS)
assetIDsAlreadyPresentSNDS.Add(entrySNDS.SoundAssetID);
foreach (EntrySoundInfo_GCN_V1 entrySNDS in assetSNDI.Entries_SNDS)
if (!assetIDsAlreadyPresentSNDS.Contains(entrySNDS.SoundAssetID))
entriesSNDS.Add(entrySNDS);
Entries_SNDS = entriesSNDS.ToArray();
}
{
// Sound_CIN
List<EntrySoundInfo_GCN_V1> entriesSound_CIN = Entries_Sound_CIN.ToList();
List<uint> assetIDsAlreadyPresentSound_CIN = new List<uint>();
foreach (EntrySoundInfo_GCN_V1 entrySound_CIN in entriesSound_CIN)
assetIDsAlreadyPresentSound_CIN.Add(entrySound_CIN.SoundAssetID);
foreach (EntrySoundInfo_GCN_V1 entrySound_CIN in assetSNDI.Entries_Sound_CIN)
if (!assetIDsAlreadyPresentSound_CIN.Contains(entrySound_CIN.SoundAssetID))
entriesSound_CIN.Add(entrySound_CIN);
Entries_Sound_CIN = entriesSound_CIN.ToArray();
}
}
}
}
29 changes: 27 additions & 2 deletions IndustrialPark/Assets/Binary/AssetSNDI_GCN_V2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,15 @@ public int lengthcompressedbytes
[Category("Sample Header")]
public uint loopstart { get; set; }
[Category("Sample Header")]
public uint loopend { get; set; }
public uint loopend
{
get
{
if (soundEntries.Length > 0)
return (uint)(soundEntries[0].lengthsamples - 1);
return 0;
}
}
[Category("Sample Header")]
public uint sampleHeaderMode { get; set; }
[Category("Sample Header")]
Expand All @@ -269,6 +277,20 @@ public int lengthcompressedbytes

public FSB3_File()
{
mode = 2;
version = 196609;

deffreq = 32000;
defpan = 128;
defpri = 255;
defvol = 255;
mindistance = 1f;
maxdistance = 1000000f;
name = "empty";
numchannels = 1;
sampleHeaderMode = 33558561;
size = 126;

soundEntries = new EntrySoundInfo_GCN_V2[0];
}

Expand All @@ -291,7 +313,7 @@ public FSB3_File(BinaryReader binaryReader)
int lengthsamples = binaryReader.ReadInt32();
int templengthcompressedbytes = binaryReader.ReadInt32();
loopstart = binaryReader.ReadUInt32();
loopend = binaryReader.ReadUInt32();
uint loopend = binaryReader.ReadUInt32();
sampleHeaderMode = binaryReader.ReadUInt32();
deffreq = binaryReader.ReadInt32();
defvol = binaryReader.ReadUInt16();
Expand Down Expand Up @@ -534,6 +556,9 @@ public void AddEntry(byte[] soundData, uint assetID)

List<FSB3_File> entries = Entries.ToList();

if (entries.Count == 0)
entries.Add(new FSB3_File());

List<EntrySoundInfo_GCN_V2> entries2 = entries[0].soundEntries.ToList();
entries2.Add(EntrySoundInfo_GCN_V2.Deserialize(soundData));
entries[0].soundEntries = entries2.ToArray();
Expand Down
28 changes: 22 additions & 6 deletions IndustrialPark/Assets/Binary/AssetSNDI_PS2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,28 @@ public byte[] GetHeader(uint assetID, AssetType assetType)

public void Merge(AssetSNDI_PS2 assetSNDI)
{
List<EntrySoundInfo_PS2> entriesSND = Entries_SND.ToList();
entriesSND.AddRange(assetSNDI.Entries_SND);
Entries_SND = entriesSND.ToArray();
List<EntrySoundInfo_PS2> entriesSNDS = Entries_SNDS.ToList();
entriesSNDS.AddRange(assetSNDI.Entries_SNDS);
Entries_SNDS = entriesSNDS.ToArray();
{
// SND
List<EntrySoundInfo_PS2> entriesSND = Entries_SND.ToList();
List<uint> assetIDsAlreadyPresentSND = new List<uint>();
foreach (EntrySoundInfo_PS2 entrySND in entriesSND)
assetIDsAlreadyPresentSND.Add(entrySND.SoundAssetID);
foreach (EntrySoundInfo_PS2 entrySND in assetSNDI.Entries_SND)
if (!assetIDsAlreadyPresentSND.Contains(entrySND.SoundAssetID))
entriesSND.Add(entrySND);
Entries_SND = entriesSND.ToArray();
}
{
// SNDS
List<EntrySoundInfo_PS2> entriesSNDS = Entries_SNDS.ToList();
List<uint> assetIDsAlreadyPresentSNDS = new List<uint>();
foreach (EntrySoundInfo_PS2 entrySNDS in entriesSNDS)
assetIDsAlreadyPresentSNDS.Add(entrySNDS.SoundAssetID);
foreach (EntrySoundInfo_PS2 entrySNDS in assetSNDI.Entries_SNDS)
if (!assetIDsAlreadyPresentSNDS.Contains(entrySNDS.SoundAssetID))
entriesSNDS.Add(entrySNDS);
Entries_SNDS = entriesSNDS.ToArray();
}
}
}
}
Loading

0 comments on commit b7320b9

Please sign in to comment.