Example #1
0
        public static void Generate(List <GenerateWebsiteInputOutputData> gens)
        {
            foreach (var g in gens)
            {
                WebsiteGenerator site = LoadWebsiteGenerator(g.GameDataPath, g.Version, g.VersionPostfix, g.Locale, g.Language, g.Endian, g.Encoding, g.Bits);

                if (g.GamePatchPath != null)
                {
                    // patch original PS3 data with fantranslation
                    {
                        // STRING_DIC
                        var stringDicTranslated = new TSS.TSSFile(TryGetStringDic(g.GamePatchPath, g.Locale, g.Version), g.Encoding, g.Endian);
                        Util.Assert(site.StringDic.Entries.Length == stringDicTranslated.Entries.Length);
                        for (int i = 0; i < site.StringDic.Entries.Length; ++i)
                        {
                            Util.Assert(site.StringDic.Entries[i].inGameStringId == stringDicTranslated.Entries[i].inGameStringId);
                            site.StringDic.Entries[i].StringEng = stringDicTranslated.Entries[i].StringJpn;
                        }
                    }
                    foreach (var kvp in site.ScenarioFiles)
                    {
                        // scenario.dat
                        if (kvp.Value.EntryList.Count > 0 && kvp.Value.Metadata.ScenarioDatIndex >= 0)
                        {
                            Stream streamMod = TryGetScenarioFile(g.GamePatchPath, kvp.Value.Metadata.ScenarioDatIndex, g.Locale, g.Version);
                            if (streamMod != null)
                            {
                                var scenarioMod = new ScenarioFile.ScenarioFile(streamMod, g.Encoding, g.Endian, g.Bits);
                                Util.Assert(kvp.Value.EntryList.Count == scenarioMod.EntryList.Count);
                                for (int i = 0; i < kvp.Value.EntryList.Count; ++i)
                                {
                                    kvp.Value.EntryList[i].EnName = scenarioMod.EntryList[i].JpName;
                                    kvp.Value.EntryList[i].EnText = scenarioMod.EntryList[i].JpText;
                                }
                            }
                        }
                    }
                    foreach (var kvp in site.BattleTextFiles)
                    {
                        // btl.svo/BATTLE_PACK
                        if (kvp.Value.EntryList.Count > 0)
                        {
                            var scenarioMod = WebsiteGenerator.LoadBattleTextFile(g.GamePatchPath, kvp.Key, g.Locale, g.Version, g.Endian, g.Encoding, g.Bits);
                            Util.Assert(kvp.Value.EntryList.Count == scenarioMod.EntryList.Count);
                            for (int i = 0; i < kvp.Value.EntryList.Count; ++i)
                            {
                                kvp.Value.EntryList[i].EnName = scenarioMod.EntryList[i].JpName;
                                kvp.Value.EntryList[i].EnText = scenarioMod.EntryList[i].JpText;
                            }
                        }
                    }
                    foreach (var kvp in site.SkitText)
                    {
                        // chat.svo
                        var    chatFile    = kvp.Value;
                        Stream streamMod   = TryGetSkitText(g.GamePatchPath, kvp.Key, g.Locale, g.Version);
                        var    chatFileMod = new TO8CHTX.ChatFile(streamMod, g.Endian, g.Encoding, g.Bits, 2);
                        Util.Assert(chatFile.Lines.Length == chatFileMod.Lines.Length);
                        for (int j = 0; j < chatFile.Lines.Length; ++j)
                        {
                            chatFile.Lines[j].SENG = chatFileMod.Lines[j].SJPN;
                            chatFile.Lines[j].SNameEnglishNotUsedByGame = chatFileMod.Lines[j].SName;
                        }
                    }
                    site.TrophyEn = HyoutaTools.Trophy.TrophyConfNode.ReadTropSfmWithTropConf(g.GamePatchPath + @"TROPHY.TRP.ext\TROP.SFM", g.GamePatchPath + @"TROPHY.TRP.ext\TROPCONF.SFM");
                }

                site.InGameIdDict = site.StringDic.GenerateInGameIdDictionary();

                if (g.ImportJpInGameDictLocale != null)
                {
                    // copy over Japanese stuff into StringDic from other locale
                    var StringDicUs = new TSS.TSSFile(TryGetStringDic(g.GameDataPath, g.ImportJpInGameDictLocale.Value, g.Version), g.Encoding, g.Endian);
                    var IdDictUs    = StringDicUs.GenerateInGameIdDictionary();
                    foreach (var kvp in IdDictUs)
                    {
                        site.InGameIdDict[kvp.Key].StringJpn = kvp.Value.StringJpn;
                    }
                }

                ExportToWebsite(site, WebsiteLanguage.BothWithEnLinks, g.WebsiteOutputPath, g.CompareSite?.Generator);

                g.Generator = site;
            }
        }