Example #1
0
        virtual public void FreeObject(IHtmlObject obj)
        {
            obj.Release();

            //可能已经被GameObject tree deleted了,不再回收
            if (obj.displayObject != null && obj.displayObject.isDisposed)
            {
                return;
            }

            if (obj is HtmlImage)
            {
                _imagePool.Push(obj);
            }
            else if (obj is HtmlInput)
            {
                _inputPool.Push(obj);
            }
            else if (obj is HtmlButton)
            {
                _buttonPool.Push(obj);
            }
            else if (obj is HtmlLink)
            {
                _linkPool.Push(obj);
            }
        }
Example #2
0
        virtual public void FreeObject(IHtmlObject obj)
        {
            if (!Application.isPlaying)
            {
                obj.Dispose();
                return;
            }

            if (obj is HtmlImage)
            {
                _imagePool.Push(obj);
            }
            else if (obj is HtmlInput)
            {
                _inputPool.Push(obj);
            }
            else if (obj is HtmlButton)
            {
                _buttonPool.Push(obj);
            }
            else if (obj is HtmlLink)
            {
                _linkPool.Push(obj);
            }
        }
Example #3
0
        public virtual void FreeObject(IHtmlObject obj)
        {
            if (!Application.isPlaying)
            {
                obj.Dispose();
                return;
            }

            if (obj is HtmlImage)
                _imagePool.Push(obj);
            else if (obj is HtmlInput)
                _inputPool.Push(obj);
            else if (obj is HtmlButton)
                _buttonPool.Push(obj);
        }
Example #4
0
        virtual public void FreeObject(IHtmlObject obj)
        {
            obj.Release();
            if (!Application.isPlaying)
            {
                obj.Dispose();
                return;
            }

            //可能已经被GameObject tree deleted了,不再回收
            if (obj.displayObject != null && obj.displayObject.isDisposed)
            {
                return;
            }

            if (obj is HtmlImage)
            {
                _imagePool.Push(obj);
            }
            else if (obj is HtmlInput)
            {
                _inputPool.Push(obj);
            }
            else if (obj is HtmlButton)
            {
                _buttonPool.Push(obj);
            }
            else if (obj is HtmlLink)
            {
                _linkPool.Push(obj);
            }

            if (obj.displayObject != null)
            {
                if (_poolManager == null)
                {
                    _poolManager = Stage.inst.CreatePoolManager("HtmlObjectPool");
                }

                ToolSet.SetParent(obj.displayObject.cachedTransform, _poolManager);
            }
        }
Example #5
0
        virtual protected void InternalRefreshObjects()
        {
            List <HtmlElement> elements = textField.htmlElements;
            int count = _toCollect != null ? _toCollect.Count : 0;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    IHtmlObject htmlObject = _toCollect[i];
                    htmlObject.Remove();
                    htmlPageContext.FreeObject(htmlObject);
                }
                _toCollect.Clear();
            }

            count = elements.Count;
            for (int i = 0; i < count; i++)
            {
                HtmlElement element = elements[i];
                if (element.htmlObject != null)
                {
                    if ((element.status & 3) == 0)                     //not (hidden and clipped)
                    {
                        if ((element.status & 4) == 0)                 //not added
                        {
                            element.status |= 4;
                            element.htmlObject.Add();
                        }
                    }
                    else
                    {
                        if ((element.status & 4) != 0)                         //added
                        {
                            element.status &= 251;
                            element.htmlObject.Remove();
                        }
                    }
                }
            }
        }
        virtual protected void InternalRefreshObjects()
        {
            List <HtmlElement> elements = textField.htmlElements;
            int count = _toCollect != null ? _toCollect.Count : 0;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    IHtmlObject htmlObject = _toCollect[i];
                    htmlObject.Remove();
                    htmlPageContext.FreeObject(htmlObject);
                }
                _toCollect.Clear();
            }

            count = elements.Count;
            for (int i = 0; i < count; i++)
            {
                HtmlElement element = elements[i];
                if (element.htmlObject != null)
                {
                    if (element.hidden)
                    {
                        if (element.added)
                        {
                            element.added = false;
                            element.htmlObject.Remove();
                        }
                    }
                    else
                    {
                        if (!element.added)
                        {
                            element.added = true;
                            element.htmlObject.Add();
                        }
                    }
                }
            }
        }
        virtual public void FreeObject(IHtmlObject obj)
        {
            if (_poolManager == null)
            {
                obj.Dispose();
                return;
            }

            //可能已经被GameObject tree deleted了,不再回收
            if (obj.displayObject != null && obj.displayObject.isDisposed)
            {
                obj.Dispose();
                return;
            }

            obj.Release();
            if (obj is HtmlImage)
            {
                _imagePool.Push(obj);
            }
            else if (obj is HtmlInput)
            {
                _inputPool.Push(obj);
            }
            else if (obj is HtmlButton)
            {
                _buttonPool.Push(obj);
            }
            else if (obj is HtmlLink)
            {
                _linkPool.Push(obj);
            }

            if (obj.displayObject != null)
            {
                obj.displayObject.cachedTransform.SetParent(_poolManager, false);
            }
        }
Example #8
0
        virtual public IHtmlObject CreateObject(RichTextField owner, HtmlElement element)
        {
            IHtmlObject ret = null;

            if (element.type == HtmlElementType.Image)
            {
                if (_imagePool.Count > 0 && Application.isPlaying)
                {
                    ret = _imagePool.Pop();
                }
                else
                {
                    ret = new HtmlImage();
                }
            }
            else if (element.type == HtmlElementType.Input)
            {
                string type = element.GetString("type");
                if (type != null)
                {
                    type = type.ToLower();
                }
                if (type == "button" || type == "submit")
                {
                    if (_buttonPool.Count > 0 && Application.isPlaying)
                    {
                        ret = _buttonPool.Pop();
                    }
                    else
                    {
                        ret = new HtmlButton();
                    }
                }
                else
                {
                    if (_inputPool.Count > 0 && Application.isPlaying)
                    {
                        ret = _inputPool.Pop();
                    }
                    else
                    {
                        ret = new HtmlInput();
                    }
                }
            }
            else if (element.type == HtmlElementType.Select)
            {
                if (_selectPool.Count > 0 && Application.isPlaying)
                {
                    ret = _selectPool.Pop();
                }
                else
                {
                    ret = new HtmlSelect();
                }
            }

            if (ret != null)
            {
                ret.Create(owner, element);
            }

            return(ret);
        }
        virtual public IHtmlObject CreateObject(RichTextField owner, HtmlElement element)
        {
            IHtmlObject ret = null;

            if (element.type == HtmlElementType.Image)
            {
                if (_imagePool.Count > 0)
                {
                    ret = _imagePool.Pop();
                }
                else
                {
                    ret = new HtmlImage();
                }
            }
            else if (element.type == HtmlElementType.Link)
            {
                if (_linkPool.Count > 0)
                {
                    ret = _linkPool.Pop();
                }
                else
                {
                    ret = new HtmlLink();
                }
            }
            else if (element.type == HtmlElementType.Input)
            {
                string type = element.GetString("type");
                if (type != null)
                {
                    type = type.ToLower();
                }
                if (type == "button" || type == "submit")
                {
                    if (_buttonPool.Count > 0)
                    {
                        ret = _buttonPool.Pop();
                    }
                    else
                    {
                        ret = new HtmlButton();
                    }
                }
                else
                {
                    if (_inputPool.Count > 0)
                    {
                        ret = _inputPool.Pop();
                    }
                    else
                    {
                        ret = new HtmlInput();
                    }
                }
            }
            else if (element.type == HtmlElementType.Select)
            {
                if (_selectPool.Count > 0)
                {
                    ret = _selectPool.Pop();
                }
                else
                {
                    ret = new HtmlSelect();
                }
            }

            if (ret != null)
            {
                ret.Create(owner, element);
                if (ret.displayObject != null)
                {
                    ret.displayObject.home = owner.cachedTransform;
                }
            }

            return(ret);
        }
        virtual public IHtmlObject CreateObject(RichTextField owner, HtmlElement element)
        {
            IHtmlObject ret      = null;
            bool        fromPool = false;

            if (element.type == HtmlElementType.Image)
            {
                if (_imagePool.Count > 0 && _poolManager != null)
                {
                    ret      = _imagePool.Pop();
                    fromPool = true;
                }
                else
                {
                    ret = new HtmlImage();
                }
            }
            else if (element.type == HtmlElementType.Link)
            {
                if (_linkPool.Count > 0 && _poolManager != null)
                {
                    ret      = _linkPool.Pop();
                    fromPool = true;
                }
                else
                {
                    ret = new HtmlLink();
                }
            }
            else if (element.type == HtmlElementType.Input)
            {
                string type = element.GetString("type");
                if (type != null)
                {
                    type = type.ToLower();
                }
                if (type == "button" || type == "submit")
                {
                    if (_buttonPool.Count > 0 && _poolManager != null)
                    {
                        ret      = _buttonPool.Pop();
                        fromPool = true;
                    }
                    else
                    {
                        ret = new HtmlButton();
                    }
                }
                else
                {
                    if (_inputPool.Count > 0 && _poolManager != null)
                    {
                        ret      = _inputPool.Pop();
                        fromPool = true;
                    }
                    else
                    {
                        ret = new HtmlInput();
                    }
                }
            }
            else if (element.type == HtmlElementType.Select)
            {
                if (_selectPool.Count > 0 && _poolManager != null)
                {
                    ret      = _selectPool.Pop();
                    fromPool = true;
                }
                else
                {
                    ret = new HtmlSelect();
                }
            }

            //Debug.Log("from=" + fromPool);
            if (ret != null)
            {
                //可能已经被GameObject tree deleted了,不再使用
                if (fromPool && ret.displayObject != null && ret.displayObject.isDisposed)
                {
                    ret.Dispose();
                    return(CreateObject(owner, element));
                }
                ret.Create(owner, element);
                if (ret.displayObject != null)
                {
                    ret.displayObject.home = owner.cachedTransform;
                }
            }

            return(ret);
        }
        public virtual void FreeObject(IHtmlObject obj)
        {
            obj.Release();
            if (!Application.isPlaying)
            {
                obj.Dispose();
                return;
            }

            //可能已经被GameObject tree deleted了,不再回收
            if (obj.displayObject != null && obj.displayObject.isDisposed)
                return;

            if (obj is HtmlImage)
                _imagePool.Push(obj);
            else if (obj is HtmlInput)
                _inputPool.Push(obj);
            else if (obj is HtmlButton)
                _buttonPool.Push(obj);
            else if (obj is HtmlLink)
                _linkPool.Push(obj);

            if (obj.displayObject != null)
            {
                if (_poolManager == null)
                    _poolManager = Stage.inst.CreatePoolManager("HtmlObjectPool");

                ToolSet.SetParent(obj.displayObject.cachedTransform, _poolManager);
            }
        }
Example #12
0
 /// <summary>
 /// 将对象外面嵌套FormGroup。
 /// </summary>
 /// <param name="obj">被嵌套内容。</param>
 /// <returns>嵌套完对象。</returns>
 public static FormGroup WrapFormGroup(this IHtmlObject obj)
 {
     return(new FormGroup {
         Children = { obj }
     });
 }