gdharness 1.2.41 → 1.3.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/build/cli.js +643 -378
- package/build/godot/addons/gdharness_editor/animation_reads.gd +7 -4
- package/build/godot/addons/gdharness_editor/bridge_client.gd +1 -1
- package/build/godot/addons/gdharness_editor/file_reads.gd +134 -10
- package/build/godot/addons/gdharness_editor/headless_check.gd +34 -4
- package/build/godot/addons/gdharness_editor/property_values.gd +4 -9
- package/build/godot/addons/gdharness_editor/reading.gd +25 -0
- package/build/godot/addons/gdharness_editor/scene_file.gd +209 -15
- package/build/godot/addons/gdharness_editor/serialisation.gd +5 -1
- package/build/godot/addons/gdharness_editor/tools/resource_tools.gd +9 -9
- package/build/godot/addons/gdharness_editor/tools/scene_kin.gd +346 -0
- package/build/godot/addons/gdharness_editor/tools/scene_kin.gd.uid +1 -0
- package/build/godot/addons/gdharness_editor/tools/scene_paths.gd +438 -0
- package/build/godot/addons/gdharness_editor/tools/scene_paths.gd.uid +1 -0
- package/build/godot/addons/gdharness_editor/tools/scene_tools.gd +91 -49
- package/build/godot/addons/gdharness_runtime/reading.gd +25 -0
- package/build/godot/addons/gdharness_runtime/runtime_autoload.gd +2 -2
- package/build/godot/addons/gdharness_runtime/runtime_capture.gd +29 -0
- package/build/godot/addons/gdharness_runtime/runtime_input.gd +2 -7
- package/build/godot/addons/gdharness_runtime/runtime_mouse.gd +6 -14
- package/build/godot/addons/gdharness_runtime/serialisation.gd +5 -1
- package/build/godot/operations/animation_reads.gd +7 -4
- package/build/godot/operations/editor_tools.gd +19 -1
- package/build/godot/operations/file_reads.gd +134 -10
- package/build/godot/operations/property_values.gd +4 -9
- package/build/godot/operations/reading.gd +25 -0
- package/build/godot/operations/serialisation.gd +5 -1
- package/build/keeper.js +10 -4
- package/package.json +1 -2
- package/build/index.js +0 -45043
|
@@ -5,22 +5,14 @@ extends Node
|
|
|
5
5
|
|
|
6
6
|
const FileReads = preload("../file_reads.gd")
|
|
7
7
|
const Read = preload("../reading.gd")
|
|
8
|
+
const Kin = preload("scene_kin.gd")
|
|
9
|
+
const Paths = preload("scene_paths.gd")
|
|
8
10
|
const Placing = preload("scene_placing.gd")
|
|
9
11
|
const PropertyValues = preload("../property_values.gd")
|
|
10
12
|
const ResourceTools = preload("resource_tools.gd")
|
|
11
13
|
const SceneFile = preload("../scene_file.gd")
|
|
12
14
|
const Serialisation = preload("../serialisation.gd")
|
|
13
15
|
|
|
14
|
-
## The names Object.ConnectFlags gives each bit. The number alone left a reader guessing that 2 is
|
|
15
|
-
## the persistence every connection in a saved scene carries.
|
|
16
|
-
const CONNECT_FLAG_NAMES: Dictionary[int, String] = {
|
|
17
|
-
Object.CONNECT_DEFERRED: "deferred",
|
|
18
|
-
Object.CONNECT_PERSIST: "persist",
|
|
19
|
-
Object.CONNECT_ONE_SHOT: "one_shot",
|
|
20
|
-
Object.CONNECT_REFERENCE_COUNTED: "reference_counted",
|
|
21
|
-
Object.CONNECT_APPEND_SOURCE_OBJECT: "append_source_object",
|
|
22
|
-
}
|
|
23
|
-
|
|
24
16
|
var _editor_plugin: EditorPlugin = null
|
|
25
17
|
var _values: Serialisation = Serialisation.new()
|
|
26
18
|
var _properties: PropertyValues = PropertyValues.new()
|
|
@@ -30,19 +22,6 @@ func set_editor_plugin(plugin: EditorPlugin) -> void:
|
|
|
30
22
|
_editor_plugin = plugin
|
|
31
23
|
|
|
32
24
|
|
|
33
|
-
## Each bit set in [param flags] by name, and whatever bits are left unnamed as one number.
|
|
34
|
-
static func _flag_names(flags: int) -> Array[String]:
|
|
35
|
-
var names: Array[String] = []
|
|
36
|
-
var rest: int = flags
|
|
37
|
-
for bit: int in CONNECT_FLAG_NAMES:
|
|
38
|
-
if flags & bit:
|
|
39
|
-
names.append(CONNECT_FLAG_NAMES[bit])
|
|
40
|
-
rest &= ~bit
|
|
41
|
-
if rest != 0:
|
|
42
|
-
names.append(str(rest))
|
|
43
|
-
return names
|
|
44
|
-
|
|
45
|
-
|
|
46
25
|
func _ensure_res_path(path: String) -> String:
|
|
47
26
|
if not path.begins_with("res://"):
|
|
48
27
|
return "res://" + path
|
|
@@ -175,17 +154,42 @@ func _collect_nodes_recursive(node: Node, path: String, out_nodes: Array) -> voi
|
|
|
175
154
|
_collect_nodes_recursive(child, child_path, out_nodes)
|
|
176
155
|
|
|
177
156
|
|
|
157
|
+
func _inherited(args: Dictionary) -> Dictionary:
|
|
158
|
+
var project_path: String = str(args.get("projectPath", ""))
|
|
159
|
+
var script_path: String = str(args.get("script", ""))
|
|
160
|
+
return Kin.inherited(
|
|
161
|
+
args,
|
|
162
|
+
_new_scene_path(args),
|
|
163
|
+
_to_scene_res_path(project_path, str(args.get("inherits", ""))),
|
|
164
|
+
"" if script_path.is_empty() else _to_scene_res_path(project_path, script_path)
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
## The res:// path a create in [param args] writes, given .tscn when it has no extension, or "".
|
|
169
|
+
func _new_scene_path(args: Dictionary) -> String:
|
|
170
|
+
var scene_path: String = _to_scene_res_path(
|
|
171
|
+
str(args.get("projectPath", "")), str(args.get("scenePath", ""))
|
|
172
|
+
)
|
|
173
|
+
if scene_path == "res://":
|
|
174
|
+
return ""
|
|
175
|
+
return scene_path if scene_path.ends_with(".tscn") else scene_path + ".tscn"
|
|
176
|
+
|
|
177
|
+
|
|
178
178
|
func create_scene(args: Dictionary) -> Dictionary:
|
|
179
|
+
if str(args.get("inherits", "")).is_empty():
|
|
180
|
+
return _create_of_a_class(args)
|
|
181
|
+
return _inherited(args)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
func _create_of_a_class(args: Dictionary) -> Dictionary:
|
|
179
185
|
var project_path: String = str(args.get("projectPath", ""))
|
|
180
|
-
var scene_path: String =
|
|
186
|
+
var scene_path: String = _new_scene_path(args)
|
|
181
187
|
var root_node_type: String = str(args.get("rootNodeType", "Node"))
|
|
182
188
|
var root_node_name: String = str(args.get("rootNodeName", root_node_type))
|
|
183
189
|
var script_path: String = str(args.get("script", ""))
|
|
184
190
|
|
|
185
|
-
if scene_path
|
|
191
|
+
if scene_path.is_empty():
|
|
186
192
|
return {"ok": false, "error": "Missing scenePath"}
|
|
187
|
-
if not scene_path.ends_with(".tscn"):
|
|
188
|
-
scene_path += ".tscn"
|
|
189
193
|
var asked_type: String = root_node_type
|
|
190
194
|
var made: Dictionary = SceneFile.made_as(
|
|
191
195
|
root_node_type,
|
|
@@ -208,19 +212,8 @@ func create_scene(args: Dictionary) -> Dictionary:
|
|
|
208
212
|
var unfit: String = SceneFile.unfit_name(root_node_name)
|
|
209
213
|
if not unfit.is_empty():
|
|
210
214
|
return {"ok": false, "error": unfit}
|
|
211
|
-
# Saving over a scene that is there replaced it, nodes and all, and answered as a new scene.
|
|
212
215
|
if FileAccess.file_exists(scene_path):
|
|
213
|
-
return
|
|
214
|
-
"ok": false,
|
|
215
|
-
"error":
|
|
216
|
-
(
|
|
217
|
-
(
|
|
218
|
-
"%s already exists, and scene_create op=create would replace everything in it. Edit it "
|
|
219
|
-
+ "with scene_node, or create the scene under another path."
|
|
220
|
-
)
|
|
221
|
-
% scene_path
|
|
222
|
-
)
|
|
223
|
-
}
|
|
216
|
+
return Kin.taken(scene_path)
|
|
224
217
|
|
|
225
218
|
var root: Node = ClassDB.instantiate(root_node_type)
|
|
226
219
|
root.name = root_node_name
|
|
@@ -395,6 +388,8 @@ func delete_node(args: Dictionary) -> Dictionary:
|
|
|
395
388
|
var at: String = scene.path_of(node)
|
|
396
389
|
node.get_parent().remove_child(node)
|
|
397
390
|
node.free()
|
|
391
|
+
var carried: Paths = Paths.new()
|
|
392
|
+
var _rewritten: int = carried.carry(scene, {at: ""})
|
|
398
393
|
|
|
399
394
|
var written: Dictionary = scene.write(
|
|
400
395
|
func(saved: Node) -> String:
|
|
@@ -405,7 +400,9 @@ func delete_node(args: Dictionary) -> Dictionary:
|
|
|
405
400
|
if not written.is_empty():
|
|
406
401
|
return written
|
|
407
402
|
|
|
408
|
-
|
|
403
|
+
var answer: Dictionary = {"ok": true, "deletedNodePath": at}
|
|
404
|
+
answer.merge(Kin.follow(scene_path, at, "", carried))
|
|
405
|
+
return answer
|
|
409
406
|
|
|
410
407
|
|
|
411
408
|
func duplicate_node(args: Dictionary) -> Dictionary:
|
|
@@ -413,7 +410,7 @@ func duplicate_node(args: Dictionary) -> Dictionary:
|
|
|
413
410
|
var scene_path: String = _to_scene_res_path(project_path, str(args.get("scenePath", "")))
|
|
414
411
|
var node_path: String = str(args.get("nodePath", ""))
|
|
415
412
|
var new_name: String = str(args.get("newName", ""))
|
|
416
|
-
var parent_path: String = str(args.get("
|
|
413
|
+
var parent_path: String = str(args.get("parentNodePath", ""))
|
|
417
414
|
|
|
418
415
|
if node_path.is_empty() or new_name.is_empty():
|
|
419
416
|
return {"ok": false, "error": "Missing nodePath or newName"}
|
|
@@ -458,6 +455,7 @@ func duplicate_node(args: Dictionary) -> Dictionary:
|
|
|
458
455
|
scene.copied(copies)
|
|
459
456
|
|
|
460
457
|
var new_path: String = scene.path_of(duplicated_node)
|
|
458
|
+
var placed: Array = [scene.path_of(target_parent), duplicated_node.get_index()]
|
|
461
459
|
var written: Dictionary = scene.write(
|
|
462
460
|
func(saved: Node) -> String:
|
|
463
461
|
if saved.get_node_or_null(new_path) == null:
|
|
@@ -467,7 +465,14 @@ func duplicate_node(args: Dictionary) -> Dictionary:
|
|
|
467
465
|
if not written.is_empty():
|
|
468
466
|
return written
|
|
469
467
|
|
|
470
|
-
return {
|
|
468
|
+
return {
|
|
469
|
+
"ok": true,
|
|
470
|
+
"nodePath": node_path,
|
|
471
|
+
"newName": new_name,
|
|
472
|
+
"newNodePath": new_path,
|
|
473
|
+
"parentNodePath": placed[0],
|
|
474
|
+
"index": placed[1],
|
|
475
|
+
}
|
|
471
476
|
|
|
472
477
|
|
|
473
478
|
func reparent_node(args: Dictionary) -> Dictionary:
|
|
@@ -525,6 +530,8 @@ func reparent_node(args: Dictionary) -> Dictionary:
|
|
|
525
530
|
|
|
526
531
|
var new_path: String = scene.path_of(node)
|
|
527
532
|
var index: int = node.get_index()
|
|
533
|
+
var carried: Paths = Paths.new()
|
|
534
|
+
var _rewritten: int = carried.carry(scene, {old_path: new_path} if new_path != old_path else {})
|
|
528
535
|
var written: Dictionary = scene.write(
|
|
529
536
|
func(saved: Node) -> String:
|
|
530
537
|
var copy: Node = saved.get_node_or_null(new_path)
|
|
@@ -537,15 +544,19 @@ func reparent_node(args: Dictionary) -> Dictionary:
|
|
|
537
544
|
return ""
|
|
538
545
|
)
|
|
539
546
|
if not written.is_empty():
|
|
547
|
+
carried.put_back(scene_path)
|
|
540
548
|
return written
|
|
541
549
|
|
|
542
|
-
|
|
550
|
+
var answer: Dictionary = {
|
|
543
551
|
"ok": true,
|
|
544
552
|
"nodePath": old_path,
|
|
545
553
|
"newParentPath": new_parent_path,
|
|
546
554
|
"newNodePath": new_path,
|
|
547
555
|
"index": index,
|
|
548
556
|
}
|
|
557
|
+
if new_path != old_path:
|
|
558
|
+
answer.merge(Kin.follow(scene_path, old_path, new_path, carried))
|
|
559
|
+
return answer
|
|
549
560
|
|
|
550
561
|
|
|
551
562
|
func set_node_properties(args: Dictionary) -> Dictionary:
|
|
@@ -553,6 +564,9 @@ func set_node_properties(args: Dictionary) -> Dictionary:
|
|
|
553
564
|
var scene_path: String = _to_scene_res_path(project_path, str(args.get("scenePath", "")))
|
|
554
565
|
var node_path: String = str(args.get("nodePath", "."))
|
|
555
566
|
var properties: Dictionary = _parse_properties_arg(args.get("properties", {}))
|
|
567
|
+
var editable: Variant = args.get("editableChildren")
|
|
568
|
+
if properties.is_empty() and editable == null:
|
|
569
|
+
return {"ok": false, "error": "set takes properties, editableChildren, or both."}
|
|
556
570
|
|
|
557
571
|
var opened: Array = _open(scene_path, true)
|
|
558
572
|
var scene: SceneFile = opened[0]
|
|
@@ -574,6 +588,15 @@ func set_node_properties(args: Dictionary) -> Dictionary:
|
|
|
574
588
|
if not unusable.is_empty():
|
|
575
589
|
return scene.refuse(unusable)
|
|
576
590
|
|
|
591
|
+
var dropped: Dictionary = {}
|
|
592
|
+
if editable != null:
|
|
593
|
+
var not_an_instance: String = Kin.set_editable(scene, node, Read.as_bool(editable))
|
|
594
|
+
if not not_an_instance.is_empty():
|
|
595
|
+
return scene.refuse(not_an_instance)
|
|
596
|
+
if not Read.as_bool(editable):
|
|
597
|
+
dropped = scene.held_under(scene.path_of(node))
|
|
598
|
+
|
|
599
|
+
var old_path: String = scene.path_of(node)
|
|
577
600
|
scene.asked(node, properties.keys())
|
|
578
601
|
var refused_property: String = _properties.write_all(node, properties)
|
|
579
602
|
if not refused_property.is_empty():
|
|
@@ -583,13 +606,29 @@ func set_node_properties(args: Dictionary) -> Dictionary:
|
|
|
583
606
|
for key: Variant in properties:
|
|
584
607
|
held[str(key)] = _readable(node, _properties.read_at(node, str(key)))
|
|
585
608
|
var new_path: String = scene.path_of(node)
|
|
609
|
+
var carried: Paths = Paths.new()
|
|
610
|
+
var _rewritten: int = carried.carry(scene, {old_path: new_path} if new_path != old_path else {})
|
|
586
611
|
var written: Dictionary = scene.write(
|
|
587
|
-
func(saved: Node) -> String:
|
|
612
|
+
func(saved: Node) -> String:
|
|
613
|
+
var unkept: String = _kept(scene, saved, node, properties.keys())
|
|
614
|
+
if unkept.is_empty() and editable != null:
|
|
615
|
+
if saved.is_editable_instance(saved.get_node(new_path)) != Read.as_bool(editable):
|
|
616
|
+
return "%s would load with editableChildren %s." % [new_path, not Read.as_bool(editable)]
|
|
617
|
+
return unkept
|
|
588
618
|
)
|
|
589
619
|
if not written.is_empty():
|
|
620
|
+
carried.put_back(scene_path)
|
|
590
621
|
return written
|
|
591
622
|
|
|
592
|
-
|
|
623
|
+
var answer: Dictionary = {"ok": true, "nodePath": new_path, "properties": held}
|
|
624
|
+
if editable != null:
|
|
625
|
+
answer["editableChildren"] = Read.as_bool(editable)
|
|
626
|
+
if not dropped.is_empty():
|
|
627
|
+
answer["droppedValues"] = dropped["values"]
|
|
628
|
+
answer["droppedNodes"] = dropped["nodes"]
|
|
629
|
+
if new_path != old_path:
|
|
630
|
+
answer.merge(Kin.follow(scene_path, old_path, new_path, carried))
|
|
631
|
+
return answer
|
|
593
632
|
|
|
594
633
|
|
|
595
634
|
func get_node_properties(args: Dictionary) -> Dictionary:
|
|
@@ -614,8 +653,11 @@ func get_node_properties(args: Dictionary) -> Dictionary:
|
|
|
614
653
|
# names this scene's file sets are always answered.
|
|
615
654
|
var props: Dictionary = _properties_of(node, include_defaults, scene.set_here(node))
|
|
616
655
|
var cells: Dictionary = ResourceTools.cells_of(node)
|
|
617
|
-
scene.close()
|
|
618
656
|
var answer: Dictionary = {"ok": true, "nodePath": node_path, "properties": props}
|
|
657
|
+
if node != scene.root and node.owner != null and not node.scene_file_path.is_empty():
|
|
658
|
+
answer["instanceOf"] = node.scene_file_path
|
|
659
|
+
answer["editableChildren"] = scene.root.is_editable_instance(node)
|
|
660
|
+
scene.close()
|
|
619
661
|
# Only an editor holds anything unsaved; a headless engine answering false would say it looked.
|
|
620
662
|
if Engine.is_editor_hint():
|
|
621
663
|
answer["unsavedInEditor"] = SceneFile.unsaved(scene_path)
|
|
@@ -770,7 +812,7 @@ func connect_signal(args: Dictionary) -> Dictionary:
|
|
|
770
812
|
"targetNodePath": to,
|
|
771
813
|
"methodName": method_name,
|
|
772
814
|
"flags": saved_flags[0],
|
|
773
|
-
"flagNames":
|
|
815
|
+
"flagNames": SceneFile.flag_names(Read.as_int(saved_flags[0])),
|
|
774
816
|
# Connected either way, as the editor's own dialog allows, since the method may be written
|
|
775
817
|
# next; a caller told nothing learnt of a misspelt one only when the signal fired.
|
|
776
818
|
"methodFound": method_found
|
|
@@ -781,7 +823,7 @@ func connect_signal(args: Dictionary) -> Dictionary:
|
|
|
781
823
|
if flags_before >= 0:
|
|
782
824
|
answer["alreadyConnected"] = true
|
|
783
825
|
if flags_before != Read.as_int(saved_flags[0]):
|
|
784
|
-
answer["flagsBefore"] =
|
|
826
|
+
answer["flagsBefore"] = SceneFile.flag_names(flags_before)
|
|
785
827
|
return answer
|
|
786
828
|
|
|
787
829
|
|
|
@@ -934,7 +976,7 @@ func list_connections(args: Dictionary) -> Dictionary:
|
|
|
934
976
|
"targetNodePath": target_path,
|
|
935
977
|
"methodName": str(callable.get_method()),
|
|
936
978
|
"flags": flags,
|
|
937
|
-
"flagNames":
|
|
979
|
+
"flagNames": SceneFile.flag_names(flags),
|
|
938
980
|
# False for a connection an instanced scene makes inside itself, which only that
|
|
939
981
|
# scene can change.
|
|
940
982
|
"editable": editable
|
|
@@ -22,6 +22,9 @@ extends RefCounted
|
|
|
22
22
|
# number was expected. Absent keys never reach here: the callers pass their own default to
|
|
23
23
|
# `Dictionary.get`, so what arrives is that default.
|
|
24
24
|
|
|
25
|
+
## How many of a node's children a refusal for a path missing below it names.
|
|
26
|
+
const NAMED_CHILDREN: int = 12
|
|
27
|
+
|
|
25
28
|
|
|
26
29
|
static func as_int(value: Variant, fallback: int = 0) -> int:
|
|
27
30
|
if value is int:
|
|
@@ -114,3 +117,25 @@ static func from_the_root(said: String, node_path: String, root_name: String) ->
|
|
|
114
117
|
if not rest.is_empty():
|
|
115
118
|
how += ', so this one is "%s"' % rest
|
|
116
119
|
return "%s%s %s." % [said, "" if said.ends_with(".") else ".", how]
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
## [param said], the refusal for a path a scene does not have, with where the path leaves it: the
|
|
123
|
+
## last node of the path it has, [param reached] from the root, called [param root_name], when that
|
|
124
|
+
## is empty; the name below it that is missing; and [param children], the names that node has, as
|
|
125
|
+
## after a node was moved or renamed. Names up to [constant NAMED_CHILDREN] of them.
|
|
126
|
+
static func missing_below(
|
|
127
|
+
said: String, root_name: String, reached: PackedStringArray, missing: String, children: PackedStringArray
|
|
128
|
+
) -> String:
|
|
129
|
+
var shown: String = ", ".join(children.slice(0, NAMED_CHILDREN))
|
|
130
|
+
if children.size() > NAMED_CHILDREN:
|
|
131
|
+
shown += " and %d more" % (children.size() - NAMED_CHILDREN)
|
|
132
|
+
return (
|
|
133
|
+
"%s%s %s has no %s; %s."
|
|
134
|
+
% [
|
|
135
|
+
said,
|
|
136
|
+
"" if said.ends_with(".") else ".",
|
|
137
|
+
"The root, %s," % root_name if reached.is_empty() else "/".join(reached),
|
|
138
|
+
missing,
|
|
139
|
+
"its children are " + shown if not children.is_empty() else "it has no children",
|
|
140
|
+
]
|
|
141
|
+
)
|
|
@@ -23,7 +23,7 @@ const Typing = preload("runtime_typing.gd")
|
|
|
23
23
|
const Values = preload("runtime_values.gd")
|
|
24
24
|
const Waits = preload("runtime_waits.gd")
|
|
25
25
|
|
|
26
|
-
const PROTOCOL: int =
|
|
26
|
+
const PROTOCOL: int = 3
|
|
27
27
|
const DEFAULT_BIND_ADDRESS: String = "127.0.0.1"
|
|
28
28
|
const BIND_ADDRESS_SETTING: String = "gdharness/runtime/bind_address"
|
|
29
29
|
## 0 asks the operating system for a free port, which is the default and what the server
|
|
@@ -502,7 +502,7 @@ func _announce(bind_address: String) -> void:
|
|
|
502
502
|
# Written whole under a name no server reads and moved into place, so no look ever meets
|
|
503
503
|
# the file empty: a server sweeping the directory between an open and a write took the
|
|
504
504
|
# announcement for a dead game's leftover, and the directory is shared by every server on
|
|
505
|
-
# the machine
|
|
505
|
+
# the machine.
|
|
506
506
|
var staged: String = path + ".tmp"
|
|
507
507
|
var file: FileAccess = FileAccess.open(staged, FileAccess.WRITE)
|
|
508
508
|
if file == null:
|
|
@@ -36,6 +36,35 @@ func capture_viewport(params: Dictionary) -> Dictionary:
|
|
|
36
36
|
if not node is Viewport:
|
|
37
37
|
return {"type": "error", "message": "Node is not a Viewport: " + viewport_path}
|
|
38
38
|
var viewport: Viewport = node
|
|
39
|
+
# The root's own state is refused in _capture. Another window of the game's that is hidden or
|
|
40
|
+
# minimised holds no frame, and asking it for its image makes the engine log the empty read into
|
|
41
|
+
# the game's output, so the run would stop unclean for an error the capture raised.
|
|
42
|
+
if viewport is Window and viewport != _host.get_tree().root:
|
|
43
|
+
var window: Window = viewport
|
|
44
|
+
if not window.visible:
|
|
45
|
+
return {
|
|
46
|
+
"type": "error",
|
|
47
|
+
"message":
|
|
48
|
+
(
|
|
49
|
+
(
|
|
50
|
+
"The Window at %s is hidden, so nothing is drawn to it. Show it (its visible "
|
|
51
|
+
+ "property) and ask again."
|
|
52
|
+
)
|
|
53
|
+
% viewport_path
|
|
54
|
+
),
|
|
55
|
+
}
|
|
56
|
+
if not window.can_draw():
|
|
57
|
+
return {
|
|
58
|
+
"type": "error",
|
|
59
|
+
"message":
|
|
60
|
+
(
|
|
61
|
+
(
|
|
62
|
+
"Nothing is being drawn to the Window at %s, which is minimised. Restore it and "
|
|
63
|
+
+ "ask again."
|
|
64
|
+
)
|
|
65
|
+
% viewport_path
|
|
66
|
+
),
|
|
67
|
+
}
|
|
39
68
|
if not viewport is SubViewport:
|
|
40
69
|
return await _capture(viewport, params)
|
|
41
70
|
# Drawn now rather than taken as it stands. A SubViewport the game does not redraw every frame
|
|
@@ -284,7 +284,7 @@ func _glyph_of(keycode: Key, shifted: bool) -> int:
|
|
|
284
284
|
## `pressed` is how a caller asks for one half, the way a drag is made: true holds the button down,
|
|
285
285
|
## false lets go of one being held.
|
|
286
286
|
func inject_mouse_click(params: Dictionary) -> Dictionary:
|
|
287
|
-
var point: Variant = Mouse.read_point(params, "x", "y"
|
|
287
|
+
var point: Variant = Mouse.read_point(params, "x", "y")
|
|
288
288
|
if point is String:
|
|
289
289
|
return {"type": "error", "message": point}
|
|
290
290
|
var position: Vector2 = point
|
|
@@ -349,7 +349,7 @@ func inject_mouse_click(params: Dictionary) -> Dictionary:
|
|
|
349
349
|
## would have carried. A relative the caller gives is kept, since a game may want to read a motion
|
|
350
350
|
## the position does not show.
|
|
351
351
|
func inject_mouse_motion(params: Dictionary) -> Dictionary:
|
|
352
|
-
var point: Variant = Mouse.read_point(params, "x", "y"
|
|
352
|
+
var point: Variant = Mouse.read_point(params, "x", "y")
|
|
353
353
|
if point is String:
|
|
354
354
|
return {"type": "error", "message": point}
|
|
355
355
|
var position: Vector2 = point
|
|
@@ -358,11 +358,6 @@ func inject_mouse_motion(params: Dictionary) -> Dictionary:
|
|
|
358
358
|
relative = Vector2(
|
|
359
359
|
Read.as_float(params.get("relativeX", 0.0)), Read.as_float(params.get("relativeY", 0.0))
|
|
360
360
|
)
|
|
361
|
-
elif params.has("relative"):
|
|
362
|
-
var movement: Variant = Mouse.read_point(params, "relativeX", "relativeY", "relative")
|
|
363
|
-
if movement is String:
|
|
364
|
-
return {"type": "error", "message": movement}
|
|
365
|
-
relative = movement
|
|
366
361
|
|
|
367
362
|
var supplied: bool = _follow_in_the_window(position)
|
|
368
363
|
Input.parse_input_event(_motion(position, relative))
|
|
@@ -6,20 +6,12 @@ extends RefCounted
|
|
|
6
6
|
const Read = preload("reading.gd")
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
## A point the tool schema sends as two flat numbers, or the
|
|
10
|
-
##
|
|
11
|
-
static func read_point(params: Dictionary, x_key: String, y_key: String
|
|
12
|
-
if params.has(x_key)
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
if raw is Vector2:
|
|
16
|
-
return raw
|
|
17
|
-
if raw is Array:
|
|
18
|
-
var pair: Array = raw
|
|
19
|
-
if pair.size() < 2:
|
|
20
|
-
return "%s array must contain [x, y]" % pair_key
|
|
21
|
-
return Vector2(Read.as_float(pair[0]), Read.as_float(pair[1]))
|
|
22
|
-
return "%s must be Vector2 or [x, y]" % pair_key
|
|
9
|
+
## A point the tool schema sends as two flat numbers. Answers a Vector2, or the String that says
|
|
10
|
+
## which was missing.
|
|
11
|
+
static func read_point(params: Dictionary, x_key: String, y_key: String) -> Variant:
|
|
12
|
+
if not params.has(x_key) or not params.has(y_key):
|
|
13
|
+
return "%s and %s are both needed." % [x_key, y_key]
|
|
14
|
+
return Vector2(Read.as_float(params[x_key]), Read.as_float(params[y_key]))
|
|
23
15
|
|
|
24
16
|
|
|
25
17
|
## The points of a drag: x, y, then each of via, then toX, toY. Answers the String saying what is
|
|
@@ -664,8 +664,12 @@ func _serialize_array(value: Array) -> Array:
|
|
|
664
664
|
|
|
665
665
|
# Base64 rather than a list of numbers. A byte array is a texture, a sound or a save file often
|
|
666
666
|
# enough that the list would be the whole answer, megabytes of it, and unreadable either way.
|
|
667
|
+
#
|
|
668
|
+
# The engine's encoder raises an error on an empty array, and an empty tile_map_data is every
|
|
669
|
+
# TileMapLayer with nothing painted yet, so a read of one carried an engine error in its answer.
|
|
667
670
|
func _serialize_bytes(value: PackedByteArray) -> Dictionary:
|
|
668
|
-
|
|
671
|
+
var text: String = "" if value.is_empty() else Marshalls.raw_to_base64(value)
|
|
672
|
+
return {"base64": text, "size": value.size(), "_type": "PackedByteArray"}
|
|
669
673
|
|
|
670
674
|
|
|
671
675
|
# The packed vector and colour arrays, each element serialised the way one of them on its own is.
|
|
@@ -62,10 +62,13 @@ static func _bare(scene_path: String, node_path: String, kind: String) -> Array:
|
|
|
62
62
|
var type: String = str(read.get("type", ""))
|
|
63
63
|
if not ClassDB.class_exists(type) or not ClassDB.is_parent_class(type, kind):
|
|
64
64
|
var said: String = "%s not found at: %s" % [kind, node_path]
|
|
65
|
-
if read.is_empty()
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
if read.is_empty():
|
|
66
|
+
var hinted: String = said
|
|
67
|
+
if FileReads.scene_node(scene_path, node_path.get_slice("/", 0)).is_empty():
|
|
68
|
+
hinted = Read.from_the_root(
|
|
69
|
+
said, node_path, str(FileReads.scene_node(scene_path, ".").get("name", ""))
|
|
70
|
+
)
|
|
71
|
+
said = hinted if hinted != said else FileReads.missing_from(said, scene_path, node_path)
|
|
69
72
|
return [null, {"ok": false, "error": said}]
|
|
70
73
|
var bare: Node = ClassDB.instantiate(type)
|
|
71
74
|
bare.name = str(read["name"])
|
|
@@ -10,6 +10,7 @@ extends RefCounted
|
|
|
10
10
|
const AnimationTools = preload("../addons/gdharness_editor/tools/animation_tools.gd")
|
|
11
11
|
const ResourceTools = preload("../addons/gdharness_editor/tools/resource_tools.gd")
|
|
12
12
|
const SceneTools = preload("../addons/gdharness_editor/tools/scene_tools.gd")
|
|
13
|
+
const SceneFile = preload("../addons/gdharness_editor/scene_file.gd")
|
|
13
14
|
|
|
14
15
|
const SCENE_COMMANDS: Array[String] = [
|
|
15
16
|
"create_scene",
|
|
@@ -60,7 +61,24 @@ static func run(params: Dictionary) -> Dictionary:
|
|
|
60
61
|
var answer: Variant = tools.call(command, arguments)
|
|
61
62
|
tools.free()
|
|
62
63
|
if answer is Dictionary:
|
|
63
|
-
|
|
64
|
+
var answered: Dictionary = answer
|
|
65
|
+
if not SceneFile.by_path.is_empty():
|
|
66
|
+
answered["namedByPath"] = (
|
|
67
|
+
(
|
|
68
|
+
"%s %s named by path rather than by uid. A uid in a file's own header is resolved "
|
|
69
|
+
+ "through the project's uid cache, which holds none for %s yet, as with a file "
|
|
70
|
+
+ "made since the project was last scanned, and a uid it does not hold would warn "
|
|
71
|
+
+ "on every load. project_import refresh_uids scans the project, and writes after "
|
|
72
|
+
+ "it name %s by uid."
|
|
73
|
+
)
|
|
74
|
+
% [
|
|
75
|
+
", ".join(SceneFile.by_path),
|
|
76
|
+
"is" if SceneFile.by_path.size() == 1 else "are",
|
|
77
|
+
"it" if SceneFile.by_path.size() == 1 else "them",
|
|
78
|
+
"it" if SceneFile.by_path.size() == 1 else "them",
|
|
79
|
+
]
|
|
80
|
+
)
|
|
81
|
+
return answered
|
|
64
82
|
return {
|
|
65
83
|
"ok": false, "error": "%s answered %s rather than an object." % [command, type_string(typeof(answer))]
|
|
66
84
|
}
|