mirror of
https://github.com/Relintai/gdfxr.git
synced 2024-11-10 00:52:12 +01:00
Add extra options menu
* Save As * Copy & Paste
This commit is contained in:
parent
bf351cff87
commit
a2cf6ac404
@ -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
|
||||
|
||||
|
@ -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 ]]
|
||||
|
@ -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 <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\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 ""
|
||||
|
@ -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 <timothyqiu32@gmail.com>\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 "播放"
|
||||
|
@ -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"
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Loading…
Reference in New Issue
Block a user