Skip to content

Commit

Permalink
Fix load/save images on separate drive, fixes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Bauxitedev committed Apr 1, 2021
1 parent 36d80dc commit 95e2df6
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions godot/UI/UI.gd
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ func load_gif():
dialog.set_filters(PoolStringArray(["*.gif ; GIF Images"]))
dialog.mode = FileDialog.MODE_OPEN_FILE

yield(dialog, "file_selected")
var filename = yield(dialog, "file_selected")
# NOTE: dialog.current_path removes C: for some reason so it tries to use a non-existing path. See https://github.com/godotengine/godot/issues/45822
# Solution: use the result of "yield" instead of dialog.current_path

last_dir = dialog.current_dir
var filename = dialog.current_path.replace("res://", "")
last_dir = filename.get_base_dir()

emit_signal("loaded_gif", filename)
clear_texture()

Expand All @@ -82,8 +84,9 @@ func load_separate_frames():
dialog.set_filters(PoolStringArray(["*.png ; PNG Frames"]))
dialog.mode = FileDialog.MODE_OPEN_FILES

var filenames = yield(dialog, "files_selected")
last_dir = dialog.current_dir
var filenames = yield(dialog, "files_selected")

last_dir = filename.get_base_dir()

emit_signal("loaded_separate_frames", filenames)
clear_texture()
Expand All @@ -93,10 +96,9 @@ func load_spritesheet():
dialog.set_filters(PoolStringArray(["*.png ; PNG Spritesheet", "*.jpg ; JPG Spritesheet"]))
dialog.mode = FileDialog.MODE_OPEN_FILE

yield(dialog, "file_selected")
var filename = yield(dialog, "file_selected")

last_dir = dialog.current_dir
var filename = dialog.current_path.replace("res://", "")
last_dir = filename.get_base_dir()

show_spritesheet_config_load_dialog(filename)

Expand All @@ -122,10 +124,9 @@ func export_gif():
dialog.set_filters(PoolStringArray(["*.gif ; GIF Image"]))
dialog.mode = FileDialog.MODE_SAVE_FILE

yield(dialog, "file_selected")
var filename = yield(dialog, "file_selected")

last_dir = dialog.current_dir
var filename = dialog.current_path.replace("res://", "")
last_dir = filename.get_base_dir()

var speed_ratio = ImageHolder.get_speed_ratio()
var output_fps = GlobalHolder.fps * speed_ratio
Expand All @@ -136,21 +137,20 @@ func export_separate_frames():
dialog.set_filters(PoolStringArray(["*.png ; PNG Frames"]))
dialog.mode = FileDialog.MODE_SAVE_FILE

yield(dialog, "file_selected")
var filename = yield(dialog, "file_selected")

last_dir = dialog.current_dir
var filename = dialog.current_path.replace("res://", "")
last_dir = filename.get_base_dir()

emit_signal("exported_separate_frames", filename)

func export_spritesheet():
var dialog = show_file_dialog()
dialog.set_filters(PoolStringArray(["*.png ; PNG Spritesheet"]))
dialog.mode = FileDialog.MODE_SAVE_FILE

yield(dialog, "file_selected")
var filename = yield(dialog, "file_selected")

last_dir = dialog.current_dir
var filename = dialog.current_path.replace("res://", "")
last_dir = filename.get_base_dir()

show_spritesheet_config_save_dialog(filename)

Expand Down

0 comments on commit 95e2df6

Please sign in to comment.