Support for decompressing carcs
This commit is contained in:
parent
04e3e65845
commit
8bbe51bb9c
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -309,12 +309,23 @@ namespace FirstPlugin
|
|||||||
return "";
|
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;
|
private bool DrawablesLoaded = false;
|
||||||
public void LoadEditors(object SelectedSection)
|
public void LoadEditors(object SelectedSection)
|
||||||
{
|
{
|
||||||
BfresEditor bfresEditor = (BfresEditor)LibraryGUI.Instance.GetActiveContent(typeof(BfresEditor));
|
BfresEditor bfresEditor = (BfresEditor)LibraryGUI.Instance.GetActiveContent(typeof(BfresEditor));
|
||||||
bool HasModels = false;
|
bool HasModels = false;
|
||||||
bool HasShapes = false;
|
bool hasShapes = HasShapes();
|
||||||
|
|
||||||
if (bfresEditor == null)
|
if (bfresEditor == null)
|
||||||
{
|
{
|
||||||
@ -325,15 +336,6 @@ namespace FirstPlugin
|
|||||||
LibraryGUI.Instance.LoadEditor(bfresEditor);
|
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;
|
bool ViewportToggled = bfresEditor.DisplayViewport;
|
||||||
|
|
||||||
if (SelectedSection is FTEX)
|
if (SelectedSection is FTEX)
|
||||||
@ -430,14 +432,12 @@ namespace FirstPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Runtime.UseOpenGL)
|
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);
|
bfresEditor.FrameCamera(BFRESRender);
|
||||||
|
|
||||||
|
bool IsSimpleEditor = PluginRuntime.UseSimpleBfresEditor;
|
||||||
if (IsSimpleEditor)
|
if (IsSimpleEditor)
|
||||||
{
|
{
|
||||||
if (SelectedSection is MatTextureWrapper)
|
if (SelectedSection is MatTextureWrapper)
|
||||||
|
@ -163,25 +163,35 @@ namespace FirstPlugin.Forms
|
|||||||
}
|
}
|
||||||
|
|
||||||
private BFRES ActiveBfres;
|
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;
|
ActiveBfres = bfres;
|
||||||
|
HasShapes = hasShapes;
|
||||||
|
ActiveDrawable = activeDrawable;
|
||||||
|
|
||||||
if (!Runtime.UseOpenGL || !DisplayViewport)
|
if (!Runtime.UseOpenGL || !DisplayViewport)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ReloadDrawableList();
|
||||||
|
|
||||||
if (customContextMenus != null)
|
if (customContextMenus != null)
|
||||||
{
|
{
|
||||||
foreach (var menu in customContextMenus)
|
foreach (var menu in customContextMenus)
|
||||||
viewport.LoadCustomMenuItem(menu);
|
viewport.LoadCustomMenuItem(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ActiveDrawable.Drawables.Count > 0 && HasShapes)
|
|
||||||
viewport.ReloadDrawables(ActiveDrawable);
|
|
||||||
|
|
||||||
OnLoadedTab();
|
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()
|
public override void OnControlClosing()
|
||||||
{
|
{
|
||||||
@ -235,6 +245,7 @@ namespace FirstPlugin.Forms
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Runtime.DisplayViewport = true;
|
Runtime.DisplayViewport = true;
|
||||||
|
ReloadDrawableList();
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayViewport = Runtime.DisplayViewport;
|
DisplayViewport = Runtime.DisplayViewport;
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -97,6 +97,15 @@ namespace Switch_Toolbox.Library.IO
|
|||||||
return OpenFileFormat(FileName, data, LeaveStreamOpen, InArchive, archiveNode, true,
|
return OpenFileFormat(FileName, data, LeaveStreamOpen, InArchive, archiveNode, true,
|
||||||
CompressionType.Zlib, DecompressedFileSize, CompressedFileSize);
|
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 (Magic == "ZLIB")
|
||||||
{
|
{
|
||||||
if (data == null)
|
if (data == null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user