adapted script for Godot 4.1
This commit is contained in:
parent
aab6be4dea
commit
93631b95e5
@ -3,17 +3,17 @@ extends Node
|
||||
signal read_completed
|
||||
signal load_completed(image)
|
||||
|
||||
var js_callback = JavaScript.create_callback(self, "load_handler");
|
||||
var js_callback = JavaScriptBridge.create_callback(self, "load_handler");
|
||||
var js_interface;
|
||||
|
||||
func _ready():
|
||||
if OS.get_name() == "HTML5" and OS.has_feature('JavaScript'):
|
||||
_define_js()
|
||||
js_interface = JavaScript.get_interface("_HTML5FileExchange");
|
||||
js_interface = JavaScriptBridge.get_interface("_HTML5FileExchange");
|
||||
|
||||
func _define_js()->void:
|
||||
#Define JS script
|
||||
JavaScript.eval("""
|
||||
JavaScriptBridge.eval("""
|
||||
var _HTML5FileExchange = {};
|
||||
_HTML5FileExchange.upload = function(gd_callback) {
|
||||
canceled = true;
|
||||
@ -51,7 +51,7 @@ func load_image():
|
||||
yield(self, "read_completed")
|
||||
|
||||
var imageType = js_interface.fileType;
|
||||
var imageData = JavaScript.eval("_HTML5FileExchange.result", true) # interface doesn't work as expected for some reason
|
||||
var imageData = JavaScriptBridge.eval("_HTML5FileExchange.result", true) # interface doesn't work as expected for some reason
|
||||
|
||||
var image = Image.new()
|
||||
var image_error
|
||||
@ -77,4 +77,4 @@ func save_image(image:Image, fileName:String = "export.png")->void:
|
||||
|
||||
image.clear_mipmaps()
|
||||
var buffer = image.save_png_to_buffer()
|
||||
JavaScript.download_buffer(buffer, fileName)
|
||||
JavaScriptBridge.download_buffer(buffer, fileName)
|
||||
|
Loading…
Reference in New Issue
Block a user