@@ -32,6 +32,9 @@ const FORMAT_STRING_PATTERN = "\\[(?<out_parameter>[^\\]]+)\\]|\\{const (?<const
32
32
## [codeblock]
33
33
## say {salute: STRING} | {fancy: BOOL}
34
34
## [/codeblock]
35
+ ## If [member property_name] is set, this template is assumed to be a format
36
+ ## string with a `%s` placeholder; in this case, any literal `%` signs must
37
+ ## be escaped as `%%`.
35
38
@export var display_template : String
36
39
37
40
## Template for the generated GDScript code. This must be valid GDScript. The
@@ -67,6 +70,10 @@ const FORMAT_STRING_PATTERN = "\\[(?<out_parameter>[^\\]]+)\\]|\\{const (?<const
67
70
## Empty except for blocks that have a defined scope.
68
71
var scope : String
69
72
73
+ ## Optional property name, for localizing it. Only relevant for property setters, changers and
74
+ ## getters.
75
+ var property_name : String
76
+
70
77
static var _display_template_regex := RegEx .create_from_string (FORMAT_STRING_PATTERN )
71
78
72
79
@@ -198,42 +205,48 @@ static func has_category(block_definition, category: String) -> bool:
198
205
199
206
static func new_property_setter (_class_name : String , property : Dictionary , category : String , default_value : Variant ) -> Resource :
200
207
var type_string : String = Types .VARIANT_TYPE_TO_STRING [property .type ]
201
- return new (
208
+ var block_definition : Resource = new (
202
209
& "% s_set_% s" % [_class_name , property .name ],
203
210
_class_name ,
204
211
"Set the %s property" % property .name ,
205
212
category ,
206
213
Types .BlockType .STATEMENT ,
207
214
TYPE_NIL ,
208
- "set %s to {value: %s} " % [ property . name . capitalize (). to_lower (), type_string ] ,
215
+ "set %% s to {value: %s} " % type_string ,
209
216
"%s = {value} " % property .name ,
210
217
{"value" : default_value },
211
218
)
219
+ block_definition .property_name = property .name
220
+ return block_definition
212
221
213
222
214
223
static func new_property_changer (_class_name : String , property : Dictionary , category : String , default_value : Variant ) -> Resource :
215
224
var type_string : String = Types .VARIANT_TYPE_TO_STRING [property .type ]
216
- return new (
225
+ var block_definition : Resource = new (
217
226
& "% s_change_% s" % [_class_name , property .name ],
218
227
_class_name ,
219
228
"Change the %s property" % property .name ,
220
229
category ,
221
230
Types .BlockType .STATEMENT ,
222
231
TYPE_NIL ,
223
- "change %s by {value: %s} " % [ property . name . capitalize (). to_lower (), type_string ] ,
232
+ "change %% s by {value: %s} " % type_string ,
224
233
"%s += {value} " % property .name ,
225
234
{"value" : default_value },
226
235
)
236
+ block_definition .property_name = property .name
237
+ return block_definition
227
238
228
239
229
240
static func new_property_getter (_class_name : String , property : Dictionary , category : String ) -> Resource :
230
- return new (
241
+ var block_definition : Resource = new (
231
242
& "% s_get_% s" % [_class_name , property .name ],
232
243
_class_name ,
233
244
"The %s property" % property .name ,
234
245
category ,
235
246
Types .BlockType .VALUE ,
236
247
property .type ,
237
- "%s " % property . name . capitalize (). to_lower () ,
248
+ "%s " ,
238
249
"%s " % property .name ,
239
250
)
251
+ block_definition .property_name = property .name
252
+ return block_definition
0 commit comments