gdharness 1.3.1 → 1.3.2
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 +311 -86
- package/build/godot/addons/gdharness_editor/declared_values.gd +116 -0
- package/build/godot/addons/gdharness_editor/declared_values.gd.uid +1 -0
- package/build/godot/addons/gdharness_editor/file_reads.gd +5 -0
- package/build/godot/addons/gdharness_editor/property_values.gd +106 -10
- package/build/godot/addons/gdharness_editor/reading.gd +37 -0
- package/build/godot/addons/gdharness_editor/serialisation.gd +4 -0
- package/build/godot/addons/gdharness_editor/tools/resource_tools.gd +133 -39
- package/build/godot/addons/gdharness_editor/tools/scene_tools.gd +9 -9
- package/build/godot/addons/gdharness_editor/value_shapes.gd +7 -0
- package/build/godot/addons/gdharness_runtime/reading.gd +37 -0
- package/build/godot/addons/gdharness_runtime/runtime_values.gd +27 -1
- package/build/godot/addons/gdharness_runtime/serialisation.gd +4 -0
- package/build/godot/addons/gdharness_runtime/value_shapes.gd +7 -0
- package/build/godot/operations/classdb_queries.gd +13 -3
- package/build/godot/operations/declared_values.gd +116 -0
- package/build/godot/operations/dependencies.gd +109 -5
- package/build/godot/operations/export_presets.gd +4 -6
- package/build/godot/operations/file_reads.gd +5 -0
- package/build/godot/operations/file_walk.gd +34 -0
- package/build/godot/operations/gdscript_analysis.gd +7 -2
- package/build/godot/operations/gdscript_authoring.gd +105 -2
- package/build/godot/operations/godot_operations.gd +2 -0
- package/build/godot/operations/import_pipeline.gd +39 -0
- package/build/godot/operations/input_actions.gd +73 -1
- package/build/godot/operations/project_config.gd +59 -3
- package/build/godot/operations/project_diagnostics.gd +27 -2
- package/build/godot/operations/property_values.gd +106 -10
- package/build/godot/operations/reading.gd +37 -0
- package/build/godot/operations/resource_files.gd +4 -1
- package/build/godot/operations/script_check.gd +16 -0
- package/build/godot/operations/serialisation.gd +4 -0
- package/build/godot/operations/value_shapes.gd +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
extends RefCounted
|
|
3
|
+
|
|
4
|
+
## What a property declares beyond its type: the values of its enum and the range it is exported
|
|
5
|
+
## with, for taking a value by name and for saying when a value written lies outside them.
|
|
6
|
+
|
|
7
|
+
const GdhRead = preload("reading.gd")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## The values an enum hint names, by name, from its hint string: "SWORD:0,SHIELD:1" as a script
|
|
11
|
+
## declares one, or "Add,Subtract" as an engine property does, each name then taking the number
|
|
12
|
+
## after the one before it.
|
|
13
|
+
static func enum_values(hint_string: String) -> Dictionary:
|
|
14
|
+
var values: Dictionary = {}
|
|
15
|
+
var next: int = 0
|
|
16
|
+
for entry: String in hint_string.split(",", false):
|
|
17
|
+
var name: String = entry.get_slice(":", 0).strip_edges()
|
|
18
|
+
var number: String = entry.get_slice(":", 1).strip_edges() if ":" in entry else ""
|
|
19
|
+
var value: int = number.to_int() if number.is_valid_int() else next
|
|
20
|
+
values[name] = value
|
|
21
|
+
next = value + 1
|
|
22
|
+
return values
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## The values of the enum [param declared] declares, by name, spelt as the script of [param target]
|
|
26
|
+
## spells them when it declares that enum. The engine's hint capitalises each name, "SWORD" as
|
|
27
|
+
## "Sword", and a refusal listing those named values the script never spells.
|
|
28
|
+
static func enum_of(target: Object, declared: Dictionary) -> Dictionary:
|
|
29
|
+
var hinted: Dictionary = enum_values(str(declared.get("hint_string", "")))
|
|
30
|
+
var attached: Variant = target.get_script()
|
|
31
|
+
if not attached is Script:
|
|
32
|
+
return hinted
|
|
33
|
+
var script: Script = attached
|
|
34
|
+
for constant: Variant in script.get_script_constant_map().values():
|
|
35
|
+
if not constant is Dictionary:
|
|
36
|
+
continue
|
|
37
|
+
var values: Dictionary = constant
|
|
38
|
+
if values.size() != hinted.size():
|
|
39
|
+
continue
|
|
40
|
+
var spelt: Dictionary = {}
|
|
41
|
+
for name: Variant in values:
|
|
42
|
+
if hinted.get(str(name).capitalize()) == values[name]:
|
|
43
|
+
spelt[str(name)] = values[name]
|
|
44
|
+
if spelt.size() == hinted.size():
|
|
45
|
+
return spelt
|
|
46
|
+
return hinted
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## The number [param word] names among [param choices], matched as written and then ignoring case,
|
|
50
|
+
## or null when it names none.
|
|
51
|
+
static func enum_named(choices: Dictionary, word: String) -> Variant:
|
|
52
|
+
var wanted: String = word.strip_edges()
|
|
53
|
+
if choices.has(wanted):
|
|
54
|
+
return choices[wanted]
|
|
55
|
+
for name: String in choices:
|
|
56
|
+
if name.to_lower() == wanted.to_lower():
|
|
57
|
+
return choices[name]
|
|
58
|
+
return null
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
static func enum_refusal(holder: String, property: String, word: String, choices: Dictionary) -> String:
|
|
62
|
+
var said: String = (
|
|
63
|
+
"%s.%s is an enum, and %s is none of its values: send %s by name or by number"
|
|
64
|
+
% [holder, property, word, _listed(choices)]
|
|
65
|
+
)
|
|
66
|
+
var close: PackedStringArray = GdhRead.nearest(word, PackedStringArray(choices.keys()))
|
|
67
|
+
if close.is_empty():
|
|
68
|
+
return said + "."
|
|
69
|
+
return said + ". The nearest %s %s." % ["is" if close.size() == 1 else "are", ", ".join(close)]
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
## Why [param value], shown as [param shown], lies outside what [param declared] allows, an export
|
|
73
|
+
## range or an enum's values, or "" when it does not. A range marked or_greater or or_less is open
|
|
74
|
+
## on that side.
|
|
75
|
+
static func outside(target: Object, declared: Dictionary, value: Variant, shown: String) -> String:
|
|
76
|
+
var hint: int = GdhRead.as_int(declared.get("hint", PROPERTY_HINT_NONE))
|
|
77
|
+
var hint_string: String = str(declared.get("hint_string", ""))
|
|
78
|
+
var property: String = str(declared.get("name", ""))
|
|
79
|
+
if typeof(value) != TYPE_INT and typeof(value) != TYPE_FLOAT:
|
|
80
|
+
return ""
|
|
81
|
+
var number: float = GdhRead.as_float(value)
|
|
82
|
+
if hint == PROPERTY_HINT_ENUM and typeof(value) == TYPE_INT:
|
|
83
|
+
var choices: Dictionary = enum_of(target, declared)
|
|
84
|
+
if choices.is_empty() or choices.values().has(value):
|
|
85
|
+
return ""
|
|
86
|
+
return "%d is none of the values %s declares: %s." % [value, property, _listed(choices)]
|
|
87
|
+
if hint != PROPERTY_HINT_RANGE:
|
|
88
|
+
return ""
|
|
89
|
+
var parts: PackedStringArray = []
|
|
90
|
+
for part: String in hint_string.split(","):
|
|
91
|
+
var _added: bool = parts.append(part.strip_edges())
|
|
92
|
+
if parts.size() < 2 or not parts[0].is_valid_float() or not parts[1].is_valid_float():
|
|
93
|
+
return ""
|
|
94
|
+
var low: float = parts[0].to_float()
|
|
95
|
+
var high: float = parts[1].to_float()
|
|
96
|
+
if (number <= high or parts.has("or_greater")) and (number >= low or parts.has("or_less")):
|
|
97
|
+
return ""
|
|
98
|
+
return (
|
|
99
|
+
(
|
|
100
|
+
"%s is outside the range %s declares, %s to %s, which the inspector holds it to; the "
|
|
101
|
+
+ "engine stores it as given."
|
|
102
|
+
)
|
|
103
|
+
% [shown, property, _bound(low), _bound(high)]
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
static func _listed(choices: Dictionary) -> String:
|
|
108
|
+
var listed: PackedStringArray = []
|
|
109
|
+
for name: String in choices:
|
|
110
|
+
var _added: bool = listed.append("%s (%d)" % [name, choices[name]])
|
|
111
|
+
return ", ".join(listed)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
## A range's end as the script wrote it: the engine's hint gives @export_range(0, 10) as 0.0 and 10.0.
|
|
115
|
+
static func _bound(end: float) -> String:
|
|
116
|
+
return str(int(end)) if end == floorf(end) and absf(end) < 1e15 else str(end)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
uid://c2bcafdf9rzgo
|
|
@@ -427,6 +427,11 @@ static func resource(res_path: String, include_defaults: bool) -> Dictionary:
|
|
|
427
427
|
}
|
|
428
428
|
if script != null:
|
|
429
429
|
answer["script"] = script.resource_path
|
|
430
|
+
# resourceType is the engine class under the script, which for a class the project declares
|
|
431
|
+
# is Resource whatever create was given.
|
|
432
|
+
var declared_class: String = str(script.get_global_name())
|
|
433
|
+
if not declared_class.is_empty():
|
|
434
|
+
answer["scriptClass"] = declared_class
|
|
430
435
|
return answer
|
|
431
436
|
|
|
432
437
|
|
|
@@ -14,6 +14,7 @@ extends RefCounted
|
|
|
14
14
|
## write accepts. What is here on top of it is the part only a property knows: the type wanted, so a
|
|
15
15
|
## dictionary shaped like a vector or a bare pair of numbers can be read as one.
|
|
16
16
|
|
|
17
|
+
const GdhDeclared = preload("declared_values.gd")
|
|
17
18
|
const GdhRead = preload("reading.gd")
|
|
18
19
|
const GdhSerialisation = preload("serialisation.gd")
|
|
19
20
|
const GdhShapes = preload("value_shapes.gd")
|
|
@@ -78,6 +79,11 @@ var _refused: String = ""
|
|
|
78
79
|
# offsets. An answer naming only what was given leaves the caller to guess the rest.
|
|
79
80
|
var _also_changed: Dictionary = {}
|
|
80
81
|
|
|
82
|
+
# The values the last write_all wrote outside what their property declares, by name, as a sentence
|
|
83
|
+
# saying so: a number past an export range, or one no enum value has. The engine stores either, and
|
|
84
|
+
# the inspector would not have let it be entered, so a write answered as made said nothing of it.
|
|
85
|
+
var _outside_declared: Dictionary = {}
|
|
86
|
+
|
|
81
87
|
|
|
82
88
|
## Turns what arrived over the wire into the Godot value a property wants.
|
|
83
89
|
##
|
|
@@ -177,23 +183,34 @@ func cannot_hold(
|
|
|
177
183
|
## caller returns the refusal instead of saving.
|
|
178
184
|
func write_all(target: Object, properties: Dictionary) -> String:
|
|
179
185
|
_also_changed = {}
|
|
186
|
+
_outside_declared = {}
|
|
180
187
|
var named: Dictionary = {}
|
|
181
188
|
for key: Variant in properties:
|
|
182
189
|
named[str(key).get_slice(":", 0)] = true
|
|
183
190
|
var before: Dictionary = _stored(target, named)
|
|
184
191
|
var given: Dictionary = {}
|
|
192
|
+
# A refusal of one of several leaves the others unwritten too, which a refusal naming only the
|
|
193
|
+
# one it refused left a caller to guess.
|
|
194
|
+
var unwritten: String = (
|
|
195
|
+
"" if properties.size() < 2 else " None of the %d properties given was written." % properties.size()
|
|
196
|
+
)
|
|
185
197
|
for key: Variant in properties:
|
|
186
198
|
var property: String = str(key)
|
|
187
199
|
var declared: Dictionary = declaration(target, property)
|
|
188
200
|
if declared.is_empty() and ":" in property:
|
|
189
201
|
declared = _component_slot(target, property)
|
|
190
202
|
if declared.has("refused"):
|
|
191
|
-
return str(declared["refused"])
|
|
203
|
+
return str(declared["refused"]) + unwritten
|
|
204
|
+
if declared.is_empty() and target is ShaderMaterial and property.begins_with("shader_parameter/"):
|
|
205
|
+
return _no_uniform(target as ShaderMaterial, property) + unwritten
|
|
192
206
|
if declared.is_empty():
|
|
193
|
-
return "%s has no property %s" % [target
|
|
207
|
+
return "%s has no property %s." % [class_called(target), property] + unwritten
|
|
194
208
|
var value: Array = value_for(target, declared, properties[key])
|
|
195
209
|
if not value[0]:
|
|
196
|
-
return str(value[1])
|
|
210
|
+
return str(value[1]) + unwritten
|
|
211
|
+
var outside: String = GdhDeclared.outside(target, declared, value[1], shown(value[1]))
|
|
212
|
+
if not outside.is_empty():
|
|
213
|
+
_outside_declared[property] = outside
|
|
197
214
|
_write(target, property, value[1])
|
|
198
215
|
given[property] = value[1]
|
|
199
216
|
|
|
@@ -217,11 +234,32 @@ func write_all(target: Object, properties: Dictionary) -> String:
|
|
|
217
234
|
return ""
|
|
218
235
|
|
|
219
236
|
|
|
237
|
+
## Why [param material] has no [param property]: a ShaderMaterial's parameters are its shader's
|
|
238
|
+
## uniforms, so the shader is what lacks one, and "ShaderMaterial has no property" named the
|
|
239
|
+
## material.
|
|
240
|
+
static func _no_uniform(material: ShaderMaterial, property: String) -> String:
|
|
241
|
+
var uniform: String = property.trim_prefix("shader_parameter/")
|
|
242
|
+
if material.shader == null:
|
|
243
|
+
return "The ShaderMaterial has no shader, so it has no parameter %s yet; set shader first." % uniform
|
|
244
|
+
var shader: String = material.shader.resource_path
|
|
245
|
+
var named: String = shader if not shader.is_empty() else "Its shader"
|
|
246
|
+
var uniforms: Array = []
|
|
247
|
+
for entry: Dictionary in material.shader.get_shader_uniform_list():
|
|
248
|
+
uniforms.append(str(entry["name"]))
|
|
249
|
+
var said: String = "%s declares no uniform %s, which %s would set" % [named, uniform, property]
|
|
250
|
+
if uniforms.is_empty():
|
|
251
|
+
return said + "; it declares no uniforms."
|
|
252
|
+
return GdhRead.offered(said, uniform, uniforms) + "."
|
|
253
|
+
|
|
254
|
+
|
|
220
255
|
## Puts under alsoChanged in [param answer] each property the last [method write_all] changed
|
|
221
|
-
## without being given it, as {was, now},
|
|
222
|
-
##
|
|
223
|
-
##
|
|
224
|
-
|
|
256
|
+
## without being given it, as {was, now}, and under outsideDeclared each value it wrote outside what
|
|
257
|
+
## its property declares, when there are any. A node is named by its path from [param relative_to],
|
|
258
|
+
## as a scene answer names one. Called before the scene is written, since the write frees the nodes
|
|
259
|
+
## these values can hold.
|
|
260
|
+
func note_write(answer: Dictionary, relative_to: Node = null) -> void:
|
|
261
|
+
if not _outside_declared.is_empty():
|
|
262
|
+
answer["outsideDeclared"] = _outside_declared.duplicate()
|
|
225
263
|
if _also_changed.is_empty():
|
|
226
264
|
return
|
|
227
265
|
var noted: Dictionary = {}
|
|
@@ -324,6 +362,18 @@ func value_for(target: Object, declared: Dictionary, raw: Variant) -> Array:
|
|
|
324
362
|
var hint: int = GdhRead.as_int(declared.get("hint", PROPERTY_HINT_NONE))
|
|
325
363
|
if expected_type == TYPE_OBJECT and hint == PROPERTY_HINT_NODE_TYPE:
|
|
326
364
|
return _node_reference(target, property, raw)
|
|
365
|
+
# An enum is written by the name of a value as well as its number, since the name is what the
|
|
366
|
+
# script and the inspector show and the number is only where the value happens to sit.
|
|
367
|
+
if expected_type == TYPE_INT and hint == PROPERTY_HINT_ENUM and typeof(raw) == TYPE_STRING:
|
|
368
|
+
var choices: Dictionary = GdhDeclared.enum_of(target, declared)
|
|
369
|
+
var chosen: Variant = GdhDeclared.enum_named(choices, str(raw))
|
|
370
|
+
if chosen == null:
|
|
371
|
+
var hinted: Dictionary = GdhDeclared.enum_values(str(declared.get("hint_string", "")))
|
|
372
|
+
chosen = GdhDeclared.enum_named(hinted, str(raw))
|
|
373
|
+
if chosen != null:
|
|
374
|
+
return [true, chosen]
|
|
375
|
+
if not str(raw).strip_edges().is_valid_int():
|
|
376
|
+
return [false, GdhDeclared.enum_refusal(class_called(target), property, str(raw), choices)]
|
|
327
377
|
|
|
328
378
|
# A resource-valued property takes the path of one, which is how a caller names a TileSet,
|
|
329
379
|
# a material or a theme: there is no other way to hand a tool a Resource.
|
|
@@ -339,12 +389,12 @@ func value_for(target: Object, declared: Dictionary, raw: Variant) -> Array:
|
|
|
339
389
|
return [false, _fraction_refusal(target, property, raw)]
|
|
340
390
|
var rounded: String = GdhSerialisation.inexact(raw, expected_type)
|
|
341
391
|
if not rounded.is_empty():
|
|
342
|
-
return [false, "%s.%s holds int: %s." % [target
|
|
392
|
+
return [false, "%s.%s holds int: %s." % [class_called(target), property, rounded]]
|
|
343
393
|
_refused = ""
|
|
344
394
|
value = parse(raw, expected_type, elements)
|
|
345
395
|
if not _refused.is_empty():
|
|
346
396
|
return [false, _refused]
|
|
347
|
-
var refusal: String = cannot_hold(target
|
|
397
|
+
var refusal: String = cannot_hold(class_called(target), property, value, expected_type, elements)
|
|
348
398
|
if not refusal.is_empty():
|
|
349
399
|
return [false, refusal]
|
|
350
400
|
if value is Object:
|
|
@@ -489,10 +539,43 @@ func _fraction_refusal(target: Object, property: String, raw: Variant) -> String
|
|
|
489
539
|
"%s.%s holds whole numbers, and %s would be cut to fit. Setting it would save a different "
|
|
490
540
|
+ "value than the one asked for."
|
|
491
541
|
)
|
|
492
|
-
% [target
|
|
542
|
+
% [class_called(target), property, shown(raw)]
|
|
493
543
|
)
|
|
494
544
|
|
|
495
545
|
|
|
546
|
+
## [param raw] as a colour, read as a property write reads one, as [true, Color] or [false, why]:
|
|
547
|
+
## fields from 0 to 1 with a optional, or an html code. [param named] is what the refusal calls it.
|
|
548
|
+
func colour_from(raw: Variant, named: String) -> Array:
|
|
549
|
+
_refused = ""
|
|
550
|
+
var value: Variant = parse(raw, TYPE_COLOR)
|
|
551
|
+
if not _refused.is_empty():
|
|
552
|
+
return [false, _refused]
|
|
553
|
+
if value is Color:
|
|
554
|
+
return [true, value]
|
|
555
|
+
return [
|
|
556
|
+
false,
|
|
557
|
+
(
|
|
558
|
+
(
|
|
559
|
+
'%s is {"r": .., "g": .., "b": .., "a": ..} from 0 to 1, a optional, or an html code such as '
|
|
560
|
+
+ '"#ff8000" or "#ff800080"; %s is neither.'
|
|
561
|
+
)
|
|
562
|
+
% [named, JSON.stringify(raw)]
|
|
563
|
+
)
|
|
564
|
+
]
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
## What [param target] is called in a refusal: the class_name its script declares, or else its
|
|
568
|
+
## engine class. A resource made as a project class is a Resource to the engine, and "Resource.kind"
|
|
569
|
+
## named a property no Resource has.
|
|
570
|
+
static func class_called(target: Object) -> String:
|
|
571
|
+
var attached: Variant = target.get_script()
|
|
572
|
+
if attached is Script:
|
|
573
|
+
var script: Script = attached
|
|
574
|
+
if not str(script.get_global_name()).is_empty():
|
|
575
|
+
return str(script.get_global_name())
|
|
576
|
+
return target.get_class()
|
|
577
|
+
|
|
578
|
+
|
|
496
579
|
## The resource [param path] names, as [found, resource or why not].
|
|
497
580
|
##
|
|
498
581
|
## The project boundary is enforced here as well as on the server, because only the engine knows
|
|
@@ -516,6 +599,19 @@ func _resource_at(path: String, property: String) -> Array:
|
|
|
516
599
|
)
|
|
517
600
|
]
|
|
518
601
|
if not ResourceLoader.exists(path):
|
|
602
|
+
# An image or a sound nobody has imported is a file the engine has no loader for, and "No
|
|
603
|
+
# resource at" sent a caller looking for a file that was there.
|
|
604
|
+
if path.begins_with("res://") and FileAccess.file_exists(path):
|
|
605
|
+
return [
|
|
606
|
+
false,
|
|
607
|
+
(
|
|
608
|
+
(
|
|
609
|
+
"%s is there, but it has never been imported, so the engine has no resource to load"
|
|
610
|
+
+ " from it for %s. project_import reimport with resourcePath %s imports it."
|
|
611
|
+
)
|
|
612
|
+
% [path, property, path]
|
|
613
|
+
)
|
|
614
|
+
]
|
|
519
615
|
return [false, "No resource at %s for %s" % [path, property]]
|
|
520
616
|
return [true, load(path)]
|
|
521
617
|
|
|
@@ -164,6 +164,43 @@ static func not_of_kind(
|
|
|
164
164
|
return told + " The scene's %ss are at %s." % [kind, shown]
|
|
165
165
|
|
|
166
166
|
|
|
167
|
+
## Up to three of [param names] closest to [param word], closest first, ignoring case: the names a
|
|
168
|
+
## refusal offers for one that is not there, as a typo usually is one of them.
|
|
169
|
+
static func nearest(word: String, names: PackedStringArray) -> PackedStringArray:
|
|
170
|
+
var wanted: String = word.to_lower()
|
|
171
|
+
var close: Array[String] = []
|
|
172
|
+
for name: String in names:
|
|
173
|
+
if name.to_lower().similarity(wanted) >= 0.5:
|
|
174
|
+
close.append(name)
|
|
175
|
+
close.sort_custom(
|
|
176
|
+
func(a: String, b: String) -> bool:
|
|
177
|
+
return a.to_lower().similarity(wanted) > b.to_lower().similarity(wanted)
|
|
178
|
+
)
|
|
179
|
+
return PackedStringArray(close.slice(0, 3))
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
## [param said], the refusal for [param word], which is not among [param names], with those nearest
|
|
183
|
+
## it when any are, or else every one of them, so the caller has a name to send instead.
|
|
184
|
+
static func offered(said: String, word: String, names: Array) -> String:
|
|
185
|
+
var every: PackedStringArray = PackedStringArray(names)
|
|
186
|
+
var close: PackedStringArray = nearest(word, every)
|
|
187
|
+
if close.is_empty():
|
|
188
|
+
return "%s; it has %s" % [said, ", ".join(every)]
|
|
189
|
+
return "%s; the nearest it has %s %s" % [said, "is" if close.size() == 1 else "are", ", ".join(close)]
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
## The signals [param object] has that a caller can connect, its own class's first: the engine
|
|
193
|
+
## lists them from Object down, which puts a Button's pressed after thirty a Control has, and names
|
|
194
|
+
## starting with an underscore are the engine's own.
|
|
195
|
+
static func signals_of(object: Object) -> Array:
|
|
196
|
+
var names: Array = []
|
|
197
|
+
for entry: Dictionary in object.get_signal_list():
|
|
198
|
+
var name: String = str(entry["name"])
|
|
199
|
+
if not name.begins_with("_"):
|
|
200
|
+
names.push_front(name)
|
|
201
|
+
return names
|
|
202
|
+
|
|
203
|
+
|
|
167
204
|
## [param word] after the article it takes, "an AnimationTree" or "a Node2D".
|
|
168
205
|
static func with_article(word: String) -> String:
|
|
169
206
|
return ("an " if word.left(1).to_upper() in ["A", "E", "I", "O", "U"] else "a ") + word
|
|
@@ -410,6 +410,10 @@ func fitted(value: Variant, type: int) -> Variant:
|
|
|
410
410
|
var simple: Array[int] = [TYPE_BOOL, TYPE_INT, TYPE_FLOAT, TYPE_STRING]
|
|
411
411
|
if not simple.has(type) or not simple.has(typeof(rebuilt)):
|
|
412
412
|
return rebuilt
|
|
413
|
+
# A number or a truth value stays as sent where text is wanted, for the refusal to name. Converted,
|
|
414
|
+
# 1 arrived as the double it is in JSON and was saved as "1.0", which is not the text anyone sends.
|
|
415
|
+
if type == TYPE_STRING and not rebuilt is String:
|
|
416
|
+
return rebuilt
|
|
413
417
|
|
|
414
418
|
# Digits are read as digits, since read as JSON they become a double and one past 2^53 a
|
|
415
419
|
# neighbour of the number written.
|