1
0
mirror of synced 2024-11-12 02:00:50 +01:00

Support for decompressing carcs

This commit is contained in:
KillzXGaming 2019-06-15 20:50:26 -04:00
parent 04e3e65845
commit 8bbe51bb9c
9 changed files with 39 additions and 19 deletions

Binary file not shown.

View File

@ -309,12 +309,23 @@ namespace FirstPlugin
return "";
}
public bool HasShapes()
{
BFRESRender.UpdateModelList();
for (int i = 0; i < BFRESRender.models.Count; i++)
{
if (BFRESRender.models[i].shapes.Count > 0)
return true;
}
return false;
}
private bool DrawablesLoaded = false;
public void LoadEditors(object SelectedSection)
{
BfresEditor bfresEditor = (BfresEditor)LibraryGUI.Instance.GetActiveContent(typeof(BfresEditor));
bool HasModels = false;
bool HasShapes = false;
bool hasShapes = HasShapes();
if (bfresEditor == null)
{
@ -325,15 +336,6 @@ namespace FirstPlugin
LibraryGUI.Instance.LoadEditor(bfresEditor);
}
for (int i = 0; i < BFRESRender.models.Count; i++)
{
if (BFRESRender.models[i].shapes.Count > 0)
{
HasShapes = true;
break;
}
}
bool ViewportToggled = bfresEditor.DisplayViewport;
if (SelectedSection is FTEX)
@ -430,14 +432,12 @@ namespace FirstPlugin
}
if (Runtime.UseOpenGL)
bfresEditor.LoadViewport(this, HasShapes, DrawableContainer);
bfresEditor.LoadViewport(this, hasShapes, DrawableContainer);
bool IsSimpleEditor = PluginRuntime.UseSimpleBfresEditor;
if (SelectedSection is BFRES && HasShapes)
if (SelectedSection is BFRES && hasShapes)
bfresEditor.FrameCamera(BFRESRender);
bool IsSimpleEditor = PluginRuntime.UseSimpleBfresEditor;
if (IsSimpleEditor)
{
if (SelectedSection is MatTextureWrapper)

View File

@ -163,25 +163,35 @@ namespace FirstPlugin.Forms
}
private BFRES ActiveBfres;
public void LoadViewport(BFRES bfres, bool HasShapes, DrawableContainer ActiveDrawable, List<ToolStripMenuItem> customContextMenus = null)
private DrawableContainer ActiveDrawable;
private bool HasShapes = false;
public void LoadViewport(BFRES bfres, bool hasShapes, DrawableContainer activeDrawable, List<ToolStripMenuItem> customContextMenus = null)
{
ActiveBfres = bfres;
HasShapes = hasShapes;
ActiveDrawable = activeDrawable;
if (!Runtime.UseOpenGL || !DisplayViewport)
return;
ReloadDrawableList();
if (customContextMenus != null)
{
foreach (var menu in customContextMenus)
viewport.LoadCustomMenuItem(menu);
}
if (ActiveDrawable.Drawables.Count > 0 && HasShapes)
viewport.ReloadDrawables(ActiveDrawable);
OnLoadedTab();
}
private void ReloadDrawableList()
{
if (viewport == null || ActiveBfres == null || ActiveDrawable == null) return;
if (ActiveDrawable.Drawables.Count > 0 && ActiveBfres.HasShapes())
viewport.ReloadDrawables(ActiveDrawable);
}
public override void OnControlClosing()
{
@ -235,6 +245,7 @@ namespace FirstPlugin.Forms
else
{
Runtime.DisplayViewport = true;
ReloadDrawableList();
}
DisplayViewport = Runtime.DisplayViewport;

View File

@ -97,6 +97,15 @@ namespace Switch_Toolbox.Library.IO
return OpenFileFormat(FileName, data, LeaveStreamOpen, InArchive, archiveNode, true,
CompressionType.Zlib, DecompressedFileSize, CompressedFileSize);
}
if (Path.GetExtension(FileName) == ".carc" && CompType == CompressionType.None)
{
if (data == null)
data = File.ReadAllBytes(FileName);
data = STLibraryCompression.ZLIB.Decompress(fileReader.getSection(0x10, data.Length - 0x10));
return OpenFileFormat(FileName, data, LeaveStreamOpen, InArchive, archiveNode, true,
CompressionType.Zlib, DecompressedFileSize, CompressedFileSize);
}
if (Magic == "ZLIB")
{
if (data == null)