void CreateSubContainerDefaultNodes()
        {
            var param    = CSParam as BehaviorTree_CustomServiceControlConstructionParams;
            var miAssist = new CustomMethodInfo();

            miAssist.MethodName  = "CustomService_" + ValidName;
            miAssist.DisplayName = "CustomService_" + NodeName;
            var eTime = new CustomMethodInfo.FunctionParam();

            eTime.ParamType = new VariableType(typeof(long), param.CSType);
            eTime.ParamName = "elapseTime";
            miAssist.InParams.Add(eTime);
            var context = new CustomMethodInfo.FunctionParam();

            context.ParamType = new VariableType(typeof(EngineNS.GamePlay.Actor.GCenterData), param.CSType);
            context.ParamName = "context";
            context.Attributes.Add(new EngineNS.Editor.Editor_MacrossMethodParamTypeAttribute(BTCenterDataWarpper.CenterDataType));
            miAssist.InParams.Add(context);
            var nodeType = typeof(CodeDomNode.MethodCustom);
            var csParam  = new CodeDomNode.MethodCustom.MethodCustomConstructParam()
            {
                CSType             = param.CSType,
                HostNodesContainer = mLinkedNodesContainer,
                ConstructParam     = "",
                IsShowProperty     = false,
                MethodInfo         = miAssist,
            };
            var node = mLinkedNodesContainer.AddOrigionNode(nodeType, csParam, 0, 100);

            node.IsDeleteable              = false;
            node.NodeNameAddShowNodeName   = false;
            mLinkedNodesContainer.HostNode = this;
        }
        internal async Task SetPropertyCustomBindOperation(EngineNS.UISystem.UIElement uiElement, string bindPropertyName, Type bindPropertyType)
        {
            Macross.Category category = Macross_Client.GetCategory(MacrossPanel.UIBindFuncCategoryName);
            var item = new Macross.CategoryItem(null, category);

            item.CategoryItemType = Macross.CategoryItem.enCategoryItemType.Unknow;
            item.CanDrag          = false;
            item.InitTypeStr      = "UI_UIElement_PropertyCustomBind";
            var data = new UIElementPropertyCustomBindCategoryitemInitData();

            data.Reset();
            data.UIElement    = uiElement;
            data.UIElementId  = uiElement.Id;
            data.PropertyName = bindPropertyName;
            data.PropertyType = bindPropertyType;
            data.FunctionName = $"UIBindFunc_{bindPropertyName}_{uiElement.Id.ToString().Replace("-","_")}_{item.Id.ToString().Replace("-", "_")}";// bindFunctionName;
            item.Initialize(Macross_Client, data);
            category.Items.Add(item);
            uiElement.PropertyBindFunctions[bindPropertyName] = data.FunctionName;

            var varItemPro     = item.PropertyShowItem as UIElementPropertyCustomBindCategoryItemPropertys;
            var nodesContainer = await Macross_Client.CreateNodesContainer(item);

            var nodeType = typeof(CodeDomNode.MethodCustom);
            var csParam  = new CodeDomNode.MethodCustom.MethodCustomConstructParam()
            {
                CSType             = Macross_Client.CSType,
                HostNodesContainer = nodesContainer.NodesControl,
                ConstructParam     = "",
                MethodInfo         = varItemPro.MethodInfo,
                IsShowProperty     = false,
            };
            var node = nodesContainer.NodesControl.AddOrigionNode(nodeType, csParam, 0, 0);

            node.IsDeleteable            = false;
            node.NodeNameAddShowNodeName = false;
            nodesContainer.Save();

            await Macross_Client.ShowNodesContainer(item);
        }
Example #3
0
        async System.Threading.Tasks.Task InitializeLinkedNodesContainer()
        {
            var param  = CSParam as MethodInvoke_DelegateControlConstructionParams;
            var assist = this.HostNodesContainer.HostControl as Macross.NodesControlAssist;

            if (mLinkedNodesContainer == null)
            {
                var data = new CodeGenerateSystem.Base.SubNodesContainerData()
                {
                    ID    = Id,
                    Title = HostNodesContainer.TitleString + "/" + param.ParamInfo.ParamName + ":" + this.Id.ToString(),
                };
                mLinkedNodesContainer = await assist.GetSubNodesContainer(data);

                if (!data.IsCreated)
                {
                    return;
                }
            }
            // 读取graph
            var tempFile      = assist.HostControl.GetGraphFileName(assist.LinkedCategoryItemName);
            var linkXndHolder = await EngineNS.IO.XndHolder.LoadXND(tempFile, EngineNS.Thread.Async.EAsyncTarget.AsyncEditor);

            bool bLoaded = false;

            if (linkXndHolder != null)
            {
                var linkNode = linkXndHolder.Node.FindNode("SubLinks");
                var idStr    = Id.ToString();
                foreach (var node in linkNode.GetNodes())
                {
                    if (node.GetName() == idStr)
                    {
                        await mLinkedNodesContainer.Load(node);

                        bLoaded = true;
                        break;
                    }
                }
            }
            if (bLoaded)
            {
                await ResetNodesMethodInfo();
            }
            else
            {
                InitDelegateMethodInfo();

                var csParam = new CodeDomNode.MethodCustom.MethodCustomConstructParam()
                {
                    CSType             = param.CSType,
                    HostNodesContainer = mLinkedNodesContainer,
                    ConstructParam     = "",
                    MethodInfo         = param.DelegateMethodInfo,
                    IsShowProperty     = false,
                };
                var node = mLinkedNodesContainer.AddOrigionNode(typeof(CodeDomNode.MethodCustom), csParam, 0, 0) as CodeDomNode.MethodCustom;
                node.IsDeleteable = false;


                var retCSParam = new CodeDomNode.ReturnCustom.ReturnCustomConstructParam()
                {
                    CSType             = param.CSType,
                    HostNodesContainer = mLinkedNodesContainer,
                    ConstructParam     = "",
                    MethodInfo         = param.DelegateMethodInfo,
                    ShowPropertyType   = ReturnCustom.ReturnCustomConstructParam.enShowPropertyType.ReturnValue,
                };
                var retNode = mLinkedNodesContainer.AddOrigionNode(typeof(CodeDomNode.ReturnCustom), retCSParam, 300, 0) as CodeDomNode.ReturnCustom;
                retNode.IsDeleteable = false;
            }
        }
        internal async Task SetVariableBindOperation(EngineNS.UISystem.VariableBindInfo bindInfo)
        {
            var category   = Macross_Client.GetCategory(MacrossPanel.UIBindFuncCategoryName);
            var bindFromUI = HostControl.mCurrentUIHost.FindChildElement(bindInfo.BindFromUIElementId);
            var bindToUI   = HostControl.mCurrentUIHost.FindChildElement(bindInfo.BindToUIElementId);

            // from->to
            if (bindInfo.BindMode == EngineNS.UISystem.enBindMode.OnWayToSource ||
                bindInfo.BindMode == EngineNS.UISystem.enBindMode.TwoWay)
            {
                var item = new Macross.CategoryItem(null, category);
                item.CategoryItemType = Macross.CategoryItem.enCategoryItemType.Unknow;
                item.CanDrag          = false;
                item.InitTypeStr      = "UI_UIElement_VariableBind";
                var data = new UIElementVariableBindCategoryItemInitData();
                data.Reset();

                data.UIElement            = bindFromUI;
                data.UIElementId          = bindInfo.BindFromUIElementId;
                data.PropertyName         = bindInfo.BindFromPropertyName;
                data.PropertyType         = bindInfo.BindFromPropertyType;
                data.TargetUIElement      = bindToUI;
                data.TargetUIElementId    = bindInfo.BindToUIElementId;
                data.TargetPropertyName   = bindInfo.VariableName;
                data.TargetPropertyType   = bindInfo.BindToVariableType;
                data.FunctionName         = $"UIVariableBindFunc_Set_{bindInfo.BindFromUIElementId.ToString().Replace("-", "_")}_{item.Id.ToString().Replace("-", "_")}";
                bindInfo.FunctionName_Set = data.FunctionName;
                item.Initialize(Macross_Client, data);
                category.Items.Add(item);

                var varItemPro     = item.PropertyShowItem as UIElementVariableBindCategoryItemPropertys;
                var nodesContainer = await Macross_Client.CreateNodesContainer(item);

                var nodeType = typeof(CodeDomNode.MethodCustom);
                var csParam  = new CodeDomNode.MethodCustom.MethodCustomConstructParam()
                {
                    CSType             = Macross_Client.CSType,
                    HostNodesContainer = nodesContainer.NodesControl,
                    ConstructParam     = "",
                    MethodInfo         = varItemPro.MethodInfo,
                    IsShowProperty     = false,
                };
                var node = nodesContainer.NodesControl.AddOrigionNode(nodeType, csParam, 0, 0);
                node.IsDeleteable            = false;
                node.NodeNameAddShowNodeName = false;

                var retNodeType = typeof(CodeDomNode.ReturnCustom);
                var retCSParam  = new CodeDomNode.ReturnCustom.ReturnCustomConstructParam()
                {
                    CSType             = Macross_Client.CSType,
                    HostNodesContainer = nodesContainer.NodesControl,
                    ConstructParam     = "",
                    MethodInfo         = varItemPro.MethodInfo,
                    ShowPropertyType   = CodeDomNode.ReturnCustom.ReturnCustomConstructParam.enShowPropertyType.ReturnValue,
                };
                var retNode = nodesContainer.NodesControl.AddOrigionNode(retNodeType, retCSParam, 500, 0) as CodeDomNode.ReturnCustom;
                retNode.IsDeleteable = false;

                // 相同或可强转类型自动连接
                var nodePins    = node.GetLinkPinInfos();
                var retNodePins = retNode.GetLinkPinInfos();
                foreach (var pin in nodePins)
                {
                    if (pin.Visibility != Visibility.Visible)
                    {
                        continue;
                    }
                    foreach (var retPin in retNodePins)
                    {
                        if (retPin.Visibility != Visibility.Visible)
                        {
                            continue;
                        }
                        if (CodeGenerateSystem.Base.LinkInfo.CanLinkWith(pin, retPin))
                        {
                            var linkInfo = new CodeGenerateSystem.Base.LinkInfo(nodesContainer.NodesControl.GetDrawCanvas(), pin, retPin);
                        }
                    }
                }

                nodesContainer.Save();

                await Macross_Client.ShowNodesContainer(item);
            }

            // to->from
            if (bindInfo.BindMode == EngineNS.UISystem.enBindMode.OnWay ||
                bindInfo.BindMode == EngineNS.UISystem.enBindMode.TwoWay)
            {
                var item = new Macross.CategoryItem(null, category);
                item.CategoryItemType = Macross.CategoryItem.enCategoryItemType.Unknow;
                item.CanDrag          = false;
                item.InitTypeStr      = "UI_UIElement_VariableBind";
                var data = new UIElementVariableBindCategoryItemInitData();
                data.Reset();
                data.UIElement            = bindToUI;
                data.UIElementId          = bindInfo.BindToUIElementId;
                data.PropertyName         = bindInfo.VariableName;
                data.PropertyType         = bindInfo.BindToVariableType;
                data.TargetUIElement      = bindFromUI;
                data.TargetUIElementId    = bindInfo.BindFromUIElementId;
                data.TargetPropertyName   = bindInfo.BindFromPropertyName;
                data.TargetPropertyType   = bindInfo.BindFromPropertyType;
                data.FunctionName         = $"UIVariableBindFunc_Get_{bindInfo.BindToUIElementId.ToString().Replace("-", "_")}_{item.Id.ToString().Replace("-", "_")}";
                bindInfo.FunctionName_Get = data.FunctionName;
                item.Initialize(Macross_Client, data);
                category.Items.Add(item);

                var varItemPro     = item.PropertyShowItem as UIElementVariableBindCategoryItemPropertys;
                var nodesContainer = await Macross_Client.CreateNodesContainer(item);

                var nodeType = typeof(CodeDomNode.MethodCustom);
                var csParam  = new CodeDomNode.MethodCustom.MethodCustomConstructParam()
                {
                    CSType             = Macross_Client.CSType,
                    HostNodesContainer = nodesContainer.NodesControl,
                    ConstructParam     = "",
                    MethodInfo         = varItemPro.MethodInfo,
                    IsShowProperty     = false,
                };
                var node = nodesContainer.NodesControl.AddOrigionNode(nodeType, csParam, 0, 0);
                node.IsDeleteable            = false;
                node.NodeNameAddShowNodeName = false;

                var retNodeType = typeof(CodeDomNode.ReturnCustom);
                var retCSParam  = new CodeDomNode.ReturnCustom.ReturnCustomConstructParam()
                {
                    CSType             = Macross_Client.CSType,
                    HostNodesContainer = nodesContainer.NodesControl,
                    ConstructParam     = "",
                    MethodInfo         = varItemPro.MethodInfo,
                    ShowPropertyType   = CodeDomNode.ReturnCustom.ReturnCustomConstructParam.enShowPropertyType.ReturnValue,
                };
                var retNode = nodesContainer.NodesControl.AddOrigionNode(retNodeType, retCSParam, 500, 0) as CodeDomNode.ReturnCustom;
                retNode.IsDeleteable = false;

                // 相同或可强转类型自动连接
                bool childLinked     = false;
                var  nodeChildren    = node.GetChildNodes();
                var  retNodeChildren = retNode.GetChildNodes();
                foreach (var nodeChild in nodeChildren)
                {
                    foreach (var retNodeChild in retNodeChildren)
                    {
                        foreach (var pin in nodeChild.GetLinkPinInfos())
                        {
                            if (pin.Visibility != Visibility.Visible)
                            {
                                continue;
                            }
                            foreach (var retPin in retNodeChild.GetLinkPinInfos())
                            {
                                if (retPin.Visibility != Visibility.Visible)
                                {
                                    continue;
                                }
                                if (CodeGenerateSystem.Base.LinkInfo.CanLinkWith(pin, retPin))
                                {
                                    var linkInfo = new CodeGenerateSystem.Base.LinkInfo(nodesContainer.NodesControl.GetDrawCanvas(), pin, retPin);
                                    childLinked = true;
                                }
                            }
                        }
                    }
                }
                if (childLinked)
                {
                    var nodePins    = node.GetLinkPinInfos();
                    var retNodePins = retNode.GetLinkPinInfos();
                    foreach (var pin in nodePins)
                    {
                        if (pin.Visibility != Visibility.Visible)
                        {
                            continue;
                        }
                        foreach (var retPin in retNodePins)
                        {
                            if (retPin.Visibility != Visibility.Visible)
                            {
                                continue;
                            }
                            if (CodeGenerateSystem.Base.LinkInfo.CanLinkWith(pin, retPin))
                            {
                                var linkInfo = new CodeGenerateSystem.Base.LinkInfo(nodesContainer.NodesControl.GetDrawCanvas(), pin, retPin);
                            }
                        }
                    }
                }

                nodesContainer.Save();

                await Macross_Client.ShowNodesContainer(item);
            }

            List <EngineNS.UISystem.VariableBindInfo> infos;

            if (!bindFromUI.VariableBindInfosDic.TryGetValue(bindInfo.BindFromPropertyName, out infos))
            {
                infos = new List <EngineNS.UISystem.VariableBindInfo>();
                bindFromUI.VariableBindInfosDic[bindInfo.BindFromPropertyName] = infos;
            }
            infos.Add(bindInfo);

            HostControl.ChangeToLogic();
        }
        internal async Task SetEventFunction(EngineNS.UISystem.UIElement element, string functionName, Type eventType)
        {
            Macross.Category category = Macross_Client.GetCategory(MacrossPanel.UIEventFuncCategoryName);
            var item = new Macross.CategoryItem(null, category);

            item.CategoryItemType = Macross.CategoryItem.enCategoryItemType.Unknow;
            item.CanDrag          = true;
            item.InitTypeStr      = "UI_UIElement_Event";
            var data = new UIElementEventCategoryItemInitData();

            data.Reset();
            data.UIElement    = element;
            data.UIElementId  = element.Id;
            data.FunctionName = functionName;
            data.EventType    = eventType;
            item.Initialize(Macross_Client, data);
            category.Items.Add(item);
            string dicValue;
            var    key = new UIResourceInfo.UIEventDicKey(element.Id, functionName);

            if (!HostControl.CurrentResInfo.UIEventsDic.TryGetValue(key, out dicValue))
            {
                HostControl.CurrentResInfo.UIEventsDic[key] = item.Name;
            }

            // 创建NodesContainer
            var varItemPro     = item.PropertyShowItem as UIElementEventCategoryItemPorpertys;
            var nodesContainer = await Macross_Client.CreateNodesContainer(item);

            var nodeType = typeof(CodeDomNode.MethodCustom);
            var csParam  = new CodeDomNode.MethodCustom.MethodCustomConstructParam()
            {
                CSType             = Macross_Client.CSType,
                HostNodesContainer = nodesContainer.NodesControl,
                ConstructParam     = "",
                MethodInfo         = varItemPro.MethodInfo,
                IsShowProperty     = false,
            };
            var node = nodesContainer.NodesControl.AddOrigionNode(nodeType, csParam, 0, 0);

            node.IsDeleteable            = false;
            node.NodeNameAddShowNodeName = false;

            // 有输出参数时才默认添加return
            if (varItemPro.MethodInfo.OutParams.Count > 0)
            {
                var retNodeType = typeof(CodeDomNode.ReturnCustom);
                var retParam    = new CodeDomNode.ReturnCustom.ReturnCustomConstructParam()
                {
                    CSType             = Macross_Client.CSType,
                    HostNodesContainer = nodesContainer.NodesControl,
                    ConstructParam     = "",
                    MethodInfo         = varItemPro.MethodInfo,
                    ShowPropertyType   = CodeDomNode.ReturnCustom.ReturnCustomConstructParam.enShowPropertyType.ReturnValue,
                };
                var retNode = nodesContainer.NodesControl.AddOrigionNode(retNodeType, retParam, 300, 0) as CodeDomNode.ReturnCustom;
                retNode.IsDeleteable = false;
            }
            nodesContainer.Save();

            await Macross_Client.ShowNodesContainer(item);
        }