Skip to content

Commit

Permalink
[AnimationEditor] Restructured sdk/type initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
CadeEvs committed Sep 22, 2022
1 parent b2d0792 commit 8582620
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ public object Data
public AssetBankViewModel(FrostyBaseEditor inOwner)
{
m_owner = inOwner;

AssetBankTypeLibrary.Initialize();


m_entries = new List<AssetBankFileEntry>();
foreach (AssetBankFileEntry entry in App.AssetManager.EnumerateCustomAssets("assetbank"))
{
Expand Down
56 changes: 34 additions & 22 deletions Plugins/AnimationEditorPlugin/Managers/AssetBankFileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ public class AssetBankFileManager : ICustomAssetManager

#region -- ICustomAssetManager --

public bool ShouldInitializeOnStartup => false;
public bool ShouldInitializeOnStartup => true;

public void Initialize(ILogger logger)
{
logger.Log("Loading asset banks");

// initial type library
AssetBankTypeLibrary.Initialize();

uint totalCount = App.AssetManager.GetResCount((uint)ResourceType.AssetBank);
uint index = 0;
foreach (ResAssetEntry resEntry in App.AssetManager.EnumerateRes((uint)ResourceType.AssetBank))
Expand Down Expand Up @@ -111,28 +114,10 @@ public void Initialize(ILogger logger)
banks = new List<Bank>();
}

using (AssetBankModuleWriter writer = new AssetBankModuleWriter("AssetBankClasses.dll", banks))
{
writer.Write(App.FileSystemManager.Head);
}

if (File.Exists("AssetBankClasses.dll"))
{
FileInfo fi = new FileInfo(".\\AssetBankTmpProfiles\\" + ProfilesLibrary.SDKFilename + ".dll");
if (!fi.Directory.Exists)
{
Directory.CreateDirectory(fi.Directory.FullName);
}
if (fi.Exists)
{
File.Delete(fi.FullName);
}

File.Move("AssetBankClasses.dll", fi.FullName);
}
else
// write sdk if one doesn't exist
if (!File.Exists("AssetBankProfiles/" + ProfilesLibrary.SDKFilename + ".dll"))
{
Console.WriteLine("Failed to produce SDK");
WriteSdk(banks);
}

/*
Expand Down Expand Up @@ -213,5 +198,32 @@ public void OnCommand(string command, params object[] value)
}

#endregion

private void WriteSdk(List<Bank> banks)
{
using (AssetBankModuleWriter writer = new AssetBankModuleWriter("AssetBankClasses.dll", banks))
{
writer.Write(App.FileSystemManager.Head);
}

if (File.Exists("AssetBankClasses.dll"))
{
FileInfo fi = new FileInfo(".\\AssetBankTmpProfiles\\" + ProfilesLibrary.SDKFilename + ".dll");
if (!fi.Directory.Exists)
{
Directory.CreateDirectory(fi.Directory.FullName);
}
if (fi.Exists)
{
File.Delete(fi.FullName);
}

File.Move("AssetBankClasses.dll", fi.FullName);
}
else
{
Console.WriteLine("Failed to produce SDK");
}
}
}
}

0 comments on commit 8582620

Please sign in to comment.