Files

63 lines
2.4 KiB
Python

# Docs inputs for the engine / level-editor sections of the scene, tile map, archive and data pages (tools/fixtures.py,
# tools/docs_check.py): the hand-written ASE of tools/fixtures/ase.py, LDtk's AutoLayers_2_stamps sample (tools/fixtures/ldtk.py),
# HaxeFlixel's TurnBasedRPG Ogmo project and level (tests/fixtures/ogmo), a small Godot scene and resource, the
# UE1 map of tools/fixtures/t3d.py.
# tests/gen/docs_engines.luau { files = { [name] = bytes }, vars = { aseText = "hand.ase", ... } }
import importlib.util, os
TSCN = """[gd_scene load_steps=3 format=3]
[sub_resource type="StandardMaterial3D" id="Mat_1"]
albedo_color = Color(1, 0.5, 0, 1)
metallic = 0.5
[sub_resource type="BoxMesh" id="Box_1"]
material = SubResource("Mat_1")
size = Vector3(1, 2, 1)
[node name="World" type="Node3D"]
[node name="Box" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, 0)
mesh = SubResource("Box_1")
[node name="Camera" type="Camera3D" parent="."]
fov = 60.0
[node name="Hud" type="Node2D" parent="."]
position = Vector2(10, 20)
"""
TRES = """[gd_resource type="StandardMaterial3D" load_steps=2 format=3]
[ext_resource type="Texture2D" path="res://brick.png" id="1"]
[resource]
albedo_color = Color(0.8, 0.4, 0.2, 1)
albedo_texture = ExtResource("1")
metallic = 0.25
roughness = 1.0
"""
INPUTS = ["tools/docs_check.py", "tools/fixtures/t3d.py", "tools/fixtures/ase.py", "tools/fixtures/ldtk.py", "tests/fixtures/ogmo"]
def mod(ctx, name):
spec = importlib.util.spec_from_file_location("fx_" + name, os.path.join(ctx.root, "tools", "fixtures", name + ".py"))
m = importlib.util.module_from_spec(spec)
spec.loader.exec_module(m)
return m
def generate(ctx):
check = mod(ctx, "../docs_check")
files = {"hand.ase": mod(ctx, "ase").HAND.encode()}
files["stamps.ldtk"] = open(os.path.join(mod(ctx, "ldtk").samples_dir(ctx), "AutoLayers_2_stamps.ldtk"), "rb").read()
for f in ("turnBasedRPG.ogmo", "room-001.json"):
files[f] = ctx.read("tests/fixtures/ogmo/" + f)
files["world.tscn"] = TSCN.encode()
files["level.t3d"] = mod(ctx, "t3d").ue1()[0].encode()
files["brick.tres"] = TRES.encode()
vars = {"t3dText": "level.t3d", "tscnText": "world.tscn", "tresText": "brick.tres", "aseText": "hand.ase", "ldtkText": "stamps.ldtk", "ogmoProjectText": "turnBasedRPG.ogmo", "ogmoLevelText": "room-001.json"}
check.emit_inputs(ctx, files, vars)