From d79267ee36b61bec8850340177f4f337b4fe37c7 Mon Sep 17 00:00:00 2001 From: JaXt0r <120568393+JaXt0r@users.noreply.github.com> Date: Wed, 6 Mar 2024 21:19:12 +0100 Subject: [PATCH] add(LabMusic): Dropdown now includes all the possible musicThemeInstances. --- Assets/GothicVR-Lab/Scenes/Lab.unity | 2 +- .../Scripts/Handler/LabMusicHandler.cs | 30 ++++++++++++------- .../GothicVR/Scripts/Manager/MusicManager.cs | 18 +++++------ 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/Assets/GothicVR-Lab/Scenes/Lab.unity b/Assets/GothicVR-Lab/Scenes/Lab.unity index 013152103..c362d4b9b 100644 --- a/Assets/GothicVR-Lab/Scenes/Lab.unity +++ b/Assets/GothicVR-Lab/Scenes/Lab.unity @@ -4120,11 +4120,11 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 464842610} + - component: {fileID: 464842615} - component: {fileID: 464842609} - component: {fileID: 464842612} - component: {fileID: 464842613} - component: {fileID: 464842614} - - component: {fileID: 464842615} - component: {fileID: 464842616} - component: {fileID: 464842617} m_Layer: 0 diff --git a/Assets/GothicVR-Lab/Scripts/Handler/LabMusicHandler.cs b/Assets/GothicVR-Lab/Scripts/Handler/LabMusicHandler.cs index 471dc937c..f0287b16d 100644 --- a/Assets/GothicVR-Lab/Scripts/Handler/LabMusicHandler.cs +++ b/Assets/GothicVR-Lab/Scripts/Handler/LabMusicHandler.cs @@ -1,9 +1,13 @@ +using System; using System.Collections.Generic; using System.Linq; +using GVR.Caches; using GVR.Debugging; +using GVR.Globals; using GVR.Manager; using TMPro; using UnityEngine; +using ZenKit.Daedalus; namespace GVR.Lab.Handler { @@ -12,17 +16,22 @@ public class LabMusicHandler : MonoBehaviour, ILabHandler public TMP_Dropdown fileSelector; public TMP_Dropdown themeSelector; - private Dictionary> musicMapping = new() - { - { "ow_day_std.sgt", new(){ "DEF_DAY_STD" } }, - { "ban_day_std.sgt", new(){ "STA_DAY_STD" } }, - { "oc_day_std.sgt", new(){ "" } }, - }; + private List _musicInstances; public void Bootstrap() { - fileSelector.options = musicMapping.Select(dict => new TMP_Dropdown.OptionData(dict.Key)).ToList(); - themeSelector.options = musicMapping.First().Value.Select(i => new TMP_Dropdown.OptionData(i)).ToList(); + var prototype = GameData.MusicVm.GetSymbolByName("C_MUSICTHEME_DEF"); + + _musicInstances = GameData.MusicVm.Symbols + .Where(s => s.Parent == prototype.Index) + .Select(s => AssetCache.TryGetMusic(s.Name)) + .GroupBy(instance => instance.File, StringComparer.InvariantCultureIgnoreCase) + .Select(group => group.First()) + .OrderBy(instance => instance.File) + .ToList(); + + fileSelector.options = _musicInstances.Select(i => new TMP_Dropdown.OptionData(i.File)).ToList(); + // themeSelector.options = musicMapping.First().Value.Select(i => new TMP_Dropdown.OptionData(i)).ToList(); } public void MusicPlayClick() @@ -31,10 +40,9 @@ public void MusicPlayClick() FeatureFlags.I.enableMusic = true; FeatureFlags.I.showMusicLogs = true; - var fileSelect = fileSelector.options[fileSelector.value].text; - var themeSelect = fileSelector.options[fileSelector.value].text; + var item = _musicInstances[fileSelector.value]; - MusicManager.I.SetMusic(fileSelect, themeSelect); + MusicManager.I.SetMusic(item); } } } diff --git a/Assets/GothicVR/Scripts/Manager/MusicManager.cs b/Assets/GothicVR/Scripts/Manager/MusicManager.cs index 1f8f59046..698f6833e 100644 --- a/Assets/GothicVR/Scripts/Manager/MusicManager.cs +++ b/Assets/GothicVR/Scripts/Manager/MusicManager.cs @@ -191,9 +191,9 @@ public void SetMusic(string zone, Tags tags) if ((tags & Tags.Thr) != 0) musicTag = "THR"; - var musicName = $"{result}_{(isDay ? "DAY" : "NGT")}_{musicTag}"; + var musicThemeInstanceName = $"{result}_{(isDay ? "DAY" : "NGT")}_{musicTag}"; - var theme = AssetCache.TryGetMusic(musicName); + var theme = AssetCache.TryGetMusic(musicThemeInstanceName); reloadTheme = pendingTheme.File != theme.File; pendingTheme = theme; @@ -201,30 +201,28 @@ public void SetMusic(string zone, Tags tags) hasPending = true; if (FeatureFlags.I.showMusicLogs) - Debug.Log($"Playing music: theme >{musicName}< from file >{theme.File}<"); + Debug.Log($"Playing music: MusicThemeInstance >{musicThemeInstanceName}< from file >{theme.File}<"); } - public void SetMusic(string segment, string themeName) + public void SetMusic(MusicThemeInstance theme) { - var theme = AssetCache.TryGetMusic(themeName); - reloadTheme = true; pendingTheme = theme; hasPending = true; if (FeatureFlags.I.showMusicLogs) - Debug.Log($"Playing music: theme >{themeName}< from file >{theme.File}<"); + Debug.Log($"[Music] Playing music from file >{theme.File}<."); } - public void SetMusic(string musicName) + public void SetMusic(string musicThemeInstanceName) { - var theme = AssetCache.TryGetMusic(musicName); + var theme = AssetCache.TryGetMusic(musicThemeInstanceName); reloadTheme = true; pendingTheme = theme; hasPending = true; if (FeatureFlags.I.showMusicLogs) - Debug.Log($"[Music] Playing music: theme >{musicName}< from file >{theme.File}<"); + Debug.Log($"[Music] Playing music: MusicThemeInstance >{musicThemeInstanceName}< from file >{theme.File}<"); } private void StopMusic()