Skip to content

Commit

Permalink
squash the slide handle bug for good
Browse files Browse the repository at this point in the history
  • Loading branch information
towai committed Aug 13, 2024
1 parent c427a20 commit 53ab190
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion note/drag_helper.gd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func init_drag():
drag_start = owner.get_local_mouse_position()


func process_drag(drag_type=Note.DRAG_NONE):
func process_drag(drag_type=Note.DRAG_NONE): # -> float|Vector2|null
match drag_type:
Note.DRAG_BAR:
var new_time : float
Expand Down
19 changes: 10 additions & 9 deletions note/note.gd
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,18 @@ var note_reference: Note: #A nice and tidy concatenator for a note ref's data.
note_data = [note_ref.bar,note_ref.length,note_ref.pitch_start,note_ref.pitch_delta,note_ref.pitch_start+note_ref.pitch_delta]
###Dew variables###

# cat rolls the most horrible solution ever, asked to leave the repo
func find_idx_in_slide() -> int:

func update_slide_idx() -> int:
var left_neighbor : Note = touching_notes.get(START_IS_TOUCHING)

match left_neighbor:
null: index_in_slide = 0
_: index_in_slide = (left_neighbor.find_idx_in_slide() + 1)
_: index_in_slide = (left_neighbor.update_slide_idx() + 1)

queue_redraw()
return index_in_slide


func propagate_to_the_right(f:StringName,args:Array=[]):
var right_neighbor : Note = touching_notes.get(END_IS_TOUCHING)

Expand Down Expand Up @@ -232,7 +233,7 @@ func _end_drag():
note_reference = note_package[i][0] #adding the new note data to the end of each individual data set via setter.
note_package[i].append(note_data) #[reference,pre-drag_data_array] => [reference,pre-drag_data_array,post-drag_data_array]
i += 1
Global.actions.append(2) #Record edit as a set of dragged notes, and append its data to Global.changes for future use.
Global.actions.append(Global.ACTION_DRAG) #Record edit as a set of dragged notes, and append its data to Global.changes for future use.
Global.changes.append(note_package)
Global.revision += 1
chart.update_note_array()
Expand All @@ -250,11 +251,11 @@ func package_neighbors(self_note) -> Array: #Dew: The initial creation of the

func remove_note(): #Dew: We cannot use queue_free(), because we need to reinstate the deleted notes with an undo!
Global.clear_future_edits() #First, check for future, undone edits in the stack that must be overwritten to continue editing...
Global.actions.append(1) #... allowing us to continue recording our edit history...
Global.changes.append([[self,self.bar]]) #... via the note's object reference.
Global.actions.append(Global.ACTION_DELETE) #... allowing us to continue recording our edit history...
Global.changes.append([[self,self.bar]]) #... via the note's object reference.
Global.revision += 1
chart.remove_child(self)
print(propagate_to_the_right("find_idx_in_slide"))
propagate_to_the_right("update_slide_idx")
chart.update_note_array()


Expand Down Expand Up @@ -282,7 +283,7 @@ func update_handle_visibility():
var next_note = touching_notes.get(END_IS_TOUCHING)

if ((prev_note != null && bar != prev_note.end)
|| (next_note != null && end != next_note.bar)):
|| (next_note != null && end != next_note.bar)):
update_touching_notes()

if !show_bar_handle:
Expand Down Expand Up @@ -369,7 +370,7 @@ func _draw():
draw_polyline_colors(points, colors, 6, true)
draw_polyline_colors(points, colors, 6, true)

if !is_tap_note || has_focus():_draw_tail.call()
if !is_tap_note || has_focus(): _draw_tail.call()
if show_bar_handle: _draw_bar_handle.call()
if show_end_handle: _draw_end_handle.call()

Expand Down
7 changes: 4 additions & 3 deletions note/slide_helper.gd
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ func find_touching_notes() -> Dictionary:
var result := {}

var prev_note = get_matching_note_off(owner.bar,[owner])
if prev_note: result[Note.START_IS_TOUCHING] = prev_note
if prev_note && chart.is_ancestor_of(owner): result[Note.START_IS_TOUCHING] = prev_note # be polite and don't trick your friend

var next_note = get_matching_note_on(owner.end,[owner])
if next_note: result[Note.END_IS_TOUCHING] = next_note
if next_note && chart.is_ancestor_of(owner): result[Note.END_IS_TOUCHING] = next_note # ||

return result

Expand Down Expand Up @@ -83,11 +83,12 @@ func update_touching_notes():
null: if old_next_note != null: old_next_note.update_touching_notes()
_:
next_note.touching_notes[Note.START_IS_TOUCHING] = owner if owner.bar >= 0 \
&& chart.is_ancestor_of(owner) && chart.is_ancestor_of(next_note) \
else null
next_note.bar = owner.end
next_note.update_handle_visibility()

owner.propagate_to_the_right("find_idx_in_slide",[])
owner.propagate_to_the_right("update_slide_idx",[])


func pass_on_slide_propagation():
Expand Down
2 changes: 1 addition & 1 deletion pianoroll/chart.gd
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func _do_tmb_update():
if !(note is Note) || note.is_queued_for_deletion():
continue
note.position.x = note.bar * bar_spacing
if !note.touching_notes.has(Note.END_IS_TOUCHING): note.find_idx_in_slide()
if !note.touching_notes.has(Note.END_IS_TOUCHING): note.update_slide_idx()
queue_redraw()
redraw_notes()
_update_queued = false
Expand Down

0 comments on commit 53ab190

Please sign in to comment.