@@ -28,7 +28,9 @@ func _define_js() -> void:
28
28
canceled = true;
29
29
var input = document.createElement('INPUT');
30
30
input.setAttribute("type", "file");
31
- input.setAttribute("accept", "image/png, image/jpeg, image/webp, image/bmp, image/x-tga");
31
+ input.setAttribute(
32
+ "accept", ".pxo, image/png, image/jpeg, image/webp, image/bmp, image/x-tga"
33
+ );
32
34
input.click();
33
35
input.addEventListener('change', event => {
34
36
if (event.target.files.length > 0){
@@ -88,19 +90,19 @@ func load_image(load_directly := true):
88
90
return
89
91
90
92
# Use data from png data
91
- var image_data
93
+ var image_data : PoolByteArray
92
94
while true :
93
95
image_data = JavaScript .eval ("fileData;" , true )
94
96
if image_data != null :
95
97
break
96
98
yield (get_tree ().create_timer (1.0 ), "timeout" ) # Need more time to load data
97
99
98
100
var image_type = JavaScript .eval ("fileType;" , true )
99
- var image_name = JavaScript .eval ("fileName;" , true )
101
+ var image_name : String = JavaScript .eval ("fileName;" , true )
100
102
101
103
var image := Image .new ()
102
- var image_error
103
- var image_info : Dictionary = {}
104
+ var image_error : int
105
+ var image_info : = {}
104
106
match image_type :
105
107
"image/png" :
106
108
if load_directly :
@@ -122,6 +124,16 @@ func load_image(load_directly := true):
122
124
"image/x-tga" :
123
125
image_error = image .load_tga_from_buffer (image_data )
124
126
var invalid_type :
127
+ if image_name .get_extension ().to_lower () == "pxo" :
128
+ var temp_file_path := "user://%s " % image_name
129
+ var temp_file := File .new ()
130
+ temp_file .open (temp_file_path , File .WRITE )
131
+ temp_file .store_buffer (image_data )
132
+ temp_file .close ()
133
+ OpenSave .open_pxo_file (temp_file_path )
134
+ var dir := Directory .new ()
135
+ dir .remove (temp_file_path )
136
+ return
125
137
print ("Invalid type: " + invalid_type )
126
138
return
127
139
if image_error :
0 commit comments