Пример #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);
        }
Пример #2
0
        /// <summary>
        /// Converts selected nodes to events. Will ask for confirmation via a dialog box for converting non-empty folders.
        /// </summary>
        public void ConvertSelectedNodesToEvents()
        {
            bool convertFolders = 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;

                convertFolders = convertFolders || (node.Nodes.Count > 0);
            }

            convertFolders = convertFolders && MessageBox.Show("Selection contains non-empty folders.\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())
            {
                //Node was already removed since a folder with it was converted to comment earlier in this loop
                if (TreeViewNodes.FindNode((TreeNode x) => x == node) == null)
                    continue;
                //Cant touch start node
                if (node.Tag is MissionNode_Start)
                    continue;
                //Skip nodes of already correct type
                if (node.Tag is MissionNode_Event)
                    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 (!convertFolders && node.Nodes.Count > 0)
                    continue;

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

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

                convertedCount++;
            }

            if (convertedCount > 0)
                RegisterChange("Converted node(s) type to event");
        }
Пример #3
0
        /// <summary>
        /// Add new event to the mission
        /// </summary>
        /// <param name="nodeUnderCursor">Specified when inserting via dropdown menu, unspecified when inserting via hotkey</param>
        public void NodeAddEvent(TreeNode nodeUnderCursor = null)
        {
            EventCount++;

            TreeNode newTNode = new TreeNode();
            MissionNode_Event newMNode = new MissionNode_Event();

            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 event node");
        }
Пример #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;
        }