コード例 #1
0
        /// <summary>
        /// Loads a pixelaria file's contents from its stream or file path
        /// </summary>
        /// <param name="file">A valid PixelariaFile with a stream of valid file path set</param>
        /// <param name="resetBundle">Whether to reset the bundle to a clear state before loading the new file</param>
        public static void Load(PixelariaFile file, bool resetBundle = true)
        {
            // TODO: Verify correctess of clearing the pixelaria file's internal blocks list before loading the file from the stream again
            PixelariaFileLoader loader = new PixelariaFileLoader(file, resetBundle);

            loader.Load();
        }
コード例 #2
0
        /// <summary>
        /// Loads a Pixelaria (.plx) file from disk
        /// </summary>
        /// <param name="path">The path of the file to load</param>
        /// <returns>A new Pixelaria file</returns>
        public static PixelariaFile LoadFileFromDisk(string path)
        {
            FileStream   stream = new FileStream(path, FileMode.Open, FileAccess.Read);
            BinaryReader reader = new BinaryReader(stream);

            // Signature Block
            if (reader.ReadByte() != 'P' || reader.ReadByte() != 'X' || reader.ReadByte() != 'L')
            {
                return(null);
            }

            // Bundle Header block
            int bundleVersion = reader.ReadInt32();

            stream.Close();

            PixelariaFile file;

            ////////
            //// Version 9 and later
            ////////
            if (bundleVersion >= 9)
            {
                file = new PixelariaFile(new Bundle("Name"), path);

                PixelariaFileLoader.Load(file);

                return(file);
            }

            Bundle bundle = LoadBundleFromDisk(path);

            file = new PixelariaFile(bundle, path);
            file.PrepareBlocksWithBundle();

            return(file);
        }