Esempio n. 1
0
        private void SaveLUT(ExtractFlags flags, string basePath, string part, string fname, ulong key, string ocioPath, MapInfo mapInfo)
        {
            if (!Directory.Exists(Path.Combine(basePath, part)))
            {
                Directory.CreateDirectory(Path.Combine(basePath, part));
            }

            if (key == 0)
            {
                return;
            }

            using (Stream lutStream = OpenFile(key))
            {
                if (lutStream == null)
                {
                    return;
                }

                lutStream.Position = 128;

                string lut = LUT.SPILUT1024x32(lutStream);
                using (Stream spilut = File.OpenWrite(Path.Combine(basePath, part, $"{fname}.spi3d")))
                    using (TextWriter spilutWriter = new StreamWriter(spilut))
                    {
                        spilutWriter.WriteLine(lut);
                        using (TextWriter ocioWriter = File.AppendText(Path.Combine(ocioPath)))
                        {
                            ocioWriter.WriteLine(OCIOChunk(mapInfo, fname));
                        }
                    }
            }
        }
Esempio n. 2
0
        private void SaveTex(ExtractFlags flags, string basePath, string part, string filename, ulong key)
        {
            if (key == 0)
            {
                return;
            }

            FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo();
            FindLogic.Combo.Find(info, key);
            info.SetTextureName(key, filename);
            SaveLogic.Combo.SaveTexture(flags, Path.Combine(basePath, part), info, key);
        }
Esempio n. 3
0
        private void SaveSound(ExtractFlags flags, string basePath, string part, ulong key)
        {
            STU_F3EB00D4 stu = GetInstance <STU_F3EB00D4>(key); // todo: should be named

            if (stu == null || stu.m_B3685B0D == 0)
            {
                return;
            }
            FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo();
            FindLogic.Combo.Find(info, stu.m_B3685B0D);
            SaveLogic.Combo.SaveSound(flags, Path.Combine(basePath, part), info, stu.m_B3685B0D);
        }
Esempio n. 4
0
        private void SaveMdl(ExtractFlags flags, string basePath, string part, ulong model, ulong modelLook)
        {
            if (model == 0 || modelLook == 0)
            {
                return;
            }

            FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo();
            FindLogic.Combo.Find(info, model);
            FindLogic.Combo.Find(info, modelLook);
            SaveLogic.Combo.Save(flags, Path.Combine(basePath, part), info);
            SaveLogic.Combo.SaveAllModelLooks(flags, Path.Combine(basePath, part), info);
            SaveLogic.Combo.SaveAllMaterials(flags, Path.Combine(basePath, part), info);
        }
Esempio n. 5
0
        private void SaveSound(ExtractFlags flags, string basePath, string part, ulong key)
        {
            STU_F3EB00D4 stu = GetInstance <STU_F3EB00D4>(key);

            if (stu == null || stu.SoundResource == 0)
            {
                return;
            }
            FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo();
            info.SaveRuntimeData = new FindLogic.Combo.ComboSaveRuntimeData {
                Threads = false
            };
            FindLogic.Combo.Find(info, stu.SoundResource);
            SaveLogic.Combo.SaveSound(flags, Path.Combine(basePath, part), info, stu.SoundResource);
        }
Esempio n. 6
0
        private void SaveEntity(ExtractFlags flags, string basePath, string part, ulong key)
        {
            FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo();
            FindLogic.Combo.Find(info, key);

            string soundDirectory = Path.Combine(basePath, part, "Sound");

            foreach (KeyValuePair <ulong, FindLogic.Combo.SoundFileInfo> soundFile in info.SoundFiles)
            {
                SaveLogic.Combo.SaveSoundFile(flags, soundDirectory, info, soundFile.Key, false);
            }

            foreach (KeyValuePair <ulong, FindLogic.Combo.SoundFileInfo> soundFile in info.VoiceSoundFiles)
            {
                SaveLogic.Combo.SaveSoundFile(flags, soundDirectory, info, soundFile.Key, true);
            }

            SaveLogic.Combo.Save(flags, Path.Combine(basePath, part), info);
        }
Esempio n. 7
0
        private void SaveMdl(ExtractFlags flags, string basePath, string part, ulong model, ulong modelLook)
        {
            if (model == 0 || modelLook == 0)
            {
                return;
            }

            FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo();
            FindLogic.Combo.Find(info, model);
            FindLogic.Combo.Find(info, modelLook);

            var context = new Combo.SaveContext(info)
            {
                m_saveAnimationEffects = false
            };

            SaveLogic.Combo.Save(flags, Path.Combine(basePath, part), context);
            SaveLogic.Combo.SaveAllModelLooks(flags, Path.Combine(basePath, part), context);
            SaveLogic.Combo.SaveAllMaterials(flags, Path.Combine(basePath, part), context);
            context.Wait();
        }
Esempio n. 8
0
        private void SaveEntity(ExtractFlags flags, string basePath, string part, ulong key)
        {
            FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo();
            FindLogic.Combo.Find(info, key);

            string soundDirectory = Path.Combine(basePath, part, "Sound");

            var context = new Combo.SaveContext(info);

            foreach (KeyValuePair <ulong, FindLogic.Combo.SoundFileAsset> soundFile in info.m_soundFiles)
            {
                SaveLogic.Combo.SaveSoundFile(flags, soundDirectory, context, soundFile.Key, false);
            }

            foreach (KeyValuePair <ulong, FindLogic.Combo.SoundFileAsset> soundFile in info.m_voiceSoundFiles)
            {
                SaveLogic.Combo.SaveSoundFile(flags, soundDirectory, context, soundFile.Key, true);
            }

            SaveLogic.Combo.Save(flags, Path.Combine(basePath, part), context);
            context.Wait();
        }
Esempio n. 9
0
        public static bool SaveVoiceSet(ExtractFlags flags, string basePath, string heroName, ulong?voiceSetGuid, ref Combo.ComboInfo info, Combo.ComboInfo baseCombo = null, Dictionary <ulong, ulong> replacements = null, bool ignoreGroups = false)
        {
            if (voiceSetGuid == null)
            {
                return(false);
            }

            info = new Combo.ComboInfo();
            Combo.Find(info, voiceSetGuid.Value, replacements);

            // if we're processing a skin, baseCombo is the combo from the hero, this remove duplicate check removes any sounds that belong to the base hero
            // this ensures you only get sounds unique to the skin when processing a skin
            if (baseCombo != null)
            {
                if (!Combo.RemoveDuplicateVoiceSetEntries(baseCombo, ref info, voiceSetGuid.Value, Combo.GetReplacement(voiceSetGuid.Value, replacements)))
                {
                    return(false);
                }
            }

            foreach (var voiceSet in info.m_voiceSets)
            {
                if (voiceSet.Value.VoiceLineInstances == null)
                {
                    continue;
                }

                foreach (var voicelineInstanceInfo in voiceSet.Value.VoiceLineInstances)
                {
                    foreach (var voiceLineInstance in voicelineInstanceInfo.Value)
                    {
                        var stimulus = GetInstance <STUVoiceStimulus>(voiceLineInstance.VoiceStimulus);
                        if (stimulus == null)
                        {
                            continue;
                        }

                        var groupName = GetVoiceGroup(voiceLineInstance.VoiceStimulus, stimulus.m_category, stimulus.m_87DCD58E);
                        if (groupName == null)
                        {
                            groupName = $"Unknown\\{teResourceGUID.Index(voiceLineInstance.VoiceStimulus):X}.{teResourceGUID.Type(voiceLineInstance.VoiceStimulus):X3}";
                        }

                        var soundFilesCombo   = new Combo.ComboInfo();
                        var soundFilesContext = new SaveLogic.Combo.SaveContext(soundFilesCombo);

                        foreach (var soundFile in voiceLineInstance.SoundFiles)
                        {
                            Combo.Find(soundFilesCombo, soundFile);
                        }

                        var path = flags.VoiceGroupByHero && flags.VoiceGroupByType
                                       ? Path.Combine(basePath, heroName, groupName)
                                       : Path.Combine(basePath, flags.VoiceGroupByHero ? Path.Combine(groupName, heroName) : groupName);

                        if (ignoreGroups)
                        {
                            path = Path.Combine(basePath, heroName);
                        }

                        foreach (var soundInfo in soundFilesCombo.m_voiceSoundFiles.Values)
                        {
                            var filename = soundInfo.GetName();
                            if (!flags.VoiceGroupByHero && !ignoreGroups)
                            {
                                filename = $"{heroName}-{soundInfo.GetName()}";
                            }

                            if (SoundIdCache.Contains(soundInfo.m_GUID))
                            {
                                TACTLib.Logger.Debug("Tool", "Duplicate sound detected, ignoring.");
                                continue;
                            }

                            SoundIdCache.Add(soundInfo.m_GUID);
                            SaveLogic.Combo.SaveSoundFile(flags, path, soundFilesContext, soundInfo.m_GUID, true, filename);
                        }

                        soundFilesContext.Wait();
                    }
                }
            }

            return(true);
        }
Esempio n. 10
0
        private static bool SaveSet(ExtractFlags flags, string basePath, ulong entityMain, string heroNameActual, ref STUVoiceSetComponent voiceSetComponent, ref Combo.ComboInfo info, STUVoiceSetComponent baseComponent = null, Combo.ComboInfo baseCombo = null, Dictionary <ulong, ulong> replacements = null)
        {
            voiceSetComponent = GetInstance <STUVoiceSetComponent>(Combo.GetReplacement(entityMain, replacements));

            if (voiceSetComponent?.m_voiceDefinition == null)
            {
                return(false);
            }

            info = new Combo.ComboInfo();
            Combo.Find(info, Combo.GetReplacement(voiceSetComponent.m_voiceDefinition, replacements), replacements);
            if (baseComponent != null && baseCombo != null)
            {
                if (!Combo.RemoveDuplicateVoiceSetEntries(baseCombo, ref info, baseComponent.m_voiceDefinition, Combo.GetReplacement(voiceSetComponent.m_voiceDefinition, replacements)))
                {
                    return(false);
                }
            }

            foreach (var voiceSet in info.m_voiceSets)
            {
                if (voiceSet.Value.VoiceLineInstances == null)
                {
                    continue;
                }

                foreach (var voicelineInstanceInfo in voiceSet.Value.VoiceLineInstances)
                {
                    foreach (var voiceLineInstance in voicelineInstanceInfo.Value)
                    {
                        var stimulus = GetInstance <STUVoiceStimulus>(voiceLineInstance.VoiceStimulus);
                        if (stimulus == null)
                        {
                            continue;
                        }

                        var groupName = GetVoiceGroup(voiceLineInstance.VoiceStimulus, stimulus.m_category, stimulus.m_87DCD58E);
                        if (groupName == null)
                        {
                            groupName = $"Unknown\\{teResourceGUID.Index(voiceLineInstance.VoiceStimulus):X}.{teResourceGUID.Type(voiceLineInstance.VoiceStimulus):X3}";
                        }

                        var soundFilesCombo   = new Combo.ComboInfo();
                        var soundFilesContext = new SaveLogic.Combo.SaveContext(soundFilesCombo);

                        foreach (var soundFile in voiceLineInstance.SoundFiles)
                        {
                            Combo.Find(soundFilesCombo, soundFile);
                        }

                        var path = flags.VoiceGroupByHero && flags.VoiceGroupByType
                            ? Path.Combine(basePath, Container, heroNameActual, groupName)
                            : Path.Combine(basePath, Container, flags.VoiceGroupByHero ? Path.Combine(groupName, heroNameActual) : groupName);

                        foreach (var soundInfo in soundFilesCombo.m_voiceSoundFiles.Values)
                        {
                            var filename = soundInfo.GetName();
                            if (!flags.VoiceGroupByHero)
                            {
                                filename = $"{heroNameActual}-{soundInfo.GetName()}";
                            }

                            if (SoundIdCache.Contains(soundInfo.m_GUID))
                            {
                                TACTLib.Logger.Debug("Tool", "Duplicate sound detected, ignoring.");
                                continue;
                            }

                            SoundIdCache.Add(soundInfo.m_GUID);
                            SaveLogic.Combo.SaveSoundFile(flags, path, soundFilesContext, soundInfo.m_GUID, true, filename);
                        }

                        soundFilesContext.Wait();
                    }
                }
            }

            return(true);
        }