Exemplo n.º 1
0
        public void Parse(ICLIFlags toolFlags)
        {
            string basePath;

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

            Log("Saving all voice sets. This will take some time.");
            foreach (var key in TrackedFiles[0x5F])
            {
                var stu = STUHelper.GetInstance <STUVoiceSet>(key);
                if (stu == null)
                {
                    continue;
                }

                var guidClean = teResourceGUID.AsString(key);
                Log($"Saving VoiceSet: {guidClean}");

                var comboInfo = new Combo.ComboInfo();
                var context   = new SaveLogic.Combo.SaveContext(comboInfo);
                Combo.Find(comboInfo, key);
                SaveLogic.Combo.SaveVoiceSet(toolFlags, Path.Combine(basePath, Container), context, key);
                context.Wait();
            }
        }
Exemplo n.º 2
0
        private static List <UxStringContainer> GetData()
        {
            var @return = new List <UxStringContainer>();

            foreach (ulong key in TrackedFiles[0x114])
            {
                var stu = STUHelper.GetInstance <STU_6649A4C0>(key);

                var stringContainer = new UxStringContainer {
                    GUID    = (teResourceGUID)key,
                    Strings = new List <UxString>()
                };

                foreach (var str in stu.m_81125A2C)
                {
                    stringContainer.Strings.Add(new UxString {
                        VirtualO1C  = str.m_id,
                        DisplayName = IO.GetString(str.m_displayName)
                    });
                }

                @return.Add(stringContainer);
            }

            return(@return);
        }
Exemplo n.º 3
0
        private static void ProcessAssetSTUv2(ulong guid, string typeDir)
        {
            teStructuredData structuredData = STUHelper.OpenSTUSafe(guid);

            if (structuredData == null)
            {
                return;
            }

            AssetRecord record = new AssetRecord {
                GUID = (teResourceGUID)guid,
                StructuredDataInfo = new Common.StructuredDataInfo(),
                References         = new HashSet <teResourceGUID>()
            };

            foreach (STUInstance instance in structuredData.Instances)
            {
                if (instance == null)
                {
                    continue;
                }
                STUv2ProcessInstance(record, instance);
            }

            using (Stream outputFile = File.OpenWrite(Path.Combine(typeDir, $"{teResourceGUID.AsString(guid)}.json"))) {
                outputFile.SetLength(0);
                byte[] buf = JsonSerializer.PrettyPrintByteArray(JsonSerializer.Serialize(record));
                outputFile.Write(buf, 0, buf.Length);
            }
        }
Exemplo n.º 4
0
        private void Init(STU_E3594B8E arcade, ulong key = default)
        {
            GUID        = (teResourceGUID)key;
            Name        = GetString(arcade.m_name);
            Description = GetString(arcade.m_description);
            Image       = arcade.m_21EB3E73;

            switch (arcade)
            {
            case STU_598579A3 a1:
                Brawl = a1.m_5DC61E59;
                break;

            case STU_19C05237 a2:
                Children = Helper.JSON.FixArray(a2.m_children);
                break;

            default:
                break;
            }

            About = arcade.m_5797DE13?.Select(x => {
                var aboutStuff = STUHelper.GetInstance <STU_56830926>(x);

                var name    = GetString(aboutStuff.m_name);
                string desc = null;

                if (aboutStuff is STU_F31D4F9C ye)
                {
                    desc = GetString(ye.m_description);
                }

                return(new string[] { name, desc });
            }).SelectMany(x => x).Where(x => x != null).ToArray();
        }
Exemplo n.º 5
0
        public Loadout(ulong key)
        {
            STULoadout loadout = STUHelper.GetInstance <STULoadout>(key);

            if (loadout == null)
            {
                return;
            }
            Init(key, loadout);
        }
Exemplo n.º 6
0
        public static Loadout GetLoadout(ulong key)
        {
            STULoadout loadout = STUHelper.GetInstance <STULoadout>(key);

            if (loadout == null)
            {
                return(null);
            }
            return(new Loadout(loadout));
        }
Exemplo n.º 7
0
        public Loadout(ulong key)
        {
            STULoadout stu = STUHelper.GetInstance <STULoadout>(key);

            if (stu == null)
            {
                return;
            }
            Init(stu, key);
        }
Exemplo n.º 8
0
        public GameRuleset(ulong key)
        {
            var stu = STUHelper.GetInstance <STUGameRuleset>(key);

            if (stu == null)
            {
                return;
            }
            Init(stu, key);
        }
Exemplo n.º 9
0
        public ArcadeMode(ulong key)
        {
            STU_E3594B8E stu = STUHelper.GetInstance <STU_E3594B8E>(key);

            if (stu == null)
            {
                return;
            }
            Init(stu, key);
        }
Exemplo n.º 10
0
        public void Parse(ICLIFlags toolFlags)
        {
            var flags  = (ExtractFlags)toolFlags;
            var output = Path.Combine(flags.OutputPath, "Dump", "STU");

            if (!Directory.Exists(output))
            {
                Directory.CreateDirectory(output);
            }

            var serializers = new Dictionary <Type, IDragonMLSerializer> {
                { typeof(teStructuredDataAssetRef <>), new teResourceGUIDSerializer() }
            };

            foreach (var type in new ushort[] {
                0x3, 0x15, 0x18, 0x1A, 0x1B, 0x1F, 0x20, 0x21, 0x24, 0x2C, 0x2D,
                0x2E, 0x2F, 0x30, 0x31, 0x32, 0x39, 0x3A, 0x3B, 0x45, 0x49, 0x4C, 0x4E, 0x51, 0x53, 0x54, 0x55, 0x58,
                0x5A, 0x5B, 0x5E, 0x5F, 0x62, 0x63, 0x64, 0x65, 0x66, 0x68, 0x70, 0x71, 0x72, 0x75, 0x78, 0x79, 0x7A,
                0x7F, 0x81, 0x90, 0x91, 0x95, 0x96, 0x97, 0x98, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA2, 0xA3, 0xA5, 0xA6,
                0xA8, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xB5, 0xB7, 0xBF, 0xC0, 0xC2, 0xC5, 0xC6, 0xC7, 0xC9, 0xCA, 0xCC,
                0xCE, 0xCF, 0xD0, 0xD4, 0xD5, 0xD6, 0xD7, 0xD9, 0xDC, 0xDF, 0xEB, 0xEC, 0xEE, 0xF8, 0x10D, 0x114, 0x116,
                0x11A, 0x122
            })
            {
                if (!Directory.Exists(Path.Combine(output, type.ToString("X3"))))
                {
                    Directory.CreateDirectory(Path.Combine(output, type.ToString("X3")));
                }

                foreach (var guid in Program.TrackedFiles[type])
                {
                    try {
                        Logger.Log24Bit(ConsoleSwatch.XTermColor.Purple5, true, Console.Out, null, $"Saving {teResourceGUID.AsString(guid)}");

                        using (var stu = STUHelper.OpenSTUSafe(guid))
                            using (Stream f = File.Open(Path.Combine(output, type.ToString("X3"), teResourceGUID.AsString(guid) + ".xml"), FileMode.Create))
                                using (TextWriter w = new StreamWriter(f)) {
                                    w.WriteLine(DragonML.Print(stu?.Instances[0], new DragonMLSettings {
                                        TypeSerializers = serializers
                                    }));
                                }
                    } catch (Exception e) {
                        Logger.Error("STU", e.ToString());
                    }
                }
            }
        }
Exemplo n.º 11
0
        private Dictionary <teResourceGUID, string> GetData()
        {
            var @return = new Dictionary <teResourceGUID, string>();

            foreach (teResourceGUID key in TrackedFiles[0xD5])
            {
                var stu = STUHelper.GetInstance <STU_96ABC153>(key);
                if (stu == null)
                {
                    continue;
                }

                @return[key] = IO.GetString(stu.m_94672A2A);
            }

            return(@return);
        }
Exemplo n.º 12
0
        public static List <Replay> ParseReplay(string filePath)
        {
            Console.Out.WriteLine($"Processing file: {Path.GetFileName(filePath)}");
            List <Replay> replays = new List <Replay>();

            var buffer = (Memory <byte>)File.ReadAllBytes(filePath);

            if (buffer.Length == 0)
            {
                return(replays);
            }

            foreach (var(filename, b64Str) in ProcessAtoms(buffer))    // hash, payload, settinghash?
            {
                byte[] bytes = Convert.FromBase64String(b64Str[1]);
                // string hex = BitConverter.ToString(bytes);

                var replayInfo = new Mp4Replay();
                replayInfo.Parse(bytes);

                var heroStu   = STUHelper.GetInstance <STUHero>(replayInfo.Header.HeroGuid);
                var hero      = new Hero(heroStu);
                var unlocks   = new ProgressionUnlocks(heroStu);
                var skins     = unlocks.GetUnlocksOfType(UnlockType.Skin);
                var skinTheme = skins.FirstOrDefault(skin => ((STUUnlock_SkinTheme)skin.STU)?.m_skinTheme == replayInfo.Header.SkinGuid);

                ulong mapHeaderGuid = (replayInfo.Header.MapGuid & ~0xFFFFFFFF00000000ul) | 0x0790000000000000ul;
                var   mapData       = new MapHeader(mapHeaderGuid);

                var replay = new Replay {
                    Title         = filename,
                    Hero          = hero.Name,
                    Map           = mapData.Name,
                    Skin          = skinTheme?.Name ?? "Unknown",
                    RecordedAt    = $"{DateTimeOffset.FromUnixTimeSeconds(replayInfo.Header.Timestamp).ToLocalTime()}",
                    HighlightType = $"{replayInfo.Header.Type:G}",
                    Quality       = $"{replayInfo.Header.QualityPct}% ({(ReplayQuality)replayInfo.Header.QualityPct})",
                    FilePath      = filePath
                };

                replays.Add(replay);
            }
            return(replays);
        }
Exemplo n.º 13
0
        public void Init(STULoadout loadout, ulong key = default)
        {
            GUID        = (teResourceGUID)key;
            MovieGUID   = loadout.m_infoMovie;
            TextureGUID = loadout.m_texture;
            Category    = loadout.m_category;

            Name        = GetString(loadout.m_name);
            Description = GetString(loadout.m_description);

            Button             = GetString(STUHelper.GetInstance <STU_C5243F93>(loadout.m_logicalButton)?.m_name);
            ButtonUnk          = GetString(STUHelper.GetInstance <STU_C5243F93>(loadout.m_9290B942)?.m_name);
            DescriptionButtons = loadout.m_B1124918?.Select(x => GetString(STUHelper.GetInstance <STU_C5243F93>(x)?.m_name)).ToArray();

            // If the ability isn't shown in the UI (weapons, zoom ability)
            IsHiddenAbility = loadout.m_0E679979 >= 1;

            // Mercy, Bastion and Torbjorn all have 2 weapons, this is only set on their secondary weapons??
            IsSecondaryWeapon = loadout.m_0E679979 == 2;
        }
Exemplo n.º 14
0
        internal static Dictionary <ulong, ulong[]> GenerateVoicelineConversationMapping(Dictionary <ushort, HashSet <ulong> > trackedFiles)
        {
            var @return = new Dictionary <ulong, ulong[]>();

            foreach (var guid in trackedFiles[0x5F])
            {
                var voiceSet = new VoiceSet(STUHelper.GetInstance <STUVoiceSet>(guid));
                if (voiceSet.VoiceLines == null)
                {
                    continue;
                }

                foreach (var voiceSetVoiceLine in voiceSet.VoiceLines)
                {
                    @return[voiceSetVoiceLine.Key] = voiceSetVoiceLine.Value.VoiceSounds;
                }
            }

            return(@return);
        }
Exemplo n.º 15
0
        public void Parse(ICLIFlags toolFlags)
        {
            var flags  = (RenderFlags)toolFlags;
            var output = Path.Combine(flags.OutputPath, "UI", "Render");

            if (!Directory.Exists(output))
            {
                Directory.CreateDirectory(output);
            }

            var serializers = new Dictionary <Type, IDragonMLSerializer> {
                { typeof(teStructuredDataAssetRef <>), new teResourceGUIDSerializer() }
            };

            foreach (var type in new ushort[] { 0x5E, 0x5A, 0x45 })
            {
                if (!Directory.Exists(Path.Combine(output, type.ToString("X3"))))
                {
                    Directory.CreateDirectory(Path.Combine(output, type.ToString("X3")));
                }

                foreach (var guid in Program.TrackedFiles[type])
                {
                    Logger.Log24Bit(ConsoleSwatch.XTermColor.Purple5, true, Console.Out, null, $"Saving {teResourceGUID.AsString(guid)}");

                    using (Stream f = File.Open(Path.Combine(output, type.ToString("X3"), teResourceGUID.AsString(guid)), FileMode.Create))
                        using (Stream d = IO.OpenFile(guid)) {
                            d.CopyTo(f);
                        }

                    using (var stu = STUHelper.OpenSTUSafe(guid))
                        using (Stream f = File.Open(Path.Combine(output, type.ToString("X3"), teResourceGUID.AsString(guid) + ".xml"), FileMode.Create))
                            using (TextWriter w = new StreamWriter(f)) {
                                w.WriteLine(DragonML.Print(stu?.Instances[0], new DragonMLSettings {
                                    TypeSerializers = serializers
                                }));
//                        w.WriteLine(JsonConvert.SerializeObject(stu?.Instances[0], Formatting.Indented, settings));
                            }
                }
            }
        }
Exemplo n.º 16
0
        private static void ProcessHeroNames(DynamicChoicesContainer container)
        {
            var heroContainer = container.GetType(VALID_HERO_NAMES);
            var npcContainer  = container.GetType(VALID_NPC_NAMES);
            var owlTeams      = container.GetType(VALID_OWL_TEAMS);

            HashSet <string> handledTeams = new HashSet <string>();

            Dictionary <ulong, STUHero> heroes          = new Dictionary <ulong, STUHero>();
            Dictionary <string, int>    nameOccurrances = new Dictionary <string, int>();

            foreach (ulong heroGUID in Program.TrackedFiles[0x75])
            {
                var hero = STUHelper.GetInstance <STUHero>(heroGUID);
                if (hero == null)
                {
                    continue;
                }

                string heroNameActual = Hero.GetCleanName(hero);
                if (heroNameActual == null)
                {
                    continue;
                }

                heroes[heroGUID] = hero;
                if (nameOccurrances.TryGetValue(heroNameActual, out _))
                {
                    nameOccurrances[heroNameActual]++;
                }
                else
                {
                    nameOccurrances[heroNameActual] = 0;
                }
            }

            foreach (ulong heroGUID in Program.TrackedFiles[0x75])
            {
                if (!heroes.TryGetValue(heroGUID, out var hero))
                {
                    continue;
                }
                string heroNameActual = Hero.GetCleanName(hero);

                var doGuidName = nameOccurrances[heroNameActual] > 1;
                if (doGuidName)
                {
                    heroNameActual += $" ({teResourceGUID.Index(heroGUID):X})";
                }

                ProgressionUnlocks progressionUnlocks = new ProgressionUnlocks(hero);

                var choice = new DynamicChoice {
                    DisplayName = heroNameActual,
                    QueryName   = $"{teResourceGUID.Index(heroGUID):X}"
                };

                if (progressionUnlocks.LevelUnlocks == null)
                {
                    npcContainer.Choices.Add(choice);
                }
                else
                {
                    heroContainer.Choices.Add(choice);
                }

                foreach (var unlock in progressionUnlocks.IterateUnlocks())
                {
                    if (string.IsNullOrWhiteSpace(unlock.Name))
                    {
                        continue;
                    }

                    if (unlock.STU.m_0B1BA7C1 != null)
                    {
                        TeamDefinition teamDef = new TeamDefinition(unlock.STU.m_0B1BA7C1);
                        if (!(teamDef.Division == Enum_5A789F71.None && teamDef.Location == null))
                        {
                            if (handledTeams.Add(teamDef.FullName))
                            {
                                owlTeams.Choices.Add(new DynamicChoice {
                                    DisplayName = teamDef.FullName,
                                    QueryName   = teamDef.FullName
                                });
                            }
                            continue;
                        }
                    }

                    var key = "datatool.ux.valid_" + Unlock.GetTypeName(unlock.STU.GetType()).ToLowerInvariant() + "_names";

                    if (choice.Children == null)
                    {
                        choice.Children = new DynamicChoicesContainer();
                    }

                    var test = choice.Children.GetType(key);
                    test.Choices.Add(new DynamicChoice {
                        QueryName   = unlock.Name,
                        DisplayName = unlock.Name
                    });
                }
            }
        }
Exemplo n.º 17
0
        private Dictionary <teResourceGUID, GameRuleset> GetData()
        {
            var @return = new Dictionary <teResourceGUID, GameRuleset>();

            // Hero rulesets that are used on Heroes
            var heroRulesetMapping = new Dictionary <teResourceGUID, RulesetSchemaMapping>();

            foreach (teResourceGUID key in TrackedFiles[0x75])
            {
                var hero = STUHelper.GetInstance <STUHero>(key);
                if (hero?.m_gameRulesetSchemas == null)
                {
                    continue;
                }

                foreach (var guid in hero.m_gameRulesetSchemas)
                {
                    var rulesetSchema = new GameRulesetSchema(guid);
                    if (rulesetSchema?.Entries == null)
                    {
                        continue;
                    }

                    foreach (var rulesetSchemaEntry in rulesetSchema.Entries)
                    {
                        heroRulesetMapping[rulesetSchemaEntry.Virtual01C] = new RulesetSchemaMapping {
                            GUID  = rulesetSchemaEntry.Virtual01C,
                            Name  = rulesetSchemaEntry.Name,
                            Value = rulesetSchemaEntry.Value
                        };
                    }
                }
            }

            foreach (teResourceGUID key in TrackedFiles[0xC0])
            {
                var ruleset = new GameRuleset(key);
                if (ruleset.GUID == 0)
                {
                    continue;
                }

                // Generate game rulesets schemas that are used for this gamemode
                var rulesetMapping = new Dictionary <teResourceGUID, RulesetSchemaMapping>();
                foreach (var guid in ruleset.GameMode.GameMode.GameRulesetSchemas)
                {
                    var rulesetSchema = new GameRulesetSchema(guid);

                    foreach (var rulesetSchemaEntry in rulesetSchema?.Entries)
                    {
                        rulesetMapping[rulesetSchemaEntry.Virtual01C] = new RulesetSchemaMapping {
                            GUID  = rulesetSchemaEntry.Virtual01C,
                            Name  = rulesetSchemaEntry.Name,
                            Value = rulesetSchemaEntry.Value
                        };
                    }
                }

                ruleset.GameMode.ConfigValues = ruleset.GameMode?.STU?.m_3CE93B76?
                                                .Select(configValuePair => GenerateConfigValues(configValuePair, rulesetMapping))
                                                .Where(x => x != null)
                                                .ToArray();

                foreach (var gameRulesetTeam in ruleset.GameMode?.Teams)
                {
                    gameRulesetTeam.ConfigValues = gameRulesetTeam.STU.m_CF58324E?
                                                   .Select(configValuePair => GenerateConfigValues(configValuePair, heroRulesetMapping))
                                                   .Where(x => x != null)
                                                   .ToArray();
                }

                if (ruleset.GameMode.ConfigValues?.Length == 0)
                {
                    ruleset.GameMode.ConfigValues = null;
                }

                @return[key] = ruleset;
            }

            return(@return);
        }
Exemplo n.º 18
0
        public GameRulesetSchema(ulong key)
        {
            var stu = STUHelper.GetInstance <STUGameRulesetSchema>(key);

            Init(stu, key);
        }
Exemplo n.º 19
0
        public ProgressionUnlocks(ulong guid)
        {
            var unlocks = STUHelper.GetInstance <STUProgressionUnlocks>(guid);

            Init(unlocks);
        }
Exemplo n.º 20
0
        public ProgressionUnlocks(STUHero hero)
        {
            var unlocks = STUHelper.GetInstance <STUProgressionUnlocks>(hero.m_heroProgression);

            Init(unlocks);
        }
Exemplo n.º 21
0
        private static WorkshopContainer GetData()
        {
            var @return = new WorkshopContainer();

            foreach (ulong key in TrackedFiles[0x54])
            {
                var baseStu = STUHelper.GetInstance <STUGenericSettings_Base>(key);

                switch (baseStu)
                {
                case STU_A21A7043 stu:
                    @return.TextOptions = stu.m_7169E470.Select(strGuid => GetString(strGuid));

                    @return.Dropdowns = stu.m_C87139B0.Select(dropdownGroup => new WorkshopDropdownDefinition {
                        Id           = dropdownGroup.m_7533CD4C,
                        DefaultValue = dropdownGroup.m_0A0AA524,
                        Options      = dropdownGroup.m_3FE1EA9E.Select(child => new WorkshopDropdownValue {
                            VirtualId   = child.m_identifier,
                            DisplayName = GetString(child.m_displayName),
                            Description = GetString(child.m_description)
                        })
                    });

                    @return.Values = stu.m_values.Select(value => new WorkshopValue {
                        Id          = value.m_identifier,
                        DisplayName = GetString(value.m_displayName),
                        Description = GetString(value.m_description),
                        OutputType  = value.m_904BDD85,
                        UnkEnum     = value.m_10038BBD,
                        UnkByte     = value.m_89C93A57,
                        Parameters  = ParseParameters(value.m_CF17DD30)
                    });
                    break;

                case STU_B85A66BB stu:
                    @return.Actions = stu.m_35CA5DCD.Select(action => new WorkshopDefinition {
                        DisplayName = GetString(action.m_displayName),
                        Description = GetString(action.m_description),
                        GraphId     = action.m_graph,
                        UnkByte     = action.m_89C93A57,
                        Parameters  = ParseParameters(action.m_params)
                    });
                    break;

                case STU_8C73C07E stu:
                    @return.Events = stu.m_targets.Select(action => new WorkshopDefinition {
                        DisplayName = GetString(action.m_displayName),
                        Description = GetString(action.m_description),
                        GraphId     = action.m_graph,
                        UnkByte     = action.m_89C93A57,
                        Parameters  = ParseParameters(action.m_params)
                    });

                    @return.Unknown = stu.m_16EC4AA9?.Select(x => new WorkshopDefinition {
                        DisplayName = GetString(x.m_displayName),
                        Description = GetString(x.m_description),
                        GraphId     = x.m_graph,
                        UnkByte     = x.m_89C93A57,
                        Parameters  = ParseParameters(x.m_params)
                    });
                    break;

                default:
                    continue;
                }
            }

            return(@return);
        }