Example #1
0
        public bool ImportSQL(bool placeEnglishInJpnEntry = true, bool updateDatabaseWithInGameStringId = false, bool generateGracesEnglish = false)
        {
            String[] DBNames =
            {
                "VGeneral",                "VMenu",             "VArtes",          "VSkills",
                "VStrategy",               "VLocation Names",   "VEnemies",
                "VGroups",                 "VItem General",     "VItem Offensive",
                "VItem Defensive",         "VItem Accessories", "VItem Food",
                "VItem Synth Ingredients", "VItem Special",
                "VItem Attachments",       "VDLC",              "VShops",          "VRecipes",
                "VEtc",                    "VLocations",        "VGrade Bonus",    "VGrade Shop",
                "VTitles",                 "VLogs",             "VMini Game Text", "VSkit Titles",
                "VMisc",                   "VMisc2",            "VTutorial",       "VAilments",   "VSigns",
                "VMap Locations",          "VCredits",          "VOther Text",
                "VEvent Jumps",            "VSkit Text"
            };

            char[]            bx06 = { '', '(' };
            String            x06  = new String(bx06);
            SQLiteConnection  connectionGracesEnglish  = null;
            SQLiteTransaction transactionGracesEnglish = null;

            if (generateGracesEnglish)
            {
                connectionGracesEnglish = new SQLiteConnection("Data Source=db/GracesEnglish");
                connectionGracesEnglish.Open();
                transactionGracesEnglish = connectionGracesEnglish.BeginTransaction();
            }

            // stuff to import the NPC text area names into GN
            Dictionary <uint, string> npcInGameIdMapDict = null;

            if (updateDatabaseWithInGameStringId)
            {
                string npcListFilename = @"d:\Dropbox\ToV\PS3\orig\npc.svo.ext\NPC.DAT.dec.ext\0000.dec";
                if (System.IO.File.Exists(npcListFilename))
                {
                    var npcListPS3 = new TOVNPC.TOVNPCL(npcListFilename, Util.Endianness.BigEndian, Util.Bitness.B32);
                    Dictionary <string, TOVNPC.TOVNPCT> npcDefs = new Dictionary <string, TOVNPC.TOVNPCT>();
                    foreach (var f in npcListPS3.NpcFileList)
                    {
                        string filename = @"d:\Dropbox\ToV\PS3\orig\npc.svo.ext\" + f.Filename + @".dec.ext\0001.dec";
                        if (System.IO.File.Exists(filename))
                        {
                            var d = new TOVNPC.TOVNPCT(filename, Util.Endianness.BigEndian, Util.Bitness.B32);
                            npcDefs.Add(f.Map, d);
                        }
                    }
                    npcInGameIdMapDict = new Dictionary <uint, string>();
                    foreach (var kvp in npcDefs)
                    {
                        foreach (var npcText in kvp.Value.NpcDefList)
                        {
                            npcInGameIdMapDict.Add(npcText.StringDicId, kvp.Key);
                        }
                    }
                }
            }

            foreach (String CurrentDBName in DBNames)
            {
                Console.WriteLine("   Importing " + CurrentDBName + "...");
                SQLiteConnection Connection = new SQLiteConnection("Data Source=db/" + CurrentDBName);
                Connection.Open();
                SQLiteCommand    Command = new SQLiteCommand("SELECT english, PointerRef, StringID FROM Text", Connection);
                SQLiteDataReader Reader  = Command.ExecuteReader();
                while (Reader.Read())
                {
                    String English    = Reader.GetString(0);
                    int    PointerRef = Reader.GetInt32(1);

                    if (updateDatabaseWithInGameStringId)
                    {
                        UpdateDatabaseWithInGameStringId(Connection, PointerRef, Entries[PointerRef + 1].inGameStringId, npcInGameIdMapDict);
                    }
                    if (generateGracesEnglish)
                    {
                        string englishOriginal  = Entries[PointerRef + 1].StringEng;
                        int    gracesJapaneseId = Reader.GetInt32(2);
                        UpdateGracesJapanese(transactionGracesEnglish, gracesJapaneseId, englishOriginal, 0);
                    }

                    if (Entries[PointerRef + 1].StringJpn != null &&
                        !String.IsNullOrEmpty(English)
                        )
                    {
                        English = English.Replace("''", "'");

                        /*
                         * if (English.Contains("<Unk6:"))
                         * {
                         *      English = English.Replace("<Unk6: ", x06);
                         *      English = English.Replace(">", ")");
                         * }
                         */
                        if (placeEnglishInJpnEntry)
                        {
                            Entries[PointerRef + 1].StringJpn = English;
                        }
                        else
                        {
                            Entries[PointerRef + 1].StringEng = English;
                        }
                    }
                }
                Reader.Close();
                Reader.Dispose();
                Connection.Close();
                Connection.Dispose();
            }

            if (generateGracesEnglish)
            {
                transactionGracesEnglish.Commit();
                connectionGracesEnglish.Close();
            }

            return(true);
        }
Example #2
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);
        }
        public string GenerateHtmlNpc()
        {
            Console.WriteLine( "Generating Website: NPCs" );
            var npcListPS3 = new TOVNPC.TOVNPCL( @"d:\Dropbox\ToV\PS3\orig\npc.svo.ext\NPC.DAT.dec.ext\0000.dec" );
            Dictionary<string, TOVNPC.TOVNPCT> npcDefs = new Dictionary<string, TOVNPC.TOVNPCT>();
            foreach ( var f in npcListPS3.NpcFileList ) {
                string filename = @"d:\Dropbox\ToV\PS3\orig\npc.svo.ext\" + f.Filename + @".dec.ext\0001.dec";
                if ( File.Exists( filename ) ) {
                    var d = new TOVNPC.TOVNPCT( filename );
                    npcDefs.Add( f.Map, d );
                }
            }

            StringBuilder sb = new StringBuilder();
            AddHeader( sb, "NPC Dialogue" );
            sb.AppendLine( "<body>" );
            //AddMenuBar( sb );
            sb.Append( "<table class=\"npcdiff\">" );
            foreach ( var kvp in npcDefs ) {
                for ( int i = 0; i < kvp.Value.NpcDefList.Count; ++i ) {
                    var d = kvp.Value.NpcDefList[i];
                    sb.Append( "<tr>" );

                    sb.Append( "<td>" );
                    sb.Append( kvp.Key );
                    sb.Append( "<br>" );
                    sb.Append( d.StringDicId );
                    //sb.Append( "<br>" );
                    //sb.Append( d.RefString1 );
                    //sb.Append( "<br>" );
                    //sb.Append( d.RefString2 );
                    sb.Append( "</td>" );

                    sb.Append( "<td>" );
                    sb.Append( InGameIdDict[d.StringDicId].StringJpnHtml( Version ) );
                    sb.Append( "</td>" );

                    sb.Append( "<td>" );
                    sb.Append( InGameIdDict[d.StringDicId].StringEngHtml( Version ) );
                    sb.Append( "</td>" );

                    sb.Append( "</tr>" );

                    sb.Append( "<tr><td colspan=\"3\"><hr></td></tr>" );
                }
            }
            sb.Append( "</table>" );
            sb.Append( "</body></html>" );

            return sb.ToString();
        }
Example #4
0
        public bool ImportSQL( bool placeEnglishInJpnEntry = true, bool updateDatabaseWithInGameStringId = false, bool generateGracesEnglish = false )
        {
            String[] DBNames = {
                                   "VGeneral", "VMenu", "VArtes", "VSkills",
                                   "VStrategy", "VLocation Names", "VEnemies",
                                   "VGroups", "VItem General", "VItem Offensive",
                                   "VItem Defensive", "VItem Accessories", "VItem Food",
                                   "VItem Synth Ingredients", "VItem Special",
                                   "VItem Attachments", "VDLC", "VShops", "VRecipes",
                                   "VEtc", "VLocations", "VGrade Bonus", "VGrade Shop",
                                   "VTitles", "VLogs", "VMini Game Text", "VSkit Titles",
                                   "VMisc", "VMisc2", "VTutorial", "VAilments", "VSigns",
                                   "VMap Locations", "VCredits", "VOther Text",
                                   "VEvent Jumps", "VSkit Text"
                               };

            char[] bx06 = { '', '(' };
            String x06 = new String( bx06 );
            SQLiteConnection connectionGracesEnglish = null;
            SQLiteTransaction transactionGracesEnglish = null;
            if ( generateGracesEnglish ) {
                connectionGracesEnglish = new SQLiteConnection( "Data Source=db/GracesEnglish" );
                connectionGracesEnglish.Open();
                transactionGracesEnglish = connectionGracesEnglish.BeginTransaction();
            }

            // stuff to import the NPC text area names into GN
            Dictionary<uint, string> npcInGameIdMapDict = null;
            if ( updateDatabaseWithInGameStringId ) {
                string npcListFilename = @"d:\Dropbox\ToV\PS3\orig\npc.svo.ext\NPC.DAT.dec.ext\0000.dec";
                if ( System.IO.File.Exists( npcListFilename ) ) {
                    var npcListPS3 = new TOVNPC.TOVNPCL( npcListFilename );
                    Dictionary<string, TOVNPC.TOVNPCT> npcDefs = new Dictionary<string, TOVNPC.TOVNPCT>();
                    foreach ( var f in npcListPS3.NpcFileList ) {
                        string filename = @"d:\Dropbox\ToV\PS3\orig\npc.svo.ext\" + f.Filename + @".dec.ext\0001.dec";
                        if ( System.IO.File.Exists( filename ) ) {
                            var d = new TOVNPC.TOVNPCT( filename );
                            npcDefs.Add( f.Map, d );
                        }
                    }
                    npcInGameIdMapDict = new Dictionary<uint, string>();
                    foreach ( var kvp in npcDefs ) {
                        foreach ( var npcText in kvp.Value.NpcDefList ) {
                            npcInGameIdMapDict.Add( npcText.StringDicId, kvp.Key );
                        }
                    }
                }
            }

            foreach ( String CurrentDBName in DBNames ) {
                Console.WriteLine( "   Importing " + CurrentDBName + "..." );
                SQLiteConnection Connection = new SQLiteConnection( "Data Source=db/" + CurrentDBName );
                Connection.Open();
                SQLiteCommand Command = new SQLiteCommand( "SELECT english, PointerRef, StringID FROM Text", Connection );
                SQLiteDataReader Reader = Command.ExecuteReader();
                while ( Reader.Read() ) {
                    String English = Reader.GetString( 0 );
                    int PointerRef = Reader.GetInt32( 1 );

                    if ( updateDatabaseWithInGameStringId ) {
                        UpdateDatabaseWithInGameStringId( Connection, PointerRef, Entries[PointerRef + 1].inGameStringId, npcInGameIdMapDict );
                    }
                    if ( generateGracesEnglish ) {
                        string englishOriginal = Entries[PointerRef + 1].StringEng;
                        int gracesJapaneseId = Reader.GetInt32( 2 );
                        UpdateGracesJapanese( transactionGracesEnglish, gracesJapaneseId, englishOriginal, 0 );
                    }

                    if ( Entries[PointerRef + 1].StringJpn != null
                         && !String.IsNullOrEmpty( English )
                       ) {
                        English = English.Replace( "''", "'" );
                        /*
                        if (English.Contains("<Unk6:"))
                        {
                            English = English.Replace("<Unk6: ", x06);
                            English = English.Replace(">", ")");
                        }
                        */
                        if ( placeEnglishInJpnEntry ) {
                            Entries[PointerRef + 1].StringJpn = English;
                        } else {
                            Entries[PointerRef + 1].StringEng = English;
                        }
                    }
                }
                Reader.Close();
                Reader.Dispose();
                Connection.Close();
                Connection.Dispose();
            }

            if ( generateGracesEnglish ) {
                transactionGracesEnglish.Commit();
                connectionGracesEnglish.Close();
            }

            return true;
        }