Files
novafarma/fix_ldtk_view.py

45 lines
1.6 KiB
Python

import json
import os
PROJECT_ROOT = "/Users/davidkotnik/repos/novafarma"
LDTK_FILE = os.path.join(PROJECT_ROOT, "AutoLayers_2_stamps.ldtk")
def main():
# Force redraw / update structure
with open(LDTK_FILE, 'r') as f:
data = json.load(f)
# Ensure Tileset path is correct RELATIVE TO LDTK FILE
# LDtk file is in root.
# Image is at godot/phases/FAZA_1_FARMA/tilesets/TerrainAtlas.png
# The JSON should have "relPath": "godot/phases/FAZA_1_FARMA/tilesets/TerrainAtlas.png"
# Check defs->tilesets
for ts in data['defs']['tilesets']:
if ts['identifier'] == "Terrain_Atlas":
print(f"Current Path: {ts['relPath']}")
# Force set
ts['relPath'] = "godot/phases/FAZA_1_FARMA/tilesets/TerrainAtlas.png"
# Check Layer order. Visuals MUST be rendered.
# Layers list in defs: [IntGrid, AutoLayer]
# This means IntGrid is "above" AutoLayer in UI list usually.
# In LDtk, layers are drawn bottom-to-top from the list? Or top-to-bottom?
# Usually the top of the list is the TOP layer.
# So IntGrid covers Visuals.
# FIX: Move Visuals to TOP of list, or set IntGrid Opacity to 0.5
# Let's set IntGrid Opacity to 0.5 so you can see through it!
for layer in data['defs']['layers']:
if layer['identifier'] == "Terrain_Control":
layer['displayOpacity'] = 0.5 # Make transparent!
with open(LDTK_FILE, 'w') as f:
json.dump(data, f, indent=2)
print("Fixed Opacity and Path!")
if __name__ == "__main__":
main()