private void BuildRegionNode(Region r, ref TreeNode parentNode) { TreeNode childNode = null; if (r.RuneName != null) { childNode = new TreeNode(String.Format("Rune Name = \"{0}\"", r.RuneName)); childNode.Tag = new RegionTag(r, "runename"); parentNode.Nodes.Add(childNode); } if (r.GoLocation.X != 9999) { childNode = new TreeNode(String.Format("Go Location : ({0}, {1}, {2})", r.GoLocation.X, r.GoLocation.Y, r.GoLocationZ)); childNode.Tag = new RegionTag(r, "golocation"); parentNode.Nodes.Add(childNode); } if (r.Entrance.X != 9999) { childNode = new TreeNode(String.Format("Entrance : ({0}, {1})", r.Entrance.X, r.Entrance.Y)); childNode.Tag = new RegionTag(r, "entrance"); parentNode.Nodes.Add(childNode); } if (r.MusicName != null) { childNode = new TreeNode(String.Format("Music : {0}", r.MusicName)); childNode.Tag = new RegionTag(r, "music"); parentNode.Nodes.Add(childNode); } if (r.MinZRange != 9999) { childNode = new TreeNode(String.Format("Minimum Z Range : {0}", r.MinZRange)); childNode.Tag = new RegionTag(r, "minzrange"); parentNode.Nodes.Add(childNode); } if (!r.LogoutDelayActive) { childNode = new TreeNode(String.Format("Logout Delay Not Active")); childNode.Tag = new RegionTag(r, "logoutdelay"); parentNode.Nodes.Add(childNode); } if (r.GuardsDisabled) { childNode = new TreeNode(String.Format("Guards Disabled")); childNode.Tag = new RegionTag(r, "guards"); parentNode.Nodes.Add(childNode); } if (r.SmartNoHousing) { childNode = new TreeNode(String.Format("Smart NoHousing Active")); childNode.Tag = new RegionTag(r, "smartnohousing"); parentNode.Nodes.Add(childNode); } if (r.Type == "QuestOfferRegion" || r.Type == "CancelQuestRegion") { childNode = new TreeNode(String.Format("Quest Type : \"{0}\"", r.QuestType)); childNode.Tag = new RegionTag(r, "questtype"); parentNode.Nodes.Add(childNode); } if (r.Type == "QuestNoEntryRegion") { childNode = new TreeNode(String.Format("Quest Type : \"{0}\", Objective = \"{1}\", Message = {2}", r.QuestType, r.QuestMin, r.QuestMessage)); childNode.Tag = new RegionTag(r, "questnoentry"); parentNode.Nodes.Add(childNode); } if (r.Type == "QuestCompleteObjectiveRegion") { childNode = new TreeNode(String.Format("Quest Type : \"{0}\", Objective = \"{1}\"", r.QuestType, r.QuestComplete)); childNode.Tag = new RegionTag(r, "questcomplete"); parentNode.Nodes.Add(childNode); } childNode = new TreeNode("Area"); childNode.Tag = new RegionTag(r, "area"); for (int x = 0; x < r.Area.Count; x++) { RegionArea ra = r.Area[x]; TreeNode areaNode = new TreeNode(String.Format("x={0}, y={1}, width={2}, height={3}{4}", ra.Area.X, ra.Area.Y, ra.Area.Width, ra.Area.Height, (ra.ZMin != 9999 ? String.Format(", zmin={0}", ra.ZMin) : ""))); areaNode.Tag = new RegionTag(r, "regionarea", x); childNode.Nodes.Add(areaNode); } if (childNode.Nodes.Count > 0) { parentNode.Nodes.Add(childNode); } childNode = new TreeNode("Spawns"); childNode.Tag = new RegionTag(r, "spawns"); for (int x = 0; x < r.Spawns.Count; x++) { Spawn s = r.Spawns[x]; 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", x); childNode.Nodes.Add(spawnNode); } if (childNode.Nodes.Count > 0) { parentNode.Nodes.Add(childNode); } childNode = new TreeNode("Regions"); childNode.Tag = new RegionTag(r, "regions"); for (int x = 0; x < r.Regions.Count; x++) { Region region = r.Regions[x]; TreeNode regionNode = new TreeNode(String.Format("{0}{1}{2}", (region.Name != null ? region.Name : "(Unnamed Region)"), (region.Priority != 9999 ? String.Format(", Priority : {0}", region.Priority) : ""), (region.Type != null ? String.Format(", [{0}]", region.Type) : ""))); regionNode.Tag = new RegionTag(r, "regionnode", x, region); BuildRegionNode(region, ref regionNode); childNode.Nodes.Add(regionNode); } if (childNode.Nodes.Count > 0) { parentNode.Nodes.Add(childNode); } }
private void FindRegionNode(ref Region region, ref TreeNode node) { RegionTag tag = new RegionTag(); FindRegionNode(ref region, ref node, true, false, ref tag); }
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 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); } }