From fa3642f99c2743178e8868bfd5e965e8638e8651 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Tue, 10 Dec 2024 23:36:33 +0200 Subject: [PATCH] Some code improvements and documentation --- Translations/Translations.pot | 3 +++ src/Autoload/Global.gd | 2 +- src/Classes/Layers/AudioLayer.gd | 13 +++++++++---- src/Preferences/PreferencesDialog.tscn | 2 -- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Translations/Translations.pot b/Translations/Translations.pot index df9c4a3c4..621efde8a 100644 --- a/Translations/Translations.pot +++ b/Translations/Translations.pot @@ -2251,6 +2251,9 @@ msgstr "" msgid "Tilemap" msgstr "" +msgid "Audio" +msgstr "" + msgid "Layers" msgstr "" diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index edbab1ab7..420ec8672 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -1193,6 +1193,6 @@ func _save_to_override_file() -> void: file.store_line("[display]\n") file.store_line("window/subwindows/embed_subwindows=%s" % single_window_mode) file.store_line("window/per_pixel_transparency/allowed=%s" % window_transparency) - file.store_line("[audio]\n") if dummy_audio_driver: + file.store_line("[audio]\n") file.store_line('driver/driver="Dummy"') diff --git a/src/Classes/Layers/AudioLayer.gd b/src/Classes/Layers/AudioLayer.gd index 0a6100bf4..ca22fb086 100644 --- a/src/Classes/Layers/AudioLayer.gd +++ b/src/Classes/Layers/AudioLayer.gd @@ -1,18 +1,21 @@ class_name AudioLayer extends BaseLayer +## A unique type of layer which acts as an audio track for the timeline. +## Each audio layer has one audio stream, and its starting position can be +## in any point during the animation. signal audio_changed signal playback_frame_changed -var audio: AudioStream: +var audio: AudioStream: ## The audio stream of the layer. set(value): audio = value audio_changed.emit() -var playback_position := 0.0: ## Measured in seconds. +var playback_position := 0.0: ## The time in seconds where the audio stream starts playing. get(): var frame := project.frames[playback_frame] return frame.position_in_seconds(project) -var playback_frame := 0: +var playback_frame := 0: ## The frame where the audio stream starts playing. set(value): playback_frame = value playback_frame_changed.emit() @@ -23,6 +26,7 @@ func _init(_project: Project, _name := "") -> void: name = _name +## Returns the length of the audio stream. func get_audio_length() -> float: if is_instance_valid(audio): return audio.get_length() @@ -30,6 +34,7 @@ func get_audio_length() -> float: return -1.0 +## Returns the class name of the audio stream. E.g. "AudioStreamMP3". func get_audio_type() -> String: if not is_instance_valid(audio): return "" @@ -61,4 +66,4 @@ func new_empty_cel() -> AudioCel: func set_name_to_default(number: int) -> void: - name = tr("Audio track") + " %s" % number + name = tr("Audio") + " %s" % number diff --git a/src/Preferences/PreferencesDialog.tscn b/src/Preferences/PreferencesDialog.tscn index bdc767232..341e268df 100644 --- a/src/Preferences/PreferencesDialog.tscn +++ b/src/Preferences/PreferencesDialog.tscn @@ -1156,13 +1156,11 @@ text = "On" [node name="DummyAudioDriverLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Performance/PerformanceContainer" groups=["DesktopOnly"]] layout_mode = 2 -tooltip_text = "If enabled, the application window can become transparent. This affects performance, so keep it off if you don't need it." mouse_filter = 0 text = "Use dummy audio driver" [node name="DummyAudioDriver" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Performance/PerformanceContainer" groups=["DesktopOnly"]] layout_mode = 2 -tooltip_text = "If enabled, the application window can become transparent. This affects performance, so keep it off if you don't need it." mouse_default_cursor_shape = 2 text = "On"