add bz2 support. use compress.bat to compress your maps

This commit is contained in:
Bitl 2022-11-02 12:53:20 -07:00
parent c694a9b120
commit 720277e265
7 changed files with 90 additions and 18 deletions

View File

@ -981,6 +981,60 @@ public class ClientManagement
} }
#endif #endif
#if LAUNCHER
//https://stackoverflow.com/questions/30687987/unable-to-decompress-bz2-file-has-orginal-file-using-dotnetzip-library
private static string Decompress(bool forceOverwrite)
{
var outFname = GlobalVars.UserConfiguration.MapPath.Replace(".bz2", "");
if (File.Exists(outFname))
{
if (forceOverwrite)
File.Delete(outFname);
else
return null;
}
using (Stream fs = File.OpenRead(GlobalVars.UserConfiguration.MapPath),
output = File.Create(outFname),
decompressor = new Ionic.BZip2.BZip2InputStream(fs))
Pump(decompressor, output);
return outFname;
}
private static void Pump(Stream src, Stream dest)
{
byte[] buffer = new byte[2048];
int n;
while ((n = src.Read(buffer, 0, buffer.Length)) > 0)
dest.Write(buffer, 0, n);
}
private static void DecompressMap(ScriptType type, bool nomap)
{
if ((type != ScriptType.Client || type != ScriptType.EasterEgg) && !nomap && GlobalVars.UserConfiguration.Map.Contains(".bz2"))
{
Decompress(true);
GlobalVars.UserConfiguration.MapPath = GlobalVars.UserConfiguration.MapPath.Replace(".bz2", "");
GlobalVars.UserConfiguration.Map = GlobalVars.UserConfiguration.Map.Replace(".bz2", "");
GlobalVars.isMapCompressed = true;
}
}
public static void ResetDecompressedMap()
{
if (GlobalVars.isMapCompressed)
{
Util.FixedFileDelete(GlobalVars.UserConfiguration.MapPath);
GlobalVars.UserConfiguration.MapPath = GlobalVars.UserConfiguration.MapPath.Replace(".rbxlx", ".rbxlx.bz2").Replace(".rbxl", ".rbxl.bz2");
GlobalVars.UserConfiguration.Map = GlobalVars.UserConfiguration.Map.Replace(".rbxlx", ".rbxlx.bz2").Replace(".rbxl", ".rbxl.bz2");
GlobalVars.isMapCompressed = false;
}
}
#endif
#if URI #if URI
public static void LaunchRBXClient(ScriptType type, bool no3d, bool nomap, EventHandler e, Label label) public static void LaunchRBXClient(ScriptType type, bool no3d, bool nomap, EventHandler e, Label label)
#else #else
@ -1000,6 +1054,10 @@ public class ClientManagement
public static void LaunchRBXClient(string ClientName, ScriptType type, bool no3d, bool nomap, EventHandler e) public static void LaunchRBXClient(string ClientName, ScriptType type, bool no3d, bool nomap, EventHandler e)
#endif #endif
{ {
#if LAUNCHER
DecompressMap(type, nomap);
#endif
switch (type) switch (type)
{ {
case ScriptType.Client: case ScriptType.Client:
@ -1324,7 +1382,7 @@ public class ClientManagement
#region Script Functions #region Script Functions
public class ScriptFuncs public class ScriptFuncs
{ {
#region Script Generator/Signer #region Script Generator/Signer
public class Generator public class Generator
{ {
public static void SignGeneratedScript(string scriptFileName, bool newSigFormat = false, bool encodeInBase64 = true) public static void SignGeneratedScript(string scriptFileName, bool newSigFormat = false, bool encodeInBase64 = true)
@ -1509,9 +1567,9 @@ public class ScriptFuncs
return ClientManagement.GetGenLuaFileName(ClientName, type); return ClientManagement.GetGenLuaFileName(ClientName, type);
} }
} }
#endregion #endregion
#region ClientScript Parser #region ClientScript Parser
public class ClientScript public class ClientScript
{ {
public static string GetArgsFromTag(string code, string tag, string endtag) public static string GetArgsFromTag(string code, string tag, string endtag)
@ -1759,6 +1817,6 @@ public class ScriptFuncs
return compiled; return compiled;
} }
} }
#endregion #endregion
} }
#endregion #endregion

View File

@ -143,6 +143,7 @@ public static class GlobalVars
public static string NextCommand = ""; public static string NextCommand = "";
public static bool AppClosed = false; public static bool AppClosed = false;
public static bool isConsoleOnly = false; public static bool isConsoleOnly = false;
public static bool isMapCompressed = false;
#endregion #endregion
} }
#endregion #endregion

View File

@ -93,7 +93,7 @@ public class ModManager
if (globalType == ModType.ModPackage) if (globalType == ModType.ModPackage)
{ {
MessageBox.Show("Your mod is loading. You will recieve a notification when it is installed. Please keep the launcher open. You can see the installation progress in the Console.", "Novetus - Mod Loading"); MessageBox.Show("Your mod is loading. You will recieve a notification when it is installed. Please keep the launcher open. If the Console is open, you can see the installation progress.", "Novetus - Mod Loading");
int filecount = 0; int filecount = 0;
StringBuilder filelistbuilder = new StringBuilder(); StringBuilder filelistbuilder = new StringBuilder();

View File

@ -436,6 +436,8 @@ namespace NovetusLauncher
Parent.Visible = true; Parent.Visible = true;
} }
ClientManagement.ResetDecompressedMap();
if (GlobalVars.isConsoleOnly) if (GlobalVars.isConsoleOnly)
{ {
CloseEventInternal(); CloseEventInternal();
@ -779,7 +781,7 @@ namespace NovetusLauncher
Util.RenameFileWithInvalidChars(path); Util.RenameFileWithInvalidChars(path);
} }
string[] fileexts = new string[] { ".rbxl", ".rbxlx" }; string[] fileexts = new string[] { ".rbxl", ".rbxlx", ".bz2" };
TreeNodeHelper.ListDirectory(Tree, mapdir, fileexts); TreeNodeHelper.ListDirectory(Tree, mapdir, fileexts);
TreeNodeHelper.CopyNodes(Tree.Nodes, _TreeCache.Nodes); TreeNodeHelper.CopyNodes(Tree.Nodes, _TreeCache.Nodes);
Tree.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.UserConfiguration.Map, Tree.Nodes); Tree.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.UserConfiguration.Map, Tree.Nodes);
@ -853,9 +855,9 @@ namespace NovetusLauncher
if (Tree.SelectedNode == null) if (Tree.SelectedNode == null)
return; return;
if (File.Exists(GlobalPaths.RootPath + @"\\" + Tree.SelectedNode.FullPath.Replace(".rbxl", "").Replace(".rbxlx", "") + "_desc.txt")) if (File.Exists(GlobalPaths.RootPath + @"\\" + Tree.SelectedNode.FullPath.Replace(".rbxl", "").Replace(".rbxlx", "").Replace(".bz2", "") + "_desc.txt"))
{ {
MapDescBox.Text = File.ReadAllText(GlobalPaths.RootPath + @"\\" + Tree.SelectedNode.FullPath.Replace(".rbxl", "").Replace(".rbxlx", "") + "_desc.txt"); MapDescBox.Text = File.ReadAllText(GlobalPaths.RootPath + @"\\" + Tree.SelectedNode.FullPath.Replace(".rbxl", "").Replace(".rbxlx", "").Replace(".bz2", "") + "_desc.txt");
} }
else else
{ {
@ -1093,7 +1095,7 @@ namespace NovetusLauncher
{ {
using (var ofd = new OpenFileDialog()) using (var ofd = new OpenFileDialog())
{ {
ofd.Filter = "Roblox Level (*.rbxl)|*.rbxl|Roblox Level (*.rbxlx)|*.rbxlx"; ofd.Filter = "Roblox Level (*.rbxl)|*.rbxl|Roblox Level (*.rbxlx)|*.rbxlx|bzip2 compressed Roblox Level (*.bz2)|*.bz2";
ofd.FilterIndex = 1; ofd.FilterIndex = 1;
ofd.Title = "Load Roblox map"; ofd.Title = "Load Roblox map";
if (ofd.ShowDialog() == DialogResult.OK) if (ofd.ShowDialog() == DialogResult.OK)

View File

@ -547,9 +547,9 @@ namespace NovetusLauncher
if (mapsBox.SelectedNode == null) if (mapsBox.SelectedNode == null)
return; return;
if (File.Exists(GlobalPaths.RootPath + @"\\" + mapsBox.SelectedNode.FullPath.Replace(".rbxl", "").Replace(".rbxlx", "") + "_desc.txt")) if (File.Exists(GlobalPaths.RootPath + @"\\" + mapsBox.SelectedNode.FullPath.Replace(".rbxl", "").Replace(".rbxlx", "").Replace(".bz2", "") + "_desc.txt"))
{ {
mapsDescBox.Text = mapsBox.SelectedNode.Text + ": " + File.ReadAllText(GlobalPaths.RootPath + @"\\" + mapsBox.SelectedNode.FullPath.Replace(".rbxl", "").Replace(".rbxlx", "") + "_desc.txt"); mapsDescBox.Text = mapsBox.SelectedNode.Text + ": " + File.ReadAllText(GlobalPaths.RootPath + @"\\" + mapsBox.SelectedNode.FullPath.Replace(".rbxl", "").Replace(".rbxlx", "").Replace(".bz2", "") + "_desc.txt");
} }
else else
{ {

View File

@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup> </startup>
<runtime> <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0"/> <bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
</dependentAssembly> </dependentAssembly>
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0"/> <bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
</dependentAssembly> </dependentAssembly>
</assemblyBinding> </assemblyBinding>
<gcAllowVeryLargeObjects enabled="true"/> <gcAllowVeryLargeObjects enabled="true" />
</runtime> </runtime>
</configuration> </configuration>

View File

@ -0,0 +1,11 @@
@ECHO OFF
SET SourceDir=%CD%
SET DestDir=%CD%
for %%f in (*.rbxl) do (
if "%%~xf"==".rbxl" (
"C:\Program Files\7-Zip\7z.exe" a "%DestDir%\%%f.bz2" "%SourceDir%\%%f"
del "%%f"
)
)