Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
igorseabra4 committed Apr 29, 2020
1 parent a5b2932 commit 5f2b50e
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 42 deletions.
42 changes: 24 additions & 18 deletions IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -583,21 +583,27 @@ public uint AddAssetWithUniqueID(int layerIndex, Section_AHDR AHDR, bool giveIDr
giveIDregardless = false;
numCopies++;

if (AHDR.ADBG.assetName.Contains(stringToAdd))
try
{
int a = Convert.ToInt32(AHDR.ADBG.assetName.Split(stringToAdd).Last());
AHDR.ADBG.assetName = AHDR.ADBG.assetName.Substring(0, AHDR.ADBG.assetName.LastIndexOf(stringToAdd));
}
catch { }

AHDR.ADBG.assetName += stringToAdd + numCopies.ToString("D2");
AHDR.ADBG.assetName = FindNewAssetName(AHDR.ADBG.assetName, stringToAdd, numCopies);
AHDR.assetID = BKDRHash(AHDR.ADBG.assetName);
}

return AddAsset(layerIndex, AHDR, setTextureDisplay);
}

public string FindNewAssetName(string previousName, char stringToAdd, int numCopies)
{
if (previousName.Contains(stringToAdd))
try
{
int a = Convert.ToInt32(previousName.Split(stringToAdd).Last());
previousName = previousName.Substring(0, previousName.LastIndexOf(stringToAdd));
}
catch { }

previousName += stringToAdd + numCopies.ToString("D2");
return previousName;
}

public void RemoveAsset(IEnumerable<uint> assetIDs)
{
List<uint> assets = assetIDs.ToList();
Expand Down Expand Up @@ -778,6 +784,15 @@ public void ImportMultipleAssets(int layerIndex, List<Section_AHDR> AHDRs, out L
{
try
{
if (overwrite)
{
if (ContainsAsset(AHDR.assetID))
RemoveAsset(AHDR.assetID);
AddAsset(layerIndex, AHDR, setTextureDisplay: false);
}
else
AddAssetWithUniqueID(layerIndex, AHDR, setTextureDisplay: true);

if (AHDR.assetType == AssetType.SND || AHDR.assetType == AssetType.SNDS)
{
try
Expand All @@ -791,15 +806,6 @@ public void ImportMultipleAssets(int layerIndex, List<Section_AHDR> AHDRs, out L
}
}

if (overwrite)
{
if (ContainsAsset(AHDR.assetID))
RemoveAsset(AHDR.assetID);
AddAsset(layerIndex, AHDR, setTextureDisplay: false);
}
else
AddAssetWithUniqueID(layerIndex, AHDR, setTextureDisplay: true);

assetIDs.Add(AHDR.assetID);
}
catch (Exception ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ public List<uint> MakeSimps(List<uint> assetIDs, bool ledgeGrabSimps)
return outAssetIDs;
}

private int IndexOfDefaultLayer()
private int IndexOfLayerOfType(int layerType)
{
int defaultLayerIndex = -1;
for (int i = 0; i < DICT.LTOC.LHDRList.Count; i++)
Expand All @@ -799,6 +799,7 @@ private int IndexOfDefaultLayer()
if (defaultLayerIndex == -1)
{
AddLayer();
DICT.LTOC.LHDRList.Last().layerType = layerType;
defaultLayerIndex = DICT.LTOC.LHDRList.Count - 1;
}

Expand All @@ -815,7 +816,7 @@ public void MakePiptVcolors(List<uint> assetIDs)
if (pipt == null)
{
List<uint> assetIDs2 = new List<uint>();
pipt = (AssetPIPT)GetFromAssetID(PlaceTemplate(new Vector3(), IndexOfDefaultLayer(), out _, ref assetIDs2, template: AssetTemplate.PipeInfoTable));
pipt = (AssetPIPT)GetFromAssetID(PlaceTemplate(new Vector3(), IndexOfLayerOfType((int)LayerType_BFBB.DEFAULT), out _, ref assetIDs2, template: AssetTemplate.PipeInfoTable));
}

List<EntryPIPT> entries = pipt.PIPT_Entries.ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ public uint PlaceTemplate(Vector3 position, int layerIndex, out bool success, re
return 0;
}

string assetName = string.IsNullOrWhiteSpace(customName) ? template.ToString().ToUpper() + "_01" : customName + "_01";
string assetName = string.IsNullOrWhiteSpace(customName) ? template.ToString().ToUpper() + "_01" : customName;

Section_AHDR newAsset = new Section_AHDR
{
Expand Down
11 changes: 10 additions & 1 deletion IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_Sounds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ public partial class ArchiveEditorFunctions
{
public void AddSoundToSNDI(byte[] soundData, uint assetID, AssetType assetType, out byte[] finalData)
{
if (!ContainsAssetWithType(AssetType.SNDI))
{
int layerType = (int)LayerType_BFBB.SNDTOC;
if (game == Game.Incredibles)
layerType = (int)LayerType_TSSM.SNDTOC;

var list = new List<uint>();
PlaceTemplate(new SharpDX.Vector3(), IndexOfLayerOfType(layerType), out _, ref list, "sound_info", AssetTemplate.SoundInfo);
}

foreach (Asset a in assetDictionary.Values)
{
if (a is AssetSNDI_GCN_V1 SNDI_G1)
Expand All @@ -32,7 +42,6 @@ public void AddSoundToSNDI(byte[] soundData, uint assetID, AssetType assetType,
return;
}
}

throw new Exception("Unable to add sound: SNDI asset not found");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@ private void button2_Click(object sender, EventArgs e)
};

if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
if (soundData == null)
InitSound();
File.WriteAllBytes(saveFileDialog.FileName, soundData);
}
File.WriteAllBytes(saveFileDialog.FileName, archive.GetSoundData(asset.AHDR.assetID, asset.Data));
}

private void buttonFindCallers_Click(object sender, EventArgs e)
Expand Down
3 changes: 2 additions & 1 deletion IndustrialPark/Assets/Binary/AssetALST.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ namespace IndustrialPark
{
public class AssetALST : Asset
{
public AssetALST(Section_AHDR AHDR, Game game, Platform platform) : base(AHDR, game, platform) { }

public AssetALST(Section_AHDR AHDR, Game game, Platform platform) : base(AHDR, game, platform) { }

public override bool HasReference(uint assetID)
{
foreach (AssetID a in ANIM_AssetIDs)
Expand Down
11 changes: 3 additions & 8 deletions IndustrialPark/Assets/ObjectAssets/AssetTIMR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,11 @@ public float Time
set => Write(0x8, value);
}

[Category("Timer"), TypeConverter(typeof(FloatTypeConverter)), Description("Not present in Scooby.")]
[Category("Timer"), TypeConverter(typeof(FloatTypeConverter))]
public float RandomRange
{
get => game == Game.Scooby ? 0 : BitConverter.ToSingle(Data, 0xC);
set
{
if (game != Game.Scooby)
for (int i = 0; i < 4; i++)
Data[0xC + i] = BitConverter.GetBytes(value)[i];
}
get => ReadFloat(0xC);
set => Write(0xC, value);
}

public override void SetDynamicProperties(DynamicTypeDescriptor dt)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using HipHopFile;
using SharpDX;
using System.Collections.Generic;
using System.ComponentModel;

Expand All @@ -13,7 +14,7 @@ public class AssetBUTN : AssetWithMotion
protected override int EventStartOffset => 0x6C + Offset + ScoobyOffset + (game == Game.Incredibles ? 0x3C : 0x30);

public AssetBUTN(Section_AHDR AHDR, Game game, Platform platform) : base(AHDR, game, platform) { }

public override bool HasReference(uint assetID) => PressedModel_AssetID == assetID || base.HasReference(assetID);

public override void Verify(ref List<string> result)
Expand Down
2 changes: 1 addition & 1 deletion IndustrialPark/Assets/Shared/Asset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public Asset(Section_AHDR AHDR, Game game, Platform platform) : base(EndianConve
this.game = game;
this.platform = platform;
}

[Category("Data")]
public byte[] Data
{
Expand Down
2 changes: 1 addition & 1 deletion IndustrialPark/Assets/Shared/AssetSpecifics/Motion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public byte UseBanking
}

[Category("Motion")]
[Description("0 = None\n1 = Unknown\n2 = Unknown\n4 = Don't start moving\nAdd numbers to enable multiple flags")]
[Description("0 = None\n1 = Face Movement Direction\n2 = Unknown\n4 = Don't Start Moving\nAdd numbers to enable multiple flags")]
public short Flags
{
get => ReadShort(2);
Expand Down
1 change: 0 additions & 1 deletion IndustrialPark/Assets/Shared/AssetWithMotion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using SharpDX;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace IndustrialPark
{
Expand Down
2 changes: 1 addition & 1 deletion IndustrialPark/Assets/Shared/ObjectAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public ObjectAsset(Section_AHDR AHDR, Game game, Platform platform) : base(AHDR,
if (AssetID != AHDR.assetID)
AssetID = AHDR.assetID;
}

[Category("Object Base")]
public AssetID AssetID
{
Expand Down
2 changes: 1 addition & 1 deletion IndustrialPark/Assets/Shared/PlaceableAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public PlaceableAsset(Section_AHDR AHDR, Game game, Platform platform) : base(AH
if (!renderableAssetSetCommon.Contains(this))
renderableAssetSetCommon.Add(this);
}

public virtual void CreateTransformMatrix()
{
world = Matrix.Scaling(_scale)
Expand Down

0 comments on commit 5f2b50e

Please sign in to comment.