Ejemplo n.º 1
0
        public void Initialize(IVVVVHost vvvvHost, INodeBrowserHost nodeBrowserHost, IWindowSwitcherHost windowSwitcherHost, IKommunikatorHost kommunikatorHost)
        {
            // Used for Windows Forms message loop
            FIsRunning = true;

            //set blackbox mode?
            this.IsBlackBoxMode = vvvvHost.IsBlackBoxMode;

            // Set VVVV45 to this running vvvv.exe
            Environment.SetEnvironmentVariable(ENV_VVVV, Path.GetFullPath(Shell.CallerPath.ConcatPath("..").ConcatPath("..")));

            FVVVVHost       = vvvvHost;
            NodeInfoFactory = new ProxyNodeInfoFactory(vvvvHost.NodeInfoFactory);

            FVVVVHost.AddMouseClickListener(this);
            FVVVVHost.AddNodeSelectionListener(this);
            FVVVVHost.AddWindowListener(this);
            FVVVVHost.AddWindowSelectionListener(this);
            FVVVVHost.AddComponentModeListener(this);
            FVVVVHost.AddEnumListener(this);

            NodeInfoFactory.NodeInfoUpdated += factory_NodeInfoUpdated;

            // Route log messages to vvvv
            Logger.AddLogger(new VVVVLogger(FVVVVHost));

            DeviceService = new DeviceService(vvvvHost.DeviceService);
            MainLoop      = new MainLoop(vvvvHost.MainLoop);

            ExposedNodeService = new ExposedNodeService(vvvvHost.ExposedNodeService, NodeInfoFactory);

            NodeBrowserHost    = new ProxyNodeBrowserHost(nodeBrowserHost, NodeInfoFactory);
            WindowSwitcherHost = windowSwitcherHost;
            KommunikatorHost   = kommunikatorHost;

            //do not add the entire directory for faster startup
            var catalog = new AggregateCatalog();

            catalog.Catalogs.Add(new AssemblyCatalog(typeof(HDEHost).Assembly.Location));
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(NodeCollection).Assembly.Location));
            //allow plugin writers to add their own factories (deprecated, see below)
            var factoriesPath = ExePath.ConcatPath(@"lib\factories");

            if (Directory.Exists(factoriesPath))
            {
                catalog.Catalogs.Add(new DirectoryCatalog(factoriesPath));
            }

            //register custom assembly resolvers which look also in the PACK_NAME/core and PACK_NAME/core/[x86|x64] folders
            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
            AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += CurrentDomain_ReflectionOnlyAssemblyResolve;

            //search for packs, add factories dir to this catalog, add core dir to assembly search path,
            //add nodes to nodes search path
            var packsPath = Path.Combine(ExePath, "packs");

            if (Directory.Exists(packsPath))
            {
                LoadFactoriesFromLegacyPackages(packsPath, catalog);
            }
            //new package loading system
            LoadFactoriesFromPackages(catalog);

            Container = new CompositionContainer(catalog);
            Container.ComposeParts(this);

            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\VVVV.Nodes.dll"));

            //Get node infos from core plugins here to avoid looping all node infos
            var windowSwitcherNodeInfo = GetNodeInfo(WINDOW_SWITCHER);
            var kommunikatorNodeInfo   = GetNodeInfo(KOMMUNIKATOR);
            var nodeBrowserNodeInfo    = GetNodeInfo(NODE_BROWSER);

            foreach (var factory in AddonFactories)
            {
                if (factory is PatchFactory)
                {
                    NodeCollection.Add(string.Empty, ExePath.ConcatPath(@"lib\nodes\native\"), factory, true, false);
                }
            }

            //now instantiate a NodeBrowser, a Kommunikator and a WindowSwitcher
            FWindowSwitcher = PluginFactory.CreatePlugin(windowSwitcherNodeInfo, null);
            FKommunikator   = PluginFactory.CreatePlugin(kommunikatorNodeInfo, null);
            FNodeBrowser    = PluginFactory.CreatePlugin(nodeBrowserNodeInfo, null);

            this.IsBoygroupClient = FVVVVHost.IsBoygroupClient;
            if (IsBoygroupClient)
            {
                this.BoygroupServerIP = FVVVVHost.BoygroupServerIP;
            }

            var clockport = 3334;

            try
            {
                if (Environment.CommandLine.Contains("/clockport"))
                {
                    var env = Environment.GetCommandLineArgs();
                    var idx = Array.IndexOf(env, "/clockport") + 1;
                    clockport = int.Parse(env[idx]);
                }
            }
            catch (Exception)
            {
                throw new Exception("Could not parse clockport, make sure you have the right syntax, e.g. '/clockport 3344' ");
            }

            //start time server of client
            FNetTimeSync = IsBoygroupClient ? new UDPTimeClient(BoygroupServerIP, clockport) : new UDPTimeServer(clockport);
            FNetTimeSync.Start();

            //now that all basics are set up, see if there are any node search paths to add
            //from the installed packs
            if (Directory.Exists(packsPath))
            {
                LoadNodesFromLegacyPackages(packsPath);
            }
            LoadNodesFromPackages();
        }
Ejemplo n.º 2
0
        public PatchRefactorer(IHDEHost hdeHost, INode2[] selectedNodes, INodeBrowserHost nodeBrowserHost, INodeInfoFactory nodeInfoFactory)
        {
            FNodeInfoFactory = nodeInfoFactory;

            int x    = 0;
            int y    = 0;
            int maxX = 0;
            int maxY = 0;

            int minX = int.MaxValue;
            int minY = int.MaxValue;

            //check selection bounds
            foreach (var node in selectedNodes)
            {
                var bounds = node.GetBounds(BoundsType.Node);
                x += bounds.X;
                y += bounds.Y;

                maxX = Math.Max(maxX, bounds.X + bounds.Width);
                maxY = Math.Max(maxY, bounds.Y + bounds.Height);

                minX = Math.Min(minX, bounds.X);
                minY = Math.Min(minY, bounds.Y);
            }

            var CBorder    = 1500;
            int CPinOffset = CBorder / 3;

            x /= selectedNodes.Length;
            y /= selectedNodes.Length;
            var selectionCenter = new Point(x, y);
            var selectionSize   = new Size((maxX - minX) + CBorder * 2, (maxY - minY) + CBorder * 2);

            //create new nodinfo for subpatch
            var patchPath = Path.GetDirectoryName(hdeHost.ActivePatchWindow.Node.NodeInfo.Filename);

            if (!Path.IsPathRooted(patchPath))
            {
                patchPath = hdeHost.ExePath;
            }
            var patchName = GetUniquePatchName(hdeHost.ActivePatchWindow.Node.NodeInfo.Filename);

            patchPath = Path.Combine(patchPath, patchName) + ".v4p";

            var ni = FNodeInfoFactory.CreateNodeInfo(patchName, "", "", patchPath, true);

            ni.InitialComponentMode = TComponentMode.Hidden;
            ni.Type = NodeType.Patch;
            ni.CommitUpdate();

            //modify the current selection XML
            FDocument = new XmlDocument();
            FDocument.LoadXml(hdeHost.GetXMLSnippetFromSelection());

            //create new subpatch
            var subID = nodeBrowserHost.CreateNode(ni, selectionCenter);
            var patch = new PatchMessage(patchPath);

            //in the new subpatch nodes will have new IDs and bounds
            FOldID2NewID.Clear();
            var newNodeID = 0;
            var origNodes = FDocument.SelectNodes("/PATCH/NODE");

            foreach (XmlNode node in origNodes)
            {
                //modify the ID
                var idAttribute = node.Attributes.GetNamedItem("id");
                var oldID       = int.Parse(idAttribute.Value);
                idAttribute.Value = newNodeID.ToString();
                FOldID2NewID.Add(oldID, newNodeID);
                newNodeID++;

                //modify the bounds
                var bounds = node.SelectNodes("BOUNDS");
                foreach (XmlElement bound in bounds)
                {
                    if ((bound.GetAttribute("type") == "Node") || (bound.GetAttribute("type") == "Box"))
                    {
                        var top  = int.Parse(bound.GetAttribute("top"));
                        var left = int.Parse(bound.GetAttribute("left"));

                        bound.SetAttribute("top", (top - minY + CBorder).ToString());
                        bound.SetAttribute("left", (left - minX + CBorder).ToString());
                    }
                }
            }

            //offset linkpoints
            var origLinks = FDocument.SelectNodes("/PATCH/LINK");

            foreach (XmlElement link in origLinks)
            {
                foreach (XmlElement point in link)
                {
                    var px = int.Parse(point.GetAttribute("x"));
                    var py = int.Parse(point.GetAttribute("y"));

                    point.SetAttribute("x", (px - minX + CBorder).ToString());
                    point.SetAttribute("y", (py - minY + CBorder).ToString());
                }
            }

            FInputNames.Clear();
            FOutputNames.Clear();

            //extract all existing iobox names, as those must not be reused
            foreach (var node in selectedNodes)
            {
                if (node.NodeInfo.Name == "IOBox")
                {
                    var inputConnected  = node.FindPin(GetIOBoxPinName(node.NodeInfo.Category, true)).IsConnected();
                    var outputConnected = node.FindPin(GetIOBoxPinName(node.NodeInfo.Category, false)).IsConnected();
                    if (inputConnected && !outputConnected)
                    {
                        FOutputNames.Add(node.FindPin("Descriptive Name").Spread.Trim('|'));
                    }
                    else if (!inputConnected && outputConnected)
                    {
                        FInputNames.Add(node.FindPin("Descriptive Name").Spread.Trim('|'));
                    }
                }
            }

            //now sort the list of nodes in X from left to right
            //in order to get IOBoxes of leftmost nodes also leftmost
            var nodes          = (from n in selectedNodes orderby n.GetBounds(BoundsType.Node).X select n).ToList();
            var oldPinToNewPin = new Dictionary <string, string>();

            var IOpins     = new Dictionary <string, int>();
            var minInputX  = 0;
            var minOutputX = 0;

            //make connections in the selection
            //for each selected nodes input pin...
            foreach (var node in nodes)
            {
                foreach (var pin in node.Pins)
                {
                    foreach (var cpin in pin.ConnectedPins)
                    {
                        if (!cpin.Name.Contains("ROUTER DON'T USE"))                         //hack for S/R nodes
                        {
                            //..if there is a connection to another selected node in the same patch
                            //(pins of IOboxes can also be connected to nodes in parentpatches!)
                            var parent = cpin.ParentNodeByPatch(node.Parent);
                            if (parent != null)
                            {
                                if (FOldID2NewID.ContainsKey(parent.ID))
                                {
                                    //this needs only be done for inputs
                                    if (pin.Direction == PinDirection.Input)
                                    {
                                        var fromID   = parent.ID;
                                        var toID     = pin.ParentNodeByPatch(node.Parent).ID;
                                        var fromName = cpin.NameByParent(parent);
                                        var toName   = pin.NameByParent(node);

                                        //copy over complete link (including linkpoints)
                                        var link = (from XmlElement l in origLinks where
                                                    (l.GetAttribute("srcnodeid") == fromID.ToString() &&
                                                     l.GetAttribute("dstnodeid") == toID.ToString() &&
                                                     l.GetAttribute("srcpinname") == fromName &&
                                                     l.GetAttribute("dstpinname") == toName) select l).First() as XmlElement;
                                        link.SetAttribute("srcnodeid", FOldID2NewID[fromID].ToString());
                                        link.SetAttribute("dstnodeid", FOldID2NewID[toID].ToString());

                                        patch.XML.AppendChild(patch.XML.OwnerDocument.ImportNode(link, true));
                                    }
                                }
                                //..if there is a connection to a not selected node
                                else
                                {
                                    //an IO pin needs to be created
                                    //- if it doesn't exist yet (multiple inputs may connect to an upstream pin and an IO pin may already exist now)
                                    //- if the connected pin belongs to a (preexisting) labeled iobox
                                    string ident = "";
                                    if (pin.Direction == PinDirection.Input)
                                    {
                                        ident = parent.ID.ToString() + cpin.NameByParent(parent);
                                    }
                                    else if (pin.Direction == PinDirection.Output)
                                    {
                                        ident = node.ID.ToString() + pin.NameByParent(node);
                                    }

                                    if ((node.NodeInfo.Name == "IOBox") && (!string.IsNullOrEmpty(node.LabelPin[0])))
                                    {
                                        if (!IOpins.ContainsKey(ident))
                                        {
                                            IOpins.Add(ident, newNodeID);
                                            oldPinToNewPin.Add(ident, node.LabelPin[0]);
                                        }
                                    }

                                    if (!IOpins.ContainsKey(ident))
                                    {
                                        var pinType = pin.Type;
                                        //create an iobox of the right type
                                        var iobox = CreateIOBox(patch, pinType);

                                        iobox.ID = newNodeID;
                                        var bounds = node.GetBounds(BoundsType.Node);

                                        //name the iobox
                                        var labelPin  = iobox.AddPin("Descriptive Name");
                                        var boxBounds = iobox.AddBounds(BoundsType.Box);

                                        if (pin.Direction == PinDirection.Input)
                                        {
                                            boxBounds.Rectangle = new Rectangle(Math.Max(minInputX, bounds.X - minX + CBorder), CPinOffset, 750, 240);

                                            //an input-pin may be connected to an output-pin
                                            //that in turn is connected to multiple inputs
                                            //in those cases name the iobox by concatenating the names of all those pins (which are in the selection!)
                                            //but leave out duplicates
                                            var pinName = GetNameForInput(node.Parent, cpin);
                                            pinName = GetUniqueInputName(pinName);
                                            oldPinToNewPin.Add(ident, pinName);
                                            labelPin.SetAttribute("values", "|" + pinName + "|");

                                            //save it for reference
                                            IOpins.Add(ident, newNodeID);
                                            var ioboxOutput = GetIOBoxPinName(pinType, false);
                                            patch.AddLink(newNodeID, ioboxOutput, FOldID2NewID[pin.ParentNodeByPatch(node.Parent).ID], pin.NameByParent(node));

                                            minInputX = boxBounds.Rectangle.X + boxBounds.Rectangle.Width + 150;
                                        }
                                        else if (pin.Direction == PinDirection.Output)
                                        {
                                            boxBounds.Rectangle = new Rectangle(Math.Max(minOutputX, bounds.X - minX + CBorder), (maxY - minY) + CPinOffset + CBorder, 750, 240);
                                            var origName = pin.NameByParent(node);
                                            var pinName  = GetUniqueOutputName(origName);
                                            oldPinToNewPin.Add(ident, pinName);
                                            labelPin.SetAttribute("values", "|" + pinName + "|");

                                            //save it for reference
                                            IOpins.Add(pin.ParentNodeByPatch(node.Parent).ID.ToString() + origName, newNodeID);
                                            var ioboxInput = GetIOBoxPinName(pinType, true);
                                            patch.AddLink(FOldID2NewID[node.ID], origName, newNodeID, ioboxInput);

                                            minOutputX = boxBounds.Rectangle.X + boxBounds.Rectangle.Width + 150;
                                        }

                                        var nodeBounds = iobox.AddBounds(BoundsType.Node);
                                        nodeBounds.Rectangle = boxBounds.Rectangle;
                                        newNodeID++;
                                    }
                                    else     //IOpin already exists
                                    {
                                        var srcID = IOpins[ident];
                                        //this needs only be done for inputs
                                        if (pin.Direction == PinDirection.Input)
                                        {
                                            patch.AddLink(srcID, GetIOBoxPinName(cpin.Type, false), FOldID2NewID[pin.ParentNodeByPatch(node.Parent).ID], pin.NameByParent(node));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //remove superfluous links from origXML
            var linksToRemove = FDocument.DocumentElement.SelectNodes("/PATCH/LINK");

            foreach (XmlElement link in linksToRemove)
            {
                FDocument.DocumentElement.RemoveChild(link);
            }

            foreach (XmlElement node in patch.XML)
            {
                var n = FDocument.ImportNode(node, true);
                FDocument.DocumentElement.AppendChild(n);
            }
            hdeHost.SendXMLSnippet(patchPath, FDocument.OuterXml, true);

            //make connections to new subpatch
            patch = new PatchMessage("");

            foreach (var node in selectedNodes)
            {
                foreach (var pin in node.Pins)
                {
                    foreach (var cpin in pin.ConnectedPins)
                    {
                        if (!cpin.Name.Contains("ROUTER DON'T USE"))                          //hack for S/R nodes
                        //..if there is a connection to a not selected node..
                        {
                            var parent = cpin.ParentNodeByPatch(node.Parent);
                            //..in the same patch..
                            if (parent != null)
                            {
                                if (!FOldID2NewID.ContainsKey(parent.ID))
                                {
                                    if (pin.Direction == PinDirection.Input)
                                    {
                                        patch.AddLink(parent.ID, cpin.NameByParent(parent), subID, oldPinToNewPin[parent.ID.ToString() + cpin.NameByParent(parent)]);
                                    }
                                    else if (pin.Direction == PinDirection.Output)
                                    {
                                        patch.AddLink(subID, oldPinToNewPin[pin.ParentNodeByPatch(node.Parent).ID.ToString() + pin.NameByParent(node)], parent.ID, cpin.NameByParent(parent));
                                    }
                                }
                            }
                            else     //..in the parentpatch
                            {
                                if (pin.Direction == PinDirection.Input)
                                {
                                    patch.AddLink(node.ID, cpin.Name, subID, node.LabelPin.Spread.Trim('|'));
                                }
                                else if (pin.Direction == PinDirection.Output)
                                {
                                    patch.AddLink(subID, node.LabelPin.Spread.Trim('|'), node.ID, cpin.Name);
                                }
                            }
                        }
                    }
                }
            }

            //..and remove selected nodes
            //if they are not labeled ioboxes that are connected in a parentpatch!
            foreach (var node in selectedNodes)
            {
                var delete = true;
                //if this is a labeled iobox check if any of its pins is connected in a parentpatch to not delete it in that case
                if ((node.NodeInfo.Name == "IOBox") &&
                    (!string.IsNullOrEmpty(node.LabelPin.Spread)))
                {
                    foreach (var pin in node.Pins)
                    {
                        foreach (var cpin in pin.ConnectedPins)
                        {
                            if (cpin.ParentNodeByPatch(node.Parent) == null)
                            {
                                delete = false;
                                break;
                            }
                        }
                    }
                }

                if (delete)
                {
                    var nodeMessage = patch.AddNode(node.ID);
                    nodeMessage.DeleteMe = true;
                }
            }

            var nodeMsg = patch.AddNode(subID);

            nodeMsg.ComponentMode = ComponentMode.Hidden;
            //enabling this fukcs it up:
            var nodeB = nodeMsg.AddBounds(BoundsType.Node);

            nodeB.Rectangle = new Rectangle(selectionCenter.X, selectionCenter.Y, 0, 0);
            var boxB = nodeMsg.AddBounds(BoundsType.Box);

            boxB.Rectangle = new Rectangle(selectionCenter.X - selectionSize.Width / 2, selectionCenter.Y - selectionSize.Height / 2, selectionSize.Width, selectionSize.Height);
            var windowB = nodeMsg.AddBounds(BoundsType.Window);

            windowB.Rectangle = new Rectangle(300 + selectionCenter.X + hdeHost.ActivePatchWindow.Bounds.X * 15, 300 + selectionCenter.Y + hdeHost.ActivePatchWindow.Bounds.Y * 15, selectionSize.Width, selectionSize.Height);

            hdeHost.SendXMLSnippet(hdeHost.ActivePatchWindow.Node.NodeInfo.Filename, patch.ToString(), true);
        }
Ejemplo n.º 3
0
        public void Initialize(IVVVVHost vvvvHost, INodeBrowserHost nodeBrowserHost, IWindowSwitcherHost windowSwitcherHost, IKommunikatorHost kommunikatorHost)
        {
            //set blackbox mode?
            this.IsBlackBoxMode = vvvvHost.IsBlackBoxMode;

            // Set VVVV45 to this running vvvv.exe
            Environment.SetEnvironmentVariable(ENV_VVVV, Path.GetFullPath(Shell.CallerPath.ConcatPath("..").ConcatPath("..")));

            FVVVVHost       = vvvvHost;
            NodeInfoFactory = new ProxyNodeInfoFactory(vvvvHost.NodeInfoFactory);

            FVVVVHost.AddMouseClickListener(this);
            FVVVVHost.AddNodeSelectionListener(this);
            FVVVVHost.AddWindowListener(this);
            FVVVVHost.AddWindowSelectionListener(this);
            FVVVVHost.AddComponentModeListener(this);

            NodeInfoFactory.NodeInfoUpdated += factory_NodeInfoUpdated;

            // Route log messages to vvvv
            Logger.AddLogger(new VVVVLogger(FVVVVHost));

            DeviceService = new DeviceService(vvvvHost.DeviceService);
            MainLoop      = new MainLoop(vvvvHost.MainLoop);

            ExposedNodeService = new ExposedNodeService(vvvvHost.ExposedNodeService, NodeInfoFactory);

            NodeBrowserHost    = new ProxyNodeBrowserHost(nodeBrowserHost, NodeInfoFactory);
            WindowSwitcherHost = windowSwitcherHost;
            KommunikatorHost   = kommunikatorHost;

            //do not add the entire directory for faster startup
            var catalog = new AggregateCatalog();

            catalog.Catalogs.Add(new AssemblyCatalog(typeof(HDEHost).Assembly.Location));
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(NodeCollection).Assembly.Location));
            //allow plugin writers to add their own factories (deprecated, see below)
            var factoriesPath = ExePath.ConcatPath(@"lib\factories");

            if (Directory.Exists(factoriesPath))
            {
                catalog.Catalogs.Add(new DirectoryCatalog(factoriesPath));
            }

            //search for packs, add factories dir to this catalog, add core dir to assembly search path,
            //add nodes to nodes search path
            var packsDirInfo = new DirectoryInfo(Path.Combine(ExePath, "packs"));

            if (packsDirInfo.Exists)
            {
                AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
                AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += CurrentDomain_ReflectionOnlyAssemblyResolve;
                foreach (var packDirInfo in packsDirInfo.GetDirectories())
                {
                    var packDir     = packDirInfo.FullName;
                    var coreDirInfo = new DirectoryInfo(Path.Combine(packDir, "core"));
                    if (coreDirInfo.Exists)
                    {
                        FAssemblySearchPaths.Add(coreDirInfo.FullName);
                        var platformDir = IntPtr.Size == 4 ? "x86" : "x64";
                        var platformDependentCorDirInfo = new DirectoryInfo(Path.Combine(coreDirInfo.FullName, platformDir));
                        if (platformDependentCorDirInfo.Exists)
                        {
                            FAssemblySearchPaths.Add(platformDependentCorDirInfo.FullName);
                        }
                    }
                    var factoriesDirInfo = new DirectoryInfo(Path.Combine(packDir, "factories"));
                    if (factoriesDirInfo.Exists)
                    {
                        catalog.Catalogs.Add(new DirectoryCatalog(factoriesDirInfo.FullName));
                    }
                    // We look for nodes later
                }
            }

            Container = new CompositionContainer(catalog);
            Container.ComposeParts(this);

            //NodeCollection.AddJob(Shell.CallerPath.Remove(Shell.CallerPath.LastIndexOf(@"bin\managed")));
            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\VVVV.Nodes.dll"));
//            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\Kommunikator.dll"));
//            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\NodeBrowser.dll"));
//            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\NodeCollector.dll"));
//            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\WindowSwitcher.dll"));

            //Get node infos from core plugins here to avoid looping all node infos
            var windowSwitcherNodeInfo = GetNodeInfo(WINDOW_SWITCHER);
            var kommunikatorNodeInfo   = GetNodeInfo(KOMMUNIKATOR);
            var nodeBrowserNodeInfo    = GetNodeInfo(NODE_BROWSER);

            foreach (var factory in AddonFactories)
            {
                if (factory is PatchFactory)
                {
                    NodeCollection.Add(string.Empty, ExePath.ConcatPath(@"lib\nodes\native\"), factory, true, false);
                }
            }

            //now instantiate a NodeBrowser, a Kommunikator and a WindowSwitcher
            FWindowSwitcher = PluginFactory.CreatePlugin(windowSwitcherNodeInfo, null);
            FKommunikator   = PluginFactory.CreatePlugin(kommunikatorNodeInfo, null);
            FNodeBrowser    = PluginFactory.CreatePlugin(nodeBrowserNodeInfo, null);

            this.IsBoygroupClient = FVVVVHost.IsBoygroupClient;
            if (IsBoygroupClient)
            {
                this.BoygroupServerIP = FVVVVHost.BoygroupServerIP;
            }


            //start time server of client
            FNetTimeSync = IsBoygroupClient ? new UDPTimeClient(BoygroupServerIP, 3334) : new UDPTimeServer(3334);
            FNetTimeSync.Start();

            //now that all basics are set up, see if there are any node search paths to add
            //from the installed packs
            if (packsDirInfo.Exists)
            {
                foreach (var packDirInfo in packsDirInfo.GetDirectories())
                {
                    var packDir      = packDirInfo.FullName;
                    var nodesDirInfo = new DirectoryInfo(Path.Combine(packDir, "nodes"));
                    if (nodesDirInfo.Exists)
                    {
                        NodeCollection.AddJob(nodesDirInfo.FullName, true);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void Initialize(IVVVVHost vvvvHost, INodeBrowserHost nodeBrowserHost, IWindowSwitcherHost windowSwitcherHost, IKommunikatorHost kommunikatorHost)
        {
            // Set VVVV45 to this running vvvv.exe
            Environment.SetEnvironmentVariable(ENV_VVVV, Path.GetFullPath(Shell.CallerPath.ConcatPath("..").ConcatPath("..")));

            FVVVVHost       = vvvvHost;
            NodeInfoFactory = new ProxyNodeInfoFactory(vvvvHost.NodeInfoFactory);

            FVVVVHost.AddMouseClickListener(this);
            FVVVVHost.AddNodeSelectionListener(this);
            FVVVVHost.AddWindowListener(this);
            FVVVVHost.AddWindowSelectionListener(this);

            NodeInfoFactory.NodeInfoUpdated += factory_NodeInfoUpdated;

            // Route log messages to vvvv
            Logger.AddLogger(new VVVVLogger(FVVVVHost));

            DeviceService = new DeviceService(vvvvHost.DeviceService);
            MainLoop      = new MainLoop(vvvvHost.MainLoop);

            ExposedNodeService = new ExposedNodeService(vvvvHost.ExposedNodeService, NodeInfoFactory);

            NodeBrowserHost    = new ProxyNodeBrowserHost(nodeBrowserHost, NodeInfoFactory);
            WindowSwitcherHost = windowSwitcherHost;
            KommunikatorHost   = kommunikatorHost;

            //do not add the entire directory for faster startup
            var catalog = new AggregateCatalog();

            catalog.Catalogs.Add(new AssemblyCatalog(typeof(HDEHost).Assembly.Location));
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(NodeCollection).Assembly.Location));
            //allow plugin writers to add their own factories
            var factoriesPath = ExePath.ConcatPath(@"lib\factories");

            if (Directory.Exists(factoriesPath))
            {
                catalog.Catalogs.Add(new DirectoryCatalog(factoriesPath));
            }
            Container = new CompositionContainer(catalog);
            Container.ComposeParts(this);

            //NodeCollection.AddJob(Shell.CallerPath.Remove(Shell.CallerPath.LastIndexOf(@"bin\managed")));
            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\VVVV.Nodes.dll"));
//            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\Kommunikator.dll"));
//            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\NodeBrowser.dll"));
//            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\NodeCollector.dll"));
//            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\WindowSwitcher.dll"));

            //Get node infos from core plugins here to avoid looping all node infos
            var windowSwitcherNodeInfo = GetNodeInfo(WINDOW_SWITCHER);
            var kommunikatorNodeInfo   = GetNodeInfo(KOMMUNIKATOR);
            var nodeBrowserNodeInfo    = GetNodeInfo(NODE_BROWSER);

            foreach (var factory in AddonFactories)
            {
                if (factory is PatchFactory)
                {
                    NodeCollection.Add(string.Empty, ExePath.ConcatPath(@"lib\nodes\native\"), factory, true, false);
                }
            }

            //now instantiate a NodeBrowser, a Kommunikator and a WindowSwitcher
            FWindowSwitcher = PluginFactory.CreatePlugin(windowSwitcherNodeInfo, null);
            FKommunikator   = PluginFactory.CreatePlugin(kommunikatorNodeInfo, null);
            FNodeBrowser    = PluginFactory.CreatePlugin(nodeBrowserNodeInfo, null);

            this.IsBoygroupClient = FVVVVHost.IsBoygroupClient;
            if (IsBoygroupClient)
            {
                this.BoygroupServerIP = FVVVVHost.BoygroupServerIP;
            }


            //start time server of client
            FNetTimeSync = IsBoygroupClient ? new UDPTimeClient(BoygroupServerIP, 3334) : new UDPTimeServer(3334);
            FNetTimeSync.Start();
        }
Ejemplo n.º 5
0
 public ProxyNodeBrowserHost(INodeBrowserHost nodeBrowserHost, ProxyNodeInfoFactory nodeInfoFactory)
 {
     FNodeBrowserHost = nodeBrowserHost;
     FNodeInfoFactory = nodeInfoFactory;
 }