1
1
class_name JSONProperty
2
2
3
3
4
- const PRECISION_ERROR = 0.000001
5
-
6
-
7
4
enum Types {
8
5
BOOL ,
9
6
NUMBER ,
@@ -19,50 +16,6 @@ enum Types {
19
16
IMAGE ,
20
17
}
21
18
22
-
23
- const MESSAGE_BOOL = "boolean"
24
- const MESSAGE_NUMBER = "number"
25
- const MESSAGE_INTEGER = "integer"
26
- const MESSAGE_PERCENTAGE = "percentage"
27
- const MESSAGE_STRING = "string"
28
- const MESSAGE_ENUM = "string"
29
- const MESSAGE_ARRAY = "array"
30
- const MESSAGE_COLOR = "color"
31
- const MESSAGE_OBJECT = "object"
32
- const MESSAGE_FILE = "file path"
33
- const MESSAGE_JSON_CONFIG_FILE = "JSON configuration file path"
34
- const MESSAGE_IMAGE = "image path"
35
-
36
-
37
- static func _type_as_text (type : int ) -> String :
38
- match type :
39
- Types .BOOL :
40
- return MESSAGE_BOOL
41
- Types .NUMBER :
42
- return MESSAGE_NUMBER
43
- Types .INTEGER :
44
- return MESSAGE_INTEGER
45
- Types .PERCENTAGE :
46
- return MESSAGE_PERCENTAGE
47
- Types .STRING :
48
- return MESSAGE_STRING
49
- Types .ENUM :
50
- return MESSAGE_ENUM
51
- Types .ARRAY :
52
- return MESSAGE_ARRAY
53
- Types .COLOR :
54
- return MESSAGE_COLOR
55
- Types .OBJECT :
56
- return MESSAGE_OBJECT
57
- Types .FILE :
58
- return MESSAGE_FILE
59
- Types .JSON_CONFIG_FILE :
60
- return MESSAGE_JSON_CONFIG_FILE
61
- Types .IMAGE :
62
- return MESSAGE_IMAGE
63
- _ :
64
- return "This type message is not defined"
65
-
66
19
enum Errors {
67
20
COULD_NOT_OPEN_FILE ,
68
21
COULD_NOT_OPEN_IMAGE ,
@@ -91,6 +44,25 @@ enum Errors {
91
44
IMAGE_WRONG_SIZE ,
92
45
}
93
46
47
+ enum Warnings {
48
+ IMAGE_WRONG_SIZE ,
49
+ }
50
+
51
+
52
+ const PRECISION_ERROR = 0.000001
53
+
54
+ const MESSAGE_BOOL = "boolean"
55
+ const MESSAGE_NUMBER = "number"
56
+ const MESSAGE_INTEGER = "integer"
57
+ const MESSAGE_PERCENTAGE = "percentage"
58
+ const MESSAGE_STRING = "string"
59
+ const MESSAGE_ENUM = "string"
60
+ const MESSAGE_ARRAY = "array"
61
+ const MESSAGE_COLOR = "color"
62
+ const MESSAGE_OBJECT = "object"
63
+ const MESSAGE_FILE = "file path"
64
+ const MESSAGE_JSON_CONFIG_FILE = "JSON configuration file path"
65
+ const MESSAGE_IMAGE = "image path"
94
66
95
67
const MESSAGE_COULD_NOT_OPEN_FILE = "Could not open the file"
96
68
const MESSAGE_COULD_NOT_OPEN_IMAGE = "Could not open the image"
@@ -125,6 +97,45 @@ const MESSAGE_WITH_CONTEXT = ", at '%s'."
125
97
const MESSAGE_WITHOUT_CONTEXT = "."
126
98
127
99
100
+ var _result
101
+ var _errors := []
102
+ var _warnings := []
103
+ var _public_variables := {}
104
+ var _private_variables := {}
105
+ var _preprocessor := JSONConfigProcessor .new ()
106
+ var _postprocessor := JSONConfigProcessor .new ()
107
+
108
+
109
+ static func _type_as_text (type : int ) -> String :
110
+ match type :
111
+ Types .BOOL :
112
+ return MESSAGE_BOOL
113
+ Types .NUMBER :
114
+ return MESSAGE_NUMBER
115
+ Types .INTEGER :
116
+ return MESSAGE_INTEGER
117
+ Types .PERCENTAGE :
118
+ return MESSAGE_PERCENTAGE
119
+ Types .STRING :
120
+ return MESSAGE_STRING
121
+ Types .ENUM :
122
+ return MESSAGE_ENUM
123
+ Types .ARRAY :
124
+ return MESSAGE_ARRAY
125
+ Types .COLOR :
126
+ return MESSAGE_COLOR
127
+ Types .OBJECT :
128
+ return MESSAGE_OBJECT
129
+ Types .FILE :
130
+ return MESSAGE_FILE
131
+ Types .JSON_CONFIG_FILE :
132
+ return MESSAGE_JSON_CONFIG_FILE
133
+ Types .IMAGE :
134
+ return MESSAGE_IMAGE
135
+ _ :
136
+ return "This type message is not defined"
137
+
138
+
128
139
static func _array_as_text (array : Array ) -> String :
129
140
var array_as_text = ""
130
141
@@ -216,11 +227,6 @@ static func _error_as_text(error: Dictionary) -> String:
216
227
return error_as_text
217
228
218
229
219
- enum Warnings {
220
- IMAGE_WRONG_SIZE ,
221
- }
222
-
223
-
224
230
static func _warning_as_text (warning : Dictionary ) -> String :
225
231
var warning_as_text
226
232
@@ -241,15 +247,6 @@ static func _warning_as_text(warning: Dictionary) -> String:
241
247
return warning_as_text
242
248
243
249
244
- var _result
245
- var _errors := []
246
- var _warnings := []
247
- var _public_variables := {}
248
- var _private_variables := {}
249
- var _preprocessor := JSONConfigProcessor .new ()
250
- var _postprocessor := JSONConfigProcessor .new ()
251
-
252
-
253
250
func set_preprocessor (processor : JSONConfigProcessor ) -> void :
254
251
_preprocessor = processor
255
252
@@ -337,11 +334,11 @@ func _get_file_path(file: String) -> String:
337
334
338
335
339
336
func _update_context (error_or_warning : Dictionary , context ) -> void :
340
- var _index_regex = RegEx .new ()
341
- _index_regex .compile ("^\\ [([0-9]|[1-9]+[0-9]+)\\ ]" )
337
+ var index_regex = RegEx .new ()
338
+ index_regex .compile ("^\\ [([0-9]|[1-9]+[0-9]+)\\ ]" )
342
339
343
340
if error_or_warning .has ("context" ):
344
- if _index_regex .search (error_or_warning .context ) == null :
341
+ if index_regex .search (error_or_warning .context ) == null :
345
342
error_or_warning .context = context + "." + error_or_warning .context
346
343
else :
347
344
error_or_warning .context = context + error_or_warning .context
0 commit comments