Exemplo n.º 1
0
        public void ReadMissingFile()
        {
            Assert.ThrowsException <FileNotFoundException>(() => ArtFile.Read("MissingFile.prt"));

            // Check if filename is an empty string
            Assert.ThrowsException <ArgumentException>(() => ArtFile.Read(""));
        }
Exemplo n.º 2
0
        public void ReadStream()
        {
            // We want a simple valid source to load from, so we will create one by first writing it
            using (MemoryStream stream = new MemoryStream())
            {
                new ArtFile().Write(stream);

                // Read from stream
                stream.Seek(0, SeekOrigin.Begin);
                ArtFile artFile = ArtFile.Read(stream);
            }
        }
Exemplo n.º 3
0
        public void ReadBinary()
        {
            // We want a simple valid source to load from, so we will create one by first writing it
            using (MemoryStream stream = new MemoryStream())
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    new ArtFile().Write(writer);

                    // Read from stream as BinaryReader
                    writer.BaseStream.Seek(0, SeekOrigin.Begin);
                    using (BinaryReader reader = new BinaryReader(writer.BaseStream))
                    {
                        ArtFile artFile = ArtFile.Read(reader);
                    }
                }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Loads required assets for the game.
        /// </summary>
        public static void Initialize(MonoBehaviour coroutineOwner, string[] modBundlePaths, OnInitializeCallback onInitCB)
        {
            // Load art file
            try
            {
                // Prepare Legacy manager
                _LegacyAssets = new ResourceManager(".");

                // Get art file
                Stream artPartStream = _LegacyAssets.GetResourceStream("op2_art.prt");
                _ArtFile = ArtFile.Read(artPartStream);
            }
            catch (System.Exception ex)
            {
                Debug.LogException(ex);

                // Inform caller of failure
                onInitCB?.Invoke(false);
                return;
            }

            // Load asset bundle
            coroutineOwner.StartCoroutine(LoadAssetsRoutine(modBundlePaths, onInitCB));
        }
Exemplo n.º 5
0
        public void Write_PaletteColors()
        {
            ArtFile artFile = GetTestArtFile();

            byte red  = 255;
            byte blue = 0;

            artFile.palettes[0].colors[0] = new Color(red, 0, blue, 0);

            using (MemoryStream stream = new MemoryStream())
            {
                artFile.Write(stream);

                // Check ArtFile palette remains unchanged after write
                Assert.AreEqual(red, artFile.palettes[0].colors[0].red);
                Assert.AreEqual(blue, artFile.palettes[0].colors[0].blue);

                // Check ArtFile palette written to disk properly
                stream.Seek(0, SeekOrigin.Begin);
                artFile = ArtFile.Read(stream);
                Assert.AreEqual(red, artFile.palettes[0].colors[0].red);
                Assert.AreEqual(blue, artFile.palettes[0].colors[0].blue);
            }
        }
Exemplo n.º 6
0
 public void ReadEmptyFile()
 {
     Assert.ThrowsException <EndOfStreamException>(() => ArtFile.Read("src/Sprite/data/Empty.prt"));
 }