-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fix AppearanceHelper.
- Loading branch information
Showing
4 changed files
with
62 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Numerics; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using WolvenKit.RED4.Types; | ||
|
||
namespace CP2077SaveEditor.Utils | ||
{ | ||
public static class JsonConverters | ||
{ | ||
public class AppearanceResourceConverter : JsonConverter<CResourceReference<appearanceAppearanceResource>> | ||
{ | ||
public override void WriteJson(JsonWriter writer, CResourceReference<appearanceAppearanceResource> value, JsonSerializer serializer) | ||
{ | ||
writer.WriteValue((ulong)value.DepotPath); | ||
} | ||
|
||
public override CResourceReference<appearanceAppearanceResource> ReadJson(JsonReader reader, Type objectType, CResourceReference<appearanceAppearanceResource> existingValue, bool hasExistingValue, JsonSerializer serializer) | ||
{ | ||
object value = reader.Value; | ||
ulong final; | ||
|
||
if (value is BigInteger bigVal) | ||
{ | ||
final = (ulong)bigVal; | ||
} | ||
else | ||
{ | ||
final = Convert.ToUInt64(value); | ||
} | ||
|
||
return new CResourceReference<appearanceAppearanceResource>() { DepotPath = final }; | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters