diff --git a/PqSave/FodyWeavers.xml b/PqSave/FodyWeavers.xml
index c6e1b7c..722f171 100644
--- a/PqSave/FodyWeavers.xml
+++ b/PqSave/FodyWeavers.xml
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file
diff --git a/PqSave/Json.cs b/PqSave/Json.cs
new file mode 100644
index 0000000..7395144
--- /dev/null
+++ b/PqSave/Json.cs
@@ -0,0 +1,109 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Newtonsoft.Json;
+using ZeroFormatter;
+
+namespace PqSave
+{
+ public static class Json
+ {
+ private static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
+ {
+ NullValueHandling = NullValueHandling.Ignore,
+ Converters = new List
+ {
+ new LazyDictionaryConverter1(),
+ new LazyDictionaryConverter2(),
+ new LazyDictionaryConverter3(),
+ new LazyDictionaryConverter4()
+ }
+ };
+
+ public static string Serialize(SaveManager save)
+ {
+ return JsonConvert.SerializeObject(save, Formatting.Indented, Settings);
+ }
+
+ public static SaveManager DeSerialize(string save)
+ {
+ return JsonConvert.DeserializeObject(save, Settings);
+ }
+ }
+
+ public class LazyDictionaryConverter1 : JsonConverter
+ {
+ public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ {
+ var dict = ((ILazyDictionary)value).ToDictionary(x => x.Key, x => x.Value);
+ serializer.Serialize(writer, dict);
+ }
+
+ public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+ {
+ return serializer.Deserialize>(reader).AsLazyDictionary();
+ }
+
+ public override bool CanConvert(Type objectType)
+ {
+ return objectType == typeof(ILazyDictionary);
+ }
+ }
+
+ public class LazyDictionaryConverter2 : JsonConverter
+ {
+ public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ {
+ var dict = ((ILazyDictionary)value).ToDictionary(x => x.Key, x => x.Value);
+ serializer.Serialize(writer, dict);
+ }
+
+ public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+ {
+ return serializer.Deserialize>(reader).AsLazyDictionary();
+ }
+
+ public override bool CanConvert(Type objectType)
+ {
+ return objectType == typeof(ILazyDictionary);
+ }
+ }
+
+ public class LazyDictionaryConverter3 : JsonConverter
+ {
+ public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ {
+ var dict = ((ILazyDictionary)value).ToDictionary(x => x.Key, x => x.Value);
+ serializer.Serialize(writer, dict);
+ }
+
+ public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+ {
+ return serializer.Deserialize>(reader).AsLazyDictionary();
+ }
+
+ public override bool CanConvert(Type objectType)
+ {
+ return objectType == typeof(ILazyDictionary);
+ }
+ }
+
+ public class LazyDictionaryConverter4 : JsonConverter
+ {
+ public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ {
+ var dict = ((ILazyDictionary)value).ToDictionary(x => x.Key, x => x.Value);
+ serializer.Serialize(writer, dict);
+ }
+
+ public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+ {
+ return serializer.Deserialize>(reader).AsLazyDictionary();
+ }
+
+ public override bool CanConvert(Type objectType)
+ {
+ return objectType == typeof(ILazyDictionary);
+ }
+ }
+}
diff --git a/PqSave/PqSave.csproj b/PqSave/PqSave.csproj
index 33c96e2..06497f9 100644
--- a/PqSave/PqSave.csproj
+++ b/PqSave/PqSave.csproj
@@ -7,6 +7,7 @@
+
diff --git a/PqSave/Program.cs b/PqSave/Program.cs
index 22fd0fb..d97bb75 100644
--- a/PqSave/Program.cs
+++ b/PqSave/Program.cs
@@ -36,6 +36,16 @@ private static void Run(string[] args)
var decSave = File.ReadAllBytes(args[1]);
File.WriteAllBytes(args[2], Encryption.EncryptSave(decSave));
break;
+ case "x":
+ var savex = new SaveManager(File.ReadAllBytes(args[1]));
+ var output = Json.Serialize(savex);
+ File.WriteAllText(args[2], output);
+ break;
+ case "i":
+ string import = File.ReadAllText(args[1]);
+ SaveManager savei = Json.DeSerialize(import);
+ File.WriteAllBytes(args[2], savei.Export());
+ break;
case "s":
var save = new SaveManager(File.ReadAllBytes(args[1]));
@@ -54,10 +64,12 @@ private static void Run(string[] args)
private static void PrintUsage()
{
- Console.WriteLine("Usage: pqsave mode input output [script1] [script2]...");
+ Console.WriteLine("Usage: pqsave mode input output [script1 (In script mode only)] [script2]...");
Console.WriteLine(" modes:");
- Console.WriteLine(" d Decrypt");
- Console.WriteLine(" e Encrypt");
+ Console.WriteLine(" d Decrypt save");
+ Console.WriteLine(" e Encrypt save");
+ Console.WriteLine(" x Export save to JSON");
+ Console.WriteLine(" i Import save from JSON");
Console.WriteLine(" s Script - Run scripts on an encrypted save");
}
}
diff --git a/PqSave/SaveManager.cs b/PqSave/SaveManager.cs
index dc8bacc..0df9eed 100644
--- a/PqSave/SaveManager.cs
+++ b/PqSave/SaveManager.cs
@@ -16,6 +16,8 @@ public SaveManager(byte[] saveEnc)
SerializeData = ZeroFormatterSerializer.Deserialize(saveDec, 56);
}
+ public SaveManager() { }
+
public byte[] Export()
{
var head = ZeroFormatterSerializer.Serialize(CheckData);
diff --git a/PqSave/Scripts/export_to_json.bat b/PqSave/Scripts/export_to_json.bat
new file mode 100644
index 0000000..52bbd31
--- /dev/null
+++ b/PqSave/Scripts/export_to_json.bat
@@ -0,0 +1,2 @@
+PqSave.exe x user user.json
+pause
\ No newline at end of file
diff --git a/PqSave/Scripts/import_from_json.bat b/PqSave/Scripts/import_from_json.bat
new file mode 100644
index 0000000..535f9c5
--- /dev/null
+++ b/PqSave/Scripts/import_from_json.bat
@@ -0,0 +1,2 @@
+PqSave.exe i user.json user_new
+pause
\ No newline at end of file
diff --git a/README.md b/README.md
index ad0d624..347603c 100644
--- a/README.md
+++ b/README.md
@@ -6,10 +6,12 @@ Pokémon Quest's title ID is `01005D100807A000`, and the save file is a single 5
### Usage
````
-Usage: pqsave mode input output [script1] [script2]...
+Usage: pqsave mode input output [script1 (In script mode only)] [script2]...
modes:
- d Decrypt
- e Encrypt
+ d Decrypt save
+ e Encrypt save
+ x Export save to JSON
+ i Import save from JSON
s Script - Run scripts on an encrypted save
````