private static Task <PakIndex?> loadPakIndex(string paksFolderPath) { var tcs = new TaskCompletionSource <PakIndex?>(); Task.Run(() => { try { var filter = new PakFilter(new[] { Constants.PAKS_FILTER_STRING }, false); var pakIndex = new PakIndex(path: paksFolderPath, cacheFiles: true, caseSensitive: true, filter: filter); if (pakIndex.PakFileCount == 0) { throw new FileNotFoundException($"No files were found at {paksFolderPath}"); } if (!unlockPakIndex(pakIndex)) { throw new InvalidOperationException($"Could not decrypt pak files at {paksFolderPath}"); } tcs.SetResult(pakIndex); } catch (Exception e) { Console.WriteLine($"Could not load Minecraft Dungeons Paks: {e}"); tcs.SetException(e); } }); return(tcs.Task); }
public static async Task InitializeOffline(string directory) { Index = new PakIndex(directory, true, false, null); Index.UseKey(FGuid.Zero, await AuthSupplier.GetKeyAsync()); foreach (var(guid, key) in await AuthSupplier.GetKeychainAsync()) { Index.UseKey(guid, key); } }
public static PakPackage?extractPackage(this PakIndex pakIndex, string fullPath) { if (!pakIndex.TryGetPackage(fullPath, out var package)) { EventLogger.logError($"Could not get package from {fullPath}"); return(null); } if (!package.HasExport()) { EventLogger.logError($"Package does not have export {fullPath}"); return(null); } return(package); }
public GlobalCache(PakIndex index) { Index = index; VBucksIcon = index.GetPackage("/FortniteGame/Content/UI/Foundation/Shell/Textures/T-Icon-VBucks-L").GetExport <Texture2D>().Image; var img = index.GetPackage("/FortniteGame/Content/VisualThreatManager/StormVisuals/Test/SpawnParticles/Streamers/LowResBlurredNoise").GetExport <Texture2D>().Image; // don't dispose objects given by exports using (var b = SKBitmap.FromImage(img)) using (var b2 = new SKBitmap(new SKImageInfo(b.Width * 2, b.Height * 2), SKBitmapAllocFlags.ZeroPixels)) { using (var c = new SKCanvas(b2)) using (var s = SKShader.CreateColorFilter(SKShader.CreateBitmap(b, SKShaderTileMode.Repeat, SKShaderTileMode.Repeat), SKColorFilter.CreateLighting(new SKColor(160, 160, 160), new SKColor(15, 15, 15)))) { c.DrawRect(0, 0, b2.Width, b2.Height, new SKPaint { Shader = s }); } using (var borderNoiseBig = b2.Resize(new SKImageInfo(b2.Width * 16, b2.Height * 16), SKFilterQuality.Medium)) using (var borderNoise = new SKBitmap(b.Width * 16, b.Width * 16)) { borderNoiseBig.ExtractSubset(borderNoise, new SKRectI(b2.Width * 4, b2.Width * 4, b2.Width * 12, b2.Width * 12)); BaseBorderShader = SKShader.CreateBitmap(borderNoise, SKShaderTileMode.Repeat, SKShaderTileMode.Repeat); } } NameTypeface = SKTypeface.FromStream(index.GetFile("/FortniteGame/Content/UI/Foundation/Fonts/BurbankBigCondensed-Black.ufont").AsStream()); ShortDescriptionTypeface = SKTypeface.FromStream(index.GetFile("/FortniteGame/Content/UI/Foundation/Fonts/NotoSans-Regular.ufont").AsStream()); PriceTypeface = SKTypeface.FromStream(index.GetFile("/FortniteGame/Content/UI/Foundation/Fonts/NotoSans-Bold.ufont").AsStream()); CategoryTypeface = SKTypeface.FromStream(index.GetFile("/FortniteGame/Content/UI/Foundation/Fonts/NotoSans-Bold.ufont").AsStream()); ImagePaint = new SKPaint { IsAntialias = true, FilterQuality = SKFilterQuality.High }; { var types = EnumHelper <DrawType> .Values; SectionCaches = new SectionCache[types.Length]; for (int i = 0; i < types.Length; i++) { SectionCaches[i] = new SectionCache(types[i], this); } } { RarityColors = new ColorPalette[] { new ColorPalette(this, default, new SKColor(150, 150, 150), new SKColor(50, 53, 58), new SKColor(212, 212, 212), new SKColor(249, 249, 249)), // COMMON
public static BitmapImage?extractBitmap(this PakIndex pakIndex, string fullPath) { var package = pakIndex.extractPackage(fullPath); var texture = package?.GetExport <UTexture2D>(); if (texture == null) { EventLogger.logError($"Could not get texture from package {fullPath}"); return(null); } var bitmap = ImageUriHelper.bitmapImageFromSKImage(texture.Image); if (bitmap == null) { EventLogger.logError($"Could not get bitmap from texture {fullPath}"); return(null); } bitmap.Freeze(); return(bitmap); }
private static bool unlockPakIndex(PakIndex pakIndex) { foreach (var keyStr in Secrets.PAKS_AES_KEY_STRINGS) { byte[] keyBytes; if (keyStr.StartsWith("0x")) { keyBytes = keyStr.Substring(2).ToBytesKey(); } else { keyBytes = keyStr.ToBytesKey(); } var count = pakIndex.UseKey(FGuid.Zero, keyBytes); if (count > 0) { return(true); } } return(false); }
private static Task <PakIndex?> loadPakIndex() { var tcs = new TaskCompletionSource <PakIndex?>(); Task.Run(() => { try { var filter = new PakFilter(new[] { "/dungeons/content" }); var pakIndex = new PakIndex(path: Constants.PAKS_FOLDER, cacheFiles: true, caseSensitive: false, filter: filter); pakIndex.UseKey(BinaryHelper.ToBytesKey(Constants.PAKS_AES_KEY_STRING)); tcs.SetResult(pakIndex); } catch (Exception e) { Console.WriteLine($"Could not load Minecraft Dungeons Paks: {e}"); tcs.SetResult(null); } }); return(tcs.Task); }
public PakImageResolver(PakIndex pakIndex, string?path) { this.path = path; _pakIndex = pakIndex; _backupResolver = new LocalImageResolver(); }
public Converter(PakIndex index) { Index = index; }
public PakImageResolver(PakIndex pakIndex) { _pakIndex = pakIndex; _backupResolver = new LocalImageResolver(); }
public static Dictionary <string, Dictionary <string, string> >?extractLocResFile(this PakIndex pakIndex, string fullPath) { if (!pakIndex.TryGetFile(fullPath, out var byteArray) || byteArray == null) { EventLogger.logError($"Could not get anything from {fullPath}"); return(null); } var stream = new MemoryStream(byteArray !.Value.Array, byteArray !.Value.Offset, byteArray !.Value.Count); Dictionary <string, Dictionary <string, string> >?entries = new LocResReader(stream).Entries; return(entries); }