Example #1
0
        public static WebsiteGenerator LoadWebsiteGenerator(string gameDataPath, GameVersion version, string versionPostfix, GameLocale locale, WebsiteLanguage websiteLanguage, Util.Endianness endian, Util.GameTextEncoding encoding, Util.Bitness bits)
        {
            WebsiteGenerator site = new WebsiteGenerator();

            site.Locale         = locale;
            site.Version        = version;
            site.VersionPostfix = versionPostfix;
            site.Language       = websiteLanguage;

            site.Items           = new ItemDat.ItemDat(TryGetItemDat(gameDataPath, site.Locale, site.Version), Util.Endianness.BigEndian);
            site.StringDic       = new TSS.TSSFile(TryGetStringDic(gameDataPath, site.Locale, site.Version), encoding, endian);
            site.Artes           = new T8BTMA.T8BTMA(TryGetArtes(gameDataPath, site.Locale, site.Version), endian, bits);
            site.Skills          = new T8BTSK.T8BTSK(TryGetSkills(gameDataPath, site.Locale, site.Version), endian, bits);
            site.Enemies         = new T8BTEMST.T8BTEMST(TryGetEnemies(gameDataPath, site.Locale, site.Version), endian, bits);
            site.EnemyGroups     = new T8BTEMGP.T8BTEMGP(TryGetEnemyGroups(gameDataPath, site.Locale, site.Version), endian, bits);
            site.EncounterGroups = new T8BTEMEG.T8BTEMEG(TryGetEncounterGroups(gameDataPath, site.Locale, site.Version), endian, bits);
            site.Recipes         = new COOKDAT.COOKDAT(TryGetRecipes(gameDataPath, site.Locale, site.Version), endian);
            site.Locations       = new WRLDDAT.WRLDDAT(TryGetLocations(gameDataPath, site.Locale, site.Version), endian);
            site.Synopsis        = new SYNPDAT.SYNPDAT(TryGetSynopsis(gameDataPath, site.Locale, site.Version), endian);
            site.Titles          = new FAMEDAT.FAMEDAT(TryGetTitles(gameDataPath, site.Locale, site.Version), endian);
            site.GradeShop       = new T8BTGR.T8BTGR(TryGetGradeShop(gameDataPath, site.Locale, site.Version), endian, bits);
            site.BattleBook      = new BTLBDAT.BTLBDAT(TryGetBattleBook(gameDataPath, site.Locale, site.Version), endian);
            site.Strategy        = new T8BTTA.T8BTTA(TryGetStrategy(gameDataPath, site.Locale, site.Version), endian, bits);
            if (site.Version != GameVersion.PC)                 // TODO
            {
                site.BattleVoicesEnd = new T8BTVA.T8BTVA(TryGetBattleVoicesEnd(gameDataPath, site.Locale, site.Version), endian);
            }
            if (!site.Version.Is360())                 // 360 version stores search points differently, haven't decoded that
            //var txm = new Texture.TXM( gameDataPath + "UI.svo.ext/WORLDNAVI.TXM" );
            //var txv = new Texture.TXV( txm, gameDataPath + "UI.svo.ext/WORLDNAVI.TXV" );
            //var tex = txv.textures.Where( x => x.TXM.Name == "U_WORLDNAVI00" ).First();
            //site.WorldMapImage = tex.GetBitmaps().First();
            {
                site.WorldMapImage = IntegerScaled(new Bitmap(gameDataPath + "UI.svo.ext/WORLDNAVI.TXM.ext/U_WORLDNAVI00.png"), 5, 4);
                site.SearchPoints  = new TOVSEAF.TOVSEAF(TryGetSearchPoints(gameDataPath, site.Locale, site.Version), endian);
            }
            site.Skits    = new TO8CHLI.TO8CHLI(TryGetSkitMetadata(gameDataPath, site.Locale, site.Version), endian, bits);
            site.SkitText = new Dictionary <string, TO8CHTX.ChatFile>();
            ISet <string> forceShiftJisSkits = version == GameVersion.X360_EU && (locale == GameLocale.UK || locale == GameLocale.US) ?
                                               new HashSet <string> {
                "VC051", "VC052", "VC053", "VC054", "VC055", "VC056", "VC057", "VC084", "VC719", "VC954"
            } : new HashSet <string>();

            for (int i = 0; i < site.Skits.SkitInfoList.Count; ++i)
            {
                string name   = site.Skits.SkitInfoList[i].RefString;
                Stream stream = TryGetSkitText(gameDataPath, name, site.Locale, site.Version);
                if (stream != null)
                {
                    bool             forceShiftJis = forceShiftJisSkits.Contains(name);
                    TO8CHTX.ChatFile chatFile      = new TO8CHTX.ChatFile(stream, endian, forceShiftJis ? Util.GameTextEncoding.ShiftJIS : encoding, bits, version == GameVersion.PC ? 11 : 2);
                    site.SkitText.Add(name, chatFile);
                }
                else
                {
                    Console.WriteLine("Couldn't find chat file " + name + "! (" + version + ", " + locale + ")");
                }
            }

            site.Records  = WebsiteGenerator.GenerateRecordsStringDicList(site.Version);
            site.Settings = WebsiteGenerator.GenerateSettingsStringDicList(site.Version);

            site.ScenarioFiles = new Dictionary <string, ScenarioFile.ScenarioFile>();

            switch (version)
            {
            case GameVersion.X360_US:
                site.Shops = new ShopData.ShopData(TryGetScenarioFile(gameDataPath, 0, site.Locale, site.Version), 0x1A718, 0x420 / 32, 0x8F8, 0x13780 / 56, endian, bits);
                break;

            case GameVersion.X360_EU:
                site.Shops = new ShopData.ShopData(TryGetScenarioFile(gameDataPath, 0, site.Locale, site.Version), 0x1A780, 0x420 / 32, 0x8F8, 0x13780 / 56, endian, bits);
                break;

            case GameVersion.PS3:
            case GameVersion.PC:
                site.Shops = new ShopData.ShopData(TryGetScenarioFile(gameDataPath, 0, site.Locale, site.Version), 0x1C9BC, 0x460 / 32, 0x980, 0x14CB8 / 56, endian, bits);
                break;

            default:
                throw new Exception("Don't know shop data location for version " + version);
            }

            if (version.HasPS3Content())
            {
                site.IconsWithItems = new uint[] { 35, 36, 37, 60, 38, 1, 4, 12, 6, 5, 13, 14, 15, 7, 52, 51, 53, 9, 16, 18, 2, 17, 19, 10, 54, 20, 21, 22, 23, 24, 25, 26, 27, 56, 30, 28, 32, 31, 33, 29, 34, 41, 42, 43, 44, 45, 57, 61, 63, 39, 3, 40 };
            }
            else
            {
                site.IconsWithItems = new uint[] { 35, 36, 37, 60, 38, 1, 4, 12, 6, 5, 13, 14, 15, 7, 52, 51, 9, 16, 18, 2, 17, 19, 10, 20, 21, 22, 23, 24, 25, 26, 27, 56, 30, 28, 32, 31, 33, 29, 34, 41, 42, 43, 44, 45, 57, 61, 63, 39, 3, 40 };
            }

            site.BattleTextFiles = WebsiteGenerator.LoadBattleText(gameDataPath, site.Locale, site.Version, endian, encoding, bits);

            if (version.HasPS3Content())
            {
                site.NecropolisFloors    = new T8BTXTM.T8BTXTMA(TryGetNecropolisFloors(gameDataPath, site.Locale, site.Version), endian, bits);
                site.NecropolisTreasures = new T8BTXTM.T8BTXTMT(TryGetNecropolisTreasures(gameDataPath, site.Locale, site.Version), endian, bits);
                site.NecropolisMaps      = new SortedDictionary <string, T8BTXTM.T8BTXTMM>();
                foreach (T8BTXTM.FloorInfo floor in site.NecropolisFloors.FloorList)
                {
                    if (!site.NecropolisMaps.ContainsKey(floor.RefString2))
                    {
                        site.NecropolisMaps.Add(floor.RefString2, new T8BTXTM.T8BTXTMM(TryGetNecropolisMap(gameDataPath, floor.RefString2, site.Locale, site.Version), endian));
                    }
                }
            }

            if (version == GameVersion.PS3)
            {
                site.TrophyJp = HyoutaTools.Trophy.TrophyConfNode.ReadTropSfmWithTropConf(gameDataPath + @"TROPHY.TRP.ext\TROP.SFM", gameDataPath + @"TROPHY.TRP.ext\TROPCONF.SFM");
            }

            if (version.HasPS3Content())
            {
                site.NpcList = new TOVNPC.TOVNPCL(gameDataPath + @"npc.svo.ext\NPC.DAT.dec.ext\0000.dec", endian, bits);
                site.NpcDefs = new Dictionary <string, TOVNPC.TOVNPCT>();
                foreach (var f in site.NpcList.NpcFileList)
                {
                    string filename = gameDataPath + @"npc.svo.ext\" + f.Filename + @".dec.ext\0001.dec";
                    if (File.Exists(filename))
                    {
                        var d = new TOVNPC.TOVNPCT(filename, endian, bits);
                        site.NpcDefs.Add(f.Map, d);
                    }
                }
            }

            var maplist = new MapList.MapList(TryGetMaplist(gameDataPath, site.Locale, site.Version), endian, bits);

            site.ScenarioGroupsStory      = site.CreateScenarioIndexGroups(ScenarioType.Story, maplist, gameDataPath, encoding, endian, bits);
            site.ScenarioGroupsSidequests = site.CreateScenarioIndexGroups(ScenarioType.Sidequests, maplist, gameDataPath, encoding, endian, bits);
            site.ScenarioGroupsMaps       = site.CreateScenarioIndexGroups(ScenarioType.Maps, maplist, gameDataPath, encoding, endian, bits);
            site.ScenarioAddSkits(site.ScenarioGroupsStory);

            return(site);
        }