diff --git a/Assets/Scripts/InventoryStuff/DisplayScrolls.cs b/Assets/Scripts/InventoryStuff/DisplayScrolls.cs index 4a79a1b2fc21c77e10cf2d48fed531cb4c18287c..59deba49b23381718f1c8d17eba1b451d6eab7aa 100644 --- a/Assets/Scripts/InventoryStuff/DisplayScrolls.cs +++ b/Assets/Scripts/InventoryStuff/DisplayScrolls.cs @@ -57,6 +57,8 @@ void Start() IEnumerator getScrollsfromServer() { UnityWebRequest request = UnityWebRequest.Get(CommunicationEvents.ServerAdress + "/scroll/list"); + //Postman-Echo-Mock + //UnityWebRequest request = UnityWebRequest.Get("https://019a8ea5-843a-498b-8d0c-778669aef987.mock.pstmn.io/get"); request.method = UnityWebRequest.kHttpVerbGET; yield return request.Send(); if (request.isNetworkError || request.isHttpError) diff --git a/Assets/Scripts/InventoryStuff/Scroll.cs b/Assets/Scripts/InventoryStuff/Scroll.cs index cbbad972e3290fd91ad8277bd16f9d40ac7af422..c1e183d42fb0cb1cacdad3eae8631f21ffcb5f5a 100644 --- a/Assets/Scripts/InventoryStuff/Scroll.cs +++ b/Assets/Scripts/InventoryStuff/Scroll.cs @@ -3,6 +3,8 @@ using System.Linq; using System; using UnityEngine; +using static JSONManager; +using Newtonsoft.Json; /* @@ -44,12 +46,18 @@ public class Scroll : LightScroll public static List<Scroll> FromJSON(string json) { - List<Scroll> scrolls = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Scroll>>(json); + List<Scroll> scrolls = JsonConvert.DeserializeObject<List<Scroll>>(json, new JsonSerializerSettings + { + TypeNameHandling = TypeNameHandling.Auto + }); return scrolls; } public static string ToJSON(FilledScroll scroll) { - string json = Newtonsoft.Json.JsonConvert.SerializeObject(scroll); + string json = Newtonsoft.Json.JsonConvert.SerializeObject(scroll, new JsonSerializerSettings + { + TypeNameHandling = TypeNameHandling.Auto + }); return json; } @@ -129,15 +137,28 @@ public FilledScroll(LightScroll scroll, List<ScrollAssignment> assignments) public class ScrollFact { public string uri; + public string kind; public string label; - public FactBody tp; - public JSONManager.MMTTerm df; } - public class FactBody + /** + * Class used for deserializing incoming symbol-declarations from mmt + */ + public class ScrollSymbolFact : ScrollFact + { + public MMTTerm tp; + public MMTTerm df; + } + + /** + * Class used for deserializing incoming value-declarations from mmt + */ + public class ScrollValueFact : ScrollFact { - public JSONManager.MMTTerm original; - public JSONManager.MMTTerm simplified; + MMTTerm lhs; + MMTTerm valueTp; + MMTTerm value; + MMTTerm proof; } } diff --git a/Assets/Scripts/JSONManager.cs b/Assets/Scripts/JSONManager.cs index eda92fa64f7eb3812e7be935f52088c3ee5e672d..1cae7a2ba527aeb2fa3c0aba03af4ba53802cd0a 100644 --- a/Assets/Scripts/JSONManager.cs +++ b/Assets/Scripts/JSONManager.cs @@ -94,7 +94,7 @@ public static string ToJson(MMTDeclaration mmtDecl) /** * MMTSymbolDeclaration: Class for facts without values, e.g. Points - **/ + */ public class MMTSymbolDeclaration : MMTDeclaration { public string kind = "general"; @@ -102,6 +102,9 @@ public class MMTSymbolDeclaration : MMTDeclaration public MMTTerm tp; public MMTTerm df; + /** + * Constructor used for sending new declarations to mmt + */ public MMTSymbolDeclaration(string label, MMTTerm tp, MMTTerm df) { this.label = label; @@ -112,7 +115,7 @@ public MMTSymbolDeclaration(string label, MMTTerm tp, MMTTerm df) /** * MMTValueDeclaration: Class for facts with values, e.g. Distances or Angles - **/ + */ public class MMTValueDeclaration : MMTDeclaration { public string kind = "veq"; @@ -121,6 +124,9 @@ public class MMTValueDeclaration : MMTDeclaration public MMTTerm valueTp; public MMTTerm value; + /** + * Constructor used for sending new declarations to mmt + */ public MMTValueDeclaration(string label, MMTTerm lhs, MMTTerm valueTp, MMTTerm value) { this.label = label;