diff --git a/addons/gdfxr/editor/Editor.gd b/addons/gdfxr/editor/Editor.gd index 6034db1..b1257ef 100644 --- a/addons/gdfxr/editor/Editor.gd +++ b/addons/gdfxr/editor/Editor.gd @@ -45,22 +45,22 @@ func _ready(): return # Running in the edited scene instead of from Plugin var popup := extra_button.get_popup() - popup.add_item(translator.tr("Save As..."), ExtraOption.SAVE_AS) + popup.add_item(translator.t("Save As..."), ExtraOption.SAVE_AS) popup.add_separator() - popup.add_icon_item(get_theme_icon("ActionCopy", "EditorIcons"), translator.tr("Copy"), ExtraOption.COPY) - popup.add_icon_item(get_theme_icon("ActionPaste", "EditorIcons"), translator.tr("Paste"), ExtraOption.PASTE) - popup.add_item(translator.tr("Paste from jsfxr"), ExtraOption.PASTE_JSFXR) - popup.add_separator(translator.tr("Recently Generated")) + popup.add_icon_item(get_theme_icon("ActionCopy", "EditorIcons"), translator.t("Copy"), ExtraOption.COPY) + popup.add_icon_item(get_theme_icon("ActionPaste", "EditorIcons"), translator.t("Paste"), ExtraOption.PASTE) + popup.add_item(translator.t("Paste from jsfxr"), ExtraOption.PASTE_JSFXR) + popup.add_separator(translator.t("Recently Generated")) popup.id_pressed.connect(_on_Extra_id_pressed) _category_names = { - SFXRConfig.Category.PICKUP_COIN: translator.tr("Pickup/Coin"), - SFXRConfig.Category.LASER_SHOOT: translator.tr("Laser/Shoot"), - SFXRConfig.Category.EXPLOSION: translator.tr("Explosion"), - SFXRConfig.Category.POWERUP: translator.tr("Powerup"), - SFXRConfig.Category.HIT_HURT: translator.tr("Hit/Hurt"), - SFXRConfig.Category.JUMP: translator.tr("Jump"), - SFXRConfig.Category.BLIP_SELECT: translator.tr("Blip/Select"), + SFXRConfig.Category.PICKUP_COIN: translator.t("Pickup/Coin"), + SFXRConfig.Category.LASER_SHOOT: translator.t("Laser/Shoot"), + SFXRConfig.Category.EXPLOSION: translator.t("Explosion"), + SFXRConfig.Category.POWERUP: translator.t("Powerup"), + SFXRConfig.Category.HIT_HURT: translator.t("Hit/Hurt"), + SFXRConfig.Category.JUMP: translator.t("Jump"), + SFXRConfig.Category.BLIP_SELECT: translator.t("Blip/Select"), } var params := find_child("Params") as Container @@ -97,7 +97,7 @@ func edit(object: Variant) -> void: var path := object.resource_path as String if _modified: _popup_confirm( - translator.tr("There are unsaved changes.\nOpen '%s' anyway?") % path, + translator.t("There are unsaved changes.\nOpen '%s' anyway?") % path, _set_editing_file.bind(path) ) else: @@ -129,7 +129,7 @@ func _popup_confirm(content: String, callback: Callable) -> void: var dialog := ConfirmationDialog.new() add_child(dialog) dialog.dialog_text = content - dialog.title = translator.tr("SFXR Editor") + dialog.title = translator.t("SFXR Editor") dialog.confirmed.connect(callback) dialog.popup_centered() dialog.visibility_changed.connect(dialog.queue_free) @@ -139,7 +139,7 @@ func _popup_message(content: String) -> void: var dialog := AcceptDialog.new() add_child(dialog) dialog.dialog_text = content - dialog.title = translator.tr("SFXR Editor") + dialog.title = translator.t("SFXR Editor") dialog.popup_centered() dialog.visibility_changed.connect(dialog.queue_free) @@ -158,7 +158,7 @@ func _popup_file_dialog(mode: int, callback: Callable, default_filename := Defau if _path: dialog.current_path = _generate_serial_path(_path) - dialog.add_filter("*.sfxr; %s" % translator.tr("SFXR Audio")) + dialog.add_filter("*.sfxr; %s" % translator.t("SFXR Audio")) dialog.file_selected.connect(callback) dialog.popup_centered_ratio() dialog.visibility_changed.connect(dialog.queue_free) @@ -184,7 +184,7 @@ func _set_editing_file(path: String) -> int: # Error else: var err := _config.load(path) if err != OK: - _popup_message(translator.tr("'%s' is not a valid SFXR file.") % path) + _popup_message(translator.t("'%s' is not a valid SFXR file.") % path) return err audio_player.stream = load(path) @@ -197,7 +197,7 @@ func _set_modified(value: bool) -> void: _modified = value var has_file := not _path.is_empty() - var base = _path if has_file else translator.tr("Unsaved sound") + var base = _path if has_file else translator.t("Unsaved sound") if _modified: base += "(*)" filename_label.text = base @@ -281,7 +281,7 @@ func _on_Play_pressed(force_regenerate := false): func _on_Randomize_pressed(category: int): if category == -1: _config.randomize() - _push_recent(translator.tr("Randomize")) + _push_recent(translator.t("Randomize")) else: _config.randomize_in_category(category) _push_recent(_category_names.get(category, "Unknown")) @@ -294,7 +294,7 @@ func _on_Randomize_pressed(category: int): func _on_Mutate_pressed(): _config.mutate() - _push_recent(translator.tr("Mutate")) + _push_recent(translator.t("Mutate")) _set_modified(true) _sync_ui() _on_Play_pressed(true) @@ -307,7 +307,7 @@ func _on_Restore_pressed(): func _on_New_pressed(): if _modified: _popup_confirm( - translator.tr("There are unsaved changes.\nCreate a new one anyway?"), + translator.t("There are unsaved changes.\nCreate a new one anyway?"), _on_New_confirmed ) else: @@ -337,7 +337,7 @@ func _on_SaveAsDialog_confirmed(path: String): func _on_Load_pressed(): if _modified: _popup_confirm( - translator.tr("There are unsaved changes.\nLoad anyway?"), + translator.t("There are unsaved changes.\nLoad anyway?"), _popup_file_dialog.bind(EditorFileDialog.FILE_MODE_OPEN_FILE, "_set_editing_file") ) else: @@ -357,7 +357,7 @@ func _on_Extra_about_to_show(): popup.remove_item(count - 1 - i) if _config_recents.is_empty(): - popup.add_item(translator.tr("None"), ExtraOption.RECENT) + popup.add_item(translator.t("None"), ExtraOption.RECENT) popup.set_item_disabled(popup.get_item_index(ExtraOption.RECENT), true) else: for i in _config_recents.size(): @@ -382,7 +382,7 @@ func _on_Extra_id_pressed(id: int) -> void: if pasted.load_from_base58(DisplayServer.clipboard_get()) == OK: _restore_from_config(pasted) else: - _popup_message(translator.tr("Clipboard does not contain code copied from jsfxr.")) + _popup_message(translator.t("Clipboard does not contain code copied from jsfxr.")) _: var i := id - ExtraOption.RECENT as int diff --git a/addons/gdfxr/editor/Editor.tscn b/addons/gdfxr/editor/Editor.tscn index c3050dd..cc7db06 100644 --- a/addons/gdfxr/editor/Editor.tscn +++ b/addons/gdfxr/editor/Editor.tscn @@ -4,7 +4,7 @@ [ext_resource type="Script" path="res://addons/gdfxr/editor/Editor.gd" id="2"] [ext_resource type="PackedScene" uid="uid://p27e3x3kk5e0" path="res://addons/gdfxr/editor/ParamSlider.tscn" id="3"] [ext_resource type="PackedScene" uid="uid://b8wt6fq8w6mxc" path="res://addons/gdfxr/editor/ParamOption.tscn" id="4"] -[ext_resource type="PackedScene" path="res://addons/gdfxr/editor/PluginTranslator.tscn" id="5"] +[ext_resource type="PackedScene" uid="uid://cewvefxbttrds" path="res://addons/gdfxr/editor/PluginTranslator.tscn" id="5"] [ext_resource type="PackedScene" path="res://addons/gdfxr/editor/VersionButton.tscn" id="6"] [node name="Editor" type="VBoxContainer"] diff --git a/addons/gdfxr/editor/ParamOption.tscn b/addons/gdfxr/editor/ParamOption.tscn index e7b6240..1a78edb 100644 --- a/addons/gdfxr/editor/ParamOption.tscn +++ b/addons/gdfxr/editor/ParamOption.tscn @@ -9,34 +9,22 @@ offset_bottom = 40.0 pivot_offset = Vector2(41, -65) size_flags_horizontal = 3 script = ExtResource("1") -options = [] -parameter = "" [node name="Label" type="Label" parent="."] -custom_minimum_size = Vector2i(100, 0) +custom_minimum_size = Vector2(100, 0) layout_mode = 2 -offset_top = 7.0 -offset_right = 132.0 -offset_bottom = 33.0 size_flags_horizontal = 3 text = "Waveform" +horizontal_alignment = 2 [node name="OptionButton" type="OptionButton" parent="."] -custom_minimum_size = Vector2i(105, 0) +custom_minimum_size = Vector2(105, 0) layout_mode = 2 -offset_left = 136.0 -offset_top = 10.0 -offset_right = 241.0 -offset_bottom = 30.0 size_flags_vertical = 4 clip_text = true [node name="Reset" type="Button" parent="."] layout_mode = 2 -offset_left = 245.0 -offset_top = 16.0 -offset_right = 253.0 -offset_bottom = 24.0 size_flags_vertical = 4 focus_mode = 0 flat = true diff --git a/addons/gdfxr/editor/ParamSlider.tscn b/addons/gdfxr/editor/ParamSlider.tscn index 9739590..6e1a5ab 100644 --- a/addons/gdfxr/editor/ParamSlider.tscn +++ b/addons/gdfxr/editor/ParamSlider.tscn @@ -9,35 +9,23 @@ offset_right = 253.0 offset_bottom = 40.0 size_flags_horizontal = 3 script = ExtResource("1") -label = "" -parameter = "" [node name="Label" type="Label" parent="."] -custom_minimum_size = Vector2i(100, 0) +custom_minimum_size = Vector2(100, 0) layout_mode = 2 -offset_top = 8.0 -offset_right = 132.0 -offset_bottom = 31.0 size_flags_horizontal = 3 +horizontal_alignment = 2 [node name="HSlider" type="Control" parent="."] clip_contents = true -custom_minimum_size = Vector2i(105, 0) +custom_minimum_size = Vector2(105, 0) layout_mode = 2 -anchors_preset = 0 -offset_left = 136.0 -offset_right = 241.0 -offset_bottom = 40.0 focus_mode = 2 mouse_default_cursor_shape = 10 script = ExtResource("3") [node name="Reset" type="Button" parent="."] layout_mode = 2 -offset_left = 245.0 -offset_top = 16.0 -offset_right = 253.0 -offset_bottom = 24.0 size_flags_vertical = 4 focus_mode = 0 flat = true diff --git a/addons/gdfxr/editor/PluginTranslator.gd b/addons/gdfxr/editor/PluginTranslator.gd index 7a563a8..5e7069d 100644 --- a/addons/gdfxr/editor/PluginTranslator.gd +++ b/addons/gdfxr/editor/PluginTranslator.gd @@ -23,10 +23,10 @@ func set_plugin(v: EditorPlugin) -> void: _translation = ResourceLoader.load(path) if _translation: - _translate_node(get_parent()) + _translate_node.call_deferred(get_parent()) -func tr(message: StringName, context := StringName()) -> String: +func t(message: StringName) -> String: if _translation: var translated := _translation.get_message(message) if translated: @@ -36,22 +36,22 @@ func tr(message: StringName, context := StringName()) -> String: func _translate_node(node: Node): if node is Control: - node.tooltip_text = tr(node.tooltip_text) + node.tooltip_text = t(node.tooltip_text) if node is HBoxContainer and node.has_method("set_options"): var options = [] for item in node.options: - options.append(tr(item)) + options.append(t(item)) node.options = options if node is Button and not node is OptionButton: - node.text = tr(node.text) + node.text = t(node.text) if node is Label: - node.text = tr(node.text) + node.text = t(node.text) if node is Slider: - node.tooltip_text = tr(node.tooltip_text) + node.tooltip_text = t(node.tooltip_text) for child in node.get_children(): _translate_node(child) diff --git a/addons/gdfxr/editor/PluginTranslator.tscn b/addons/gdfxr/editor/PluginTranslator.tscn index 1868f2a..7d77bab 100644 --- a/addons/gdfxr/editor/PluginTranslator.tscn +++ b/addons/gdfxr/editor/PluginTranslator.tscn @@ -1,6 +1,6 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=2 format=3 uid="uid://cewvefxbttrds"] -[ext_resource path="res://addons/gdfxr/editor/PluginTranslator.gd" type="Script" id=1] +[ext_resource type="Script" path="res://addons/gdfxr/editor/PluginTranslator.gd" id="1"] [node name="PluginTranslator" type="Node"] -script = ExtResource( 1 ) +script = ExtResource("1")