Esempio n. 1
0
        /// <summary>
        /// Utility methods returning custom view properties from byte array containing view name
        /// </summary>
        /// <param name="currentViewName"></param>
        /// <returns></returns>
        private static Couple <string> _GetViewProperties(byte[] currentViewName)
        {
            Couple <string> returnedProps = null;

            if (currentViewName != null)
            {
                string dirtyName = Array2.BytesToString(currentViewName);

                // Getting every character after the ASCII 0
                int    zeroPos = dirtyName.IndexOf('\0');
                string props   = dirtyName.Substring(zeroPos + 1);

                if (props.Contains(new string(Tools.SYMBOL_VALUE_SEPARATOR, 1)))
                {
                    // Properties are set
                    string[] splittedProps = props.Split(Tools.SYMBOL_VALUE_SEPARATOR);

                    if (splittedProps.Length == 2)
                    {
                        // Cleaning props
                        string parentId   = splittedProps[0];
                        string parentView = (splittedProps[1].Length == 2) ?
                                            splittedProps[1] :
                                            splittedProps[1].Substring(0, splittedProps[1].IndexOf((char)0xCD));

                        returnedProps = new Couple <string>(parentId, parentView);
                    }
                }
            }

            return(returnedProps);
        }
Esempio n. 2
0
        /// <summary>
        /// Utility method returning clean view name from a byte array
        /// </summary>
        /// <param name="currentViewName"></param>
        /// <returns></returns>
        private static string _GetViewName(byte[] currentViewName)
        {
            string returnedName = "";

            if (currentViewName != null)
            {
                string dirtyName = Array2.BytesToString(currentViewName);

                // Removing every character after the ASCII 0
                int zeroPos = dirtyName.IndexOf('\0');

                returnedName = dirtyName.Substring(0, zeroPos);
            }

            return(returnedName);
        }
Esempio n. 3
0
File: _2DB.cs Progetto: djey47/tdumt
        /// <summary>
        /// Lit le contenu du fichier
        /// </summary>
        protected override void _ReadData()
        {
            FileStream   input  = null;
            BinaryReader reader = null;

            try
            {
                input  = new FileStream(_FileName, FileMode.Open, FileAccess.Read);
                reader = new BinaryReader(input);

                // En-tête
                _Header.dwTwo           = reader.ReadUInt32();
                _Header.dwZero1         = reader.ReadUInt32();
                _Header.dwSize          = reader.ReadUInt32();
                _Header.bID1            = reader.ReadBytes(4);
                _Header.bID2            = reader.ReadBytes(4);
                _Header.dwZero2         = reader.ReadUInt32();
                _Header.dwSize2         = reader.ReadUInt32();
                _Header.dwSize2Bis      = reader.ReadUInt32();
                _Header.strName         = reader.ReadBytes(8);
                _Header.width           = reader.ReadInt16();
                _Header.height          = reader.ReadInt16();
                _Header.one             = reader.ReadInt16();
                _Header.bMipMapCount    = reader.ReadByte();
                _Header.bMipMapCountBis = reader.ReadByte();
                _Header.bFormat         = reader.ReadByte();
                _Header.bUnk2           = reader.ReadByte();
                _Header.unk3            = reader.ReadInt16();
                _Header.dwUnk4          = reader.ReadUInt32();
                _Header.dwUnk5          = reader.ReadUInt32();
                _Header.dwType          = reader.ReadUInt32();
                _Header.dwFlags         = reader.ReadUInt32();
                _Header.dwUnk6          = reader.ReadUInt32();
                _Header.dwUnk7          = reader.ReadUInt32();
                _Header.dwZero3         = reader.ReadUInt32();

                // Données d'image
                FileInfo fi = new FileInfo(_FileName);

                _ImageData = reader.ReadBytes((int)(fi.Length - HEADER_SIZE));

                // EVO_65: property support
                Property.ComputeValueDelegate nameDelegate = delegate
                {
                    string textureName =
                        Array2.BytesToString(_Header.strName);

                    return(Tools.OutlineExtendedCharacters(textureName));
                };
                Property.ComputeValueDelegate dimensionsDelegate = delegate { return(_Header.width + "x" + _Header.height); };
                Property.ComputeValueDelegate mipmapDelegate     = delegate { return(_Header.bMipMapCount.ToString()); };
                Property.ComputeValueDelegate formatDelegate     = delegate { return(GetFormatName(_Header.bFormat)); };
                Property.ComputeValueDelegate typeDelegate       = delegate { return(_Header.dwType.ToString()); };
                Property.ComputeValueDelegate flagsDelegate      = delegate { return(_Header.dwFlags.ToString()); };
                Property.ComputeValueDelegate magicDelegate      = delegate { return(_Header.dwUnk6 + " - " + _Header.dwUnk7); };

                _Properties.Add(new Property("Texture name", "2DB", nameDelegate));
                _Properties.Add(new Property("Dimensions", "Texture", dimensionsDelegate));
                _Properties.Add(new Property("Mipmap count", "Texture", mipmapDelegate));
                _Properties.Add(new Property("Format", "2DB", formatDelegate));
                _Properties.Add(new Property("Type", "2DB", typeDelegate));
                _Properties.Add(new Property("Flags", "2DB", flagsDelegate));
                _Properties.Add(new Property("Magic", "2DB", magicDelegate));
            }
            catch (Exception ex)
            {
                Exception2.PrintStackTrace(ex);

                throw;
            }
            finally
            {
                // Fermeture
                if (reader != null)
                {
                    reader.Close();
                }
                if (input != null)
                {
                    input.Close();
                }
            }
        }