forked from EmK530/BloxDump
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cs
More file actions
173 lines (159 loc) · 6.89 KB
/
Copy pathMain.cs
File metadata and controls
173 lines (159 loc) · 6.89 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#pragma warning disable CS8602,CS8604
using static Essentials;
class Entry
{
public static async Task Main(string[] args)
{
//Assets.Init();
Console.Title = $"{app_name} {app_version}";
if (!Ktx2Sharp.Ktx.Init())
fatal("Could not intialize Ktx2Sharp! Make sure ktx.dll exists.");
CancellationTokenSource cts = new CancellationTokenSource(); // currently unused lol
Dumper.token = cts.Token;
List<Task> threads = new List<Task>();
if (!webPath.EndsWith("\\") && !webIsDatabase)
webPath = webPath + "\\";
if (!UWPPath.EndsWith("\\") && !UWPisDatabase)
UWPPath = UWPPath + "\\";
if (!webDB.EndsWith("\\"))
webDB = webDB + "\\";
if (!UWPdb.EndsWith("\\"))
UWPdb = UWPdb + "\\";
// Manage dependencies
if (!Directory.Exists(dependDir))
{
Directory.CreateDirectory(dependDir);
}
if(!File.Exists(dependDir + "ffmpeg.exe"))
{
bool downloaded = await DownloadDependencyAsync("ffmpeg.exe", "https://github.com/EmK530/BloxDump/releases/download/dependencies/ffmpeg.exe");
if (!downloaded)
fatal("Could not download dependency: ffmpeg.exe");
}
if(Directory.GetCurrentDirectory().Contains("System32"))
{
warn("Attempting to move out of System32!");
Directory.SetCurrentDirectory(exedir);
Environment.CurrentDirectory = exedir;
}
if (ReadConfigBoolean("Cache.ForceCustomDirectory.Enable"))
{
string dir = ReadAliasedString("Cache.ForceCustomDirectory.TargetDirectory");
bool db = ReadConfigBoolean("Cache.ForceCustomDirectory.IsDatabase");
if (!(db ? File.Exists(dir) : Directory.Exists(dir)))
{
fatal($"ForceCustomDirectory is enabled, but a path was not found! ({dir})\nFix the config or disable ForceCustomDirectory.");
}
if (!dir.EndsWith("\\") && !db)
dir += "\\";
CacheScanner.targetPath = dir;
CacheScanner.TargetIsDatabase = db;
if(db)
{
string dbDir = ReadAliasedString("Cache.ForceCustomDirectory.DBFolder");
if (!Directory.Exists(dir))
{
fatal($"ForceCustomDirectory is enabled, but a path was not found! ({dir})\nFix the config or disable ForceCustomDirectory.");
}
CacheScanner.dbFolder = dbDir;
}
}
else
{
bool isDir1 = webIsDatabase ? File.Exists(webPath) : Directory.Exists(webPath);
bool isDir2 = UWPisDatabase ? File.Exists(UWPPath) : Directory.Exists(UWPPath);
if ((isDir1 && isDir2) || (!isDir1 && !isDir2))
{
Console.WriteLine("\nWhich version of Roblox do you use?");
Console.WriteLine("If your input is incorrect then dumping will not work as intended.\n");
Console.WriteLine($"1: Standard Version\n2: UWP Version (Microsoft Store)");
bool done = false;
while (!done)
{
Console.Write("\nInput: ");
string? get = Console.ReadLine();
if (int.TryParse(get, out int parsed))
{
switch (parsed)
{
case 1:
CacheScanner.targetPath = webPath;
CacheScanner.TargetIsDatabase = webIsDatabase;
CacheScanner.dbFolder = webDB;
done = true;
break;
case 2:
CacheScanner.targetPath = UWPPath;
CacheScanner.TargetIsDatabase = UWPisDatabase;
CacheScanner.dbFolder = UWPdb;
done = true;
break;
default:
warn($"Unrecognized choice: {parsed}");
break;
}
}
}
}
else if (isDir2 && !isDir1)
{
CacheScanner.targetPath = UWPPath;
CacheScanner.TargetIsDatabase = UWPisDatabase;
CacheScanner.dbFolder = UWPdb;
}
}
if (ReadConfigBoolean("Cache.PromptClearOnLaunch"))
{
Console.WriteLine("\nDo you want to clear Roblox's cache?");
Console.WriteLine("If you clear the cache then any assets downloaded from previous sessions will not be dumped.");
Console.Write("\nType Y to clear or anything else to proceed: ");
if (Console.ReadLine().ToLower() == "y")
{
Console.WriteLine();
print("Deleting Roblox cache...\n");
while (!EmptyFolder())
{
warn("Unable to clear Roblox's cache! You may need to close Roblox first.\n\nDo you wish to try again?");
Console.Write("\nType Y to try again or anything else to ignore: ");
if (Console.ReadLine().ToLower() == "y")
{
Console.Clear();
} else
{
break;
}
}
}
}
else
{
if (ReadConfigBoolean("Cache.AutoClearIfNoPrompt"))
{
print("Deleting Roblox cache...\n");
if(!EmptyFolder())
{
warn("Unable to clear Roblox's cache! You may need to close Roblox first.");
Thread.Sleep(3000);
}
}
}
int threadCount = Environment.ProcessorCount - 1;
if (ReadConfigBoolean("DumperSettings.CustomThreadCount.Enable"))
{
threadCount = ReadConfigInteger("DumperSettings.CustomThreadCount.Target");
if (threadCount > Environment.ProcessorCount)
{
warn($"The config has instructed BloxDump to run with {threadCount} threads.");
warn($"This is more than your CPU thread count of {Environment.ProcessorCount}, be aware.");
}
}
for (int i = 0; i < Math.Max(threadCount, 1); i++)
{
int thr = i + 1;
debug($"Launching dumper Thread-{thr}");
threads.Add(Task.Run(() => Dumper.Thread(thr)));
}
Console.Clear();
await CacheScanner.Begin();
}
}