Beispiel #1
0
        public Bridge InstencePanel(IPanelBase parentPanel, string panelName, Transform root)
        {
            Bridge     bridge = null;
            UIInfoBase uiNode = null;

            if (TryMatchPanel(parentPanel, panelName, out bridge, out uiNode))
            {
                uiNode.OnCreate = (go) =>
                {
                    Utility.SetTranform(go.transform, uiNode.type.layer, uiNode.type.layerIndex, root == null ? Trans : root);
                    go.SetActive(true);
                    var panel = go.GetComponent <IPanelBase>();
                    if (panel != null)
                    {
                        createdPanels.Add(panel);
                        if (parentPanel != null)
                        {
                            parentPanel.RecordChild(panel);
                        }
                        bridgeDic.Add(panel, bridge);
                        InitPanel(panel, bridge, uiNode);
                        HandBridgeOptions(panel, bridge);
                    }
                };
                creater.CreatePanel(uiNode);
            }
            return(bridge);
        }
Beispiel #2
0
 /// <summary>
 /// 按规则设置面板及父亲面板的状态
 /// </summary>
 /// <param name="panel"></param>
 /// <param name="root"></param>
 /// <param name="bridge"></param>
 private void InitPanel(IPanelBase panel, Bridge bridge, UIInfoBase uiNode)
 {
     panel.UType     = uiNode.type;
     panel.Group     = this;
     panel.onDelete += OnDeletePanel;
     panel.HandleData(bridge);
 }
Beispiel #3
0
        private void CreateUI_Internal(GameObject go, UIInfoBase uiNode, Bridge bridge, Transform parent, IUIPanel parentPanel)
        {
            if (go == null)
            {
                return;
            }

            var parentDic = GetParentDic(parent);

            Utility.SetTranform(go.transform, uiNode.type.layer, uiNode.type.layerIndex, Trans, parent, parentDic, transRefDic);

            go.name = uiNode.panelName;
            go.SetActive(true);

            IUIPanel panel = GetPanelFromPool(go);

            InitPanelInformation(panel, uiNode);
            panel.Binding(go);
            panel.HandleData(bridge);
            transRefDic.Add(go.transform.GetInstanceID(), panel);
            createdPanels.Add(panel);

            if (parentPanel != null)
            {
                parentPanel.RecordChild(panel);
            }

            if (bridge != null)
            {
                bridge.OnCreatePanel(panel);
            }

            HandBridgeOptions(panel, bridge);
        }
        internal UICreateInfo Allocate(UIInfoBase info, UnityAction <GameObject> onCreate)
        {
            var uicreateInfo = innerPool.Allocate();

            uicreateInfo.uiInfo   = info;
            uicreateInfo.onCreate = onCreate;
            return(uicreateInfo);
        }
Beispiel #5
0
        public bool TryOpenOldPanel(string panelName, UIInfoBase uiNode, IUIPanel parentPanel, out Bridge bridgeObj)
        {
            bridgeObj = null;

            if (uiNode == null)
            {
                return(false);
            }

            var oldPanels = createdPanels.FindAll(x => x.Name == panelName);

            for (int i = 0; i < oldPanels.Count; i++)
            {
                var oldPanel = oldPanels[i];

                if (oldPanel != null)
                {
                    bridgeObj = createdBridges.Find(x => x.OutPanel == oldPanel);

                    if (bridgeObj != null)
                    {
                        if (oldPanel.UType.form == UIFormType.Fixed)
                        {
                            bridgeObj.SetInPanel(parentPanel);

                            if (parentPanel != null)
                            {
                                parentPanel.RecordChild(oldPanel);
                            }

                            if (!oldPanel.IsShowing)
                            {
                                oldPanel.UnHide();
                            }
                            HandBridgeOptions(oldPanel, bridgeObj);
                            return(true);
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        Debug.LogError("目标面板信息丢失,请检查逻辑!!!" + parentPanel);
                        for (int j = 0; j < createdBridges.Count; j++)
                        {
                            var item = createdBridges[j];
                            Debug.Log(item.OutPanel.Name);
                        }
                    }
                }
            }

            return(false);
        }
 /// <summary>
 /// 按规则设置面板及父亲面板的状态
 /// </summary>
 /// <param name="panel"></param>
 /// <param name="bridge"></param>
 /// <param name="uiNode"></param>
 protected void InitPanel(IUIPanel panel, Bridge bridge, UIInfoBase uiNode)
 {
     panel.UType = uiNode.type;
     panel.Group = this;
     if (panel is BridgeUI.Binding.IBindingContext && bridge.Info.viewModel != null)
     {
         (panel as BridgeUI.Binding.IBindingContext).ViewModel = bridge.Info.viewModel as Binding.IViewModel;
     }
     panel.onDelete += OnDeletePanel;
     panel.HandleData(bridge);
 }
Beispiel #7
0
        public void CreatePanel(UIInfoBase uiNode, Bridge bridge, IUIPanel parentPanel)
        {
            Transform root = parentPanel == null ? Trans : parentPanel.Content;

            var createUIHandle = new UICreateHandle();

            createUIHandle.parentPanel = parentPanel;
            createUIHandle.uiNode      = uiNode;
            createUIHandle.bridge      = bridge;
            createUIHandle.parent      = root;
            createUIHandle.onCreate    = CreateUI_Internal;
            createRule.CreatePanel(uiNode, createUIHandle.OnCreate);
        }
        public Bridge InstencePanel(IUIPanel parentPanel, string panelName, int index, Transform root)
        {
            Bridge     bridge = null;
            UIInfoBase uiNode = null;

            if (NeedCreatePanel(parentPanel, panelName, index, out bridge, out uiNode))
            {
                if (!waitCreateDic.ContainsKey(uiNode.panelName))
                {
                    var parent = root == null ? Trans : root;
                    var action = new UnityAction <GameObject>(go =>
                    {
                        CreateUI(go, uiNode, bridge, parent, parentPanel);
                    });
                    var uiCreateInfo = uiCreateInfoPool.Allocate(uiNode, action);
                    waitCreateQueue.Add(uiNode.panelName);
                    waitCreateDic.Add(uiNode.panelName, uiCreateInfo);
                }
            }
            return(bridge);
        }
        /// <summary>
        /// 创建对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="panelName"></param>
        /// <param name="onCreate"></param>
        public void CreatePanel(UIInfoBase itemInfo)
        {
            if (_cansaleKeys.Contains(itemInfo.panelName))
            {
                _cansaleKeys.RemoveAll(x => x == itemInfo.panelName);
            }

            if (!_loadingKeys.Contains(itemInfo.IDName))
            {
                _loadingKeys.Add(itemInfo.IDName);
                var bInfo = itemInfo as BundleUIInfo;
                var pInfo = itemInfo as PrefabUIInfo;

                if (bInfo != null)
                {
                    GetGameObjectInfo(bInfo);
                }
                else if (pInfo != null)
                {
                    GetGameObjectInfo(pInfo);
                }
            }
        }
        private void CreateUI(GameObject go, UIInfoBase uiNode, Bridge bridge, Transform parent, IUIPanel parentPanel)
        {
            Utility.SetTranform(go.transform, uiNode.type.layer, uiNode.type.layerIndex, Trans, parent, ref childParentDic);
            go.SetActive(true);

            var panel = go.GetComponent <IUIPanel>();

            if (panel == null)
            {
                panel = go.AddComponent <PanelCore>();
            }

            createdPanels.Add(panel);
            if (parentPanel != null)
            {
                parentPanel.RecordChild(panel);
            }
            if (bridge != null)
            {
                bridge.OnCreatePanel(panel);
            }
            InitPanel(panel, bridge, uiNode);
            HandBridgeOptions(panel, bridge);
        }
        /// <summary>
        /// 获取对象实例
        /// </summary>
        private void CreateInstance(GameObject prefab, UIInfoBase nodeInfo)
        {
            if (_cansaleKeys.Contains(nodeInfo.panelName))
            {
                _cansaleKeys.Remove(nodeInfo.panelName);
                return;
            }

            if (prefab == null || nodeInfo == null)
            {
                return;
            }

            GameObject go = GameObject.Instantiate(prefab);

            go.name = nodeInfo.panelName;

            go.SetActive(true);

            if (nodeInfo.OnCreate != null)
            {
                nodeInfo.OnCreate(go);
            }
        }
Beispiel #12
0
        /// <summary>
        /// 找到信息源和bridge
        /// </summary>
        /// <param name="parentName"></param>
        /// <param name="panelName"></param>
        /// <param name="bridgeObj"></param>
        /// <param name="uiNode"></param>
        /// <returns></returns>
        private bool TryMatchPanel(IPanelBase parentPanel, string panelName, out Bridge bridgeObj, out UIInfoBase uiNode)
        {
            uiNode = Nodes.Find(x => x.panelName == panelName);

            if (uiNode != null)// && uiNode.type.form == UIFormType.Fixed
            {
                if (uiNode.type.form == UIFormType.Fixed)
                {
                    var oldPanel = createdPanels.Find(x => x.Name == panelName);
                    if (oldPanel != null)
                    {
                        bridgeObj = bridgeDic[oldPanel];
                        if (!oldPanel.IsShowing)
                        {
                            oldPanel.UnHide();
                            HandBridgeOptions(oldPanel, bridgeObj);
                        }
                        return(false);
                    }
                }
            }

            if (uiNode == null)
            {
                bridgeObj = null;
                return(false);
            }

            bridgeObj = GetBridgeClamp(parentPanel, panelName);
            return(uiNode != null && bridgeObj != null);
        }
        /// <summary>
        /// 找到信息源和bridge
        /// </summary>
        /// <param name="parentPanel"></param>
        /// <param name="panelName"></param>
        /// <param name="bridgeObj"></param>
        /// <param name="uiNode"></param>
        /// <returns></returns>
        protected bool NeedCreatePanel(IUIPanel parentPanel, string panelName, int index, out Bridge bridgeObj, out UIInfoBase uiNode)
        {
            Nodes.TryGetValue(panelName, out uiNode);

            if (uiNode != null)
            {
                if (uiNode.type.form == UIFormType.Fixed)
                {
                    var oldPanel = createdPanels.Find(x => x.Name == panelName && x.Parent == parentPanel);
                    if (oldPanel != null)
                    {
                        bridgeObj = createdBridges.Find(x => x.InPanel == parentPanel && x.OutPanel == oldPanel);
                        if (!oldPanel.IsShowing)
                        {
                            oldPanel.UnHide();
                            HandBridgeOptions(oldPanel, bridgeObj);
                        }
                        return(false);
                    }
                }
            }

            if (uiNode == null)
            {
                bridgeObj = null;
                return(false);
            }

            bridgeObj = GetBridgeClamp(parentPanel, panelName, index);
            createdBridges.Add(bridgeObj);
            return(uiNode != null && bridgeObj != null);
        }
Beispiel #14
0
 /// <summary>
 /// 按规则设置面板及父亲面板的状态
 /// </summary>
 /// <param name="panel"></param>
 /// <param name="bridge"></param>
 /// <param name="uiNode"></param>
 protected void InitPanelInformation(IUIPanel panel, UIInfoBase uiNode)
 {
     panel.UType    = uiNode.type;
     panel.Group    = this;
     panel.onClose += OnDeletePanel;
 }
Beispiel #15
0
        public bool CreateInfoAndBridge(string panelName, IUIPanel parentPanel, int index, UIInfoBase uiInfo, out Bridge bridgeObj)
        {
            if (uiInfo == null)
            {
                bridgeObj = null;
                return(false);
            }

            bridgeObj = GetBridgeClamp(parentPanel, panelName, index);
            createdBridges.Add(bridgeObj);
            return(uiInfo != null && bridgeObj != null);
        }