Skip to content

Commit c86c23b

Browse files
committed
Added helper functions for appearance hashes.
1 parent 0a09171 commit c86c23b

4 files changed

Lines changed: 42 additions & 0 deletions

File tree

CP2077SaveEditor/Properties/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CP2077SaveEditor/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,7 @@
151151
<data name="ItemNames" type="System.Resources.ResXFileRef, System.Windows.Forms">
152152
<value>..\Resources\ItemNames.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
153153
</data>
154+
<data name="AppearancePaths" type="System.Resources.ResXFileRef, System.Windows.Forms">
155+
<value>..\Resources\AppearancePaths.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
156+
</data>
154157
</root>

CP2077SaveEditor/Resources/AppearancePaths.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

CP2077SaveEditor/Utils/TypeExtensions.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
using System.Windows.Forms;
1111
using CyberCAT.Core.Classes;
1212
using CyberCAT.Core.Classes.Interfaces;
13+
using CyberCAT.Core.Classes.NodeRepresentations;
14+
using CyberCAT.Extra.Utils;
15+
using Newtonsoft.Json;
1316

1417
namespace CP2077SaveEditor.Extensions
1518
{
@@ -188,4 +191,30 @@ public static void SetValue(this NumericUpDown numericUpDown, decimal value)
188191
numericUpDown.Value = value;
189192
}
190193
}
194+
195+
public static class HashValueEntryExtensions
196+
{
197+
private static Dictionary<ulong, string> pathHashes;
198+
199+
static HashValueEntryExtensions()
200+
{
201+
pathHashes = new Dictionary<ulong, string>();
202+
var names = JsonConvert.DeserializeObject<string[]>(CP2077SaveEditor.Properties.Resources.AppearancePaths);
203+
204+
for(int i = 0; i < names.Length; i++)
205+
{
206+
pathHashes.Add(HashGenerator.CalcFNV1A64(names[i]), names[i]);
207+
}
208+
}
209+
210+
public static string GetPath(this CharacterCustomizationAppearances.HashValueEntry entry)
211+
{
212+
return pathHashes.ContainsKey(entry.Hash) ? pathHashes[entry.Hash] : string.Empty;
213+
}
214+
215+
public static void SetPath(this CharacterCustomizationAppearances.HashValueEntry entry, string value)
216+
{
217+
entry.Hash = HashGenerator.CalcFNV1A64(value);
218+
}
219+
}
191220
}

0 commit comments

Comments
 (0)