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); }
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); }