Beispiel #1
0
        static Effect()
        {
            PSXEffects = new Dictionary<UInt16, Effect>( 513 );
            PSPEffects = new Dictionary<UInt16, Effect>( 513 );

            for( UInt16 i = 0; i < 512; i++ )
            {
                PSPEffects[i] = new Effect( i, PSPResources.Lists.AbilityEffects[i] );
                PSXEffects[i] = new Effect( i, PSXResources.Lists.AbilityEffects[i] );
            }

            PSPEffects[0xFFFF] = new Effect( 0xFFFF, "" );
            PSXEffects[0xFFFF] = new Effect( 0xFFFF, "" );

            PSPEffects = new PatcherLib.Datatypes.ReadOnlyDictionary<UInt16, Effect>( PSPEffects );
            PSXEffects = new PatcherLib.Datatypes.ReadOnlyDictionary<UInt16, Effect>( PSXEffects );
        }
Beispiel #2
0
        static Effect()
        {
            PSXEffects = new Dictionary <UInt16, Effect>(513);
            PSPEffects = new Dictionary <UInt16, Effect>(513);

            for (UInt16 i = 0; i < 512; i++)
            {
                PSPEffects[i] = new Effect(i, PSPResources.Lists.AbilityEffects[i]);
                PSXEffects[i] = new Effect(i, PSXResources.Lists.AbilityEffects[i]);
            }

            PSPEffects[0xFFFF] = new Effect(0xFFFF, "");
            PSXEffects[0xFFFF] = new Effect(0xFFFF, "");

            PSPEffects = new PatcherLib.Datatypes.ReadOnlyDictionary <UInt16, Effect>(PSPEffects);
            PSXEffects = new PatcherLib.Datatypes.ReadOnlyDictionary <UInt16, Effect>(PSXEffects);
        }
Beispiel #3
0
        static ResourcesClass()
        {
            using (MemoryStream memStream = new MemoryStream(PatcherLib.Resources.Properties.Resources.ZippedResources, false))
                using (GZipInputStream gzStream = new GZipInputStream(memStream))
                    using (TarInputStream tarStream = new TarInputStream(gzStream))
                    {
                        var      tempDefault = new Dictionary <string, IList <byte> >();
                        TarEntry entry;
                        entry = tarStream.GetNextEntry();
                        while (entry != null)
                        {
                            if (entry.Size != 0)
                            {
                                byte[] bytes = new byte[entry.Size];
                                StreamUtils.ReadFully(tarStream, bytes);
                                tempDefault[entry.Name] = bytes.AsReadOnly();
                            }
                            entry = tarStream.GetNextEntry();
                        }

                        DefaultZipFileContents = new PatcherLib.Datatypes.ReadOnlyDictionary <string, IList <byte> >(tempDefault);
                    }

            string defaultsFile = Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Resources.zip");

            if (File.Exists(defaultsFile))
            {
                var tempContents = new Dictionary <string, IList <byte> >();
                try
                {
                    using (FileStream file = File.Open(defaultsFile, FileMode.Open, FileAccess.Read))
                        using (ZipInputStream zipStream = new ZipInputStream(file))
                        {
                            ZipEntry entry = zipStream.GetNextEntry();
                            while (entry != null)
                            {
                                if (entry.Size != 0)
                                {
                                    byte[] bytes = new byte[entry.Size];
                                    StreamUtils.ReadFully(zipStream, bytes);
                                    tempContents[entry.Name] = bytes.AsReadOnly();
                                }
                                entry = zipStream.GetNextEntry();
                            }

                            foreach (KeyValuePair <string, IList <byte> > kvp in DefaultZipFileContents)
                            {
                                if (!tempContents.ContainsKey(kvp.Key))
                                {
                                    tempContents[kvp.Key] = kvp.Value;
                                }
                            }
                        }

                    ZipFileContents = new PatcherLib.Datatypes.ReadOnlyDictionary <string, IList <byte> >(tempContents);
                }
                catch (Exception)
                {
                    ZipFileContents = DefaultZipFileContents;
                }
            }
            else
            {
                ZipFileContents = DefaultZipFileContents;
            }

            abilityFormulasDoc = ZipFileContents[Paths.AbilityFormulasXML].ToUTF8String().ToXmlDocument();
        }
Beispiel #4
0
        static ResourcesClass()
        {
            using( MemoryStream memStream = new MemoryStream( PatcherLib.Resources.Properties.Resources.ZippedResources, false ) )
            using( GZipInputStream gzStream = new GZipInputStream( memStream ) )
            using( TarInputStream tarStream = new TarInputStream( gzStream ) )
            {
                var tempDefault = new Dictionary<string, IList<byte>>();
                TarEntry entry;
                entry = tarStream.GetNextEntry();
                while( entry != null )
                {
                    if( entry.Size != 0 )
                    {
                        byte[] bytes = new byte[entry.Size];
                        StreamUtils.ReadFully( tarStream, bytes );
                        tempDefault[entry.Name] = bytes.AsReadOnly();
                    }
                    entry = tarStream.GetNextEntry();
                }

                DefaultZipFileContents = new PatcherLib.Datatypes.ReadOnlyDictionary<string, IList<byte>>(tempDefault);
            }

            string defaultsFile = Path.Combine( Path.GetDirectoryName( System.Windows.Forms.Application.ExecutablePath ), "Resources.zip" );

            if( File.Exists( defaultsFile ) )
            {
                var tempContents = new Dictionary<string, IList<byte>>();
                try
                {
                    using( FileStream file = File.Open( defaultsFile, FileMode.Open, FileAccess.Read ) )
                    using( ZipInputStream zipStream = new ZipInputStream( file ) )
                    {
                        ZipEntry entry = zipStream.GetNextEntry();
                        while( entry != null )
                        {
                            if( entry.Size != 0 )
                            {
                                byte[] bytes = new byte[entry.Size];
                                StreamUtils.ReadFully( zipStream, bytes );
                                tempContents[entry.Name] = bytes.AsReadOnly();
                            }
                            entry = zipStream.GetNextEntry();
                        }

                        foreach (KeyValuePair<string, IList<byte>> kvp in DefaultZipFileContents)
                        {
                            if (!tempContents.ContainsKey(kvp.Key))
                            {
                                tempContents[kvp.Key] = kvp.Value;
                            }
                        }
                    }

                    ZipFileContents = new PatcherLib.Datatypes.ReadOnlyDictionary<string, IList<byte>>(tempContents);
                }
                catch( Exception )
                {
                    ZipFileContents = DefaultZipFileContents;
                }
            }
            else
            {
                ZipFileContents = DefaultZipFileContents;
            }

            abilityFormulasDoc = ZipFileContents[Paths.AbilityFormulasXML].ToUTF8String().ToXmlDocument();
        }