Esempio n. 1
0
 static void CloneAll(byte[] ui, Transform root)
 {
     if (ui != null)
     {
         HGUIManager.Initial(root);
         var fake  = HGUIManager.LoadModels(ui, "assTest").models;
         var child = HGUIManager.GetAllChild(fake);
         if (child != null)
         {
             Initializer initializer = new Initializer();
             for (int i = 0; i < child.Length; i++)
             {
                 var go = HGUIManager.Clone(child[i], initializer);
                 if (go != null)
                 {
                     var trans = go.transform;
                     trans.SetParent(root);
                     trans.localPosition = Vector3.zero;
                     trans.localScale    = Vector3.one;
                     trans.localRotation = Quaternion.identity;
                 }
             }
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 创建项目实例,如果缓存中有则从缓存中提前
        /// </summary>
        /// <returns></returns>
        protected TreeViewItem CreateItem()
        {
            TreeViewItem it = queue.Dequeue();

            if (it != null)
            {
                it.target.activeSelf = true;
                return(it);
            }
            if (creator != null)
            {
                var t = creator.Create();
                t.target = HGUIManager.Clone(ItemMod, creator.initializer);
                var trans = t.target;
                trans.SetParent(Enity);
                trans.localScale    = Vector3.one;
                trans.localRotation = Quaternion.identity;
                return(t);
            }
            else
            {
                var go = HGUIManager.Clone(ItemMod);
                go.SetParent(Enity);
                go.localScale    = Vector3.one;
                go.localRotation = Quaternion.identity;
                TreeViewItem a = new TreeViewItem();
                a.target           = go;
                a.Text             = go as HText;
                a.Item             = go.RegEvent <UserEvent>();
                a.Item.Click       = DefultItemClick;
                a.Item.DataContext = a;
                return(a);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 创建项目
        /// </summary>
        /// <param name="buffer">项目缓存</param>
        /// <param name="con">构造器</param>
        /// <param name="mod">UI模型数据</param>
        /// <param name="parent">父坐标变换</param>
        /// <returns></returns>
        protected ScrollItem CreateItem(List <ScrollItem> buffer, Constructor con, FakeStruct mod, UIElement parent)
        {
            if (buffer.Count > 0)
            {
                var it = buffer[0];
                it.target.activeSelf = true;
                it.index             = -1;
                buffer.RemoveAt(0);
                return(it);
            }
            ScrollItem a = new ScrollItem();

            if (con == null)
            {
                a.obj = a.target = HGUIManager.Clone(mod);
            }
            else
            {
                a.obj    = con.Create();
                a.target = HGUIManager.Clone(mod, con.initializer);
            }
            a.target.SetParent(parent);
            a.target.localScale    = Vector3.one;
            a.target.localRotation = Quaternion.identity;
            return(a);
        }
Esempio n. 4
0
        void MItemCreate(ObjectLinker obj, LinkerMod mod)
        {
            T t = new T();

            initializer.Reset(t);
            mod.main = HGUIManager.Clone(model, initializer);
            mod.UI   = t;
        }
Esempio n. 5
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="lay">停靠面板主体</param>
 public DockpanelArea(DockPanel lay)
 {
     layout = lay;
     model  = HGUIManager.Clone(layout.AreaMod);
     layout = lay;
     model.SetParent(layout.AreaLevel);
     model.localPosition = Vector3.zero;
     model.localScale    = Vector3.one;
     model.localRotation = Quaternion.identity;
     layout.areas.Add(this);
 }
Esempio n. 6
0
        /// <summary>
        /// 添加可停靠区域
        /// </summary>
        /// <param name="dock">区域停靠方位</param>
        /// <param name="r">占用大小</param>
        /// <returns></returns>
        public DesignedDockAuxiliary AddArea(DockpanelArea.Dock dock, float r = 0.5f)
        {
            var area = dockArea.AddAreaR(dock, r);
            var go   = HGUIManager.Clone(layout.Auxiliary);

            go.SetParent(area.model);
            go.localScale    = Vector3.one;
            go.localRotation = Quaternion.identity;
            var con = new DesignedDockAuxiliary(layout);

            con.Initial(area, go);
            layout.contents.Add(con);
            return(con);
        }
Esempio n. 7
0
        /// <summary>
        /// 创建一个实例,如果回收缓存中有就从缓存中提取
        /// </summary>
        /// <returns></returns>
        public DataGridItem CreateEnity()
        {
            DataGridItem it = buf.Dequeue();

            if (it != null)
            {
                it.target.activeSelf = true;
                return(it);
            }
            var t = itemCreator.Create() as DataGridItem;

            t.target = HGUIManager.Clone(mod, itemCreator.initializer);
            return(t);
        }
Esempio n. 8
0
        /// <summary>
        /// 载入UI模型并实例化
        /// </summary>
        /// <typeparam name="T">UI模型</typeparam>
        /// <param name="asset">资源包名</param>
        /// <param name="name">UI名</param>
        /// <returns></returns>
        public T LoadUI <T>(string asset, string name) where T : class, new()
        {
            uiName = name;
            model  = HGUIManager.FindModelAndSetAssets(asset, name);
            T t = new T();

            uiInitializer = new UIInitializer(ObjectFields(typeof(T)));
            uiInitializer.Reset(t);
            Main = HGUIManager.Clone(model, uiInitializer);
            uiInitializer.Done();
            Main.SetParent(Parent);
            Main.localPosition = Vector3.zero;
            Main.localScale    = Vector3.one;
            Main.localRotation = Quaternion.identity;
            Main.activeSelf    = true;
            return(t);
        }
Esempio n. 9
0
    static void CloneAll(DataBuffer db, UIElement root)
    {
        root.child.Clear();
        var fake  = HGUIManager.LoadModels(db, "assTest").models;
        var child = HGUIManager.GetAllChild(fake);

        if (child != null)
        {
            for (int i = 0; i < child.Length; i++)
            {
                var go = HGUIManager.Clone(child[i]);
                if (go != null)
                {
                    go.SetParent(root);
                    go.localScale = Vector3.one;
                }
            }
        }
    }
Esempio n. 10
0
        /// <summary>
        /// 添加一个内容标签,将使用默认模板
        /// </summary>
        /// <param name="name">名称</param>
        /// <returns></returns>
        public ItemContent AddContent(string name)
        {
            var         item = HGUIManager.Clone(control.Item);
            ItemContent con  = new ItemContent();

            con.Parent = control;
            con.Item   = item;
            item.RegEvent <UserEvent>();
            item.userEvent.PointerDown = HeadPointDown;
            item.userEvent.Drag        = HeadDrag;
            item.userEvent.DragEnd     = HeadDragEnd;
            item.userEvent.DataContext = con;

            var content = UICreator.CreateElement(Vector3.zero, Vector2.zero, "Content", control.Content);

            content.marginType = MarginType.Margin;

            con.Content = content;
            con.Back    = item.Find("Image") as HImage;

            con.Label = item.Find("Text") as HText;
            var txt = con.Label;

            txt.Text = name;
            Vector2 v = txt.SizeDelta;

            txt.GetPreferredWidth(ref v, name);
            con.Back.SizeDelta = item.SizeDelta = new Vector2(v.x + 40, v.y);

            var clo = item.Find("Close");

            if (clo != null)
            {
                con.Close = clo;
                con.Close.RegEvent <UserEvent>();
                con.Close.userEvent.Click       = CloseClick;
                con.Close.userEvent.DataContext = con;
                clo.localPosition = new Vector3(v.x * 0.5f + 8, 0, 0);
            }
            control.AddContent(con);
            return(con);
        }
Esempio n. 11
0
        DockPanelLine AddVLine(float x)
        {
            var   m  = HGUIManager.Clone(layout.LineMod);
            float ex = Top.Enity.localPosition.y;
            float sx = Down.Enity.localPosition.y;
            float w  = ex - sx;

            if (w < 0)
            {
                w = -w;
            }
            DockPanelLine line = new DockPanelLine(layout, m, Direction.Vertical);
            var           pos  = model.localPosition;

            pos.x = x;
            line.SetSize(pos, new Vector2(DockPanel.LineWidth, w));
            line.SetLineStart(Down);
            line.SetLineEnd(Top);
            return(line);
        }
Esempio n. 12
0
        DockPanelLine AddHLine(float y)
        {
            var   m  = HGUIManager.Clone(layout.LineMod);
            float ex = Right.Enity.localPosition.x;
            float sx = Left.Enity.localPosition.x;
            float w  = ex - sx;

            if (w < 0)
            {
                w = -w;
            }
            DockPanelLine line = new DockPanelLine(layout, m, Direction.Horizontal);
            var           pos  = model.localPosition;

            pos.y = y;
            line.SetSize(pos, new Vector2(w, DockPanel.LineWidth));
            line.SetLineStart(Left);
            line.SetLineEnd(Right);
            return(line);
        }
Esempio n. 13
0
        /// <summary>
        /// 创建项目连接器
        /// </summary>
        /// <returns></returns>
        public override LinkerMod CreateUI()
        {
            for (int i = 0; i < buffer.Count; i++)
            {
                if (buffer[i].index < 0)
                {
                    var item = buffer[i];
                    buffer.RemoveAt(i);
                    return(item);
                }
            }
            LinkerMod mod = new LinkerMod();
            T         t   = new T();

            if (initializer == null)
            {
                initializer = new UIInitializer(TempReflection.ObjectFields(typeof(T)));
            }
            initializer.Reset(t);
            mod.main = HGUIManager.Clone(model, initializer);
            mod.UI   = t;
            return(mod);
        }
Esempio n. 14
0
        void InitialFixLine()
        {
            var m = HGUIManager.Clone(LineMod);

            Left = new DockPanelLine(this, m, Direction.Vertical, false);

            m     = HGUIManager.Clone(LineMod);
            Right = new DockPanelLine(this, m, Direction.Vertical, false);

            m   = HGUIManager.Clone(LineMod);
            Top = new DockPanelLine(this, m, Direction.Vertical, false);

            m    = HGUIManager.Clone(LineMod);
            Down = new DockPanelLine(this, m, Direction.Vertical, false);

            Vector2 size = Enity.SizeDelta;
            float   rx   = size.x * 0.5f;
            float   ty   = size.y * 0.5f;

            Left.SetSize(new Vector2(-rx, 0), new Vector2(LineWidth, size.y));
            Right.SetSize(new Vector2(rx, 0), new Vector2(LineWidth, size.y));
            Top.SetSize(new Vector2(0, ty), new Vector2(size.x, LineWidth));
            Down.SetSize(new Vector2(0, -ty), new Vector2(size.x, LineWidth));
        }
Esempio n. 15
0
 static void Clone(string CloneName, byte[] ui, Transform root)
 {
     if (ui != null)
     {
         if (CloneName != null)
         {
             if (CloneName != "")
             {
                 HGUIManager.Initial(root);
                 HGUIManager.LoadModels(ui, "assTest");
                 Initializer initializer = new Initializer();
                 var         go          = HGUIManager.Clone(HGUIManager.FindModel("assTest", CloneName), initializer);
                 if (go != null)
                 {
                     var trans = go.transform;
                     trans.SetParent(root);
                     trans.localScale    = Vector3.one;
                     trans.localScale    = Vector3.one;
                     trans.localRotation = Quaternion.identity;
                 }
             }
         }
     }
 }