Skip to content
Snippets Groups Projects
Commit 72c6c77d authored by John Schihada's avatar John Schihada
Browse files

Fixed Scroll-Selection-Bug

parent 5a783cf4
No related branches found
No related tags found
No related merge requests found
...@@ -7,38 +7,6 @@ ...@@ -7,38 +7,6 @@
using JsonSubTypes; using JsonSubTypes;
using Newtonsoft.Json; using Newtonsoft.Json;
/*
[Serializable]
public class Declaration
{
public string name;
public string isProof;
public string value;
public string identifier;
public string description;
}
[Serializable]
public class Scroll
{
public string problemTheory;
public string solutionTheory;
public string label;
public string description;
public Declaration[] declarations;
//public string output;
public static Scroll generateFromJson(string json) {
return JsonUtility.FromJson<Scroll>(json);
}
public string toJson() {
return JsonUtility.ToJson(this);
}
}
*/
public class Scroll : LightScroll public class Scroll : LightScroll
{ {
public string label; public string label;
...@@ -65,52 +33,6 @@ public static void InitDynamicScroll(int n) ...@@ -65,52 +33,6 @@ public static void InitDynamicScroll(int n)
FactOccurences = new List<KeyValuePair<int, int>>[n]; FactOccurences = new List<KeyValuePair<int, int>>[n];
} }
//also collects occurences to be changed later
public static string ParseString(int stringId, string raw, List<ScrollFact> scrollFacts)
{
int i = 0;
while(true)
{
char[] rawChars = raw.ToCharArray();
i = Array.FindIndex(rawChars,i, c => c == '$');
if (i == -1) break;
// Debug.Log(i);
//id of Fact, specified after the $
int toChange = (int) Char.GetNumericValue(raw[i + 1]);
//label of this Fact
string label = scrollFacts[toChange].label;
raw = raw.Remove(i,2);
raw = raw.Insert(i,label);
if(FactOccurences[toChange] == null)
{
FactOccurences[toChange] = new List<KeyValuePair<int, int>>();
}
//if (toChange >= 0) Debug.Log(stringId);
FactOccurences[toChange].Add(new KeyValuePair<int, int>(stringId,i));
}
return raw;
}
/*
public class ScrollList
{
public List<Scroll> scrolls;
}*/
public class ScrollAssignment public class ScrollAssignment
{ {
public KeyValuePair<string, JSONManager.MMTTerm> assignment; public KeyValuePair<string, JSONManager.MMTTerm> assignment;
......
...@@ -56,7 +56,11 @@ public void setScroll(Scroll s) ...@@ -56,7 +56,11 @@ public void setScroll(Scroll s)
Transform scrollView = gameObject.transform.GetChild(2); Transform scrollView = gameObject.transform.GetChild(2);
Transform viewport = scrollView.GetChild(0); Transform viewport = scrollView.GetChild(0);
this.scroll = s; this.scroll = s;
//Clear all current ScrollFacts
foreach (Transform child in viewport.GetChild(0).transform)
GameObject.Destroy(child.gameObject);
ParameterDisplays = new List<GameObject>(); ParameterDisplays = new List<GameObject>();
Scroll.InitDynamicScroll(s.requiredFacts.Count); Scroll.InitDynamicScroll(s.requiredFacts.Count);
for (int i = 0; i < s.requiredFacts.Count; i++) for (int i = 0; i < s.requiredFacts.Count; i++)
...@@ -67,15 +71,12 @@ public void setScroll(Scroll s) ...@@ -67,15 +71,12 @@ public void setScroll(Scroll s)
scrollFact.ID = i; scrollFact.ID = i;
//obj.GetComponent<RectTransform>().localPosition = GetPosition(i); //obj.GetComponent<RectTransform>().localPosition = GetPosition(i);
scrollFact.Label = Scroll.ParseString(i,s.requiredFacts[i].label,s.requiredFacts); scrollFact.Label = s.requiredFacts[i].label;
obj.transform.SetParent(viewport.GetChild(0)); obj.transform.SetParent(viewport.GetChild(0));
//this is from benni, I dont know if the hack is the commented line below or the line above....
//TODO: Remvoe this reaaaaly bad hack
//obj.transform.localScale = Vector3.one;
ParameterDisplays.Add(obj); ParameterDisplays.Add(obj);
} }
//scroll description //scroll description
ScrollDescription = Scroll.ParseString(-1, s.description, s.requiredFacts); ScrollDescription = s.description;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment