From 39477460f2405bbe809ca19dee2562ffe1f9e7d2 Mon Sep 17 00:00:00 2001 From: kingborehaha <55667610+kingborehaha@users.noreply.github.com> Date: Sat, 13 Jan 2024 18:17:59 -0800 Subject: [PATCH 1/2] Support editing ER SystemParam --- .../ER/Defs/Gconfig_RaytracingQuality.xml | 20 ++++ src/StudioCore/ParamEditor/ParamBank.cs | 95 +++++++++++++------ 2 files changed, 86 insertions(+), 29 deletions(-) create mode 100644 src/StudioCore/Assets/Paramdex/ER/Defs/Gconfig_RaytracingQuality.xml diff --git a/src/StudioCore/Assets/Paramdex/ER/Defs/Gconfig_RaytracingQuality.xml b/src/StudioCore/Assets/Paramdex/ER/Defs/Gconfig_RaytracingQuality.xml new file mode 100644 index 000000000..b17cda480 --- /dev/null +++ b/src/StudioCore/Assets/Paramdex/ER/Defs/Gconfig_RaytracingQuality.xml @@ -0,0 +1,20 @@ + + + CS_RAYTRACING_QUALITY_DETAIL + 1 + False + True + 203 + + + + + + + + + + + + + diff --git a/src/StudioCore/ParamEditor/ParamBank.cs b/src/StudioCore/ParamEditor/ParamBank.cs index 4ab1b8956..cd1ff8c49 100644 --- a/src/StudioCore/ParamEditor/ParamBank.cs +++ b/src/StudioCore/ParamEditor/ParamBank.cs @@ -905,16 +905,41 @@ private void LoadParamsER(bool partial) } } } + + string sysParam = AssetLocator.GetAssetPath(@"param\systemparam\systemparam.parambnd.dcx"); + if (File.Exists(sysParam)) + { + LoadParamsERFromFile(sysParam, false); + } + else + { + TaskLogs.AddLog("Systemparam could not be found. These require an unpacked game to modify.", LogLevel.Information, TaskLogs.LogPriority.Normal); + } } private void LoadVParamsER() { LoadParamsERFromFile($@"{AssetLocator.GameRootDirectory}\regulation.bin"); + + var sysParam = $@"{AssetLocator.GameRootDirectory}\param\systemparam\systemparam.parambnd.dcx"; + if (File.Exists(sysParam)) + { + LoadParamsERFromFile(sysParam, false); + } } - private void LoadParamsERFromFile(string path) + private void LoadParamsERFromFile(string path, bool encrypted = true) { - LoadParamFromBinder(SFUtil.DecryptERRegulation(path), ref _params, out _paramVersion, true); + if (encrypted) + { + using BND4 bnd = SFUtil.DecryptERRegulation(path); + LoadParamFromBinder(bnd, ref _params, out _paramVersion, true); + } + else + { + using BND4 bnd = BND4.Read(path); + LoadParamFromBinder(bnd, ref _params, out _, false); + } } private void LoadParamsAC6() @@ -1755,6 +1780,37 @@ private void SaveParamsDES() private void SaveParamsER(bool partial) { + void OverwriteParamsER(BND4 paramBnd) + { + // Replace params with edited ones + foreach (BinderFile p in paramBnd.Files) + { + if (_params.ContainsKey(Path.GetFileNameWithoutExtension(p.Name))) + { + Param paramFile = _params[Path.GetFileNameWithoutExtension(p.Name)]; + IReadOnlyList backup = paramFile.Rows; + List changed = new(); + if (partial) + { + TaskManager.WaitAll(); //wait on dirtycache update + HashSet dirtyCache = _vanillaDiffCache[Path.GetFileNameWithoutExtension(p.Name)]; + foreach (Param.Row row in paramFile.Rows) + { + if (dirtyCache.Contains(row.ID)) + { + changed.Add(row); + } + } + + paramFile.Rows = changed; + } + + p.Bytes = paramFile.Write(); + paramFile.Rows = backup; + } + } + } + var dir = AssetLocator.GameRootDirectory; var mod = AssetLocator.GameModDirectory; if (!File.Exists($@"{dir}\\regulation.bin")) @@ -1771,37 +1827,18 @@ private void SaveParamsER(bool partial) param = $@"{dir}\regulation.bin"; } - BND4 paramBnd = SFUtil.DecryptERRegulation(param); + BND4 regParams = SFUtil.DecryptERRegulation(param); + OverwriteParamsER(regParams); + Utils.WriteWithBackup(dir, mod, @"regulation.bin", regParams, GameType.EldenRing); - // Replace params with edited ones - foreach (BinderFile p in paramBnd.Files) + string sysParam = AssetLocator.GetAssetPath(@"param\systemparam\systemparam.parambnd.dcx"); + if (File.Exists(sysParam)) { - if (_params.ContainsKey(Path.GetFileNameWithoutExtension(p.Name))) - { - Param paramFile = _params[Path.GetFileNameWithoutExtension(p.Name)]; - IReadOnlyList backup = paramFile.Rows; - List changed = new(); - if (partial) - { - TaskManager.WaitAll(); //wait on dirtycache update - HashSet dirtyCache = _vanillaDiffCache[Path.GetFileNameWithoutExtension(p.Name)]; - foreach (Param.Row row in paramFile.Rows) - { - if (dirtyCache.Contains(row.ID)) - { - changed.Add(row); - } - } - - paramFile.Rows = changed; - } - - p.Bytes = paramFile.Write(); - paramFile.Rows = backup; - } + using BND4 sysParams = BND4.Read(sysParam); + OverwriteParamsER(sysParams); + Utils.WriteWithBackup(dir, mod, @"param\systemparam\systemparam.parambnd.dcx", sysParams); } - Utils.WriteWithBackup(dir, mod, @"regulation.bin", paramBnd, GameType.EldenRing); _pendingUpgrade = false; } From 40075647fc7a9fcde1f4337bfaf0a8098b1af92b Mon Sep 17 00:00:00 2001 From: kingborehaha <55667610+kingborehaha@users.noreply.github.com> Date: Sun, 14 Jan 2024 17:40:16 -0800 Subject: [PATCH 2/2] ER raytracing paramdefs --- .../Paramdex/ER/Defs/Gconfig_RaytracingQuality.xml | 4 ++-- .../Paramdex/ER/Meta/Gconfig_RaytracingQuality.xml | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/StudioCore/Assets/Paramdex/ER/Meta/Gconfig_RaytracingQuality.xml diff --git a/src/StudioCore/Assets/Paramdex/ER/Defs/Gconfig_RaytracingQuality.xml b/src/StudioCore/Assets/Paramdex/ER/Defs/Gconfig_RaytracingQuality.xml index b17cda480..fcee38393 100644 --- a/src/StudioCore/Assets/Paramdex/ER/Defs/Gconfig_RaytracingQuality.xml +++ b/src/StudioCore/Assets/Paramdex/ER/Defs/Gconfig_RaytracingQuality.xml @@ -6,8 +6,8 @@ True 203 - - + + diff --git a/src/StudioCore/Assets/Paramdex/ER/Meta/Gconfig_RaytracingQuality.xml b/src/StudioCore/Assets/Paramdex/ER/Meta/Gconfig_RaytracingQuality.xml new file mode 100644 index 000000000..8efe7bac8 --- /dev/null +++ b/src/StudioCore/Assets/Paramdex/ER/Meta/Gconfig_RaytracingQuality.xml @@ -0,0 +1,10 @@ + + + + + + + + + +