Exemple #1
0
        public static List <AudioEntry> generateAudioFileNames()
        {
            List <AudioEntry> ret = new List <AudioEntry>();

            // list of audio languages to generate
            List <CardDefinitions.CardDefClass> languages = getLanguages();
            List <String> DuplicateFiles = new List <String>();

            // list of datas
            List <Dictionary <String, String> > data = CardGeneratorDB.Instance.getDataFromTable(CardGeneratorDB.TABLECardData);

            // for each audio language build filename
            foreach (CardDefinitions.CardDefClass language in languages)
            {
                foreach (Dictionary <String, String> item in data)
                {
                    AudioEntry newEntry = new AudioEntry();
                    newEntry.languageCode = language.LANGUAGECODE;
                    newEntry.text         = item[language.COLUMNSOURCE];
                    newEntry.filename     = generateFilename(newEntry.languageCode, newEntry.text);

                    if (!DuplicateFiles.Contains(newEntry.filename))
                    {
                        ret.Add(newEntry);
                        DuplicateFiles.Add(newEntry.filename);
                    }
                }
            }

            return(ret);
        }
Exemple #2
0
 public void ReloadWiseBank()
 {
     if (Application.isPlaying)
     {
         AudioEntry.ReloadWiseBank();
     }
 }
 public void Update()
 {
     if (manager == null)
     {
         return;
     }
     if (Entry == null)
     {
         Entry = manager.GetEntry(Sound);
     }
     if (Active)
     {
         if (Entry.Range.Y > 0 && (VectorMath.Distance(manager.ListenerPosition, Position) > Entry.Range.Y))
         {
             EnsureStopped();
         }
         else
         {
             TryMakeActive();
         }
     }
     else
     {
         EnsureStopped();
     }
     //Update properties
     if (Instance != null)
     {
         Instance.SetPosition(Position);
         Instance.SetPitch(Pitch);
     }
 }
Exemple #4
0
    void DrawEntryList(Dictionary <string, AudioEntry> dictionary)
    {
        if (dictionary == null)
        {
            return;
        }

        foreach (KeyValuePair <string, AudioEntry> pair in dictionary)
        {
            EditorGUILayout.BeginHorizontal("box");

            Color oldColor = GUI.color;

            if (pair.Key == displayId)
            {
                GUI.color = Color.yellow;
            }

            if (GUILayout.Button(pair.Value.type.ToString() + " : " + pair.Key))
            {
                displayId = pair.Key;
                TrySelectAsset(pair.Value.path);
                currentAudioEntry = pair.Value;
            }

            GUI.color = oldColor;
            EditorGUILayout.EndHorizontal();
        }
    }
Exemple #5
0
        public void Load(Stream stream)
        {
            CanSave = true;

            Text = FileName;

            bars = new BarsLib.BARS(stream);

            if (bars.HasMetaData)
            {
                Nodes.Add("Meta Data");
            }

            if (bars.HasAudioFiles)
            {
                Nodes.Add(new AudioFolder("Audio"));
            }

            for (int i = 0; i < bars.AudioEntries.Count; i++)
            {
                var amtaWrapper = new MetaDataNodeWrapper(bars.AudioEntries[i].MetaData);
                amtaWrapper.ImageKey         = "MetaInfo";
                amtaWrapper.SelectedImageKey = amtaWrapper.ImageKey;

                string audioName = bars.AudioEntries[i].MetaData.Name;

                amtaWrapper.Text = $"{audioName}.amta";
                Nodes[0].Nodes.Add(amtaWrapper);

                if (bars.AudioEntries[i].AudioFile != null)
                {
                    BARSAudioFile audio = bars.AudioEntries[i].AudioFile;

                    AudioEntry node = new AudioEntry();
                    node.audioFile = audio;
                    node.Magic     = audio.Magic;
                    node.SetupMusic();

                    if (audio.Magic == "FWAV")
                    {
                        node.Text = audioName + ".bfwav";
                    }
                    else if (audio.Magic == "FSTP")
                    {
                        node.Text = audioName + ".bfstp";
                    }
                    else if (audio.Magic == "BWAV")
                    {
                        node.Text = audioName + ".bwav";
                    }
                    else
                    {
                        node.Text = $"{audioName}.{audio.Magic}";
                    }

                    Nodes[1].Nodes.Add(node);
                }
            }
        }
    void InitAllAudio()
    {
        CreateHandler("MusicHandler", ref m_MusicHandler);
        CreateHandler("Player1SFXHandler", ref m_Player1SFXHandler);
        CreateHandler("Player2SFXHandler", ref m_Player2SFXHandler);
        CreateHandler("UISFXHandler", ref m_UISFXHandler);
        CreateHandler("VoiceSFXHandler", ref m_VoiceSFXHandler);

        InitSFXAudioSource(ref m_Player1SFXHandler, ref m_Player1WhiffSFXAudioSource, m_SFXMixerGroup, true);
        InitSFXAudioSource(ref m_Player1SFXHandler, ref m_Player1AttackSFXAudioSource, m_SFXMixerGroup, true);
        InitSFXAudioSource(ref m_Player1SFXHandler, ref m_Player1HeavyHitGruntSFXAudioSource, m_SFXMixerGroup, true);

        InitSFXAudioSource(ref m_Player2SFXHandler, ref m_Player2WhiffSFXAudioSource, m_SFXMixerGroup, true);
        InitSFXAudioSource(ref m_Player2SFXHandler, ref m_Player2AttackSFXAudioSource, m_SFXMixerGroup, true);
        InitSFXAudioSource(ref m_Player2SFXHandler, ref m_Player2HeavyHitGruntSFXAudioSource, m_SFXMixerGroup, true);

        InitSFXAudioSource(ref m_VoiceSFXHandler, ref m_VoiceSFXAudioSource, m_VoiceMixerGroup, true);

        List <SceneSettings> allSceneSettings = ScenesConfig.GetAllSceneSettings();

        for (int i = 0; i < allSceneSettings.Count; i++)
        {
            AudioEntry musicEntry = allSceneSettings[i].m_MusicSettings.m_MusicEntry;
            if (musicEntry.m_Clip != null)
            {
                AudioSource musicAudioSource = CreateAudioSource(ref m_MusicHandler, m_MusicMixerGroup, false, musicEntry.m_Clip);
                musicAudioSource.volume = musicEntry.m_Volume;
                musicAudioSource.loop   = true;
                m_MusicAudioSources.Add(allSceneSettings[i].m_Scene, new MusicInfo(allSceneSettings[i].m_MusicSettings, musicAudioSource));
            }
        }

        foreach (EUISFXType sfxType in Enum.GetValues(typeof(EUISFXType)))
        {
            AudioEntry sfxEntry = m_UISFX.GetSFX(sfxType);
            if (sfxEntry.m_Clip != null)
            {
                AudioSource SFXTypeAudioSource = CreateAudioSource(ref m_UISFXHandler, m_SFXMixerGroup, false, sfxEntry.m_Clip);
                SFXTypeAudioSource.volume = sfxEntry.m_Volume;
                m_UIAudioSources.Add(sfxType, SFXTypeAudioSource);
            }
        }

        foreach (EAnimSFXType sfxType in Enum.GetValues(typeof(EAnimSFXType)))
        {
            AudioEntry sfxEntry = m_AnimSFX[(int)sfxType].m_SFX;
            if (sfxEntry.m_Clip != null)
            {
                AudioSource p1AnimSFXTypeAudioSource = CreateAudioSource(ref m_Player1SFXHandler, m_SFXMixerGroup, true, sfxEntry.m_Clip);
                p1AnimSFXTypeAudioSource.volume = sfxEntry.m_Volume;

                AudioSource p2AnimSFXTypeAudioSource = CreateAudioSource(ref m_Player2SFXHandler, m_SFXMixerGroup, true, sfxEntry.m_Clip);
                p2AnimSFXTypeAudioSource.volume = sfxEntry.m_Volume;

                m_Player1AnimSFXAudioSources.Add(sfxType, p1AnimSFXTypeAudioSource);
                m_Player2AnimSFXAudioSources.Add(sfxType, p2AnimSFXTypeAudioSource);
            }
        }
    }
    public void PlayVoiceSFX(EVoiceSFXType voiceSFXType)
    {
        AudioEntry voiceEntry = m_VoiceSFX.GetSFX(voiceSFXType);

        m_VoiceSFXAudioSource.clip   = voiceEntry.m_Clip;
        m_VoiceSFXAudioSource.volume = voiceEntry.m_Volume;
        m_VoiceSFXAudioSource.Play();
    }
Exemple #8
0
    public void AddAudioClip(AudioClip clip)
    {
        AudioEntry entry = new AudioEntry();

        entry.audioName = clip.name;
        entry.clip      = clip;
        audioEntries.Add(entry);
    }
Exemple #9
0
        public void Load(Stream stream)
        {
            CanSave = true;

            Text = FileName;

            bars = new BarsLib.BARS(stream);

            if (bars.AmtaList.Count > 0)
            {
                Nodes.Add("AMTA");
            }

            if (bars.audioList.Count > 0)
            {
                Nodes.Add("Audio");
            }

            for (int i = 0; i < bars.AmtaList.Count; i++)
            {
                var    amtaWrapper = new MetaDataNodeWrapper(bars.AmtaList[i]);
                string audioName   = bars.AmtaList[i].Name;

                amtaWrapper.Text = $"{audioName}.amta";
                Nodes[0].Nodes.Add(amtaWrapper);

                if (bars.audioList.Count > 0)
                {
                    BARSAudioFile audio = bars.audioList[i];

                    AudioEntry node = new AudioEntry();
                    node.Type = audio.AudioType;
                    node.Data = audio.data;
                    node.SetupMusic();

                    if (audio.AudioType == AudioType.Bfwav)
                    {
                        node.Text = audioName + ".bfwav";
                    }
                    else if (audio.AudioType == AudioType.Bfstp)
                    {
                        node.Text = audioName + ".bfstp";
                    }
                    else
                    {
                        node.Text = audioName + ".UNKOWN";
                    }

                    Nodes[1].Nodes.Add(node);
                }
            }

            ContextMenu = new ContextMenu();
            MenuItem save = new MenuItem("Save");

            ContextMenu.MenuItems.Add(save);
            save.Click += Save;
        }
        private static AudioEntry GetAudioEntry(AudioCategory category)
        {
            AudioEntry audioEntry = AudioEntries.Find(entry => !entry.AudioSource.isPlaying) ?? AddAudioEntry();

            audioEntry.Id       = _idCounter++;
            audioEntry.Category = category;

            return(audioEntry);
        }
        /// <summary>
        /// Stops all audio sources playing the provided audio clip.
        /// </summary>
        /// <param name="audioId">The audio ID to stop.</param>
        public static void Stop(AudioId audioId)
        {
            AudioEntry audioEntry = AudioEntries.Find(entry => entry.Id == audioId);

            if (audioEntry != null)
            {
                audioEntry.AudioSource.Stop();
            }
        }
Exemple #12
0
        public AudioClipData(AudioEntry audioEntry)
        {
            this.loadLevel = audioEntry.loadLevel;
            this.path      = audioEntry.path;
            this.type      = audioEntry.type;

            this.loadType = audioEntry.loadType;

            this.inherentVolume = audioEntry.inherentVolume;
        }
Exemple #13
0
    void Awake()
    {
        int count = audioEntries.Count;

        for (int i = 0; i < count; i++)
        {
            AudioEntry entry = audioEntries[i];
            clipMap.Add(entry.audioName, entry.clip);
        }
    }
Exemple #14
0
 /// <summary>
 /// Remove one specific entry from the library
 /// </summary>
 /// <param name="entry">Entry to remove</param>
 public void RemoveEntry(AudioEntry entry)
 {
     if (entry != null)
     {
         if (Entries.Contains(entry))
         {
             Entries.Remove(entry);
             SaveLibrary();
         }
     }
 }
Exemple #15
0
 /// <summary>
 /// Adds an entry to the library
 /// </summary>
 /// <param name="entry">Entry to add</param>
 public void AddEntry(AudioEntry entry)
 {
     if (entry != null)
     {
         if (!Entries.Contains(entry))
         {
             Entries.Add(entry);
             SaveLibrary();
         }
     }
 }
    private void PlaySFX(EProjectileSFXType projectileSFXType)
    {
        AudioEntry sfxEntry = m_ProjectileSFX.GetSFX(m_ProjectileType, projectileSFXType);

        if (sfxEntry != null)
        {
            m_AudioSource.clip   = sfxEntry.m_Clip;
            m_AudioSource.volume = sfxEntry.m_Volume;
            m_AudioSource.loop   = projectileSFXType == EProjectileSFXType.Movement;
            m_AudioSource.Play();
        }
    }
        private static AudioEntry AddAudioEntry()
        {
            AudioEntry audioEntry = new AudioEntry
            {
                AudioSource = Camera.AddComponent <AudioSource>(),
            };

            AudioEntries.Add(audioEntry);

            Log.Info($"Adding additional audio entry (there are now {Log.Cyan(AudioEntries.Count)} audio entries).", LogCategory.AudioManager);
            return(audioEntry);
        }
 public void PlayWhiffSFX(int playerIndex, EWhiffSFXType whiffSFXType)
 {
     if (whiffSFXType != EWhiffSFXType.None)
     {
         EAttackSFXType attackSFXType   = ConvertWhiffToAttackSFXType(whiffSFXType);
         AudioSource    sourceToPlay    = (playerIndex == 0) ? m_Player1WhiffSFXAudioSource : m_Player2WhiffSFXAudioSource;
         AudioEntry[]   attackSFXList   = m_AttackSFX[(int)attackSFXType].m_SFXList;
         AudioEntry     attackSFXToPlay = attackSFXList[Random.Range(0, attackSFXList.Length)];
         sourceToPlay.clip   = attackSFXToPlay.m_Clip;
         sourceToPlay.volume = attackSFXToPlay.m_Volume;
         sourceToPlay.Play();
     }
 }
        /// <summary>
        /// Play a provided audio clip. An audio source will be automatically selected.
        /// </summary>
        /// <param name="audioClip">The audio clip to play.</param>
        /// <param name="category">The category of the audio clip. See <see cref="AudioCategory"/> for available categories.</param>
        /// <param name="volume">The volume the audio clip should be played at.</param>
        /// <param name="loop">Whether or not the the audio clip loop.</param>
        /// <param name="pitch">The pitch the audio clip should be played at.</param>
        /// <returns>The id of the playing audio.</returns>
        public static AudioId Play(AudioClip audioClip, AudioCategory category, float volume = 0.75f, bool loop = false,
                                   float pitch = 1.0f)
        {
            AudioEntry audioEntry = GetAudioEntry(category);

            audioEntry.AudioSource.clip   = audioClip;
            audioEntry.AudioSource.volume = volume * AudioCategoryVolumes[(int)category];
            audioEntry.AudioSource.loop   = loop;
            audioEntry.AudioSource.pitch  = pitch;
            audioEntry.AudioSource.Play();

            Log.Info($"Playing {Log.Orange(audioClip.name)} (volume = {Log.Cyan(volume)}, loop = {Log.Cyan(loop)}) using audio entry {Log.Cyan(AudioEntries.IndexOf(audioEntry))}.", LogCategory.AudioManager);
            return(audioEntry.Id);
        }
Exemple #20
0
        public void ParseAudioEntryTest4()
        {
            AudioEntry       audioEntry = new AudioEntry();
            short            audioPid   = 256;
            string           lang1      = "deu";
            string           lang2      = "spa";
            Nullable <short> audioType  = 4;
            string           expected   = CreateAudioString(audioPid, lang1, lang2, audioType);

            audioEntry.ParseAudioEntry(expected);
            Assert.AreEqual(audioPid, audioEntry.AudioPID);
            Assert.AreEqual(lang1, audioEntry.Lang1);
            Assert.AreEqual(lang2, audioEntry.Lang2);
            Assert.AreEqual(audioType, audioEntry.AudioType);
            Assert.AreEqual(expected, audioEntry.ToString());
        }
Exemple #21
0
    public void PlaySound(int index, int volume = 0, int pan = 0)
    {
        if (index >= audioClips.Length)
        {
            Debug.LogWarning("PlaySound: FAILED to due out of clip range!");
            return;
        }

        mut.WaitOne();
        AudioEntry entry = new AudioEntry();

        entry.clip   = audioClips[index];
        entry.volume = 255 - volume;
        entry.pan    = pan;
        newClips.Add(entry);
        GlobalMembers.Sound[index].num++;
        mut.ReleaseMutex();
    }
Exemple #22
0
        public void Load()
        {
            IsActive = true;
            CanSave  = true;

            Text = FileName;

            bars = new BarsLib.BARS(new MemoryStream(Data));
            Nodes.Add("AMTA");
            Nodes.Add("Audio");
            for (int i = 0; i < bars.AmtaList.Count; i++)
            {
                string audioName = bars.AmtaList[i].Name;

                Nodes[0].Nodes.Add(audioName + ".amta");
                BARSAudioFile audio = bars.audioList[i];

                AudioEntry node = new AudioEntry();
                node.Type = audio.AudioType;
                node.Data = audio.data;
                node.SetupMusic();

                if (audio.AudioType == AudioType.Bfwav)
                {
                    node.Text = audioName + ".bfwav";
                }
                else if (audio.AudioType == AudioType.Bfstp)
                {
                    node.Text = audioName + ".bfstp";
                }
                else
                {
                    node.Text = audioName + ".UNKOWN";
                }

                Nodes[1].Nodes.Add(node);
            }

            ContextMenu = new ContextMenu();
            MenuItem save = new MenuItem("Save");

            ContextMenu.MenuItems.Add(save);
            save.Click += Save;
        }
Exemple #23
0
    void DrawEditor()
    {
        EditorGUILayout.BeginVertical("box", GUILayout.Width(280), GUILayout.Height(500));

        if (pathList != null && pathList.Count > 0)
        {
            DrawEntryBoard(pathList);

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.Space();

            if (GUILayout.Button("Next"))
            {
                if (AudioDataManagerWizardWindow.registry != null && AudioDataManagerWizardWindow.registry.data != null && (AudioDataManagerWizardWindow.registry.data.ContainsKey(displayId) || (displayId == "")))
                {
                    EditorUtility.DisplayDialog("Invalid Key", "The ID must be unique and not string.Empty", "Ok");
                    return;
                }
                else
                {
                    AudioDataManagerWizardWindow.registry.data.Add(displayId, currentAudioEntry);
                    displayId         = "";
                    currentAudioEntry = null;
                    pathList.RemoveAt(0);
                }
            }

            EditorGUILayout.Space();
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.Space();

        EditorGUILayout.BeginVertical("ShurikenEffectBg");
        mainScroll = EditorGUILayout.BeginScrollView(mainScroll);

        DrawEntryQueue();

        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();

        EditorGUILayout.EndVertical();
    }
 public void Update()
 {
     if (manager == null)
     {
         return;
     }
     if (Entry == null)
     {
         Entry = manager.GetEntry(Sound);
     }
     if (Active)
     {
         if (Entry.Range.Y > 0 && (Vector3.Distance(manager.ListenerPosition, Position) > Entry.Range.Y))
         {
             EnsureStopped();
         }
         else
         {
             TryMakeActive();
         }
         if (PlayOnce && Played && !(Instance?.Playing ?? false))
         {
             EnsureStopped();
             Active = false;
         }
     }
     else
     {
         EnsureStopped();
     }
     //Update properties
     if (Instance != null)
     {
         Instance.SetPosition(Position);
         Instance.SetVelocity(Velocity);
         Instance.SetAttenuation(Attenuation);
         Instance.SetPitch(Pitch);
         Instance.UpdateProperties();
     }
 }
Exemple #25
0
        public void Load(System.IO.Stream stream)
        {
            Text = FileName;

            using (var reader = new FileReader(stream))
            {
                uint magic         = reader.ReadUInt32();
                uint audioInfoSize = reader.ReadUInt32();

                reader.SeekBegin(48);
                uint numEntries = reader.ReadUInt32();

                uint audioOffset = audioInfoSize + 12;
                for (int i = 0; i < numEntries; i++)
                {
                    AudioEntry entry = new AudioEntry();
                    entry.ImageKey         = "bfwav";
                    entry.SelectedImageKey = "bfwav";
                    Nodes.Add(entry);

                    entry.HashID = reader.ReadUInt32();
                    uint alignment = reader.ReadUInt32();
                    uint AudioSize = reader.ReadUInt32();
                    uint unk       = reader.ReadUInt32();
                    reader.ReadUInt32(); //0

                    entry.Text = entry.HashID.ToString("X") + ".wem";

                    using (reader.TemporarySeek(audioOffset, System.IO.SeekOrigin.Begin))
                    {
                        reader.Align((int)alignment);
                        entry.AudioData = reader.ReadBytes((int)AudioSize);
                        audioOffset     = (uint)reader.Position;
                    }
                }
            }
        }
Exemple #26
0
        public void Load()
        {
            IsActive = true;
            CanSave  = true;

            bars       = new BarsLib.BARS(new MemoryStream(Data));
            EditorRoot = new TreeNodeFile(FileName, this);
            EditorRoot.Nodes.Add("AMTA");
            EditorRoot.Nodes.Add("Audio");
            for (int i = 0; i < bars.AmtaList.Count; i++)
            {
                string audioName = bars.AmtaList[i].Name;

                EditorRoot.Nodes[0].Nodes.Add(audioName + ".amta");
                BARSAudioFile audio = bars.audioList[i];

                AudioEntry node = new AudioEntry();
                node.Type = audio.AudioType;
                node.Data = audio.data;
                node.SetupMusic();

                if (audio.AudioType == AudioType.Bfwav)
                {
                    node.Text = audioName + ".bfwav";
                }
                else if (audio.AudioType == AudioType.Bfstp)
                {
                    node.Text = audioName + ".bfstp";
                }
                else
                {
                    node.Text = audioName + ".UNKOWN";
                }

                EditorRoot.Nodes[1].Nodes.Add(node);
            }
        }
    public void PlayHitSFX(int playerVictimIndex, EAttackSFXType attackSFXType, bool isProjectileAttack)
    {
        AudioSource sourceToPlay = (playerVictimIndex == 0) ? m_Player1AttackSFXAudioSource : m_Player2AttackSFXAudioSource;

        AudioEntry[] attackSFXList   = m_AttackSFX[(int)attackSFXType].m_SFXList;
        AudioEntry   attackSFXToPlay = attackSFXList[Random.Range(0, attackSFXList.Length)];

        sourceToPlay.clip   = attackSFXToPlay.m_Clip;
        sourceToPlay.volume = attackSFXToPlay.m_Volume;
        sourceToPlay.Play();

        // If projectile attack, stop whiff only on victim, else on both players
        if (isProjectileAttack)
        {
            AudioSource whiffSourceToStop = (playerVictimIndex == 0) ? m_Player1WhiffSFXAudioSource : m_Player2WhiffSFXAudioSource;
            whiffSourceToStop.Stop();
        }
        else
        {
            m_Player1WhiffSFXAudioSource.Stop();
            m_Player2WhiffSFXAudioSource.Stop();
        }

        if (attackSFXType == EAttackSFXType.Hit_Heavy)
        {
            float random = Random.Range(0f, 1f);
            if (random <= m_HeavyHitGruntSFX.m_GruntProbability)
            {
                AudioSource gruntSourceToPlay = (playerVictimIndex == 0) ? m_Player1HeavyHitGruntSFXAudioSource : m_Player2HeavyHitGruntSFXAudioSource;
                AudioEntry  gruntSFXToPlay    = m_HeavyHitGruntSFX.m_GruntSFX[Random.Range(0, m_HeavyHitGruntSFX.m_GruntSFX.Length)];
                gruntSourceToPlay.clip   = gruntSFXToPlay.m_Clip;
                gruntSourceToPlay.volume = gruntSFXToPlay.m_Volume;
                gruntSourceToPlay.Play();
            }
        }
    }
Exemple #28
0
        public void Load(System.IO.Stream stream)
        {
            Sounds.Clear();

            _stream = stream;
            Text    = FileName;
            CanSave = true;

            using (var reader = new FileReader(stream, true))
            {
                reader.ReadSignature(4, "AKPK");
                //Total size of language, banks, and sound headers
                uint HeaderSize = reader.ReadUInt32();
                Flags = reader.ReadUInt32();
                uint LanguageSize = reader.ReadUInt32();
                uint BanksSize    = reader.ReadUInt32();
                uint SoundsSize   = reader.ReadUInt32();

                uint SectionSizes = LanguageSize + BanksSize + SoundsSize + 0x10;
                if (SectionSizes == HeaderSize)
                {
                    Version = 1;
                }
                else
                {
                    Version = 2;
                    uint Section4 = reader.ReadUInt32();
                }

                //Parse sections

                //Parse language
                long LanguagePos   = reader.Position;
                uint LanguageCount = reader.ReadUInt32();
                for (int i = 0; i < LanguageCount; i++)
                {
                    var  lang       = new LanguageEntry();
                    uint nameOffset = reader.ReadUInt32();;
                    lang.ID = reader.ReadUInt32();
                    Languages.Add(lang);

                    using (reader.TemporarySeek(LanguagePos + nameOffset, System.IO.SeekOrigin.Begin)) {
                        lang.Name = reader.ReadZeroTerminatedString();
                    }
                }

                reader.SeekBegin(LanguagePos + LanguageSize);

                //Parse bansk
                long banksPos   = reader.Position;
                uint BanksCount = reader.ReadUInt32();
                for (int i = 0; i < BanksCount; i++)
                {
                    Banks.Add(new BankEntry());
                }
                reader.SeekBegin(banksPos + BanksSize);

                //Parse sounds
                long soundPos    = reader.Position;
                uint SoundsCount = reader.ReadUInt32();
                Console.WriteLine($"SoundsCount {SoundsCount}");
                for (int i = 0; i < SoundsCount; i++)
                {
                    var entry = new AudioEntry();
                    Sounds.Add(entry);

                    entry.HashID    = reader.ReadUInt32();
                    entry.Alignment = reader.ReadUInt32();
                    uint size   = reader.ReadUInt32();
                    uint offset = reader.ReadUInt32();
                    entry.LanguageID = reader.ReadUInt32();

                    entry.FileName       = entry.HashID.ToString("X") + ".wem";
                    entry.FileDataStream = new SubStream(reader.BaseStream, offset * entry.Alignment, size);
                }

                reader.SeekBegin(soundPos + SoundsSize);
            }
        }
Exemple #29
0
    void DrawEntryBoard(Dictionary <string, AudioEntry> dictionary)
    {
        if (dictionary == null)
        {
            return;
        }

        if (displayId != "" && currentAudioEntry == null)
        {
            if (dictionary.TryGetValue(displayId, out currentAudioEntry))
            {
            }
        }

        if (currentAudioEntry == null)
        {
            currentAudioEntry = new AudioEntry( );
        }

        EditorGUILayout.BeginVertical("box", GUILayout.Width(200));

        string key = displayId, path = currentAudioEntry.path;
        int    loadLevel = currentAudioEntry.loadLevel;


        AudioType type = currentAudioEntry.type;

        EditorGUILayout.BeginHorizontal();

        EditorGUILayout.LabelField(new GUIContent("ID:"), GUILayout.Width(50));
        key = EditorGUILayout.TextField(key);

        EditorGUILayout.EndHorizontal();


        EditorGUILayout.BeginHorizontal();

        EditorGUILayout.LabelField(new GUIContent("Path:"), GUILayout.Width(50));

        Color oldColor = GUI.color;

        GUI.color = Color.yellow;
        EditorGUILayout.LabelField(path);

        GUI.color = oldColor;

        EditorGUILayout.EndHorizontal();
        if (GUILayout.Button("Get Asset Path"))
        {
            Object selectedObj = Selection.activeObject;

            if (selectedObj != null)
            {
                AudioClip audioClip = (AudioClip)selectedObj;

                if (audioClip != null)
                {
                    path = AssetDatabase.GetAssetPath(audioClip.GetInstanceID());
                    DebugWrapper.Log(path);
                    string[] pathSplitted = path.Split('/');

                    bool startAdding = false;

                    string fileName = "";

                    for (int splitedIndex = 0; splitedIndex < pathSplitted.Length; splitedIndex++)
                    {
                        if (startAdding)
                        {
                            fileName += pathSplitted [splitedIndex] + "/";
                        }

                        if (pathSplitted [splitedIndex] == "Resources")
                        {
                            startAdding = true;
                        }
                    }

                    string[] fileNameSplited = fileName.Split('.');
                    path = fileNameSplited[0];

                    DebugWrapper.Log(path);
                }
            }
        }

        float inherentVolume = currentAudioEntry.inherentVolume;

        EditorGUILayout.BeginHorizontal();

        EditorGUILayout.LabelField(new GUIContent("Volume:"), GUILayout.Width(50));
        inherentVolume = EditorGUILayout.Slider(inherentVolume, 0.0f, 1.0f);

        EditorGUILayout.EndHorizontal();

        currentAudioEntry.inherentVolume = inherentVolume;


        EditorGUILayout.BeginHorizontal();

        EditorGUILayout.LabelField(new GUIContent("Load Level:"), GUILayout.Width(60));
        loadLevel = EditorGUILayout.IntField(loadLevel, GUILayout.Width(15));

        AudioClipLoadType aclt = currentAudioEntry.loadType;

        EditorGUILayout.Space();

        EditorGUILayout.LabelField(new GUIContent("Type:"), GUILayout.Width(30));

        aclt = (AudioClipLoadType)EditorGUILayout.EnumPopup(aclt, GUILayout.Width(140));

        currentAudioEntry.loadType = aclt;

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();

        EditorGUILayout.LabelField(new GUIContent("Type:"));

        type = (AudioType)EditorGUILayout.EnumPopup(type, GUILayout.Width(50));

        EditorGUILayout.EndHorizontal();


        EditorGUILayout.EndVertical();

        displayId = key;
        currentAudioEntry.path      = path;
        currentAudioEntry.loadLevel = loadLevel;
        currentAudioEntry.type      = type;
    }
 public MusicInfo(MusicSettings settings, AudioSource source)
 {
     m_MusicSettings = settings;
     m_MusicEntry    = settings.m_MusicEntry;
     m_MusicSource   = source;
 }