Ejemplo n.º 1
0
 private void ActionAddCustomProperty(object sender, EventArgs e)
 {
     if (treeView1.SelectedNode.Tag is Item)
     {
         Item i = (Item)treeView1.SelectedNode.Tag;
         AddCustomProperty form = new AddCustomProperty(i.CustomProperties);
         form.ShowDialog();
     }
     if (treeView1.SelectedNode.Tag is root)
     {
         root l = (root)treeView1.SelectedNode.Tag;
         AddCustomProperty form = new AddCustomProperty(l.CustomProperties);
         form.ShowDialog();
     }
     if (treeView1.SelectedNode.Tag is Layer)
     {
         Layer             l    = (Layer)treeView1.SelectedNode.Tag;
         AddCustomProperty form = new AddCustomProperty(l.CustomProperties);
         form.ShowDialog();
     }
     if (treeView1.SelectedNode.Tag is CustomNode)
     {
     }
     propertyGrid1.Refresh();
 }
Ejemplo n.º 2
0
        public void loadroot(String filename)
        {
            root root = root.FromFile(filename, Game1.Instance.Content);

            Editor.Instance.loadroot(root);
            rootfilename = filename;
            DirtyFlag    = false;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Must be called after all Items have been deserialized.
 /// Restores the Item references in CustomProperties of type Item.
 /// </summary>
 public void RestoreItemAssociations(root root)
 {
     foreach (CustomProperty cp in Values)
     {
         if (cp.type == typeof(Item))
         {
             cp.value = root.getItemByName((string)cp.value);
         }
     }
 }
Ejemplo n.º 4
0
        public static root FromFile(string filename)
        {
            FileStream    stream     = File.Open(filename, FileMode.Open);
            XmlSerializer serializer = new XmlSerializer(typeof(root));
            root          root       = (root)serializer.Deserialize(stream);

            stream.Close();



            return(root);
        }
Ejemplo n.º 5
0
        public void makelike(IUndoable other)
        {
            /*Layer l2 = (Layer)other;
             * Items = l2.Items;
             * treenode.Nodes.Clear();
             * foreach (Item i in Items)
             * {
             *  Editor.Instance.addItem(i);
             * }*/


            root l2 = (root)other;

            Level = l2.Level;
            treenode.Nodes.Clear();

            Editor.Instance.addLevel(Level);
        }
Ejemplo n.º 6
0
        public IUndoable cloneforundo()
        {
            selecteditems = "";
            foreach (Item i in Editor.Instance.SelectedItems)
            {
                selecteditems += i.Name + ";";
            }
            if (Editor.Instance.SelectedLayer != null)
            {
                selectedlayers = Editor.Instance.SelectedLayer.Name;
            }


            root result = (root)this.MemberwiseClone();

            result.Level      = new Level("Level");
            result.Level      = result.Level.clone();
            result.Level.root = result;
            return((IUndoable)result);
        }
Ejemplo n.º 7
0
        private void treeView1_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            if (e.Label == null)
            {
                return;
            }

            TreeNode[] nodes = treeView1.Nodes.Find(e.Label, true);
            if (nodes.Length > 0)
            {
                MessageBox.Show("A layer or item with the name \"" + e.Label + "\" already exists in the root. Please use another name!");
                e.CancelEdit = true;
                return;
            }
            if (e.Node.Tag is root)
            {
                root l = (root)e.Node.Tag;
                Editor.Instance.beginCommand("Rename root (\"" + l.Name + "\" -> \"" + e.Label + "\")");
                l.Name      = e.Label;
                e.Node.Name = e.Label;
                Editor.Instance.endCommand();
            }
            if (e.Node.Tag is Layer)
            {
                Layer l = (Layer)e.Node.Tag;
                Editor.Instance.beginCommand("Rename Layer (\"" + l.Name + "\" -> \"" + e.Label + "\")");
                l.Name      = e.Label;
                e.Node.Name = e.Label;
                Editor.Instance.endCommand();
            }
            if (e.Node.Tag is Item)
            {
                Item i = (Item)e.Node.Tag;
                Editor.Instance.beginCommand("Rename Item (\"" + i.Name + "\" -> \"" + e.Label + "\")");
                i.Name      = e.Label;
                e.Node.Name = e.Label;
                Editor.Instance.endCommand();
            }
            propertyGrid1.Refresh();
            pictureBox1.Select();
        }
Ejemplo n.º 8
0
        //MENU
        public void newroot()
        {
            Application.DoEvents();

            GLEED2D1.test t = new GLEED2D1.test();

            foreach (GLEED2D1.Archetype arch in t.arch_Root.Archetypes)
            {
                ToolStripMenuItem tt = new ToolStripMenuItem(arch.Name);
                tt.Tag = arch;

                tt.MouseDown += new MouseEventHandler(Editor.Instance.OnClick1);
                setArchetypeToolStripMenuItem.DropDownItems.Add(tt);
            }

            root newroot = new root();

            Editor.Instance.loadroot(newroot);
            rootfilename = "untitled";
            DirtyFlag    = false;
        }
Ejemplo n.º 9
0
        public static root FromFile(string filename, ContentManager cm)
        {
            FileStream    stream     = File.Open(filename, FileMode.Open);
            XmlSerializer serializer = new XmlSerializer(typeof(root));
            root          root       = (root)serializer.Deserialize(stream);

            stream.Close();


            foreach (Layer layer in root.Level.Layers)
            {
                foreach (Item item in layer.Items)
                {
                    item.CustomProperties.RestoreItemAssociations(root);
                    item.load(cm);
                }
            }


            return(root);
        }