diff --git a/Assets/Resources/Prefabs/ScrollParameterDisplay.prefab b/Assets/Resources/Prefabs/ScrollParameterDisplay.prefab index c4e9b99d6342b8a9875878a254df23dbfb34de2d..d015bbc16962c7dd51cf9a03071caa0806f2bebc 100644 --- a/Assets/Resources/Prefabs/ScrollParameterDisplay.prefab +++ b/Assets/Resources/Prefabs/ScrollParameterDisplay.prefab @@ -93,7 +93,7 @@ MonoBehaviour: m_enableVertexGradient: 1 m_colorMode: 3 m_fontColorGradient: - topLeft: {r: 1, g: 1, b: 1, a: 1} + topLeft: {r: 0, g: 0, b: 0, a: 1} topRight: {r: 1, g: 1, b: 1, a: 1} bottomLeft: {r: 1, g: 1, b: 1, a: 1} bottomRight: {r: 1, g: 1, b: 1, a: 1} diff --git a/Assets/Scripts/InteractionEngine/CommunicationEvents.cs b/Assets/Scripts/InteractionEngine/CommunicationEvents.cs index 75fd97d208d6c44f2c50673c3b88af982caea26b..33c2ce9808febfe47613c65dc907b04fa44c574c 100644 --- a/Assets/Scripts/InteractionEngine/CommunicationEvents.cs +++ b/Assets/Scripts/InteractionEngine/CommunicationEvents.cs @@ -6,21 +6,6 @@ public static class CommunicationEvents { - /* public class PointEvent : UnityEvent<RaycastHit,int> - { - - } - - public class LineEvent : UnityEvent<int, int, int> { - - } - - - - public class FactEvent : UnityEvent<int> - { - - }*/ public class HitEvent : UnityEvent<RaycastHit> { @@ -56,11 +41,6 @@ public class AnimationEvent : UnityEvent<String> { public static HitEvent TriggerEvent = new HitEvent(); public static ToolModeEvent ToolModeChangedEvent = new ToolModeEvent(); - /* - public static FactEvent AddPointEvent = new FactEvent(); - public static FactEvent AddLineEvent = new FactEvent(); - public static FactEvent AddAngleEvent = new FactEvent(); - */ public static FactEvent AddFactEvent = new FactEvent(); public static FactEvent RemoveFactEvent = new FactEvent(); @@ -72,6 +52,7 @@ public class AnimationEvent : UnityEvent<String> { public static SignalEvent gameNotSucceededEvent = new SignalEvent(); public static AnimationEvent parameterDisplayHint = new AnimationEvent(); + public static SignalEvent newAssignmentEvent = new SignalEvent(); //------------------------------------------------------------------------------------ diff --git a/Assets/Scripts/InventoryStuff/DropHandling.cs b/Assets/Scripts/InventoryStuff/DropHandling.cs index 1999d73ec0c5fff146361374ebf21cb26c1edc8f..5b84e90a85e3bb05cb2c403dbc0e9c973ce92e23 100644 --- a/Assets/Scripts/InventoryStuff/DropHandling.cs +++ b/Assets/Scripts/InventoryStuff/DropHandling.cs @@ -25,6 +25,8 @@ public void OnDrop(PointerEventData eventData){ currentFact = eventData.pointerDrag.GetComponent<FactWrapper>().fact; Debug.Log("recieved Fact: " + currentFact.backendURI); + + CommunicationEvents.newAssignmentEvent.Invoke(); } } diff --git a/Assets/Scripts/InventoryStuff/RenderedScrollFact.cs b/Assets/Scripts/InventoryStuff/RenderedScrollFact.cs index 016386a0aff9b17b7b3940bdaafc7595d4e31754..fe69d301be5bb8811a2ae4addf9fd51782d388a0 100644 --- a/Assets/Scripts/InventoryStuff/RenderedScrollFact.cs +++ b/Assets/Scripts/InventoryStuff/RenderedScrollFact.cs @@ -9,6 +9,7 @@ public class RenderedScrollFact : MonoBehaviour public int ID; public TextMeshProUGUI LabelMesh; private string _label; + public string factUri; public string Label { diff --git a/Assets/Scripts/InventoryStuff/Scroll.cs b/Assets/Scripts/InventoryStuff/Scroll.cs index c2467df9b901e75e3fa3f11a599362ed671b9ec0..98c4bfbbcff2b84bd955142df5e73b7a5bc84708 100644 --- a/Assets/Scripts/InventoryStuff/Scroll.cs +++ b/Assets/Scripts/InventoryStuff/Scroll.cs @@ -98,7 +98,8 @@ public class ScrollDynamicInfo { public Scroll original; public Scroll rendered; - //public List<List<ScrollAssignmentsToBeImplemented>> completions + //Todo: Adjust due to new Server-Format + public List<List<System.Object>> completions; public Boolean valid; public ScrollApplicationCheckingError[] errors; } diff --git a/Assets/Scripts/InventoryStuff/ScrollDetails.cs b/Assets/Scripts/InventoryStuff/ScrollDetails.cs index e528d375477c810e3dca35353ade450da27ae2aa..6070b1ca9b607a893bc09a6c45a540b8c2fade14 100644 --- a/Assets/Scripts/InventoryStuff/ScrollDetails.cs +++ b/Assets/Scripts/InventoryStuff/ScrollDetails.cs @@ -27,7 +27,7 @@ void Start() if (cursor == null) cursor = GameObject.FindObjectOfType<WorldCursor>(); CommunicationEvents.parameterDisplayHint.AddListener(animateScrollParameter); - + CommunicationEvents.newAssignmentEvent.AddListener(newAssignment); } public void setScroll(Scroll s) @@ -57,9 +57,12 @@ public void setScroll(Scroll s) var originalScrollFact = originalObj.transform.GetChild(0).GetComponent<RenderedScrollFact>(); originalScrollFact.ID = i; originalScrollFact.Label = s.requiredFacts[i].label; + originalScrollFact.factUri = s.requiredFacts[i].@ref.uri; //Copy original Object for use in redered Scroll var renderedObj = Instantiate(originalObj); - + //Set Text Color to red + renderedObj.transform.GetChild(1).GetComponent<TextMeshProUGUI>().color = new Color32(255,0,0,255); + originalObj.transform.SetParent(originalViewport.GetChild(0)); renderedObj.transform.SetParent(renderedViewport.GetChild(0)); @@ -71,7 +74,18 @@ public void setScroll(Scroll s) ParameterDisplays.Add(originalObj); } + } + public void updateRenderedScroll(Scroll rendered) + { + Transform renderedScroll = gameObject.transform.GetChild(2).transform; + + renderedScroll.GetChild(0).GetComponent<TextMeshProUGUI>().text = rendered.description; + for (int i = 0; i < rendered.requiredFacts.Count; i++) { + var obj = ParameterDisplays.Find(x => x.transform.GetChild(0).GetComponent<RenderedScrollFact>().factUri.Equals(rendered.requiredFacts[i].@ref.uri)); + obj.transform.GetChild(0).GetComponent<DropHandling>().associatedDropHandling.transform.parent + .GetChild(0).GetComponent<RenderedScrollFact>().Label = rendered.requiredFacts[i].label; + } } public void animateScrollParameter(string label) @@ -85,22 +99,37 @@ public void animateScrollParameter(string label) public void magicButton() { - List<Scroll.ScrollFact> pushoutFacts = sendView(); - if (pushoutFacts == null) + string answer = sendView("/scroll/apply"); + + if (answer == null) { Debug.Log("DAS HAT NICHT GEKLAPPT"); //TODO: hier ne Art PopUp, wo drin steht, dass das nicht geklappt hat CommunicationEvents.PushoutFactFailEvent.Invoke(null); return; } + List<Scroll.ScrollFact> pushoutFacts = JsonConvert.DeserializeObject<List<Scroll.ScrollFact>>(answer); readPushout(pushoutFacts); } - private List<Scroll.ScrollFact> sendView() + public void newAssignment() + { + string answer = sendView("/scroll/dynamic"); + + if (answer == null) + { + Debug.Log("DAS HAT NICHT GEKLAPPT"); + return; + } + Scroll.ScrollDynamicInfo scrollDynamicInfo = JsonConvert.DeserializeObject<Scroll.ScrollDynamicInfo>(answer); + updateRenderedScroll(scrollDynamicInfo.rendered); + } + + private string sendView(string endpoint) { string body = prepareScrollAssignments(); - UnityWebRequest www = UnityWebRequest.Put(CommunicationEvents.ServerAdress+"/scroll/apply", body); + UnityWebRequest www = UnityWebRequest.Put(CommunicationEvents.ServerAdress + endpoint, body); www.method = UnityWebRequest.kHttpVerbPOST; www.SetRequestHeader("Content-Type", "application/json"); var async = www.Send(); @@ -115,7 +144,7 @@ public void magicButton() { string answer = www.downloadHandler.text; Debug.Log(answer); - return JsonConvert.DeserializeObject<List<Scroll.ScrollFact>>(answer); + return answer; } } @@ -140,19 +169,15 @@ private string prepareScrollAssignments() for (int i = 0; i < ParameterDisplays.Count; i++) { + //Todo: Adjust due to new Server-Format List<System.Object> listEntry = new List<System.Object>(); tempFact = ParameterDisplays[i].GetComponentInChildren<DropHandling>().currentFact; if (tempFact != null) { listEntry.Add(new JSONManager.URI(this.scroll.requiredFacts[i].@ref.uri)); listEntry.Add(new JSONManager.OMS(tempFact.backendURI)); + assignmentList.Add(listEntry); } - else - { - listEntry.Add(new JSONManager.URI(this.scroll.requiredFacts[i].@ref.uri)); - listEntry.Add(null); - } - assignmentList.Add(listEntry); } Scroll.FilledScroll filledScroll = new Scroll.FilledScroll(this.scroll.@ref, assignmentList);