From fe4994f86f1ad387ba35e26b3dd7ca74e67c9af4 Mon Sep 17 00:00:00 2001
From: Bjoern Esswein <692-bessw@users.noreply.gl.kwarc.info>
Date: Sun, 22 Sep 2024 21:28:45 +0200
Subject: [PATCH] Fix old ScrollView description displaying html source code
 after a fact has been assigned

---
 Assets/Scripts/UI/InGame/ScrollDetails.cs | 26 +++++++++++------------
 Packages/bessw.unity.webview              |  2 +-
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/Assets/Scripts/UI/InGame/ScrollDetails.cs b/Assets/Scripts/UI/InGame/ScrollDetails.cs
index 29b9a97e..ccf2176e 100644
--- a/Assets/Scripts/UI/InGame/ScrollDetails.cs
+++ b/Assets/Scripts/UI/InGame/ScrollDetails.cs
@@ -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)
diff --git a/Packages/bessw.unity.webview b/Packages/bessw.unity.webview
index 923dcaa9..5004257d 160000
--- a/Packages/bessw.unity.webview
+++ b/Packages/bessw.unity.webview
@@ -1 +1 @@
-Subproject commit 923dcaa913260cf737f908310cafcfccf78aef0d
+Subproject commit 5004257d58f35d6c32eaf5a0a4afd7f42fc7d049
-- 
GitLab