Ejemplo n.º 1
0
        public static Entity GetView(this UIManagerComponent self, string ui_name)
        {
            var res = self.GetWindow(ui_name);

            if (res != null)
            {
                return(res.GetComponent <Entity>());
            }
            return(null);
        }
Ejemplo n.º 2
0
        //判断窗口是否打开
        public static bool IsActiveWindow <T>(this UIManagerComponent self) where T : Entity
        {
            string ui_name = typeof(T).Name;
            var    target  = self.GetWindow(ui_name);

            if (target == null)
            {
                return(false);
            }
            return(target.Active);
        }
Ejemplo n.º 3
0
        //打开窗口
        public static async ETTask <T> OpenWindow <T, P1, P2, P3, P4>(this UIManagerComponent self, string path, P1 p1, P2 p2, P3 p3, P4 p4,
                                                                      UILayerNames layer_name = UILayerNames.NormalLayer, bool banKey = true) where T : Entity, IAwake, IOnCreate, IOnEnable <P1, P2, P3, P4>, new()
        {
            string ui_name = typeof(T).Name;
            var    target  = self.GetWindow(ui_name);

            if (target == null)
            {
                target = self.__InitWindow <T>(path, layer_name);
                self.windows[ui_name] = target;
            }
            target.Layer  = layer_name;
            target.BanKey = banKey;
            return(await self.__InnerOpenWindow <T, P1, P2, P3, P4>(target, p1, p2, p3, p4));
        }
Ejemplo n.º 4
0
        public static async ETTask CloseWindow(this UIManagerComponent self, string ui_name)
        {
            var target = self.GetWindow(ui_name, 1);

            if (target == null)
            {
                return;
            }
            while (target.LoadingState != UIWindowLoadingState.LoadOver)
            {
                await TimerComponent.Instance.WaitAsync(1);
            }
            self.__RemoveFromStack(target);
            self.__InnnerCloseWindow(target);
        }
Ejemplo n.º 5
0
        public static async ETTask DestroyWindow(this UIManagerComponent self, string ui_name)
        {
            var target = self.GetWindow(ui_name);

            if (target != null)
            {
                await self.CloseWindow(ui_name);

                Game.EventSystem.Publish(new UIEventType.InnerDestroyWindow()
                {
                    target = target
                });
                self.windows.Remove(target.Name);
                target.Dispose();
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 获取最上层window
 /// </summary>
 /// <param name="self"></param>
 /// <returns></returns>
 public static UIWindow GetTopWindow(this UIManagerComponent self)
 {
     for (int i = (byte)UILayerNames.TopLayer; i >= 0; i--)
     {
         var wins = self.window_stack[(UILayerNames)i];
         if (wins.Count <= 0)
         {
             continue;
         }
         var name = wins.First.Value;
         var win  = self.GetWindow(name, 1);
         if (win != null)
         {
             return(win);
         }
     }
     return(null);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 将窗口移到当前层级最上方
        /// </summary>
        /// <param name="self"></param>
        /// <typeparam name="T"></typeparam>
        public static void MoveWindowToTop <T>(this UIManagerComponent self) where T : Entity
        {
            string ui_name = typeof(T).Name;
            var    target  = self.GetWindow(ui_name, 1);

            if (target == null)
            {
                return;
            }
            var layer_name = target.Layer;

            if (self.window_stack[layer_name].Contains(ui_name))
            {
                self.window_stack[layer_name].Remove(ui_name);
            }
            self.window_stack[layer_name].AddFirst(ui_name);
            Game.EventSystem.Publish(new UIEventType.AddWindowToStack()
            {
                window = target
            });
        }
Ejemplo n.º 8
0
 public static void SetWidthPadding(this UIManagerComponent self, float value)
 {
     self.WidthPadding = value;
     foreach (var layer in self.window_stack.Values)
     {
         if (layer != null)
         {
             for (LinkedListNode <string> node = layer.First; null != node; node = node.Next)
             {
                 var target = self.GetWindow(node.Value);
                 var win    = target.GetComponent(target.ViewType) as IOnWidthPaddingChange;
                 if (win != null)
                 {
                     EventSystem.Instance.Publish(new UIEventType.OnWidthPaddingChange
                     {
                         entity = win as Entity
                     });
                 }
             }
         }
     }
 }