gdharness 1.3.0 → 1.3.1
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/build/cli.js +14 -13
- package/build/godot/addons/gdharness_editor/animation_reads.gd +7 -19
- package/build/godot/addons/gdharness_editor/bridge_client.gd +8 -8
- package/build/godot/addons/gdharness_editor/file_reads.gd +60 -25
- package/build/godot/addons/gdharness_editor/headless_check.gd +7 -7
- package/build/godot/addons/gdharness_editor/plugin.gd +6 -6
- package/build/godot/addons/gdharness_editor/property_values.gd +120 -53
- package/build/godot/addons/gdharness_editor/reading.gd +28 -0
- package/build/godot/addons/gdharness_editor/scene_file.gd +28 -23
- package/build/godot/addons/gdharness_editor/serialisation.gd +45 -94
- package/build/godot/addons/gdharness_editor/tool_executor.gd +24 -24
- package/build/godot/addons/gdharness_editor/tools/animation_tools.gd +52 -41
- package/build/godot/addons/gdharness_editor/tools/filesystem_tools.gd +4 -4
- package/build/godot/addons/gdharness_editor/tools/play_tools.gd +2 -2
- package/build/godot/addons/gdharness_editor/tools/profile_tools.gd +14 -14
- package/build/godot/addons/gdharness_editor/tools/resource_tools.gd +48 -41
- package/build/godot/addons/gdharness_editor/tools/scene_kin.gd +17 -17
- package/build/godot/addons/gdharness_editor/tools/scene_paths.gd +14 -12
- package/build/godot/addons/gdharness_editor/tools/scene_placing.gd +7 -7
- package/build/godot/addons/gdharness_editor/tools/scene_tools.gd +81 -77
- package/build/godot/addons/gdharness_editor/tools/settings_tools.gd +4 -4
- package/build/godot/addons/gdharness_editor/value_shapes.gd +111 -0
- package/build/godot/addons/gdharness_editor/value_shapes.gd.uid +1 -0
- package/build/godot/addons/gdharness_runtime/reading.gd +28 -0
- package/build/godot/addons/gdharness_runtime/runtime_accessibility.gd +18 -18
- package/build/godot/addons/gdharness_runtime/runtime_autoload.gd +29 -29
- package/build/godot/addons/gdharness_runtime/runtime_capture.gd +21 -18
- package/build/godot/addons/gdharness_runtime/runtime_changes.gd +86 -80
- package/build/godot/addons/gdharness_runtime/runtime_input.gd +65 -64
- package/build/godot/addons/gdharness_runtime/runtime_items.gd +6 -6
- package/build/godot/addons/gdharness_runtime/runtime_menus.gd +8 -8
- package/build/godot/addons/gdharness_runtime/runtime_mouse.gd +6 -6
- package/build/godot/addons/gdharness_runtime/runtime_pad.gd +10 -10
- package/build/godot/addons/gdharness_runtime/runtime_paths.gd +7 -7
- package/build/godot/addons/gdharness_runtime/runtime_queries.gd +41 -41
- package/build/godot/addons/gdharness_runtime/runtime_says.gd +3 -3
- package/build/godot/addons/gdharness_runtime/runtime_targets.gd +33 -33
- package/build/godot/addons/gdharness_runtime/runtime_typing.gd +20 -20
- package/build/godot/addons/gdharness_runtime/runtime_values.gd +25 -24
- package/build/godot/addons/gdharness_runtime/runtime_waits.gd +56 -50
- package/build/godot/addons/gdharness_runtime/serialisation.gd +45 -94
- package/build/godot/addons/gdharness_runtime/value_shapes.gd +111 -0
- package/build/godot/addons/gdharness_runtime/value_shapes.gd.uid +1 -0
- package/build/godot/operations/animation_reads.gd +7 -19
- package/build/godot/operations/audio_buses.gd +10 -10
- package/build/godot/operations/class_cache.gd +16 -16
- package/build/godot/operations/classdb_queries.gd +12 -12
- package/build/godot/operations/dependencies.gd +33 -29
- package/build/godot/operations/editor_tools.gd +12 -12
- package/build/godot/operations/export_presets.gd +10 -8
- package/build/godot/operations/file_reads.gd +60 -25
- package/build/godot/operations/gdscript_analysis.gd +20 -20
- package/build/godot/operations/gdscript_authoring.gd +17 -15
- package/build/godot/operations/godot_operations.gd +64 -63
- package/build/godot/operations/import_pipeline.gd +20 -20
- package/build/godot/operations/input_actions.gd +17 -17
- package/build/godot/operations/logger.gd +1 -1
- package/build/godot/operations/plugins.gd +8 -8
- package/build/godot/operations/project_config.gd +24 -17
- package/build/godot/operations/project_diagnostics.gd +9 -9
- package/build/godot/operations/property_values.gd +120 -53
- package/build/godot/operations/reading.gd +28 -0
- package/build/godot/operations/rename_checks.gd +3 -3
- package/build/godot/operations/resource_files.gd +5 -5
- package/build/godot/operations/script_check.gd +7 -7
- package/build/godot/operations/serialisation.gd +45 -94
- package/build/godot/operations/value_shapes.gd +111 -0
- package/package.json +1 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
extends RefCounted
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
const GdhRead = preload("reading.gd")
|
|
4
|
+
const GdhLog = preload("logger.gd")
|
|
5
|
+
const GdhPatterns = preload("patterns.gd")
|
|
6
6
|
|
|
7
7
|
const MODIFICATION_TYPES: Array[String] = ["add_constant", "add_variable", "add_signal", "add_function"]
|
|
8
8
|
const BLANKS_AROUND_FUNCTIONS: int = 2
|
|
9
9
|
|
|
10
|
-
var _log:
|
|
10
|
+
var _log: GdhLog
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
func _init(p_log:
|
|
13
|
+
func _init(p_log: GdhLog) -> void:
|
|
14
14
|
_log = p_log
|
|
15
15
|
|
|
16
16
|
|
|
@@ -231,14 +231,14 @@ static func _modification_problems(modifications: Array, declared: Dictionary) -
|
|
|
231
231
|
# one: variables, constants, signals, functions, enums and inner classes, which share one namespace.
|
|
232
232
|
static func _declared(lines: Array[String]) -> Dictionary:
|
|
233
233
|
var found: Dictionary = {}
|
|
234
|
-
var declaration: RegEx =
|
|
234
|
+
var declaration: RegEx = GdhPatterns.compiled(
|
|
235
235
|
"^(?:static\\s+)?(var|const|signal|func|enum|class)\\s+([A-Za-z_][A-Za-z0-9_]*)"
|
|
236
236
|
)
|
|
237
237
|
for i: int in range(lines.size()):
|
|
238
238
|
var raw: String = lines[i]
|
|
239
239
|
if raw.is_empty() or raw[0] == "\t" or raw[0] == " ":
|
|
240
240
|
continue
|
|
241
|
-
var matched: RegExMatch = declaration.search(
|
|
241
|
+
var matched: RegExMatch = declaration.search(GdhPatterns.without_annotations(raw))
|
|
242
242
|
if matched != null and not found.has(matched.get_string(2)):
|
|
243
243
|
found[matched.get_string(2)] = {"kind": matched.get_string(1), "line": i + 1}
|
|
244
244
|
return found
|
|
@@ -286,7 +286,7 @@ func _add_constant(lines: Array[String], mod: Dictionary, placed: Array[Dictiona
|
|
|
286
286
|
var const_line: String = "const %s: %s = %s" % [str(mod.get("name", "")), declared_type, value]
|
|
287
287
|
var after: int = 0
|
|
288
288
|
for i: int in range(lines.size()):
|
|
289
|
-
var line: String =
|
|
289
|
+
var line: String = GdhPatterns.without_annotations(lines[i])
|
|
290
290
|
if (
|
|
291
291
|
line.begins_with("extends ")
|
|
292
292
|
or line.begins_with("class_name ")
|
|
@@ -310,9 +310,9 @@ func _add_variable(lines: Array[String], mod: Dictionary, placed: Array[Dictiona
|
|
|
310
310
|
var var_name: String = str(mod.get("name", ""))
|
|
311
311
|
var var_type: String = str(mod.get("varType", ""))
|
|
312
312
|
var default_value: String = str(mod.get("defaultValue", ""))
|
|
313
|
-
var is_export: bool =
|
|
313
|
+
var is_export: bool = GdhRead.as_bool(mod.get("isExport", false))
|
|
314
314
|
var export_hint: String = str(mod.get("exportHint", ""))
|
|
315
|
-
var is_onready: bool =
|
|
315
|
+
var is_onready: bool = GdhRead.as_bool(mod.get("isOnready", false))
|
|
316
316
|
|
|
317
317
|
var var_line: String = ""
|
|
318
318
|
|
|
@@ -433,7 +433,7 @@ func _variable_insertion_point(lines: Array[String]) -> int:
|
|
|
433
433
|
# takes the new line above the `class_name`, where it does not parse; one that declares
|
|
434
434
|
# `extends` first takes it between the two, which does not parse either. Stripping also
|
|
435
435
|
# turns `@export var x` into `var x`, which is why the annotation names are gone below.
|
|
436
|
-
var line: String =
|
|
436
|
+
var line: String = GdhPatterns.without_annotations(lines[i])
|
|
437
437
|
if line.begins_with("extends ") or line.begins_with("class_name "):
|
|
438
438
|
after_header = i + 1
|
|
439
439
|
elif line.begins_with("signal "):
|
|
@@ -443,7 +443,7 @@ func _variable_insertion_point(lines: Array[String]) -> int:
|
|
|
443
443
|
break
|
|
444
444
|
|
|
445
445
|
for i: int in range(after_header, before_func):
|
|
446
|
-
if
|
|
446
|
+
if GdhPatterns.without_annotations(lines[i]).begins_with("var "):
|
|
447
447
|
after_header = i + 1
|
|
448
448
|
|
|
449
449
|
return after_header
|
|
@@ -455,7 +455,7 @@ func _signal_insertion_point(lines: Array[String]) -> int:
|
|
|
455
455
|
for i: int in range(lines.size()):
|
|
456
456
|
# As above: the annotations come off before the line is read, so an abstract class has a
|
|
457
457
|
# header to find and `@export var x` reads as the var it is.
|
|
458
|
-
var line: String =
|
|
458
|
+
var line: String = GdhPatterns.without_annotations(lines[i])
|
|
459
459
|
if line.begins_with("extends ") or line.begins_with("class_name "):
|
|
460
460
|
after_header = i + 1
|
|
461
461
|
elif line.begins_with("signal "):
|
|
@@ -485,7 +485,7 @@ func _line_after_function(lines: Array[String], prefix: String) -> int:
|
|
|
485
485
|
# ends of this. An annotated `_ready` was never found, so `after_ready` placed the new
|
|
486
486
|
# function at the end of the file, and an annotated function after `_ready` was not the
|
|
487
487
|
# boundary it is, so the new one went in after whichever later function was plain.
|
|
488
|
-
var line: String =
|
|
488
|
+
var line: String = GdhPatterns.without_annotations(lines[i])
|
|
489
489
|
if line.begins_with(prefix):
|
|
490
490
|
inside = true
|
|
491
491
|
elif inside and (line.begins_with("func ") or line.begins_with("static func ")):
|
|
@@ -502,7 +502,9 @@ static func _start_of_declaration(lines: Array[String], at: int) -> int:
|
|
|
502
502
|
var start: int = at
|
|
503
503
|
while start > 0 and _indentation(lines[start - 1]) == indent:
|
|
504
504
|
var above: String = lines[start - 1].strip_edges()
|
|
505
|
-
var annotation_only: bool =
|
|
505
|
+
var annotation_only: bool = (
|
|
506
|
+
above.begins_with("@") and GdhPatterns.without_annotations(above).is_empty()
|
|
507
|
+
)
|
|
506
508
|
if not above.begins_with("#") and not annotation_only:
|
|
507
509
|
break
|
|
508
510
|
start -= 1
|
|
@@ -14,25 +14,25 @@ extends SceneTree
|
|
|
14
14
|
# the operations directory ships inside the server package and is handed to the engine as an
|
|
15
15
|
# absolute path outside the project. A res:// path would only resolve in the test fixture.
|
|
16
16
|
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
17
|
+
const GdhAnimationReads = preload("animation_reads.gd")
|
|
18
|
+
const GdhAudioBuses = preload("audio_buses.gd")
|
|
19
|
+
const GdhClassCache = preload("class_cache.gd")
|
|
20
|
+
const GdhClassDbQueries = preload("classdb_queries.gd")
|
|
21
|
+
const GdhDependencies = preload("dependencies.gd")
|
|
22
|
+
const GdhExportPresets = preload("export_presets.gd")
|
|
23
|
+
const GdhFileReads = preload("file_reads.gd")
|
|
24
|
+
const GdhGdscriptAnalysis = preload("gdscript_analysis.gd")
|
|
25
|
+
const GdhGdscriptAuthoring = preload("gdscript_authoring.gd")
|
|
26
|
+
const GdhImportPipeline = preload("import_pipeline.gd")
|
|
27
|
+
const GdhInputActions = preload("input_actions.gd")
|
|
28
|
+
const GdhLog = preload("logger.gd")
|
|
29
|
+
const GdhPlugins = preload("plugins.gd")
|
|
30
|
+
const GdhProjectConfig = preload("project_config.gd")
|
|
31
|
+
const GdhProjectDiagnostics = preload("project_diagnostics.gd")
|
|
32
|
+
const GdhRead = preload("reading.gd")
|
|
33
|
+
const GdhRenameChecks = preload("rename_checks.gd")
|
|
34
|
+
const GdhResourceFiles = preload("resource_files.gd")
|
|
35
|
+
const GdhScriptCheck = preload("script_check.gd")
|
|
36
36
|
|
|
37
37
|
## Printed once the answer is written, after which the engine runs the project's autoloads. Kept in
|
|
38
38
|
## step with `ANSWERED` in src/headless.ts.
|
|
@@ -59,12 +59,12 @@ const AFTER_THE_AUTOLOADS: Array[String] = [
|
|
|
59
59
|
"run_editor_tool",
|
|
60
60
|
]
|
|
61
61
|
|
|
62
|
-
var _log:
|
|
62
|
+
var _log: GdhLog
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
func _init() -> void:
|
|
66
66
|
var args: PackedStringArray = OS.get_cmdline_args()
|
|
67
|
-
_log =
|
|
67
|
+
_log = GdhLog.new("--debug-godot" in args)
|
|
68
68
|
|
|
69
69
|
# The script path is the argument after --script, so the operation and its parameters are
|
|
70
70
|
# the two that follow it.
|
|
@@ -180,26 +180,27 @@ func _run(operation: String, params: Dictionary) -> Dictionary:
|
|
|
180
180
|
match operation:
|
|
181
181
|
# Resource files
|
|
182
182
|
"get_uid":
|
|
183
|
-
payload =
|
|
183
|
+
payload = GdhResourceFiles.new(_log).get_uid(params)
|
|
184
184
|
"refresh_class_cache":
|
|
185
|
-
payload =
|
|
185
|
+
payload = GdhClassCache.new(_log).refresh_class_cache(params)
|
|
186
186
|
"read_scene_tree":
|
|
187
187
|
payload = _read(
|
|
188
|
-
|
|
188
|
+
GdhFileReads.scene_tree(
|
|
189
189
|
str(params.get("scene_path", "")),
|
|
190
|
-
|
|
191
|
-
|
|
190
|
+
GdhRead.as_int(params.get("depth", -1), -1),
|
|
191
|
+
GdhRead.as_bool(params.get("include_properties", false))
|
|
192
192
|
)
|
|
193
193
|
)
|
|
194
194
|
"read_resource":
|
|
195
195
|
payload = _read(
|
|
196
|
-
|
|
197
|
-
str(params.get("resource_path", "")),
|
|
196
|
+
GdhFileReads.resource(
|
|
197
|
+
str(params.get("resource_path", "")),
|
|
198
|
+
GdhRead.as_bool(params.get("include_defaults", false))
|
|
198
199
|
)
|
|
199
200
|
)
|
|
200
201
|
"read_animations":
|
|
201
202
|
payload = _read(
|
|
202
|
-
|
|
203
|
+
GdhAnimationReads.scene_animations(
|
|
203
204
|
str(params.get("scene_path", "")),
|
|
204
205
|
str(params.get("player_node_path", ".")),
|
|
205
206
|
str(params.get("animation_name", ""))
|
|
@@ -207,7 +208,7 @@ func _run(operation: String, params: Dictionary) -> Dictionary:
|
|
|
207
208
|
)
|
|
208
209
|
"read_animation_states":
|
|
209
210
|
payload = _read(
|
|
210
|
-
|
|
211
|
+
GdhAnimationReads.scene_states(
|
|
211
212
|
str(params.get("scene_path", "")),
|
|
212
213
|
str(params.get("anim_tree_path", "")),
|
|
213
214
|
str(params.get("state_machine_path", ""))
|
|
@@ -219,83 +220,83 @@ func _run(operation: String, params: Dictionary) -> Dictionary:
|
|
|
219
220
|
|
|
220
221
|
# Import and export pipeline
|
|
221
222
|
"get_import_status":
|
|
222
|
-
payload =
|
|
223
|
+
payload = GdhImportPipeline.new(_log).get_import_status(params)
|
|
223
224
|
"get_import_options":
|
|
224
|
-
payload =
|
|
225
|
+
payload = GdhImportPipeline.new(_log).get_import_options(params)
|
|
225
226
|
"set_import_options":
|
|
226
|
-
payload =
|
|
227
|
+
payload = GdhImportPipeline.new(_log).set_import_options(params)
|
|
227
228
|
"list_export_presets":
|
|
228
|
-
payload =
|
|
229
|
+
payload = GdhExportPresets.new(_log).list_export_presets(params)
|
|
229
230
|
"add_export_preset":
|
|
230
|
-
payload =
|
|
231
|
+
payload = GdhExportPresets.new(_log).add_export_preset(params)
|
|
231
232
|
"validate_project":
|
|
232
|
-
payload =
|
|
233
|
+
payload = GdhImportPipeline.new(_log).validate_project(params)
|
|
233
234
|
|
|
234
235
|
# Dependencies and project inspection
|
|
235
236
|
"get_dependencies":
|
|
236
|
-
payload =
|
|
237
|
+
payload = GdhDependencies.new(_log).get_dependencies(params)
|
|
237
238
|
"find_resource_usages":
|
|
238
|
-
payload =
|
|
239
|
+
payload = GdhDependencies.new(_log).find_resource_usages(params)
|
|
239
240
|
"get_project_health":
|
|
240
|
-
payload =
|
|
241
|
+
payload = GdhProjectDiagnostics.new(_log).get_project_health(params)
|
|
241
242
|
|
|
242
243
|
# project.godot
|
|
243
244
|
"get_project_setting":
|
|
244
|
-
payload =
|
|
245
|
+
payload = GdhProjectConfig.new(_log).get_project_setting(params)
|
|
245
246
|
"set_project_setting":
|
|
246
|
-
payload =
|
|
247
|
+
payload = GdhProjectConfig.new(_log).set_project_setting(params)
|
|
247
248
|
"add_autoload":
|
|
248
|
-
payload =
|
|
249
|
+
payload = GdhProjectConfig.new(_log).add_autoload(params)
|
|
249
250
|
"remove_autoload":
|
|
250
|
-
payload =
|
|
251
|
+
payload = GdhProjectConfig.new(_log).remove_autoload(params)
|
|
251
252
|
"list_autoloads":
|
|
252
|
-
payload =
|
|
253
|
+
payload = GdhProjectConfig.new(_log).list_autoloads(params)
|
|
253
254
|
"set_main_scene":
|
|
254
|
-
payload =
|
|
255
|
+
payload = GdhProjectConfig.new(_log).set_main_scene(params)
|
|
255
256
|
|
|
256
257
|
# GDScript files
|
|
257
258
|
"create_script":
|
|
258
|
-
payload =
|
|
259
|
+
payload = GdhGdscriptAuthoring.new(_log).create_gdscript(params)
|
|
259
260
|
"modify_script":
|
|
260
|
-
payload =
|
|
261
|
+
payload = GdhGdscriptAuthoring.new(_log).modify_gdscript(params)
|
|
261
262
|
"get_script_info":
|
|
262
|
-
payload =
|
|
263
|
+
payload = GdhGdscriptAnalysis.new(_log).get_gdscript_info(params)
|
|
263
264
|
"names_taken":
|
|
264
|
-
payload =
|
|
265
|
+
payload = GdhRenameChecks.new(_log).names_taken(params)
|
|
265
266
|
"check_scripts":
|
|
266
|
-
payload =
|
|
267
|
+
payload = GdhScriptCheck.new(_log).check_scripts(params)
|
|
267
268
|
|
|
268
269
|
# Plugins and input
|
|
269
270
|
"list_plugins":
|
|
270
|
-
payload =
|
|
271
|
+
payload = GdhPlugins.new(_log).list_plugins(params)
|
|
271
272
|
"enable_plugin":
|
|
272
|
-
payload =
|
|
273
|
+
payload = GdhPlugins.new(_log).enable_plugin(params)
|
|
273
274
|
"disable_plugin":
|
|
274
|
-
payload =
|
|
275
|
+
payload = GdhPlugins.new(_log).disable_plugin(params)
|
|
275
276
|
"add_input_action":
|
|
276
|
-
payload =
|
|
277
|
+
payload = GdhInputActions.new(_log).add_input_action(params)
|
|
277
278
|
"remove_input_action":
|
|
278
|
-
payload =
|
|
279
|
+
payload = GdhInputActions.new(_log).remove_input_action(params)
|
|
279
280
|
|
|
280
281
|
# Audio
|
|
281
282
|
"create_audio_bus":
|
|
282
|
-
payload =
|
|
283
|
+
payload = GdhAudioBuses.new(_log).create_audio_bus(params)
|
|
283
284
|
"remove_audio_bus":
|
|
284
|
-
payload =
|
|
285
|
+
payload = GdhAudioBuses.new(_log).remove_audio_bus(params)
|
|
285
286
|
"get_audio_buses":
|
|
286
|
-
payload =
|
|
287
|
+
payload = GdhAudioBuses.new(_log).get_audio_buses(params)
|
|
287
288
|
"set_audio_bus_effect":
|
|
288
|
-
payload =
|
|
289
|
+
payload = GdhAudioBuses.new(_log).set_audio_bus_effect(params)
|
|
289
290
|
"set_audio_bus_volume":
|
|
290
|
-
payload =
|
|
291
|
+
payload = GdhAudioBuses.new(_log).set_audio_bus_volume(params)
|
|
291
292
|
|
|
292
293
|
# ClassDB
|
|
293
294
|
"query_classes":
|
|
294
|
-
payload =
|
|
295
|
+
payload = GdhClassDbQueries.new(_log).query_classes(params)
|
|
295
296
|
"query_class_info":
|
|
296
|
-
payload =
|
|
297
|
+
payload = GdhClassDbQueries.new(_log).query_class_info(params)
|
|
297
298
|
"inspect_inheritance":
|
|
298
|
-
payload =
|
|
299
|
+
payload = GdhClassDbQueries.new(_log).inspect_inheritance(params)
|
|
299
300
|
|
|
300
301
|
_:
|
|
301
302
|
_log.error("Unknown operation: " + operation)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
extends RefCounted
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
3
|
+
const GdhExportPresets = preload("export_presets.gd")
|
|
4
|
+
const GdhRead = preload("reading.gd")
|
|
5
|
+
const GdhSerialisation = preload("serialisation.gd")
|
|
6
|
+
const GdhFileWalk = preload("file_walk.gd")
|
|
7
|
+
const GdhLog = preload("logger.gd")
|
|
8
8
|
|
|
9
9
|
## What the engine imports with no tool outside it, for finding what has not been imported yet;
|
|
10
10
|
## everything imported already is found by its sidecar whatever its extension.
|
|
@@ -53,20 +53,20 @@ const OPENTYPE_OPTIONS: Dictionary[String, Array] = {"font_data_dynamic": ["open
|
|
|
53
53
|
const EDITOR_DIRECTORY: String = "res://.godot/editor"
|
|
54
54
|
const EDITOR_CACHE_PREFIX: String = "filesystem_cache"
|
|
55
55
|
|
|
56
|
-
var _log:
|
|
57
|
-
var _files:
|
|
58
|
-
var _values:
|
|
56
|
+
var _log: GdhLog
|
|
57
|
+
var _files: GdhFileWalk = GdhFileWalk.new()
|
|
58
|
+
var _values: GdhSerialisation = GdhSerialisation.new()
|
|
59
59
|
var _sidecar_md5s: Variant = null
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
func _init(p_log:
|
|
62
|
+
func _init(p_log: GdhLog) -> void:
|
|
63
63
|
_log = p_log
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
# Get import status for resources
|
|
67
67
|
func get_import_status(params: Dictionary) -> Dictionary:
|
|
68
68
|
var resource_path: String = str(params.get("resource_path", ""))
|
|
69
|
-
var include_up_to_date: bool =
|
|
69
|
+
var include_up_to_date: bool = GdhRead.as_bool(params.get("include_up_to_date", false))
|
|
70
70
|
|
|
71
71
|
_log.info(
|
|
72
72
|
(
|
|
@@ -203,7 +203,7 @@ func set_import_options(params: Dictionary) -> Dictionary:
|
|
|
203
203
|
and (value is int or value is float)
|
|
204
204
|
and type_convert(value, typeof(given)) != given
|
|
205
205
|
)
|
|
206
|
-
if held != null and (lossy or not
|
|
206
|
+
if held != null and (lossy or not GdhSerialisation.acceptable(value, typeof(held))):
|
|
207
207
|
var held_type: String = type_string(typeof(held))
|
|
208
208
|
var article: String = "an" if held_type.to_lower()[0] in "aeiou" else "a"
|
|
209
209
|
refused.append(
|
|
@@ -323,7 +323,7 @@ static func _all_ints(held: Variant, keys: bool) -> bool:
|
|
|
323
323
|
# Validate project for export
|
|
324
324
|
func validate_project(params: Dictionary) -> Dictionary:
|
|
325
325
|
var preset_name: String = str(params.get("preset", ""))
|
|
326
|
-
var include_suggestions: bool =
|
|
326
|
+
var include_suggestions: bool = GdhRead.as_bool(params.get("include_suggestions", true), true)
|
|
327
327
|
|
|
328
328
|
_log.info("Validating project" + (" for preset: " + preset_name if not preset_name.is_empty() else ""))
|
|
329
329
|
|
|
@@ -355,12 +355,12 @@ func validate_project(params: Dictionary) -> Dictionary:
|
|
|
355
355
|
include_suggestions
|
|
356
356
|
)
|
|
357
357
|
)
|
|
358
|
-
elif not
|
|
358
|
+
elif not GdhFileWalk.missing_reason(main_scene).is_empty():
|
|
359
359
|
issues.append(
|
|
360
360
|
_finding(
|
|
361
361
|
"error",
|
|
362
362
|
"main_scene",
|
|
363
|
-
"Main scene " +
|
|
363
|
+
"Main scene " + GdhFileWalk.missing_reason(main_scene),
|
|
364
364
|
"Update the main scene setting or create the missing scene file",
|
|
365
365
|
include_suggestions
|
|
366
366
|
)
|
|
@@ -382,7 +382,7 @@ func validate_project(params: Dictionary) -> Dictionary:
|
|
|
382
382
|
# does not exist answered valid, as though it had been checked.
|
|
383
383
|
if not preset_name.is_empty():
|
|
384
384
|
checks_performed.append("export_preset")
|
|
385
|
-
var named: Array[String] =
|
|
385
|
+
var named: Array[String] = GdhExportPresets.names()
|
|
386
386
|
if preset_name not in named:
|
|
387
387
|
issues.append(
|
|
388
388
|
_finding(
|
|
@@ -611,8 +611,8 @@ static func _import_staleness(resource_path: String, sidecar: ConfigFile) -> Dic
|
|
|
611
611
|
# imported them again: every scene after an engine upgrade raised the importer's version, and
|
|
612
612
|
# every VRAM texture once the project asked for another compression format.
|
|
613
613
|
var importer: String = str(sidecar.get_value("remap", "importer", ""))
|
|
614
|
-
var version: int =
|
|
615
|
-
var current: int =
|
|
614
|
+
var version: int = GdhRead.as_int(sidecar.get_value("remap", "importer_version", 0))
|
|
615
|
+
var current: int = GdhRead.as_int(IMPORTER_VERSIONS.get(importer, 0))
|
|
616
616
|
if current > version:
|
|
617
617
|
return _stale(
|
|
618
618
|
(
|
|
@@ -697,12 +697,12 @@ static func _vram_formats_lacking(metadata: Variant) -> Array[String]:
|
|
|
697
697
|
if not metadata is Dictionary:
|
|
698
698
|
return lacking
|
|
699
699
|
var meta: Dictionary = metadata
|
|
700
|
-
if not
|
|
700
|
+
if not GdhRead.as_bool(meta.get("vram_texture", false)):
|
|
701
701
|
return lacking
|
|
702
702
|
var written: Variant = meta.get("imported_formats", [])
|
|
703
703
|
var formats: Array = written if written is Array else []
|
|
704
704
|
for format: String in VRAM_FORMATS:
|
|
705
|
-
var asked: bool =
|
|
705
|
+
var asked: bool = GdhRead.as_bool(
|
|
706
706
|
ProjectSettings.get_setting("rendering/textures/vram_compression/import_" + format, false)
|
|
707
707
|
)
|
|
708
708
|
if asked and format not in formats:
|
|
@@ -850,7 +850,7 @@ static func _images_of(scene_path: String) -> Array[String]:
|
|
|
850
850
|
text = bytes.slice(20, mini(20 + length, bytes.size())).get_string_from_utf8()
|
|
851
851
|
if text.is_empty():
|
|
852
852
|
return images
|
|
853
|
-
var parsed: Variant =
|
|
853
|
+
var parsed: Variant = GdhRead.json_or_null(text)
|
|
854
854
|
if not parsed is Dictionary:
|
|
855
855
|
return images
|
|
856
856
|
var document: Dictionary = parsed
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
extends RefCounted
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
const GdhRead = preload("reading.gd")
|
|
4
|
+
const GdhLog = preload("logger.gd")
|
|
5
|
+
const GdhProjectFile = preload("project_file.gd")
|
|
6
6
|
|
|
7
7
|
# The key names a caller may write, and what the engine calls them.
|
|
8
8
|
const KEY_NAMES: Dictionary = {
|
|
@@ -97,10 +97,10 @@ const KEY_NAMES: Dictionary = {
|
|
|
97
97
|
"Equal": KEY_EQUAL,
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
var _log:
|
|
100
|
+
var _log: GdhLog
|
|
101
101
|
|
|
102
102
|
|
|
103
|
-
func _init(p_log:
|
|
103
|
+
func _init(p_log: GdhLog) -> void:
|
|
104
104
|
_log = p_log
|
|
105
105
|
|
|
106
106
|
|
|
@@ -108,7 +108,7 @@ func _init(p_log: Log) -> void:
|
|
|
108
108
|
func add_input_action(params: Dictionary) -> Dictionary:
|
|
109
109
|
var action_name: String = str(params.get("action_name", ""))
|
|
110
110
|
var events: Array = params.get("events", [])
|
|
111
|
-
var deadzone: float =
|
|
111
|
+
var deadzone: float = GdhRead.as_float(params.get("deadzone", 0.5), 0.5)
|
|
112
112
|
|
|
113
113
|
_log.info("Adding input action: " + action_name)
|
|
114
114
|
_log.debug("Events: " + JSON.stringify(events))
|
|
@@ -192,12 +192,12 @@ func add_input_action(params: Dictionary) -> Dictionary:
|
|
|
192
192
|
var bound: InputEvent = event
|
|
193
193
|
old_events.append(_shaped(bound))
|
|
194
194
|
answer["old_events"] = old_events
|
|
195
|
-
answer["old_deadzone"] =
|
|
195
|
+
answer["old_deadzone"] = GdhRead.as_float(old.get("deadzone", 0.5), 0.5)
|
|
196
196
|
|
|
197
197
|
# Through ProjectSettings so the file is saved the way the editor saves it, header and
|
|
198
198
|
# every other line kept; a ConfigFile of project.godot drops the comments on the way out.
|
|
199
199
|
ProjectSettings.set_setting(setting, action)
|
|
200
|
-
var err: Error =
|
|
200
|
+
var err: Error = GdhProjectFile.save()
|
|
201
201
|
if err != OK:
|
|
202
202
|
return _log.failure("Failed to save project.godot: " + error_string(err))
|
|
203
203
|
|
|
@@ -250,7 +250,7 @@ func remove_input_action(params: Dictionary) -> Dictionary:
|
|
|
250
250
|
)
|
|
251
251
|
)
|
|
252
252
|
ProjectSettings.set_setting(setting, null)
|
|
253
|
-
var err: Error =
|
|
253
|
+
var err: Error = GdhProjectFile.save()
|
|
254
254
|
if err != OK:
|
|
255
255
|
return _log.failure("Failed to save project.godot: " + error_string(err))
|
|
256
256
|
return {"action_name": action_name, "removed": true}
|
|
@@ -273,29 +273,29 @@ func build_input_action(deadzone: float, events: Array) -> Dictionary:
|
|
|
273
273
|
match evt_class:
|
|
274
274
|
"InputEventKey":
|
|
275
275
|
var key: InputEventKey = InputEventKey.new()
|
|
276
|
-
key.keycode =
|
|
277
|
-
key.ctrl_pressed =
|
|
278
|
-
key.alt_pressed =
|
|
279
|
-
key.shift_pressed =
|
|
276
|
+
key.keycode = GdhRead.as_int(event.get("keycode", 0)) as Key
|
|
277
|
+
key.ctrl_pressed = GdhRead.as_bool(event.get("ctrl_pressed", false))
|
|
278
|
+
key.alt_pressed = GdhRead.as_bool(event.get("alt_pressed", false))
|
|
279
|
+
key.shift_pressed = GdhRead.as_bool(event.get("shift_pressed", false))
|
|
280
280
|
built.append(key)
|
|
281
281
|
|
|
282
282
|
"InputEventMouseButton":
|
|
283
283
|
var mouse: InputEventMouseButton = InputEventMouseButton.new()
|
|
284
284
|
mouse.button_index = (
|
|
285
|
-
|
|
285
|
+
GdhRead.as_int(event.get("button_index", MOUSE_BUTTON_LEFT), MOUSE_BUTTON_LEFT)
|
|
286
286
|
as MouseButton
|
|
287
287
|
)
|
|
288
288
|
built.append(mouse)
|
|
289
289
|
|
|
290
290
|
"InputEventJoypadButton":
|
|
291
291
|
var pad: InputEventJoypadButton = InputEventJoypadButton.new()
|
|
292
|
-
pad.button_index =
|
|
292
|
+
pad.button_index = GdhRead.as_int(event.get("button_index", 0)) as JoyButton
|
|
293
293
|
built.append(pad)
|
|
294
294
|
|
|
295
295
|
"InputEventJoypadMotion":
|
|
296
296
|
var motion: InputEventJoypadMotion = InputEventJoypadMotion.new()
|
|
297
|
-
motion.axis =
|
|
298
|
-
motion.axis_value =
|
|
297
|
+
motion.axis = GdhRead.as_int(event.get("axis", 0)) as JoyAxis
|
|
298
|
+
motion.axis_value = GdhRead.as_float(event.get("axis_value", 1.0), 1.0)
|
|
299
299
|
built.append(motion)
|
|
300
300
|
|
|
301
301
|
_:
|
|
@@ -3,7 +3,7 @@ extends RefCounted
|
|
|
3
3
|
# Everything printed is diagnostics; the answer goes to a file. The server reads `[ERROR]` lines as
|
|
4
4
|
# the operation's own errors, and the prefixes let a human read the rest without parsing it.
|
|
5
5
|
#
|
|
6
|
-
# Every module preloads this as `
|
|
6
|
+
# Every module preloads this as `GdhLog`. `Logger` is a native class from Godot 4.5 on, and a
|
|
7
7
|
# constant of that name is a parse error rather than a shadowing warning.
|
|
8
8
|
|
|
9
9
|
var debug_mode: bool = false
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
extends RefCounted
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
const GdhPatterns = preload("patterns.gd")
|
|
4
|
+
const GdhLog = preload("logger.gd")
|
|
5
|
+
const GdhProjectFile = preload("project_file.gd")
|
|
6
6
|
|
|
7
|
-
var _log:
|
|
7
|
+
var _log: GdhLog
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
func _init(p_log:
|
|
10
|
+
func _init(p_log: GdhLog) -> void:
|
|
11
11
|
_log = p_log
|
|
12
12
|
|
|
13
13
|
|
|
@@ -148,7 +148,7 @@ func _enabled_paths() -> Array[String]:
|
|
|
148
148
|
paths.assign(packed)
|
|
149
149
|
elif enabled_value is String:
|
|
150
150
|
var listed: String = enabled_value
|
|
151
|
-
for m: RegExMatch in
|
|
151
|
+
for m: RegExMatch in GdhPatterns.compiled("res://[^\"',)]+?plugin\\.cfg").search_all(listed):
|
|
152
152
|
paths.append(m.get_string())
|
|
153
153
|
return paths
|
|
154
154
|
|
|
@@ -172,11 +172,11 @@ static func _names_of(paths: Array[String]) -> Array[String]:
|
|
|
172
172
|
func _save_enabled_paths(paths: Array[String]) -> Error:
|
|
173
173
|
if paths.is_empty():
|
|
174
174
|
ProjectSettings.set_setting("editor_plugins/enabled", null)
|
|
175
|
-
return
|
|
175
|
+
return GdhProjectFile.save()
|
|
176
176
|
|
|
177
177
|
# Kept in an Array[String] and converted here, because appending to a packed array answers with
|
|
178
178
|
# whether it worked and a project holding return_value_discarded at error level will not compile
|
|
179
179
|
# a script that drops that answer. The conversion is what matters: an Array[String] handed to
|
|
180
180
|
# set_setting is written as Array[String]([...]), which the editor does not read as a plugin list.
|
|
181
181
|
ProjectSettings.set_setting("editor_plugins/enabled", PackedStringArray(paths))
|
|
182
|
-
return
|
|
182
|
+
return GdhProjectFile.save()
|