コード例 #1
0
        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;
            }
        }
コード例 #2
0
        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);
            }
        }