Example #1
0
        public ArrayList ImportDesigns()
        {
            ArrayList designs = new ArrayList();

            string[] filenames = GetImportFileNames();

            if (filenames == null)
            {
                return(designs);
            }

            foreach (string filename in filenames)
            {
                if (!File.Exists(filename))
                {
                    continue;
                }

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

                short version = reader.ReadShort();

                switch (version)
                {
                case 1:
                    // file contains only one design (old format)
                    designs.Add(ImportDesign(reader, version));
                    break;

                case 2:
                    // file may contain multiple designs
                    int designCount = reader.ReadShort();

                    for (int i = 0; i < designCount; ++i)
                    {
                        designs.Add(ImportDesign(reader, version));
                    }

                    break;
                }

                reader.Close();
            }

            return(designs);
        }
Example #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);
        }
Example #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);
        }