Пример #1
0
        public IEnumerable <MenuAction <ConversationNode> > GetMenuActions(IGraphEditorControl <ConversationNode> control, IProject2 project, Action <IEnumerable <IErrorListElement> > log, ILocalizationEngine localizer)
        {
            Action <ConversationNode, Point> jump = (n, p) =>
            {
                if (n.Data.NodeTypeId == SpecialNodes.JumpTo)
                {
                    var targetnodes = control.CurrentFile.Nodes.Where(a => a.Data.NodeTypeId == SpecialNodes.JumpTarget);
                    var target      = targetnodes.FirstOrDefault(t => GetId(t) == GetTarget(n));
                    if (target != null)
                    {
                        control.SelectNode(target);
                    }
                }
                else if (n.Data.NodeTypeId == SpecialNodes.JumpTarget)
                {
                    var sourceNodes = control.CurrentFile.Nodes.Where(a => a.Data.NodeTypeId == SpecialNodes.JumpTo);
                    var source      = sourceNodes.FirstOrDefault(t => GetTarget(t) == GetId(n));
                    if (source != null)
                    {
                        control.SelectNode(source);
                    }
                }
            };

            yield return(new MenuAction <ConversationNode>("Jump", (n, p) => (n.Data.NodeTypeId == SpecialNodes.JumpTo || n.Data.NodeTypeId == SpecialNodes.JumpTarget ? () => jump(n, p) : (Action)null), null, null, null));
        }
Пример #2
0
 public override IEnumerable <MenuAction <ConversationNode> > GetMenuActions(IGraphEditorControl <ConversationNode> control, IProject2 project, Action <IEnumerable <IErrorListElement> > log, ILocalizationEngine localizer)
 {
     foreach (var action in base.GetMenuActions(control, project, log, localizer))
     {
         yield return(action);
     }
     yield return(new MenuAction <ConversationNode>("Find References", (n, p) => () => FileReferences(n), null, null, null));
 }
Пример #3
0
        public IEnumerable <MenuAction <ConversationNode> > GetMenuActions(IGraphEditorControl <ConversationNode> control, IProject2 project, Action <IEnumerable <IErrorListElement> > log, ILocalizationEngine localizer)
        {
            XmlGraphData <NodeUIData, ConversationEditorData> data;
            Assembly assembly = Assembly.GetExecutingAssembly();

            using (Stream stream = assembly.GetManifestResourceStream("Clandestine.Templates.Basic Conversation.xml"))
            {
                data = SerializationUtils.ConversationDeserializer(control.DataSource).Read(stream);
            }

            yield return(new MenuAction <ConversationNode>("Basic Conversation", (a, b) => null, null, null, p =>
            {
                control.Insert(p, Tuple.Create(data.Nodes, data.EditorData.Groups, new object(), true));
            }));
        }
Пример #4
0
        public virtual IEnumerable <MenuAction <ConversationNode> > GetMenuActions(IGraphEditorControl <ConversationNode> control, IProject2 project, Action <IEnumerable <IErrorListElement> > log, ILocalizationEngine localizer)
        {
            MenuAction <ConversationNode> addNodes = new MenuAction <ConversationNode>("Add Node", (n, p) => null, null, null, p => { });

            AddNodeMenuItem(addNodes, control.DataSource.Nodes, control);
            yield return(addNodes);

            yield return(new MenuAction <ConversationNode>("Reset Zoom", (n, p) => null, null, null, (p) => { control.GraphScale = 1; }));

            yield return(new MenuAction <ConversationNode>("Paste", (n, p) => null, null, null, (p) => { control.Paste(p); }));

            yield return(new MenuAction <ConversationNode>("Delete", (n, p) => () => { control.CurrentFile.Remove(n.Only(), Enumerable.Empty <NodeGroup>(), localizer); }, null, null, null));

            yield return(new MenuAction <ConversationNode>("Remove Links", (n, p) => () => { foreach (var c in n.Data.Connectors)
                                                                                             {
                                                                                                 control.CurrentFile.RemoveLinks(c);
                                                                                             }
                                                           }, (i, p) => { control.CurrentFile.RemoveLinks(i); }, null, null));

            yield return(new MenuAction <ConversationNode>("Copy ID", (n, p) => control.ShowIds ? () => Clipboard.SetText(n.Data.NodeId.Serialized()) : (Action)null, null, null, null));
        }
Пример #5
0
 public IEnumerable <MenuAction <ConversationNode> > GetMenuActions(IGraphEditorControl <ConversationNode> control, IProject2 project, Action <IEnumerable <IErrorListElement> > log, ILocalizationEngine localizer)
 {
     yield return(new MenuAction <ConversationNode>("Reset Zoom", (n, p) => null, null, null, (p) => { control.GraphScale = 1; }));
     //yield return new MenuAction2<ConversationNode>("Delete", (n, p) => () => { Delete(n); }, null, null, null);
     //yield return new MenuAction2<ConversationNode>("Remove Links", (n, p) => null, (i, p) => { control.CurrentFile.RemoveLinks(i); }, null, null);
 }
Пример #6
0
 private void AddNodeMenuItem(MenuAction <ConversationNode> menu, INodeType node, IGraphEditorControl <ConversationNode> control)
 {
     foreach (var n in node.Nodes.OrderBy(n => n.Name))
     {
         var nn   = n;
         var name = nn.Name;
         menu.Add(new MenuAction <ConversationNode>(name, (nnn, p) => null, null, null, p => { control.AddNode(nn, p); }));
     }
     foreach (var n in node.ChildTypes)
     {
         var nn = n;
         var a  = menu.Add(new MenuAction <ConversationNode>(nn.Name, (nnn, p) => null, null, null, p => { }));
         AddNodeMenuItem(a, nn, control);
     }
 }
Пример #7
0
 public IEnumerable <MenuAction <ConversationNode <INodeGui> > > GetMenuActions(IGraphEditorControl <ConversationNode <INodeGui> > control, IProject2 project, Action <IEnumerable <IErrorListElement> > log, ILocalizationEngine localizer)
 {
     //XmlGraphData<NodeUIData, ConversationEditorData> data;
     //Assembly assembly = Assembly.GetExecutingAssembly();
     //using (Stream stream = assembly.GetManifestResourceStream("PluginPack.Templates.Basic Conversation.xml"))
     //{
     //    data = SerializationUtils.ConversationDeserializer(control.DataSource).Read(stream);
     //}
     yield return(new MenuAction <ConversationNode>("Find Nodes of Type", (a, b) => () =>
     {
         var nodesofType = project.ConversationFilesCollection.SelectMany(f => f.Nodes.Where(n => n.Data.NodeTypeId == a.Data.NodeTypeId).Select(n => new { Node = n, File = f }));
         log(nodesofType.Select(n => new LogElement(n.File, n.Node, localizer)));
     }
                                                    , null, null, null));
 }