Exemple #1
0
 public void Load(ActionNodeData node, TreeNodeCollection tnc)
 {
     if (node != null && tnc != null)
     {
         List <Node> nc = node.Items;
         for (int i = 0; i < nc.Count; i++)
         {
             ActionNodeData ActionNodeData = nc[i] as ActionNodeData;
             if (ActionNodeData != null)
             {
                 T treeNode = new T();
                 treeNode.Text            = ActionNodeData.Text;
                 treeNode.Parameter       = ActionNodeData;
                 treeNode.ActionCallback += new ActionCallback(delegate(IActionControl sender, ActionEventArgs e)
                 {
                     if (OnActionTreeNodeMouseClick != null)
                     {
                         OnActionTreeNodeMouseClick(treeNode);
                     }
                 });
                 if (ActionNodeData.IsDefault)
                 {
                     treeNode.NotifyAction(treeNode, null);
                 }
                 tnc.Add(treeNode);
                 if (ActionNodeData.Items.Count > 0)
                 {
                     Load(ActionNodeData, treeNode.Nodes);
                 }
             }
         }
     }
 }
Exemple #2
0
        public void Load(List <ActionNodeData> nodes)
        {
            ActionNodeData root = new ActionNodeData();

            root.AddRange(nodes);
            Load(root, Nodes);
        }
    //TODO use NodeType to categorize Types.
    public static BaseNode CreateNode(ActionNodeData aData)
    {
        if (aData.NodeType == null)
        {
            Debug.LogError("Type not set");
            return(null);
        }

        aData.GUID          = string.IsNullOrEmpty(aData.GUID) ? Guid.NewGuid().ToString() : aData.GUID;
        aData.OutputPortIDs = aData.OutputPortIDs ?? new List <string>();

        //The copy prevent the node to modify the list in the ActionNodeData
        List <string> copy = new List <string>();

        foreach (var outputPort in aData.OutputPortIDs)
        {
            copy.Add(outputPort);
        }

        BaseNode node;
        Type     type = Type.GetType(aData.NodeType);

        if (type == typeof(ChangeSceneNode))
        {
            node = ChangeSceneNode.Create("Change Scene", aData.Position, aData.GUID, copy);
        }
        else if (type == typeof(StartNode))
        {
            node = StartNode.Create("Start Node", aData.Position, aData.GUID, copy);
        }
        else if (type == typeof(ConditionalNode))
        {
            node = ConditionalNode.Create("Conditional", aData.Position, aData.GUID, copy);
        }
        else if (type == typeof(MultiNode))
        {
            node = MultiNode.Create("Multi Output", aData.Position, aData.GUID, copy);
        }
        else if (type == typeof(ExitNode))
        {
            node = ExitNode.Create("Exit Node", aData.Position, aData.GUID, copy);
        }
        else if (type == typeof(RandomNode))
        {
            node = RandomNode.Create("Random Node", aData.Position, aData.GUID, copy);
        }
        else if (type == typeof(TakeObjectNode))
        {
            node = TakeObjectNode.Create("Take Object", aData.Position, aData.GUID, copy);
        }
        else
        {
            throw new NotImplementedException($"Node type {type} not handled in NodeFactory");
        }

        node?.SetSerializedScript(aData.SerializedScript);
        return(node);
    }
Exemple #4
0
		void MainForm_Load(object sender, EventArgs e)
		{
			TreeTabScreen tts = new TreeTabScreen();
			ActionNodeData nd = new ActionNodeData();
			nd.Add(typeof(ParserForm).AssemblyQualifiedName, "ParserForm", true);
			this.BeginEmbed();
			this.Embed(tts, EmbedType.Fill);
			this.EndEmbed();
			tts.LoadNodeData(nd);
		}
Exemple #5
0
        void MainForm_Load(object sender, EventArgs e)
        {
            TreeTabScreen  tts = new TreeTabScreen();
            ActionNodeData nd  = new ActionNodeData();

            nd.Add(typeof(ParserForm).AssemblyQualifiedName, "ParserForm", true);
            this.BeginEmbed();
            this.Embed(tts, EmbedType.Fill);
            this.EndEmbed();
            tts.LoadNodeData(nd);
        }
Exemple #6
0
		void MasterForm_Load(object sender, EventArgs e)
		{
			//ScannerScreen scanner = new ScannerScreen();
			TreeTabScreen treetab = new TreeTabScreen();
			Text = string.Concat(Text, " - ", Application.ProductVersion);
			this.BeginEmbed();
			this.Embed(treetab, EmbedType.Fill);
			this.EndEmbed();

			ActionNodeData tn = new ActionNodeData();
			tn.Add(typeof(ScannerScreen).FullName + ",Platform.Startup", "Basic");
			treetab.LoadNodeData(tn);
		}
Exemple #7
0
		void MainForm_Load(object sender, EventArgs e)
		{
			TreeTabScreen tts = new TreeTabScreen();
			ActionNodeData nd = new ActionNodeData();
			nd.Add(typeof(PIDForm).AssemblyQualifiedName, "Pid", true);
			nd.Add(typeof(UrlToolForm).AssemblyQualifiedName, "Url");
            nd.Add(typeof(RemoteExecForm).AssemblyQualifiedName, "Remote");
            nd.Add(typeof(CommonExecution).AssemblyQualifiedName, "Common");
			this.BeginEmbed();
			this.Embed(tts, EmbedType.Fill);
			this.EndEmbed();
			tts.LoadNodeData(nd);
		}
Exemple #8
0
        void ActionTreeView_OnActionTreeNodeMouseClick(object s)
        {
            ScreenTreeNode sender = s as ScreenTreeNode;

            if (sender != null)
            {
                object screenObj = null;
                if (sender.CachedScreen == null)
                {
                    ActionNodeData  data = sender.Parameter as ActionNodeData;
                    Type            type = Type.GetType(data.TypeName);
                    ConstructorInfo ci   = type.GetConstructor(Type.EmptyTypes);
                    screenObj           = ci.Invoke(null);
                    sender.CachedScreen = (Form)screenObj;
                }
                else
                {
                    screenObj = sender.CachedScreen;
                }
                ScreenRegion region = screenObj as ScreenRegion;
                ContentPanel.Embed(region, EmbedType.Fill);
            }
        }
Exemple #9
0
 public void Load(ActionNodeData root)
 {
     Load(root, Nodes);
 }
    public bool OnSelectEntry(SearchTreeEntry SearchTreeEntry, SearchWindowContext context)
    {
        var worldMousePosition = window.rootVisualElement.ChangeCoordinatesTo(window.rootVisualElement.parent,
                                                                              context.screenMousePosition - window.position.position);
        var localMousePosition = graphView.contentViewContainer.WorldToLocal(worldMousePosition);

        BaseNode       node = (BaseNode)SearchTreeEntry.userData;
        ActionNodeData and  = new ActionNodeData
        {
            Position      = new Rect(localMousePosition, graphView.DefaultNodeSize),
            GUID          = Guid.NewGuid().ToString(),
            OutputPortIDs = new List <string>(),
            NodeType      = node.NodeType.AssemblyQualifiedName
        };
        BaseNode temp = NodeFactory.CreateNode(and);

        temp?.Draw(graphView);

        //if tempEdge is not null, this means that the search window
        if (graphView.TempEdge != null && temp != null)
        {
            //get the inpût port of the new node
            var tempInput = graphView.GetInputPorts(temp).ToList();

            if (tempInput.Count == 0)
            {
                graphView.TempPort = null;
                graphView.TempEdge = null;

                return(true);
            }
            var inputPort = tempInput.First();

            //if the output port is single and already connected. Must disconnect it.
            if (graphView.TempPort.capacity == Port.Capacity.Single && graphView.TempPort.connected)
            {
                var edge = graphView.edges.ToList().Where(x => x.output == graphView.TempPort);
                if (edge.Any())
                {
                    var e = edge.First();
                    e.input.Disconnect(e);
                    e.output.Disconnect(e);
                    graphView.RemoveElement(e);
                }
            }
            var tempEdge = new Edge
            {
                input  = inputPort,
                output = graphView.TempPort
            };
            inputPort.Connect(tempEdge);
            graphView.TempPort.Connect(tempEdge);
            graphView.Add(tempEdge);

            graphView.TempPort = null;
            graphView.TempEdge = null;

            return(true);
        }

        //Return false doesn't close window
        return(true);
    }
Exemple #11
0
		public void LoadNodeData(ActionNodeData nodeData)
		{
			ActionTreeView.OnActionTreeNodeMouseClick += new ActionTreeView<ScreenTreeNode>.NodeMouseClickHandler(ActionTreeView_OnActionTreeNodeMouseClick); 
			ActionTreeView.Load(nodeData);
		}
Exemple #12
0
        public void LoadNodeData(ActionNodeData nodeData)
        {
            ActionTreeView.OnActionTreeNodeMouseClick += new ActionTreeView <ScreenTreeNode> .NodeMouseClickHandler(ActionTreeView_OnActionTreeNodeMouseClick);

            ActionTreeView.Load(nodeData);
        }