Example #1
0
        public static void Save(ICLIFlags flags, string directory, DataModels.Unlock unlock)
        {
            FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo();
            FindLogic.Combo.Find(info, unlock.GUID);

            bool saveAllTextures = false;

            try {
                info.m_textures.First(x => x.Value.m_loose).Value.m_name = unlock.Name;
                directory = Path.GetFullPath(Path.Combine(directory, ".."));
            } catch {
                // animated spray - no main image

                saveAllTextures = true;
            }

            var context = new Combo.SaveContext(info);

            Combo.SaveLooseTextures(flags, directory, context);
            if (!saveAllTextures)
            {
                context.Wait();
                return;
            }

            Combo.SaveAllMaterials(flags, directory, context);
            Combo.Save(flags, directory, context);
            context.Wait();
        }
Example #2
0
        public void ExtractType(ICLIFlags toolFlags)
        {
            string basePath;

            if (toolFlags is ExtractFlags flags)
            {
                basePath = flags.OutputPath + "\\Music";
            }
            else
            {
                throw new Exception("no output path");
            }

            foreach (ulong @ulong in TrackedFiles[0x2C])
            {
                STUSound music   = GetInstance <STUSound>(@ulong);
                var      s_class = music.m_C32C2195.m_wwiseBankID;
                if (music_types.ContainsKey(s_class))
                {
                    FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo();
                    var context = new Combo.SaveContext(info);
                    FindLogic.Combo.Find(info, @ulong);
                    SaveLogic.Combo.SaveAllSoundFiles(flags, Path.Combine(basePath, music_types[s_class]), context);
                    context.Wait();
                }
            }
        }
Example #3
0
        public static void Save(ICLIFlags flags, string directory, DataModels.Unlock unlock)
        {
            STUUnlock_PortraitFrame portraitFrame = (STUUnlock_PortraitFrame)unlock.STU;

            string tier = portraitFrame.m_rank.ToString();

            FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo();

            if (portraitFrame.m_rankTexture != null)
            {
                FindLogic.Combo.Find(info, portraitFrame.m_rankTexture);
                info.SetTextureName(portraitFrame.m_rankTexture, $"Star - {portraitFrame.m_stars}");
            }

            if (portraitFrame.m_949D9C2A != null)
            {
                FindLogic.Combo.Find(info, portraitFrame.m_949D9C2A);
                int borderNum = portraitFrame.m_level - portraitFrame.m_stars * 10 - (int)portraitFrame.m_rank * 10;

                if ((int)portraitFrame.m_rank > 1)
                {
                    borderNum -= 50 * ((int)portraitFrame.m_rank - 1);
                }
                borderNum -= 1;

                info.SetTextureName(portraitFrame.m_949D9C2A, $"Border - {borderNum}");
            }

            var context = new Combo.SaveContext(info);

            Combo.SaveLooseTextures(flags, Path.Combine(directory, tier), context);
            context.Wait();
        }
Example #4
0
        public static void SaveVoiceLines(ICLIFlags flags, HashSet <ulong> lines, VoiceSet voiceSet, string directory)
        {
            FindLogic.Combo.ComboInfo fakeComboInfo = new FindLogic.Combo.ComboInfo();
            var saveContext = new Combo.SaveContext(fakeComboInfo);

            foreach (ulong line in lines)
            {
                VoiceLineInstance voiceLineInstance = voiceSet.VoiceLines[line];

                SaveVoiceLine(flags, voiceLineInstance, directory, saveContext);
            }
            saveContext.Wait();
        }
Example #5
0
        public static void Save(ICLIFlags flags, string directory, DataModels.Unlock unlock)
        {
            FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo();
            FindLogic.Combo.Find(info, unlock.GUID);

            var context = new Combo.SaveContext(info)
            {
                m_saveAnimationEffects = false // todo: unsupported here due to relative paths used by OWEffect
            };

            Combo.Save(flags, directory, context);
            Combo.SaveAllAnimations(flags, directory, context);
            context.Wait();
        }
Example #6
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();
            var context = new Combo.SaveContext(info);

            FindLogic.Combo.Find(info, stu.m_B3685B0D);
            SaveLogic.Combo.SaveSound(flags, Path.Combine(basePath, part), context, stu.m_B3685B0D);
            context.Wait();
        }
Example #7
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);

            var context = new Combo.SaveContext(info);

            SaveLogic.Combo.SaveTexture(flags, Path.Combine(basePath, part), context, key);
            context.Wait();
        }
Example #8
0
        public static void SaveMaterial(string basePath, ulong materialGUID, string name)
        {
            string path    = Path.Combine(basePath, name, IO.GetFileName(materialGUID));
            string rawPath = Path.Combine(path, "raw");
            string imgPath = Path.Combine(path, "img");

            // IO.CreateDirectorySafe(path);
            IO.CreateDirectorySafe(rawPath);

            teMaterial material = new teMaterial(IO.OpenFile(materialGUID));

            IO.WriteFile(materialGUID, rawPath);
            IO.WriteFile(material.Header.ShaderSource, rawPath);
            IO.WriteFile(material.Header.ShaderGroup, rawPath);
            IO.WriteFile(material.Header.GUIDx03A, rawPath);
            IO.WriteFile(material.Header.MaterialData, rawPath);

            using (Stream stream = IO.OpenFile(material.Header.MaterialData)) {
                if (stream != null)
                {
                    teMaterialData materialData = new teMaterialData(stream);
                    if (materialData.Textures != null)
                    {
                        FindLogic.Combo.ComboInfo comboInfo = new FindLogic.Combo.ComboInfo();
                        foreach (var texture in materialData.Textures)
                        {
                            FindLogic.Combo.Find(comboInfo, texture.TextureGUID);
                            comboInfo.SetTextureName(texture.TextureGUID, texture.NameHash.ToString("X8"));
                        }

                        var context = new Combo.SaveContext(comboInfo);
                        Combo.SaveLooseTextures(null, imgPath, context);
                        context.Wait();
                    }
                }
            }

            teShaderGroup shaderGroup = new teShaderGroup(IO.OpenFile(material.Header.ShaderGroup));

            SaveShaderGroup(shaderGroup, path);
        }
Example #9
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();
        }
Example #10
0
        public void ExtractMOVI(ICLIFlags toolFlags)
        {
            string       basePath;
            ExtractFlags flags = toolFlags as ExtractFlags;

            basePath = flags?.OutputPath;
            if (string.IsNullOrWhiteSpace(basePath))
            {
                throw new Exception("no output path");
            }

            const string container = "DebugMovies";

            foreach (ulong key in Program.TrackedFiles[0xB6])
            {
                using (Stream videoStream = OpenFile(key)) {
                    if (videoStream != null)
                    {
                        using (BinaryReader reader = new BinaryReader(videoStream))
                        {
                            MOVI movi = reader.Read <MOVI>();
                            videoStream.Position = 128;  // wrapped in "MOVI" for some reason
                            string videoFile = Path.Combine(basePath, container, teResourceGUID.LongKey(key).ToString("X12"), $"{teResourceGUID.LongKey(key):X12}.bk2");
                            WriteFile(videoStream, videoFile);
                            FindLogic.Combo.ComboInfo audioInfo = new FindLogic.Combo.ComboInfo
                            {
                                m_soundFiles = new System.Collections.Generic.Dictionary <ulong, FindLogic.Combo.SoundFileAsset>
                                {
                                    { movi.MasterAudio, new FindLogic.Combo.SoundFileAsset(movi.MasterAudio) }
                                }
                            };
                            var audioContext = new Combo.SaveContext(audioInfo);
                            SaveLogic.Combo.SaveSoundFile(flags, Path.Combine(basePath, container, teResourceGUID.LongKey(key).ToString("X12")), audioContext, movi.MasterAudio, false);
                            audioContext.Wait();
                        }
                    }
                }
            }
        }
Example #11
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();
        }
Example #12
0
        public static void Save(ICLIFlags flags, string directory, STUSkinBase skin, STUHero hero)
        {
            Dictionary <ulong, ulong> replacements = GetReplacements(skin);

            LoudLog("\t\tFinding");

            FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo();
            var saveContext = new Combo.SaveContext(info);

            FindLogic.Combo.Find(info, hero.m_gameplayEntity, replacements);
            info.SetEntityName(hero.m_gameplayEntity, "Gameplay3P");

            FindLogic.Combo.Find(info, hero.m_previewEmoteEntity, replacements);
            info.SetEntityName(hero.m_previewEmoteEntity, "PreviewEmote");

            FindLogic.Combo.Find(info, hero.m_322C521A, replacements);
            info.SetEntityName(hero.m_322C521A, "Showcase");

            FindLogic.Combo.Find(info, hero.m_26D71549, replacements);
            info.SetEntityName(hero.m_26D71549, "HeroGallery");

            FindLogic.Combo.Find(info, hero.m_8125713E, replacements);
            info.SetEntityName(hero.m_8125713E, "HighlightIntro");

            if (skin is STUSkinTheme skinTheme)
            {
                info.m_processExistingEntities = true;
                List <Dictionary <ulong, ulong> > weaponReplacementStack = new List <Dictionary <ulong, ulong> >();
                for (var index = 0; index < skinTheme.m_heroWeapons.Length; index++)
                {
                    var           weaponOverrideGUID = skinTheme.m_heroWeapons[index];
                    STUHeroWeapon heroWeapon         = GetInstance <STUHeroWeapon>(weaponOverrideGUID);
                    if (heroWeapon == null)
                    {
                        continue;
                    }

                    Dictionary <ulong, ulong> weaponReplacements = GetReplacements(heroWeapon);

                    SetPreviewWeaponNames(info, weaponReplacements, hero.m_previewWeaponEntities, index);
                    SetPreviewWeaponNames(info, weaponReplacements, hero.m_C2FE396F, index);

                    weaponReplacementStack.Add(weaponReplacements == null ? new Dictionary <ulong, ulong>() : weaponReplacements.Where(x => teResourceGUID.Type(x.Key) == 0x1A).ToDictionary(x => x.Key, x => x.Value));
                }

                for (var index = 0; index < weaponReplacementStack.Count; index++)
                {
                    foreach (var pair in weaponReplacementStack[index].Where(pair => pair.Key != pair.Value && info.m_modelLooks.ContainsKey(pair.Value) && info.m_modelLooks[pair.Value].m_name == null))
                    {
                        info.SetModelLookName(pair.Value, $"{(STUWeaponType) index:G}-{teResourceGUID.Index(pair.Value):X}");
                    }
                }

                info.m_processExistingEntities = false;
            }

            foreach (STU_1A496D3C tex in hero.m_8203BFE1)   // find GUI
            {
                FindLogic.Combo.Find(info, tex.m_texture, replacements);
                info.SetTextureName(tex.m_texture, teResourceGUID.AsString(tex.m_id));
            }

            if (replacements != null)
            {
                string soundDirectory = Path.Combine(directory, "Sound");

                FindLogic.Combo.ComboInfo diffInfoBefore = new FindLogic.Combo.ComboInfo();
                FindLogic.Combo.ComboInfo diffInfoAfter  = new FindLogic.Combo.ComboInfo();
                var diffInfoAfterContext = new Combo.SaveContext(diffInfoAfter); // todo: remove

                foreach (KeyValuePair <ulong, ulong> replacement in replacements)
                {
                    uint diffReplacementType = teResourceGUID.Type(replacement.Value);
                    if (diffReplacementType != 0x2C && diffReplacementType != 0x3F &&
                        diffReplacementType != 0xB2)
                    {
                        continue;                              // no voice sets, use extract-hero-voice
                    }
                    FindLogic.Combo.Find(diffInfoAfter, replacement.Value);
                    FindLogic.Combo.Find(diffInfoBefore, replacement.Key);
                }

                foreach (KeyValuePair <ulong, FindLogic.Combo.VoiceSetAsset> voiceSet in diffInfoAfter.m_voiceSets)
                {
                    if (diffInfoBefore.m_voiceSets.ContainsKey(voiceSet.Key))
                    {
                        continue;
                    }
                    Combo.SaveVoiceSet(flags, soundDirectory, diffInfoAfterContext, voiceSet.Key);
                }

                foreach (KeyValuePair <ulong, FindLogic.Combo.SoundFileAsset> soundFile in diffInfoAfter.m_soundFiles)
                {
                    if (diffInfoBefore.m_soundFiles.ContainsKey(soundFile.Key))
                    {
                        continue;
                    }
                    Combo.SaveSoundFile(flags, soundDirectory, diffInfoAfterContext, soundFile.Key, false);
                }

                foreach (KeyValuePair <ulong, FindLogic.Combo.SoundFileAsset> soundFile in diffInfoAfter.m_voiceSoundFiles)
                {
                    if (diffInfoBefore.m_voiceSoundFiles.ContainsKey(soundFile.Key))
                    {
                        continue;
                    }
                    Combo.SaveSoundFile(flags, soundDirectory, diffInfoAfterContext, soundFile.Key, true);
                }

                diffInfoAfterContext.Wait();
            }

            LoudLog("\t\tSaving");
            Combo.SaveLooseTextures(flags, Path.Combine(directory, "GUI"), saveContext);
            Combo.Save(flags, directory, saveContext);
            saveContext.Wait();
            LoudLog("\t\tDone");
        }