forked from MontagueM/Phonon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExporter.cs
More file actions
97 lines (85 loc) · 4.58 KB
/
Copy pathExporter.cs
File metadata and controls
97 lines (85 loc) · 4.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Phonon
{
public class Exporter
{
public string Path = "";
public string Hash = "";
public string SaveName = "";
public PhononType ePhononType;
public TextureFormat eTextureFormat;
public Exporter()
{
}
public bool Export(string PackagesPath)
{
string[] s = Path.Split("\\");
string SavePath = String.Join("/", s);
string FinalSaveName = "";
if (SaveName == "")
{
SaveName = s.Last().Split(".")[0];
FinalSaveName = SaveName;
}
else
{
SavePath += "/" + SaveName + "/";
Directory.CreateDirectory(SavePath);
FinalSaveName = SaveName + "_" + Hash;
}
[DllImport("DestinyDynamicExtractorBL.dll", EntryPoint = "RequestExportDynamic")]
static extern bool RequestExportDynamicBL([MarshalAs(UnmanagedType.LPStr)] string DynamicHash, [MarshalAs(UnmanagedType.LPStr)] string pkgsPath, [MarshalAs(UnmanagedType.LPStr)] string ExportPath, [MarshalAs(UnmanagedType.LPStr)] string ExportName, int TextureFormat);
[DllImport("DestinyDynamicExtractorPREBL.dll", EntryPoint = "RequestExportDynamic")]
static extern bool RequestExportDynamicPREBL([MarshalAs(UnmanagedType.LPStr)] string DynamicHash, [MarshalAs(UnmanagedType.LPStr)] string pkgsPath, [MarshalAs(UnmanagedType.LPStr)] string ExportPath, [MarshalAs(UnmanagedType.LPStr)] string ExportName, int TextureFormat);
[DllImport("DestinyDynamicExtractorD1.dll", EntryPoint = "RequestExportDynamic")]
static extern bool RequestExportDynamicD1([MarshalAs(UnmanagedType.LPStr)] string DynamicHash, [MarshalAs(UnmanagedType.LPStr)] string pkgsPath, [MarshalAs(UnmanagedType.LPStr)] string ExportPath, [MarshalAs(UnmanagedType.LPStr)] string ExportName, int TextureFormat);
bool status = false;
if (ePhononType == PhononType.Destiny2BL)
{
status = RequestExportDynamicBL(Hash, PackagesPath, SavePath, FinalSaveName, ((int)eTextureFormat));
}
else if (ePhononType == PhononType.Destiny2PREBL)
{
status = RequestExportDynamicPREBL(Hash, PackagesPath, SavePath, FinalSaveName, ((int)eTextureFormat));
}
else if (ePhononType == PhononType.Destiny1)
{
status = RequestExportDynamicD1(Hash, PackagesPath, SavePath, FinalSaveName, ((int)eTextureFormat));
}
return status;
}
public bool ExportD1Map(string PackagesPath, List<string> MapNames, Dictionary<string, Dictionary<string, List<string>>> MapInfoDict)
{
[DllImport("DestinyDynamicExtractorD1.dll", EntryPoint = "RequestExportD1Map")]
static extern bool RequestExportD1Map([MarshalAs(UnmanagedType.LPStr)] string MapHash, [MarshalAs(UnmanagedType.LPStr)] string pkgsPath, [MarshalAs(UnmanagedType.LPStr)] string ExportPath, [MarshalAs(UnmanagedType.LPStr)] string ExportName, int TextureFormat);
[DllImport("DestinyDynamicExtractorD1.dll", EntryPoint = "RequestExportD1DynMap")]
static extern bool RequestExportD1DynMap([MarshalAs(UnmanagedType.LPStr)] string MapHash, [MarshalAs(UnmanagedType.LPStr)] string pkgsPath, [MarshalAs(UnmanagedType.LPStr)] string ExportPath, [MarshalAs(UnmanagedType.LPStr)] string ExportName);
bool status = true;
string[] s = Path.Split("\\");
foreach (string MapName in MapNames)
{
string SavePath = String.Join("/", s) + "/" + MapName + "/";
Directory.CreateDirectory(SavePath);
string DynSavePath = $"{SavePath}/DynamicMaps/";
Directory.CreateDirectory(DynSavePath);
List<string> StaticHashes = MapInfoDict[MapName]["static"];
foreach (string MapHash in StaticHashes)
{
status &= RequestExportD1Map(MapHash, PackagesPath, SavePath, MapName, ((int)eTextureFormat));
}
List<string> DynHashes = MapInfoDict[MapName]["dynamic"];
foreach (string MapHash in DynHashes)
{
status &= RequestExportD1DynMap(MapHash, PackagesPath, DynSavePath, MapName);
}
}
return status;
}
}
}