Skip to content

Commit

Permalink
Fix a number of bugs (#771)
Browse files Browse the repository at this point in the history
  • Loading branch information
MewPurPur authored May 30, 2024
1 parent 6e46bce commit 9c9cf87
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
27 changes: 15 additions & 12 deletions src/FileUtils.gd
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static func open_import_dialog() -> void:
if FileUtils._is_native_preferred():
DisplayServer.file_dialog_show(TranslationServer.translate("Import a .svg file"),
Utils.get_last_dir(), "", false, DisplayServer.FILE_DIALOG_MODE_OPEN_FILE,
["*.svg"], native_file_import)
["*.svg"], native_svg_import)
elif OS.has_feature("web"):
HandlerGUI.web_load_svg()
else:
Expand All @@ -110,25 +110,28 @@ static func open_reference_load_dialog() -> void:
if FileUtils._is_native_preferred():
DisplayServer.file_dialog_show(TranslationServer.translate("Load an image file"),
Utils.get_last_dir(), "", false, DisplayServer.FILE_DIALOG_MODE_OPEN_FILE,
["*.svg", "*.png", "*.jpeg", "*.jpg", "*.webp"], native_file_import)
PackedStringArray(["*.svg,*.png,*.jpeg,*.jpg,*.webp"]),
native_reference_image_load)
# TODO: Add Web Support
#elif OS.has_feature("web"):
#HandlerGUI.web_load_svg()
#HandlerGUI.web_load_reference_image()
else:
var png_import_dialog := GoodFileDialog.instantiate()
png_import_dialog.setup(Utils.get_last_dir(), "",
var image_import_dialog := GoodFileDialog.instantiate()
image_import_dialog.setup(Utils.get_last_dir(), "",
GoodFileDialogType.FileMode.SELECT,
PackedStringArray(["svg", "png", "jpeg", "jpg", "webp"]))
HandlerGUI.add_overlay(png_import_dialog)
png_import_dialog.file_selected.connect(load_reference_image)
HandlerGUI.add_overlay(image_import_dialog)
image_import_dialog.file_selected.connect(load_reference_image)

static func native_file_import(has_selected: bool, files: PackedStringArray,
static func native_svg_import(has_selected: bool, files: PackedStringArray,
_filter_idx: int) -> void:
if has_selected:
if files[0].ends_with(".svg"):
apply_svg_from_path(files[0])
else:
load_reference_image(files[0])
apply_svg_from_path(files[0])

static func native_reference_image_load(has_selected: bool, files: PackedStringArray,
_filter_idx: int) -> void:
if has_selected:
load_reference_image(files[0])

static func load_reference_image(path: String) -> void:
GlobalSettings.modify_save_data("reference_path", path)
Expand Down
4 changes: 2 additions & 2 deletions src/ui_elements/pathdata_field.gd
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ func _on_commands_gui_input(event: InputEvent) -> void:
if event.button_index == MOUSE_BUTTON_LEFT:
if event.is_pressed():
if event.double_click:
# Unselect the tag, so then it's selected again.
Indications.ctrl_select(tid, cmd_idx)
# Unselect the tags so we can use Ctrl select.
Indications.clear_inner_selection()
var subpath_range: Vector2i =\
SVG.root_tag.get_tag(tid).attributes.d.get_subpath(cmd_idx)
for idx in range(subpath_range.x, subpath_range.y + 1):
Expand Down
5 changes: 3 additions & 2 deletions src/ui_parts/display.gd
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ func _ready() -> void:
get_window().window_input.connect(_update_input_debug)
view_settings_updated.emit(grid_visuals.visible, controls.visible,
viewport.display_texture.rasterized)

if OS.has_feature("web"):
reference_button.hide()
reference_button.disabled = true
reference_button.tooltip_text = "Not currently available on web."

func _unhandled_input(input_event: InputEvent) -> void:
if Input.is_action_pressed("debug"):
Expand Down

0 comments on commit 9c9cf87

Please sign in to comment.