public List <List <ScenarioData> > CreateScenarioIndexGroups(ScenarioType type, MapList.MapList maplist, IContainer gameDataPath, TextUtils.GameTextEncoding encoding, EndianUtils.Endianness endian, BitUtils.Bitness bits)
        {
            SortedDictionary <int, ScenarioWebsiteName> websiteNames = ScenarioWebsiteName.GenerateWebsiteNames(this.Version);

            Util.Assert(maplist.MapNames.Count == websiteNames.Count);

            List <ScenarioData> scenes = new List <ScenarioData>();
            List <ScenarioFile.ScenarioFile> scenarioFiles = new List <ScenarioFile.ScenarioFile>();
            bool haveSeenEP_030_010 = false;

            foreach (var d in websiteNames)
            {
                var names = maplist.MapNames[d.Key];
                if (d.Value.Type != type)
                {
                    continue;
                }

                string episodeID = names.Name3 == "dummy" ? names.Name1 : names.Name3;

                // the game has this file twice in scenario.dat, so ignore the first instance we encounter, as presumably the game would overwrite the first instance with the second?
                if (!haveSeenEP_030_010 && episodeID == "EP_030_010")
                {
                    haveSeenEP_030_010 = true;
                    continue;
                }

                int num      = d.Key;
                var metadata = new ScenarioData()
                {
                    ScenarioDatIndex = num, EpisodeId = episodeID, HumanReadableName = d.Value.Description != null ? d.Value.Description : episodeID
                };
                System.IO.Stream stream = GenerateWebsite.TryGetScenarioFile(gameDataPath, num, Locale, Version);
                if (stream != null)
                {
                    var orig = new ScenarioFile.ScenarioFile(stream, encoding, endian, bits);
                    orig.Metadata = metadata;
                    scenarioFiles.Add(orig);
                    scenes.Add(metadata);
                }
            }

            foreach (var s in scenarioFiles.OrderBy(x => x.Metadata.EpisodeId))
            {
                this.ScenarioFiles.Add(s.Metadata.EpisodeId, s);
            }
            return(ScenarioData.ProcessScenesToGroups(scenes));
        }
 public static SCFOMBIN.SCFOMBIN LoadBattleTextFile(IContainer gameDataPath, string filename, GameLocale locale, GameVersion version, EndianUtils.Endianness endian, TextUtils.GameTextEncoding encoding, BitUtils.Bitness bits)
 {
     if (!version.Is360())
     {
         uint ptrDiff = 0x1888;
         if (filename.StartsWith("BTL_XTM"))
         {
             ptrDiff = 0x1B4C;
         }
         var bin = new SCFOMBIN.SCFOMBIN(GenerateWebsite.TryGetBattleScenarioFile(gameDataPath, filename, locale, version), endian, encoding, ptrDiff);
         return(bin);
     }
     else
     {
         var bin = new ScenarioFile.ScenarioFile(GenerateWebsite.TryGetBattleScenarioFile(gameDataPath, filename, locale, version), encoding, endian, bits);
         var btl = new SCFOMBIN.SCFOMBIN();
         btl.EntryList = bin.EntryList;
         return(btl);
     }
 }
        public void LoadBattleTextTSS( string dir )
        {
            BattleTextFiles = new Dictionary<string, SCFOMBIN.SCFOMBIN>();

            var files = new System.IO.DirectoryInfo( dir ).GetFiles();
            foreach ( var file in files ) {
                if ( file.Name.StartsWith( "BTL_" ) ) {
                    var bin = new ScenarioFile.ScenarioFile( Path.Combine( dir, file.Name ), true );
                    var name = file.Name.Split( '.' )[0];

                    var btl = new SCFOMBIN.SCFOMBIN();
                    btl.EntryList = bin.EntryList;
                    BattleTextFiles.Add( name, btl );
                }
            }
        }
        private List<List<ScenarioData>> CreateScenarioIndexGroups( ScenarioType type, string database, string scenarioDatFolder, string scenarioDatFolderMod = null, bool isUtf8 = false )
        {
            var data = SqliteUtil.SelectArray( "Data Source=" + database, "SELECT filename, shortdesc, desc FROM descriptions ORDER BY desc" );

            List<ScenarioData> scenes = new List<ScenarioData>();
            foreach ( var d in data ) {
                string filename = (string)d[0];
                string humanReadableName = (string)d[1];
                string episodeID = (string)d[2];

                int idx = humanReadableName.LastIndexOfAny( new char[] { ']', '}' } );
                if ( idx > -1 ) {
                    humanReadableName = humanReadableName.Substring( idx + 1 );
                }
                humanReadableName = humanReadableName.Trim();

                if ( filename.StartsWith( "VScenario" ) ) {
                    string group;
                    int dummy;
                    bool isStory;
                    bool isScenario = episodeID.StartsWith( "EP_" );

                    if ( isScenario ) {
                        group = episodeID.Split( '_' )[1];
                        isStory = group.Length == 3 && Int32.TryParse( group, out dummy );
                    } else {
                        group = "";
                        isStory = false;
                    }

                    bool exportAsScenario = isScenario && ( ( type == ScenarioType.Story && isStory ) || ( type == ScenarioType.Sidequests && !isStory ) );
                    bool exportAsMap = !isScenario && type == ScenarioType.Maps;
                    if ( exportAsScenario || exportAsMap ) {
                        if ( !ScenarioFiles.ContainsKey( episodeID ) ) {
                            string num = filename.Substring( "VScenario".Length );
                            try {
                                var orig = new ScenarioFile.ScenarioFile( Path.Combine( scenarioDatFolder, num + ".d" ), isUtf8 );
                                if ( scenarioDatFolderMod != null ) {
                                    var mod = new ScenarioFile.ScenarioFile( Path.Combine( scenarioDatFolderMod, num + ".d" ), isUtf8 );
                                    Util.Assert( orig.EntryList.Count == mod.EntryList.Count );
                                    for ( int i = 0; i < orig.EntryList.Count; ++i ) {
                                        orig.EntryList[i].EnName = mod.EntryList[i].JpName;
                                        orig.EntryList[i].EnText = mod.EntryList[i].JpText;
                                    }
                                }
                                orig.EpisodeID = episodeID;
                                this.ScenarioFiles.Add( episodeID, orig );
                                scenes.Add( new ScenarioData() { EpisodeId = episodeID, HumanReadableName = humanReadableName, DatabaseName = filename } );
                            } catch ( FileNotFoundException ) { }
                        }
                    }
                }
            }

            return ScenarioData.ProcessScenesToGroups( scenes );
        }
示例#5
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;
            }
        }