mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Merge pull request #65 from bluepilledgreat/mod-to-resources
get rid of base64 mod strings
This commit is contained in:
commit
bd9dc7e22c
@ -18,6 +18,12 @@
|
||||
<Content Include="Bloxstrap.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\Mods\OldCursor.png" />
|
||||
<EmbeddedResource Include="Resources\Mods\OldDeath.ogg" />
|
||||
<EmbeddedResource Include="Resources\Mods\OldFarCursor.png" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DiscordRichPresence" Version="1.1.3.18" />
|
||||
<PackageReference Include="securifybv.ShellLink" Version="0.1.0" />
|
||||
|
@ -114,7 +114,7 @@ namespace Bloxstrap
|
||||
if (!Directory.Exists(VersionFolder) && CheckIfRunning(true) || Program.Settings.VersionGuid != VersionGuid && !CheckIfRunning(false))
|
||||
await InstallLatestVersion();
|
||||
|
||||
ApplyModifications();
|
||||
await ApplyModifications();
|
||||
|
||||
if (Program.IsFirstRun)
|
||||
Program.SettingsManager.ShouldSave = true;
|
||||
@ -475,7 +475,7 @@ namespace Bloxstrap
|
||||
Program.Settings.VersionGuid = VersionGuid;
|
||||
}
|
||||
|
||||
private void ApplyModifications()
|
||||
private async Task ApplyModifications()
|
||||
{
|
||||
Dialog.Message = "Applying Roblox modifications...";
|
||||
|
||||
@ -488,13 +488,13 @@ namespace Bloxstrap
|
||||
if (!Directory.Exists(modFolder))
|
||||
{
|
||||
Directory.CreateDirectory(modFolder);
|
||||
File.WriteAllText(Path.Combine(modFolder, "README.txt"), ModReadme);
|
||||
await File.WriteAllTextAsync(Path.Combine(modFolder, "README.txt"), ModReadme);
|
||||
}
|
||||
|
||||
CheckModPreset(Program.Settings.UseOldDeathSound, @"content\sounds\ouch.ogg", Program.Base64OldDeathSound);
|
||||
CheckModPreset(Program.Settings.UseOldMouseCursor, @"content\textures\Cursors\KeyboardMouse\ArrowCursor.png", Program.Base64OldArrowCursor);
|
||||
CheckModPreset(Program.Settings.UseOldMouseCursor, @"content\textures\Cursors\KeyboardMouse\ArrowFarCursor.png", Program.Base64OldArrowFarCursor);
|
||||
CheckModPreset(Program.Settings.UseDisableAppPatch, @"ExtraContent\places\Mobile.rbxl", "");
|
||||
await CheckModPreset(Program.Settings.UseOldDeathSound, @"content\sounds\ouch.ogg", "OldDeath.ogg");
|
||||
await CheckModPreset(Program.Settings.UseOldMouseCursor, @"content\textures\Cursors\KeyboardMouse\ArrowCursor.png", "OldCursor.png");
|
||||
await CheckModPreset(Program.Settings.UseOldMouseCursor, @"content\textures\Cursors\KeyboardMouse\ArrowFarCursor.png", "OldFarCursor.png");
|
||||
await CheckModPreset(Program.Settings.UseDisableAppPatch, @"ExtraContent\places\Mobile.rbxl", "");
|
||||
|
||||
foreach (string file in Directory.GetFiles(modFolder, "*.*", SearchOption.AllDirectories))
|
||||
{
|
||||
@ -513,7 +513,7 @@ namespace Bloxstrap
|
||||
// original files from the downloaded packages
|
||||
|
||||
if (File.Exists(manifestFile))
|
||||
manifestFiles = File.ReadAllLines(manifestFile).ToList<string>();
|
||||
manifestFiles = (await File.ReadAllLinesAsync(manifestFile)).ToList();
|
||||
else
|
||||
manifestFiles = modFolderFiles;
|
||||
|
||||
@ -567,10 +567,10 @@ namespace Bloxstrap
|
||||
File.WriteAllLines(manifestFile, modFolderFiles);
|
||||
}
|
||||
|
||||
private static void CheckModPreset(bool condition, string location, string base64Contents)
|
||||
private static async Task CheckModPreset(bool condition, string location, string name)
|
||||
{
|
||||
string modFolderLocation = Path.Combine(Directories.Modifications, location);
|
||||
byte[] binaryData = Convert.FromBase64String(base64Contents);
|
||||
byte[] binaryData = string.IsNullOrEmpty(name) ? Array.Empty<byte>() : await ResourceHelper.Get(name);
|
||||
|
||||
if (condition)
|
||||
{
|
||||
@ -583,7 +583,7 @@ namespace Bloxstrap
|
||||
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
File.WriteAllBytes(modFolderLocation, binaryData);
|
||||
await File.WriteAllBytesAsync(modFolderLocation, binaryData);
|
||||
}
|
||||
}
|
||||
else if (File.Exists(modFolderLocation) && Utilities.MD5File(modFolderLocation) == Utilities.MD5Data(binaryData))
|
||||
|
25
Bloxstrap/Helpers/ResourceHelper.cs
Normal file
25
Bloxstrap/Helpers/ResourceHelper.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Bloxstrap.Helpers
|
||||
{
|
||||
internal class ResourceHelper
|
||||
{
|
||||
static readonly Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
static readonly string[] resourceNames = assembly.GetManifestResourceNames();
|
||||
|
||||
public static async Task<byte[]> Get(string name)
|
||||
{
|
||||
string path = resourceNames.Single(str => str.EndsWith(name));
|
||||
|
||||
using (Stream stream = assembly.GetManifestResourceStream(path)!)
|
||||
{
|
||||
using (MemoryStream memoryStream = new())
|
||||
{
|
||||
await stream.CopyToAsync(memoryStream);
|
||||
return memoryStream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
BIN
Bloxstrap/Resources/Mods/OldCursor.png
Normal file
BIN
Bloxstrap/Resources/Mods/OldCursor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 232 B |
BIN
Bloxstrap/Resources/Mods/OldDeath.ogg
Normal file
BIN
Bloxstrap/Resources/Mods/OldDeath.ogg
Normal file
Binary file not shown.
BIN
Bloxstrap/Resources/Mods/OldFarCursor.png
Normal file
BIN
Bloxstrap/Resources/Mods/OldFarCursor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 235 B |
Loading…
Reference in New Issue
Block a user