11class_name JSONProperty
22
33
4- const PRECISION_ERROR = 0.000001
5-
6-
74enum Types {
85 BOOL ,
96 NUMBER ,
@@ -19,50 +16,6 @@ enum Types {
1916 IMAGE ,
2017}
2118
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-
6619enum Errors {
6720 COULD_NOT_OPEN_FILE ,
6821 COULD_NOT_OPEN_IMAGE ,
@@ -91,6 +44,25 @@ enum Errors {
9144 IMAGE_WRONG_SIZE ,
9245}
9346
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"
9466
9567const MESSAGE_COULD_NOT_OPEN_FILE = "Could not open the file"
9668const MESSAGE_COULD_NOT_OPEN_IMAGE = "Could not open the image"
@@ -125,6 +97,45 @@ const MESSAGE_WITH_CONTEXT = ", at '%s'."
12597const MESSAGE_WITHOUT_CONTEXT = "."
12698
12799
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+
128139static func _array_as_text (array : Array ) -> String :
129140 var array_as_text = ""
130141
@@ -216,11 +227,6 @@ static func _error_as_text(error: Dictionary) -> String:
216227 return error_as_text
217228
218229
219- enum Warnings {
220- IMAGE_WRONG_SIZE ,
221- }
222-
223-
224230static func _warning_as_text (warning : Dictionary ) -> String :
225231 var warning_as_text
226232
@@ -241,15 +247,6 @@ static func _warning_as_text(warning: Dictionary) -> String:
241247 return warning_as_text
242248
243249
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-
253250func set_preprocessor (processor : JSONConfigProcessor ) -> void :
254251 _preprocessor = processor
255252
@@ -337,11 +334,11 @@ func _get_file_path(file: String) -> String:
337334
338335
339336func _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]+)\\ ]" )
342339
343340 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 :
345342 error_or_warning .context = context + "." + error_or_warning .context
346343 else :
347344 error_or_warning .context = context + error_or_warning .context
0 commit comments