Beispiel #1
0
        private void ApplyComponentSelector(ModuleWalkCallback visitor, XmlNode node, UIComponent component)
        {
            var name = XmlUtil.GetStringAttribute(node, "name");

            bool regex     = XmlUtil.TryGetBoolAttribute(node, "name_regex");
            bool recursive = XmlUtil.TryGetBoolAttribute(node, "recursive");
            bool optional  = XmlUtil.TryGetBoolAttribute(node, "optional");

            var childComponents = Util.FindComponentsInChildren(node, component, name, regex, recursive, optional);

            var hash = XmlUtil.TryGetStringAttribute(node, "hash", null);

            foreach (var childComponent in childComponents)
            {
                if (hash != null)
                {
                    var componentHash =
                        HashUtil.HashToString(
                            HashUtil.HashRect(new Rect(childComponent.relativePosition.x,
                                                       childComponent.relativePosition.y,
                                                       childComponent.size.x, childComponent.size.y)));

                    if (Regex.IsMatch(componentHash, hash))
                    {
                        WalkModuleInternalRecursive(visitor, node, childComponent);
                        break;
                    }

                    continue;
                }

                WalkModuleInternalRecursive(visitor, node, childComponent);
            }
        }
        public void WalkModule(ModuleWalkCallback visitor)
        {
            var rootNode = _document.SelectSingleNode("/UIView");
            if (rootNode == null)
            {
                throw new Exception("SkinModule missing root UIView node");
            }

            WalkModuleInternalRecursive(visitor, rootNode, null);
        }
Beispiel #3
0
        public void WalkModule(ModuleWalkCallback visitor)
        {
            var rootNode = _document.SelectSingleNode("/UIView");

            if (rootNode == null)
            {
                throw new Exception("SkinModule missing root UIView node");
            }

            WalkModuleInternalRecursive(visitor, rootNode, null);
        }
Beispiel #4
0
        private void WalkModuleInternalRecursive(ModuleWalkCallback visitor, XmlNode node, UIComponent component)
        {
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.Attributes == null)
                {
                    Debug.LogWarningFormat("Child with null attributes: \"{0}\"", XmlUtil.XmlNodeInfo(childNode));
                    continue;
                }

                if (childNode.Name == "Component")
                {
                    ApplyComponentSelector(visitor, childNode, component);
                }
                else if (component != null)
                {
                    visitor(childNode, component);
                }
                else
                {
                    throw new ParseException("Setting properties on the UIView object is not allowed!", childNode);
                }
            }
        }
        private void WalkModuleInternalRecursive(ModuleWalkCallback visitor, XmlNode node, UIComponent component)
        {
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.Attributes == null)
                {
                    Debug.LogWarningFormat("Child with null attributes: \"{0}\"", XmlUtil.XmlNodeInfo(childNode));
                    continue;
                }

                if (childNode.Name == "Component")
                {
                    ApplyComponentSelector(visitor, childNode, component);
                }
                else if (component != null)
                {
                    visitor(childNode, component);
                }
                else
                {
                    throw new ParseException("Setting properties on the UIView object is not allowed!", childNode);
                }
            }
        }
        private void ApplyComponentSelector(ModuleWalkCallback visitor, XmlNode node, UIComponent component)
        {
            var name = XmlUtil.GetStringAttribute(node, "name");

            bool regex = XmlUtil.TryGetBoolAttribute(node, "name_regex");
            bool recursive = XmlUtil.TryGetBoolAttribute(node, "recursive");
            bool optional = XmlUtil.TryGetBoolAttribute(node, "optional");

            var childComponents = Util.FindComponentsInChildren(node, component, name, regex, recursive, optional);

            var hash = XmlUtil.TryGetStringAttribute(node, "hash", null);

            foreach (var childComponent in childComponents)
            {
                if (hash != null)
                {
                    var componentHash =
                        HashUtil.HashToString(
                            HashUtil.HashRect(new Rect(childComponent.relativePosition.x,
                                childComponent.relativePosition.y,
                                childComponent.size.x, childComponent.size.y)));

                    if (Regex.IsMatch(componentHash, hash))
                    {
                        WalkModuleInternalRecursive(visitor, node, childComponent);
                        break;
                    }

                    continue;
                }

                WalkModuleInternalRecursive(visitor, node, childComponent);
            }
        }