Beispiel #1
0
        public static int Execute( List<string> args )
        {
            if ( args.Count != 4 ) {
                Console.WriteLine( "Usage: LuxPainEvt_GraceNote event.evt NewDBFile GracesJapanese event.jp.evt" );
                return -1;
            }
            String Filename = args[0];
            String NewDB = args[1];
            String GracesDB = args[2];
            String JapaneseFilename = args[3];

            LuxPainEvt Evt;
            LuxPainEvt EvtJp;
            try {
                Evt = new LuxPainEvt( Filename );
                EvtJp = new LuxPainEvt( JapaneseFilename );
            } catch ( Exception ex ) {
                Console.WriteLine( ex.Message );
                Console.WriteLine( "Failed loading text file!" );
                return -1;
            }
            Evt.FormatTextForEditing();
            EvtJp.FormatTextForEditing();

            if ( Evt.TextEntries.Count != EvtJp.TextEntries.Count ) {
                Console.WriteLine( "Entry count over languages doesn't match, padding..." );

                while ( Evt.TextEntries.Count < EvtJp.TextEntries.Count ) {
                    LuxPainEvtText t = new LuxPainEvtText();
                    t.OffsetLocation = 0x7FFFFFFF;
                    t.Text = "[Entry does not exist in this language, this is just for completion's sake.]";
                    Evt.TextEntries.Add( t );
                }

                while ( Evt.TextEntries.Count > EvtJp.TextEntries.Count ) {
                    LuxPainEvtText t = new LuxPainEvtText();
                    t.OffsetLocation = 0x7FFFFFFF;
                    t.Text = "[Entry does not exist in this language, this is just for completion's sake.]";
                    EvtJp.TextEntries.Add( t );
                }

                if ( Evt.TextEntries.Count != EvtJp.TextEntries.Count ) { throw new Exception( "this shouldn't happen!" ); }
            }

            Console.WriteLine( "Found " + Evt.TextEntries.Count + " entries, importing..." );
            System.IO.File.WriteAllBytes( NewDB, Properties.Resources.gndb_template );

            List<GraceNoteDatabaseEntry> Entries = new List<GraceNoteDatabaseEntry>( Evt.TextEntries.Count );
            for ( int i = 0; i < Evt.TextEntries.Count; ++i ) {
                // fetch GracesJapanese ID or generate new & insert new text
                String EnPlusJp = Evt.TextEntries[i].Text + "\n\n" + EvtJp.TextEntries[i].Text;
                GraceNoteDatabaseEntry gn =
                    new GraceNoteDatabaseEntry( EnPlusJp, Evt.TextEntries[i].Text, "", 0, (int)Evt.TextEntries[i].OffsetLocation, "", 0 );
                Entries.Add( gn );
            }
            GraceNoteDatabaseEntry.InsertSQL( Entries.ToArray(), "Data Source=" + NewDB, "Data Source=" + GracesDB );
            Console.WriteLine( "Successfully imported entries!" );

            return 0;
        }
Beispiel #2
0
        public static int Execute( List<string> args )
        {
            if ( args.Count != 3 ) {
                Console.WriteLine( "Usage: GN_LPE Infile Outfile DB" );
                return -1;
            }

            //*
            String InFilename = args[0];
            String OutFilename = args[1];
            String DB = args[2];
            //String GracesDB = args[3];
            //*/

            /*
            String Filename = @"c:\Users\Georg\Downloads\Xillia Script files\69753.SDBJPN";
            String NewDB = @"c:\Users\Georg\Downloads\Xillia Script files\X69753";
            String TemplateDB = @"c:\Users\Georg\Downloads\Xillia Script files\XTemplate";
            String GracesDB = @"c:\Users\Georg\Downloads\Xillia Script files\GracesJapanese";
            //*/

            LuxPainEvt Evt;
            byte[] EvtFile;
            try {
                EvtFile = System.IO.File.ReadAllBytes( InFilename );
                Evt = new LuxPainEvt( EvtFile );
                Evt.GetSQL( "Data Source=" + DB );
            } catch ( Exception ex ) {
                Console.WriteLine( ex.Message );
                Console.WriteLine( "Failed loading menu file!" );
                return -1;
            }

            LuxPainEvt Evt2 = new LuxPainEvt( EvtFile );
            Evt.FormatTextForGameInserting();
            byte[] newtextblock = Evt.CreateTextBlock( 256 * 256 * 2 );

            List<byte> newEvtFile = new List<byte>( (int)Evt.Header.TextOffsetsLocation + newtextblock.Length );

            for ( uint i = 0; i < Evt.Header.TextOffsetsLocation; ++i ) {
                newEvtFile.Add( EvtFile[i] );
            }
            newEvtFile.AddRange( newtextblock );

            // replicating the weird behavoir that if the last entry ends with 0x8144, there's an additional 0x0000 after it, sometimes.
            // No idea if that's actually relevant but better be safe than sorry!
            if ( newEvtFile[newEvtFile.Count - 4] == 0x81 && newEvtFile[newEvtFile.Count - 3] == 0x44 ) {
                newEvtFile.Add( 0x00 );
                newEvtFile.Add( 0x00 );
            }

            System.IO.File.WriteAllBytes( OutFilename, newEvtFile.ToArray() );

            return 0;
        }