Beispiel #1
0
        public void Parse(Dictionary <ushort, List <ulong> > track, Dictionary <ulong, Record> map, CASCHandler handler, bool quiet, OverToolFlags flags)
        {
            foreach (ulong key in track[0x54])
            {
                if (!map.ContainsKey(key))
                {
                    continue;
                }
                Dictionary <OWRecord, string> items = new Dictionary <OWRecord, string>();
                using (Stream input = Util.OpenFile(map[key], handler)) {
                    if (input == null)
                    {
                        continue;
                    }
                    STUD stud = new STUD(input);
                    if (stud.Instances == null || stud.Instances[0] == null)
                    {
                        continue;
                    }

                    GlobalInventoryMaster master = stud.Instances[0] as GlobalInventoryMaster;
                    if (master == null)
                    {
                        continue;
                    }

                    Console.Out.WriteLine("\tACHIEVEMENT");
                    foreach (OWRecord record in master.StandardItems)
                    {
                        ListInventory.GetInventoryName(record.key, false, map, handler, "General");
                    }

                    Dictionary <string, List <OWRecord> > aggreg = new Dictionary <string, List <OWRecord> >();
                    for (int i = 0; i < master.Generic.Length; ++i)
                    {
                        if (master.GenericItems[i].Length == 0)
                        {
                            continue;
                        }
                        string s = $"\tSTANDARD_{ItemEvents.GetInstance().GetEvent(master.Generic[i].@event)}";
                        if (!aggreg.ContainsKey(s))
                        {
                            aggreg[s] = new List <OWRecord>();
                        }
                        for (int j = 0; j < master.GenericItems[i].Length; ++j)
                        {
                            aggreg[s].Add(master.GenericItems[i][j]);
                        }
                    }

                    foreach (KeyValuePair <string, List <OWRecord> > pair in aggreg)
                    {
                        Console.Out.WriteLine(pair.Key);
                        foreach (OWRecord record in pair.Value)
                        {
                            ListInventory.GetInventoryName(record, false, map, handler, "General");
                        }
                    }

                    aggreg.Clear();

                    for (int i = 0; i < master.Categories.Length; ++i)
                    {
                        if (master.CategoryItems[i].Length == 0)
                        {
                            continue;
                        }
                        Console.Out.WriteLine($"\t{ItemEvents.GetInstance().GetEvent(master.Categories[i].@event)}");
                        for (int j = 0; j < master.CategoryItems[i].Length; ++j)
                        {
                            ListInventory.GetInventoryName(master.CategoryItems[i][j], false, map, handler, "General");
                        }
                    }

                    for (int i = 0; i < master.ExclusiveOffsets.Length; ++i)
                    {
                        if (master.LootboxExclusive[i].Length == 0)
                        {
                            continue;
                        }
                        Console.Out.WriteLine($"\tLOOTBOX_EXCLUSIVE_{ItemEvents.GetInstance().GetEvent((ulong)i)}");
                        for (int j = 0; j < master.LootboxExclusive[i].Length; ++j)
                        {
                            ListInventory.GetInventoryName(master.LootboxExclusive[i][j].item, false, map, handler, "General");
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public void Parse(Dictionary <ushort, List <ulong> > track, Dictionary <ulong, Record> map, CASCHandler handler, bool quiet, OverToolFlags flags)
        {
            Dictionary <string, Dictionary <string, Dictionary <string, List <JSONPkg> > > > dict = new Dictionary <string, Dictionary <string, Dictionary <string, List <JSONPkg> > > >();

            foreach (ulong key in track[0x54])
            {
                if (!map.ContainsKey(key))
                {
                    continue;
                }

                using (Stream input = Util.OpenFile(map[key], handler)) {
                    if (input == null)
                    {
                        continue;
                    }
                    STUD stud = new STUD(input);
                    if (stud.Instances == null || stud.Instances[0] == null)
                    {
                        continue;
                    }

                    GlobalInventoryMaster master = stud.Instances[0] as GlobalInventoryMaster;
                    if (master == null)
                    {
                        continue;
                    }

                    if (!dict.ContainsKey("ACHIEVEMENT"))
                    {
                        dict["ACHIEVEMENT"] = new Dictionary <string, Dictionary <string, List <JSONPkg> > >();
                    }

                    if (!dict.ContainsKey("AVAILABLE"))
                    {
                        dict["AVAILABLE"] = new Dictionary <string, Dictionary <string, List <JSONPkg> > >();
                    }

                    if (!dict.ContainsKey("LOOTBOX_EXCLUSIVE"))
                    {
                        dict["LOOTBOX_EXCLUSIVE"] = new Dictionary <string, Dictionary <string, List <JSONPkg> > >();
                    }

                    for (int i = 0; i < master.Generic.Length; ++i)
                    {
                        if (master.GenericItems[i].Length == 0)
                        {
                            continue;
                        }
                        string s = ItemEvents.GetInstance().GetEvent(master.Generic[i].@event);
                        if (!dict["ACHIEVEMENT"].ContainsKey(s))
                        {
                            dict["ACHIEVEMENT"][s] = new Dictionary <string, List <JSONPkg> >();
                        }

                        for (int j = 0; j < master.GenericItems[i].Length; ++j)
                        {
                            JSONPkg pkg = GenerateJSONPkg(master.GenericItems[i][j].key, map, handler);
                            if (pkg.Name == null)
                            {
                                continue;
                            }
                            pkg.EventId = master.Generic[i].@event;
                            pkg.Event   = s;

                            if (!dict["ACHIEVEMENT"][s].ContainsKey(pkg.Type))
                            {
                                dict["ACHIEVEMENT"][s][pkg.Type] = new List <JSONPkg>();
                            }
                            dict["ACHIEVEMENT"][s][pkg.Type].Add(pkg);
                        }
                    }

                    for (int i = 0; i < master.Categories.Length; ++i)
                    {
                        if (master.CategoryItems[i].Length == 0)
                        {
                            continue;
                        }

                        string s = ItemEvents.GetInstance().GetEvent(master.Categories[i].@event);
                        if (!dict["AVAILABLE"].ContainsKey(s))
                        {
                            dict["AVAILABLE"][s] = new Dictionary <string, List <JSONPkg> >();
                        }

                        for (int j = 0; j < master.CategoryItems[i].Length; ++j)
                        {
                            JSONPkg pkg = GenerateJSONPkg(master.CategoryItems[i][j].key, map, handler);
                            if (pkg.Name == null)
                            {
                                continue;
                            }
                            pkg.EventId = master.Categories[i].@event;
                            pkg.Event   = s;

                            if (!dict["AVAILABLE"][s].ContainsKey(pkg.Type))
                            {
                                dict["AVAILABLE"][s][pkg.Type] = new List <JSONPkg>();
                            }
                            dict["AVAILABLE"][s][pkg.Type].Add(pkg);
                        }
                    }

                    for (int i = 0; i < master.ExclusiveOffsets.Length; ++i)
                    {
                        if (master.LootboxExclusive[i].Length == 0)
                        {
                            continue;
                        }

                        string s = ItemEvents.GetInstance().GetEvent((ulong)i);
                        if (!dict["LOOTBOX_EXCLUSIVE"].ContainsKey(s))
                        {
                            dict["LOOTBOX_EXCLUSIVE"][s] = new Dictionary <string, List <JSONPkg> >();
                        }

                        for (int j = 0; j < master.LootboxExclusive[i].Length; ++j)
                        {
                            JSONPkg pkg = GenerateJSONPkg(master.LootboxExclusive[i][j].item, map, handler);
                            if (pkg.Name == null)
                            {
                                continue;
                            }
                            pkg.EventId = (ulong)i;
                            pkg.Event   = s;

                            if (!dict["LOOTBOX_EXCLUSIVE"][s].ContainsKey(pkg.Type))
                            {
                                dict["LOOTBOX_EXCLUSIVE"][s][pkg.Type] = new List <JSONPkg>();
                            }
                            dict["LOOTBOX_EXCLUSIVE"][s][pkg.Type].Add(pkg);
                        }
                    }
                }
            }

            if (Path.GetDirectoryName(flags.Positionals[2]).Trim().Length > 0 && !Directory.Exists(Path.GetDirectoryName(flags.Positionals[2])))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(flags.Positionals[2]));
            }
            using (Stream file = File.OpenWrite(flags.Positionals[2])) {
                using (TextWriter writer = new StreamWriter(file)) {
                    writer.Write(JsonConvert.SerializeObject(dict, Formatting.Indented));
                }
            }
        }
Beispiel #3
0
        public void Parse(Dictionary <ushort, List <ulong> > track, Dictionary <ulong, Record> map, CASCHandler handler, bool quiet, OverToolFlags flags)
        {
            string output = flags.Positionals[2];

            foreach (ulong key in track[0x54])
            {
                if (!map.ContainsKey(key))
                {
                    continue;
                }
                Dictionary <OWRecord, string> items = new Dictionary <OWRecord, string>();
                using (Stream input = Util.OpenFile(map[key], handler)) {
                    if (input == null)
                    {
                        continue;
                    }
                    STUD stud = new STUD(input);
                    if (stud.Instances == null || stud.Instances[0] == null)
                    {
                        continue;
                    }

                    GlobalInventoryMaster master = stud.Instances[0] as GlobalInventoryMaster;
                    if (master == null)
                    {
                        continue;
                    }

                    foreach (OWRecord record in master.StandardItems)
                    {
                        items[record] = "ACHIEVEMENT";
                    }

                    for (int i = 0; i < master.Generic.Length; ++i)
                    {
                        string name = $"STANDARD_{ItemEvents.GetInstance().GetEvent(master.Generic[i].@event)}";
                        for (int j = 0; j < master.GenericItems[i].Length; ++j)
                        {
                            items[master.GenericItems[i][j]] = name;
                        }
                    }

                    for (int i = 0; i < master.Categories.Length; ++i)
                    {
                        string name = ItemEvents.GetInstance().GetEvent(master.Categories[i].@event);
                        for (int j = 0; j < master.CategoryItems[i].Length; ++j)
                        {
                            items[master.CategoryItems[i][j]] = name;
                        }
                    }

                    for (int i = 0; i < master.ExclusiveOffsets.Length; ++i)
                    {
                        string name = $"LOOTBOX_EXCLUSIVE_{i:X}";
                        for (int j = 0; j < master.LootboxExclusive[i].Length; ++j)
                        {
                            items[master.LootboxExclusive[i][j].item] = name;
                        }
                    }
                }

                foreach (KeyValuePair <OWRecord, string> recordname in items)
                {
                    OWRecord record    = recordname.Key;
                    string   itemGroup = recordname.Value;
                    if (!map.ContainsKey(record.key))
                    {
                        continue;
                    }

                    STUD stud = new STUD(Util.OpenFile(map[record.key], handler));
                    if (stud.Instances == null)
                    {
                        continue;
                    }
                    IInventorySTUDInstance instance = (IInventorySTUDInstance)stud.Instances[0];
                    string name = Util.GetString(instance.Header.name.key, map, handler);
                    if (name == null)
                    {
                        name = $"{GUID.LongKey(key):X12}";
                    }

                    switch (instance.Name)
                    {
                    case "Spray":
                        Console.Out.WriteLine("Extracting spray {0}...", name);
                        ExtractLogic.Spray.Extract(stud, output, "Generic", name, itemGroup, track, map, handler, quiet, flags);
                        break;

                    case "Icon":
                        Console.Out.WriteLine("Extracting icon {0}...", name);
                        ExtractLogic.Icon.Extract(stud, output, "Generic", name, itemGroup, track, map, handler, quiet, flags);
                        break;

                    case "Portrait":
                        PortraitItem portrait = instance as PortraitItem;
                        ExtractLogic.Portrait.Extract(stud, output, "Generic", $"Tier {portrait.Data.tier}", itemGroup, track, map, handler, quiet, flags);
                        break;

                    default:
                        continue;
                    }
                }
            }
        }