the recording revolution is upon us
This commit is contained in:
parent
6148a3ec45
commit
e1215c17b6
11 changed files with 289 additions and 64 deletions
|
@ -1,5 +1,24 @@
|
|||
extends Control
|
||||
|
||||
var playing : bool = false
|
||||
var recording : bool = false
|
||||
var index : int = 0
|
||||
var playback_rate : int = 1
|
||||
|
||||
signal step_forward()
|
||||
signal step_backward()
|
||||
signal start_recording()
|
||||
signal end_recording()
|
||||
signal return_to_zero()
|
||||
|
||||
func update_time_label() -> void:
|
||||
var frames = index % 60
|
||||
var seconds = floori(index/60) % 60
|
||||
var minutes = floori(index/360) % 60
|
||||
var hours = floori(index/7200)
|
||||
$SequencerPanel/TransportControls/TimeLabel.text = "%d:%02d:%02d:%02d" % [hours, minutes, seconds, frames]
|
||||
#$SequencerPanel/TransportControls/TimeLabel.text = str(index)
|
||||
|
||||
func _ready() -> void:
|
||||
get_tree().get_root().size_changed.connect(_on_size_changed)
|
||||
|
||||
|
@ -8,6 +27,12 @@ func _input(event: InputEvent) -> void:
|
|||
$CameraPreview.visible = !$CameraPreview.visible;
|
||||
$CameraFullScreen.visible = !$CameraFullScreen.visible;
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
if (playing || recording):
|
||||
step_forward.emit()
|
||||
index += 1
|
||||
update_time_label()
|
||||
|
||||
func _on_size_changed() -> void:
|
||||
$SubViewport.size = $ColorRect.size
|
||||
|
||||
|
@ -25,3 +50,63 @@ func _on_credits_input_eater_pressed() -> void:
|
|||
|
||||
func _on_v_scroll_bar_value_changed(value: float) -> void:
|
||||
$SequencerPanel/TimelinePanel/InvisibleMask/RowsHandle.position.y = value * -44
|
||||
|
||||
|
||||
func _on_play_button_pressed() -> void:
|
||||
playback_rate = 1
|
||||
playing = true
|
||||
recording = false
|
||||
end_recording.emit()
|
||||
|
||||
func _on_pause_button_pressed() -> void:
|
||||
playing = false
|
||||
recording = false
|
||||
end_recording.emit()
|
||||
|
||||
func _on_play_backwards_button_pressed() -> void:
|
||||
playback_rate = -1
|
||||
playing = true
|
||||
recording = false
|
||||
end_recording.emit()
|
||||
|
||||
func _on_fast_backwards_button_pressed() -> void:
|
||||
playback_rate = -2
|
||||
playing = true
|
||||
recording = false
|
||||
end_recording.emit()
|
||||
|
||||
func _on_step_backwards_button_pressed() -> void:
|
||||
playing = false
|
||||
recording = false
|
||||
end_recording.emit()
|
||||
step_backward.emit()
|
||||
if (index != 0): index -= 1
|
||||
update_time_label()
|
||||
|
||||
func _on_fast_forward_button_pressed() -> void:
|
||||
playback_rate = 2
|
||||
playing = true
|
||||
recording = false
|
||||
end_recording.emit()
|
||||
|
||||
func _on_step_forward_button_pressed() -> void:
|
||||
playing = false
|
||||
recording = false
|
||||
end_recording.emit()
|
||||
step_forward.emit()
|
||||
index += 1
|
||||
update_time_label()
|
||||
|
||||
func _on_record_button_pressed() -> void:
|
||||
playback_rate = 1
|
||||
playing = false
|
||||
recording = true
|
||||
start_recording.emit()
|
||||
|
||||
func _on_stop_button_pressed() -> void:
|
||||
playing = false
|
||||
recording = false
|
||||
index = 0
|
||||
end_recording.emit()
|
||||
return_to_zero.emit()
|
||||
update_time_label()
|
||||
|
|
6
Scripts/MovementFrameIndicator.gd
Normal file
6
Scripts/MovementFrameIndicator.gd
Normal file
|
@ -0,0 +1,6 @@
|
|||
extends Control
|
||||
|
||||
@export var x_offset : int = 0
|
||||
|
||||
func _ready() -> void:
|
||||
self.size.x += x_offset
|
1
Scripts/MovementFrameIndicator.gd.uid
Normal file
1
Scripts/MovementFrameIndicator.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://b4qincechbf63
|
|
@ -1,21 +1,84 @@
|
|||
extends Panel
|
||||
|
||||
@export var movement_bit : int = 0;
|
||||
@export var movement_bit : int = 0
|
||||
@export var movement_name : String = "Name"
|
||||
@export var flow_path : String = "../../../../../../HelenHouseFlyout/FlowControls/"
|
||||
@export var recording : bool = false
|
||||
@export var current_index : int = 0;
|
||||
@export var animatronic_path : String = "../../../../../../SubViewport/HelenHouse/3stHelen"
|
||||
@export var movements : Array[bool]
|
||||
|
||||
var in_flow : float = 1.0
|
||||
var out_flow : float = 1.0
|
||||
|
||||
var key_binding : InputEventKey = InputEventKey.new()
|
||||
var current_index : int = 0
|
||||
var binding : bool = false
|
||||
var held_on_previous_frame : bool = false
|
||||
var playback_held_on_previous_frame : bool = false
|
||||
var etching: bool = false
|
||||
var recording : bool = false
|
||||
var playing : bool = true
|
||||
|
||||
signal movement_in(movement, rate)
|
||||
signal movement_out(movement, rate)
|
||||
|
||||
func set_at_current() -> void:
|
||||
if (current_index > self.movements.size()-1): self.movements.append(true)
|
||||
else: self.movements.set(current_index, true)
|
||||
var indicator = load("res://Scenes/GUI/Controls/MovementFrameIndicatorOn.tscn")
|
||||
var instance = indicator.instantiate()
|
||||
instance.x_offset = current_index * 2
|
||||
$MovementsBG/InvisibleMask/MovementsHandle.add_child(instance)
|
||||
|
||||
func unset_at_current() -> void:
|
||||
if (current_index > self.movements.size()-1): self.movements.append(false)
|
||||
else: self.movements.set(current_index, false)
|
||||
var indicator = load("res://Scenes/GUI/Controls/MovementFrameIndicatorOff.tscn")
|
||||
var instance = indicator.instantiate()
|
||||
instance.x_offset = current_index * 2
|
||||
$MovementsBG/InvisibleMask/MovementsHandle.add_child(instance)
|
||||
|
||||
func check_at_current() -> bool:
|
||||
if (current_index > self.movements.size()-1): return false
|
||||
var out = self.movements.get(current_index)
|
||||
if (out == null): return false
|
||||
return out
|
||||
|
||||
func _step_forward():
|
||||
if (recording && etching): set_at_current()
|
||||
elif (recording && !etching): unset_at_current()
|
||||
if (playing):
|
||||
if (check_at_current()):
|
||||
if (!playback_held_on_previous_frame):
|
||||
movement_in.emit(movement_name, in_flow)
|
||||
playback_held_on_previous_frame = true;
|
||||
else:
|
||||
if (playback_held_on_previous_frame):
|
||||
movement_out.emit(movement_name, out_flow)
|
||||
playback_held_on_previous_frame = false;
|
||||
current_index += 1
|
||||
$MovementsBG/InvisibleMask/MovementsHandle.position.x -= 2
|
||||
|
||||
func _step_backward():
|
||||
if (current_index == 0): return
|
||||
current_index -= 1
|
||||
$MovementsBG/InvisibleMask/MovementsHandle.position.x += 2
|
||||
|
||||
func _return_to_zero():
|
||||
current_index = 0
|
||||
$MovementsBG/InvisibleMask/MovementsHandle.position.x = 120
|
||||
|
||||
func _start_recording():
|
||||
recording = true
|
||||
|
||||
func _end_recording():
|
||||
recording = false
|
||||
|
||||
func _start_playback():
|
||||
playing = true
|
||||
|
||||
func _end_playback():
|
||||
playing = false
|
||||
|
||||
func update_text() -> void:
|
||||
$Button.text = "%d - %s (%s)" % [movement_bit, movement_name, key_binding.as_text() if key_binding.keycode != 0 else "Unbound"]
|
||||
|
||||
|
@ -26,7 +89,7 @@ func _update_out_flow(new_value: float) -> void:
|
|||
out_flow = new_value
|
||||
|
||||
func _ready() -> void:
|
||||
var animatronic = get_node("../../../../../../SubViewport/HelenHouse/3stHelen")
|
||||
var animatronic = get_node(animatronic_path)
|
||||
if (flow_path != "None"):
|
||||
var if_node = get_node(flow_path + "InFlows/" + movement_name.replace(" ", "") + "Flow")
|
||||
var of_node = get_node(flow_path + "OutFlows/" + movement_name.replace(" ", "") + "Flow")
|
||||
|
@ -38,9 +101,15 @@ func _ready() -> void:
|
|||
movement_out.connect(animatronic._movement_out)
|
||||
movement_in.connect(self._movement_in)
|
||||
movement_out.connect(self._movement_out)
|
||||
var editor = get_node("../../../../../../")
|
||||
editor.step_forward.connect(_step_forward)
|
||||
editor.step_backward.connect(_step_backward)
|
||||
editor.start_recording.connect(_start_recording)
|
||||
editor.end_recording.connect(_end_recording)
|
||||
editor.return_to_zero.connect(_return_to_zero)
|
||||
update_text()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
func _process(_delta: float) -> void:
|
||||
if (binding): return
|
||||
if (Input.is_key_pressed(key_binding.keycode)):
|
||||
if (!held_on_previous_frame):
|
||||
|
@ -51,14 +120,15 @@ func _process(delta: float) -> void:
|
|||
movement_out.emit(movement_name, out_flow)
|
||||
held_on_previous_frame = false;
|
||||
|
||||
func _movement_in(movement, rate):
|
||||
func _movement_in(_movement, _rate):
|
||||
$ActiveBG.visible = true
|
||||
if (recording): etching = true
|
||||
|
||||
func _movement_out(movement, rate):
|
||||
func _movement_out(_movement, _rate):
|
||||
$ActiveBG.visible = false
|
||||
etching = false
|
||||
|
||||
func _on_button_pressed() -> void:
|
||||
if (recording): return
|
||||
if (binding):
|
||||
update_text()
|
||||
binding = false
|
||||
|
@ -67,7 +137,7 @@ func _on_button_pressed() -> void:
|
|||
$Button.text = "Press a key to bind."
|
||||
binding = true
|
||||
else:
|
||||
key_binding.keycode = 0
|
||||
key_binding.keycode = KEY_NONE
|
||||
update_text()
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue