Esempio n. 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();
        }
Esempio n. 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);
        }
Esempio n. 3
0
        /// <summary>
        /// Saves a pixelaria file's contents to its stream or file path
        /// </summary>
        /// <param name="file">A valid PixelariaFile with a stream of valid file path set</param>
        public static void Save(PixelariaFile file)
        {
            PixelariaFileSaver saver = new PixelariaFileSaver(file);

            saver.Save();
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the PixelariaFileLoader class
 /// </summary>
 /// <param name="file">The file to save to the stream</param>
 public PixelariaFileSaver(PixelariaFile file)
 {
     _file = file;
 }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the PixelariaFileLoader class
 /// </summary>
 /// <param name="file">The file to load from the stream</param>
 /// <param name="resetBundle">Whether to reset the bundle to a clear state before loading the new file</param>
 public PixelariaFileLoader(PixelariaFile file, bool resetBundle)
 {
     _file        = file;
     _resetBundle = resetBundle;
 }
Esempio n. 6
0
 /// <summary>
 /// Saves the given PixelariaFile object to disk
 /// </summary>
 /// <param name="file">The file to save to disk</param>
 public static void SaveFileToDisk(PixelariaFile file)
 {
     PixelariaFileSaver.Save(file);
 }
Esempio n. 7
0
        /// <summary>
        /// Saves the given bundle to disk
        /// </summary>
        /// <param name="bundle">The bundle to save</param>
        /// <param name="path">The path to save the bundle to</param>
        public static void SaveBundleToDisk(Bundle bundle, string path)
        {
            PixelariaFile file = new PixelariaFile(bundle, path);

            SaveFileToDisk(file);
        }