@@ -67,6 +67,10 @@ const FORMAT_STRING_PATTERN = "\\[(?<out_parameter>[^\\]]+)\\]|\\{const (?<const
67
67
## Empty except for blocks that have a defined scope.
68
68
var scope : String
69
69
70
+ ## Optional property name, for localizing it. Only relevant for property setters, changers and
71
+ ## getters.
72
+ var property_name : String
73
+
70
74
static var _display_template_regex := RegEx .create_from_string (FORMAT_STRING_PATTERN )
71
75
72
76
@@ -198,42 +202,48 @@ static func has_category(block_definition, category: String) -> bool:
198
202
199
203
static func new_property_setter (_class_name : String , property : Dictionary , category : String , default_value : Variant ) -> Resource :
200
204
var type_string : String = Types .VARIANT_TYPE_TO_STRING [property .type ]
201
- return new (
205
+ var block_definition : Resource = new (
202
206
& "% s_set_% s" % [_class_name , property .name ],
203
207
_class_name ,
204
208
"Set the %s property" % property .name ,
205
209
category ,
206
210
Types .BlockType .STATEMENT ,
207
211
TYPE_NIL ,
208
- "set %s to {value: %s} " % [ property . name . capitalize (). to_lower (), type_string ] ,
212
+ "set %% s to {value: %s} " % type_string ,
209
213
"%s = {value} " % property .name ,
210
214
{"value" : default_value },
211
215
)
216
+ block_definition .property_name = property .name
217
+ return block_definition
212
218
213
219
214
220
static func new_property_changer (_class_name : String , property : Dictionary , category : String , default_value : Variant ) -> Resource :
215
221
var type_string : String = Types .VARIANT_TYPE_TO_STRING [property .type ]
216
- return new (
222
+ var block_definition : Resource = new (
217
223
& "% s_change_% s" % [_class_name , property .name ],
218
224
_class_name ,
219
225
"Change the %s property" % property .name ,
220
226
category ,
221
227
Types .BlockType .STATEMENT ,
222
228
TYPE_NIL ,
223
- "change %s by {value: %s} " % [ property . name . capitalize (). to_lower (), type_string ] ,
229
+ "change %% s by {value: %s} " % type_string ,
224
230
"%s += {value} " % property .name ,
225
231
{"value" : default_value },
226
232
)
233
+ block_definition .property_name = property .name
234
+ return block_definition
227
235
228
236
229
237
static func new_property_getter (_class_name : String , property : Dictionary , category : String ) -> Resource :
230
- return new (
238
+ var block_definition : Resource = new (
231
239
& "% s_get_% s" % [_class_name , property .name ],
232
240
_class_name ,
233
241
"The %s property" % property .name ,
234
242
category ,
235
243
Types .BlockType .VALUE ,
236
244
property .type ,
237
- "%s " % property . name . capitalize (). to_lower () ,
245
+ "%s " ,
238
246
"%s " % property .name ,
239
247
)
248
+ block_definition .property_name = property .name
249
+ return block_definition
0 commit comments