Esempio 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);
        }
Esempio n. 2
0
        /// <summary> Clone this MissionNode appropriately</summary>
        public object Clone()
        {
            //Copy mission node
            MissionNode result = MissionNode.NewFromXML(this.ToXml(new XmlDocument(), true));

            //Exchange IDs
            if (result.ID.HasValue)
            {
                if (Helper.GuidDictionary.ContainsKey(result.ID.Value))
                {
                    result.ID = Helper.GuidDictionary[result.ID.Value];
                }
                else
                {
                    Helper.GuidDictionary.Add(result.ID.Value, (result.ID = Guid.NewGuid()).Value);
                }
            }
            if (result.ParentID.HasValue)
            {
                if (Helper.GuidDictionary.ContainsKey(result.ParentID.Value))
                {
                    result.ParentID = Helper.GuidDictionary[result.ParentID.Value];
                }
                else
                {
                    Helper.GuidDictionary.Add(result.ParentID.Value, (result.ParentID = Guid.NewGuid()).Value);
                }
            }

            return(result);
        }
        public static MissionStatement NewFromXML(XmlNode item, MissionNode parent)
        {
            MissionStatement mn = new MissionStatement(parent);

            mn.FromXml(item);

            mn.Update();

            return(mn);
        }
 public MissionStatement(MissionNode parent)
 {
     Parent                 = parent;
     Name                   = "";
     Body                   = "";
     Attributes             = new Dictionary <string, string>();
     Expression             = new List <ExpressionMemberContainer>();
     _invalidatedLabel      = true;
     _invalidatedExpression = true;
     _updating              = false;
     IsCommentary           = false;
 }
 public MissionStatement(MissionNode parent)
 {
     Parent = parent;
     Name = "";
     Body = "";
     Attributes = new Dictionary<string, string>();
     Expression = new List<ExpressionMemberContainer>();
     _invalidatedLabel = true;
     _invalidatedExpression = true;
     _updating = false;
     IsCommentary = false;
 }
Esempio n. 6
0
 /// <summary>
 /// Insert "Create Nameless" statement to the node. Called from ParseSpaceMapCreateResults.
 /// </summary>
 private void ParseSpaceMapCreateResults_InsertNameless(ref int i, MissionNode curNode, int position, SpaceMap.Space result, XmlDocument xDoc, List<string> missingProperties)
 {
     i--;
     missingProperties.Clear();
     curNode.Actions.Insert(position,
         MissionStatement.NewFromXML(result.NamelessObjects[i].ToXml(xDoc, missingProperties), curNode));
     if (missingProperties.Count > 0 && Settings.Current.AddFailureComments)
     {
         curNode.Actions.Insert(position,
         MissionStatement.NewFromXML(xDoc.CreateComment("will fail because it lacks " + missingProperties.Aggregate((x, y) => x + ", " + y) + " "), curNode));
     }
 }
Esempio n. 7
0
        /// <summary> 
        /// Check if the mission node matches the search criteria, return search result if it does 
        /// </summary>
        private MissionSearchResult Find_CheckNodeForMatch(TreeNode node, MissionNode mNode, int curNode, MissionSearchCommand msc)
        {
            bool statisfies = false;

            //We are interested in event/start/folder nodes...
            if (msc.NodeNames && (node.Tag is MissionNode_Event || node.Tag is MissionNode_Folder || node.Tag is MissionNode_Start))
                statisfies = statisfies | Find_CheckStringForMatch(mNode.Name, msc);

            //... or commentaries
            if (msc.Commentaries && node.Tag is MissionNode_Comment)
                statisfies = statisfies | Find_CheckStringForMatch(mNode.Name, msc);

            if (statisfies)
                return new MissionSearchResult(curNode, 0, mNode.Name, node, null);

            return new MissionSearchResult(curNode, 0, null, node, null);
        }
        public static MissionStatement NewFromXML(XmlNode item, MissionNode parent)
        {
            MissionStatement mn = new MissionStatement(parent);

            mn.FromXml(item);

            mn.Update();

            return mn;
        }