Exemple #1
0
        public static RESFile OpenFile(string filePath)
        {
            using (BinaryReader reader = new BinaryReader(File.OpenRead(filePath)))
            {
                RESFile file = new RESFile();

                long fileLength = reader.BaseStream.Length;

                while (reader.BaseStream.Position < fileLength) //TODO: Caching
                {
                    SectionHeader header = new SectionHeader(reader);

                    switch (header.Type)
                    {
                    case SectionType.COLORS:
                        file.ReadColors(reader, header.Count);
                        break;

                    case SectionType.TEXTUREFILES:
                        file.ReadTextureFiles(reader, header.Count);
                        break;

                    case SectionType.PALETTEFILES:
                        file.ReadPalettes(reader, header.Count);
                        break;

                    case SectionType.SOUNDFILES:
                        file.ReadSoundFiles(reader, header.Count);
                        break;

                    case SectionType.BACKFILES:
                        break;

                    case SectionType.MASKFILES:
                        file.ReadMaskFiles(reader, header.Count);
                        break;

                    case SectionType.MATERIALS:
                        file.ReadMaterials(reader, header.Count);
                        break;

                    case SectionType.SOUNDS:
                        file.ReadSoundNames(reader, header.Count);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }

                return(file);
            }
        }
Exemple #2
0
        public void InitMaterial(RESFile baseFile)
        {
            if (_MaterialParameters.Length < 1)
            {
                return;
            }

            MaterialParameters = new List <IMaterialParameter>();

            //TODO: Fix material parameters initialization
            for (int i = 1; i < _MaterialParameters.Length; i++)
            {
                try
                {
                    int skipCount = 0;
                    IMaterialParameter parameter = ParameterFabric.Resolve(_MaterialParameters[i], out skipCount);

                    if (parameter == null)
                    {
                        continue;
                    }

                    string[] matParams = new string[skipCount];
                    for (int j = 0; j < skipCount; j++)
                    {
                        matParams[j] = _MaterialParameters[i + 1 + j];
                    }
                    parameter.Parse(baseFile, matParams);

                    MaterialParameters.Add(parameter);

                    i += skipCount;
                }
                catch (Exception)
                {
                    //Debug.LogException(e);
                    //Debug.LogError($"{i}");
                }
            }
        }
Exemple #3
0
 /// <inheritdoc />
 public void Parse(RESFile file, params string[] options)
 {
     _TransparencyLevel = Single.Parse(options[0], CultureInfo.InvariantCulture);
 }
Exemple #4
0
 /// <inheritdoc />
 public void Parse(RESFile file, params string[] options)
 {
 }
 /// <inheritdoc />
 public void Parse(RESFile file, params string[] options)
 {
     _Texture = file.TextureFiles[Int32.Parse(options[0]) - 1].Item;
 }
 /// <inheritdoc />
 public void Parse(RESFile file, params string[] options)
 {
     _Power = Single.Parse(options[0], CultureInfo.InvariantCulture);
 }
 /// <inheritdoc />
 public void Parse(RESFile file, params string[] options)
 {
     _Power = Single.Parse(options[0]);
 }
 /// <inheritdoc />
 public void Parse(RESFile file, params string[] options)
 {
     _Color = file.Palettes[0].Item.PaletteColors[Int32.Parse(options[0]) - 1];
 }