コード例 #1
0
ファイル: PortraitFrame.cs プロジェクト: ipud2/OWLib
        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}");
            }

            Combo.SaveLooseTextures(flags, Path.Combine(directory, tier), info);
        }
コード例 #2
0
ファイル: ExtractMapEnvs.cs プロジェクト: carveryiz/OWLib
        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);
        }
コード例 #3
0
ファイル: Portrait.cs プロジェクト: Toocanzs/OWLib
        public static void SaveItems(string basePath, string heroName, string containerName, string folderName, ICLIFlags flags, IEnumerable <ItemInfo> items)
        {
            FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo();

            foreach (ItemInfo item in items)
            {
                if (item == null)
                {
                    continue;
                }
                if (!(item.Unlock is STULevelPortrait unlock))
                {
                    continue;
                }
                string tier = unlock.Tier.ToString();

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

                if (unlock.BorderImage != null)
                {
                    FindLogic.Combo.Find(info, unlock.BorderImage);
                    int borderNum = unlock.Level - unlock.Star * 10 - (int)unlock.Tier * 10;

                    if ((int)unlock.Tier > 1)
                    {
                        borderNum -= 50 * ((int)unlock.Tier - 1);
                    }
                    borderNum -= 1;

                    info.SetTextureName(unlock.BorderImage, $"Border - {borderNum}");
                }

                Combo.SaveLooseTextures(flags, Path.Combine(basePath, containerName, "Portraits", tier), info);
                info.Textures = new Dictionary <ulong, FindLogic.Combo.TextureInfoNew>();  // quite naughty
            }
        }
コード例 #4
0
ファイル: ExtractDebugShaders.cs プロジェクト: HellPie/OWLib
        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);
        }
コード例 #5
0
ファイル: SkinTheme.cs プロジェクト: carveryiz/OWLib
        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();

            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.Config.DoExistingEntities = true;
                foreach (var weaponOverrideGUID in skinTheme.m_heroWeapons)
                {
                    STUHeroWeapon heroWeapon = GetInstance <STUHeroWeapon>(weaponOverrideGUID);
                    if (heroWeapon == null)
                    {
                        continue;
                    }

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

                    SavePreviewWeapons(info, weaponReplacements, hero.m_previewWeaponEntities);
                    SavePreviewWeapons(info, weaponReplacements, hero.m_C2FE396F);
                }
                info.Config.DoExistingEntities = false;
            }

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

            Combo.SaveLooseTextures(flags, Path.Combine(directory, "GUI"), info);

            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();

                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.VoiceSetInfo> voiceSet in diffInfoAfter.VoiceSets)
                {
                    if (diffInfoBefore.VoiceSets.ContainsKey(voiceSet.Key))
                    {
                        continue;
                    }
                    Combo.SaveVoiceSet(flags, soundDirectory, diffInfoAfter, voiceSet.Key);
                }

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

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

            LoudLog("\t\tSaving");
            Combo.Save(flags, directory, info);
            LoudLog("\t\tDone");
        }
コード例 #6
0
ファイル: SkinTheme.cs プロジェクト: HellPie/OWLib
        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");
        }