You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Only allows strings representing a path to a file. This path can be absolute or relative. When the file path is relative, it would be relative to the directory that contains the JSON configuration file that specifies this field. Please, use '/' as a [path delimiter](https://docs.godotengine.org/en/stable/getting_started/step_by_step/filesystem.html?highlight=file%20path#path-delimiter).
8
+
9
+
## Usage
10
+
11
+
Once you have instantiated the class, you can determine how to open the file via the 'set_mode_flag' method. It would be [File.READ](https://docs.godotengine.org/en/stable/classes/class_file.html?highlight=File.READ#enumerations) by default.
12
+
13
+
## Example
14
+
15
+
In this example, the configuration structure has one required property. The property 'file' must be a path to another file.
16
+
17
+
```GDScript
18
+
# Create a JSON configuration file
19
+
var json_config_file = JSONConfigFile.new()
20
+
21
+
# Add the 'file' property, which is a path to a file
@@ -7,4 +89,13 @@ The public methods of this class are:
7
89
|-|-|-|-|
8
90
|**set_preprocessor**|**processor -> JSONConfigProcessor:** <br> Object that defines the function to execute before the validation process. | Sets the process to execute before the validation process. | Nothing. |
9
91
|**set_postprocessor**|**processor -> JSONConfigProcessor:** <br> Object that defines the function to execute after the validation process. | Sets the process to execute after the validation process. | Nothing. |
10
-
| **set_mode_flag** | **mode_flag -> int:** <br> The flag that determines how to open the file. <br><br> **NOTE:** Check [File.ModeFlags](https://docs.godotengine.org/en/stable/classes/class_file.html?highlight=File#enum-file-modeflags) for more information. | Determines how to open the file. | Nothing.
92
+
| **set_mode_flag** | **mode_flag -> int:** <br> The flag that determines how to open the file. <br><br> **NOTE:** Check [File.ModeFlags](https://docs.godotengine.org/en/stable/classes/class_file.html?highlight=File#enum-file-modeflags) for more information. | Determines how to open the file. | Nothing.
93
+
94
+
## Errors
95
+
96
+
This class could directly raise any of the following errors:
97
+
98
+
| Enum value | Description | Params | As text |
99
+
|-|-|-|-|
100
+
| WRONG_TYPE | The type of the input does not match the expected one. |**expected -> int:** <br> Takes the value [FILE](./ENUMS.md). | Wrong type: expected 'file path' |
101
+
| COULD_NOT_OPEN_FILE | The file path leads to a nonexistent file or an error occurred when opening the file. |**code -> int:** <br> Error code returned by [File.open()](https://docs.godotengine.org/en/stable/classes/class_file.html?highlight=File#class-file-method-open). | Could not open the file |
Only allows strings representing a path to an image. This path can be absolute or relative. When the file path is relative, it would be relative to the directory that contains the JSON configuration file that specifies this field. Please, use '/' as a [path delimiter](https://docs.godotengine.org/en/stable/getting_started/step_by_step/filesystem.html?highlight=file%20path#path-delimiter). Also, check Godot's [supported image formats](https://docs.godotengine.org/en/latest/getting_started/workflow/assets/importing_images.html#supported-image-formats).
8
+
9
+
## Usage
10
+
11
+
Once you have instantiated the class, you can determine the size of the image via the 'set_size' method. By default, the images would be resizable and rescaled using [Image.INTERPOLATE_BILINEAR](https://docs.godotengine.org/en/stable/classes/class_image.html?highlight=Image#enum-image-interpolation). That means that when the image size is different, this property will raise a warning. If you want it to raise an error, set the third parameter in 'set_size' to 'false'.
12
+
13
+
## Example
14
+
15
+
In this example, the configuration structure has one required property. The property 'image' must be a path to an image which size should be 64x64.
16
+
17
+
```GDScript
18
+
# Create a JSON configuration file
19
+
var json_config_file = JSONConfigFile.new()
20
+
21
+
# Create an image property
22
+
var image_property = JSONPropertyImage.new()
23
+
image_property.set_size(64, 64)
24
+
25
+
# Add the 'image' property, which is a path to an image
"as_text": "Could not open the image, at 'image'."
84
+
}
85
+
]
86
+
```
87
+
88
+
### Semi-incorrect JSON: Wrong size image
89
+
90
+
This JSON contains one warning. The 'image' property indicates a path to an image which size is not the desired one.
91
+
92
+
```JSON
93
+
{
94
+
"image": "32x32_image.png"
95
+
}
96
+
```
97
+
98
+
Returned warning:
99
+
100
+
```GDScript
101
+
[
102
+
{
103
+
"warning": Warnings.IMAGE_WRONG_SIZE,
104
+
"expected_size": [64, 64],
105
+
"size": [32, 32],
106
+
"context": "image",
107
+
"as_text": "The image is not the correct size (64, 64), at 'image'."
108
+
}
109
+
]
110
+
```
111
+
2
112
## Functions
3
113
4
114
The public methods of this class are:
@@ -7,4 +117,22 @@ The public methods of this class are:
7
117
|-|-|-|-|
8
118
|**set_preprocessor**|**processor -> JSONConfigProcessor:** <br> Object that defines the function to execute before the validation process. | Sets the process to execute before the validation process. | Nothing. |
9
119
|**set_postprocessor**|**processor -> JSONConfigProcessor:** <br> Object that defines the function to execute after the validation process. | Sets the process to execute after the validation process. | Nothing. |
10
-
|**set_size**|**width -> int:** <br> Width of the image. <br> **height -> int:** <br> Height of the image. <br> **resizable -> bool(true):** <br> Determines if the image is resizable. If it is, it will raise a warning whenever the size of the input image is different than this size, and then it will resize the image. If it is not, it will raise an error instead. <br> **interpolation -> int(Image.INTERPOLATE_BILINEAR):** <br> Interpolation tecnich to apply whenever the size of the input image is different and it must be resized. <br><br> **NOTE:** Check [Image.Interpolation](https://docs.godotengine.org/en/stable/classes/class_image.html?highlight=Image#enum-image-interpolation) for more information. | Sets the recommended, or required, size of the image. | Nothing. |
120
+
|**set_size**|**width -> int:** <br> Width of the image. <br> **height -> int:** <br> Height of the image. <br> **resizable -> bool(true):** <br> Determines if the image is resizable. If it is, it will raise a warning whenever the size of the input image is different than this size, and then it will resize the image. If it is not, it will raise an error instead. <br> **interpolation -> int(Image.INTERPOLATE_BILINEAR):** <br> The interpolation technic to apply whenever the size of the input image is different, and it must be resized. <br><br> **NOTE:** Check [Image.Interpolation](https://docs.godotengine.org/en/stable/classes/class_image.html?highlight=Image#enum-image-interpolation) for more information. | Sets the recommended, or required, size of the image. | Nothing. |
121
+
122
+
## Errors
123
+
124
+
This class could directly raise any of the following errors:
125
+
126
+
| Enum value | Description | Params | As text |
127
+
|-|-|-|-|
128
+
| WRONG_TYPE | The type of the input does not match the expected one. |**expected -> int:** <br> Takes the value [IMAGE](./ENUMS.md). | Wrong type: expected 'file path' |
129
+
| COULD_NOT_OPEN_IMAGE | The image path leads to a nonexistent image or an error occurred when loading the image. |**code -> int:** <br> Error code returned by [Image.load()](https://docs.godotengine.org/en/stable/classes/class_image.html?highlight=Image#class-image-method-load). | Could not open the image |
130
+
IMAGE_WRONG_SIZE | The image has not the correct size. | **expected_size -> array:** <br> Array with two integers representing the expected size of the image. <br> **size -> array:** <br> Array with two integers representing the actual size of the image. | The image is not the correct size ({expected_size})
131
+
132
+
## Warnings
133
+
134
+
This class could directly raise any of the following warnings:
135
+
136
+
| Enum value | Description | Params | As text |
137
+
|-|-|-|-|
138
+
IMAGE_WRONG_SIZE | The image has not the correct size. | **expected_size -> array:** <br> Array with two integers representing the expected size of the image. <br> **size -> array:** <br> Array with two integers representing the actual size of the image. | The image is not the correct size ({expected_size})
0 commit comments