Skip to content
Snippets Groups Projects
Commit 9b828280 authored by scherlit's avatar scherlit
Browse files

Merge branch 'RenewWebsiteFunctionality' of...

Merge branch 'RenewWebsiteFunctionality' of https://gitup.uni-potsdam.de/mm_vr/vr-klassenzimmer into RenewWebsiteFunctionality
parents 235e01f9 e883b23f
No related branches found
No related tags found
No related merge requests found
......@@ -64,6 +64,12 @@ namespace TeachR.Displays
public void Next() => Slide = Math.Min(Slide + 1, Count - 1);
public void Prev() => Slide = Math.Max(0, Slide - 1);
/// <summary>
/// Asynchronously loads image files from the specified paths, converts them into Texture2D objects,
/// sorts the textures by their names (with numerical order preserved), and returns them as a Presentation object.
/// </summary>
public static async Awaitable<Presentation> FromFiles(IEnumerable<string> paths)
{
List<Task<Texture2D>> loadFilesTasks = paths.Select(async f =>
......
using System;
using System.IO;
using TeachR.ApplicationManager;
using TeachR.WebCommunication;
using UnityEngine;
using TeachR.StructureTree;
using System.Linq;
namespace TeachR.Displays
{
......@@ -9,10 +12,14 @@ namespace TeachR.Displays
{
public static Presentation Presentation { get; private set; }
public static event Action OnLoad;
private static readonly string[] allowedFileFormats = { ".png", ".jpg" };
private static string folderPath;
private static string[] filePath;
[RuntimeInitializeOnLoadMethod]
private static void Init()
{
ImpulseController.ThemeChangedHook += LoadPresentationOnThemeChange;
CoachRtc.Persistent.On("loadPresentation", json => Load(json.GetValue<PresentationData>()));
CoachRtc.Persistent.On("changeSlide", json => Presentation.Slide = int.Parse(json.content));
CoachRtc.Persistent.On("clearPresentation", _ => Presentation = null);
......@@ -39,5 +46,26 @@ namespace TeachR.Displays
if (Presentation != null) Presentation.Prev();
else Debug.Log("No slides loaded yet");
}
public static async void LoadPresentationOnThemeChange(string fromFolder)
{
string pathToPresentationFolder = Path.Combine(Application.streamingAssetsPath, "Config~", fromFolder, "PresentationSlides");
if (!Directory.Exists(pathToPresentationFolder)) return;
string[] pathToPresentationSlides = Directory.GetFiles(pathToPresentationFolder, "*.jpg");// mehr dateiformate zulassen
//string[] pathToPresentationSlides = Directory.GetFiles(pathToPresentationFolder, "*.*", SearchOption.TopDirectoryOnly)
// .Where(f => allowedFileFormats.Contains(Path.GetExtension(f)))
// .ToArray();
if (pathToPresentationSlides.Length > 0)
{
Presentation = await Presentation.FromFiles(pathToPresentationSlides);
}
else
{
Debug.Log("No postercontent found");
}
}
}
}
\ No newline at end of file
......@@ -10,7 +10,8 @@
"GUID:df380645f10b7bc4b97d4f5eb6303d95",
"GUID:5797ac88e999e2e42a3aa9bee208f62f",
"GUID:f50e0b5d75e4c9348a7d42a1c5382977",
"GUID:0ced200546f7ed84e923e5314f07fa40"
"GUID:0ced200546f7ed84e923e5314f07fa40",
"GUID:71eb3b62d9c24a443ae2633f4a99eb65"
],
"includePlatforms": [],
"excludePlatforms": [
......
......@@ -47,7 +47,7 @@ namespace TeachR.StructureTree
// in case something specific needs to be loaded for each theme, there is an EventHook.
public static event Action<string> ThemeChangedHook;
public bool showDebug = true;
[SerializeField] private bool showDebug = true;
private void Awake()
......@@ -155,6 +155,7 @@ namespace TeachR.StructureTree
Debug.Log("Theme " + fromFolder + " requested");
fromFolder = "theme/" + fromFolder;
config.LoadPosters(fromFolder);
//loadPresentation(fromFolder); TODO
config.LoadLessonDraft(fromFolder);
config.lessonDraftSheet.gameObject.SetActive(true);
......@@ -235,8 +236,7 @@ namespace TeachR.StructureTree
}
}
GoToNextNode(bc);
if (showDebug)
Debug.Log($"StartTalkPerformedBy requested student: {studentSlot.name}");
if (showDebug) Debug.Log($"StartTalkPerformedBy requested student: {studentSlot.name}");
StartTalkPerformedBy(studentSlot);
SetBehavioursToIdle("RaiseArm");
return;
......@@ -285,8 +285,7 @@ namespace TeachR.StructureTree
{
BehaviourController bc = studentSlot.GetComponent<BehaviourController>();
string currentNode = bc.currentNodeInDiscussion;
if (showDebug)
Debug.Log($"{line}) student: {studentSlot.name}, currentNode: {currentNode}");
if (showDebug) Debug.Log($"{line}) student: {studentSlot.name}, currentNode: {currentNode}");
GraphToTreeConverter.StructureTreeNode nextNode = default;
StudentController studenController = studentSlot.GetComponent<StudentController>();
......@@ -398,8 +397,7 @@ namespace TeachR.StructureTree
{
string nextNodeId = bc[0].nextNode;
GraphToTreeConverter.StructureTreeNode nextNode = StructureTreeContainer.GetNextNodeById(nextNodeId);
if (showDebug)
Debug.Log($"Go to next node, nextNodeId: {nextNodeId}, currentNodeInDiscussion: {bc[0].currentNodeInDiscussion}");
if (showDebug) Debug.Log($"Go to next node, nextNodeId: {nextNodeId}, currentNodeInDiscussion: {bc[0].currentNodeInDiscussion}");
if (StructureTreeHandler.classHasGlobalKnowledge)
{
ClassController.DiscussionGoesToNode(nextNode.nodeId);
......@@ -489,8 +487,7 @@ namespace TeachR.StructureTree
}
StudentController sc = studentSlot.GetComponent<StudentController>();
if (showDebug)
Debug.Log($"StartTalkPerformedBy: {studentSlot.name}");
if (showDebug) Debug.Log($"StartTalkPerformedBy: {studentSlot.name}");
string soundFileFolder = StructureTreeHandler.stc[currentNode].soundFileName;
string previousVoice = sc.StudentObj.PreviousVoice;
string pathOfAudioFile = StructureTreeHandler.GetPathOfAudioFile(soundFileFolder, sc.IsMale, previousVoice);
......@@ -498,24 +495,20 @@ namespace TeachR.StructureTree
if (pathOfAudioFile != "")
{
string audioFileName = Path.GetFileNameWithoutExtension(pathOfAudioFile);
if (showDebug)
Debug.Log($"audioFileName: {audioFileName}");
if (showDebug) Debug.Log($"audioFileName: {audioFileName}");
if (string.IsNullOrEmpty(previousVoice)) // set previous voice if not set before
{
string voice = audioFileName.Replace(soundFileFolder, "").Replace("_", "").Replace("-", "");
if (showDebug)
Debug.Log($"previousVoice: {voice}");
if (showDebug) Debug.Log($"previousVoice: {voice}");
if (!string.IsNullOrEmpty(voice))
{
sc.StudentObj.PreviousVoice = voice;
if (showDebug)
Debug.Log($"set previousVoice to {voice}");
if (showDebug) Debug.Log($"set previousVoice to {voice}");
}
else
{
if (showDebug)
Debug.Log($"previousVoice was set to {voice} before");
if (showDebug) Debug.Log($"previousVoice was set to {voice} before");
}
}
else if (!audioFileName.Contains(previousVoice))
......@@ -552,13 +545,11 @@ namespace TeachR.StructureTree
if (StructureTreeHandler.classHasGlobalKnowledge)
{
if (showDebug)
Debug.Log("Class is now at node " + StructureTreeHandler.stc[currentNode].nodeId);
if (showDebug) Debug.Log("Class is now at node " + StructureTreeHandler.stc[currentNode].nodeId);
}
else
{
if (showDebug)
Debug.Log(sc.Name + " is now at node " + StructureTreeHandler.stc[currentNode].nodeId);
if (showDebug) Debug.Log(sc.Name + " is now at node " + StructureTreeHandler.stc[currentNode].nodeId);
}
}
}
......
m_EditorVersion: 6000.0.29f1
m_EditorVersionWithRevision: 6000.0.29f1 (9fafe5c9db65)
m_EditorVersion: 6000.0.31f1
m_EditorVersionWithRevision: 6000.0.31f1 (a206c360e2a8)
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