1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-31 07:29:49 +00:00

Easily change the playback frame of an audio layer from the right click menu of cel buttons

This commit is contained in:
Emmanouil Papadeas 2024-12-10 23:15:10 +02:00
parent b7d4a9bd77
commit 7f63bb3a16
2 changed files with 12 additions and 2 deletions

View file

@ -2,6 +2,7 @@ class_name AudioLayer
extends BaseLayer extends BaseLayer
signal audio_changed signal audio_changed
signal playback_frame_changed
var audio: AudioStream: var audio: AudioStream:
set(value): set(value):
@ -11,7 +12,10 @@ var playback_position := 0.0: ## Measured in seconds.
get(): get():
var frame := project.frames[playback_frame] var frame := project.frames[playback_frame]
return frame.position_in_seconds(project) return frame.position_in_seconds(project)
var playback_frame := 0 var playback_frame := 0:
set(value):
playback_frame = value
playback_frame_changed.emit()
func _init(_project: Project, _name := "") -> void: func _init(_project: Project, _name := "") -> void:

View file

@ -32,9 +32,11 @@ func _ready() -> void:
elif cel is GroupCel: elif cel is GroupCel:
transparent_checker.visible = false transparent_checker.visible = false
elif cel is AudioCel: elif cel is AudioCel:
popup_menu.add_item("Play audio here")
_is_playing_audio() _is_playing_audio()
Global.cel_switched.connect(_is_playing_audio) Global.cel_switched.connect(_is_playing_audio)
Global.current_project.fps_changed.connect(_is_playing_audio) Global.current_project.fps_changed.connect(_is_playing_audio)
Global.current_project.layers[layer].playback_frame_changed.connect(_is_playing_audio)
func _notification(what: int) -> void: func _notification(what: int) -> void:
@ -134,7 +136,11 @@ func _on_PopupMenu_id_pressed(id: int) -> void:
properties.cel_indices = _get_cel_indices() properties.cel_indices = _get_cel_indices()
properties.popup_centered() properties.popup_centered()
MenuOptions.DELETE: MenuOptions.DELETE:
_delete_cel_content() var layer_class := Global.current_project.layers[layer]
if layer_class is AudioLayer:
layer_class.playback_frame = frame
else:
_delete_cel_content()
MenuOptions.LINK, MenuOptions.UNLINK: MenuOptions.LINK, MenuOptions.UNLINK:
var project := Global.current_project var project := Global.current_project