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

fixed typos

parent fe4994f8
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
using System.Linq; using System.Linq;
using UnityEngine.UI; using UnityEngine.UI;
public class FactObjectUI : FactObject, BrowserDropable public class FactObjectUI : FactObject, IBrowserDroppable
{ {
public Image[] Images; public Image[] Images;
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
#nullable enable annotations #nullable enable annotations
/// <summary> /// <summary>
/// This class keeps track of the currently active scroll and comunicates with the FrameIT Server. /// This class keeps track of the currently active scroll and communicates with the FrameIT Server.
/// It represents the model of the Model-View-Controler pattern. /// It represents the model of the Model-View-Controller pattern.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class ActiveScroll : MonoBehaviour public class ActiveScroll : MonoBehaviour
...@@ -20,17 +20,17 @@ public class ActiveScroll : MonoBehaviour ...@@ -20,17 +20,17 @@ public class ActiveScroll : MonoBehaviour
/** <summary>Event that is invoked when a scroll button is clicked, e.g. magic button. You can use it to handle custom buttons.</summary> */ /** <summary>Event that is invoked when a scroll button is clicked, e.g. magic button. You can use it to handle custom buttons.</summary> */
public UnityEvent<ScrollButton> OnButtonClick = new(); public UnityEvent<ScrollButton> OnButtonClick = new();
/** <summary>Notifies about availible hints.</summary> */ /** <summary>Notifies about available hints.</summary> */
public UnityEvent<IReadOnlyList<string>> HintAvailableEvent = new(); public UnityEvent<IReadOnlyList<string>> HintAvailableEvent = new();
/** <summary>Event that is invoked when a fact has been assigned to a slot and the ui needs to update.</summary> */ /** <summary>Event that is invoked when a fact has been assigned to a slot and the ui needs to update.</summary> */
public UnityEvent<string,SlotAssignment> OnFactAssignmentUpdated = new(); public UnityEvent<string,SlotAssignment> OnFactAssignmentUpdated = new();
/** <summary>Event that is invoked when the MMT server returned an error.</summary> */ /** <summary>Event that is invoked when the MMT server returned an error.</summary> */
public UnityEvent<string> OnMMTServerComunicationError = new(); public UnityEvent<string> OnMMTServerCommunicationError = new();
/** <summary>Event that is invoked when the scroll dynamic info returned errors in the current scroll assignment.</summary> */ /** <summary>Event that is invoked when the scroll dynamic info returned errors in the current scroll assignment.</summary> */
public UnityEvent<ScrollApplicationCheckingError[]> OnScrollDynamicInfoError = new(); public UnityEvent<ScrollApplicationCheckingError[]> OnScrollDynamicInfoError = new();
/** <summary>Event that is invoked when the scroll application returned errors in the current assignment.</summary> */ /** <summary>Event that is invoked when the scroll application returned errors in the current assignment.</summary> */
public UnityEvent<ScrollApplicationCheckingError[]> OnScrollApplicationError = new(); public UnityEvent<ScrollApplicationCheckingError[]> OnScrollApplicationError = new();
/** <summary>Event that is invoked when the OnMMTServerError or OnScrollApplicationFailed error state has been resolved and e.g. the error popup can be cloesed.</summary> */ /** <summary>Event that is invoked when the OnMMTServerError or OnScrollApplicationFailed error state has been resolved and e.g. the error popup can be closed.</summary> */
public UnityEvent OnCancelErrorState = new(); public UnityEvent OnCancelErrorState = new();
/** <summary>Event that is invoked when the scroll has been solved.</summary> */ /** <summary>Event that is invoked when the scroll has been solved.</summary> */
public UnityEvent<IReadOnlyList<Fact>> OnScrollSolved = new(); public UnityEvent<IReadOnlyList<Fact>> OnScrollSolved = new();
...@@ -65,7 +65,7 @@ public class ActiveScroll : MonoBehaviour ...@@ -65,7 +65,7 @@ public class ActiveScroll : MonoBehaviour
/** <summary>List of available hints for the current partial assignment.</summary> */ /** <summary>List of available hints for the current partial assignment.</summary> */
private List<Fact> LatestRenderedHints; private List<Fact> LatestRenderedHints;
/** <summary>List of available auto comletions for the current partial assignment. Used to generate hints.</summary> */ /** <summary>List of available auto completions for the current partial assignment. Used to generate hints.</summary> */
private List<ScrollAssignment> LatestBackwartsCompletions; private List<ScrollAssignment> LatestBackwartsCompletions;
private Scroll _Scroll; private Scroll _Scroll;
...@@ -79,7 +79,7 @@ public Scroll Scroll ...@@ -79,7 +79,7 @@ public Scroll Scroll
_Scroll = value; _Scroll = value;
// initialize the assignments dictionary with the references to the required fact slots as keys // initialize the assignments dictionary with the references to the required fact slots as keys
// and an empty SlottAssignment // and an empty SlotAssignment
_Assignments = value.requiredFacts _Assignments = value.requiredFacts
.ToDictionary(fact => fact.@ref.uri, _ => new SlotAssignment()); .ToDictionary(fact => fact.@ref.uri, _ => new SlotAssignment());
...@@ -129,7 +129,7 @@ public void ButtonClicked(ScrollButton button) ...@@ -129,7 +129,7 @@ public void ButtonClicked(ScrollButton button)
switch (button) switch (button)
{ {
// Magic button to apply the scroll // Magic button to apply the scroll
case MagicScrollButton: case ApplyScrollButton:
if ((Scroll is not null) && ! MagicInQue) StartCoroutine(SendScrollApplication()); if ((Scroll is not null) && ! MagicInQue) StartCoroutine(SendScrollApplication());
break; break;
case HintScrollButton: case HintScrollButton:
...@@ -153,7 +153,7 @@ public void AssignFact(string slotUri, Fact fact) ...@@ -153,7 +153,7 @@ public void AssignFact(string slotUri, Fact fact)
{ {
var slot = _Assignments[slotUri]; var slot = _Assignments[slotUri];
// return if the slot is already assigned to the given value (avoid unnecessary ui updates and frameit Server requests) // return if the slot is already assigned to the given value (avoid unnecessary ui updates and FrameIT Server requests)
//if ((fact is null && !slot.IsSet) || (slot.IsSet && slot.fact.Id == fact.Id)) return; //if ((fact is null && !slot.IsSet) || (slot.IsSet && slot.fact.Id == fact.Id)) return;
if (fact is null && !slot.IsSet) return; if (fact is null && !slot.IsSet) return;
...@@ -209,7 +209,7 @@ private IEnumerator SendScrollApplication() ...@@ -209,7 +209,7 @@ private IEnumerator SendScrollApplication()
if (currentMmtAnswer == null) if (currentMmtAnswer == null)
{ {
// OnMMTServerComunicationError is already invoked in SendView // OnMMTServerCommunicationError is already invoked in SendView
Debug.LogError("Magic FAILED"); Debug.LogError("Magic FAILED");
yield break; yield break;
} }
...@@ -220,7 +220,7 @@ private IEnumerator SendScrollApplication() ...@@ -220,7 +220,7 @@ private IEnumerator SendScrollApplication()
System.DateTime deserializeTime = System.DateTime.UtcNow; System.DateTime deserializeTime = System.DateTime.UtcNow;
ScrollApplicationInfo scrollApplication = JsonConvert.DeserializeObject<ScrollApplicationInfo>(currentMmtAnswer); ScrollApplicationInfo scrollApplication = JsonConvert.DeserializeObject<ScrollApplicationInfo>(currentMmtAnswer);
Debug.LogFormat($"Answerd deserialized in : {(System.DateTime.UtcNow - deserializeTime).TotalMilliseconds}ms"); Debug.LogFormat($"Answer deserialized in : {(System.DateTime.UtcNow - deserializeTime).TotalMilliseconds}ms");
if (scrollApplication.acquiredFacts.Count == 0 if (scrollApplication.acquiredFacts.Count == 0
|| scrollApplication.errors.Length > 0) || scrollApplication.errors.Length > 0)
...@@ -246,7 +246,7 @@ private List<Fact> __GenerateUnityFactsForAcquiredMMTFacts(List<MMTFact> pushout ...@@ -246,7 +246,7 @@ private List<Fact> __GenerateUnityFactsForAcquiredMMTFacts(List<MMTFact> pushout
Dictionary<string, string> old_to_new = new(); Dictionary<string, string> old_to_new = new();
System.DateTime parseTime = System.DateTime.UtcNow; System.DateTime parseTime = System.DateTime.UtcNow;
bool samestep = false; bool sameStep = false;
for (int i = 0; i < pushoutFacts.Count; i++) for (int i = 0; i < pushoutFacts.Count; i++)
{ {
List<Fact> new_list = Fact.MMTFactory(pushoutFacts[i].MapURIs(old_to_new)); List<Fact> new_list = Fact.MMTFactory(pushoutFacts[i].MapURIs(old_to_new));
...@@ -259,16 +259,16 @@ private List<Fact> __GenerateUnityFactsForAcquiredMMTFacts(List<MMTFact> pushout ...@@ -259,16 +259,16 @@ private List<Fact> __GenerateUnityFactsForAcquiredMMTFacts(List<MMTFact> pushout
foreach (Fact new_fact in new_list) foreach (Fact new_fact in new_list)
{ {
Fact added = FactAdder.AddFactIfNotFound(new_fact, out bool exists, samestep, null, Scroll.label); Fact added = FactAdder.AddFactIfNotFound(new_fact, out bool exists, sameStep, null, Scroll.label);
if (!exists) if (!exists)
{ {
new_facts.Add(added); new_facts.Add(added);
CommunicationEvents.AnimateExistingFactEvent.Invoke(added.Id, FactWrapper.FactMaterials.Solution); CommunicationEvents.AnimateExistingFactEvent.Invoke(added.Id, FactWrapper.FactMaterials.Solution);
samestep = true; sameStep = true;
} }
else else
{ {
// AnimateExistingFactEvent.Invoke(_new, FactWrapper.FactMaterials.Hint); // Automaticly done in FactRecorder // AnimateExistingFactEvent.Invoke(_new, FactWrapper.FactMaterials.Hint); // Automatically done in FactRecorder
old_to_new.Add(new_fact.Id, added.Id); old_to_new.Add(new_fact.Id, added.Id);
} }
} }
...@@ -349,14 +349,14 @@ private IEnumerator _SendAssignments() ...@@ -349,14 +349,14 @@ private IEnumerator _SendAssignments()
DynamicScrollInQue = true; DynamicScrollInQue = true;
while (!SendingViewDone) while (!SendingViewDone)
yield return null; // if we dont wait => server will crash yield return null; // if we don't wait => server will crash
DynamicScrollInQue = false; DynamicScrollInQue = false;
yield return SendView("/scroll/dynamic"); yield return SendView("/scroll/dynamic");
if (currentMmtAnswer == null) if (currentMmtAnswer == null)
{ {
// OnMMTServerComunicationError is already invoked in SendView // OnMMTServerCommunicationError is already invoked in SendView
Debug.LogError("Dynamic Scroll FAILED"); Debug.LogError("Dynamic Scroll FAILED");
yield break; yield break;
} }
...@@ -371,8 +371,8 @@ private IEnumerator _SendAssignments() ...@@ -371,8 +371,8 @@ private IEnumerator _SendAssignments()
catch (JsonSerializationException ex) catch (JsonSerializationException ex)
{ {
Debug.LogException(ex); Debug.LogException(ex);
Debug.LogError("Could not Deserialize MMT aswer for /scroll/dynamic\n" + currentMmtAnswer); Debug.LogError("Could not Deserialize MMT answer for /scroll/dynamic\n" + currentMmtAnswer);
OnMMTServerComunicationError.Invoke("MMT Server communication error: could not deserialize message."); OnMMTServerCommunicationError.Invoke("MMT Server communication error: could not deserialize message.");
yield break; yield break;
} }
...@@ -453,7 +453,7 @@ private IEnumerator SendView(string endpoint) ...@@ -453,7 +453,7 @@ private IEnumerator SendView(string endpoint)
System.DateTime sendTime = System.DateTime.UtcNow; System.DateTime sendTime = System.DateTime.UtcNow;
yield return www.SendWebRequest(); yield return www.SendWebRequest();
//if (VerboseURI) //if (VerboseURI)
Debug.LogFormat("Server answerd in : {0}ms" Debug.LogFormat("Server answered in : {0}ms"
, (System.DateTime.UtcNow - sendTime).TotalMilliseconds); , (System.DateTime.UtcNow - sendTime).TotalMilliseconds);
if (www.result == UnityWebRequest.Result.ConnectionError if (www.result == UnityWebRequest.Result.ConnectionError
...@@ -461,7 +461,7 @@ private IEnumerator SendView(string endpoint) ...@@ -461,7 +461,7 @@ private IEnumerator SendView(string endpoint)
{ {
Debug.LogWarning(www.error); Debug.LogWarning(www.error);
currentMmtAnswer = null; currentMmtAnswer = null;
OnMMTServerComunicationError.Invoke($"Server communication error: {www.error}"); OnMMTServerCommunicationError.Invoke($"Server communication error: {www.error}");
SendingViewDone = true; SendingViewDone = true;
yield break; yield break;
} }
...@@ -491,11 +491,11 @@ string prepareScrollAssignments() ...@@ -491,11 +491,11 @@ string prepareScrollAssignments()
} }
/// <summary> /// <summary>
/// Parrent class for all scroll buttons, inherit from this class to implement custom buttons. /// Parent class for all scroll buttons, inherit from this class to implement custom buttons.
/// </summary> /// </summary>
public abstract class ScrollButton {} public abstract class ScrollButton {}
public class MagicScrollButton : ScrollButton {} public class ApplyScrollButton : ScrollButton {}
public class HintScrollButton : ScrollButton public class HintScrollButton : ScrollButton
{ {
public readonly string SlotUri; public readonly string SlotUri;
......
...@@ -27,7 +27,7 @@ public string MessageText ...@@ -27,7 +27,7 @@ public string MessageText
void OnEnable() void OnEnable()
{ {
SwitchScrollUI.activeScrollData.OnMMTServerComunicationError.AddListener(OnShowErrorMessage); SwitchScrollUI.activeScrollData.OnMMTServerCommunicationError.AddListener(OnShowErrorMessage);
SwitchScrollUI.activeScrollData.OnScrollDynamicInfoError.AddListener(OnFailedScrollInput); SwitchScrollUI.activeScrollData.OnScrollDynamicInfoError.AddListener(OnFailedScrollInput);
SwitchScrollUI.activeScrollData.OnScrollApplicationError.AddListener(OnFailedScrollInput); SwitchScrollUI.activeScrollData.OnScrollApplicationError.AddListener(OnFailedScrollInput);
SwitchScrollUI.activeScrollData.OnCancelErrorState.AddListener(HidePopUp); SwitchScrollUI.activeScrollData.OnCancelErrorState.AddListener(HidePopUp);
...@@ -35,7 +35,7 @@ void OnEnable() ...@@ -35,7 +35,7 @@ void OnEnable()
void OnDisable() void OnDisable()
{ {
SwitchScrollUI.activeScrollData.OnMMTServerComunicationError.RemoveListener(OnShowErrorMessage); SwitchScrollUI.activeScrollData.OnMMTServerCommunicationError.RemoveListener(OnShowErrorMessage);
SwitchScrollUI.activeScrollData.OnScrollDynamicInfoError.RemoveListener(OnFailedScrollInput); SwitchScrollUI.activeScrollData.OnScrollDynamicInfoError.RemoveListener(OnFailedScrollInput);
SwitchScrollUI.activeScrollData.OnScrollApplicationError.RemoveListener(OnFailedScrollInput); SwitchScrollUI.activeScrollData.OnScrollApplicationError.RemoveListener(OnFailedScrollInput);
SwitchScrollUI.activeScrollData.OnCancelErrorState.RemoveListener(HidePopUp); SwitchScrollUI.activeScrollData.OnCancelErrorState.RemoveListener(HidePopUp);
......
...@@ -120,6 +120,6 @@ private void OnFactAssignmentUpdated(string slotUri, ActiveScroll.SlotAssignment ...@@ -120,6 +120,6 @@ private void OnFactAssignmentUpdated(string slotUri, ActiveScroll.SlotAssignment
[ContextMenu("MagicButtonClicked")] [ContextMenu("MagicButtonClicked")]
public void MagicButtonClicked() public void MagicButtonClicked()
{ {
SwitchScrollUI.activeScrollData.ButtonClicked(new MagicScrollButton()); SwitchScrollUI.activeScrollData.ButtonClicked(new ApplyScrollButton());
} }
} }
...@@ -109,17 +109,17 @@ private async void SetScrollContent(Scroll scroll) ...@@ -109,17 +109,17 @@ private async void SetScrollContent(Scroll scroll)
} }
else else
{ {
// scroll is a lagacy plain text scroll, generate html with slots for the required facts // scroll is a legacy plain text scroll, generate html with slots for the required facts
var factSlots = SwitchScrollUI.activeScrollData.Assignments var factSlots = SwitchScrollUI.activeScrollData.Assignments
.Where(pair => pair.Value.IsVisible) .Where(pair => pair.Value.IsVisible)
.Select(pair => .Select(pair =>
@$"<span class='lagacySlot' dropzone='copy' data-slot-id='{pair.Key}' {(pair.Value.IsSet ? $"data-fact-id='{pair.Value.fact.Id}'" : "")}> @$"<span class='legacySlot' dropzone='copy' data-slot-id='{pair.Key}' {(pair.Value.IsSet ? $"data-fact-id='{pair.Value.fact.Id}'" : "")}>
{(pair.Value.IsSet ? {(pair.Value.IsSet ?
pair.Value.fact.GetLabel(StageStatic.stage.factState) : pair.Value.fact.GetLabel(StageStatic.stage.factState) :
scroll.requiredFacts.Find(fact => fact.@ref.uri == pair.Key).label )} scroll.requiredFacts.Find(fact => fact.@ref.uri == pair.Key).label )}
</span>"); </span>");
description = $"<scroll-description><p>{scroll.description}</p><div id='lagacySlots'>{String.Join("", factSlots)}</div></scroll-description>"; description = $"<scroll-description><p>{scroll.description}</p><div id='legacySlots'>{String.Join("", factSlots)}</div></scroll-description>";
} }
// display the scroll description // display the scroll description
dropzones = null; dropzones = null;
...@@ -130,7 +130,7 @@ private async void SetScrollContent(Scroll scroll) ...@@ -130,7 +130,7 @@ private async void SetScrollContent(Scroll scroll)
private async void DropzoneAttributeModifiedHandler(attributeModifiedEvent attributeModifiedEvent) private async void DropzoneAttributeModifiedHandler(attributeModifiedEvent attributeModifiedEvent)
{ {
Debug.LogWarning($"dropzoneAtrributeModifiedHandler: '{attributeModifiedEvent.name}'"); Debug.LogWarning($"dropzoneAttributeModifiedHandler: '{attributeModifiedEvent.name}'");
// call the onFactAssignment event if the data-fact-id attribute was modified // call the onFactAssignment event if the data-fact-id attribute was modified
if (attributeModifiedEvent.name == "data-fact-id") if (attributeModifiedEvent.name == "data-fact-id")
...@@ -140,11 +140,11 @@ private async void DropzoneAttributeModifiedHandler(attributeModifiedEvent attri ...@@ -140,11 +140,11 @@ private async void DropzoneAttributeModifiedHandler(attributeModifiedEvent attri
if (! (node.Node.attributes.TryGetValue("data-slot-id", out string slot) if (! (node.Node.attributes.TryGetValue("data-slot-id", out string slot)
|| (await node.getAttributesAsync()).TryGetValue("data-slot-id", out slot))) || (await node.getAttributesAsync()).TryGetValue("data-slot-id", out slot)))
{ {
Debug.LogError($"dropzoneAtrributeModifiedHandler: data-slot-id attribute not found on dropzone"); Debug.LogError($"dropzoneAttributeModifiedHandler: data-slot-id attribute not found on dropzone");
throw new Exception("data-slot-id attribute not found on dropzone"); throw new Exception("data-slot-id attribute not found on dropzone");
} }
// if fact has been unasigned from the scroll // if fact has been unassigned from the scroll
if (attributeModifiedEvent.value == "null") if (attributeModifiedEvent.value == "null")
{ {
// remove fact from slot // remove fact from slot
...@@ -155,7 +155,7 @@ private async void DropzoneAttributeModifiedHandler(attributeModifiedEvent attri ...@@ -155,7 +155,7 @@ private async void DropzoneAttributeModifiedHandler(attributeModifiedEvent attri
// get the fact from the fact id // get the fact from the fact id
if (!FactRecorder.AllFacts.TryGetValue(attributeModifiedEvent.value, out Fact fact)) if (!FactRecorder.AllFacts.TryGetValue(attributeModifiedEvent.value, out Fact fact))
{ {
Debug.LogError($"dropzoneAtrributeModifiedHandler: fact with id '{attributeModifiedEvent.value}' not found"); Debug.LogError($"dropzoneAttributeModifiedHandler: fact with id '{attributeModifiedEvent.value}' not found");
throw new Exception($"fact with id '{attributeModifiedEvent.value}' not found"); throw new Exception($"fact with id '{attributeModifiedEvent.value}' not found");
} }
...@@ -182,7 +182,7 @@ private async void OnHintAvailable(IReadOnlyList<string> url) ...@@ -182,7 +182,7 @@ private async void OnHintAvailable(IReadOnlyList<string> url)
private void ApplyScrollHandler(string button) private void ApplyScrollHandler(string button)
{ {
SwitchScrollUI.activeScrollData.ButtonClicked(new MagicScrollButton()); SwitchScrollUI.activeScrollData.ButtonClicked(new ApplyScrollButton());
} }
private void GetHintHandler(string url) private void GetHintHandler(string url)
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
align-items: center; align-items: center;
flex-wrap: wrap; flex-wrap: wrap;
} }
.lagacySlot { .legacySlot {
width: 100px; width: 100px;
height: 100px; height: 100px;
margin: 50px; margin: 50px;
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
</mtable> </mtable>
</math> </math>
</div> </div>
<button type="button" title="Apply the scroll" onclick="applyScroll('')">Magic</button><br> <button type="button" title="Apply the scroll" onclick="applyScroll('')">Apply</button><br>
<p>You can right click on yellow slots to get a hint.</p> <p>You can right click on yellow slots to get a hint.</p>
</body> </body>
<script> <script>
...@@ -203,11 +203,11 @@ ...@@ -203,11 +203,11 @@
const data = event.dataTransfer.getData("application/json") const data = event.dataTransfer.getData("application/json")
//const data = event.dataTransfer.getData("text/plain") //const data = event.dataTransfer.getData("text/plain")
console.log(`Droped data: '${event.dataTransfer.types}'`, event.dataTransfer.types) console.log(`Dropped data: '${event.dataTransfer.types}'`, event.dataTransfer.types)
/** @type {Fact} */ /** @type {Fact} */
const fact = JSON.parse(data) const fact = JSON.parse(data)
console.warn(`Droped Fact '${fact.label}':`, fact) console.warn(`Dropped Fact '${fact.label}':`, fact)
/** @type {HTMLElement} */ /** @type {HTMLElement} */
const element = event.target const element = event.target
......
Subproject commit 5004257d58f35d6c32eaf5a0a4afd7f42fc7d049 Subproject commit c2220c67983c8152fe5052cf5981fe680772c4f0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment