mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2025-02-16 22:08:26 +00:00
Fix loading ZAR files
This commit is contained in:
parent
1540f86a88
commit
61cd136c41
3 changed files with 41 additions and 6 deletions
Binary file not shown.
|
@ -30,7 +30,11 @@ namespace FirstPlugin
|
|||
{
|
||||
using (var reader = new Toolbox.Library.IO.FileReader(stream, true))
|
||||
{
|
||||
return reader.CheckSignature(4, "ZAR/x01") || reader.CheckSignature(4, "GAR\x02") || reader.CheckSignature(4, "GAR\x05");
|
||||
return reader.CheckSignature(4, "ZAR\x01") ||
|
||||
reader.CheckSignature(4, "GAR\x02") ||
|
||||
reader.CheckSignature(4, "GAR\x03") ||
|
||||
reader.CheckSignature(4, "GAR\x04") ||
|
||||
reader.CheckSignature(4, "GAR\x05");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,7 +172,10 @@ namespace FirstPlugin
|
|||
{
|
||||
for (int f = 0; f < ((FileGroup)FileGroups[i]).FileCount; f++)
|
||||
{
|
||||
GarFileInfos.Add(new GarFileInfo(reader));
|
||||
if (Version == VersionMagic.ZAR1)
|
||||
GarFileInfos.Add(new ZarFileInfo(reader));
|
||||
else
|
||||
GarFileInfos.Add(new GarFileInfo(reader));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,11 +183,22 @@ namespace FirstPlugin
|
|||
uint[] Offsets = reader.ReadUInt32s(FileCount);
|
||||
for (int i = 0; i < GarFileInfos.Count; i++)
|
||||
{
|
||||
files.Add(new FileEntry()
|
||||
if (GarFileInfos[i] is ZarFileInfo)
|
||||
{
|
||||
FileName = ((GarFileInfo)GarFileInfos[i]).FileName,
|
||||
FileData = reader.getSection(Offsets[i], ((GarFileInfo)GarFileInfos[i]).FileSize)
|
||||
});
|
||||
files.Add(new FileEntry()
|
||||
{
|
||||
FileName = ((ZarFileInfo)GarFileInfos[i]).FileName,
|
||||
FileData = reader.getSection(Offsets[i], ((ZarFileInfo)GarFileInfos[i]).FileSize)
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
files.Add(new FileEntry()
|
||||
{
|
||||
FileName = ((GarFileInfo)GarFileInfos[i]).FileName,
|
||||
FileData = reader.getSection(Offsets[i], ((GarFileInfo)GarFileInfos[i]).FileSize)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,6 +92,8 @@ namespace FirstPlugin
|
|||
|
||||
shader.SetBoolToInt("isTransparent", cmbMaterial.BlendEnaled);
|
||||
|
||||
SetGLCullMode(cmbMaterial.CullMode);
|
||||
|
||||
GL.Enable(EnableCap.Blend);
|
||||
GL.BlendFunc(cmbMaterial.BlendingFactorSrcAlpha, cmbMaterial.BlendingFactorDestAlpha);
|
||||
GL.BlendColor(1.0f, 1.0f, 1.0f, cmbMaterial.BlendColorA);
|
||||
|
@ -103,6 +105,21 @@ namespace FirstPlugin
|
|||
GL.AlphaFunc(cmbMaterial.AlphaTestFunction, cmbMaterial.AlphaTestReference);
|
||||
}
|
||||
|
||||
private void SetGLCullMode(CullMode CullMode)
|
||||
{
|
||||
GL.Enable(EnableCap.CullFace);
|
||||
|
||||
if (CullMode == CullMode.BACK)
|
||||
GL.CullFace(CullFaceMode.Back);
|
||||
if (CullMode == CullMode.FRONT)
|
||||
GL.CullFace(CullFaceMode.Front);
|
||||
if (CullMode == CullMode.FRONT_AND_BACK)
|
||||
GL.CullFace(CullFaceMode.FrontAndBack);
|
||||
if (CullMode == CullMode.NONE)
|
||||
GL.Disable(EnableCap.CullFace);
|
||||
|
||||
}
|
||||
|
||||
public override int BindTexture(STGenericMatTexture tex, ShaderProgram shader)
|
||||
{
|
||||
GL.ActiveTexture(TextureUnit.Texture0 + tex.textureUnit + 1);
|
||||
|
|
Loading…
Add table
Reference in a new issue