key binding now fully works
This commit is contained in:
parent
d75221dc1b
commit
90043c8e6f
3 changed files with 51 additions and 3 deletions
|
@ -4,9 +4,14 @@ extends Panel
|
|||
@export var movement_name : String = "Name"
|
||||
@export var flow_path : String = "../../../../../../HelenHouseFlyout/FlowControls/"
|
||||
@export var recording : bool = false
|
||||
@export var current_index : int = 0;
|
||||
|
||||
var in_flow : float = 1.0
|
||||
var out_flow : float = 1.0
|
||||
|
||||
var key_binding : InputEventKey = InputEventKey.new()
|
||||
var binding : bool = false
|
||||
var held_on_previous_frame : bool = false
|
||||
|
||||
signal movement_in(movement, rate)
|
||||
signal movement_out(movement, rate)
|
||||
|
@ -14,19 +19,43 @@ signal movement_out(movement, rate)
|
|||
func update_text() -> void:
|
||||
$Button.text = "%d - %s (%s)" % [movement_bit, movement_name, key_binding.as_text() if key_binding.keycode != 0 else "Unbound"]
|
||||
|
||||
func _update_in_flow(new_value: float) -> void:
|
||||
in_flow = new_value
|
||||
|
||||
func _update_out_flow(new_value: float) -> void:
|
||||
out_flow = new_value
|
||||
|
||||
func _ready() -> void:
|
||||
var animatronic = get_node("../../../../../../SubViewport/HelenHouse/3stHelen")
|
||||
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")
|
||||
if_node.value_updated.connect(self._update_in_flow)
|
||||
of_node.value_updated.connect(self._update_out_flow)
|
||||
in_flow = if_node.value
|
||||
out_flow = of_node.value
|
||||
movement_in.connect(animatronic._movement_in)
|
||||
movement_out.connect(animatronic._movement_out)
|
||||
movement_in.connect(self._movement_in)
|
||||
movement_out.connect(self._movement_out)
|
||||
update_text()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if (binding): return
|
||||
if (Input.is_key_pressed(key_binding.keycode)):
|
||||
if (!held_on_previous_frame):
|
||||
movement_in.emit(movement_name, in_flow)
|
||||
held_on_previous_frame = true;
|
||||
else:
|
||||
if (held_on_previous_frame):
|
||||
movement_out.emit(movement_name, out_flow)
|
||||
held_on_previous_frame = false;
|
||||
|
||||
func _movement_in(movement, rate):
|
||||
pass
|
||||
$ActiveBG.visible = true
|
||||
|
||||
func _movement_out(movement, rate):
|
||||
pass
|
||||
$ActiveBG.visible = false
|
||||
|
||||
func _on_button_pressed() -> void:
|
||||
if (recording): return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue