-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed issue where the visible attribute was not correctly converted t… #133
base: master
Are you sure you want to change the base?
Conversation
…o a boolean in TileImageLayer.
pytmx/pytmx.py
Outdated
@@ -1271,9 +1271,6 @@ def parse_xml(self, node): | |||
:return: self | |||
""" | |||
self._set_properties(node) | |||
self.name = node.get('name', None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are these removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These attributes get set in the self._set_properties(node) call. That method, in TiledElement, correctly casts the values for these types in the _cast_and_set_attributes_from_node_items method.
subnodes += find_all_visible_nodes(subnode, node_type) | ||
return subnodes | ||
|
||
for subnode in find_all_visible_nodes(node, 'layer'): | ||
self.add_layer(TiledTileLayer(self, subnode)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only adds visible layers while previously non-visible layers were also added. If there is utility in also adding the non-visible layers, it has been lost. It could be restored with additional changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should be ignoring invisible layers. For instance, a map may have a shape layer for boundaries that might be invisible on tiled, but we still want it loaded to get the shapes.
Thanks been busy but I will take a look
…On Fri, Feb 5, 2021 at 2:10 PM justinbeetle ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pytmx/pytmx.py
<#133 (comment)>:
> +
+ :param node: ElementTree xml node
+ :param node_type: Tag name of elements to find
+ :return: Python list of ElementTree xml nodes
+ """
+ subnodes = []
+ for subnode in node:
+ if 'visible' in subnode.attrib and not convert_to_bool(subnode.attrib['visible']):
+ continue
+ if subnode.tag == node_type:
+ subnodes.append(subnode)
+ elif subnode.tag == 'group':
+ subnodes += find_all_visible_nodes(subnode, node_type)
+ return subnodes
+
+ for subnode in find_all_visible_nodes(node, 'layer'):
self.add_layer(TiledTileLayer(self, subnode))
This only adds visible layers while previously non-visible layers were
also added. If there is utility in also adding the non-visible layers, it
has been lost. It could be restored with additional changes.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#133 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEH5JYPBAG2BTWWKT4KXLLS5RGCZANCNFSM4VTLCVBA>
.
|
…nd_all_visible_nodes in TiledMap.parse_xml to avoid rendering layers nested inside of invisible groups.
…o a boolean in TileImageLayer.