diff --git a/AssetStudio/AssetStudio-x86.csproj b/AssetStudio/AssetStudio-x86.csproj
index 1174731..375d318 100644
--- a/AssetStudio/AssetStudio-x86.csproj
+++ b/AssetStudio/AssetStudio-x86.csproj
@@ -169,6 +169,7 @@
+
ShaderResource.resx
True
diff --git a/AssetStudio/AssetStudio.csproj b/AssetStudio/AssetStudio.csproj
index f826d37..3a86871 100644
--- a/AssetStudio/AssetStudio.csproj
+++ b/AssetStudio/AssetStudio.csproj
@@ -152,6 +152,7 @@
+
True
True
diff --git a/AssetStudio/Classes/AudioClip.cs b/AssetStudio/Classes/AudioClip.cs
index a70108c..0b2585c 100644
--- a/AssetStudio/Classes/AudioClip.cs
+++ b/AssetStudio/Classes/AudioClip.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
-using System.Windows.Forms;
namespace AssetStudio
{
@@ -94,36 +93,7 @@ namespace AssetStudio
{
if (!string.IsNullOrEmpty(m_Source))
{
- var resourceFileName = Path.GetFileName(m_Source);
- var resourceFilePath = Path.GetDirectoryName(sourceFile.filePath) + "\\" + resourceFileName;
- if (!File.Exists(resourceFilePath))
- {
- var findFiles = Directory.GetFiles(Path.GetDirectoryName(sourceFile.filePath), resourceFileName, SearchOption.AllDirectories);
- if (findFiles.Length > 0)
- {
- resourceFilePath = findFiles[0];
- }
- }
- if (File.Exists(resourceFilePath))
- {
- using (var resourceReader = new BinaryReader(File.OpenRead(resourceFilePath)))
- {
- resourceReader.BaseStream.Position = m_Offset;
- m_AudioData = resourceReader.ReadBytes((int)m_Size);
- }
- }
- else
- {
- if (Studio.resourceFileReaders.TryGetValue(resourceFileName.ToUpper(), out var resourceReader))
- {
- resourceReader.Position = m_Offset;
- m_AudioData = resourceReader.ReadBytes((int)m_Size);
- }
- else
- {
- MessageBox.Show($"can't find the resource file {resourceFileName}");
- }
- }
+ m_AudioData = ResourcesHelper.GetData(m_Source, sourceFile.filePath, m_Offset, (int)m_Size);
}
else
{
diff --git a/AssetStudio/Classes/Texture2D.cs b/AssetStudio/Classes/Texture2D.cs
index 6aa7e24..7cb6102 100644
--- a/AssetStudio/Classes/Texture2D.cs
+++ b/AssetStudio/Classes/Texture2D.cs
@@ -4,7 +4,6 @@ using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
-using System.Windows.Forms;
namespace AssetStudio
{
@@ -117,36 +116,7 @@ namespace AssetStudio
{
if (!string.IsNullOrEmpty(path))
{
- var resourceFileName = Path.GetFileName(path);
- var resourceFilePath = Path.GetDirectoryName(sourceFile.filePath) + "\\" + resourceFileName;
- if (!File.Exists(resourceFilePath))
- {
- var findFiles = Directory.GetFiles(Path.GetDirectoryName(sourceFile.filePath), resourceFileName, SearchOption.AllDirectories);
- if (findFiles.Length > 0)
- {
- resourceFilePath = findFiles[0];
- }
- }
- if (File.Exists(resourceFilePath))
- {
- using (var resourceReader = new BinaryReader(File.OpenRead(resourceFilePath)))
- {
- resourceReader.BaseStream.Position = offset;
- image_data = resourceReader.ReadBytes(image_data_size);
- }
- }
- else
- {
- if (Studio.resourceFileReaders.TryGetValue(resourceFileName.ToUpper(), out var resourceReader))
- {
- resourceReader.Position = offset;
- image_data = resourceReader.ReadBytes(image_data_size);
- }
- else
- {
- MessageBox.Show($"can't find the resource file {resourceFileName}");
- }
- }
+ image_data = ResourcesHelper.GetData(path, sourceFile.filePath, offset, image_data_size);
}
else
{
diff --git a/AssetStudio/Classes/VideoClip.cs b/AssetStudio/Classes/VideoClip.cs
index 360385d..dfb8866 100644
--- a/AssetStudio/Classes/VideoClip.cs
+++ b/AssetStudio/Classes/VideoClip.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
-using System.Windows.Forms;
namespace AssetStudio
{
@@ -54,36 +53,7 @@ namespace AssetStudio
{
if (!string.IsNullOrEmpty(m_Source))
{
- var resourceFileName = Path.GetFileName(m_Source);
- var resourceFilePath = Path.GetDirectoryName(sourceFile.filePath) + "\\" + resourceFileName;
- if (!File.Exists(resourceFilePath))
- {
- var findFiles = Directory.GetFiles(Path.GetDirectoryName(sourceFile.filePath), resourceFileName, SearchOption.AllDirectories);
- if (findFiles.Length > 0)
- {
- resourceFilePath = findFiles[0];
- }
- }
- if (File.Exists(resourceFilePath))
- {
- using (var resourceReader = new BinaryReader(File.OpenRead(resourceFilePath)))
- {
- resourceReader.BaseStream.Position = (long)m_Offset;
- m_VideoData = resourceReader.ReadBytes((int)m_Size);
- }
- }
- else
- {
- if (Studio.resourceFileReaders.TryGetValue(resourceFileName.ToUpper(), out var resourceReader))
- {
- resourceReader.Position = (long)m_Offset;
- m_VideoData = resourceReader.ReadBytes((int)m_Size);
- }
- else
- {
- MessageBox.Show($"can't find the resource file {resourceFileName}");
- }
- }
+ m_VideoData = ResourcesHelper.GetData(m_Source, sourceFile.filePath, (long)m_Offset, (int)m_Size);
}
else
{
diff --git a/AssetStudio/StudioClasses/ResourcesHelper.cs b/AssetStudio/StudioClasses/ResourcesHelper.cs
new file mode 100644
index 0000000..448b725
--- /dev/null
+++ b/AssetStudio/StudioClasses/ResourcesHelper.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+
+namespace AssetStudio
+{
+ public static class ResourcesHelper
+ {
+ public static byte[] GetData(string path, string sourceFilePath, long offset, int size)
+ {
+ var resourceFileName = Path.GetFileName(path);
+ var resourceFilePath = Path.GetDirectoryName(sourceFilePath) + "\\" + resourceFileName;
+ if (!File.Exists(resourceFilePath))
+ {
+ var findFiles = Directory.GetFiles(Path.GetDirectoryName(sourceFilePath), resourceFileName, SearchOption.AllDirectories);
+ if (findFiles.Length > 0)
+ {
+ resourceFilePath = findFiles[0];
+ }
+ }
+ if (File.Exists(resourceFilePath))
+ {
+ using (var resourceReader = new BinaryReader(File.OpenRead(resourceFilePath)))
+ {
+ resourceReader.BaseStream.Position = offset;
+ return resourceReader.ReadBytes(size);
+ }
+ }
+ else
+ {
+ if (Studio.resourceFileReaders.TryGetValue(resourceFileName.ToUpper(), out var resourceReader))
+ {
+ resourceReader.Position = offset;
+ return resourceReader.ReadBytes(size);
+ }
+ else
+ {
+ MessageBox.Show($"can't find the resource file {resourceFileName}");
+ return null;
+ }
+ }
+ }
+ }
+}