Exemple #1
0
        /*
         *  TreeQL関連、実際に操作できるタイミングは非アップデート中とかそんな感じなので、
         *  stateに関する制約が必要。
         */

        public void AppendContentToLast(string htmlContent, string query = "")
        {
            if (viewState != ViewState.Ready)
            {
                return;
            }

            TagTree.CorrectTrees(layoutedTree);

            var parser = new HTMLParser(resLoader);
            var parse  = parser.ParseRoot(
                htmlContent,
                parsedTagTree =>
            {
                if (parsedTagTree.errors.Any())
                {
                    Debug.LogError("parse errors:" + parsedTagTree.errors.Count);

                    foreach (var error in parsedTagTree.errors)
                    {
                        Debug.LogError("code:" + error.code + " reason:" + error.reason);
                    }
                    return;
                }

                // parse succeeded.
                var newTreeIds     = TagTree.CollectTreeIds(parsedTagTree);
                var currentTreeIds = TagTree.CollectTreeIds(layoutedTree);

                var appendedTreeIds = newTreeIds.Except(currentTreeIds).ToArray();

                var children = parsedTagTree.GetChildren();

                // add to content.
                if (string.IsNullOrEmpty(query))
                {
                    layoutedTree.AddChildren(children.ToArray());
                }
                else
                {
                    var targetTreeFamily = GetTreeFamily(new List <TagTree> {
                        layoutedTree
                    }, GetQuery(query));
                    targetTreeFamily.Last().AddChildren(children.ToArray());
                }

                // relayout.
                Update(appendedTreeIds, () => { });
            }
                );

            CoroutineExecutor(parse);
        }
Exemple #2
0
        /**
         *  layout -> materialize.
         *  if parsedTagTree was changed, materialize dirty flagged content only.
         */
        private IEnumerator Load(TagTree tree, Vector2 viewRect, float offsetY, GameObject eventReceiverGameObj = null)
        {
            var usingIds = TagTree.CorrectTrees(tree);

            IEnumerator materialize = null;
            var         layout      = layoutMachine.Layout(
                tree,
                viewRect,
                layoutedTree =>
            {
                // update layouted tree.
                this.layoutedTree = layoutedTree;

                var newIds = TagTree.CollectTreeIds(this.layoutedTree);

                UpdateParentViewSizeIfExist();

                resLoader.BackGameObjects(usingIds);
                materialize = materializeMachine.Materialize(
                    view.GetGameObject(),
                    this,
                    this.layoutedTree,
                    viewRect,
                    offsetY,
                    () =>
                {
                    StartCalculateProgress(newIds);
                }
                    );
            }
                );

            {
                while (layout.MoveNext())
                {
                    yield return(null);
                }
            }

            {
                while (materialize.MoveNext())
                {
                    yield return(null);
                }
            }
        }