Skip to content

Commit

Permalink
more asset data, multiple sndi support, fix copy sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
igorseabra4 committed Nov 24, 2018
1 parent 2d7a28e commit d452f21
Show file tree
Hide file tree
Showing 33 changed files with 318 additions and 372 deletions.
2 changes: 1 addition & 1 deletion HipHopTool
68 changes: 34 additions & 34 deletions IndustrialPark/ArchiveEditor/ArchiveEditor.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 37 additions & 1 deletion IndustrialPark/ArchiveEditor/ArchiveEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,30 @@ private void buttonCopy_Click(object sender, EventArgs e)
List<Section_AHDR> copiedAHDRs = new List<Section_AHDR>();

foreach (uint u in archive.GetCurrentlySelectedAssetIDs())
copiedAHDRs.Add(archive.GetFromAssetID(u).AHDR);
{
Section_AHDR AHDR = JsonConvert.DeserializeObject<Section_AHDR>(JsonConvert.SerializeObject(archive.GetFromAssetID(u).AHDR));

if (AHDR.assetType == AssetType.SND || AHDR.assetType == AssetType.SNDS)
{
List<byte> file = new List<byte>();
file.AddRange(archive.GetHeaderFromSNDI(AHDR.assetID));
file.AddRange(AHDR.data);

if (new string(new char[] { (char)file[0], (char)file[1], (char)file[2], (char)file[3] }) == "RIFF")
{
byte[] chunkSizeArr = BitConverter.GetBytes(file.Count - 8);

file[4] = chunkSizeArr[0];
file[5] = chunkSizeArr[1];
file[6] = chunkSizeArr[2];
file[7] = chunkSizeArr[3];
}

AHDR.data = file.ToArray();
}

copiedAHDRs.Add(AHDR);
}

Clipboard.SetText(JsonConvert.SerializeObject(copiedAHDRs));
}
Expand All @@ -462,6 +485,19 @@ private void buttonPaste_Click(object sender, EventArgs e)

foreach (Section_AHDR AHDR in AHDRs)
{
if (AHDR.assetType == AssetType.SND || AHDR.assetType == AssetType.SNDS)
{
try
{
archive.AddSoundToSNDI(AHDR.data, AHDR.assetID, AHDR.assetType, out byte[] soundData);
AHDR.data = soundData;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

archive.AddAssetWithUniqueID(comboBoxLayers.SelectedIndex, AHDR);
assetIDs.Add(AHDR.assetID);
}
Expand Down
35 changes: 22 additions & 13 deletions IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1048,23 +1048,23 @@ public void AddTextureDictionary(string fileName)
ReadFileMethods.treatTexturesAsByteArray = false;
}

public void AddSoundToSNDI(byte[] soundData, uint assetID, out byte[] finalData)
public void AddSoundToSNDI(byte[] soundData, uint assetID, AssetType assetType, out byte[] finalData)
{
foreach (Asset a in assetDictionary.Values)
{
if (a is AssetSNDI_GCN_V1 SNDI_G1)
{
SNDI_G1.AddEntry(soundData, assetID, GetFromAssetID(assetID).AHDR.assetType, out finalData);
SNDI_G1.AddEntry(soundData, assetID, assetType, out finalData);
return;
}
else if (a is AssetSNDI_XBOX SNDI_X)
{
SNDI_X.AddEntry(soundData, assetID, GetFromAssetID(assetID).AHDR.assetType, out finalData);
SNDI_X.AddEntry(soundData, assetID, assetType, out finalData);
return;
}
else if (a is AssetSNDI_PS2 SNDI_P)
{
SNDI_P.AddEntry(soundData, assetID, GetFromAssetID(assetID).AHDR.assetType, out finalData);
SNDI_P.AddEntry(soundData, assetID, assetType, out finalData);
return;
}
}
Expand All @@ -1078,18 +1078,18 @@ public void RemoveSoundFromSNDI(uint assetID)
{
if (a is AssetSNDI_GCN_V1 SNDI_G1)
{
SNDI_G1.RemoveEntry(assetID, GetFromAssetID(assetID).AHDR.assetType);
break;
if (SNDI_G1.HasReference(assetID))
SNDI_G1.RemoveEntry(assetID, GetFromAssetID(assetID).AHDR.assetType);
}
else if (a is AssetSNDI_XBOX SNDI_X)
{
SNDI_X.RemoveEntry(assetID, GetFromAssetID(assetID).AHDR.assetType);
break;
if (SNDI_X.HasReference(assetID))
SNDI_X.RemoveEntry(assetID, GetFromAssetID(assetID).AHDR.assetType);
}
else if (a is AssetSNDI_PS2 SNDI_P)
{
SNDI_P.RemoveEntry(assetID, GetFromAssetID(assetID).AHDR.assetType);
break;
if (SNDI_P.HasReference(assetID))
SNDI_P.RemoveEntry(assetID, GetFromAssetID(assetID).AHDR.assetType);
}
}
}
Expand All @@ -1099,11 +1099,20 @@ public byte[] GetHeaderFromSNDI(uint assetID)
foreach (Asset a in assetDictionary.Values)
{
if (a is AssetSNDI_GCN_V1 SNDI_G1)
return SNDI_G1.GetHeader(assetID, GetFromAssetID(assetID).AHDR.assetType);
{
if (SNDI_G1.HasReference(assetID))
return SNDI_G1.GetHeader(assetID, GetFromAssetID(assetID).AHDR.assetType);
}
else if (a is AssetSNDI_XBOX SNDI_X)
return SNDI_X.GetHeader(assetID, GetFromAssetID(assetID).AHDR.assetType);
{
if (SNDI_X.HasReference(assetID))
return SNDI_X.GetHeader(assetID, GetFromAssetID(assetID).AHDR.assetType);
}
else if (a is AssetSNDI_PS2 SNDI_P)
return SNDI_P.GetHeader(assetID, GetFromAssetID(assetID).AHDR.assetType);
{
if (SNDI_P.HasReference(assetID))
return SNDI_P.GetHeader(assetID, GetFromAssetID(assetID).AHDR.assetType);
}
}

throw new Exception("Error: could not find SNDI asset in this archive.");
Expand Down
17 changes: 0 additions & 17 deletions IndustrialPark/ArchiveEditor/AssetEditor/AddAssetDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,6 @@ public AddAssetDialog(Section_AHDR AHDR)
VerifyTemplate();
}

private string GetMiscSettingsString(byte[] MiscSettings)
{
if (MiscSettings.Length == 0) return "";

string output = String.Format("{0, 2:X2}", MiscSettings[0]) + String.Format("{0, 2:X2}", MiscSettings[1])
+ String.Format("{0, 2:X2}", MiscSettings[2]) + String.Format("{0, 2:X2}", MiscSettings[3]);

for (int i = 4; i < MiscSettings.Length; i += 4)
{
output += " " +
String.Format("{0, 2:X2}", MiscSettings[i]) + String.Format("{0, 2:X2}", MiscSettings[i + 1]) +
String.Format("{0, 2:X2}", MiscSettings[i + 2]) + String.Format("{0, 2:X2}", MiscSettings[i + 3]);
}

return output;
}

public static Section_AHDR GetAsset(AddAssetDialog a, out bool success)
{
DialogResult d = a.ShowDialog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private void button1_Click(object sender, EventArgs e)
{
try
{
archive.AddSoundToSNDI(file, asset.AHDR.assetID, out byte[] soundData);
archive.AddSoundToSNDI(file, asset.AHDR.assetID, asset.AHDR.assetType, out byte[] soundData);
asset.AHDR.data = soundData;
}
catch (Exception ex)
Expand Down
2 changes: 2 additions & 0 deletions IndustrialPark/Assets/Binary/AssetALST.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Linq;
using static HipHopFile.Functions;
using System.ComponentModel;

namespace IndustrialPark
{
Expand All @@ -19,6 +20,7 @@ public override bool HasReference(uint assetID)
return base.HasReference(assetID);
}

[Category("Animation List")]
public AssetID[] ANIM_AssetIDs
{
get
Expand Down
11 changes: 11 additions & 0 deletions IndustrialPark/Assets/Binary/AssetANIM.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using HipHopFile;
using static IndustrialPark.ConverterFunctions;
Expand All @@ -22,42 +23,49 @@ public class AssetANIM : Asset
{
public AssetANIM(Section_AHDR AHDR) : base(AHDR) { }

[Category("Animation")]
public int Unknown_04
{
get => ReadInt(0x04);
set => Write(0x04, value);
}

[Category("Animation")]
public short NumBones
{
get => ReadShort(0x08);
set => Write(0x08, value);
}

[Category("Animation")]
public short NumFrames
{
get => ReadShort(0x0A);
set => Write(0x0A, value);
}

[Category("Animation")]
public int NumKeyFrames
{
get => ReadInt(0xC);
set => Write(0xC, value);
}

[Category("Animation")]
public int Unknown10
{
get => ReadInt(0x10);
set => Write(0x10, value);
}

[Category("Animation")]
public int Unknown14
{
get => ReadInt(0x14);
set => Write(0x14, value);
}

[Category("Animation")]
public int Unknown18
{
get => ReadInt(0x18);
Expand All @@ -66,6 +74,7 @@ public int Unknown18

private int KeyFramesSectionStart { get => 0x1C; }

[Category("Animation")]
public KeyFrame[] KeyFrames
{
get
Expand Down Expand Up @@ -110,6 +119,7 @@ public KeyFrame[] KeyFrames

private int TimeMapSectionStart { get => KeyFramesSectionStart + NumKeyFrames * 0x10; }

[Category("Animation")]
public float[] TimeMap
{
get
Expand All @@ -133,6 +143,7 @@ public float[] TimeMap

private int KeyFrameMapSectionStart { get => TimeMapSectionStart + NumFrames * 4; }

[Category("Animation")]
public short[][] KeyFrameMap
{
get
Expand Down
Loading

0 comments on commit d452f21

Please sign in to comment.