Skip to content

Commit

Permalink
Merge pull request #202 from nesrak1/at3
Browse files Browse the repository at this point in the history
Merge AT3 into master (finally)
  • Loading branch information
nesrak1 authored Nov 18, 2022
2 parents 72acfb0 + 1c9d3bc commit a2bc41c
Show file tree
Hide file tree
Showing 58 changed files with 3,346 additions and 1,494 deletions.
12 changes: 6 additions & 6 deletions AudioClipPlugin/AudioClipPlugin.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Platforms>AnyCPU;x64;x86</Platforms>
Expand All @@ -14,15 +14,15 @@
<UABEABinDir>$(SolutionDir)UABEAvalonia\$(OutputPath)</UABEABinDir>
</PropertyGroup>

<Copy SourceFiles="$(OutputPath)AudioClipPlugin.dll;$(OutputPath)Fmod5Sharp.dll;$(OutputPath)IndexRange.dll;$(OutputPath)NAudio.Core.dll;$(OutputPath)OggVorbisEncoder.dll;$(OutputPath)System.Text.Json.dll" DestinationFolder="$(UABEABinDir)plugins" ContinueOnError="true" />
<Copy SourceFiles="$(OutputPath)AudioClipPlugin.dll;$(OutputPath)Fmod5Sharp.dll;$(OutputPath)NAudio.Core.dll;$(OutputPath)OggVorbisEncoder.dll;$(OutputPath)System.Text.Json.dll" DestinationFolder="$(UABEABinDir)plugins" ContinueOnError="true" />
</Target>
<!-- publish event -->
<Target Name="CopyLibrariesPublish" AfterTargets="Publish" Condition="'$(SolutionDir)' != '*Undefined*'">
<PropertyGroup>
<UABEABinDir>$(SolutionDir)UABEAvalonia\$(PublishDir)</UABEABinDir>
</PropertyGroup>

<Copy SourceFiles="$(OutputPath)AudioClipPlugin.dll;$(OutputPath)Fmod5Sharp.dll;$(OutputPath)IndexRange.dll;$(OutputPath)NAudio.Core.dll;$(OutputPath)OggVorbisEncoder.dll;$(OutputPath)System.Text.Json.dll" DestinationFolder="$(UABEABinDir)plugins" ContinueOnError="true" />
<Copy SourceFiles="$(OutputPath)AudioClipPlugin.dll;$(OutputPath)Fmod5Sharp.dll;$(OutputPath)NAudio.Core.dll;$(OutputPath)OggVorbisEncoder.dll;$(OutputPath)System.Text.Json.dll" DestinationFolder="$(UABEABinDir)plugins" ContinueOnError="true" />
</Target>

<ItemGroup>
Expand All @@ -36,9 +36,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.13" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.13" />
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.13" />
<PackageReference Include="Avalonia" Version="11.0.0-preview3" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview3" />
<PackageReference Include="Avalonia.Diagnostics" Version="11.0.0-preview3" />
<PackageReference Include="Fmod5Sharp" Version="3.0.1" />
<PackageReference Include="Mono.Cecil" Version="0.11.4" />
</ItemGroup>
Expand Down
33 changes: 17 additions & 16 deletions AudioClipPlugin/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public bool SelectionValidForPlugin(AssetsManager am, UABEAPluginAction action,
if (action != UABEAPluginAction.Export)
return false;

int classId = AssetHelper.FindAssetClassByName(am.classFile, "AudioClip").classId;
int classId = AssetHelper.FindAssetClassByName(am.classDatabase, "AudioClip").ClassId;

foreach (AssetContainer cont in selection)
{
Expand Down Expand Up @@ -67,16 +67,16 @@ public async Task<bool> BatchExport(Window win, AssetWorkspace workspace, List<A
{
AssetTypeValueField baseField = workspace.GetBaseField(cont);

string name = baseField.Get("m_Name").GetValue().AsString();
string name = baseField["m_Name"].AsString;
name = Extensions.ReplaceInvalidPathChars(name);

CompressionFormat compressionFormat = (CompressionFormat) baseField.Get("m_CompressionFormat").GetValue().AsInt();
CompressionFormat compressionFormat = (CompressionFormat)baseField["m_CompressionFormat"].AsInt;
string extension = GetExtension(compressionFormat);
string file = Path.Combine(dir, $"{name}-{Path.GetFileName(cont.FileInstance.path)}-{cont.PathId}.{extension}");

string ResourceSource = baseField.Get("m_Resource").Get("m_Source").GetValue().AsString();
ulong ResourceOffset = baseField.Get("m_Resource").Get("m_Offset").GetValue().AsUInt64();
ulong ResourceSize = baseField.Get("m_Resource").Get("m_Size").GetValue().AsUInt64();
string ResourceSource = baseField["m_Resource.m_Source"].AsString;
ulong ResourceOffset = baseField["m_Resource.m_Offset"].AsULong;
ulong ResourceSize = baseField["m_Resource.m_Size"].AsULong;

byte[] resourceData;
if (!GetAudioBytes(cont, ResourceSource, ResourceOffset, ResourceSize, out resourceData))
Expand All @@ -103,17 +103,18 @@ public async Task<bool> BatchExport(Window win, AssetWorkspace workspace, List<A
}
return false;
}

public async Task<bool> SingleExport(Window win, AssetWorkspace workspace, List<AssetContainer> selection)
{
AssetContainer cont = selection[0];

SaveFileDialog sfd = new SaveFileDialog();

AssetTypeValueField baseField = workspace.GetBaseField(cont);
string name = baseField.Get("m_Name").GetValue().AsString();
string name = baseField["m_Name"].AsString;
name = Extensions.ReplaceInvalidPathChars(name);

CompressionFormat compressionFormat = (CompressionFormat) baseField.Get("m_CompressionFormat").GetValue().AsInt();
CompressionFormat compressionFormat = (CompressionFormat) baseField["m_CompressionFormat"].AsInt;

sfd.Title = "Save audio file";
string extension = GetExtension(compressionFormat);
Expand All @@ -126,9 +127,9 @@ public async Task<bool> SingleExport(Window win, AssetWorkspace workspace, List<

if (file != null && file != string.Empty)
{
string ResourceSource = baseField.Get("m_Resource").Get("m_Source").GetValue().AsString();
ulong ResourceOffset = baseField.Get("m_Resource").Get("m_Offset").GetValue().AsUInt64();
ulong ResourceSize = baseField.Get("m_Resource").Get("m_Size").GetValue().AsUInt64();
string ResourceSource = baseField["m_Resource.m_Source"].AsString;
ulong ResourceOffset = baseField["m_Resource.m_Offset"].AsULong;
ulong ResourceSize = baseField["m_Resource.m_Size"].AsULong;

byte[] resourceData;
if (!GetAudioBytes(cont, ResourceSource, ResourceOffset, ResourceSize, out resourceData))
Expand Down Expand Up @@ -227,14 +228,14 @@ private bool GetAudioBytes(AssetContainer cont, string filepath, ulong offset, u

AssetBundleFile bundle = cont.FileInstance.parentBundle.file;

AssetsFileReader reader = bundle.reader;
AssetBundleDirectoryInfo06[] dirInf = bundle.bundleInf6.dirInf;
AssetsFileReader reader = bundle.DataReader;
AssetBundleDirectoryInfo[] dirInf = bundle.BlockAndDirInfo.DirectoryInfos;
for (int i = 0; i < dirInf.Length; i++)
{
AssetBundleDirectoryInfo06 info = dirInf[i];
if (info.name == searchPath)
AssetBundleDirectoryInfo info = dirInf[i];
if (info.Name == searchPath)
{
reader.Position = bundle.bundleHeader6.GetFileDataOffset() + info.offset + (long) offset;
reader.Position = info.Offset + (long)offset;
audioData = reader.ReadBytes((int)size);
return true;
}
Expand Down
138 changes: 138 additions & 0 deletions Libs/AssetsTools.NET.Cpp2IL.deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{
"runtimeTarget": {
"name": ".NETStandard,Version=v2.0/",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETStandard,Version=v2.0": {},
".NETStandard,Version=v2.0/": {
"AssetsTools.NET.Cpp2IL/1.0.0": {
"dependencies": {
"AssetsTools.NET": "1.0.0",
"NETStandard.Library": "2.0.3",
"Samboy063.LibCpp2IL": "2022.0.5"
},
"runtime": {
"AssetsTools.NET.Cpp2IL.dll": {}
}
},
"IndexRange/1.0.0": {
"runtime": {
"lib/netstandard2.0/IndexRange.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.0.0.0"
}
}
},
"Microsoft.NETCore.Platforms/1.1.0": {},
"Mono.Cecil/0.11.3": {
"runtime": {
"lib/netstandard2.0/Mono.Cecil.Mdb.dll": {
"assemblyVersion": "0.11.3.0",
"fileVersion": "0.11.3.0"
},
"lib/netstandard2.0/Mono.Cecil.Pdb.dll": {
"assemblyVersion": "0.11.3.0",
"fileVersion": "0.11.3.0"
},
"lib/netstandard2.0/Mono.Cecil.Rocks.dll": {
"assemblyVersion": "0.11.3.0",
"fileVersion": "0.11.3.0"
},
"lib/netstandard2.0/Mono.Cecil.dll": {
"assemblyVersion": "0.11.3.0",
"fileVersion": "0.11.3.0"
}
}
},
"NETStandard.Library/2.0.3": {
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0"
}
},
"Samboy063.LibCpp2IL/2022.0.5": {
"dependencies": {
"IndexRange": "1.0.0",
"Samboy063.WasmDisassembler": "2022.0.2"
},
"runtime": {
"lib/netstandard2.0/LibCpp2IL.dll": {
"assemblyVersion": "2022.0.5.0",
"fileVersion": "2022.0.5.0"
}
}
},
"Samboy063.WasmDisassembler/2022.0.2": {
"runtime": {
"lib/netstandard2.0/WasmDisassembler.dll": {
"assemblyVersion": "2022.0.2.0",
"fileVersion": "2022.0.2.0"
}
}
},
"AssetsTools.NET/1.0.0": {
"dependencies": {
"Mono.Cecil": "0.11.3"
},
"runtime": {
"AssetsTools.NET.dll": {}
}
}
}
},
"libraries": {
"AssetsTools.NET.Cpp2IL/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"IndexRange/1.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-6TgS1JLSUkpmPLfXBPaAgB39ZUix8E4soXWk2XSDcscVe84i1JKzIAtA7jHbRHSkOOrcr6YA0MpLCeq98y9mYQ==",
"path": "indexrange/1.0.0",
"hashPath": "indexrange.1.0.0.nupkg.sha512"
},
"Microsoft.NETCore.Platforms/1.1.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==",
"path": "microsoft.netcore.platforms/1.1.0",
"hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512"
},
"Mono.Cecil/0.11.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-DNYE+io5XfEE8+E+5padThTPHJARJHbz1mhbhMPNrrWGKVKKqj/KEeLvbawAmbIcT73NuxLV7itHZaYCZcVWGg==",
"path": "mono.cecil/0.11.3",
"hashPath": "mono.cecil.0.11.3.nupkg.sha512"
},
"NETStandard.Library/2.0.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
"path": "netstandard.library/2.0.3",
"hashPath": "netstandard.library.2.0.3.nupkg.sha512"
},
"Samboy063.LibCpp2IL/2022.0.5": {
"type": "package",
"serviceable": true,
"sha512": "sha512-eH+/FBclsKDxboa9N/tFoiM8kwvietVX0FtXYxvcexSp/geYCyTt2XUGOQjinqd3Yqg/QxmpIqBO7qy4MQHrhw==",
"path": "samboy063.libcpp2il/2022.0.5",
"hashPath": "samboy063.libcpp2il.2022.0.5.nupkg.sha512"
},
"Samboy063.WasmDisassembler/2022.0.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-2uu+xBb7M3HKfBx9tAY6jiDieAf0hRnQjSmGX+7IdE6i24dYsx6TYgtrLvRx5lOuF2M8DijZ5H8yQ1pcuCs2SA==",
"path": "samboy063.wasmdisassembler/2022.0.2",
"hashPath": "samboy063.wasmdisassembler.2022.0.2.nupkg.sha512"
},
"AssetsTools.NET/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
Binary file added Libs/AssetsTools.NET.Cpp2IL.dll
Binary file not shown.
Binary file modified Libs/AssetsTools.NET.dll
Binary file not shown.
Loading

0 comments on commit a2bc41c

Please sign in to comment.