Example #1
0
        // import design from extracted design data
        public void ImportItems(DesignItemCol items, bool calculateOffsets, bool foundation)
        {
            if (items.Count == 0)
            {
                return;
            }

            _items.Clear();

            for (int i = 0; i < items.Count; ++i)
            {
                DesignItem item = items[i];

                int xoffset = 0;
                int yoffset = 0;
                int zoffset = 0;

                if (!foundation)
                {
                    item.Z += LevelZ[1];
                }

                if (calculateOffsets)
                {
                    xoffset = item.X - items.OriginX;
                    yoffset = item.Y - items.OriginY;
                    zoffset = item.Z - items.OriginZ;
                }
                else
                {
                    xoffset = item.X;
                    yoffset = item.Y;
                    zoffset = item.Z;
                }

                _items.Add(new DesignItem(item.ItemID, xoffset, yoffset, zoffset, GetZLevel(zoffset), item.Hue));
            }

            UpdateSize();
        }
Example #2
0
        public ArrayList ImportDesigns()
        {
            ArrayList designs  = new ArrayList();
            string    filename = GetImportFileName();

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

            try
            {
                using (StreamReader reader = new StreamReader(File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read)))
                {
                    string        line;
                    char[]        delimiter   = new char[] { '\t' };
                    DesignData    design      = null;
                    DesignItemCol designItems = new DesignItemCol();

                    while ((line = reader.ReadLine()) != null)
                    {
                        if (line.Length == 0)
                        {
                            continue;
                        }

                        string[] Values = line.Split(delimiter);

                        if (Values.Length > 5)                        // this is the multi header line
                        {
                            if (design != null && designItems.Count > 0)
                            {
                                design.ImportItems(designItems, true, true);
                                designs.Add(design);
                                design = null;
                                designItems.Clear();
                            }

                            design = new DesignData("Multi " + designs.Count + 1, "multicache", "misc");
                        }
                        else if (Values.Length == 5)                         // this is a multi component
                        {
                            if (design != null)
                            {
                                DesignItem item = new DesignItem();

                                item.ItemID = Convert.ToInt16(Values[0]);
                                item.X      = Convert.ToInt32(Values[2]);
                                item.Y      = Convert.ToInt32(Values[3]);
                                item.Z      = Convert.ToInt32(Values[4]);

                                if (item.ItemID != 1)
                                {
                                    designItems.Add(item);
                                }
                            }
                        }
                    }

                    reader.Close();

                    if (design != null && designItems.Count > 0)
                    {
                        design.ImportItems(designItems, true, true);
                        designs.Add(design);
                    }
                }
            }
            catch
            {
            }

            return(designs);
        }