Ejemplo n.º 1
0
        //R. Judge: store item on MissionNode with Missionstatement  <-- WTF?
        /// <summary>
        /// Create and return new MissionNode from an XmlNode. Will set type appropriately.
        /// </summary>
        public static MissionNode NewFromXML(XmlNode item)
        {
            MissionNode mn = null;

            switch (item.Name)
            {
            case "event":
                mn = new MissionNode_Event();
                break;

            case "disabled_event":
                mn = new MissionNode_Event();
                break;

            case "start":
                mn = new MissionNode_Start();
                break;

            case "#comment":
                mn = new MissionNode_Comment();
                break;

            case "folder_arme":
                mn = new MissionNode_Folder();
                break;

            default:
                mn = new MissionNode_Unknown();
                break;
            }

            mn.FromXml(item);
            return(mn);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Converts selected nodes to folders. Will ask for confirmation via a dialog box for converting non-empty events.
        /// </summary>
        public void ConvertSelectedNodesToFolders()
        {
            bool convertEvents = false;
            int convertedCount = 0;

            foreach (TreeNode node in TreeViewNodes.SelectedNodes)
            {
                if (node.Tag is MissionNode_Comment && TreeViewNodes.Nodes.IndexOf(_startNode) > TreeViewNodes.Nodes.IndexOf(node))
                    continue;

                convertEvents = convertEvents || (node.Tag is MissionNode_Event && (((MissionNode_Event)node.Tag).Actions.Count > 0 || ((MissionNode_Event)node.Tag).Conditions.Count > 0));
            }

            convertEvents = convertEvents && MessageBox.Show("Selection contains non-empty events.\r\nDo you want them to be converted as well?\r\n(This will clear their contents)", "Artemis Mission Editor", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes;

            foreach (TreeNode node in TreeViewNodes.SelectedNodes.ToList())
            {
                //Cant touch start node
                if (node.Tag is MissionNode_Start)
                    continue;
                //Skip nodes of already correct type
                if (node.Tag is MissionNode_Folder)
                    continue;
                //Cannot convert comment over start node to something else
                if (node.Tag is MissionNode_Comment && TreeViewNodes.Nodes.IndexOf(_startNode) > TreeViewNodes.Nodes.IndexOf(node))
                    continue;
                //Skip nodes user decided not to convert
                if (!convertEvents && (node.Tag is MissionNode_Event && (((MissionNode_Event)node.Tag).Actions.Count > 0 || ((MissionNode_Event)node.Tag).Conditions.Count > 0)))
                    continue;

                MissionNode mn = (MissionNode)node.Tag;
                MissionNode_Folder mnf = new MissionNode_Folder();
                mnf.Name = node.Text;
                if (mn.ID != null)
                {
                    mnf.ID = mn.ID;
                    mnf.ParentID = mn.ParentID;
                }
                else
                {
                    mnf.ID = Guid.NewGuid();
                    mnf.ParentID = null;
                }
                node.Tag = mnf;
                node.ImageIndex = mnf.ImageIndex;
                node.SelectedImageIndex = mnf.ImageIndex;

                if (node == TreeViewNodes.SelectedNode)
                    OutputMissionNodeContentsToStatementTree();

                convertedCount++;
            }

            if (convertedCount > 0)
                RegisterChange("Converted node(s) type to folder");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Add new folder to the mission
        /// </summary>
        /// <param name="nodeUnderCursor">Specified when inserting via dropdown menu, unspecified when inserting via hotkey</param>
        public void NodeAddFolder(TreeNode nodeUnderCursor = null)
        {
            TreeNode newTNode = new TreeNode();
            MissionNode_Folder newMNode = new MissionNode_Folder();

            newTNode.Text = newMNode.Name;
            newTNode.ImageIndex = newMNode.ImageIndex;
            newTNode.SelectedImageIndex = newMNode.ImageIndex;
            newTNode.Tag = newMNode;

            NodeInsertUnderNode(newTNode, nodeUnderCursor ?? TreeViewNodes.SelectedNode);
            TreeViewNodes.SelectedNode = newTNode;

            RegisterChange("New folder node");
        }
Ejemplo n.º 4
0
        //R. Judge: store item on MissionNode with Missionstatement  <-- WTF?
        /// <summary>
        /// Create and return new MissionNode from an XmlNode. Will set type appropriately.
        /// </summary>
        public static MissionNode NewFromXML(XmlNode item)
        {
            MissionNode mn = null;

            switch (item.Name)
            {
                case "event":
                    mn = new MissionNode_Event();
                    break;
                case "disabled_event":
                    mn = new MissionNode_Event();
                    break;
                case "start":
                    mn = new MissionNode_Start();
                    break;
                case "#comment":
                    mn = new MissionNode_Comment();
                    break;
                case "folder_arme":
                    mn = new MissionNode_Folder();
                    break;
                default:
                    mn = new MissionNode_Unknown();
                    break;
            }

            mn.FromXml(item);
            return mn;
        }