diff --git a/.gitignore b/.gitignore index 49aab4c22e69fe2631c99aa4daa400042dd54ddb..0c70a87915f27b4be5a57b887cad14238e75e77b 100644 --- a/.gitignore +++ b/.gitignore @@ -66,3 +66,5 @@ crashlytics-build.properties # Ignore UserSettings UserSettings/ +/Assets/Images/frameit_logo_512x512.png.meta +/Assets/Images/ScreenCapture_1024x500.png.meta diff --git a/Assets/Scripts/InventoryStuff/ScrollDetails.cs b/Assets/Scripts/InventoryStuff/ScrollDetails.cs index 4106ffad2883967595e7106832bfd00197d1d0fb..15d3cf02727c9aab04b1c8a3d72b0a891510db4b 100644 --- a/Assets/Scripts/InventoryStuff/ScrollDetails.cs +++ b/Assets/Scripts/InventoryStuff/ScrollDetails.cs @@ -29,6 +29,7 @@ void Start() ScrollFactHintEvent.AddListener(animateHint); NewAssignmentEvent.AddListener(newAssignmentTrigger); + RemoveFactEvent.AddListener(removeFactFromAssignment); mmtAnswerPopUp.GetComponent<PopupBehavior>().hidePopUp(); } @@ -309,16 +310,22 @@ public void animateHint(GameObject scrollParameter, string scrollParameterUri) { } } } + + //this is called whenever a Fact is Deleted in the world, to make sure it is removed from the scroll + public void removeFactFromAssignment(Fact fact) + { + Transform originalScroll = gameObject.transform.GetChild(1).transform; + Transform originalScrollView = originalScroll.GetChild(1); + Transform originalViewport = originalScrollView.GetChild(0); - public void animateInvalidAssignedFact(GameObject scrollParameter) - { - //Animate ScrollParameter - scrollParameter.GetComponentInChildren<ImageHintAnimation>().AnimationTrigger(); - } - - public void animateScrollParameter(string label) - { - var obj = ParameterDisplays.Find(x => x.transform.GetChild(0).GetComponent<RenderedScrollFact>().Label == label); - obj.GetComponentInChildren<Animator>().SetTrigger("animateHint"); + for (int i = 0; i < originalViewport.GetChild(0).childCount; i++) + { + RenderedScrollFact scrollFact = originalViewport.GetChild(0).transform.GetChild(i).GetChild(0).gameObject.GetComponent<RenderedScrollFact>(); + if (scrollFact.Label == fact.Label) + { + DropHandling dropHandling = originalViewport.GetChild(0).transform.GetChild(i).GetChild(0).gameObject.GetComponent<DropHandling>(); + dropHandling.OnPointerClick(null); + } + } } } diff --git a/Assets/Scripts/UI/HideUI_mobile.cs b/Assets/Scripts/UI/HideUI_mobile.cs index ea14e4c2b975d90fb628ea648ff62aca2e06a174..d7c5af0598a0018b2a5d7ed31ad661d2599865df 100644 --- a/Assets/Scripts/UI/HideUI_mobile.cs +++ b/Assets/Scripts/UI/HideUI_mobile.cs @@ -126,8 +126,6 @@ void Start() } UICanvas.enabled = false; } - - } @@ -289,6 +287,10 @@ void CheckIf() UIconfig.CanvasOnOff_Array[16] = 1; UIconfig.CanvasOnOff_Array[20] = 0; + + //Maybe shift somewhere else. This fixes issues with the dynamic scroll application + //whenever the player opens the MathMode Menu, send new assignment, facts could have been deleted + CommunicationEvents.NewAssignmentEvent.Invoke(); return; } diff --git a/Assets/Scripts/UI/InGame/PopupBehavior.cs b/Assets/Scripts/UI/InGame/PopupBehavior.cs index 48beb882edc05ab6dd8f4b18fcd558224ddbada0..28fe96da1344d3f92d255bd4f0654b663a33dec2 100644 --- a/Assets/Scripts/UI/InGame/PopupBehavior.cs +++ b/Assets/Scripts/UI/InGame/PopupBehavior.cs @@ -61,13 +61,18 @@ public void hidePopUp() canvas.SetActive(false); } + /// <summary> + /// this method creates a helpful error message and shows the popup. For it to work properly, the setScroll and setParameterDisplays must have been set. + /// </summary> + /// <param name="startfact"></param> + /// <param name="errorInfo"></param> public void onFailedScrollInput(Fact startfact, Scroll.ScrollApplicationInfo errorInfo) { - setMessage(generateHelpfulMessage(errorInfo)); + setMessage(generateHelpfulMessageAndAnimateScrollParam(errorInfo)); showPopUp(); } - private string generateHelpfulMessage(Scroll.ScrollApplicationInfo errorInfo) + private string generateHelpfulMessageAndAnimateScrollParam(Scroll.ScrollApplicationInfo errorInfo) { if(errorInfo == null) { @@ -77,7 +82,8 @@ private string generateHelpfulMessage(Scroll.ScrollApplicationInfo errorInfo) errorMessage = ""; for (int i = 0; i < errorInfo.errors.Length; i++) { Scroll.ScrollApplicationCheckingError error = errorInfo.errors[i]; - + + //check which error ocurred and set Message to a helpful error message. if (error.kind == "nonTotal") { errorMessage += NonTotalMessage; @@ -86,13 +92,21 @@ private string generateHelpfulMessage(Scroll.ScrollApplicationInfo errorInfo) { invAssCount++; Scroll.ScrollFact fact = parseFactFromError(error); - foreach (GameObject g in parameterDisplays) + + //animate all invalidly assigned facts + if (parameterDisplays != null && fact != null) { - RenderedScrollFact scrollfact = g.transform.GetChild(0).GetComponent<RenderedScrollFact>(); - if(scrollfact.factUri == fact.@ref.uri) + foreach (GameObject g in parameterDisplays) { - scrollfact.ScrollParameterObject.GetComponentInChildren<ImageHintAnimation>().AnimationTrigger(); + RenderedScrollFact scrollfact = g.transform.GetChild(0).GetComponent<RenderedScrollFact>(); + if (scrollfact.factUri == fact.@ref.uri) + { + scrollfact.ScrollParameterObject.GetComponentInChildren<ImageHintAnimation>().AnimationTrigger(); + } } + } else + { + Debug.Log("PopupBehavior: Error: scroll or parameterDisplays not set."); } } else if (error.kind == "unknown") { @@ -137,15 +151,16 @@ private Scroll.ScrollFact parseFactFromError(Scroll.ScrollApplicationCheckingErr int factNameLength = rest.IndexOf('?') - 2; string factLabel = rest.Substring(2, factNameLength); - //add ?factName URI + //add ?factName to URI factUri += "?" + factLabel; - //Debug.Log("Parsed URI: " + factUri + " parsed fact label: " + factLabel); - + //find the required fact in the active scroll thats invalidly assigned + if((activeScroll == null)) + { + return null; + } foreach (Scroll.ScrollFact f in activeScroll.requiredFacts) { - //Debug.Log("KIND: " + f.kind + " Label: " + f.label + " Uri: " + f.@ref.uri); - //Debug.Log("Uri: " + f.@ref.uri); if (f.@ref.uri.Equals(factUri)) { return f;