Skip to content
Snippets Groups Projects
Commit b68bee63 authored by Jacktheholdy's avatar Jacktheholdy
Browse files

Fixed a Bug where Facts stay assigned in scroll even when deleted in the...

Fixed a Bug where Facts stay assigned in scroll even when deleted in the world. Now they also are deleted in the scoll.
There are still issues with the dynamic scroll assignment however.

Removed some unused functions implemented for the invalid assigned fact animations.

Added some comments to popupbehavior script
parent 60ff5187
No related branches found
No related tags found
No related merge requests found
......@@ -66,3 +66,5 @@ crashlytics-build.properties
# Ignore UserSettings
UserSettings/
/Assets/Images/frameit_logo_512x512.png.meta
/Assets/Images/ScreenCapture_1024x500.png.meta
......@@ -29,6 +29,7 @@ void Start()
ScrollFactHintEvent.AddListener(animateHint);
NewAssignmentEvent.AddListener(newAssignmentTrigger);
RemoveFactEvent.AddListener(removeFactFromAssignment);
mmtAnswerPopUp.GetComponent<PopupBehavior>().hidePopUp();
}
......@@ -310,15 +311,21 @@ public void animateHint(GameObject scrollParameter, string scrollParameterUri) {
}
}
public void animateInvalidAssignedFact(GameObject scrollParameter)
//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)
{
//Animate ScrollParameter
scrollParameter.GetComponentInChildren<ImageHintAnimation>().AnimationTrigger();
}
Transform originalScroll = gameObject.transform.GetChild(1).transform;
Transform originalScrollView = originalScroll.GetChild(1);
Transform originalViewport = originalScrollView.GetChild(0);
public void animateScrollParameter(string label)
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)
{
var obj = ParameterDisplays.Find(x => x.transform.GetChild(0).GetComponent<RenderedScrollFact>().Label == label);
obj.GetComponentInChildren<Animator>().SetTrigger("animateHint");
DropHandling dropHandling = originalViewport.GetChild(0).transform.GetChild(i).GetChild(0).gameObject.GetComponent<DropHandling>();
dropHandling.OnPointerClick(null);
}
}
}
}
......@@ -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;
}
......
......@@ -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)
{
......@@ -78,6 +83,7 @@ private string generateHelpfulMessage(Scroll.ScrollApplicationInfo errorInfo)
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,6 +92,10 @@ private string generateHelpfulMessage(Scroll.ScrollApplicationInfo errorInfo)
{
invAssCount++;
Scroll.ScrollFact fact = parseFactFromError(error);
//animate all invalidly assigned facts
if (parameterDisplays != null && fact != null)
{
foreach (GameObject g in parameterDisplays)
{
RenderedScrollFact scrollfact = g.transform.GetChild(0).GetComponent<RenderedScrollFact>();
......@@ -94,6 +104,10 @@ private string generateHelpfulMessage(Scroll.ScrollApplicationInfo errorInfo)
scrollfact.ScrollParameterObject.GetComponentInChildren<ImageHintAnimation>().AnimationTrigger();
}
}
} else
{
Debug.Log("PopupBehavior: Error: scroll or parameterDisplays not set.");
}
} else if (error.kind == "unknown")
{
errorMessage += UnknownErrorMessage;
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment