Example #1
0
        public static string enchantmentName(string enchantment)
        {
            var key = enchantment;

            if (!isStringsLoaded)
            {
                return(key);
            }
            if (_mismatches.ContainsKey(key))
            {
                key = _mismatches[key];
            }
            if (_enchantment.TryGetValue(key, out string value))
            {
                if (enchantment.ToLowerInvariant().Contains("ranged"))
                {
                    return($"{value} ({R.RANGED_ITEMS_FILTER})");
                }
                else if (enchantment.ToLowerInvariant().Contains("melee"))
                {
                    return($"{value} ({R.MELEE_ITEMS_FILTER})");
                }
                else
                {
                    return(value);
                }
            }
            EventLogger.logError($"Could not find string for enchantment {key}");
            return(enchantment);
        }
Example #2
0
        public static async ValueTask ProcessFile(FileInfo file, bool overwrite)
        {
            if (!file.Exists)
            {
                EventLogger.logError($"File \"{file.FullName}\" could not be found and has been skipped.");
                return;
            }

            using FileStream inputStream = file.OpenRead();
            bool encrypted = SaveFileHandler.IsFileEncrypted(inputStream);

            Stream?processed = encrypted ? await Decrypt(inputStream) : await Encrypt(inputStream);

            if (processed == null)
            {
                EventLogger.logError($"Content of file \"{file.Name}\" could not be converted to a supported format.");
                return;
            }

            processed.Seek(0, SeekOrigin.Begin);
            string outputFile = GetOutputFilePath(file, encrypted, overwrite);

            using FileStream outputStream = File.Open(outputFile, FileMode.Create, FileAccess.Write);
            await processed.CopyToAsync(outputStream);
        }
        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);
        }
Example #4
0
 public BitmapImage?imageSourceForItem(string itemType)
 {
     if (_equipment.TryGetValue(itemType, out string fullPath))
     {
         var image = imageSource(fullPath);
         if (image != null)
         {
             return(image);
         }
     }
     EventLogger.logError($"Could not find full path for item {itemType}");
     return(_backupResolver.imageSourceForItem(itemType));
 }
 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);
 }
 private BitmapImage?tryBitmapImageForUri(Uri uri)
 {
     try
     {
         //Console.WriteLine("Requesting Uri: {0}", uri);
         var image = new BitmapImage(uri, REQUEST_CACHE_POLICY);
         return(image);
     }
     catch (Exception e)
     {
         EventLogger.logError($"Error creating bitmap for {uri}");
         Console.Write(e);
         //Debug.Assert(false);
         return(null);
     }
 }
Example #7
0
        private async Task <ProfileSaveFile?> tryParseFileStreamAsync(Stream stream)
        {
            try
            {
                stream.Seek(0, SeekOrigin.Begin);
                var profile = await ProfileParser.Read(stream);

                return(profile);
            }
            catch (Exception e)
            {
                EventLogger.logError(e.ToString());
                showError?.Invoke(R.FAILED_TO_PARSE_FILE_ERROR_MESSAGE);
            }
            return(null);
        }
Example #8
0
 public static string?getString(string key)
 {
     if (!isStringsLoaded)
     {
         return(null);
     }
     if (_mismatches.ContainsKey(key))
     {
         key = _mismatches[key];
     }
     if (_clickys.TryGetValue(key, out string value))
     {
         return(value);
     }
     EventLogger.logError($"Could not find string for mission {key}");
     return(null);
 }
Example #9
0
 private static string?getArmorPropertyString(string key)
 {
     if (!isStringsLoaded)
     {
         return(key);
     }
     if (_mismatches.ContainsKey(key))
     {
         key = _mismatches[key];
     }
     if (_armorProperties.TryGetValue(key, out string value))
     {
         return(value);
     }
     EventLogger.logError($"Could not find string for armor {key}");
     return(null);
 }
Example #10
0
 private static string?getEnchantmentString(string key)
 {
     if (!isStringsLoaded)
     {
         return(key);
     }
     if (_mismatches.ContainsKey(key))
     {
         key = _mismatches[key];
     }
     if (_enchantment.TryGetValue(key, out string value))
     {
         return(value);
     }
     EventLogger.logError($"Could not find string for enchantment {key}");
     return(null);
 }
Example #11
0
        public BitmapImage?imageSourceForEnchantment(string enchantment)
        {
            var enchantmentId = enchantment;

            if (enchantmentId == Constants.DEFAULT_ENCHANTMENT_ID)
            {
                return(imageSource("/Dungeons/Content/UI/Materials/MissionSelectMap/marker/locked_node"));
            }

            if (_enchantments.TryGetValue(enchantmentId, out string fullPath))
            {
                var image = imageSource(fullPath);
                if (image != null)
                {
                    return(image);
                }
            }
            EventLogger.logError($"Could not find full path for enchantment {enchantmentId}");
            return(_backupResolver.imageSourceForEnchantment(enchantmentId));
        }
Example #12
0
        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);
        }
Example #13
0
        private async Task <ProfileSaveFile?> handleDatFileOpen(string filePath)
        {
            var file = new FileInfo(filePath);

            using FileStream inputStream = file.OpenRead();
            bool encrypted = SaveFileHandler.IsFileEncrypted(inputStream);

            if (!encrypted)
            {
                EventLogger.logError($"The file \"{file.Name}\" was in an unexpected format.");
                showError?.Invoke(R.formatFILE_IN_UNEXPECTED_FORMAT_ERROR_MESSAGE(file.Name));
                return(null);
            }
            using Stream? processed = await FileProcessHelper.Decrypt(inputStream);

            if (processed == null)
            {
                EventLogger.logError($"Content of file \"{file.Name}\" could not be converted to a supported format.");
                showError?.Invoke(R.formatFILE_DECRYPT_ERROR_MESSAGE(file.Name));
                return(null);
            }
            return(await tryParseFileStreamAsync(processed !));
        }