1
0
mirror of synced 2024-12-01 02:27:22 +01:00

Only get the filedata once for opening archive editors for quicker loading/less memory usage

This commit is contained in:
KillzXGaming 2019-06-22 10:40:08 -04:00
parent 55fa5381fa
commit c879ec7839
7 changed files with 10 additions and 13 deletions

Binary file not shown.

View File

@ -247,15 +247,13 @@ namespace FirstPlugin
if (UseDDS)
{
// Data.Add(SDFParent.block2Array[DdsType].Data.Take((int)SDFParent.block2Array[DdsType].UsedBytes).ToArray());
bool IsDX10 = false;
using (var filereader = new FileReader(SDFParent.block2Array[DdsType].Data))
{
filereader.Position = 84;
IsDX10 = filereader.ReadString(4) == "DX10";
if (IsDX10)
if (IsDX10)
{
if (SDFParent.block2Array[DdsType].UsedBytes > 0x94)
IsSwizzled = true;
@ -440,8 +438,6 @@ namespace FirstPlugin
bool IsFile = !Name.Contains("dummy") && decompresedSize > 5;
Console.WriteLine(Name + " " + IsFile);
if (IsFile)
{
FileEntries.Add(new FileEntry()

View File

@ -61,26 +61,27 @@ namespace Switch_Toolbox.Library.Forms
{
if (GetEditor() == 0)
UpdatePropertiesView();
if (GetEditor() == 1)
else if (GetEditor() == 1)
UpdateHexView();
if (GetEditor() == 2)
else if (GetEditor() == 2)
UpdateFileEditor();
if (GetEditor() == 3)
else if (GetEditor() == 3)
UpdateTextView();
}
private void UpdateFileEditor()
{
if (!ArchiveFileInfo.IsSupportedFileFormat())
var File = ArchiveFileInfo.FileFormat;
if (File == null) //If the file is not open yet, try temporarily for a preview
File = ArchiveFileInfo.OpenFile();
//If the file is still null, just add a basic control and return
if (File == null)
{
AddControl(new STUserControl());
return;
}
var File = ArchiveFileInfo.FileFormat;
if (File == null) //If the file is not open yet, try temporarily for a preview
File = ArchiveFileInfo.OpenFile();
SetEditorForm(File);
//If the format isn't active we can just dispose it