bloxstrap/Bloxstrap/Helpers/RSMM/PackageManifest.cs
pizzaboxer 92b159d682 Updates and bugfixes for v1.3.0
- Features
    - Added integration with rbxfpsunlocker
    - Added support for user-applicable mods
    - Added ability to disable auto-update checking

 - Misc
    - Removed Bloxstrap branding from Discord Rich Presence
    - Mod presets for old death sound and mouse cursor are now statically stored as base64 strings, eliminating reliance on the website and the old cursors still existing

 - Bugfixes
    - Fixed vista bootstrapper style not hiding properly and improper behavior when closed
    - Fixed forms not being brought to the front when shown

 - Code
    - Reconsolidated Bootstrapper to a single file, using regions instead of partials
2022-08-21 22:41:16 +01:00

88 lines
2.5 KiB
C#

// https://github.com/MaximumADHD/Roblox-Studio-Mod-Manager/blob/main/ProjectSrc/Bootstrapper/PackageManifest.cs
using System.IO;
using System.Net.Http;
namespace Bloxstrap.Helpers.RSMM
{
internal class PackageManifest : List<Package>
{
public string RawData { get; private set; }
private PackageManifest(string data)
{
using (var reader = new StringReader(data))
{
string version = reader.ReadLine();
if (version != "v0")
{
string errorMsg = $"Unexpected package manifest version: {version} (expected v0!)\n" +
"Please contact MaximumADHD if you see this error.";
throw new NotSupportedException(errorMsg);
}
bool eof = false;
var readLine = new Func<string>(() =>
{
string line = reader.ReadLine();
if (line == null)
eof = true;
return line;
});
while (!eof)
{
string fileName = readLine();
string signature = readLine();
string rawPackedSize = readLine();
string rawSize = readLine();
if (eof)
break;
if (!int.TryParse(rawPackedSize, out int packedSize))
break;
if (!int.TryParse(rawSize, out int size))
break;
if (fileName == "RobloxPlayerLauncher.exe")
break;
var package = new Package()
{
Name = fileName,
Signature = signature,
PackedSize = packedSize,
Size = size
};
Add(package);
}
}
RawData = data;
}
public static async Task<PackageManifest> Get(string versionGuid)
{
string pkgManifestUrl = $"{Program.BaseUrlSetup}/{versionGuid}-rbxPkgManifest.txt";
string pkgManifestData;
using (HttpClient http = new())
{
var getData = http.GetStringAsync(pkgManifestUrl);
pkgManifestData = await getData.ConfigureAwait(false);
}
return new PackageManifest(pkgManifestData);
}
}
}