From 4bc0fba941944ced4483b38a665064db49375032 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas Date: Wed, 24 Jan 2024 03:57:40 +0200 Subject: [PATCH] Add a variable in Global for setting file dialogs as native, and add a "FileDialogs" node group This settings is not exposed in the preferences in this commit --- src/Autoload/Global.gd | 14 +++++++++++--- src/Palette/EditPaletteDialog.tscn | 2 +- src/Preferences/PreferencesDialog.tscn | 2 +- src/Tools/3DTools/3DShapeEdit.tscn | 2 +- src/UI/Dialogs/ExportDialog.tscn | 2 +- src/UI/Dialogs/ImageEffects/ShaderEffect.tscn | 2 +- src/UI/Dialogs/OpenSprite.tscn | 2 +- src/UI/Dialogs/SaveSprite.tscn | 2 +- 8 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index 23a236c51..4b9060013 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -148,16 +148,23 @@ var integer_zoom := false: zoom_slider.step = 1 zoom_slider.value = zoom_slider.value # to trigger signal emission -## Found in Preferences. The scale of the Interface. +## Found in Preferences. The scale of the interface. var shrink := 1.0 -## Found in Preferences. The font size used by the Interface. +## Found in Preferences. The font size used by the interface. var font_size := 16: set(value): font_size = value control.theme.default_font_size = value control.theme.set_font_size("font_size", "HeaderSmall", value + 2) -## Found in Preferences. If [code]true[/code], the Interface dims on popups. +## Found in Preferences. If [code]true[/code], the interface dims on popups. var dim_on_popup := true +var use_native_file_dialogs := false: + set(value): + use_native_file_dialogs = value + if not is_inside_tree(): + await tree_entered + await get_tree().process_frame + get_tree().set_group(&"FileDialogs", "use_native_dialog", value) ## Found in Preferences. The modulation color (or simply color) of icons. var modulate_icon_color := Color.GRAY ## Found in Preferences. Determines if [member modulate_icon_color] uses custom or theme color. @@ -1055,6 +1062,7 @@ func create_ui_for_shader_uniforms( file_dialog.access = FileDialog.ACCESS_FILESYSTEM file_dialog.size = Vector2(384, 281) file_dialog.file_selected.connect(file_selected.bind(u_name)) + file_dialog.use_native_dialog = use_native_file_dialogs var button := Button.new() button.text = "Load texture" button.pressed.connect(file_dialog.popup_centered) diff --git a/src/Palette/EditPaletteDialog.tscn b/src/Palette/EditPaletteDialog.tscn index 815a7313a..1745e88bf 100644 --- a/src/Palette/EditPaletteDialog.tscn +++ b/src/Palette/EditPaletteDialog.tscn @@ -115,7 +115,7 @@ text = "Delete Palette?" horizontal_alignment = 1 vertical_alignment = 1 -[node name="ExportFileDialog" type="FileDialog" parent="."] +[node name="ExportFileDialog" type="FileDialog" parent="." groups=["FileDialogs"]] size = Vector2i(677, 400) access = 2 filters = PackedStringArray("*.png ; PNG Image", "*.jpg,*.jpeg ; JPEG Image", "*.webp ; WebP Image") diff --git a/src/Preferences/PreferencesDialog.tscn b/src/Preferences/PreferencesDialog.tscn index 68d8b5a37..468bb60d8 100644 --- a/src/Preferences/PreferencesDialog.tscn +++ b/src/Preferences/PreferencesDialog.tscn @@ -1320,7 +1320,7 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 -[node name="AddExtensionFileDialog" type="FileDialog" parent="Popups"] +[node name="AddExtensionFileDialog" type="FileDialog" parent="Popups" groups=["FileDialogs"]] mode = 1 title = "Open File(s)" size = Vector2i(560, 400) diff --git a/src/Tools/3DTools/3DShapeEdit.tscn b/src/Tools/3DTools/3DShapeEdit.tscn index 2d34b83ed..f78845945 100644 --- a/src/Tools/3DTools/3DShapeEdit.tscn +++ b/src/Tools/3DTools/3DShapeEdit.tscn @@ -773,7 +773,7 @@ script = ExtResource("5") wait_time = 0.2 one_shot = true -[node name="LoadModelDialog" type="FileDialog" parent="." index="6"] +[node name="LoadModelDialog" type="FileDialog" parent="." index="6" groups=["FileDialogs"]] mode = 1 title = "Open File(s)" size = Vector2i(558, 300) diff --git a/src/UI/Dialogs/ExportDialog.tscn b/src/UI/Dialogs/ExportDialog.tscn index 029d1c67e..9534e604e 100644 --- a/src/UI/Dialogs/ExportDialog.tscn +++ b/src/UI/Dialogs/ExportDialog.tscn @@ -306,7 +306,7 @@ offset_right = 692.0 offset_bottom = 551.0 mouse_filter = 2 -[node name="PathDialog" type="FileDialog" parent="Popups"] +[node name="PathDialog" type="FileDialog" parent="Popups" groups=["FileDialogs"]] mode = 2 title = "Open a Directory" size = Vector2i(675, 500) diff --git a/src/UI/Dialogs/ImageEffects/ShaderEffect.tscn b/src/UI/Dialogs/ImageEffects/ShaderEffect.tscn index ccecefc55..d86aa0464 100644 --- a/src/UI/Dialogs/ImageEffects/ShaderEffect.tscn +++ b/src/UI/Dialogs/ImageEffects/ShaderEffect.tscn @@ -53,7 +53,7 @@ text = "No shader loaded!" [node name="ShaderParams" type="VBoxContainer" parent="VBoxContainer"] layout_mode = 2 -[node name="FileDialog" type="FileDialog" parent="."] +[node name="FileDialog" type="FileDialog" parent="." groups=["FileDialogs"]] access = 2 filters = PackedStringArray("*gdshader; Godot Shader File") show_hidden_files = true diff --git a/src/UI/Dialogs/OpenSprite.tscn b/src/UI/Dialogs/OpenSprite.tscn index c0e98ee2a..c7745d848 100644 --- a/src/UI/Dialogs/OpenSprite.tscn +++ b/src/UI/Dialogs/OpenSprite.tscn @@ -1,6 +1,6 @@ [gd_scene format=3 uid="uid://b3aeqj2k58wdk"] -[node name="OpenSprite" type="FileDialog"] +[node name="OpenSprite" type="FileDialog" groups=["FileDialogs"]] title = "Open File(s)" size = Vector2i(558, 400) exclusive = false diff --git a/src/UI/Dialogs/SaveSprite.tscn b/src/UI/Dialogs/SaveSprite.tscn index 73a3288ae..50b177449 100644 --- a/src/UI/Dialogs/SaveSprite.tscn +++ b/src/UI/Dialogs/SaveSprite.tscn @@ -1,6 +1,6 @@ [gd_scene format=3 uid="uid://d4euwo633u33b"] -[node name="SaveSprite" type="FileDialog"] +[node name="SaveSprite" type="FileDialog" groups=["FileDialogs"]] size = Vector2i(675, 400) exclusive = false popup_window = true