Пример #1
0
        public static void LoadDesignHeaders()
        {
            if (File.Exists(INDEX_FILE))
            {
                BinaryFileReader reader = new BinaryFileReader(File.Open(INDEX_FILE, FileMode.Open, FileAccess.Read, FileShare.Read));

                try
                {
                    int count   = reader.ReadInt();
                    int version = reader.ReadInt();

                    m_DesignHeaders = new ArrayList(count);

                    for (int i = 0; i < count; ++i)
                    {
                        DesignData header = new DesignData();

                        switch (version)
                        {
                        case 0:
                            header.Name         = reader.ReadString();
                            header.Category     = reader.ReadString();
                            header.Subsection   = reader.ReadString();
                            header.Width        = reader.ReadInt();
                            header.Height       = reader.ReadInt();
                            header.UserWidth    = reader.ReadInt();
                            header.UserHeight   = reader.ReadInt();
                            header.FilePosition = reader.ReadLong();
                            header.RecordCount  = reader.ReadInt();
                            break;
                        }

                        m_DesignHeaders.Add(header);
                    }
                }
                catch (Exception e)
                {
                    m_DesignHeaders.Clear();
                    System.Windows.Forms.MessageBox.Show("Unable to load the designs\n" + e.Message);
                }
                finally
                {
                    reader.Close();
                }
            }
            else
            {
                m_DesignHeaders = new ArrayList();
            }
        }
Пример #2
0
        public override DesignData ImportDesign()
        {
            string filename = GetImportFileName();

            if (!File.Exists(filename))
            {
                return(null);
            }

            BinaryFileReader reader = new BinaryFileReader(File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read));

            short version = reader.ReadShort();

            DesignData design = new DesignData();

            if (version == 1)
            {
                design.Name       = reader.ReadString();
                design.Category   = reader.ReadString();
                design.Subsection = reader.ReadString();
                design.Width      = reader.ReadInt();
                design.Height     = reader.ReadInt();
                design.UserWidth  = reader.ReadInt();
                design.UserHeight = reader.ReadInt();

                int count = reader.ReadInt();

                for (int i = 0; i < count; ++i)
                {
                    short index = reader.ReadShort();
                    short x     = reader.ReadShort();
                    short y     = reader.ReadShort();
                    short z     = reader.ReadShort();
                    short level = reader.ReadShort();
                    short hue   = reader.ReadShort();

                    design.Items.Add(new DesignItem(index, x, y, z, level, hue));
                }
            }

            reader.Close();

            return(design);
        }
Пример #3
0
        private DesignData ImportDesign(BinaryFileReader reader, short version)
        {
            DesignData design = new DesignData();

            switch (version)
            {
            case 1:
            case 2:
                design.Name       = reader.ReadString();
                design.Category   = reader.ReadString();
                design.Subsection = reader.ReadString();
                design.Width      = reader.ReadInt();
                design.Height     = reader.ReadInt();
                design.UserWidth  = reader.ReadInt();
                design.UserHeight = reader.ReadInt();

                int count = reader.ReadInt();

                for (int i = 0; i < count; ++i)
                {
                    short index = reader.ReadShort();
                    short x     = reader.ReadShort();
                    short y     = reader.ReadShort();
                    short z     = reader.ReadShort();
                    short level = reader.ReadShort();
                    short hue   = reader.ReadShort();

                    design.Items.Add(new DesignItem(index, x, y, z, level, hue));

                    _itemCount++;
                }
                break;
            }

            return(design);
        }