1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Compare commits

..

2 commits

Author SHA1 Message Date
Emmanouil Papadeas d7c356f1d4 Update CHANGELOG.md 2024-01-30 21:27:33 +02:00
Emmanouil Papadeas 3dcc51705a Load pxo files from the Web version - Fixes #820 2024-01-30 21:26:07 +02:00
2 changed files with 18 additions and 5 deletions

View file

@ -27,6 +27,7 @@ Built using Godot 3.5.2
- Tool shortcuts can now work with <kbd>Control</kbd>. [#935](https://github.com/Orama-Interactive/Pixelorama/issues/935)
- Optimize canvas drawing by only updating it when the image(s) have changed. [ac6a4db43d9296ebc03e639d8199dd3878a25d86](https://github.com/Orama-Interactive/Pixelorama/commit/ac6a4db43d9296ebc03e639d8199dd3878a25d86)
- Fix bug where using shortcuts to switch between frames also moved the selection, causing deletions.
- Pxo files can now be loaded from the Open menu option in the Web version. [3dcc51705a999145e53a8e6d4de217dc03b0f147](https://github.com/Orama-Interactive/Pixelorama/commit/3dcc51705a999145e53a8e6d4de217dc03b0f147)
- The ellipse tool no longer produces gaps with large sizes. [4f3a7a305a264e0d2fe86c201af76eca4b2fea0a](https://github.com/Orama-Interactive/Pixelorama/commit/4f3a7a305a264e0d2fe86c201af76eca4b2fea0a)
- Fix "visible layers" option on the export dialog producing wrong results. [346d1f071a8c6b1defb1072d39aea9c642f1ef59](https://github.com/Orama-Interactive/Pixelorama/commit/346d1f071a8c6b1defb1072d39aea9c642f1ef59)
- Random brushes now work again. [1317e40ffa5e9f01a9d214221bb5133db20a1de9](https://github.com/Orama-Interactive/Pixelorama/commit/1317e40ffa5e9f01a9d214221bb5133db20a1de9)

View file

@ -28,7 +28,9 @@ func _define_js() -> void:
canceled = true;
var input = document.createElement('INPUT');
input.setAttribute("type", "file");
input.setAttribute("accept", "image/png, image/jpeg, image/webp, image/bmp, image/x-tga");
input.setAttribute(
"accept", ".pxo, image/png, image/jpeg, image/webp, image/bmp, image/x-tga"
);
input.click();
input.addEventListener('change', event => {
if (event.target.files.length > 0){
@ -88,7 +90,7 @@ func load_image(load_directly := true):
return
# Use data from png data
var image_data
var image_data: PoolByteArray
while true:
image_data = JavaScript.eval("fileData;", true)
if image_data != null:
@ -96,11 +98,11 @@ func load_image(load_directly := true):
yield(get_tree().create_timer(1.0), "timeout") # Need more time to load data
var image_type = JavaScript.eval("fileType;", true)
var image_name = JavaScript.eval("fileName;", true)
var image_name: String = JavaScript.eval("fileName;", true)
var image := Image.new()
var image_error
var image_info: Dictionary = {}
var image_error: int
var image_info := {}
match image_type:
"image/png":
if load_directly:
@ -122,6 +124,16 @@ func load_image(load_directly := true):
"image/x-tga":
image_error = image.load_tga_from_buffer(image_data)
var invalid_type:
if image_name.get_extension().to_lower() == "pxo":
var temp_file_path := "user://%s" % image_name
var temp_file := File.new()
temp_file.open(temp_file_path, File.WRITE)
temp_file.store_buffer(image_data)
temp_file.close()
OpenSave.open_pxo_file(temp_file_path)
var dir := Directory.new()
dir.remove(temp_file_path)
return
print("Invalid type: " + invalid_type)
return
if image_error: