Skip to content
Snippets Groups Projects
Verified Commit fe4994f8 authored by Björn Eßwein's avatar Björn Eßwein
Browse files

Fix old ScrollView description displaying html source code after a fact has been assigned

parent 3dfe74ef
No related branches found
No related tags found
No related merge requests found
Pipeline #6346 passed
......@@ -40,14 +40,14 @@ private void OnEnable()
{
SwitchScrollUI.activeScrollData.OnScrollChanged.AddListener(ShowScroll);
SwitchScrollUI.activeScrollData.OnFactAssignmentUpdated.AddListener(OnFactAssignmentUpdated);
SwitchScrollUI.activeScrollData.OnScrollDynamicInfoUpdated.AddListener(UpdateScrollDescription);
SwitchScrollUI.activeScrollData.OnScrollDynamicInfoUpdated.AddListener(DisplayScrollDescription);
}
private void OnDisable()
{
SwitchScrollUI.activeScrollData.OnScrollChanged.RemoveListener(ShowScroll);
SwitchScrollUI.activeScrollData.OnFactAssignmentUpdated.RemoveListener(OnFactAssignmentUpdated);
SwitchScrollUI.activeScrollData.OnScrollDynamicInfoUpdated.RemoveListener(UpdateScrollDescription);
SwitchScrollUI.activeScrollData.OnScrollDynamicInfoUpdated.RemoveListener(DisplayScrollDescription);
}
private void OnDestroy()
......@@ -68,13 +68,7 @@ private void ShowScroll(Scroll newScroll)
//Clear all current ScrollFacts
originalViewport.GetChild(0).gameObject.DestroyAllChildren();
var description = newScroll.description;
// if description is a html description, extract the alternative text representation
if (Regex.IsMatch(newScroll.description, ".*<scroll-description.*"))
{
description = Regex.Match(newScroll.description, "<scroll-description [^>]* alt=((?>\\\")|(?>\\'))([^>]*?)\\1[^>]*>").Groups[2].Value;
}
originalScroll.GetChild(0).GetComponent<TextMeshProUGUI>().text = description;
DisplayScrollDescription(newScroll);
//ParameterDisplays.ForEach(gameObj => Destroy(gameObj));
ParameterDisplays = new();
......@@ -94,13 +88,17 @@ private void ShowScroll(Scroll newScroll)
}
}
private void UpdateScrollDescription(Scroll rendered)
private void DisplayScrollDescription(Scroll scroll)
{
if (SwitchScrollUI.activeScrollData.DynamicScrollDescriptionsActive)
{ // Update scroll-description
Transform scroll = gameObject.transform.GetChild(1).transform;
scroll.GetChild(0).GetComponent<TextMeshProUGUI>().text = rendered.description;
var description = scroll.description;
// if description is a html description, extract the alternative text representation
if (Regex.IsMatch(scroll.description, ".*<scroll-description.*"))
{
description = Regex.Match(scroll.description, "<scroll-description [^>]* alt=((?>\\\")|(?>\\'))([^>]*?)\\1[^>]*>").Groups[2].Value;
}
Transform scrollComponent = gameObject.transform.GetChild(1).transform;
scrollComponent.GetChild(0).GetComponent<TextMeshProUGUI>().text = description;
}
private void OnFactAssignmentUpdated(string slotUri, ActiveScroll.SlotAssignment slotAssignment)
......
Subproject commit 923dcaa913260cf737f908310cafcfccf78aef0d
Subproject commit 5004257d58f35d6c32eaf5a0a4afd7f42fc7d049
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment