Decouple NoteHandler from InputHandler
This commit is contained in:
parent
aed0f952c7
commit
812f5891af
|
@ -28,7 +28,7 @@ shader_param/px = 0.00108696
|
||||||
shader_param/px2 = 0.00217391
|
shader_param/px2 = 0.00217391
|
||||||
shader_param/alpha = 1.0
|
shader_param/alpha = 1.0
|
||||||
|
|
||||||
[sub_resource type="ArrayMesh" id=7]
|
[sub_resource type="ArrayMesh" id=2]
|
||||||
surfaces/0 = {
|
surfaces/0 = {
|
||||||
"aabb": AABB( -481.834, -481.834, 0, 963.667, 963.667, 0 ),
|
"aabb": AABB( -481.834, -481.834, 0, 963.667, 963.667, 0 ),
|
||||||
"array_data": PoolByteArray( 0, 0, 220, 67, 0, 0, 0, 0, 166, 59, 0, 0, 177, 234, 240, 67, 0, 0, 0, 0, 48, 60, 0, 0, 95, 168, 216, 67, 118, 207, 152, 66, 137, 59, 80, 49, 183, 65, 237, 67, 202, 86, 167, 66, 32, 60, 210, 49, 125, 187, 206, 67, 38, 125, 22, 67, 48, 59, 60, 53, 64, 99, 226, 67, 249, 203, 36, 67, 223, 59, 187, 53, 141, 134, 190, 67, 0, 0, 92, 67, 160, 58, 166, 55, 217, 163, 208, 67, 177, 234, 112, 67, 65, 59, 48, 56, 159, 135, 168, 67, 204, 105, 141, 67, 220, 57, 235, 56, 142, 141, 184, 67, 186, 219, 154, 67, 107, 58, 98, 57, 204, 105, 141, 67, 159, 135, 168, 67, 235, 56, 220, 57, 186, 219, 154, 67, 142, 141, 184, 67, 98, 57, 107, 58, 0, 0, 92, 67, 141, 134, 190, 67, 166, 55, 160, 58, 177, 234, 112, 67, 217, 163, 208, 67, 48, 56, 65, 59, 38, 125, 22, 67, 125, 187, 206, 67, 60, 53, 48, 59, 249, 203, 36, 67, 64, 99, 226, 67, 187, 53, 223, 59, 118, 207, 152, 66, 95, 168, 216, 67, 80, 49, 137, 59, 202, 86, 167, 66, 183, 65, 237, 67, 210, 49, 32, 60, 141, 172, 242, 40, 0, 0, 220, 67, 0, 0, 166, 59, 143, 223, 4, 41, 177, 234, 240, 67, 0, 0, 48, 60, 118, 207, 152, 194, 95, 168, 216, 67, 80, 177, 137, 59, 202, 86, 167, 194, 183, 65, 237, 67, 210, 177, 32, 60, 38, 125, 22, 195, 125, 187, 206, 67, 60, 181, 48, 59, 249, 203, 36, 195, 64, 99, 226, 67, 187, 181, 223, 59, 0, 0, 92, 195, 141, 134, 190, 67, 166, 183, 160, 58, 177, 234, 112, 195, 217, 163, 208, 67, 48, 184, 65, 59, 204, 105, 141, 195, 159, 135, 168, 67, 235, 184, 220, 57, 186, 219, 154, 195, 142, 141, 184, 67, 98, 185, 107, 58, 159, 135, 168, 195, 204, 105, 141, 67, 220, 185, 235, 56, 142, 141, 184, 195, 186, 219, 154, 67, 107, 186, 98, 57, 141, 134, 190, 195, 0, 0, 92, 67, 160, 186, 166, 55, 217, 163, 208, 195, 177, 234, 112, 67, 65, 187, 48, 56, 125, 187, 206, 195, 38, 125, 22, 67, 48, 187, 60, 53, 64, 99, 226, 195, 249, 203, 36, 67, 223, 187, 187, 53, 95, 168, 216, 195, 118, 207, 152, 66, 137, 187, 80, 49, 183, 65, 237, 195, 202, 86, 167, 66, 32, 188, 210, 49, 0, 0, 220, 195, 141, 172, 114, 41, 166, 187, 0, 0, 177, 234, 240, 195, 143, 223, 132, 41, 48, 188, 0, 0, 95, 168, 216, 195, 118, 207, 152, 194, 137, 187, 80, 177, 183, 65, 237, 195, 202, 86, 167, 194, 32, 188, 210, 177, 125, 187, 206, 195, 38, 125, 22, 195, 48, 187, 60, 181, 64, 99, 226, 195, 249, 203, 36, 195, 223, 187, 187, 181, 141, 134, 190, 195, 0, 0, 92, 195, 160, 186, 166, 183, 217, 163, 208, 195, 177, 234, 112, 195, 65, 187, 48, 184, 159, 135, 168, 195, 204, 105, 141, 195, 220, 185, 235, 184, 142, 141, 184, 195, 186, 219, 154, 195, 107, 186, 98, 185, 204, 105, 141, 195, 159, 135, 168, 195, 235, 184, 220, 185, 186, 219, 154, 195, 142, 141, 184, 195, 98, 185, 107, 186, 0, 0, 92, 195, 141, 134, 190, 195, 166, 183, 160, 186, 177, 234, 112, 195, 217, 163, 208, 195, 48, 184, 65, 187, 38, 125, 22, 195, 125, 187, 206, 195, 60, 181, 48, 187, 249, 203, 36, 195, 64, 99, 226, 195, 187, 181, 223, 187, 118, 207, 152, 194, 95, 168, 216, 195, 80, 177, 137, 187, 202, 86, 167, 194, 183, 65, 237, 195, 210, 177, 32, 188, 106, 1, 182, 169, 0, 0, 220, 195, 0, 0, 166, 187, 87, 79, 199, 169, 177, 234, 240, 195, 0, 0, 48, 188, 118, 207, 152, 66, 95, 168, 216, 195, 80, 49, 137, 187, 202, 86, 167, 66, 183, 65, 237, 195, 210, 49, 32, 188, 38, 125, 22, 67, 125, 187, 206, 195, 60, 53, 48, 187, 249, 203, 36, 67, 64, 99, 226, 195, 187, 53, 223, 187, 0, 0, 92, 67, 141, 134, 190, 195, 166, 55, 160, 186, 177, 234, 112, 67, 217, 163, 208, 195, 48, 56, 65, 187, 204, 105, 141, 67, 159, 135, 168, 195, 235, 56, 220, 185, 186, 219, 154, 67, 142, 141, 184, 195, 98, 57, 107, 186, 159, 135, 168, 67, 204, 105, 141, 195, 220, 57, 235, 184, 142, 141, 184, 67, 186, 219, 154, 195, 107, 58, 98, 185, 141, 134, 190, 67, 0, 0, 92, 195, 160, 58, 166, 183, 217, 163, 208, 67, 177, 234, 112, 195, 65, 59, 48, 184, 125, 187, 206, 67, 38, 125, 22, 195, 48, 59, 60, 181, 64, 99, 226, 67, 249, 203, 36, 195, 223, 59, 187, 181, 95, 168, 216, 67, 118, 207, 152, 194, 137, 59, 80, 177, 183, 65, 237, 67, 202, 86, 167, 194, 32, 60, 210, 177, 0, 0, 220, 67, 0, 0, 0, 0, 166, 59, 0, 0, 177, 234, 240, 67, 0, 0, 0, 0, 48, 60, 0, 0 ),
|
"array_data": PoolByteArray( 0, 0, 220, 67, 0, 0, 0, 0, 166, 59, 0, 0, 177, 234, 240, 67, 0, 0, 0, 0, 48, 60, 0, 0, 95, 168, 216, 67, 118, 207, 152, 66, 137, 59, 80, 49, 183, 65, 237, 67, 202, 86, 167, 66, 32, 60, 210, 49, 125, 187, 206, 67, 38, 125, 22, 67, 48, 59, 60, 53, 64, 99, 226, 67, 249, 203, 36, 67, 223, 59, 187, 53, 141, 134, 190, 67, 0, 0, 92, 67, 160, 58, 166, 55, 217, 163, 208, 67, 177, 234, 112, 67, 65, 59, 48, 56, 159, 135, 168, 67, 204, 105, 141, 67, 220, 57, 235, 56, 142, 141, 184, 67, 186, 219, 154, 67, 107, 58, 98, 57, 204, 105, 141, 67, 159, 135, 168, 67, 235, 56, 220, 57, 186, 219, 154, 67, 142, 141, 184, 67, 98, 57, 107, 58, 0, 0, 92, 67, 141, 134, 190, 67, 166, 55, 160, 58, 177, 234, 112, 67, 217, 163, 208, 67, 48, 56, 65, 59, 38, 125, 22, 67, 125, 187, 206, 67, 60, 53, 48, 59, 249, 203, 36, 67, 64, 99, 226, 67, 187, 53, 223, 59, 118, 207, 152, 66, 95, 168, 216, 67, 80, 49, 137, 59, 202, 86, 167, 66, 183, 65, 237, 67, 210, 49, 32, 60, 141, 172, 242, 40, 0, 0, 220, 67, 0, 0, 166, 59, 143, 223, 4, 41, 177, 234, 240, 67, 0, 0, 48, 60, 118, 207, 152, 194, 95, 168, 216, 67, 80, 177, 137, 59, 202, 86, 167, 194, 183, 65, 237, 67, 210, 177, 32, 60, 38, 125, 22, 195, 125, 187, 206, 67, 60, 181, 48, 59, 249, 203, 36, 195, 64, 99, 226, 67, 187, 181, 223, 59, 0, 0, 92, 195, 141, 134, 190, 67, 166, 183, 160, 58, 177, 234, 112, 195, 217, 163, 208, 67, 48, 184, 65, 59, 204, 105, 141, 195, 159, 135, 168, 67, 235, 184, 220, 57, 186, 219, 154, 195, 142, 141, 184, 67, 98, 185, 107, 58, 159, 135, 168, 195, 204, 105, 141, 67, 220, 185, 235, 56, 142, 141, 184, 195, 186, 219, 154, 67, 107, 186, 98, 57, 141, 134, 190, 195, 0, 0, 92, 67, 160, 186, 166, 55, 217, 163, 208, 195, 177, 234, 112, 67, 65, 187, 48, 56, 125, 187, 206, 195, 38, 125, 22, 67, 48, 187, 60, 53, 64, 99, 226, 195, 249, 203, 36, 67, 223, 187, 187, 53, 95, 168, 216, 195, 118, 207, 152, 66, 137, 187, 80, 49, 183, 65, 237, 195, 202, 86, 167, 66, 32, 188, 210, 49, 0, 0, 220, 195, 141, 172, 114, 41, 166, 187, 0, 0, 177, 234, 240, 195, 143, 223, 132, 41, 48, 188, 0, 0, 95, 168, 216, 195, 118, 207, 152, 194, 137, 187, 80, 177, 183, 65, 237, 195, 202, 86, 167, 194, 32, 188, 210, 177, 125, 187, 206, 195, 38, 125, 22, 195, 48, 187, 60, 181, 64, 99, 226, 195, 249, 203, 36, 195, 223, 187, 187, 181, 141, 134, 190, 195, 0, 0, 92, 195, 160, 186, 166, 183, 217, 163, 208, 195, 177, 234, 112, 195, 65, 187, 48, 184, 159, 135, 168, 195, 204, 105, 141, 195, 220, 185, 235, 184, 142, 141, 184, 195, 186, 219, 154, 195, 107, 186, 98, 185, 204, 105, 141, 195, 159, 135, 168, 195, 235, 184, 220, 185, 186, 219, 154, 195, 142, 141, 184, 195, 98, 185, 107, 186, 0, 0, 92, 195, 141, 134, 190, 195, 166, 183, 160, 186, 177, 234, 112, 195, 217, 163, 208, 195, 48, 184, 65, 187, 38, 125, 22, 195, 125, 187, 206, 195, 60, 181, 48, 187, 249, 203, 36, 195, 64, 99, 226, 195, 187, 181, 223, 187, 118, 207, 152, 194, 95, 168, 216, 195, 80, 177, 137, 187, 202, 86, 167, 194, 183, 65, 237, 195, 210, 177, 32, 188, 106, 1, 182, 169, 0, 0, 220, 195, 0, 0, 166, 187, 87, 79, 199, 169, 177, 234, 240, 195, 0, 0, 48, 188, 118, 207, 152, 66, 95, 168, 216, 195, 80, 49, 137, 187, 202, 86, 167, 66, 183, 65, 237, 195, 210, 49, 32, 188, 38, 125, 22, 67, 125, 187, 206, 195, 60, 53, 48, 187, 249, 203, 36, 67, 64, 99, 226, 195, 187, 53, 223, 187, 0, 0, 92, 67, 141, 134, 190, 195, 166, 55, 160, 186, 177, 234, 112, 67, 217, 163, 208, 195, 48, 56, 65, 187, 204, 105, 141, 67, 159, 135, 168, 195, 235, 56, 220, 185, 186, 219, 154, 67, 142, 141, 184, 195, 98, 57, 107, 186, 159, 135, 168, 67, 204, 105, 141, 195, 220, 57, 235, 184, 142, 141, 184, 67, 186, 219, 154, 195, 107, 58, 98, 185, 141, 134, 190, 67, 0, 0, 92, 195, 160, 58, 166, 183, 217, 163, 208, 67, 177, 234, 112, 195, 65, 59, 48, 184, 125, 187, 206, 67, 38, 125, 22, 195, 48, 59, 60, 181, 64, 99, 226, 67, 249, 203, 36, 195, 223, 59, 187, 181, 95, 168, 216, 67, 118, 207, 152, 194, 137, 59, 80, 177, 183, 65, 237, 67, 202, 86, 167, 194, 32, 60, 210, 177, 0, 0, 220, 67, 0, 0, 0, 0, 166, 59, 0, 0, 177, 234, 240, 67, 0, 0, 0, 0, 48, 60, 0, 0 ),
|
||||||
|
@ -124,14 +124,13 @@ __meta__ = {
|
||||||
|
|
||||||
[node name="Receptors" type="MeshInstance2D" parent="Center"]
|
[node name="Receptors" type="MeshInstance2D" parent="Center"]
|
||||||
material = SubResource( 1 )
|
material = SubResource( 1 )
|
||||||
mesh = SubResource( 7 )
|
mesh = SubResource( 2 )
|
||||||
script = ExtResource( 9 )
|
script = ExtResource( 9 )
|
||||||
|
|
||||||
[node name="Tween" type="Tween" parent="Center/Receptors"]
|
[node name="Tween" type="Tween" parent="Center/Receptors"]
|
||||||
|
|
||||||
[node name="NoteHandler" type="Node2D" parent="Center"]
|
[node name="NoteHandler" type="Node2D" parent="Center"]
|
||||||
script = ExtResource( 8 )
|
script = ExtResource( 8 )
|
||||||
MusicPlayerPath = NodePath("")
|
|
||||||
|
|
||||||
[node name="Viewport" type="Viewport" parent="Center/NoteHandler"]
|
[node name="Viewport" type="Viewport" parent="Center/NoteHandler"]
|
||||||
size = Vector2( 1080, 1080 )
|
size = Vector2( 1080, 1080 )
|
||||||
|
@ -185,3 +184,6 @@ script = ExtResource( 1 )
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[connection signal="column_pressed" from="InputHandler" to="Center/NoteHandler" method="_on_InputHandler_column_pressed"]
|
||||||
|
[connection signal="column_released" from="InputHandler" to="Center/NoteHandler" method="_on_InputHandler_column_released"]
|
||||||
|
|
|
@ -2,10 +2,12 @@ extends Control
|
||||||
|
|
||||||
var buttons_pressed := PoolByteArray()
|
var buttons_pressed := PoolByteArray()
|
||||||
var touchbuttons_pressed := PoolByteArray()
|
var touchbuttons_pressed := PoolByteArray()
|
||||||
signal button_pressed(index) # Add int type to these once Godot supports typed signals
|
signal button_pressed(column) # Add int type to these once Godot supports typed signals
|
||||||
signal button_released(index)
|
signal button_released(column)
|
||||||
signal touchbutton_pressed(index)
|
signal touchbutton_pressed(column)
|
||||||
signal touchbutton_released(index)
|
signal touchbutton_released(column)
|
||||||
|
signal column_pressed(column) # This will trigger when either is pressed
|
||||||
|
signal column_released(column) # This will trigger when both are released
|
||||||
const TOUCHBUTTON_MIN_DIST := 0.8
|
const TOUCHBUTTON_MIN_DIST := 0.8
|
||||||
const TOUCHBUTTON_MAX_DIST := 1.075
|
const TOUCHBUTTON_MAX_DIST := 1.075
|
||||||
const BUTTON_MIN_DIST := 0.925
|
const BUTTON_MIN_DIST := 0.925
|
||||||
|
@ -20,6 +22,10 @@ func _init():
|
||||||
for i in Rules.COLS:
|
for i in Rules.COLS:
|
||||||
buttons_pressed[i] = 0
|
buttons_pressed[i] = 0
|
||||||
touchbuttons_pressed[i] = 0
|
touchbuttons_pressed[i] = 0
|
||||||
|
connect('button_pressed', self, '_on_button_pressed')
|
||||||
|
connect('touchbutton_pressed', self, '_on_button_pressed')
|
||||||
|
connect('button_released', self, '_on_button_released')
|
||||||
|
connect('touchbutton_released', self, '_on_touchbutton_released')
|
||||||
|
|
||||||
func print_pressed(col: int):
|
func print_pressed(col: int):
|
||||||
print('Pressed %d'%col)
|
print('Pressed %d'%col)
|
||||||
|
@ -68,3 +74,14 @@ func set_touchbutton_state(index: int, state: bool):
|
||||||
-1:
|
-1:
|
||||||
emit_signal('touchbutton_released', index)
|
emit_signal('touchbutton_released', index)
|
||||||
touchbuttons_pressed[index] = new_state
|
touchbuttons_pressed[index] = new_state
|
||||||
|
|
||||||
|
func _on_button_pressed(column: int):
|
||||||
|
emit_signal('column_pressed', column)
|
||||||
|
|
||||||
|
func _on_button_released(column: int):
|
||||||
|
if touchbuttons_pressed[column] == 0:
|
||||||
|
emit_signal('column_released', column)
|
||||||
|
|
||||||
|
func _on_touchbutton_released(column: int):
|
||||||
|
if buttons_pressed[column] == 0:
|
||||||
|
emit_signal('column_released', column)
|
||||||
|
|
|
@ -7,12 +7,9 @@ signal finished_song(song_key, score_data)
|
||||||
var running := false
|
var running := false
|
||||||
var song_key = ''
|
var song_key = ''
|
||||||
|
|
||||||
export var MusicPlayerPath := @'../../music'
|
|
||||||
export var VideoPlayerPath := @'../../video'
|
export var VideoPlayerPath := @'../../video'
|
||||||
export var InputHandlerPath := @'../../InputHandler'
|
|
||||||
onready var MusicPlayer := SFXPlayer.music_player
|
onready var MusicPlayer := SFXPlayer.music_player
|
||||||
onready var VideoPlayer := get_node(VideoPlayerPath)
|
onready var VideoPlayer := get_node(VideoPlayerPath)
|
||||||
onready var InputHandler := get_node(InputHandlerPath)
|
|
||||||
|
|
||||||
onready var Painter = $Painter
|
onready var Painter = $Painter
|
||||||
onready var SlideTrailHandler = $'Viewport/Center/SlideTrailHandler'
|
onready var SlideTrailHandler = $'Viewport/Center/SlideTrailHandler'
|
||||||
|
@ -257,8 +254,6 @@ func button_pressed(col):
|
||||||
if -hit_delta <= Rules.JUDGEMENT_TIMES_PRE[i]:
|
if -hit_delta <= Rules.JUDGEMENT_TIMES_PRE[i]:
|
||||||
activate_note(note, -i)
|
activate_note(note, -i)
|
||||||
return
|
return
|
||||||
func touchbutton_pressed(col):
|
|
||||||
button_pressed(col)
|
|
||||||
|
|
||||||
|
|
||||||
func do_hold_release(note):
|
func do_hold_release(note):
|
||||||
|
@ -299,15 +294,6 @@ func check_hold_release(col):
|
||||||
if note.is_held == true:
|
if note.is_held == true:
|
||||||
do_hold_release(note) # Separate function since there's no need to 'consume' releases
|
do_hold_release(note) # Separate function since there's no need to 'consume' releases
|
||||||
|
|
||||||
func button_released(col):
|
|
||||||
# We only care about hold release.
|
|
||||||
# For that particular case, we want both to be unheld.
|
|
||||||
if InputHandler.touchbuttons_pressed[col] == 0:
|
|
||||||
check_hold_release(col)
|
|
||||||
func touchbutton_released(col):
|
|
||||||
if InputHandler.buttons_pressed[col] == 0:
|
|
||||||
check_hold_release(col)
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
const arr_div := Vector3(2.0, float(Rules.COLS), TAU)
|
const arr_div := Vector3(2.0, float(Rules.COLS), TAU)
|
||||||
func _draw():
|
func _draw():
|
||||||
|
@ -471,11 +457,6 @@ func _ready():
|
||||||
noteline_array_image.fill(Color(0.0, 0.0, 0.0))
|
noteline_array_image.fill(Color(0.0, 0.0, 0.0))
|
||||||
# Format: first 15 rows are for hit events, last row is for releases only (no ring glow)
|
# Format: first 15 rows are for hit events, last row is for releases only (no ring glow)
|
||||||
|
|
||||||
InputHandler.connect('button_pressed', self, 'button_pressed')
|
|
||||||
InputHandler.connect('touchbutton_pressed', self, 'touchbutton_pressed')
|
|
||||||
InputHandler.connect('button_released', self, 'button_released')
|
|
||||||
InputHandler.connect('touchbutton_released', self, 'touchbutton_released')
|
|
||||||
|
|
||||||
meshinstance.material.set_shader_param('star_color', GameTheme.COLOR_STAR)
|
meshinstance.material.set_shader_param('star_color', GameTheme.COLOR_STAR)
|
||||||
meshinstance.material.set_shader_param('held_color', GameTheme.COLOR_HOLD_HELD)
|
meshinstance.material.set_shader_param('held_color', GameTheme.COLOR_HOLD_HELD)
|
||||||
meshinstance.material.set_shader_param('bps', bpm/60.0)
|
meshinstance.material.set_shader_param('bps', bpm/60.0)
|
||||||
|
@ -648,3 +629,10 @@ func _process(delta):
|
||||||
meshinstance.material.set_shader_param('screen_size', get_viewport().get_size())
|
meshinstance.material.set_shader_param('screen_size', get_viewport().get_size())
|
||||||
update()
|
update()
|
||||||
Painter.update()
|
Painter.update()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_InputHandler_column_pressed(column) -> void:
|
||||||
|
button_pressed(column)
|
||||||
|
|
||||||
|
func _on_InputHandler_column_released(column) -> void:
|
||||||
|
check_hold_release(column)
|
||||||
|
|
Loading…
Reference in New Issue