Esempio n. 1
0
        //不受ViewManager管理
        public static FWidget Create(Type cls, Action <FWidget> callback, object args = null)
        {
            System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
            FWidget widget = asm.CreateInstance(cls.FullName) as FWidget;

            if (widget != null)
            {
                string packageName   = widget.package;
                string componentName = widget.component;

                widget.__isCreating = true;
                FComponent.Create <FComponent>(packageName, componentName, widget.isAsync, (fComponent) =>
                {
                    widget.__isCreating = false;
                    if (widget.__isDisposed)
                    {
                        widget.__isDisposed = false;
                        fComponent.Dispose();
                        return;
                    }
                    OnCreateSuccess(fComponent.GetObject(), widget, args);
                    callback?.Invoke(widget);
                });
            }

            return(widget);
        }
Esempio n. 2
0
        public FComponent GetParent()
        {
            var obj = _obj.parent;

            __parent = (obj != null) ? (__parent != null ? __parent.InitWithObj(obj) as FComponent : new FComponent().InitWithObj(obj) as FComponent) : null;
            return(__parent);
        }
Esempio n. 3
0
        public FComponent GetFooter()
        {
            var obj = _obj.footer;

            __footer = (obj != null) ? (__footer != null ? __footer.InitWithObj(obj) as FComponent : new FComponent().InitWithObj(obj) as FComponent) : null;
            return(__footer);
        }
Esempio n. 4
0
        /// <summary>
        /// 初始化基准组件
        /// </summary>
        /// <param name="fComponent"></param>
        /// <param name="baseArgs"></param>
        private static void InitBaseArgs(FComponent fComponent, BaseArgs baseArgs)
        {
            if (fComponent == null)
            {
                return;
            }

            if (baseArgs == null)
            {
                return;
            }

            fComponent.SetXY(baseArgs.xy);
            fComponent.SetSize(baseArgs.size);
            fComponent.SetPivot(baseArgs.pivot.x, baseArgs.pivot.y, baseArgs.pivotAsAnchor);
            fComponent.SetScale(baseArgs.scale.x, baseArgs.scale.y);
            fComponent.SetAlpha(baseArgs.alpha);
            fComponent.SetText(baseArgs.title);

            if (baseArgs.center)
            {
                fComponent.Center();
            }
            if (baseArgs.parent != null)
            {
                baseArgs.parent.AddChild(fComponent);
            }
        }
Esempio n. 5
0
File: FList.cs Progetto: cnscj/THSTG
        //加一层遮罩,List含3d物体时用
        public void SetStencil()
        {
            SetVirtual();
            // 弄一个组件和list一样大
            // 弄一个shape当做遮罩
            // 把这个list放入这个组件
            var container = FComponent.Create <FComponent, GComponent>();
            var graph     = FComponent.Create <FGraph, GGraph>();
            var parent    = this.GetParent();

            //初始化
            container.SetXY(this.GetXY());

            graph.SetXY(0, 0);
            graph.SetSize(this.GetSize());

            //
            this.RemoveFromParent();
            this.SetXY(0, 0);

            //
            parent.AddChild(container);
            container.AddChild(graph);
            container.AddChild(this);

            graph.AddRelation(this, FairyGUI.RelationType.Size);
            container.GetObject().asCom.mask = graph.GetObject().displayObject;
        }
Esempio n. 6
0
File: FList.cs Progetto: cnscj/THSTG
 public void SetState <T1, T2>(ItemStateFuncT2 <T1, T2> func) where T1 : new() where T2 : FComponent, new()
 {
     _obj.asList.itemRenderer = new ListItemRenderer((index, obj) =>
     {
         FComponent fComp = null;
         if (!_dataTemplate.TryGetValue(obj, out fComp))
         {
             fComp = FComponent.Create <T2>(obj);
             _dataTemplate[obj] = fComp;
         }
         func?.Invoke(index, (T1)_dataProvider[index], (T2)fComp);
     });
 }
Esempio n. 7
0
        private static T NewT <T>(GObject fguiObj, BaseArgs baseArgs) where T : FComponent, new()
        {
            T fComponent = null;

            if (baseArgs != null && !string.IsNullOrEmpty(baseArgs.packageName))
            {
                fComponent = FComponent.Create <T>(baseArgs.packageName, baseArgs.componentName);
            }
            else
            {
                fComponent = FComponent.Create <T>(fguiObj);
            }
            InitBaseArgs(fComponent, baseArgs);
            return(fComponent);
        }
Esempio n. 8
0
            public void Release(FComponent uiObj)
            {
                if (uiObj == null)
                {
                    return;
                }

                if (AvailableCount >= MaxCount)
                {
                    onDispose?.Invoke(uiObj);
                    m_recordObjs?.Remove(uiObj);
                }
                else
                {
                    var poolList   = GetObjectList();
                    var newPoolObj = CreatePoolObj(uiObj);
                    onRelease?.Invoke(uiObj);
                    poolList.AddLast(newPoolObj);
                }
            }
Esempio n. 9
0
            private PoolObject CreatePoolObj(FComponent uiObj = null)
            {
                var newFobj = uiObj;

                if (newFobj == null)
                {
                    newFobj = (FComponent)System.Activator.CreateInstance(fComponent);
                    onCreate?.Invoke(newFobj);
                }

                var        recordDict = GetObjectDict();
                PoolObject newPoolObj = null;

                if (!recordDict.ContainsKey(newFobj))
                {
                    recordDict[newFobj] = new PoolObject();
                }
                newPoolObj     = recordDict[newFobj];
                newPoolObj.obj = newFobj;
                newPoolObj.UpdateTick();

                return(newPoolObj);
            }