diff --git a/Assets/Scripts/UI/InGame/WebViewController.cs b/Assets/Scripts/UI/InGame/WebViewController.cs index 422ceffdf2a0b8ed8c44fb8e36044a1f621546ec..6ec5dc7bd2209e13c75ad9434fbcaf72964fa141 100644 --- a/Assets/Scripts/UI/InGame/WebViewController.cs +++ b/Assets/Scripts/UI/InGame/WebViewController.cs @@ -89,9 +89,9 @@ private async void SetScrollContent(Scroll scroll) var description = scroll.description; if (Regex.IsMatch(description, ".*<scroll-description.*")) { + // replace slot templates description = Regex.Replace(description, "<scroll-slot([^>]*)>([^<]*)</scroll-slot>", match => { - Debug.LogWarning($"Regex: Value'{match.Value}', Group[{match.Groups.Count - 1}]={match.Groups[match.Groups.Count -1]}"); var extraAttributes = match.Groups[1].Value; var slotId = match.Groups[2].Value; var assignment = SwitchScrollUI.activeScrollData.Assignments[slotId]; @@ -99,6 +99,13 @@ private async void SetScrollContent(Scroll scroll) var label = assignment.IsSet ? assignment.fact.GetLabel(StageStatic.stage.factState) : scroll.requiredFacts.Find(fact => fact.@ref.uri == slotId).label; return $"<mi dropzone='copy' data-slot-id='{slotId}' {(assignment.IsSet ? $"data-fact-id='{assignment.fact.Id}'" : "")} {extraAttributes}>{label}</mi>"; }); + // replace solution templates + description = Regex.Replace(description, "<scroll-solution([^>]*)>([^<]*)</scroll-solution>", match => + { + var extraAttributes = match.Groups[1].Value; + var solutionId = match.Groups[2].Value; + return $"<mi data-solution-id='{solutionId}' {extraAttributes}>{scroll.acquiredFacts.Find(fact => fact.@ref.uri == solutionId).label}</mi>"; + }); } else { diff --git a/Assets/StreamingAssets/StreamToDataPath_withHandler/scrollView.html b/Assets/StreamingAssets/StreamToDataPath_withHandler/scrollView.html index fcdf0a1b8e346dc5e8610fe0c6aa189d2c7e5664..760dae874bf95352a91190069176d6d44470db96 100644 --- a/Assets/StreamingAssets/StreamToDataPath_withHandler/scrollView.html +++ b/Assets/StreamingAssets/StreamToDataPath_withHandler/scrollView.html @@ -19,15 +19,11 @@ position: absolute; background-color: red; } - .demoFact { - font-size: initial; - margin-top: 20px; - } </style> </head> <body> <div id="scrollContainer"> - <div>Default Scroll</div> + <div>No scroll selected</div> <math> <mi>E</mi> <mo>=</mo> @@ -70,7 +66,7 @@ </math> </div> <button type="button" title="Apply the scroll" onclick="applyScroll('')">Magic</button><br> - <button type="button" title="Hint" onclick="getHint('http://mathhub.info/FrameIT/frameworld?TriangleProblem_RightAngleAtC?rightAngleC')">Hint</button> + <p>Right click on a slot to get a hint.</p> </body> <script> /**