private void areaModify_Click(object sender, EventArgs e)
        {
            if (facetView.SelectedNode != null)
            {
                RegionTag tag = (RegionTag)facetView.SelectedNode.Tag;
                Region    r   = tag.Parent;

                RegionArea ra = r.Area[tag.Index];

                SpecifyArea sa = new SpecifyArea();
                sa.Initialize(xSlider.Maximum, ySlider.Maximum, ra.Area, ra.ZMin);
                sa.ShowDialog(this);

                if (sa.Canceled)
                {
                    return;
                }

                Rectangle area = sa.Area;
                int       zmin = sa.zMin;

                ChangesMade = true;

                facetView.SelectedNode.Text = String.Format("x={0}, y={1}, width={2}, height={3}{4}", area.X, area.Y, area.Width, area.Height,
                                                            (zmin != 9999 ? String.Format(", zmin={0}", zmin) : ""));

                r.Area[tag.Index] = new RegionArea(area, zmin);
            }
        }
        private void FindRegionRecursivly(TreeNode oParentNode)
        {
            foreach (TreeNode oSubNode in oParentNode.Nodes)
            {
                RegionTag tag = (RegionTag)oSubNode.Tag;
                Region    r   = tag.Parent;

                if (r != null)
                {
                    foreach (RegionArea ra in r.Area)
                    {
                        mapDisplay.HighlightedRegion.Add(ra.Area);
                    }

                    foreach (Region rg in r.Regions)
                    {
                        foreach (RegionArea ra in rg.Area)
                        {
                            mapDisplay.HighlightedRegion.Add(ra.Area);
                        }
                    }

                    GotoLocation(r.GoLocation.X, r.GoLocation.Y);

                    return;
                }

                FindRegionRecursivly(oSubNode);
            }
        }
        private void modifySpawn_Click(object sender, EventArgs e)
        {
            if (facetView.SelectedNode != null)
            {
                RegionTag tag = (RegionTag)facetView.SelectedNode.Tag;
                Region    r   = tag.Parent;

                Spawn s = r.Spawns[tag.Index];

                ModifySpawn ms = new ModifySpawn();
                ms.Initialize(s);
                ms.ShowDialog(this);

                if (ms.Canceled)
                {
                    return;
                }

                ChangesMade = true;

                s = ms.Spawn;

                facetView.SelectedNode.Text = String.Format("ID={0}, Type={1}, MinSeconds={2}, MaxSeconds={3}, Amount={4}",
                                                            s.SpawnID.ToString(), s.SpawnType, s.SpawnMinSeconds.ToString(), s.SpawnMaxSeconds.ToString(), s.SpawnAmount.ToString());

                r.Spawns[tag.Index] = s;
            }
        }
        private void addSpawn_Click(object sender, EventArgs e)
        {
            Region   r    = null;
            TreeNode node = null;

            FindRegionNode(ref r, ref node, false);

            if (node == null || r == null)
            {
                return;
            }

            ModifySpawn ms = new ModifySpawn();

            ms.ShowDialog(this);

            if (ms.Canceled)
            {
                return;
            }

            ChangesMade = true;

            Spawn s = ms.Spawn;

            r.Spawns.Add(s);

            bool spawnNodeFound = false;

            foreach (TreeNode child in node.Nodes)
            {
                RegionTag tag = (RegionTag)child.Tag;

                if (tag.Reference == "spawns")
                {
                    spawnNodeFound = true;

                    TreeNode spawnNode = new TreeNode(String.Format("ID={0}, Type={1}, MinSeconds={2}, MaxSeconds={3}, Amount={4}",
                                                                    s.SpawnID.ToString(), s.SpawnType, s.SpawnMinSeconds.ToString(), s.SpawnMaxSeconds.ToString(), s.SpawnAmount.ToString()));

                    spawnNode.Tag = new RegionTag(r, "spawndef", r.Spawns.Count - 1);
                    child.Nodes.Add(spawnNode);
                }
            }

            if (!spawnNodeFound)
            {
                TreeNode childNode = new TreeNode("Spawns");
                childNode.Tag = new RegionTag(r, "spawns");

                TreeNode spawnNode = new TreeNode(String.Format("ID={0}, Type={1}, MinSeconds={2}, MaxSeconds={3}, Amount={4}",
                                                                s.SpawnID.ToString(), s.SpawnType, s.SpawnMinSeconds.ToString(), s.SpawnMaxSeconds.ToString(), s.SpawnAmount.ToString()));

                spawnNode.Tag = new RegionTag(r, "spawndef", r.Spawns.Count - 1);
                childNode.Nodes.Add(spawnNode);

                node.Nodes.Add(childNode);
            }
        }
        private void removeRegion_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Delete region?", "Confirm Delete", MessageBoxButtons.YesNo);

            if (result != System.Windows.Forms.DialogResult.Yes)
            {
                return;
            }

            Region    r    = null;
            TreeNode  node = null;
            RegionTag tag  = new RegionTag();

            FindRegionNode(ref r, ref node, true, true, ref tag);

            if (node == null)
            {
                return;
            }

            ChangesMade = true;

            TreeNode parent = node.Parent;

            if (tag.Parent == null)
            {
                facet.Regions.RemoveAt(tag.Index);
                facetView.Nodes.Remove(node);

                if (facet.Regions.Count > 0)
                {
                    for (int x = 0; x < facetView.Nodes.Count; x++)
                    {
                        tag = (RegionTag)facetView.Nodes[x].Tag;
                        facetView.Nodes[x].Tag = new RegionTag(tag.Parent, tag.Reference, x, tag.OwnRegion);
                    }
                }
            }
            else
            {
                r.Regions.RemoveAt(tag.Index);

                if (r.Regions.Count > 0)
                {
                    parent.Nodes.Remove(facetView.SelectedNode);

                    for (int x = 0; x < parent.Nodes.Count; x++)
                    {
                        tag = (RegionTag)parent.Nodes[x].Tag;
                        parent.Nodes[x].Tag = new RegionTag(tag.Parent, tag.Reference, x, tag.OwnRegion);
                    }
                }
                else
                {
                    try { parent.Parent.Nodes.Remove(parent); }
                    catch { }
                }
            }
        }
        private void removeArea_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Delete area?", "Confirm Delete", MessageBoxButtons.YesNo);

            if (result != System.Windows.Forms.DialogResult.Yes)
            {
                return;
            }

            if (facetView.SelectedNode != null)
            {
                RegionTag tag    = (RegionTag)facetView.SelectedNode.Tag;
                Region    r      = tag.Parent;
                TreeNode  parent = facetView.SelectedNode.Parent;

                ChangesMade = true;

                r.Area.RemoveAt(tag.Index);

                if (r.Area.Count > 0)
                {
                    parent.Nodes.Remove(facetView.SelectedNode);

                    for (int x = 0; x < parent.Nodes.Count; x++)
                    {
                        tag = (RegionTag)parent.Nodes[x].Tag;
                        parent.Nodes[x].Tag = new RegionTag(tag.Parent, tag.Reference, x);
                    }
                }
                else
                {
                    try { parent.Parent.Nodes.Remove(parent); }
                    catch { }
                }
            }
        }
        private void facetView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (facetView.SelectedNode != null)
            {
                RegionTag tag = (RegionTag)facetView.SelectedNode.Tag;
                Region    r   = tag.Parent;

                addSubRegion.Enabled = true;
                modifyRegion.Enabled = true;
                removeRegion.Enabled = true;
                addSpawn.Enabled     = true;
                addArea.Enabled      = true;

                if (tag.Reference == "spawndef")
                {
                    modifySpawn.Enabled = true;
                    removeSpawn.Enabled = true;
                }
                else
                {
                    modifySpawn.Enabled = false;
                    removeSpawn.Enabled = false;
                }

                if (tag.Reference == "regionarea")
                {
                    removeArea.Enabled = true;
                    areaModify.Enabled = true;
                }
                else
                {
                    removeArea.Enabled = false;
                    areaModify.Enabled = false;
                }
            }
        }
        private void facetView_DoubleClick(object sender, EventArgs e)
        {
            if (facetView.SelectedNode != null)
            {
                RegionTag tag = (RegionTag)facetView.SelectedNode.Tag;
                Region    r   = tag.Parent;

                if (tag.Reference == "regionnode")
                {
                    if (facetView.SelectedNode.IsExpanded)
                    {
                        mapDisplay.HighlightedRegion.Clear();

                        FindRegionRecursivly(facetView.SelectedNode);
                    }
                }
                else if (tag.Reference == "golocation")
                {
                    mapDisplay.HighlightedArea = new Rectangle(r.GoLocation.X, r.GoLocation.Y, 1, 1);
                    GotoLocation(r.GoLocation.X, r.GoLocation.Y);
                }
                else if (tag.Reference == "entrance")
                {
                    mapDisplay.HighlightedArea = new Rectangle(r.Entrance.X, r.Entrance.Y, 1, 1);
                    GotoLocation(r.Entrance.X, r.Entrance.Y);
                }
                else if (tag.Reference == "regionarea")
                {
                    mapDisplay.HighlightedArea = r.Area[tag.Index].Area;

                    bool center = mapDisplay.HighlightedArea.Width < mapDisplay.TileWidth && mapDisplay.HighlightedArea.Height < mapDisplay.TileWidth;

                    GotoLocation(r.Area[tag.Index].Area.X, r.Area[tag.Index].Area.Y, center);
                }
            }
        }
Esempio n. 9
0
        private void facetView_DoubleClick(object sender, EventArgs e)
        {
            if (facetView.SelectedNode != null)
            {
                RegionTag tag = (RegionTag)facetView.SelectedNode.Tag;
                Region    r   = tag.Parent;

                if (tag.Reference == "golocation")
                {
                    mapDisplay.HighlightedArea = new Rectangle(r.GoLocation.X, r.GoLocation.Y, 1, 1);
                    GotoLocation(r.GoLocation.X, r.GoLocation.Y);
                }
                else if (tag.Reference == "entrance")
                {
                    mapDisplay.HighlightedArea = new Rectangle(r.Entrance.X, r.Entrance.Y, 1, 1);
                    GotoLocation(r.Entrance.X, r.Entrance.Y);
                }
                else if (tag.Reference == "regionarea")
                {
                    mapDisplay.HighlightedArea = r.Area[tag.Index].Area;
                    GotoLocation(r.Area[tag.Index].Area.X, r.Area[tag.Index].Area.Y, false);
                }
            }
        }
        private void FindRegionNode(ref Region region, ref TreeNode node)
        {
            RegionTag tag = new RegionTag();

            FindRegionNode(ref region, ref node, true, false, ref tag);
        }
        private void addArea_Click(object sender, EventArgs e)
        {
            Rectangle rect = mapDisplay.HighlightedArea;
            int       zMin = 9999;

            if (rect.Width <= 0)
            {
                SpecifyArea sa = new SpecifyArea();
                sa.Initialize(xSlider.Maximum, ySlider.Maximum);
                sa.ShowDialog();

                if (sa.Canceled)
                {
                    return;
                }

                rect = sa.Area;
                zMin = sa.zMin;
            }

            Region   r    = null;
            TreeNode node = null;

            FindRegionNode(ref r, ref node, false);

            if (node == null || r == null)
            {
                return;
            }

            ChangesMade = true;

            foreach (RegionArea area in r.Area)
            {
                if (area.Area.X == rect.X &&
                    area.Area.Y == rect.Y &&
                    area.Area.Width == rect.Width &&
                    area.Area.Height == rect.Height)
                {
                    return;
                }
            }

            RegionArea newArea = new RegionArea(rect, zMin);

            r.Area.Add(newArea);

            bool areaNodeFound = false;

            foreach (TreeNode child in node.Nodes)
            {
                RegionTag tag = (RegionTag)child.Tag;

                if (tag.Reference == "area")
                {
                    areaNodeFound = true;

                    TreeNode areaNode = new TreeNode(String.Format("x={0}, y={1}, width={2}, height={3}{4}", newArea.Area.X, newArea.Area.Y,
                                                                   newArea.Area.Width, newArea.Area.Height, (newArea.ZMin != 9999 ? String.Format(", zmin={0}", newArea.ZMin) : "")));
                    areaNode.Tag = new RegionTag(r, "regionarea", r.Area.Count - 1);
                    child.Nodes.Add(areaNode);
                }
            }

            if (!areaNodeFound)
            {
                TreeNode childNode = new TreeNode("Area");
                childNode.Tag = new RegionTag(r, "area");

                TreeNode areaNode = new TreeNode(String.Format("x={0}, y={1}, width={2}, height={3}{4}", newArea.Area.X, newArea.Area.Y,
                                                               newArea.Area.Width, newArea.Area.Height, (newArea.ZMin != 9999 ? String.Format(", zmin={0}", newArea.ZMin) : "")));
                areaNode.Tag = new RegionTag(r, "regionarea", r.Area.Count - 1);
                childNode.Nodes.Add(areaNode);

                node.Nodes.Add(childNode);
            }
        }
Esempio n. 12
0
        private void FindRegionNode(ref Region region, ref TreeNode node, bool parent)
        {
            RegionTag tag = new RegionTag();

            FindRegionNode(ref region, ref node, parent, false, ref tag);
        }
Esempio n. 13
0
        private void removeRegion_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Delete region?", "Confirm Delete", MessageBoxButtons.YesNo);

            if (result != System.Windows.Forms.DialogResult.Yes)
                return;

            Region r = null;
            TreeNode node = null;
            RegionTag tag = new RegionTag();

            FindRegionNode(ref r, ref node, true, true, ref tag);

            if (node == null)
                return;

            ChangesMade = true;

            TreeNode parent = node.Parent;

            if (tag.Parent == null)
            {
                facet.Regions.RemoveAt(tag.Index);
                facetView.Nodes.Remove(node);

                if (facet.Regions.Count > 0)
                {
                    for (int x = 0; x < facetView.Nodes.Count; x++)
                    {
                        tag = (RegionTag)facetView.Nodes[x].Tag;
                        facetView.Nodes[x].Tag = new RegionTag(tag.Parent, tag.Reference, x, tag.OwnRegion);
                    }
                }
            }
            else
            {
                r.Regions.RemoveAt(tag.Index);

                if (r.Regions.Count > 0)
                {
                    parent.Nodes.Remove(facetView.SelectedNode);

                    for (int x = 0; x < parent.Nodes.Count; x++)
                    {
                        tag = (RegionTag)parent.Nodes[x].Tag;
                        parent.Nodes[x].Tag = new RegionTag(tag.Parent, tag.Reference, x, tag.OwnRegion);
                    }
                }
                else
                {
                    try { parent.Parent.Nodes.Remove(parent); }
                    catch { }
                }
            }
        }
Esempio n. 14
0
        private void FindRegionNode(ref Region region, ref TreeNode node, bool parent, bool allowNullRegion, ref RegionTag tag)
        {
            if (facetView.SelectedNode == null)
                return;

            region = null;
            node = facetView.SelectedNode;

            bool done = false;

            while (node != null && region == null && !done)
            {
                tag = (RegionTag)node.Tag;

                if (tag.Reference == "regionnode")
                {
                    if (parent)
                        region = tag.Parent;
                    else
                        region = tag.OwnRegion;

                    if (allowNullRegion)
                        done = true;
                }
                else
                    node = node.Parent;
            }
        }
        private void FindRegionNode(ref Region region, ref TreeNode node, bool parent)
        {
            RegionTag tag = new RegionTag();

            FindRegionNode(ref region, ref node, parent, false, ref tag);
        }
        private void FindRegionNode(ref Region region, ref TreeNode node, bool parent, bool allowNullRegion, ref RegionTag tag)
        {
            if (facetView.SelectedNode == null)
            {
                return;
            }

            region = null;
            node   = facetView.SelectedNode;

            bool done = false;

            while (node != null && region == null && !done)
            {
                tag = (RegionTag)node.Tag;

                if (tag.Reference == "regionnode")
                {
                    if (parent)
                    {
                        region = tag.Parent;
                    }
                    else
                    {
                        region = tag.OwnRegion;
                    }

                    if (allowNullRegion)
                    {
                        done = true;
                    }
                }
                else
                {
                    node = node.Parent;
                }
            }
        }
Esempio n. 17
0
        private void FindRegionNode(ref Region region, ref TreeNode node)
        {
            RegionTag tag = new RegionTag();

            FindRegionNode(ref region, ref node, true, false, ref tag);
        }