topotopo 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +40 -10
- package/README.md +475 -111
- package/dist/cli.js +328 -133
- package/dist/config.d.ts +48 -0
- package/dist/config.js +170 -0
- package/dist/core/analysis.d.ts +5 -1
- package/dist/core/analysis.js +8 -3
- package/dist/core/bake.d.ts +16 -8
- package/dist/core/bake.js +165 -29
- package/dist/core/bevel.d.ts +3 -1
- package/dist/core/bevel.js +238 -97
- package/dist/core/decimate.d.ts +65 -0
- package/dist/core/decimate.js +409 -3
- package/dist/core/erosion.d.ts +37 -0
- package/dist/core/erosion.js +41 -1
- package/dist/core/geometry.d.ts +5 -1
- package/dist/core/geometry.js +204 -4
- package/dist/core/heightfield.d.ts +27 -4
- package/dist/core/heightfield.js +54 -16
- package/dist/core/imageops.d.ts +6 -0
- package/dist/core/imageops.js +51 -0
- package/dist/core/intrinsics.d.ts +7 -0
- package/dist/core/intrinsics.js +94 -0
- package/dist/core/manifold.d.ts +12 -1
- package/dist/core/manifold.js +78 -6
- package/dist/core/materials.d.ts +11 -0
- package/dist/core/materials.js +56 -0
- package/dist/core/noise.d.ts +9 -0
- package/dist/core/noise.js +10 -1
- package/dist/core/packed.js +11 -0
- package/dist/core/particles.d.ts +1 -1
- package/dist/core/particles.js +1 -1
- package/dist/core/polymerge.d.ts +21 -0
- package/dist/core/polymerge.js +327 -0
- package/dist/core/rbd.js +13 -1
- package/dist/core/repair.d.ts +2 -0
- package/dist/core/repair.js +2 -0
- package/dist/core/report.d.ts +70 -0
- package/dist/core/report.js +275 -0
- package/dist/core/scatter.d.ts +1 -1
- package/dist/core/scatter.js +1 -1
- package/dist/core/scene.d.ts +20 -0
- package/dist/core/scene.js +72 -0
- package/dist/core/sha256.d.ts +4 -0
- package/dist/core/sha256.js +69 -0
- package/dist/core/shapes.d.ts +3 -0
- package/dist/core/shapes.js +34 -0
- package/dist/core/snippet-lib.d.ts +15 -2
- package/dist/core/snippet-lib.js +40 -14
- package/dist/core/solidify.d.ts +38 -0
- package/dist/core/solidify.js +356 -0
- package/dist/core/tangents.d.ts +54 -0
- package/dist/core/tangents.js +218 -0
- package/dist/core/texcoord.d.ts +4 -0
- package/dist/core/texcoord.js +14 -0
- package/dist/core/texnoise.d.ts +6 -1
- package/dist/core/texnoise.js +6 -2
- package/dist/core/texsdf.d.ts +131 -0
- package/dist/core/texsdf.js +637 -0
- package/dist/core/texture.d.ts +163 -9
- package/dist/core/texture.js +844 -20
- package/dist/core/topology.d.ts +32 -0
- package/dist/core/topology.js +238 -7
- package/dist/core/traceimage.d.ts +7 -0
- package/dist/core/traceimage.js +221 -0
- package/dist/core/tritri.d.ts +5 -0
- package/dist/core/tritri.js +120 -0
- package/dist/core/unwrap.d.ts +72 -0
- package/dist/core/unwrap.js +800 -0
- package/dist/core/usercode.d.ts +27 -0
- package/dist/core/usercode.js +87 -0
- package/dist/core/uv.d.ts +15 -16
- package/dist/core/uv.js +36 -189
- package/dist/core/uvislands.d.ts +62 -0
- package/dist/core/uvislands.js +574 -0
- package/dist/core/uvoverlap.d.ts +58 -0
- package/dist/core/uvoverlap.js +220 -0
- package/dist/core/uvpack.d.ts +64 -0
- package/dist/core/uvpack.js +628 -0
- package/dist/core/uvreport.d.ts +127 -0
- package/dist/core/uvreport.js +372 -0
- package/dist/core/wrangle.d.ts +6 -1
- package/dist/core/wrangle.js +27 -16
- package/dist/core/xatlas.d.ts +16 -1
- package/dist/core/xatlas.js +95 -61
- package/dist/engines.d.ts +63 -0
- package/dist/engines.js +180 -0
- package/dist/explain.d.ts +4 -3
- package/dist/explain.js +129 -12
- package/dist/graph/engine.d.ts +92 -29
- package/dist/graph/engine.js +298 -148
- package/dist/graph/expr.d.ts +6 -3
- package/dist/graph/expr.js +18 -8
- package/dist/graph/outputs.d.ts +23 -0
- package/dist/graph/outputs.js +41 -0
- package/dist/graph/packages.d.ts +72 -0
- package/dist/graph/packages.js +261 -0
- package/dist/graph/parallel.d.ts +3 -1
- package/dist/graph/parallel.js +4 -1
- package/dist/graph/params.d.ts +6 -0
- package/dist/graph/params.js +34 -7
- package/dist/graph/scope.d.ts +55 -0
- package/dist/graph/scope.js +14 -0
- package/dist/graph/types.d.ts +75 -12
- package/dist/graph/types.js +4 -2
- package/dist/graph/vars.d.ts +16 -0
- package/dist/graph/vars.js +80 -0
- package/dist/host/artifacts.d.ts +10 -1
- package/dist/host/artifacts.js +37 -6
- package/dist/host/cook.d.ts +241 -0
- package/dist/host/cook.js +844 -0
- package/dist/host/export-targets.d.ts +42 -5
- package/dist/host/export-targets.js +72 -13
- package/dist/host/godot-commands.d.ts +4 -0
- package/dist/host/godot-commands.js +21 -0
- package/dist/host/godot.d.ts +183 -0
- package/dist/host/godot.js +916 -0
- package/dist/host/node.d.ts +12 -7
- package/dist/host/node.js +27 -9
- package/dist/host/pool.js +51 -2
- package/dist/host/sidecars.d.ts +8 -0
- package/dist/host/sidecars.js +50 -0
- package/dist/host/types.d.ts +19 -6
- package/dist/host/version.d.ts +1 -0
- package/dist/host/version.js +3 -0
- package/dist/host/worker.js +5 -2
- package/dist/index.d.ts +5 -3
- package/dist/index.js +3 -2
- package/dist/inspect.d.ts +84 -1
- package/dist/inspect.js +271 -24
- package/dist/io/common.d.ts +33 -5
- package/dist/io/export.js +2 -1
- package/dist/io/files.d.ts +23 -4
- package/dist/io/files.js +60 -8
- package/dist/io/gltf.js +355 -51
- package/dist/io/heightmap.d.ts +3 -0
- package/dist/io/heightmap.js +1 -0
- package/dist/io/import.js +10 -0
- package/dist/io/inspect-scene.d.ts +55 -0
- package/dist/io/inspect-scene.js +155 -0
- package/dist/io/kinds.d.ts +81 -0
- package/dist/io/kinds.js +163 -0
- package/dist/io/points.d.ts +2 -1
- package/dist/io/points.js +3 -1
- package/dist/io/sidecars.d.ts +24 -0
- package/dist/io/sidecars.js +57 -0
- package/dist/io/source.d.ts +65 -0
- package/dist/io/source.js +112 -0
- package/dist/io/targets.d.ts +47 -3
- package/dist/io/targets.js +149 -14
- package/dist/io/textures.js +21 -1
- package/dist/io/unreal.js +5 -1
- package/dist/mcp/docs.d.ts +10 -1
- package/dist/mcp/docs.js +816 -119
- package/dist/mcp/inputs.d.ts +12 -5
- package/dist/mcp/inputs.js +50 -13
- package/dist/mcp/server.js +70 -24
- package/dist/mcp/tools.d.ts +14 -7
- package/dist/mcp/tools.js +207 -108
- package/dist/mcp/verify.d.ts +2 -2
- package/dist/mcp/verify.js +1 -1
- package/dist/mcp/workspace.d.ts +15 -0
- package/dist/mcp/workspace.js +349 -0
- package/dist/nodes/attributes.js +198 -1
- package/dist/nodes/bake.js +207 -83
- package/dist/nodes/beam.d.ts +1 -0
- package/dist/nodes/beam.js +201 -0
- package/dist/nodes/bevel.js +54 -5
- package/dist/nodes/cloth.js +2 -0
- package/dist/nodes/code.js +22 -10
- package/dist/nodes/curves.js +440 -93
- package/dist/nodes/flow.js +53 -33
- package/dist/nodes/generate.js +13 -39
- package/dist/nodes/heightfield.js +248 -77
- package/dist/nodes/imageops.d.ts +1 -0
- package/dist/nodes/imageops.js +203 -0
- package/dist/nodes/index.d.ts +4 -0
- package/dist/nodes/index.js +4 -0
- package/dist/nodes/material.js +91 -23
- package/dist/nodes/measure.js +45 -18
- package/dist/nodes/particles.js +2 -0
- package/dist/nodes/pcg.js +6 -5
- package/dist/nodes/procedural.js +4 -3
- package/dist/nodes/rbd.js +1 -1
- package/dist/nodes/remesh.js +71 -15
- package/dist/nodes/scene.d.ts +1 -0
- package/dist/nodes/scene.js +55 -0
- package/dist/nodes/sdf.js +10 -5
- package/dist/nodes/solid.js +20 -5
- package/dist/nodes/solidify.d.ts +1 -0
- package/dist/nodes/solidify.js +52 -0
- package/dist/nodes/splines.d.ts +15 -1
- package/dist/nodes/splines.js +112 -105
- package/dist/nodes/texture.d.ts +21 -6
- package/dist/nodes/texture.js +1318 -185
- package/dist/nodes/topology.d.ts +7 -0
- package/dist/nodes/topology.js +133 -6
- package/dist/nodes/transform.js +11 -3
- package/dist/nodes/util.d.ts +1 -1
- package/dist/nodes/uv.js +192 -174
- package/dist/nodes/wasmcall.js +6 -2
- package/dist/open.d.ts +19 -0
- package/dist/open.js +12 -0
- package/dist/package.d.ts +288 -0
- package/dist/package.js +772 -0
- package/dist/packages/check.d.ts +32 -0
- package/dist/packages/check.js +169 -0
- package/dist/packages/commands.d.ts +57 -0
- package/dist/packages/commands.js +537 -0
- package/dist/packages/registry.d.ts +796 -0
- package/dist/packages/registry.js +2998 -0
- package/dist/packages/update.d.ts +124 -0
- package/dist/packages/update.js +476 -0
- package/dist/render/options.d.ts +2 -0
- package/dist/render/options.js +44 -5
- package/dist/render/pbr.d.ts +28 -0
- package/dist/render/pbr.js +378 -0
- package/dist/render/preview.d.ts +69 -0
- package/dist/render/preview.js +26 -0
- package/dist/render/raster.d.ts +78 -7
- package/dist/render/raster.js +600 -145
- package/dist/render/texview.d.ts +7 -1
- package/dist/render/texview.js +34 -2
- package/dist/scan.d.ts +61 -0
- package/dist/scan.js +228 -0
- package/dist/session.d.ts +311 -0
- package/dist/session.js +849 -0
- package/dist/viewer/app/api.js +48 -6
- package/dist/viewer/app/camera.js +1 -1
- package/dist/viewer/app/cooking.js +78 -0
- package/dist/viewer/app/embed.js +100 -0
- package/dist/viewer/app/export-popover.js +118 -16
- package/dist/viewer/app/grid.js +6 -2
- package/dist/viewer/app/guides.js +123 -1
- package/dist/viewer/app/keymap.js +7 -4
- package/dist/viewer/app/layers.js +5 -5
- package/dist/viewer/app/main.js +186 -53
- package/dist/viewer/app/markers.js +61 -1
- package/dist/viewer/app/outliner.js +72 -27
- package/dist/viewer/app/output-info.js +45 -0
- package/dist/viewer/app/outputs.css +147 -8
- package/dist/viewer/app/outputs.js +168 -54
- package/dist/viewer/app/packages.js +614 -0
- package/dist/viewer/app/props.js +177 -53
- package/dist/viewer/app/scene.js +35 -6
- package/dist/viewer/app/select.js +5 -4
- package/dist/viewer/app/selection.js +1 -1
- package/dist/viewer/app/status.js +12 -15
- package/dist/viewer/app/style.css +66 -8
- package/dist/viewer/app/units.js +1 -1
- package/dist/viewer/app/vars.js +48 -1
- package/dist/viewer/app/welcome.js +72 -0
- package/dist/viewer/graph-file.d.ts +62 -0
- package/dist/viewer/graph-file.js +175 -0
- package/dist/viewer/index.html +24 -11
- package/dist/viewer/json-edit.d.ts +13 -0
- package/dist/viewer/json-edit.js +274 -0
- package/dist/viewer/outputs.d.ts +49 -5
- package/dist/viewer/outputs.js +264 -56
- package/dist/viewer/packages.d.ts +121 -0
- package/dist/viewer/packages.js +584 -0
- package/dist/viewer/server.d.ts +24 -7
- package/dist/viewer/server.js +289 -31
- package/dist/web/app/web.css +419 -0
- package/dist/web/app/web.js +188 -0
- package/dist/web/bake.d.ts +34 -0
- package/dist/web/bake.js +153 -0
- package/dist/web/folder-page.d.ts +101 -0
- package/dist/web/folder-page.js +146 -0
- package/dist/web/folders.d.ts +280 -0
- package/dist/web/folders.js +970 -0
- package/dist/web/library.d.ts +91 -0
- package/dist/web/library.js +228 -0
- package/dist/web/markdown.d.ts +45 -0
- package/dist/web/markdown.js +677 -0
- package/dist/web/pages.d.ts +258 -0
- package/dist/web/pages.js +301 -0
- package/dist/web/server.d.ts +24 -0
- package/dist/web/server.js +1068 -0
- package/dist/workspace.d.ts +88 -105
- package/dist/workspace.js +359 -375
- package/integrations/godot/addons/topotopo/LICENSE +202 -0
- package/integrations/godot/addons/topotopo/README.md +57 -0
- package/integrations/godot/addons/topotopo/context_menu.gd +43 -0
- package/integrations/godot/addons/topotopo/dock.gd +266 -0
- package/integrations/godot/addons/topotopo/dock.tscn +72 -0
- package/integrations/godot/addons/topotopo/export_filter.gd +72 -0
- package/integrations/godot/addons/topotopo/gltf_instancing.gd +131 -0
- package/integrations/godot/addons/topotopo/icons/topotopo.svg +1 -0
- package/integrations/godot/addons/topotopo/inspector.gd +38 -0
- package/integrations/godot/addons/topotopo/instances_post_import.gd +111 -0
- package/integrations/godot/addons/topotopo/package.gd +23 -0
- package/integrations/godot/addons/topotopo/package_importer.gd +187 -0
- package/integrations/godot/addons/topotopo/plugin.cfg +7 -0
- package/integrations/godot/addons/topotopo/plugin.gd +970 -0
- package/integrations/godot/addons/topotopo/record.gd +435 -0
- package/integrations/godot/addons/topotopo/runner.gd +458 -0
- package/integrations/godot/addons/topotopo/tools/check.gd +42 -0
- package/integrations/godot/addons/topotopo/watcher.gd +199 -0
- package/kernels/pkg/README.md +23 -29
- package/kernels/pkg-simd/README.md +23 -29
- package/library/architecture/versions/1.0/architecture.topo +12 -0
- package/{shelf → library/architecture/versions/1.0/graphs}/arch.json +3 -3
- package/{shelf → library/architecture/versions/1.0/graphs}/beam_truss.json +6 -6
- package/{shelf → library/architecture/versions/1.0/graphs}/brick_wall.json +8 -8
- package/{shelf → library/architecture/versions/1.0/graphs}/door_frame.json +3 -3
- package/{shelf → library/architecture/versions/1.0/graphs}/hex_grid_floor.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/house.json +8 -8
- package/library/architecture/versions/1.0/graphs/lineup.json +42 -0
- package/{shelf → library/architecture/versions/1.0/graphs}/pillar.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/railing.json +5 -5
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_gable.json +2 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_hip.json +2 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_skeleton.json +2 -1
- package/{shelf → library/architecture/versions/1.0/graphs}/scaffold.json +4 -4
- package/{shelf → library/architecture/versions/1.0/graphs}/spiral_stairs.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/stairs.json +6 -6
- package/{shelf → library/architecture/versions/1.0/graphs}/tile_floor.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/wall_segment.json +10 -10
- package/{shelf → library/architecture/versions/1.0/graphs}/window_frame.json +2 -2
- package/library/architecture/versions/1.0/version.json +1119 -0
- package/{shelf → library/nature/versions/1.0/graphs}/bush.json +2 -2
- package/{shelf → library/nature/versions/1.0/graphs}/cliff_block.json +4 -3
- package/{shelf → library/nature/versions/1.0/graphs}/forest_patch.json +5 -5
- package/{shelf → library/nature/versions/1.0/graphs}/grass_clumps.json +2 -2
- package/library/nature/versions/1.0/graphs/lineup.json +24 -0
- package/{shelf → library/nature/versions/1.0/graphs}/log.json +6 -6
- package/{shelf → library/nature/versions/1.0/graphs}/rock.json +5 -4
- package/{shelf → library/nature/versions/1.0/graphs}/scatter_rocks.json +5 -5
- package/{shelf → library/nature/versions/1.0/graphs}/tree_lowpoly.json +3 -2
- package/library/nature/versions/1.0/nature.topo +12 -0
- package/library/nature/versions/1.0/version.json +534 -0
- package/{shelf → library/props/versions/1.0/graphs}/barrel.json +5 -4
- package/{shelf → library/props/versions/1.0/graphs}/crate.json +3 -3
- package/library/props/versions/1.0/graphs/lineup.json +18 -0
- package/{shelf → library/props/versions/1.0/graphs}/pallet.json +4 -3
- package/{shelf → library/props/versions/1.0/graphs}/pipe_run.json +3 -3
- package/{shelf → library/props/versions/1.0/graphs}/sandbag_wall.json +5 -5
- package/library/props/versions/1.0/props.topo +12 -0
- package/library/props/versions/1.0/version.json +336 -0
- package/{shelf → library/street/versions/1.0/graphs}/bench.json +5 -5
- package/{shelf → library/street/versions/1.0/graphs}/bollard.json +2 -1
- package/{shelf → library/street/versions/1.0/graphs}/cable.json +4 -4
- package/{shelf → library/street/versions/1.0/graphs}/fence.json +7 -7
- package/{shelf → library/street/versions/1.0/graphs}/lamp_post.json +2 -2
- package/library/street/versions/1.0/graphs/lineup.json +22 -0
- package/{shelf → library/street/versions/1.0/graphs}/road_strip.json +2 -2
- package/{shelf → library/street/versions/1.0/graphs}/sign_post.json +1 -1
- package/library/street/versions/1.0/street.topo +12 -0
- package/library/street/versions/1.0/version.json +421 -0
- package/package.json +23 -8
- package/dist/graph/migrate.d.ts +0 -23
- package/dist/graph/migrate.js +0 -58
- package/shelf/index.json +0 -190
|
@@ -0,0 +1,970 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
extends EditorPlugin
|
|
3
|
+
## TopoTopo's Godot addon. A TopoTopo package inside the project imports as <id>.topo; its published outputs are cooked
|
|
4
|
+
## (topotopo cook --jobs …) into plain GLBs and PNGs that Godot imports itself, and kept current while the package's
|
|
5
|
+
## files change. PROTOCOL.md in the TopoTopo repository is the contract with the command line.
|
|
6
|
+
##
|
|
7
|
+
## This script is the hub: it registers the importer, the glTF instancing extension and its post-import step, the
|
|
8
|
+
## export filter, the context menu, the inspector header, the dock and the editor settings; it keeps the packages'
|
|
9
|
+
## state, runs cooks through runner.gd and imports what they wrote. watcher.gd decides when to cook.
|
|
10
|
+
|
|
11
|
+
const PROTOCOL := 1
|
|
12
|
+
const Record := preload("record.gd")
|
|
13
|
+
const Runner := preload("runner.gd")
|
|
14
|
+
const Importer := preload("package_importer.gd")
|
|
15
|
+
const Instancing := preload("gltf_instancing.gd")
|
|
16
|
+
const PostImport := preload("instances_post_import.gd")
|
|
17
|
+
const ExportFilter := preload("export_filter.gd")
|
|
18
|
+
const ContextMenu := preload("context_menu.gd")
|
|
19
|
+
const Inspector := preload("inspector.gd")
|
|
20
|
+
const Dock := preload("dock.tscn")
|
|
21
|
+
const Watcher := preload("watcher.gd")
|
|
22
|
+
|
|
23
|
+
const SETTING := "filesystem/import/topotopo/"
|
|
24
|
+
const UNFOCUSED := "interface/editor/behavior/import_resources_when_unfocused"
|
|
25
|
+
const MENU := "TopoTopo"
|
|
26
|
+
|
|
27
|
+
## The packages' state changed (the dock and the inspector redraw).
|
|
28
|
+
signal packages_changed
|
|
29
|
+
|
|
30
|
+
## The project folder (absolute, no trailing slash).
|
|
31
|
+
var project := ""
|
|
32
|
+
var record: Record
|
|
33
|
+
var runner: Runner
|
|
34
|
+
var headless := false
|
|
35
|
+
## res:// of each .topo -> its state: {topo, abs, dir, id, fresh, record, report, cooking, progress, error, crashed,
|
|
36
|
+
## last_ms, last_time, copy, root}
|
|
37
|
+
var packages := {}
|
|
38
|
+
var first_scan_done := false
|
|
39
|
+
|
|
40
|
+
var _importer: Importer
|
|
41
|
+
var _instancing: Instancing
|
|
42
|
+
var _post_import: PostImport
|
|
43
|
+
var _export_filter: ExportFilter
|
|
44
|
+
var _context_menu: ContextMenu
|
|
45
|
+
var _inspector: Inspector
|
|
46
|
+
var _dock: Control
|
|
47
|
+
var _watcher: Node
|
|
48
|
+
var _menu: PopupMenu
|
|
49
|
+
|
|
50
|
+
var _batch_depth := 0
|
|
51
|
+
var _batch := PackedStringArray()
|
|
52
|
+
## Godot's nested texture import can clear its outer scene-reload list. Reimport those scenes once after
|
|
53
|
+
## the outer batch finishes, when their extracted textures are current. Let Godot preserve the edited instances.
|
|
54
|
+
var _nested_scenes := {}
|
|
55
|
+
var _scene_retry_md5 := {}
|
|
56
|
+
var _force_reimport := {}
|
|
57
|
+
var _flushing := false
|
|
58
|
+
## Files a cook wrote, to import (res:// -> true when the import waits for the focus rule).
|
|
59
|
+
var _pending := {}
|
|
60
|
+
## .topo files whose status resource may be behind their record: res:// -> {gated (waits for the focus rule),
|
|
61
|
+
## written (a cook rewrote the record)}.
|
|
62
|
+
var _refresh := {}
|
|
63
|
+
## What each .topo's last import saw (res:// -> {record: the record's md5, state: its freshness state}).
|
|
64
|
+
var _imported := {}
|
|
65
|
+
var _said_missing := false
|
|
66
|
+
var _said_skipped := {}
|
|
67
|
+
var _viewers := {}
|
|
68
|
+
var _flush_queued := false
|
|
69
|
+
var _tries := {}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
func _get_plugin_name() -> String:
|
|
73
|
+
return "TopoTopo"
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
func _enter_tree() -> void:
|
|
77
|
+
# a headless editor (--import, --export-*) cooks before its first scan and has no window parts;
|
|
78
|
+
# TOPOTOPO_GODOT_WINDOW=1 makes one work as with a window (the tests drive the window's flow that way)
|
|
79
|
+
headless = DisplayServer.get_name() == "headless" and OS.get_environment("TOPOTOPO_GODOT_WINDOW") != "1"
|
|
80
|
+
project = ProjectSettings.globalize_path("res://").replace("\\", "/").trim_suffix("/")
|
|
81
|
+
record = Record.new()
|
|
82
|
+
_register_settings()
|
|
83
|
+
runner = Runner.new(project, editor_settings())
|
|
84
|
+
_importer = Importer.new()
|
|
85
|
+
_importer.host = self
|
|
86
|
+
add_import_plugin(_importer)
|
|
87
|
+
_instancing = Instancing.new()
|
|
88
|
+
GLTFDocument.register_gltf_document_extension(_instancing)
|
|
89
|
+
_post_import = PostImport.new()
|
|
90
|
+
add_scene_post_import_plugin(_post_import)
|
|
91
|
+
_export_filter = ExportFilter.new()
|
|
92
|
+
_export_filter.host = self
|
|
93
|
+
add_export_plugin(_export_filter)
|
|
94
|
+
var efs := EditorInterface.get_resource_filesystem()
|
|
95
|
+
efs.resources_reimporting.connect(_on_reimporting)
|
|
96
|
+
efs.resources_reimported.connect(_on_reimported)
|
|
97
|
+
efs.filesystem_changed.connect(_on_filesystem_changed)
|
|
98
|
+
_watcher = Watcher.new()
|
|
99
|
+
_watcher.host = self
|
|
100
|
+
add_child(_watcher)
|
|
101
|
+
if not headless:
|
|
102
|
+
add_window_parts()
|
|
103
|
+
_startup()
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
## The parts of the editor's window: the context menu, the inspector header, the panel, Project > Tools > TopoTopo, and
|
|
107
|
+
## the reaction to settings. A headless editor (--import, --export-*) has none, and cooks before its first scan
|
|
108
|
+
## instead of in the background.
|
|
109
|
+
func add_window_parts() -> void:
|
|
110
|
+
if _dock:
|
|
111
|
+
return
|
|
112
|
+
_context_menu = ContextMenu.new()
|
|
113
|
+
_context_menu.host = self
|
|
114
|
+
add_context_menu_plugin(EditorContextMenuPlugin.CONTEXT_SLOT_FILESYSTEM, _context_menu)
|
|
115
|
+
_inspector = Inspector.new()
|
|
116
|
+
_inspector.host = self
|
|
117
|
+
add_inspector_plugin(_inspector)
|
|
118
|
+
_dock = Dock.instantiate()
|
|
119
|
+
_dock.host = self
|
|
120
|
+
add_dock(_dock)
|
|
121
|
+
_menu = PopupMenu.new()
|
|
122
|
+
_menu.add_item("Cook Stale Packages", 0)
|
|
123
|
+
_menu.add_item("Recook All", 1)
|
|
124
|
+
_menu.add_separator()
|
|
125
|
+
_menu.add_item("Show TopoTopo Panel", 2)
|
|
126
|
+
_menu.id_pressed.connect(_on_menu)
|
|
127
|
+
add_tool_submenu_item(MENU, _menu)
|
|
128
|
+
EditorInterface.get_editor_settings().settings_changed.connect(_on_settings_changed)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
func _exit_tree() -> void:
|
|
132
|
+
var efs := EditorInterface.get_resource_filesystem()
|
|
133
|
+
if efs.resources_reimporting.is_connected(_on_reimporting):
|
|
134
|
+
efs.resources_reimporting.disconnect(_on_reimporting)
|
|
135
|
+
efs.resources_reimported.disconnect(_on_reimported)
|
|
136
|
+
efs.filesystem_changed.disconnect(_on_filesystem_changed)
|
|
137
|
+
if EditorInterface.get_editor_settings().settings_changed.is_connected(_on_settings_changed):
|
|
138
|
+
EditorInterface.get_editor_settings().settings_changed.disconnect(_on_settings_changed)
|
|
139
|
+
runner.kill_all()
|
|
140
|
+
for v in _viewers.values():
|
|
141
|
+
if OS.is_process_running(v.pid):
|
|
142
|
+
OS.kill(v.pid)
|
|
143
|
+
_viewers.clear()
|
|
144
|
+
if _menu:
|
|
145
|
+
remove_tool_menu_item(MENU)
|
|
146
|
+
_menu = null
|
|
147
|
+
if _dock:
|
|
148
|
+
remove_dock(_dock)
|
|
149
|
+
_dock.queue_free()
|
|
150
|
+
_dock = null
|
|
151
|
+
if _inspector:
|
|
152
|
+
remove_inspector_plugin(_inspector)
|
|
153
|
+
_inspector.host = null
|
|
154
|
+
if _context_menu:
|
|
155
|
+
remove_context_menu_plugin(_context_menu)
|
|
156
|
+
_context_menu.host = null
|
|
157
|
+
remove_export_plugin(_export_filter)
|
|
158
|
+
_export_filter.host = null
|
|
159
|
+
remove_scene_post_import_plugin(_post_import)
|
|
160
|
+
GLTFDocument.unregister_gltf_document_extension(_instancing)
|
|
161
|
+
remove_import_plugin(_importer)
|
|
162
|
+
_importer.host = null
|
|
163
|
+
if _watcher:
|
|
164
|
+
_watcher.queue_free()
|
|
165
|
+
_watcher = null
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
# ------------------------------------------------------------------------------------------------------- settings
|
|
169
|
+
|
|
170
|
+
func _register_settings() -> void:
|
|
171
|
+
var es := EditorInterface.get_editor_settings()
|
|
172
|
+
var defs := [
|
|
173
|
+
["topotopo_path", "", TYPE_STRING, PROPERTY_HINT_GLOBAL_FILE, "*.ts,*.js"],
|
|
174
|
+
["node_path", "", TYPE_STRING, PROPERTY_HINT_GLOBAL_FILE, "*.exe" if OS.get_name() == "Windows" else ""],
|
|
175
|
+
["live_cook", true, TYPE_BOOL, PROPERTY_HINT_NONE, ""],
|
|
176
|
+
["watch_interval", 1.0, TYPE_FLOAT, PROPERTY_HINT_RANGE, "0,10,0.1,suffix:s"],
|
|
177
|
+
["cook_timeout", 600.0, TYPE_FLOAT, PROPERTY_HINT_RANGE, "10,7200,1,suffix:s"],
|
|
178
|
+
]
|
|
179
|
+
for d in defs:
|
|
180
|
+
var name: String = SETTING + d[0]
|
|
181
|
+
if not es.has_setting(name):
|
|
182
|
+
es.set_setting(name, d[1])
|
|
183
|
+
es.set_initial_value(name, d[1], false)
|
|
184
|
+
es.add_property_info({"name": name, "type": d[2], "hint": d[3], "hint_string": d[4]})
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
func editor_settings() -> Dictionary:
|
|
188
|
+
var es := EditorInterface.get_editor_settings()
|
|
189
|
+
var val := func(k: String, d): return es.get_setting(SETTING + k) if es.has_setting(SETTING + k) else d
|
|
190
|
+
return {
|
|
191
|
+
"topotopo_path": String(val.call("topotopo_path", "")), "node_path": String(val.call("node_path", "")),
|
|
192
|
+
"live_cook": bool(val.call("live_cook", true)), "watch_interval": float(val.call("watch_interval", 1.0)),
|
|
193
|
+
"cook_timeout": float(val.call("cook_timeout", 600.0)),
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
func _on_settings_changed() -> void:
|
|
198
|
+
var es := EditorInterface.get_editor_settings()
|
|
199
|
+
if es.check_changed_settings_in_group(SETTING.trim_suffix("/")):
|
|
200
|
+
var s := editor_settings()
|
|
201
|
+
var where_changed: bool = s.topotopo_path != runner.settings.topotopo_path or s.node_path != runner.settings.node_path
|
|
202
|
+
runner.settings = s
|
|
203
|
+
if where_changed:
|
|
204
|
+
_look_again()
|
|
205
|
+
packages_changed.emit()
|
|
206
|
+
elif es.check_changed_settings_in_group(UNFOCUSED):
|
|
207
|
+
packages_changed.emit()
|
|
208
|
+
queue_flush()
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
## Look for TopoTopo again (where it is was set): check every package, and cook the stale ones once it is found.
|
|
212
|
+
func _look_again() -> void:
|
|
213
|
+
runner.reset()
|
|
214
|
+
_said_missing = false
|
|
215
|
+
check_all()
|
|
216
|
+
if runner.found() and bool(runner.settings.get("live_cook", true)) and _watcher:
|
|
217
|
+
var stale := []
|
|
218
|
+
for t in packages:
|
|
219
|
+
if is_stale(packages[t].fresh) and not packages[t].copy and not packages[t].root:
|
|
220
|
+
stale.append(t)
|
|
221
|
+
if stale.size():
|
|
222
|
+
_watcher.cook_background(stale, false)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
## Godot's own "Import Resources When Unfocused".
|
|
226
|
+
func import_when_unfocused() -> bool:
|
|
227
|
+
var es := EditorInterface.get_editor_settings()
|
|
228
|
+
return es.has_setting(UNFOCUSED) and bool(es.get_setting(UNFOCUSED))
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
func set_import_when_unfocused(on: bool) -> void:
|
|
232
|
+
EditorInterface.get_editor_settings().set_setting(UNFOCUSED, on)
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
## Set where TopoTopo is (the editor setting), then look for it again.
|
|
236
|
+
func locate(path: String) -> void:
|
|
237
|
+
EditorInterface.get_editor_settings().set_setting(SETTING + "topotopo_path", path)
|
|
238
|
+
runner.settings = editor_settings()
|
|
239
|
+
_look_again()
|
|
240
|
+
packages_changed.emit()
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
# ------------------------------------------------------------------------------------------------------- packages
|
|
244
|
+
|
|
245
|
+
func _abs(res: String) -> String:
|
|
246
|
+
return Record.res_to_abs(project, res)
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
func _res(abs_path: String) -> String:
|
|
250
|
+
return Record.abs_to_res(project, abs_path)
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
## Find the packages Godot's scan sees (a .topo outside a .gdignore folder) and drop those that are gone.
|
|
254
|
+
func scan_packages() -> void:
|
|
255
|
+
var seen := {}
|
|
256
|
+
for abs_topo in Record.find_topos(project):
|
|
257
|
+
var res := _res(abs_topo)
|
|
258
|
+
if res == "":
|
|
259
|
+
continue
|
|
260
|
+
seen[res] = true
|
|
261
|
+
if not packages.has(res):
|
|
262
|
+
packages[res] = {
|
|
263
|
+
"topo": res, "abs": abs_topo, "dir": abs_topo.get_base_dir(), "id": abs_topo.get_file().get_basename(),
|
|
264
|
+
"fresh": {"state": "never_cooked", "why": "record", "path": "", "note": "", "text": "not checked yet"},
|
|
265
|
+
"record": null, "report": null, "cooking": false, "progress": "", "error": "", "crashed": "",
|
|
266
|
+
"last_ms": -1, "last_time": "", "copy": Record.is_published_copy(abs_topo),
|
|
267
|
+
"root": abs_topo.get_base_dir() == project, "options": {},
|
|
268
|
+
}
|
|
269
|
+
for res in packages.keys():
|
|
270
|
+
if not seen.has(res):
|
|
271
|
+
packages.erase(res)
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
## The import options of a package, from its .topo.import (or `params` when given), as the record compares them.
|
|
275
|
+
func options_for(topo: String, params = null) -> Dictionary:
|
|
276
|
+
var p: Dictionary = params if typeof(params) == TYPE_DICTIONARY else Record.import_params(_abs(topo))
|
|
277
|
+
return Record.options_from_params(p, topo, project)
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
## Check a package's freshness now (and read its record); returns the freshness.
|
|
281
|
+
func check(topo: String, opts = null) -> Dictionary:
|
|
282
|
+
if not packages.has(topo):
|
|
283
|
+
scan_packages()
|
|
284
|
+
var st = packages.get(topo)
|
|
285
|
+
if st == null:
|
|
286
|
+
return {"state": "stale", "why": "record", "path": "", "note": "", "text": "%s is not a package Godot sees" % topo}
|
|
287
|
+
var o: Dictionary = opts if typeof(opts) == TYPE_DICTIONARY else options_for(topo)
|
|
288
|
+
st.options = o
|
|
289
|
+
if st.copy:
|
|
290
|
+
st.fresh = {"state": "failed", "why": "copy", "path": "", "note": "", "text": "a published copy; hide its folder with .gdignore (topotopo godot setup)"}
|
|
291
|
+
return st.fresh
|
|
292
|
+
if st.root:
|
|
293
|
+
st.fresh = {"state": "failed", "why": "root", "path": "", "note": "", "text": "a package at the project's root is not supported (its assets/ would hide the game's art): move it into a folder"}
|
|
294
|
+
return st.fresh
|
|
295
|
+
if o.has("error"):
|
|
296
|
+
st.fresh = {"state": "stale", "why": "options", "path": "", "note": "", "text": o.error}
|
|
297
|
+
return st.fresh
|
|
298
|
+
var r := Record.read_record(st.dir)
|
|
299
|
+
st.record = r.record
|
|
300
|
+
if r.error != "":
|
|
301
|
+
st.fresh = {"state": "stale", "why": "record", "path": "", "note": "", "text": r.error}
|
|
302
|
+
else:
|
|
303
|
+
st.fresh = record.freshness(st.dir, r.record, o, project, runner.version if runner.found() else "")
|
|
304
|
+
if not is_stale(st.fresh) and not st.cooking:
|
|
305
|
+
# what made the last cook fail is gone (its record is current)
|
|
306
|
+
st.error = ""
|
|
307
|
+
st.crashed = ""
|
|
308
|
+
return st.fresh
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
func check_all() -> void:
|
|
312
|
+
scan_packages()
|
|
313
|
+
for topo in packages:
|
|
314
|
+
check(topo)
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
static func is_stale(fr: Dictionary) -> bool:
|
|
318
|
+
return fr.state == "stale" or fr.state == "never_cooked"
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
## Whether the last cook of a package did not finish it and its files are the same since (it is not cooked again by
|
|
322
|
+
## itself until they change; Recook retries).
|
|
323
|
+
func failed_unchanged(topo: String) -> bool:
|
|
324
|
+
var st = packages.get(topo)
|
|
325
|
+
return st != null and st.crashed != "" and st.error != "" and _watcher != null and not headless and _watcher.source_stamp(topo) == st.crashed
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
## The report file of a package's cooks (res://.godot/topotopo/<id>-<md5 of its res path>.report.json).
|
|
329
|
+
func report_path(topo: String) -> String:
|
|
330
|
+
return project.path_join(".godot/topotopo/%s-%s.report.json" % [topo.get_file().get_basename(), topo.md5_text().substr(0, 12)])
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
## A package's job for the jobs file, with its options given explicitly.
|
|
334
|
+
func job_for(topo: String, opts = null) -> Dictionary:
|
|
335
|
+
var o: Dictionary = opts if typeof(opts) == TYPE_DICTIONARY else options_for(topo)
|
|
336
|
+
return {
|
|
337
|
+
"package": _abs(topo), "into": o.folder, "per_output_folders": o.per_output_folders, "skip": Array(o.skip),
|
|
338
|
+
"instancing": o.instancing, "report": report_path(topo), "timeout": runner.settings.cook_timeout,
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
## Start a cook of packages (one process). `blocking`: wait for it. `gated`: what it writes waits for the focus rule
|
|
343
|
+
## before it is imported (a background cook). Returns the run, or {} when nothing could start.
|
|
344
|
+
func cook(topos: Array, force := false, blocking := false, gated := true, opts := {}) -> Dictionary:
|
|
345
|
+
var jobs := []
|
|
346
|
+
var selected := []
|
|
347
|
+
for t in topos:
|
|
348
|
+
if packages.has(t) and not packages[t].copy and not packages[t].root:
|
|
349
|
+
var o: Dictionary = opts[t] if typeof(opts.get(t)) == TYPE_DICTIONARY else options_for(t)
|
|
350
|
+
if o.has("error"):
|
|
351
|
+
check(t, o)
|
|
352
|
+
packages[t].error = o.error
|
|
353
|
+
packages[t].crashed = _watcher.source_stamp(t) if _watcher and not headless else ""
|
|
354
|
+
_error("TopoTopo: %s: %s" % [t, o.error])
|
|
355
|
+
continue
|
|
356
|
+
jobs.append(job_for(t, o))
|
|
357
|
+
selected.append(t)
|
|
358
|
+
if jobs.is_empty():
|
|
359
|
+
packages_changed.emit()
|
|
360
|
+
return {}
|
|
361
|
+
var run := runner.start(jobs, force)
|
|
362
|
+
if run.has("error"):
|
|
363
|
+
for t in selected:
|
|
364
|
+
if packages.has(t):
|
|
365
|
+
packages[t].error = run.error
|
|
366
|
+
_error("TopoTopo: the cook could not start: %s" % run.error)
|
|
367
|
+
packages_changed.emit()
|
|
368
|
+
return {}
|
|
369
|
+
run.gated = gated
|
|
370
|
+
for t in selected:
|
|
371
|
+
if packages.has(t):
|
|
372
|
+
packages[t].cooking = true
|
|
373
|
+
packages[t].progress = "waiting"
|
|
374
|
+
packages[t].error = ""
|
|
375
|
+
# the package's files as this cook reads them: a cook that ends stale with the same files is not retried
|
|
376
|
+
packages[t].cook_stamp = _watcher.source_stamp(t) if _watcher and not headless else ""
|
|
377
|
+
packages_changed.emit()
|
|
378
|
+
if blocking:
|
|
379
|
+
runner.wait(run)
|
|
380
|
+
collect(run)
|
|
381
|
+
return run
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
## Wait for a package of a running cook (blocking), then take in what it did.
|
|
385
|
+
func wait_for(run: Dictionary, topo_abs: String) -> void:
|
|
386
|
+
runner.wait_package(run, topo_abs)
|
|
387
|
+
collect(run)
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
## Read the running cooks (non-blocking) and take in what finished.
|
|
391
|
+
func poll_runs() -> void:
|
|
392
|
+
for run in runner.runs.duplicate():
|
|
393
|
+
var events := runner.poll(run)
|
|
394
|
+
for ev in events:
|
|
395
|
+
var res := _res(String(ev.get("package", "")))
|
|
396
|
+
if packages.has(res) and ev.get("event") == "output":
|
|
397
|
+
var pk = run.packages.get(Runner._key(String(ev.package)))
|
|
398
|
+
if pk:
|
|
399
|
+
packages[res].progress = "cooking %s (%d of %d)" % [ev.get("output", ""), pk.finished, pk.total]
|
|
400
|
+
if events.size():
|
|
401
|
+
packages_changed.emit()
|
|
402
|
+
collect(run)
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
## Take in every package of a run that finished and was not taken in yet.
|
|
406
|
+
func collect(run: Dictionary) -> void:
|
|
407
|
+
for k in run.order:
|
|
408
|
+
var pk = run.packages[k]
|
|
409
|
+
if pk.done and not pk.get("handled", false):
|
|
410
|
+
pk.handled = true
|
|
411
|
+
_package_done(run, pk)
|
|
412
|
+
if run.exited and not run.handled:
|
|
413
|
+
run.handled = true
|
|
414
|
+
if _watcher:
|
|
415
|
+
_watcher.run_ended(run)
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
func _package_done(run: Dictionary, pk: Dictionary) -> void:
|
|
419
|
+
var topo := _res(pk.topo)
|
|
420
|
+
var st = packages.get(topo)
|
|
421
|
+
if st == null:
|
|
422
|
+
return
|
|
423
|
+
st.cooking = false
|
|
424
|
+
st.progress = ""
|
|
425
|
+
var gated := bool(run.get("gated", true))
|
|
426
|
+
var stamp: String = st.get("cook_stamp", "")
|
|
427
|
+
if pk.crash != "":
|
|
428
|
+
if run.killed == "restart":
|
|
429
|
+
return
|
|
430
|
+
st.error = pk.crash
|
|
431
|
+
# not tried again until the package's files change (they may have changed while it cooked)
|
|
432
|
+
st.crashed = stamp if stamp != "" else "crashed"
|
|
433
|
+
_error("TopoTopo: %s: %s" % [st.id, pk.crash])
|
|
434
|
+
toast("TopoTopo: %s did not cook: %s" % [st.id, pk.crash.get_slice("\n", 0)], EditorToaster.SEVERITY_ERROR)
|
|
435
|
+
check(topo)
|
|
436
|
+
_refresh[topo] = {"gated": gated, "written": false}
|
|
437
|
+
packages_changed.emit()
|
|
438
|
+
queue_flush()
|
|
439
|
+
return
|
|
440
|
+
var rep: Dictionary = pk.result
|
|
441
|
+
st.report = rep
|
|
442
|
+
st.error = ""
|
|
443
|
+
st.crashed = ""
|
|
444
|
+
st.last_ms = int(rep.get("ms", 0))
|
|
445
|
+
st.last_time = Time.get_datetime_string_from_system(false, true)
|
|
446
|
+
var written := []
|
|
447
|
+
for o in rep.get("outputs", []):
|
|
448
|
+
for f in o.get("written", []):
|
|
449
|
+
_pending[f] = gated
|
|
450
|
+
if not o.get("written", []).is_empty():
|
|
451
|
+
written.append(o.id)
|
|
452
|
+
for e in rep.get("errors", []):
|
|
453
|
+
_error("TopoTopo: %s: %s" % [st.id, e])
|
|
454
|
+
check(topo)
|
|
455
|
+
if is_stale(st.fresh):
|
|
456
|
+
# the package did not open, or its files changed while it cooked: say why. Files changed meanwhile cook again
|
|
457
|
+
# (run_ended); the same files are not cooked again by themselves when the package did not open, nor after a second
|
|
458
|
+
# cook that left its record stale (TopoTopo and this addon would disagree on them).
|
|
459
|
+
st.error = String(rep.errors[0]) if rep.get("errors", []).size() else st.fresh.text
|
|
460
|
+
var same: bool = stamp != "" and _watcher != null and _watcher.source_stamp(topo) == stamp
|
|
461
|
+
if same and (rep.get("record") == "none" or int(st.get("retries", 0)) >= 1):
|
|
462
|
+
st.crashed = stamp
|
|
463
|
+
st.retries = 0
|
|
464
|
+
else:
|
|
465
|
+
st.retries = int(st.get("retries", 0)) + 1 if same else 0
|
|
466
|
+
else:
|
|
467
|
+
st.retries = 0
|
|
468
|
+
_refresh[topo] = {"gated": gated, "written": rep.get("record") == "written" or written.size() > 0}
|
|
469
|
+
if rep.get("ok", false) and written.size():
|
|
470
|
+
toast("TopoTopo: %s updated: %s" % [st.id, ", ".join(written)], EditorToaster.SEVERITY_INFO)
|
|
471
|
+
elif not rep.get("ok", false) and rep.get("errors", []).size():
|
|
472
|
+
toast("TopoTopo: %s did not cook: %s" % [st.id, String(rep.errors[0])], EditorToaster.SEVERITY_ERROR)
|
|
473
|
+
packages_changed.emit()
|
|
474
|
+
queue_flush()
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
# --------------------------------------------------------------------------------------------- importing outputs
|
|
478
|
+
|
|
479
|
+
func _on_reimporting(paths: PackedStringArray) -> void:
|
|
480
|
+
_batch_depth += 1
|
|
481
|
+
if _batch_depth != 1:
|
|
482
|
+
if not headless and not EditorInterface.get_open_scene_roots().is_empty():
|
|
483
|
+
for f in _batch:
|
|
484
|
+
if f.get_extension() == "glb" and package_of_file(f) != "":
|
|
485
|
+
_nested_scenes[f] = true
|
|
486
|
+
return
|
|
487
|
+
_batch = paths
|
|
488
|
+
# one cook process for every stale package of the batch; each .topo's _import waits for its package
|
|
489
|
+
var stale := []
|
|
490
|
+
var opts := {}
|
|
491
|
+
for p in paths:
|
|
492
|
+
if p.get_extension() != "topo":
|
|
493
|
+
continue
|
|
494
|
+
if not packages.has(p):
|
|
495
|
+
scan_packages()
|
|
496
|
+
if not packages.has(p) or not runner.found() or not runner.run_with(_abs(p)).is_empty():
|
|
497
|
+
continue
|
|
498
|
+
var o := options_for(p)
|
|
499
|
+
var fr := check(p, o)
|
|
500
|
+
if is_stale(fr) and (fr.why == "options" or not failed_unchanged(p)):
|
|
501
|
+
stale.append(p)
|
|
502
|
+
opts[p] = o
|
|
503
|
+
if stale.size():
|
|
504
|
+
cook(stale, false, false, false, opts)
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
func _on_reimported(_paths: PackedStringArray) -> void:
|
|
508
|
+
_batch_depth = maxi(0, _batch_depth - 1)
|
|
509
|
+
if _batch_depth == 0:
|
|
510
|
+
for f in _nested_scenes:
|
|
511
|
+
var md5 := FileAccess.get_md5(f)
|
|
512
|
+
if md5 != "" and _scene_retry_md5.get(f, "") != md5:
|
|
513
|
+
_scene_retry_md5[f] = md5
|
|
514
|
+
_force_reimport[f] = true
|
|
515
|
+
_pending[f] = true
|
|
516
|
+
_nested_scenes.clear()
|
|
517
|
+
_batch = PackedStringArray()
|
|
518
|
+
queue_flush()
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
## The current import batch (the outermost resources_reimporting), empty outside one.
|
|
522
|
+
func batch() -> PackedStringArray:
|
|
523
|
+
return _batch
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
## A .topo was imported with the record as it is now.
|
|
527
|
+
func imported(topo: String) -> void:
|
|
528
|
+
var st = packages.get(topo)
|
|
529
|
+
if st:
|
|
530
|
+
_imported[topo] = {"record": FileAccess.get_md5(st.dir.path_join(Record.RECORD)), "state": st.fresh.state}
|
|
531
|
+
_refresh.erase(topo)
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
## Whether a .topo's import is behind its package: valid while the package is not ok (or the other way round), or made
|
|
535
|
+
## from another record or state than now. When this session has not imported it, a record a cook rewrote (`written`)
|
|
536
|
+
## counts as behind.
|
|
537
|
+
func topo_behind(topo: String, written: bool) -> bool:
|
|
538
|
+
var st = packages.get(topo)
|
|
539
|
+
if st == null or not FileAccess.file_exists(st.abs):
|
|
540
|
+
return false
|
|
541
|
+
if topo_import_valid(topo) != (st.fresh.state == "ok"):
|
|
542
|
+
return true
|
|
543
|
+
var seen = _imported.get(topo)
|
|
544
|
+
if seen != null:
|
|
545
|
+
return seen.record != FileAccess.get_md5(st.dir.path_join(Record.RECORD)) or seen.state != st.fresh.state
|
|
546
|
+
return written
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
## Import a .topo again once nothing else imports (and the focus rule allows it), if its import is behind.
|
|
550
|
+
func refresh_later(topo: String, written := false) -> void:
|
|
551
|
+
_refresh[topo] = {"gated": not headless, "written": written}
|
|
552
|
+
queue_flush()
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
func queue_flush() -> void:
|
|
556
|
+
if _flush_queued:
|
|
557
|
+
return
|
|
558
|
+
_flush_queued = true
|
|
559
|
+
_flush_deferred.call_deferred()
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
func _flush_deferred() -> void:
|
|
563
|
+
_flush_queued = false
|
|
564
|
+
flush()
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
## Whether imports may run now: Godot has focus, or its "Import Resources When Unfocused" is on (always headless).
|
|
568
|
+
func focus_allows() -> bool:
|
|
569
|
+
if headless:
|
|
570
|
+
return true
|
|
571
|
+
if import_when_unfocused():
|
|
572
|
+
return true
|
|
573
|
+
var w := EditorInterface.get_base_control().get_window()
|
|
574
|
+
return w != null and w.has_focus()
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
## Whether a file's import is missing or older than its bytes: "new", "changed" or "".
|
|
578
|
+
func needs_import(file: String) -> String:
|
|
579
|
+
if not FileAccess.file_exists(_abs(file) + ".import"):
|
|
580
|
+
return "new"
|
|
581
|
+
var md5 := ConfigFile.new()
|
|
582
|
+
if md5.load("res://.godot/imported/%s-%s.md5" % [file.get_file(), file.md5_text()]) != OK:
|
|
583
|
+
return "changed"
|
|
584
|
+
return "" if String(md5.get_value("", "source_md5", "")) == FileAccess.get_md5(file) else "changed"
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
## Import what cooks wrote, once nothing else imports: new files first, then changed ones, then the .topo files whose
|
|
588
|
+
## status resource is behind their record. Files Godot imported itself meanwhile are left alone. A file in a folder
|
|
589
|
+
## Godot's file system does not hold yet is found by a scan (Godot's update_file cannot add folders).
|
|
590
|
+
func flush() -> void:
|
|
591
|
+
# Import progress can run editor frames and callbacks before reimport_files returns.
|
|
592
|
+
if _flushing:
|
|
593
|
+
return
|
|
594
|
+
_flushing = true
|
|
595
|
+
_flush()
|
|
596
|
+
_flushing = false
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
func _flush() -> void:
|
|
600
|
+
if _pending.is_empty() and _refresh.is_empty():
|
|
601
|
+
return
|
|
602
|
+
var efs := EditorInterface.get_resource_filesystem()
|
|
603
|
+
if _batch_depth > 0 or efs.is_scanning() or efs.is_importing():
|
|
604
|
+
return
|
|
605
|
+
var allowed := focus_allows()
|
|
606
|
+
var fresh_files := PackedStringArray()
|
|
607
|
+
var changed := PackedStringArray()
|
|
608
|
+
var unknown := {}
|
|
609
|
+
for f in _pending.keys():
|
|
610
|
+
var gated: bool = _pending[f]
|
|
611
|
+
if gated and not allowed:
|
|
612
|
+
continue
|
|
613
|
+
_pending.erase(f)
|
|
614
|
+
var force := _force_reimport.has(f)
|
|
615
|
+
_force_reimport.erase(f)
|
|
616
|
+
if not FileAccess.file_exists(_abs(f)):
|
|
617
|
+
continue
|
|
618
|
+
var need := needs_import(f)
|
|
619
|
+
if need == "" and not force:
|
|
620
|
+
continue
|
|
621
|
+
if not _efs_knows(f):
|
|
622
|
+
efs.update_file(f)
|
|
623
|
+
if not _efs_knows(f):
|
|
624
|
+
unknown[f] = gated
|
|
625
|
+
elif need == "new":
|
|
626
|
+
fresh_files.append(f)
|
|
627
|
+
else:
|
|
628
|
+
changed.append(f)
|
|
629
|
+
var topos := PackedStringArray()
|
|
630
|
+
for t in _refresh.keys():
|
|
631
|
+
var r: Dictionary = _refresh[t]
|
|
632
|
+
if r.gated and not allowed:
|
|
633
|
+
continue
|
|
634
|
+
_refresh.erase(t)
|
|
635
|
+
if packages.has(t) and not packages[t].cooking:
|
|
636
|
+
check(t)
|
|
637
|
+
if topo_behind(t, r.written):
|
|
638
|
+
topos.append(t)
|
|
639
|
+
if fresh_files.size():
|
|
640
|
+
efs.reimport_files(fresh_files)
|
|
641
|
+
if changed.size():
|
|
642
|
+
efs.reimport_files(changed)
|
|
643
|
+
if unknown.size():
|
|
644
|
+
if headless:
|
|
645
|
+
_scan_now()
|
|
646
|
+
else:
|
|
647
|
+
# Godot's scan imports them; what it misses is imported on a later flush (three tries)
|
|
648
|
+
for f in unknown:
|
|
649
|
+
_tries[f] = int(_tries.get(f, 0)) + 1
|
|
650
|
+
if _tries[f] <= 3:
|
|
651
|
+
_pending[f] = unknown[f]
|
|
652
|
+
else:
|
|
653
|
+
_tries.erase(f)
|
|
654
|
+
_warning("TopoTopo: %s was cooked but Godot's file system does not show it: rescan (FileSystem dock > Rescan)" % f)
|
|
655
|
+
efs.scan_sources()
|
|
656
|
+
if topos.size():
|
|
657
|
+
if efs.is_scanning() or efs.is_importing():
|
|
658
|
+
for t in topos:
|
|
659
|
+
_refresh[t] = {"gated": false, "written": true}
|
|
660
|
+
else:
|
|
661
|
+
efs.reimport_files(topos)
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
func _efs_knows(file: String) -> bool:
|
|
665
|
+
var dir := EditorInterface.get_resource_filesystem().get_filesystem_path(file.get_base_dir())
|
|
666
|
+
return dir != null and dir.find_file_index(file.get_file()) >= 0
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
## Headless only: scan the project now and finish the scan on this thread, so that files the startup cook wrote in new
|
|
670
|
+
## folders are imported before --import quits (Godot's first scan took the folders before plugins loaded, and
|
|
671
|
+
## --import ends the frame after it).
|
|
672
|
+
func _scan_now() -> void:
|
|
673
|
+
var efs := EditorInterface.get_resource_filesystem()
|
|
674
|
+
efs.scan()
|
|
675
|
+
var t0 := Time.get_ticks_msec()
|
|
676
|
+
while efs.is_scanning() and Time.get_ticks_msec() - t0 < 600000:
|
|
677
|
+
OS.delay_msec(5)
|
|
678
|
+
efs.notification(Node.NOTIFICATION_PROCESS)
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
## Whether Godot holds a valid import of a .topo.
|
|
682
|
+
func topo_import_valid(topo: String) -> bool:
|
|
683
|
+
var efs := EditorInterface.get_resource_filesystem()
|
|
684
|
+
var dir := efs.get_filesystem_path(topo.get_base_dir())
|
|
685
|
+
if dir == null:
|
|
686
|
+
return false
|
|
687
|
+
var i := dir.find_file_index(topo.get_file())
|
|
688
|
+
return i >= 0 and dir.get_file_import_is_valid(i)
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
func _on_filesystem_changed() -> void:
|
|
692
|
+
if not first_scan_done and not EditorInterface.get_resource_filesystem().is_scanning():
|
|
693
|
+
_after_first_scan()
|
|
694
|
+
else:
|
|
695
|
+
scan_packages()
|
|
696
|
+
packages_changed.emit()
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
## After the first scan: a .topo whose import is invalid but whose record is current now is imported again.
|
|
700
|
+
func _after_first_scan() -> void:
|
|
701
|
+
if first_scan_done:
|
|
702
|
+
return
|
|
703
|
+
first_scan_done = true
|
|
704
|
+
scan_packages()
|
|
705
|
+
for topo in packages:
|
|
706
|
+
var st = packages[topo]
|
|
707
|
+
if st.copy or st.root or st.cooking:
|
|
708
|
+
continue
|
|
709
|
+
check(topo)
|
|
710
|
+
if topo_behind(topo, false):
|
|
711
|
+
_refresh[topo] = {"gated": false, "written": false}
|
|
712
|
+
packages_changed.emit()
|
|
713
|
+
queue_flush()
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
# --------------------------------------------------------------------------------------------------------- startup
|
|
717
|
+
|
|
718
|
+
## Editor start: every record is checked. Headless (--import, --export-*): stale packages cook now, in one process,
|
|
719
|
+
## so the first scan imports their new files. With a window: they cook in the background (watcher.gd).
|
|
720
|
+
func _startup() -> void:
|
|
721
|
+
scan_packages()
|
|
722
|
+
var stale := []
|
|
723
|
+
for topo in packages:
|
|
724
|
+
var st = packages[topo]
|
|
725
|
+
if st.copy:
|
|
726
|
+
_error("TopoTopo: %s is a published copy; hide its folder with .gdignore (topotopo godot setup %s)" % [topo, project])
|
|
727
|
+
continue
|
|
728
|
+
if st.root:
|
|
729
|
+
_error("TopoTopo: %s: a package at the project's root is not supported (its assets/ would hide the game's art): move it into a folder" % topo)
|
|
730
|
+
continue
|
|
731
|
+
if is_stale(check(topo)):
|
|
732
|
+
stale.append(topo)
|
|
733
|
+
if stale.size() and not runner.found():
|
|
734
|
+
for topo in stale:
|
|
735
|
+
_warning("TopoTopo: %s: %s; TopoTopo is not set up here (%s), so the committed outputs are used" % [topo, packages[topo].fresh.text, runner.problem])
|
|
736
|
+
# after the first scan, their .topo imports say it too (Godot's red ImportFail icon)
|
|
737
|
+
say_missing_once()
|
|
738
|
+
elif stale.size():
|
|
739
|
+
if headless:
|
|
740
|
+
print("TopoTopo: cooking %d stale package%s before the first scan: %s" % [stale.size(), "" if stale.size() == 1 else "s", ", ".join(stale)])
|
|
741
|
+
cook(stale, false, true, false)
|
|
742
|
+
elif bool(runner.settings.get("live_cook", true)):
|
|
743
|
+
var newer := stale.filter(func(t): return packages[t].fresh.why == "version")
|
|
744
|
+
if newer.size():
|
|
745
|
+
toast("TopoTopo %s is newer than the one that cooked %d package%s: cooking %s again" % [runner.version, newer.size(), "" if newer.size() == 1 else "s", "it" if newer.size() == 1 else "them"], EditorToaster.SEVERITY_INFO)
|
|
746
|
+
_watcher.cook_background(stale, false)
|
|
747
|
+
if not headless:
|
|
748
|
+
_watcher.rebaseline()
|
|
749
|
+
_maybe_scanned.call_deferred()
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
func _maybe_scanned() -> void:
|
|
753
|
+
var efs := EditorInterface.get_resource_filesystem()
|
|
754
|
+
if not first_scan_done and not efs.is_scanning() and not efs.is_importing() and efs.get_filesystem().get_subdir_count() + efs.get_filesystem().get_file_count() > 0:
|
|
755
|
+
_after_first_scan()
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
# ------------------------------------------------------------------------------------------------------- commands
|
|
759
|
+
|
|
760
|
+
## Cook the stale packages now (in the background). `force`: every package, ignoring records and the cache.
|
|
761
|
+
func cook_now(topos: Array, force: bool) -> void:
|
|
762
|
+
if not runner.found():
|
|
763
|
+
toast("TopoTopo is not set up: %s" % runner.problem, EditorToaster.SEVERITY_ERROR)
|
|
764
|
+
return
|
|
765
|
+
var list := []
|
|
766
|
+
for t in topos:
|
|
767
|
+
var st = packages.get(t)
|
|
768
|
+
if st == null or st.copy or st.root:
|
|
769
|
+
continue
|
|
770
|
+
if force or is_stale(check(t)):
|
|
771
|
+
list.append(t)
|
|
772
|
+
if list.is_empty():
|
|
773
|
+
toast("TopoTopo: every package is current", EditorToaster.SEVERITY_INFO)
|
|
774
|
+
return
|
|
775
|
+
_watcher.cook_background(list, force)
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
func _on_menu(id: int) -> void:
|
|
779
|
+
check_all()
|
|
780
|
+
match id:
|
|
781
|
+
0:
|
|
782
|
+
cook_now(packages.keys(), false)
|
|
783
|
+
1:
|
|
784
|
+
cook_now(packages.keys(), true)
|
|
785
|
+
2:
|
|
786
|
+
show_panel()
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
func show_panel() -> void:
|
|
790
|
+
if _dock and _dock.has_method("make_visible"):
|
|
791
|
+
_dock.make_visible()
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
## The package a file belongs to: its .topo, or the .topo whose record lists it as an output or orphan ("" for none).
|
|
795
|
+
func package_of_file(path: String) -> String:
|
|
796
|
+
if path.get_extension() == "topo" and packages.has(path):
|
|
797
|
+
return path
|
|
798
|
+
for topo in packages:
|
|
799
|
+
var rec = packages[topo].record
|
|
800
|
+
if rec == null:
|
|
801
|
+
continue
|
|
802
|
+
if Record.output_files(rec).has(path) or (typeof(rec.get("orphans")) == TYPE_DICTIONARY and rec.orphans.has(path)):
|
|
803
|
+
return topo
|
|
804
|
+
return ""
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
## Open TopoTopo's live viewer on a package in the browser (one viewer per package for the session).
|
|
808
|
+
func open_in_topotopo(topo: String) -> void:
|
|
809
|
+
var st = packages.get(topo)
|
|
810
|
+
if st == null:
|
|
811
|
+
return
|
|
812
|
+
if not runner.found():
|
|
813
|
+
toast("TopoTopo is not set up: %s" % runner.problem, EditorToaster.SEVERITY_ERROR)
|
|
814
|
+
return
|
|
815
|
+
var v = _viewers.get(st.dir)
|
|
816
|
+
if v and OS.is_process_running(v.pid):
|
|
817
|
+
if v.url != "":
|
|
818
|
+
OS.shell_open(v.url)
|
|
819
|
+
else:
|
|
820
|
+
v.wanted = true
|
|
821
|
+
return
|
|
822
|
+
var p := OS.execute_with_pipe(runner.node, PackedStringArray([Runner.arg_path(runner.cli), "edit", Runner.arg_path(st.dir), "--json"]), false)
|
|
823
|
+
if p.is_empty():
|
|
824
|
+
toast("TopoTopo: the viewer could not start", EditorToaster.SEVERITY_ERROR)
|
|
825
|
+
return
|
|
826
|
+
_viewers[st.dir] = {"pid": p.pid, "stdio": p.stdio, "stderr": p.stderr, "buf": PackedByteArray(), "url": "", "wanted": true, "id": st.id}
|
|
827
|
+
print("TopoTopo: starting the viewer on %s…" % st.id)
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
## Read the viewers' first line ({"url"}) and open it once it is there.
|
|
831
|
+
func poll_viewers() -> void:
|
|
832
|
+
for dir in _viewers.keys():
|
|
833
|
+
var v = _viewers[dir]
|
|
834
|
+
var a: PackedByteArray = v.stdio.get_buffer(4096)
|
|
835
|
+
v.stderr.get_buffer(65536)
|
|
836
|
+
if a.size():
|
|
837
|
+
var buf: PackedByteArray = v.buf
|
|
838
|
+
buf.append_array(a)
|
|
839
|
+
v.buf = buf
|
|
840
|
+
var i := buf.find(10)
|
|
841
|
+
if i >= 0 and v.url == "":
|
|
842
|
+
var line = JSON.parse_string(buf.slice(0, i).get_string_from_ascii())
|
|
843
|
+
if typeof(line) == TYPE_DICTIONARY and line.has("url"):
|
|
844
|
+
v.url = String(line.url)
|
|
845
|
+
print("TopoTopo: the viewer on %s is at %s" % [v.id, v.url])
|
|
846
|
+
if v.url != "" and v.wanted:
|
|
847
|
+
v.wanted = false
|
|
848
|
+
OS.shell_open(v.url)
|
|
849
|
+
if not OS.is_process_running(v.pid):
|
|
850
|
+
if v.url == "":
|
|
851
|
+
toast("TopoTopo: the viewer on %s stopped before it opened" % v.id, EditorToaster.SEVERITY_ERROR)
|
|
852
|
+
_viewers.erase(dir)
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
## Remove the files a package's outputs no longer write (its orphans), with Godot's files beside them: their .import and
|
|
856
|
+
## .uid, the textures Godot extracted from an orphan GLB (<name>_<image>.png beside it), and the folder when that
|
|
857
|
+
## leaves it empty.
|
|
858
|
+
func remove_orphans(topo: String) -> void:
|
|
859
|
+
var st = packages.get(topo)
|
|
860
|
+
if st == null or st.record == null:
|
|
861
|
+
return
|
|
862
|
+
var orphans = st.record.get("orphans", {})
|
|
863
|
+
var current := Record.output_files(st.record)
|
|
864
|
+
var removed := []
|
|
865
|
+
for f in orphans:
|
|
866
|
+
if current.has(f):
|
|
867
|
+
continue
|
|
868
|
+
var a := _abs(f)
|
|
869
|
+
var files := [a]
|
|
870
|
+
if f.get_extension().to_lower() == "glb":
|
|
871
|
+
var prefix := a.get_file().get_basename() + "_"
|
|
872
|
+
# Only textures the imported scene actually uses. A matching filename alone does not make an image ours.
|
|
873
|
+
for dependency in ResourceLoader.get_dependencies(f):
|
|
874
|
+
var texture := dependency.get_slice("::", dependency.get_slice_count("::") - 1)
|
|
875
|
+
if texture.begins_with("res://") and texture.get_base_dir() == f.get_base_dir() and texture.get_file().begins_with(prefix) \
|
|
876
|
+
and ["png", "jpg", "jpeg", "webp"].has(texture.get_extension().to_lower()) and not current.has(texture):
|
|
877
|
+
files.append(_abs(texture))
|
|
878
|
+
for file in files:
|
|
879
|
+
for side in ["", ".import", ".uid"]:
|
|
880
|
+
if FileAccess.file_exists(file + side):
|
|
881
|
+
DirAccess.remove_absolute(file + side)
|
|
882
|
+
removed.append(f)
|
|
883
|
+
if DirAccess.get_files_at(a.get_base_dir()).is_empty() and DirAccess.get_directories_at(a.get_base_dir()).is_empty():
|
|
884
|
+
DirAccess.remove_absolute(a.get_base_dir())
|
|
885
|
+
if removed.size():
|
|
886
|
+
print("TopoTopo: %s: removed %s" % [st.id, ", ".join(removed)])
|
|
887
|
+
EditorInterface.get_resource_filesystem().scan()
|
|
888
|
+
# the record lists them until the next cook, which leaves out orphans that are gone: cook it now (its outputs
|
|
889
|
+
# are carried over when current)
|
|
890
|
+
if runner.found() and _watcher:
|
|
891
|
+
_watcher.cook_background([topo], false)
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
## Print a package's last report to Output.
|
|
895
|
+
func show_report(topo: String) -> void:
|
|
896
|
+
var st = packages.get(topo)
|
|
897
|
+
if st == null:
|
|
898
|
+
return
|
|
899
|
+
var rep = st.report if st.report != null else Runner._read_report(report_path(topo))
|
|
900
|
+
print("TopoTopo: %s (%s): %s" % [st.id, topo, st.fresh.text])
|
|
901
|
+
if rep == null:
|
|
902
|
+
print(" no cook report in this project yet (%s)" % report_path(topo))
|
|
903
|
+
else:
|
|
904
|
+
print(" last cook: %s, %d ms, record %s" % ["ok" if rep.get("ok") else "failed", int(rep.get("ms", 0)), rep.get("record", "")])
|
|
905
|
+
for o in rep.get("outputs", []):
|
|
906
|
+
print(" %s (%s): %s%s" % [o.id, o.get("kind", ""), o.state, (" → " + ", ".join(o.files)) if o.get("files", []).size() else ""])
|
|
907
|
+
for e in o.get("errors", []):
|
|
908
|
+
print(" %s%s%s" % ["[%s] " % e.node if e.node != "" else "", e.message, " (hint: %s)" % e.hint if e.hint != "" else ""])
|
|
909
|
+
for w in o.get("warnings", []):
|
|
910
|
+
print(" warning: %s" % w)
|
|
911
|
+
for f in rep.get("orphans", []):
|
|
912
|
+
print(" orphan (kept, no longer cooked): %s" % f)
|
|
913
|
+
for e in rep.get("errors", []):
|
|
914
|
+
print(" error: %s" % e)
|
|
915
|
+
show_panel()
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
## Every package an export would ship stale, failed or never cooked: a line each for the export log.
|
|
919
|
+
func export_problems() -> PackedStringArray:
|
|
920
|
+
check_all()
|
|
921
|
+
var out := PackedStringArray()
|
|
922
|
+
for topo in packages:
|
|
923
|
+
var st = packages[topo]
|
|
924
|
+
if st.fresh.state != "ok":
|
|
925
|
+
out.append("%s: %s%s" % [st.id, st.fresh.state.replace("_", " "), (": " + st.fresh.text) if st.fresh.text != "" else ""])
|
|
926
|
+
return out
|
|
927
|
+
|
|
928
|
+
|
|
929
|
+
## The message of a stale package when TopoTopo is not set up here.
|
|
930
|
+
func not_set_up_text(topo: String, fr: Dictionary) -> String:
|
|
931
|
+
var st = packages.get(topo, {})
|
|
932
|
+
var cooked: String = String(st.record.get("topotopo", "")) if st.get("record") != null else ""
|
|
933
|
+
var what := ("%s has never been cooked" % topo.get_file()) if fr.state == "never_cooked" else ("%s: %s" % [topo.get_file(), fr.text])
|
|
934
|
+
return "TopoTopo: %s and TopoTopo is not set up here (%s); %s. Set Editor Settings > FileSystem > Import > TopoTopo, or run topotopo godot setup %s." % [
|
|
935
|
+
what, runner.problem, ("the committed outputs (cooked with %s) are still used" % cooked) if cooked != "" else "nothing can be imported until it is cooked", project]
|
|
936
|
+
|
|
937
|
+
|
|
938
|
+
## Once per session: a warning toast that TopoTopo is not set up, with the panel's Locate button.
|
|
939
|
+
func say_missing_once() -> void:
|
|
940
|
+
if _said_missing:
|
|
941
|
+
return
|
|
942
|
+
_said_missing = true
|
|
943
|
+
toast("TopoTopo is not set up here: stale packages keep their committed outputs (Locate TopoTopo… in the TopoTopo panel)", EditorToaster.SEVERITY_WARNING)
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
func say_skipped_once(topo: String, rec) -> void:
|
|
947
|
+
if _said_skipped.has(topo) or typeof(rec) != TYPE_DICTIONARY:
|
|
948
|
+
return
|
|
949
|
+
_said_skipped[topo] = true
|
|
950
|
+
var skipped = rec.get("skipped", {})
|
|
951
|
+
for id in Record._sorted_keys(skipped):
|
|
952
|
+
var why := String(skipped[id].get("why", "")) if typeof(skipped[id]) == TYPE_DICTIONARY else ""
|
|
953
|
+
if why != "":
|
|
954
|
+
print("TopoTopo: %s > %s: not imported: %s" % [topo.get_file().get_basename(), id, why])
|
|
955
|
+
|
|
956
|
+
|
|
957
|
+
func toast(message: String, severity: int) -> void:
|
|
958
|
+
if headless:
|
|
959
|
+
return
|
|
960
|
+
var t := EditorInterface.get_editor_toaster()
|
|
961
|
+
if t:
|
|
962
|
+
t.push_toast(message, severity)
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
func _error(message: String) -> void:
|
|
966
|
+
push_error(message)
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
func _warning(message: String) -> void:
|
|
970
|
+
push_warning(message)
|