diff --git a/addons/native_dialogs/LICENSE b/addons/native_dialogs/LICENSE new file mode 100644 index 0000000..21c88e9 --- /dev/null +++ b/addons/native_dialogs/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Tomás Espejo Gómez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/addons/native_dialogs/bin/native_dialog_message.gdns b/addons/native_dialogs/bin/native_dialog_message.gdns new file mode 100644 index 0000000..0d0e666 --- /dev/null +++ b/addons/native_dialogs/bin/native_dialog_message.gdns @@ -0,0 +1,9 @@ +[gd_resource type="NativeScript" load_steps=2 format=2] + +[ext_resource path="res://addons/native_dialogs/bin/native_dialogs.gdnlib" type="GDNativeLibrary" id=1] + +[resource] +resource_name = "native_dialog_message" +class_name = "NativeDialogMessage" +library = ExtResource( 1 ) +script_class_icon_path = "res://addons/native_dialogs/icons/native_dialog_message.png" diff --git a/addons/native_dialogs/bin/native_dialog_notify.gdns b/addons/native_dialogs/bin/native_dialog_notify.gdns new file mode 100644 index 0000000..31a1322 --- /dev/null +++ b/addons/native_dialogs/bin/native_dialog_notify.gdns @@ -0,0 +1,9 @@ +[gd_resource type="NativeScript" load_steps=2 format=2] + +[ext_resource path="res://addons/native_dialogs/bin/native_dialogs.gdnlib" type="GDNativeLibrary" id=1] + +[resource] +resource_name = "native_dialog_notify" +class_name = "NativeDialogNotify" +library = ExtResource( 1 ) +script_class_icon_path = "res://addons/native_dialogs/icons/native_dialog_notify.png" diff --git a/addons/native_dialogs/bin/native_dialog_open_file.gdns b/addons/native_dialogs/bin/native_dialog_open_file.gdns new file mode 100644 index 0000000..cfb5bbc --- /dev/null +++ b/addons/native_dialogs/bin/native_dialog_open_file.gdns @@ -0,0 +1,9 @@ +[gd_resource type="NativeScript" load_steps=2 format=2] + +[ext_resource path="res://addons/native_dialogs/bin/native_dialogs.gdnlib" type="GDNativeLibrary" id=1] + +[resource] +resource_name = "native_dialog_open_file" +class_name = "NativeDialogOpenFile" +library = ExtResource( 1 ) +script_class_icon_path = "res://addons/native_dialogs/icons/native_dialog_open_file.png" diff --git a/addons/native_dialogs/bin/native_dialog_save_file.gdns b/addons/native_dialogs/bin/native_dialog_save_file.gdns new file mode 100644 index 0000000..01ad849 --- /dev/null +++ b/addons/native_dialogs/bin/native_dialog_save_file.gdns @@ -0,0 +1,9 @@ +[gd_resource type="NativeScript" load_steps=2 format=2] + +[ext_resource path="res://addons/native_dialogs/bin/native_dialogs.gdnlib" type="GDNativeLibrary" id=1] + +[resource] +resource_name = "native_dialog_save_file" +class_name = "NativeDialogSaveFile" +library = ExtResource( 1 ) +script_class_icon_path = "res://addons/native_dialogs/icons/native_dialog_save_file.png" diff --git a/addons/native_dialogs/bin/native_dialog_select_folder.gdns b/addons/native_dialogs/bin/native_dialog_select_folder.gdns new file mode 100644 index 0000000..2fa3655 --- /dev/null +++ b/addons/native_dialogs/bin/native_dialog_select_folder.gdns @@ -0,0 +1,9 @@ +[gd_resource type="NativeScript" load_steps=2 format=2] + +[ext_resource path="res://addons/native_dialogs/bin/native_dialogs.gdnlib" type="GDNativeLibrary" id=1] + +[resource] +resource_name = "native_dialog_select_folder" +class_name = "NativeDialogSelectFolder" +library = ExtResource( 1 ) +script_class_icon_path = "res://addons/native_dialogs/icons/native_dialog_select_folder.png" diff --git a/addons/native_dialogs/bin/native_dialogs.gdnlib b/addons/native_dialogs/bin/native_dialogs.gdnlib new file mode 100644 index 0000000..e4f4792 --- /dev/null +++ b/addons/native_dialogs/bin/native_dialogs.gdnlib @@ -0,0 +1,18 @@ +[general] + +singleton=false +load_once=true +symbol_prefix="godot_" +reloadable=false + +[entry] + +X11.64="res://addons/native_dialogs/bin/x11/libnativedialogs.so" +Windows.64="res://addons/native_dialogs/bin/win64/libnativedialogs.dll" +OSX.64="res://addons/native_dialogs/bin/osx/libnativedialogs.dylib" + +[dependencies] + +X11.64=[ ] +Windows.64=[ ] +OSX.64=[ ] diff --git a/addons/native_dialogs/bin/osx/libnativedialogs.dylib b/addons/native_dialogs/bin/osx/libnativedialogs.dylib new file mode 100644 index 0000000..7df60e9 Binary files /dev/null and b/addons/native_dialogs/bin/osx/libnativedialogs.dylib differ diff --git a/addons/native_dialogs/bin/win64/libnativedialogs.dll b/addons/native_dialogs/bin/win64/libnativedialogs.dll new file mode 100644 index 0000000..1e8ed3c Binary files /dev/null and b/addons/native_dialogs/bin/win64/libnativedialogs.dll differ diff --git a/addons/native_dialogs/bin/win64/libnativedialogs.exp b/addons/native_dialogs/bin/win64/libnativedialogs.exp new file mode 100644 index 0000000..b7196c9 Binary files /dev/null and b/addons/native_dialogs/bin/win64/libnativedialogs.exp differ diff --git a/addons/native_dialogs/bin/win64/libnativedialogs.lib b/addons/native_dialogs/bin/win64/libnativedialogs.lib new file mode 100644 index 0000000..626b97d Binary files /dev/null and b/addons/native_dialogs/bin/win64/libnativedialogs.lib differ diff --git a/addons/native_dialogs/bin/x11/libnativedialogs.so b/addons/native_dialogs/bin/x11/libnativedialogs.so new file mode 100644 index 0000000..0392edb Binary files /dev/null and b/addons/native_dialogs/bin/x11/libnativedialogs.so differ diff --git a/addons/native_dialogs/icons/native_dialog_message.png b/addons/native_dialogs/icons/native_dialog_message.png new file mode 100644 index 0000000..5df8877 Binary files /dev/null and b/addons/native_dialogs/icons/native_dialog_message.png differ diff --git a/addons/native_dialogs/icons/native_dialog_message.png.import b/addons/native_dialogs/icons/native_dialog_message.png.import new file mode 100644 index 0000000..21aa28d --- /dev/null +++ b/addons/native_dialogs/icons/native_dialog_message.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/native_dialog_message.png-d3a3788b812cbdd538caffc1bd4f6303.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/native_dialogs/icons/native_dialog_message.png" +dest_files=[ "res://.import/native_dialog_message.png-d3a3788b812cbdd538caffc1bd4f6303.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/addons/native_dialogs/icons/native_dialog_notify.png b/addons/native_dialogs/icons/native_dialog_notify.png new file mode 100644 index 0000000..4760f51 Binary files /dev/null and b/addons/native_dialogs/icons/native_dialog_notify.png differ diff --git a/addons/native_dialogs/icons/native_dialog_notify.png.import b/addons/native_dialogs/icons/native_dialog_notify.png.import new file mode 100644 index 0000000..1235e69 --- /dev/null +++ b/addons/native_dialogs/icons/native_dialog_notify.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/native_dialog_notify.png-5ccb03b82c726e402d1ee63705cdfce9.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/native_dialogs/icons/native_dialog_notify.png" +dest_files=[ "res://.import/native_dialog_notify.png-5ccb03b82c726e402d1ee63705cdfce9.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/addons/native_dialogs/icons/native_dialog_open_file.png b/addons/native_dialogs/icons/native_dialog_open_file.png new file mode 100644 index 0000000..eb0a803 Binary files /dev/null and b/addons/native_dialogs/icons/native_dialog_open_file.png differ diff --git a/addons/native_dialogs/icons/native_dialog_open_file.png.import b/addons/native_dialogs/icons/native_dialog_open_file.png.import new file mode 100644 index 0000000..97a88b8 --- /dev/null +++ b/addons/native_dialogs/icons/native_dialog_open_file.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/native_dialog_open_file.png-94d31b95f481d556dcb2679a4986fc3e.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/native_dialogs/icons/native_dialog_open_file.png" +dest_files=[ "res://.import/native_dialog_open_file.png-94d31b95f481d556dcb2679a4986fc3e.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/addons/native_dialogs/icons/native_dialog_save_file.png b/addons/native_dialogs/icons/native_dialog_save_file.png new file mode 100644 index 0000000..72515a7 Binary files /dev/null and b/addons/native_dialogs/icons/native_dialog_save_file.png differ diff --git a/addons/native_dialogs/icons/native_dialog_save_file.png.import b/addons/native_dialogs/icons/native_dialog_save_file.png.import new file mode 100644 index 0000000..af8db81 --- /dev/null +++ b/addons/native_dialogs/icons/native_dialog_save_file.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/native_dialog_save_file.png-488c5f5500af041c2ce0b2fc9836df36.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/native_dialogs/icons/native_dialog_save_file.png" +dest_files=[ "res://.import/native_dialog_save_file.png-488c5f5500af041c2ce0b2fc9836df36.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/addons/native_dialogs/icons/native_dialog_select_folder.png b/addons/native_dialogs/icons/native_dialog_select_folder.png new file mode 100644 index 0000000..dc5328a Binary files /dev/null and b/addons/native_dialogs/icons/native_dialog_select_folder.png differ diff --git a/addons/native_dialogs/icons/native_dialog_select_folder.png.import b/addons/native_dialogs/icons/native_dialog_select_folder.png.import new file mode 100644 index 0000000..821f3bd --- /dev/null +++ b/addons/native_dialogs/icons/native_dialog_select_folder.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/native_dialog_select_folder.png-38710e428d30ce3e92fad43e6141022e.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/native_dialogs/icons/native_dialog_select_folder.png" +dest_files=[ "res://.import/native_dialog_select_folder.png-38710e428d30ce3e92fad43e6141022e.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/addons/native_dialogs/native_dialogs.gd b/addons/native_dialogs/native_dialogs.gd new file mode 100644 index 0000000..6a67dcc --- /dev/null +++ b/addons/native_dialogs/native_dialogs.gd @@ -0,0 +1,11 @@ +const Message = preload("./bin/native_dialog_message.gdns") +const Notify = preload("./bin/native_dialog_notify.gdns") +const OpenFile = preload("./bin/native_dialog_open_file.gdns") +const SaveFile = preload("./bin/native_dialog_save_file.gdns") +const SelectFolder = preload("./bin/native_dialog_select_folder.gdns") + +enum MessageChoices { OK, OK_CANCEL, YES_NO, YES_NO_CANCEL } +enum MessageIcons { INFO, WARNING, ERROR, QUESTION } +enum MessageResults { OK, CANCEL, YES, NO } + +enum NotifyIcons { INFO, WARNING, ERROR } diff --git a/addons/native_dialogs/plugin.cfg b/addons/native_dialogs/plugin.cfg new file mode 100644 index 0000000..f14747f --- /dev/null +++ b/addons/native_dialogs/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="Native Dialogs" +description="Native Dialogs is a plugin for Godot that allows you to interact with OS-specific dialogs, such as notifications, messages and file dialogs. " +author="Teggy" +version="1.0.0" +script="plugin.gd" diff --git a/addons/native_dialogs/plugin.gd b/addons/native_dialogs/plugin.gd new file mode 100644 index 0000000..594e814 --- /dev/null +++ b/addons/native_dialogs/plugin.gd @@ -0,0 +1,50 @@ +tool +extends EditorPlugin + + +const NativeDialogs = preload("./native_dialogs.gd") + + +func _enter_tree(): + add_custom_type( + "NativeDialogMessage", + "Node", + NativeDialogs.Message, + preload("./icons/native_dialog_message.png") + ) + + add_custom_type( + "NativeDialogNotify", + "Node", + NativeDialogs.Notify, + preload("./icons/native_dialog_notify.png") + ) + + add_custom_type( + "NativeDialogOpenFile", + "Node", + NativeDialogs.OpenFile, + preload("./icons/native_dialog_open_file.png") + ) + + add_custom_type( + "NativeDialogSaveFile", + "Node", + NativeDialogs.SaveFile, + preload("./icons/native_dialog_save_file.png") + ) + + add_custom_type( + "NativeDialogSelectFolder", + "Node", + NativeDialogs.SelectFolder, + preload("./icons/native_dialog_select_folder.png") + ) + + +func _exit_tree(): + remove_custom_type("NativeDialogMessage") + remove_custom_type("NativeDialogNotify") + remove_custom_type("NativeDialogOpenFile") + remove_custom_type("NativeDialogSaveFile") + remove_custom_type("NativeDialogSelectFolder") diff --git a/project.godot b/project.godot index f2c2b16..8b479f3 100644 --- a/project.godot +++ b/project.godot @@ -96,6 +96,10 @@ window/handheld/orientation="portrait" window/ios/hide_home_indicator=false window/stretch/aspect="keep" +[editor_plugins] + +enabled=PoolStringArray( "res://addons/native_dialogs/plugin.cfg" ) + [gui] theme/use_hidpi=true diff --git a/scripts/config_manager.gd b/scripts/config_manager.gd index e53f5af..564f9ba 100644 --- a/scripts/config_manager.gd +++ b/scripts/config_manager.gd @@ -63,6 +63,8 @@ var current_timesheet_file_path: String = "" setget set_current_timesheet_file_p func set_current_timesheet_file_path(value: String) -> void: + if current_timesheet_file_path == value: + return timesheet = _load_timesheet(value) if timesheet == null: return diff --git a/ui/settings.gd b/ui/settings.gd index 3c0bb72..244f2ae 100644 --- a/ui/settings.gd +++ b/ui/settings.gd @@ -2,6 +2,8 @@ extends Control var config: ConfigManager = preload("res://config_manager.tres") +const NativeDialogs := preload("res://addons/native_dialogs/native_dialogs.gd") + onready var file_path_line_edit := $"%FilePathLineEdit" as LineEdit onready var file_path_button := $"%FilePathButton" as Button onready var theme_path_button := $"%ThemePathButton" as Button @@ -9,8 +11,8 @@ onready var sound_check_box := $"%SoundCheckBox" as CheckBox onready var open_data_dir_button := $"%OpenDataDirButton" as Button onready var file_path_open_button := $"%FilePathOpenButton" as Button onready var attributions_rich_text_label := $"%AttributionsRichTextLabel" as RichTextLabel -onready var file_path_file_dialog := $"%FilePathFileDialog" as FileDialog -onready var theme_path_file_dialog := $"%ThemePathFileDialog" as FileDialog +var file_path_file_dialog := NativeDialogs.SaveFile.new() +var theme_path_file_dialog := NativeDialogs.OpenFile.new() func _ready() -> void: @@ -24,16 +26,22 @@ func _ready() -> void: # warning-ignore:return_value_discarded file_path_button.connect("pressed", self, "_on_file_path_button_pressed") + file_path_file_dialog.filters = ["*.csv ; CSV Files"] + file_path_file_dialog.force_overwrite = true + add_child(file_path_file_dialog) # warning-ignore:return_value_discarded file_path_file_dialog.connect("file_selected", self, "_on_current_file_selected") + # warning-ignore:return_value_discarded file_path_line_edit.connect("text_entered", self, "_on_current_file_selected") # warning-ignore:return_value_discarded theme_path_button.connect("pressed", self, "_on_theme_path_button_pressed") + theme_path_file_dialog.filters = ["*.theme ; Theme Files"] + add_child(theme_path_file_dialog) # warning-ignore:return_value_discarded - theme_path_file_dialog.connect("file_selected", self, "_on_new_theme_selected") + theme_path_file_dialog.connect("files_selected", self, "_on_new_theme_selected") theme_path_file_dialog.hide() file_path_file_dialog.hide() @@ -54,8 +62,7 @@ func _ready() -> void: func _on_current_file_changed() -> void: - file_path_file_dialog.current_path = config.current_timesheet_file_path - file_path_file_dialog.current_dir = config.current_timesheet_file_path.get_base_dir() + #file_path_file_dialog.initial_path = config.current_timesheet_file_path.get_base_dir() file_path_line_edit.text = config.current_timesheet_file_path @@ -64,11 +71,12 @@ func _on_theme_changed() -> void: func _on_file_path_button_pressed() -> void: - file_path_file_dialog.popup_centered() + file_path_file_dialog.initial_path = config.current_timesheet_file_path + file_path_file_dialog.show() func _on_current_file_selected(new_file: String) -> void: - config.set_current_file = new_file + config.current_timesheet_file_path = new_file func _on_sound_toggle(is_on: bool) -> void: @@ -76,11 +84,12 @@ func _on_sound_toggle(is_on: bool) -> void: func _on_theme_path_button_pressed() -> void: - theme_path_file_dialog.popup_centered() + theme_path_file_dialog.initial_path = config.theme_file_path + theme_path_file_dialog.show() func _on_new_theme_selected(new_theme_path: String) -> void: - config.set_theme_path = new_theme_path + config.theme_file_path = new_theme_path func _on_attributions_rich_text_label_meta_clicked(meta) -> void: diff --git a/ui/settings.tscn b/ui/settings.tscn index e374030..ffd3578 100644 --- a/ui/settings.tscn +++ b/ui/settings.tscn @@ -128,8 +128,10 @@ This game uses Godot Engine, available under the following license: [node name="FilePathFileDialog" type="FileDialog" parent="CanvasLayer"] unique_name_in_owner = true -anchor_right = 1.0 -anchor_bottom = 1.0 +visible = true +margin_top = 39.0 +margin_right = 875.0 +margin_bottom = 765.0 size_flags_horizontal = 3 size_flags_vertical = 3 window_title = "Pick a file"