Exemple #1
0
        private void RewriteXML(object sender, EventArgs e)
        {
            TreeViewMobs.BeginUpdate();
            TreeViewMobs.TreeViewNodeSorter = new GraphicSorter();
            TreeViewMobs.Sort();
            TreeViewMobs.EndUpdate();

            string filepath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;

            string FileName = Path.Combine(filepath, "Animationlist.xml");

            XmlDocument    dom  = new XmlDocument();
            XmlDeclaration decl = dom.CreateXmlDeclaration("1.0", "utf-8", null);

            dom.AppendChild(decl);
            XmlElement sr      = dom.CreateElement("Graphics");
            XmlComment comment = dom.CreateComment("Entries in Mob tab");

            sr.AppendChild(comment);
            comment = dom.CreateComment("Name=Displayed name");
            sr.AppendChild(comment);
            comment = dom.CreateComment("body=Graphic");
            sr.AppendChild(comment);
            comment = dom.CreateComment("type=0:Monster, 1:Sea, 2:Animal, 3:Human/Equipment");
            sr.AppendChild(comment);

            XmlElement elem;

            foreach (TreeNode node in TreeViewMobs.Nodes[0].Nodes)
            {
                elem = dom.CreateElement("Mob");
                elem.SetAttribute("name", node.Text);
                elem.SetAttribute("body", ((int[])node.Tag)[0].ToString());
                elem.SetAttribute("type", ((int[])node.Tag)[1].ToString());

                sr.AppendChild(elem);
            }
            foreach (TreeNode node in TreeViewMobs.Nodes[1].Nodes)
            {
                elem = dom.CreateElement("Equip");
                elem.SetAttribute("name", node.Text);
                elem.SetAttribute("body", ((int[])node.Tag)[0].ToString());
                elem.SetAttribute("type", ((int[])node.Tag)[1].ToString());
                sr.AppendChild(elem);
            }
            dom.AppendChild(sr);
            dom.Save(FileName);
            MessageBox.Show("XML saved", "Rewrite", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
        }
Exemple #2
0
 private void OnClick_Sort(object sender, EventArgs e)
 {
     sortalpha = !sortalpha;
     TreeViewMobs.BeginUpdate();
     if (!sortalpha)
     {
         TreeViewMobs.TreeViewNodeSorter = new GraphicSorter();
     }
     else
     {
         TreeViewMobs.TreeViewNodeSorter = new AlphaSorter();
     }
     TreeViewMobs.Sort();
     TreeViewMobs.EndUpdate();
     LoadListView();
 }
Exemple #3
0
        /// <summary>
        /// Adds Graphic with type and name to List
        /// </summary>
        /// <param name="graphic"></param>
        /// <param name="type"></param>
        /// <param name="name"></param>
        public void AddGraphic(int graphic, int type, string name)
        {
            TreeViewMobs.BeginUpdate();
            TreeViewMobs.TreeViewNodeSorter = null;
            TreeNode nodeParent = new TreeNode(name)
            {
                Tag         = new[] { graphic, type },
                ToolTipText = Animations.GetFileName(graphic)
            };

            if (type == 4)
            {
                TreeViewMobs.Nodes[1].Nodes.Add(nodeParent);
                type = 3;
            }
            else
            {
                TreeViewMobs.Nodes[0].Nodes.Add(nodeParent);
            }

            for (int i = 0; i < GetAnimNames[type].GetLength(0); ++i)
            {
                if (!Animations.IsActionDefined(graphic, i, 0))
                {
                    continue;
                }

                TreeNode node = new TreeNode($"{i} {GetAnimNames[type][i]}")
                {
                    Tag = i
                };

                nodeParent.Nodes.Add(node);
            }

            TreeViewMobs.TreeViewNodeSorter = !_sortAlpha
                ? new GraphicSorter()
                : (IComparer) new AlphaSorter();

            TreeViewMobs.Sort();
            TreeViewMobs.EndUpdate();
            LoadListView();
            TreeViewMobs.SelectedNode = nodeParent;
            nodeParent.EnsureVisible();
        }
Exemple #4
0
        /// <summary>
        /// Adds Graphic with type and name to List
        /// </summary>
        /// <param name="graphic"></param>
        /// <param name="type"></param>
        /// <param name="name"></param>
        public void AddGraphic(int graphic, int type, string name)
        {
            TreeViewMobs.BeginUpdate();
            TreeViewMobs.TreeViewNodeSorter = null;
            TreeNode nodeparent = new TreeNode(name);

            nodeparent.Tag         = new int[] { graphic, type };
            nodeparent.ToolTipText = Animations.GetFileName(graphic);
            if (type == 4)
            {
                TreeViewMobs.Nodes[1].Nodes.Add(nodeparent);
                type = 3;
            }
            else
            {
                TreeViewMobs.Nodes[0].Nodes.Add(nodeparent);
            }


            TreeNode node;

            for (int i = 0; i < AnimNames[type].GetLength(0); ++i)
            {
                if (Animations.IsActionDefined(graphic, i, 0))
                {
                    node     = new TreeNode(i.ToString() + " " + AnimNames[type][i]);
                    node.Tag = i;
                    nodeparent.Nodes.Add(node);
                }
            }
            if (!sortalpha)
            {
                TreeViewMobs.TreeViewNodeSorter = new GraphicSorter();
            }
            else
            {
                TreeViewMobs.TreeViewNodeSorter = new AlphaSorter();
            }
            TreeViewMobs.Sort();
            TreeViewMobs.EndUpdate();
            LoadListView();
            TreeViewMobs.SelectedNode = nodeparent;
            nodeparent.EnsureVisible();
        }
Exemple #5
0
        private bool LoadXml()
        {
            string path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;

            string FileName = Path.Combine(path, "Animationlist.xml");

            if (!(File.Exists(FileName)))
            {
                return(false);
            }
            TreeViewMobs.BeginUpdate();
            TreeViewMobs.Nodes.Clear();


            XmlDocument dom = new XmlDocument();

            dom.Load(FileName);
            XmlElement      xMobs = dom["Graphics"];
            List <TreeNode> nodes = new List <TreeNode>();
            TreeNode        rootnode, node, typenode;

            rootnode      = new TreeNode("Mobs");
            rootnode.Name = "Mobs";
            rootnode.Tag  = -1;
            nodes.Add(rootnode);

            foreach (XmlElement xMob in xMobs.SelectNodes("Mob"))
            {
                string name;
                int    value;
                name  = xMob.GetAttribute("name");
                value = int.Parse(xMob.GetAttribute("body"));
                int type = int.Parse(xMob.GetAttribute("type"));
                node             = new TreeNode(name);
                node.Tag         = new int[] { value, type };
                node.ToolTipText = Animations.GetFileName(value);
                rootnode.Nodes.Add(node);

                for (int i = 0; i < AnimNames[type].GetLength(0); ++i)
                {
                    if (Animations.IsActionDefined(value, i, 0))
                    {
                        typenode     = new TreeNode(i.ToString() + " " + AnimNames[type][i]);
                        typenode.Tag = i;
                        node.Nodes.Add(typenode);
                    }
                }
            }
            rootnode      = new TreeNode("Equipment");
            rootnode.Name = "Equipment";
            rootnode.Tag  = -2;
            nodes.Add(rootnode);

            foreach (XmlElement xMob in xMobs.SelectNodes("Equip"))
            {
                string name;
                int    value;
                name  = xMob.GetAttribute("name");
                value = int.Parse(xMob.GetAttribute("body"));
                int type = int.Parse(xMob.GetAttribute("type"));
                node             = new TreeNode(name);
                node.Tag         = new int[] { value, type };
                node.ToolTipText = Animations.GetFileName(value);
                rootnode.Nodes.Add(node);

                for (int i = 0; i < AnimNames[type].GetLength(0); ++i)
                {
                    if (Animations.IsActionDefined(value, i, 0))
                    {
                        typenode     = new TreeNode(i.ToString() + " " + AnimNames[type][i]);
                        typenode.Tag = i;
                        node.Nodes.Add(typenode);
                    }
                }
            }
            TreeViewMobs.Nodes.AddRange(nodes.ToArray());
            nodes.Clear();
            TreeViewMobs.EndUpdate();
            return(true);
        }