mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 18:12:19 +02:00
Revert "Move editor scripts to druid folder"
This reverts commit 007e715009
.
This commit is contained in:
44
druid/editor_scripts/setup_layers.py
Normal file
44
druid/editor_scripts/setup_layers.py
Normal file
@@ -0,0 +1,44 @@
|
||||
# @license MIT, Insality 2021
|
||||
# @source https://github.com/Insality/druid
|
||||
|
||||
import sys
|
||||
import deftree
|
||||
|
||||
def main():
|
||||
filename = sys.argv[1]
|
||||
print("Auto setup layers for file", filename)
|
||||
tree = deftree.parse(filename)
|
||||
root = tree.get_root()
|
||||
|
||||
layers = []
|
||||
for texture in root.iter_elements("textures"):
|
||||
layers.append(texture.get_attribute("name").value)
|
||||
|
||||
for fonts in root.iter_elements("fonts"):
|
||||
layers.append(fonts.get_attribute("name").value)
|
||||
|
||||
to_remove_layers = []
|
||||
for layer in root.iter_elements("layers"):
|
||||
to_remove_layers.append(layer)
|
||||
for layer in to_remove_layers:
|
||||
root.remove(layer)
|
||||
|
||||
for layer in layers:
|
||||
new_layer = root.add_element("layers")
|
||||
new_layer.add_attribute("name", layer)
|
||||
|
||||
for node in root.iter_elements("nodes"):
|
||||
texture = node.get_attribute("texture")
|
||||
font = node.get_attribute("font")
|
||||
|
||||
if texture:
|
||||
layer = texture.value.split("/")[0]
|
||||
node.set_attribute("layer", layer)
|
||||
|
||||
if font:
|
||||
layer = font.value
|
||||
node.set_attribute("layer", layer)
|
||||
|
||||
tree.write()
|
||||
|
||||
main()
|
Reference in New Issue
Block a user