diff --git a/addons/gdfxr/editor/Editor.gd b/addons/gdfxr/editor/Editor.gd index 4e9d2fc..d91db62 100644 --- a/addons/gdfxr/editor/Editor.gd +++ b/addons/gdfxr/editor/Editor.gd @@ -1,6 +1,8 @@ tool extends Container +enum ExtraOption { SAVE_AS, COPY, PASTE } + const SFXRConfig := preload("../SFXRConfig.gd") const SFXRGenerator := preload("../SFXRGenerator.gd") @@ -8,6 +10,7 @@ var plugin: EditorPlugin var _config := SFXRConfig.new() var _config_defaults := SFXRConfig.new() +var _config_clipboard: SFXRConfig var _generator := SFXRGenerator.new() var _path: String var _modified := false @@ -18,6 +21,7 @@ onready var audio_player := $AudioStreamPlayer as AudioStreamPlayer onready var filename_label := find_node("Filename") as Label onready var save_button := find_node("Save") as Button onready var restore_button := find_node("Restore") as Button +onready var extra_button := find_node("Extra") as MenuButton onready var version_button := find_node("VersionButton") onready var translator := $PluginTranslator @@ -29,6 +33,13 @@ func _ready(): for child in get_children(): _hook_plugin(child) + var popup := extra_button.get_popup() + popup.add_item(translator.tr("Save As..."), ExtraOption.SAVE_AS) + popup.add_separator() + popup.add_item(translator.tr("Copy"), ExtraOption.COPY) + popup.add_item(translator.tr("Paste"), ExtraOption.PASTE) + popup.connect("id_pressed", self, "_on_Extra_id_pressed") + var params := find_node("Params") as Container for category in params.get_children(): for control in category.get_children(): @@ -46,6 +57,11 @@ func _notification(what: int): match what: NOTIFICATION_ENTER_TREE, NOTIFICATION_THEME_CHANGED: find_node("ScrollContainer").add_stylebox_override("bg", get_stylebox("bg", "Tree")) + + if extra_button: + var popup = extra_button.get_popup() + popup.set_item_icon(popup.get_item_index(ExtraOption.COPY), get_icon("ActionCopy", "EditorIcons")) + popup.set_item_icon(popup.get_item_index(ExtraOption.PASTE), get_icon("ActionPaste", "EditorIcons")) func edit(path: String) -> void: @@ -233,3 +249,25 @@ func _on_Load_pressed(): else: _popup_file_dialog(EditorFileDialog.MODE_OPEN_FILE, "_set_editing_file") + +func _on_Extra_about_to_show(): + var popup := extra_button.get_popup() + popup.set_item_disabled(popup.get_item_index(ExtraOption.PASTE), _config_clipboard == null) + + +func _on_Extra_id_pressed(id: int) -> void: + match id: + ExtraOption.SAVE_AS: + _popup_file_dialog(EditorFileDialog.MODE_SAVE_FILE, "_on_SaveAsDialog_confirmed") + + ExtraOption.COPY: + if not _config_clipboard: + _config_clipboard = SFXRConfig.new() + _config_clipboard.copy_from(_config) + + ExtraOption.PASTE: + _config.copy_from(_config_clipboard) + _sync_ui() + _set_modified(not _config.is_equal(_config_defaults)) + audio_player.stream = null + diff --git a/addons/gdfxr/editor/Editor.tscn b/addons/gdfxr/editor/Editor.tscn index 039eaa1..da858f0 100644 --- a/addons/gdfxr/editor/Editor.tscn +++ b/addons/gdfxr/editor/Editor.tscn @@ -11,9 +11,6 @@ anchor_right = 1.0 anchor_bottom = 1.0 script = ExtResource( 2 ) -__meta__ = { -"_edit_use_anchors_": false -} [node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] @@ -44,14 +41,22 @@ hint_tooltip = "Save" script = ExtResource( 1 ) icon_name = "Save" -[node name="VSeparator" type="VSeparator" parent="Toolbar"] +[node name="Extra" type="MenuButton" parent="Toolbar"] margin_left = 48.0 -margin_right = 52.0 +margin_right = 60.0 +margin_bottom = 22.0 +hint_tooltip = "Extra Options" +script = ExtResource( 1 ) +icon_name = "GuiTabMenuHl" + +[node name="VSeparator" type="VSeparator" parent="Toolbar"] +margin_left = 64.0 +margin_right = 68.0 margin_bottom = 22.0 [node name="Play" type="Button" parent="Toolbar"] -margin_left = 56.0 -margin_right = 136.0 +margin_left = 72.0 +margin_right = 152.0 margin_bottom = 22.0 rect_min_size = Vector2( 80, 0 ) size_flags_horizontal = 0 @@ -60,8 +65,8 @@ script = ExtResource( 1 ) icon_name = "Play" [node name="Restore" type="Button" parent="Toolbar"] -margin_left = 140.0 -margin_right = 220.0 +margin_left = 156.0 +margin_right = 236.0 margin_bottom = 22.0 rect_min_size = Vector2( 80, 0 ) hint_tooltip = "Restore" @@ -71,12 +76,12 @@ script = ExtResource( 1 ) icon_name = "Reload" [node name="VSeparator2" type="VSeparator" parent="Toolbar"] -margin_left = 224.0 -margin_right = 228.0 +margin_left = 240.0 +margin_right = 244.0 margin_bottom = 22.0 [node name="Filename" type="Label" parent="Toolbar"] -margin_left = 232.0 +margin_left = 248.0 margin_top = 4.0 margin_right = 1020.0 margin_bottom = 18.0 @@ -367,6 +372,7 @@ parameter = "p_hpf_ramp" [connection signal="pressed" from="Toolbar/New" to="." method="_on_New_pressed"] [connection signal="pressed" from="Toolbar/Load" to="." method="_on_Load_pressed"] [connection signal="pressed" from="Toolbar/Save" to="." method="_on_Save_pressed"] +[connection signal="about_to_show" from="Toolbar/Extra" to="." method="_on_Extra_about_to_show"] [connection signal="pressed" from="Toolbar/Play" to="." method="_on_Play_pressed"] [connection signal="pressed" from="Toolbar/Restore" to="." method="_on_Restore_pressed"] [connection signal="pressed" from="Editor/Generators/Button" to="." method="_on_Randomize_pressed" binds= [ 0 ]] diff --git a/addons/gdfxr/editor/translations/gdfxr.pot b/addons/gdfxr/editor/translations/gdfxr.pot index 922d579..a992319 100644 --- a/addons/gdfxr/editor/translations/gdfxr.pot +++ b/addons/gdfxr/editor/translations/gdfxr.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: gdfxr 1.0\n" "Report-Msgid-Bugs-To: timothyqiu32@gmail.com\n" -"POT-Creation-Date: 2022-02-25 17:37+0800\n" +"POT-Creation-Date: 2022-03-07 18:27+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,6 +17,18 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.9.1\n" +#: addons/gdfxr/editor/Editor.gd +msgid "Save As..." +msgstr "" + +#: addons/gdfxr/editor/Editor.gd +msgid "Copy" +msgstr "" + +#: addons/gdfxr/editor/Editor.gd +msgid "Paste" +msgstr "" + #: addons/gdfxr/editor/Editor.gd #, python-format msgid "" @@ -65,6 +77,10 @@ msgstr "" msgid "Save" msgstr "" +#: addons/gdfxr/editor/Editor.tscn +msgid "Extra Options" +msgstr "" + #: addons/gdfxr/editor/Editor.tscn msgid "Play" msgstr "" diff --git a/addons/gdfxr/editor/translations/zh_CN.po b/addons/gdfxr/editor/translations/zh_CN.po index 8a7c16e..7fbde03 100644 --- a/addons/gdfxr/editor/translations/zh_CN.po +++ b/addons/gdfxr/editor/translations/zh_CN.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: gdfxr 1.0\n" "Report-Msgid-Bugs-To: timothyqiu32@gmail.com\n" -"POT-Creation-Date: 2022-02-25 17:37+0800\n" -"PO-Revision-Date: 2022-02-25 17:38+0800\n" +"POT-Creation-Date: 2022-03-07 18:27+0800\n" +"PO-Revision-Date: 2022-03-07 18:27+0800\n" "Last-Translator: Haoyu Qiu \n" "Language-Team: \n" "Language: zh_CN\n" @@ -19,6 +19,18 @@ msgstr "" "Generated-By: Babel 2.9.1\n" "X-Generator: Poedit 3.0.1\n" +#: addons/gdfxr/editor/Editor.gd +msgid "Save As..." +msgstr "另存为..." + +#: addons/gdfxr/editor/Editor.gd +msgid "Copy" +msgstr "复制" + +#: addons/gdfxr/editor/Editor.gd +msgid "Paste" +msgstr "粘贴" + #: addons/gdfxr/editor/Editor.gd #, python-format msgid "" @@ -73,6 +85,10 @@ msgstr "加载" msgid "Save" msgstr "保存" +#: addons/gdfxr/editor/Editor.tscn +msgid "Extra Options" +msgstr "更多选项" + #: addons/gdfxr/editor/Editor.tscn msgid "Play" msgstr "播放" diff --git a/addons/gdfxr/plugin.cfg b/addons/gdfxr/plugin.cfg index de10369..a8a5792 100644 --- a/addons/gdfxr/plugin.cfg +++ b/addons/gdfxr/plugin.cfg @@ -3,5 +3,5 @@ name="gdfxr" description="A Godot plugin that ports sfxr, the popular program of choice to make retro sound effects for games." author="Haoyu Qiu" -version="1.0" +version="1.1" script="plugin.gd" diff --git a/screenshots/editor-zh_CN.png b/screenshots/editor-zh_CN.png index 15d0e1b..e708d5e 100644 Binary files a/screenshots/editor-zh_CN.png and b/screenshots/editor-zh_CN.png differ diff --git a/screenshots/editor.png b/screenshots/editor.png index 4a35fb4..b3d887b 100644 Binary files a/screenshots/editor.png and b/screenshots/editor.png differ