Ejemplo n.º 1
0
    public static void ReloadParams()
    {
        if (!File.Exists(ParamPath))
        {
            Debug.Log("Data0.bdt not found. This will make treasure editor have less functionality.");
            return;
        }
        BND4 paramBnd = SFUtil.DecryptDS3Regulation(DarkSoulsTools.GetOverridenPath(ParamPath));

        DS3Param = PARAM.Read(paramBnd.Files.Find(x => Path.GetFileName(x.Name) == "ItemLotParam.param").Bytes);
        PARAM.Layout layout = PARAM.Layout.ReadXMLFile($@"{Application.dataPath.Replace('/', '\\')}\dstools\ParamLayouts\DS3\{DS3Param.ID}.xml");
        DS3Param.SetLayout(layout);

        // Build and cache the item name list
        HashSet <int> usedItemIds = new HashSet <int>();

        ItemNameList = new List <Tuple <int, string> >();
        foreach (var row in DS3Param.Rows)
        {
            ItemLotParam param = new ItemLotParam(row);
            foreach (int id in param.ItemID)
            {
                if (!usedItemIds.Contains(id))
                {
                    usedItemIds.Add(id);
                    ItemNameList.Add(new Tuple <int, string>(id, FMGUtils.LookupItemName(id)));
                }
            }
        }
        ItemNameList.Sort((a, b) => StringComparer.InvariantCulture.Compare(a.Item2, b.Item2));
    }
Ejemplo n.º 2
0
        private static void LoadParamsDS3()
        {
            var dir = AssetLocator.GameRootDirectory;
            var mod = AssetLocator.GameModDirectory;

            if (!File.Exists($@"{dir}\Data0.bdt"))
            {
                MessageBox.Show("Could not find DS3 regulation file. Functionality will be limited.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Load loose params if they exist
            if (File.Exists($@"{mod}\\param\gameparam\gameparam_dlc2.parambnd.dcx"))
            {
                // Load params
                var  lparam    = $@"{mod}\param\gameparam\gameparam_dlc2.parambnd.dcx";
                BND4 lparamBnd = BND4.Read(lparam);

                LoadParamFromBinder(lparamBnd);
                return;
            }

            // Load params
            var param = $@"{mod}\Data0.bdt";

            if (!File.Exists(param))
            {
                param = $@"{dir}\Data0.bdt";
            }
            BND4 paramBnd = SFUtil.DecryptDS3Regulation(param);

            LoadParamFromBinder(paramBnd);
        }
Ejemplo n.º 3
0
 // Reads bnd
 private IBinder ReadBnd(string path)
 {
     try
     {
         if (BND3.Is(path))
         {
             return(BND3.Read(path));
         }
         else if (BND4.Is(path))
         {
             return(BND4.Read(path));
         }
         else if (Spec.Game == FromGame.DS3 && path.EndsWith("Data0.bdt"))
         {
             return(SFUtil.DecryptDS3Regulation(path));
         }
         else
         {
             throw new Exception($"Unrecognized bnd format for game {Spec.Game}: {path}");
         }
     }
     catch (Exception ex)
     {
         throw new Exception($"Failed to load {path}: {ex}");
     }
 }
Ejemplo n.º 4
0
        private void LoadRegulation(string path)
        {
            BND4 bnd;

            try
            {
                bnd = SFUtil.DecryptDS3Regulation(path);
            }
            catch (Exception ex)
            {
                ShowError($"Failed to load regulation file:\r\n\r\n{path}\r\n\r\n{ex}");
                return;
            }

            paramFiles = new List <ParamFile>();
            foreach (BinderFile file in bnd.Files)
            {
                if (Path.GetExtension(file.Name) == ".param")
                {
                    try
                    {
                        PARAM param = PARAM.Read(file.Bytes);
                        paramFiles.Add(new ParamFile(Path.GetFileNameWithoutExtension(file.Name), param, layouts));
                    }
                    catch
                    {
                    }
                }
            }

            paramFiles.Sort((p1, p2) => p1.Name.CompareTo(p2.Name));
            dgvParams.DataSource = paramFiles;
        }
Ejemplo n.º 5
0
    public static void SaveParams()
    {
        if (GameType != DarkSoulsTools.GameType.DarkSoulsIII || DS3Param == null)
        {
            return;
        }

        BND4 paramBnd = SFUtil.DecryptDS3Regulation(DarkSoulsTools.GetOverridenPath(ParamPath));
        var  param    = paramBnd.Files.Find(x => Path.GetFileName(x.Name) == "ItemLotParam.param");

        param.Bytes = DS3Param.Write();

        // Save a backup if one doesn't exist
        if (!File.Exists(ParamPath + ".backup"))
        {
            File.Copy(ParamPath, ParamPath + ".backup");
        }

        string paramPath = ParamPath;

        if (DarkSoulsTools.GetModProjectPathForFile(ParamPath) != null)
        {
            paramPath = DarkSoulsTools.GetModProjectPathForFile(ParamPath);
        }

        // Write as a temporary file to make sure there are no errors before overwriting current file
        if (File.Exists(paramPath + ".temp"))
        {
            File.Delete(paramPath + ".temp");
        }
        SFUtil.EncryptDS3Regulation(paramPath + ".temp", paramBnd);

        // Make a copy of the previous map
        File.Copy(paramPath, paramPath + ".prev", true);

        // Move temp file as new map file
        File.Delete(paramPath);
        File.Move(paramPath + ".temp", paramPath);
    }
Ejemplo n.º 6
0
        public static bool LoadParamBND(bool forceReload)
        {
            string interroot = GameDataManager.InterrootPath;

            bool justNowLoadedParamBND = false;

            if (forceReload || !ParamBNDs.ContainsKey(GameDataManager.GameType))
            {
                ParamBNDs.Add(GameDataManager.GameType, null);

                if (GameDataManager.GameType == GameDataManager.GameTypes.DS1)
                {
                    if (Directory.Exists($"{interroot}\\param\\GameParam\\") && File.Exists($"{interroot}\\param\\GameParam\\GameParam.parambnd"))
                    {
                        ParamBNDs[GameDataManager.GameType] = BND3.Read($"{interroot}\\param\\GameParam\\GameParam.parambnd");
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (GameDataManager.GameType == GameDataManager.GameTypes.BB)
                {
                    if (Directory.Exists($"{interroot}\\param\\GameParam\\") && File.Exists($"{interroot}\\param\\GameParam\\GameParam.parambnd.dcx"))
                    {
                        ParamBNDs[GameDataManager.GameType] = BND4.Read($"{interroot}\\param\\GameParam\\GameParam.parambnd.dcx");
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (GameDataManager.GameType == GameDataManager.GameTypes.DS3)
                {
                    if (Directory.Exists($"{interroot}\\param\\GameParam\\") && File.Exists($"{interroot}\\param\\GameParam\\GameParam_dlc2.parambnd.dcx"))
                    {
                        ParamBNDs[GameDataManager.GameType] = BND4.Read($"{interroot}\\param\\GameParam\\GameParam_dlc2.parambnd.dcx");
                    }
                    else if (File.Exists($"{interroot}\\Data0.bdt"))
                    {
                        ParamBNDs[GameDataManager.GameType] = SFUtil.DecryptDS3Regulation($"{interroot}\\Data0.bdt");
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    throw new NotImplementedException();
                }

                justNowLoadedParamBND = true;
            }

            if (justNowLoadedParamBND || forceReload || GameTypeCurrentLoadedParamsAreFrom != GameDataManager.GameType)
            {
                LoadStuffFromParamBND();
            }

            return(true);
        }
Ejemplo n.º 7
0
        private static void SaveParamsDS3(bool loose)
        {
            var dir = AssetLocator.GameRootDirectory;
            var mod = AssetLocator.GameModDirectory;

            if (!File.Exists($@"{dir}\Data0.bdt"))
            {
                MessageBox.Show("Could not find DS3 regulation file. Cannot save.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Load params
            var param = $@"{mod}\Data0.bdt";

            if (!File.Exists(param))
            {
                param = $@"{dir}\Data0.bdt";
            }
            BND4 paramBnd = SFUtil.DecryptDS3Regulation(param);

            // Replace params with edited ones
            foreach (var p in paramBnd.Files)
            {
                if (_params.ContainsKey(Path.GetFileNameWithoutExtension(p.Name)))
                {
                    p.Bytes = _params[Path.GetFileNameWithoutExtension(p.Name)].Write();
                }
            }

            // If not loose write out the new regulation
            if (!loose)
            {
                Utils.WriteWithBackup(dir, mod, @"Data0.bdt", paramBnd, true);
            }
            else
            {
                // Otherwise write them out as parambnds
                BND4 paramBND = new BND4
                {
                    BigEndian   = false,
                    Compression = DCX.Type.DCX_DFLT_10000_44_9,
                    Extended    = 0x04,
                    Unk04       = false,
                    Unk05       = false,
                    Format      = Binder.Format.Compression | Binder.Format.Flag6 | Binder.Format.LongOffsets | Binder.Format.Names1,
                    Unicode     = true,
                    Files       = paramBnd.Files.Where(f => f.Name.EndsWith(".param")).ToList()
                };

                BND4 stayBND = new BND4
                {
                    BigEndian   = false,
                    Compression = DCX.Type.DCX_DFLT_10000_44_9,
                    Extended    = 0x04,
                    Unk04       = false,
                    Unk05       = false,
                    Format      = Binder.Format.Compression | Binder.Format.Flag6 | Binder.Format.LongOffsets | Binder.Format.Names1,
                    Unicode     = true,
                    Files       = paramBnd.Files.Where(f => f.Name.EndsWith(".stayparam")).ToList()
                };

                Utils.WriteWithBackup(dir, mod, @"param\gameparam\gameparam_dlc2.parambnd.dcx", paramBND);
                Utils.WriteWithBackup(dir, mod, @"param\gameparam\stayparam.parambnd.dcx", stayBND);
            }
        }
Ejemplo n.º 8
0
        public static LoadParamsResult LoadParams(string paramPath, Dictionary <string, ParamInfo> paramInfo,
                                                  Dictionary <string, PARAM64.Layout> layouts, bool hideUnusedParams)
        {
            if (!File.Exists(paramPath))
            {
                ShowError($"Parambnd not found:\r\n{paramPath}\r\nPlease browse to the Data0.bdt or parambnd you would like to edit.");
                return(null);
            }

            var result = new LoadParamsResult();

            try
            {
                if (BND4.Is(paramPath))
                {
                    result.ParamBND  = BND4.Read(paramPath);
                    result.Encrypted = false;
                }
                else
                {
                    result.ParamBND  = SFUtil.DecryptDS3Regulation(paramPath);
                    result.Encrypted = true;
                }
            }
            catch (DllNotFoundException ex) when(ex.Message.Contains("oo2core_6_win64.dll"))
            {
                ShowError("In order to load Sekiro params, you must copy oo2core_6_win64.dll from Sekiro into Yapped's lib folder.");
                return(null);
            }
            catch (Exception ex)
            {
                ShowError($"Failed to load parambnd:\r\n{paramPath}\r\n\r\n{ex}");
                return(null);
            }

            result.ParamWrappers = new List <ParamWrapper>();
            foreach (BinderFile file in result.ParamBND.Files.Where(f => f.Name.EndsWith(".param")))
            {
                string name = Path.GetFileNameWithoutExtension(file.Name);
                if (paramInfo.ContainsKey(name))
                {
                    if (paramInfo[name].Blocked || paramInfo[name].Hidden && hideUnusedParams)
                    {
                        continue;
                    }
                }

                try
                {
                    PARAM64 param = PARAM64.Read(file.Bytes);
                    if (layouts.ContainsKey(param.ID))
                    {
                        PARAM64.Layout layout = layouts[param.ID];
                        if (layout.Size == param.DetectedSize)
                        {
                            string description = null;
                            if (paramInfo.ContainsKey(name))
                            {
                                description = paramInfo[name].Description;
                            }

                            var wrapper = new ParamWrapper(name, param, layout, description);
                            result.ParamWrappers.Add(wrapper);
                        }
                        else
                        {
                        }
                    }
                }
                catch (Exception ex)
                {
                    ShowError($"Failed to load param file: {name}.param\r\n\r\n{ex}");
                }
            }

            result.ParamWrappers.Sort();
            return(result);
        }
Ejemplo n.º 9
0
        public static bool LoadParamBND(bool forceReload)
        {
            string interroot = GameDataManager.InterrootPath;

            bool justNowLoadedParamBND = false;

            if (forceReload)
            {
                ParamBNDs.Clear();
                LoadedParams.Clear();

                BehaviorParam?.Clear();
                BehaviorParam_PC?.Clear();
                AtkParam_Pc?.Clear();
                AtkParam_Npc?.Clear();
                NpcParam?.Clear();
                EquipParamWeapon?.Clear();
                EquipParamProtector?.Clear();
                WepAbsorpPosParam?.Clear();
            }

            if (forceReload || !ParamBNDs.ContainsKey(GameDataManager.GameType))
            {
                ParamBNDs.Add(GameDataManager.GameType, null);

                if (GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.DS1)
                {
                    if (Directory.Exists($"{interroot}\\param\\GameParam\\") && File.Exists($"{interroot}\\param\\GameParam\\GameParam.parambnd"))
                    {
                        ParamBNDs[GameDataManager.GameType] = BND3.Read($"{interroot}\\param\\GameParam\\GameParam.parambnd");
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.DS1R)
                {
                    if (Directory.Exists($"{interroot}\\param\\GameParam\\") && File.Exists($"{interroot}\\param\\GameParam\\GameParam.parambnd.dcx"))
                    {
                        ParamBNDs[GameDataManager.GameType] = BND3.Read($"{interroot}\\param\\GameParam\\GameParam.parambnd.dcx");
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.DES)
                {
                    if (Directory.Exists($"{interroot}\\param\\GameParam\\") && File.Exists($"{interroot}\\param\\GameParam\\GameParamNA.parambnd.dcx"))
                    {
                        ParamBNDs[GameDataManager.GameType] = BND3.Read($"{interroot}\\param\\GameParam\\GameParamNA.parambnd.dcx");
                    }
                    else if (Directory.Exists($"{interroot}\\param\\GameParam\\") && File.Exists($"{interroot}\\param\\GameParam\\GameParam.parambnd.dcx"))
                    {
                        ParamBNDs[GameDataManager.GameType] = BND3.Read($"{interroot}\\param\\GameParam\\GameParam.parambnd.dcx");
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.BB ||
                         GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.SDT)
                {
                    if (Directory.Exists($"{interroot}\\param\\GameParam\\") && File.Exists($"{interroot}\\param\\GameParam\\GameParam.parambnd.dcx"))
                    {
                        ParamBNDs[GameDataManager.GameType] = BND4.Read($"{interroot}\\param\\GameParam\\GameParam.parambnd.dcx");
                    }
                    else if (Directory.Exists($"{interroot}\\..\\param\\GameParam\\") && File.Exists($"{interroot}\\..\\param\\GameParam\\GameParam.parambnd.dcx"))
                    {
                        ParamBNDs[GameDataManager.GameType] = BND4.Read($"{interroot}\\..\\param\\GameParam\\GameParam.parambnd.dcx");
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.DS3)
                {
                    if (Directory.Exists($"{interroot}\\param\\GameParam\\") &&
                        File.Exists($"{interroot}\\param\\GameParam\\GameParam_dlc2.parambnd.dcx"))
                    {
                        ParamBNDs[GameDataManager.GameType] = BND4.Read($"{interroot}\\param\\GameParam\\GameParam_dlc2.parambnd.dcx");
                    }
                    else if (File.Exists($"{interroot}\\Data0.bdt"))
                    {
                        ParamBNDs[GameDataManager.GameType] = SFUtil.DecryptDS3Regulation($"{interroot}\\Data0.bdt");
                    }
                    else if (Directory.Exists($"{interroot}\\..\\param\\GameParam\\") &&
                             File.Exists($"{interroot}\\..\\param\\GameParam\\GameParam_dlc2.parambnd.dcx"))
                    {
                        ParamBNDs[GameDataManager.GameType] = BND4.Read($"{interroot}\\..\\param\\GameParam\\GameParam_dlc2.parambnd.dcx");
                    }
                    else if (File.Exists($"{interroot}\\..\\Data0.bdt"))
                    {
                        ParamBNDs[GameDataManager.GameType] = SFUtil.DecryptDS3Regulation($"{interroot}\\..\\Data0.bdt");
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.DS2SOTFS)
                {
                    if (File.Exists($"{interroot}\\enc_regulation.bnd.dcx"))
                    {
                        ParamBNDs[GameDataManager.GameType] = DarkSouls2.DS2GameParamUtil.DecryptDS2Regulation($"{interroot}\\enc_regulation.bnd.dcx");
                    }
                    else
                    {
                        return(false);
                    }
                    //System.Windows.Forms.MessageBox.Show("DS2 Params not supported yet.");
                    //LoadStuffFromParamBND(isClearAll: true);
                    //return true;
                }
                else
                {
                    throw new NotImplementedException();
                }

                justNowLoadedParamBND = true;
            }

            if (justNowLoadedParamBND || forceReload || GameTypeCurrentLoadedParamsAreFrom != GameDataManager.GameType)
            {
                LoadStuffFromParamBND(isDS2: GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.DS2SOTFS);
            }

            return(true);
        }
Ejemplo n.º 10
0
        private void btnDump_Click(object sender, EventArgs e)
        {
            BND4 bnd;

            try
            {
                bnd = SFUtil.DecryptDS3Regulation(txtRegulation.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Failed to load regulation:\r\n\r\n{txtRegulation.Text}\r\n\r\n{ex}");
                return;
            }

            var translations = new Dictionary <string, string>();
            var xml          = new XmlDocument();

            xml.Load("translations.xml");

            foreach (XmlNode text in xml.SelectNodes("translations/text"))
            {
                string jp = text.SelectSingleNode("jp").InnerText;
                string en = text.SelectSingleNode("en").InnerText;
                translations[WebUtility.HtmlDecode(jp)] = WebUtility.HtmlDecode(en);
            }

            var package = new ExcelPackage();

            foreach (BinderFile file in bnd.Files)
            {
                if (Path.GetExtension(file.Name) == ".param")
                {
                    PARAM64 param      = PARAM64.Read(file.Bytes);
                    string  layoutPath = $"Layouts\\{param.ID}.xml";

                    txtStatus.AppendText(file.Name + "\r\n");

                    var worksheet = package.Workbook.Worksheets.Add(Path.GetFileNameWithoutExtension(file.Name));

                    PARAM64.Layout layout;
                    if (File.Exists(layoutPath))
                    {
                        layout = PARAM64.Layout.ReadXMLFile(layoutPath);
                        if (layout.Size != param.DetectedSize)
                        {
                            layout = new PARAM64.Layout();
                            for (int i = 0; i < param.DetectedSize / 4; i++)
                            {
                                layout.Add(new PARAM64.Layout.Entry(CellType.u32, $"unk0x{i * 4:X4}", (uint)0));
                            }
                            for (int i = 0; i < param.DetectedSize % 4; i++)
                            {
                                layout.Add(new PARAM64.Layout.Entry(CellType.u8, "unkb" + i, (byte)0));
                            }
                        }
                    }
                    else
                    {
                        layout = new PARAM64.Layout();
                    }

                    param.SetLayout(layout);
                    List <PARAM64.Row> rows = param.Rows;

                    worksheet.Cells[1, 1].Value = "ID";
                    worksheet.Cells[1, 2].Value = "Name";
                    worksheet.Cells[1, 3].Value = "Translated";
                    int columnCount = 3;
                    foreach (PARAM64.Layout.Entry lv in layout)
                    {
                        if (lv.Type != CellType.dummy8)
                        {
                            worksheet.Cells[1, ++columnCount].Value = lv.Name;
                        }
                    }

                    for (int i = 0; i < rows.Count; i++)
                    {
                        PARAM64.Row row = rows[i];
                        worksheet.Cells[i + 2, 1].Value = row.ID;
                        if (row.Name != null)
                        {
                            if (translations.ContainsKey(row.Name))
                            {
                                worksheet.Cells[i + 2, 2].Value = row.Name;
                                worksheet.Cells[i + 2, 3].Value = translations[row.Name];
                            }
                            else if (row.Name.Contains(" -- "))
                            {
                                worksheet.Cells[i + 2, 2].Value = row.Name.Substring(row.Name.IndexOf(" -- ") + 4);
                                worksheet.Cells[i + 2, 3].Value = row.Name.Substring(0, row.Name.IndexOf(" -- "));
                            }
                        }
                        else
                        {
                            worksheet.Cells[i + 2, 2].Value = row.Name;
                        }
                        columnCount = 3;

                        foreach (PARAM64.Cell cell in row.Cells)
                        {
                            CellType type = cell.Type;
                            if (type != CellType.dummy8)
                            {
                                var range = worksheet.Cells[i + 2, ++columnCount];
                                if (type == CellType.f32)
                                {
                                    range.Value = (double)(float)cell.Value;
                                }
                                else if (type == CellType.b8 || type == CellType.b32)
                                {
                                    bool b = (bool)cell.Value;
                                    range.Value = b.ToString();
                                    range.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
                                    range.Style.Fill.BackgroundColor.SetColor(b ? Color.LightGreen : Color.LightPink);
                                }
                                else if (type == CellType.x8)
                                {
                                    range.Value = $"0x{cell.Value:X2}";
                                    range.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Right;
                                }
                                else if (type == CellType.x16)
                                {
                                    range.Value = $"0x{cell.Value:X4}";
                                    range.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Right;
                                }
                                else if (type == CellType.x32)
                                {
                                    range.Value = $"0x{cell.Value:X8}";
                                    range.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Right;
                                }
                                else
                                {
                                    range.Value = cell.Value;
                                }
                            }
                        }
                    }

                    worksheet.Row(1).Style.Font.Bold    = true;
                    worksheet.Column(1).Style.Font.Bold = true;
                    worksheet.View.FreezePanes(2, 4);
                    worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
                }
            }

            FileInfo f = new FileInfo(Path.Combine(txtOutput.Text, "dump.xlsx"));

            package.SaveAs(f);
        }
Ejemplo n.º 11
0
        public static LoadParamsResult LoadParams(string paramPath, Dictionary <string, ParamInfo> paramInfo,
                                                  Dictionary <string, PARAM.Layout> layouts, Dictionary <BinderFile, ParamWrapper> fileWrapperCache, GameMode gameMode, bool hideUnusedParams)
        {
            if (!File.Exists(paramPath))
            {
                ShowError($"Parambnd类型文件 {paramPath} 不存在!\r\n请选定要给要编辑的Data0.bdt文件或Parambnd类型文件。");
                return(null);
            }

            var result = new LoadParamsResult();

            try
            {
                if (BND4.Is(paramPath))
                {
                    result.ParamBND  = BND4.Read(paramPath);
                    result.Encrypted = false;
                }
                else if (BND3.Is(paramPath))
                {
                    result.ParamBND  = BND3.Read(paramPath);
                    result.Encrypted = false;
                }
                else if (gameMode.Game == GameMode.GameType.DarkSouls2)
                {
                    result.ParamBND  = DecryptDS2Regulation(paramPath);
                    result.Encrypted = true;
                }
                else if (gameMode.Game == GameMode.GameType.DarkSouls3)
                {
                    result.ParamBND  = SFUtil.DecryptDS3Regulation(paramPath);
                    result.Encrypted = true;
                }
                else
                {
                    throw new FormatException("无法识别文件的数据格式!");
                }
            }
            catch (DllNotFoundException ex) when(ex.Message.Contains("oo2core_6_win64.dll"))
            {
                ShowError("为了加载Sekiro参数,必须将文件oo2core_6_win64.dll从Sekiro复制到文件DSParamEditor.exe的同一目录中。");
                return(null);
            }
            catch (Exception ex)
            {
                ShowError($"加载Parambnd类型文件失败!\r\n{paramPath}\r\n\r\n{ex}");
                return(null);
            }

            fileWrapperCache.Clear();
            result.ParamWrappers = new List <ParamWrapper>();
            foreach (var file in result.ParamBND.Files.Where(f => f.Name.EndsWith(".param")))
            {
                var name = Path.GetFileNameWithoutExtension(file.Name);
                if (paramInfo.ContainsKey(name))
                {
                    if (paramInfo[name].Blocked || paramInfo[name].Hidden && hideUnusedParams)
                    {
                        continue;
                    }
                }

                try
                {
                    var          param  = PARAM.Read(file.Bytes);
                    PARAM.Layout layout = null;
                    if (layouts.ContainsKey(param.ParamType))
                    {
                        layout = layouts[param.ParamType];
                    }

                    string description = null;
                    if (paramInfo.ContainsKey(name))
                    {
                        description = paramInfo[name].Description;
                    }

                    var wrapper = new ParamWrapper(name, param, layout, description);
                    result.ParamWrappers.Add(wrapper);
                    fileWrapperCache[file] = wrapper;
                }
                catch (Exception ex)
                {
                    ShowError($"加载参数文件:{name}.param失败!\r\n\r\n{ex}");
                }
            }

            result.ParamWrappers.Sort();
            return(result);
        }