Improve variable naming in Filesystem.gd
This commit is contained in:
parent
578ecb1d01
commit
b7e2c9dfa2
4 changed files with 19 additions and 20 deletions
|
@ -25,8 +25,8 @@ func _process(_delta: float) -> void:
|
|||
old_zoom = self.zoom
|
||||
|
||||
func fit_image():
|
||||
if Filesystem.original_image != null:
|
||||
var image_size = Filesystem.original_image.get_size()
|
||||
if Filesystem.input_image_texture != null:
|
||||
var image_size = Filesystem.input_image_texture.get_size()
|
||||
var viewport_size = get_viewport_rect().size
|
||||
var zoomf = 1.0
|
||||
if viewport_size.x / image_size.x * image_size.y > viewport_size.y:
|
||||
|
|
|
@ -17,13 +17,12 @@ var shader: Shader:
|
|||
print("Load ", shader_path)
|
||||
return load(shader_path)
|
||||
|
||||
var image_path = ""
|
||||
|
||||
var original_image: ImageTexture
|
||||
var result: Image
|
||||
var input_image_path = ""
|
||||
var input_image_texture: ImageTexture
|
||||
var last_input_image_path = ""
|
||||
|
||||
var last_image_savepath = ""
|
||||
var last_original_image_path = ""
|
||||
var result: Image
|
||||
|
||||
func get_absolute_path(p: String) -> String:
|
||||
# this only works on Linux!
|
||||
|
@ -32,16 +31,16 @@ func get_absolute_path(p: String) -> String:
|
|||
return p
|
||||
|
||||
func load_image() -> String: # returns an error message
|
||||
print("Load ", image_path)
|
||||
print("Load ", input_image_path)
|
||||
var img = Image.new()
|
||||
var err = img.load(image_path)
|
||||
var err = img.load(input_image_path)
|
||||
if err == OK:
|
||||
original_image = ImageTexture.create_from_image(img)
|
||||
if self.last_image_savepath == "" or image_path != self.last_original_image_path:
|
||||
self.last_image_savepath = image_path
|
||||
self.last_original_image_path = image_path
|
||||
input_image_texture = ImageTexture.create_from_image(img)
|
||||
if self.last_image_savepath == "" or input_image_path != self.last_input_image_path:
|
||||
self.last_image_savepath = input_image_path
|
||||
self.last_input_image_path = input_image_path
|
||||
return ""
|
||||
return error_string(err) + " " + image_path
|
||||
return error_string(err) + " " + input_image_path
|
||||
|
||||
func save_result(path: String):
|
||||
print("Export ", path)
|
||||
|
|
|
@ -50,7 +50,7 @@ func set_vsync(enabled: bool):
|
|||
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
|
||||
|
||||
func update() -> Array: # returns error messages (strings)
|
||||
if Filesystem.image_path == "":
|
||||
if Filesystem.input_image_path == "":
|
||||
return ["No image loaded!"]
|
||||
var shader = Filesystem.shader # read from disk
|
||||
if shader == null:
|
||||
|
@ -60,16 +60,16 @@ func update() -> Array: # returns error messages (strings)
|
|||
return ["Shader compilation failed!"]
|
||||
var errors = []
|
||||
# load texture
|
||||
var fit_image = Filesystem.image_path != Filesystem.last_original_image_path
|
||||
var fit_image = Filesystem.input_image_path != Filesystem.last_input_image_path
|
||||
var err = Filesystem.load_image()
|
||||
if err != "":
|
||||
errors.append(err)
|
||||
image_viewport_display.hide()
|
||||
return errors
|
||||
# apply texture
|
||||
image_sprite.texture = Filesystem.original_image
|
||||
image_sprite.offset = Filesystem.original_image.get_size() / 2
|
||||
self.size = Filesystem.original_image.get_size()
|
||||
image_sprite.texture = Filesystem.input_image_texture
|
||||
image_sprite.offset = Filesystem.input_image_texture.get_size() / 2
|
||||
self.size = Filesystem.input_image_texture.get_size()
|
||||
# show the image viewport & fit the image
|
||||
if fit_image: camera.fit_image()
|
||||
image_viewport_display.show()
|
||||
|
|
|
@ -92,7 +92,7 @@ func _on_open_shader_dialog_confirmed() -> void:
|
|||
|
||||
|
||||
func _on_open_image_dialog_file_selected(path: String) -> void:
|
||||
Filesystem.image_path = path
|
||||
Filesystem.input_image_path = path
|
||||
self._on_apply_shader_button_pressed()
|
||||
|
||||
func _on_open_image_dialog_canceled() -> void:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue