Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix visual editor event copy/paste issues #2459

Merged
merged 5 commits into from
Nov 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,12 @@ func get_events_indexed(events:Array) -> Dictionary:
if event.resource is DialogicEndBranchEvent:
continue

indexed_dict[event.get_index()] = event.resource.to_text()
indexed_dict[event.get_index()] = event.resource._store_as_string()

# store an end branch if it is selected or connected to a selected event
if 'end_node' in event and event.end_node:
event = event.end_node
indexed_dict[event.get_index()] = event.resource.to_text()
indexed_dict[event.get_index()] = event.resource._store_as_string()
elif event.resource is DialogicEndBranchEvent:
if event.parent_node in events: # add local index
indexed_dict[event.get_index()] += str(events.find(event.parent_node))
Expand Down Expand Up @@ -471,7 +471,7 @@ func add_events_indexed(indexed_events:Dictionary) -> void:
event_resource = i.duplicate()
break

event_resource.from_text(indexed_events[event_idx])
event_resource._load_from_string(indexed_events[event_idx])

# now create the visual block.
deselect_all_items()
Expand Down Expand Up @@ -542,7 +542,7 @@ func copy_selected_events() -> void:

var event_copy_array := []
for item in selected_items:
event_copy_array.append(item.resource.to_text())
event_copy_array.append(item.resource._store_as_string())
if item.resource is DialogicEndBranchEvent:
if item.parent_node in selected_items: # add local index
event_copy_array[-1] += str(selected_items.find(item.parent_node))
Expand Down Expand Up @@ -1099,16 +1099,17 @@ func _input(event:InputEvent) -> void:
get_viewport().set_input_as_handled()

"Ctrl+C":
select_events_indexed(get_events_indexed(selected_items))
copy_selected_events()
get_viewport().set_input_as_handled()

"Ctrl+V":
var events_list := get_clipboard_data()
var paste_position := -1
var paste_position := 0
if selected_items:
paste_position = selected_items[-1].get_index()+1
else:
paste_position = %Timeline.get_child_count()-1
paste_position = %Timeline.get_child_count()
if events_list:
TimelineUndoRedo.create_action("[D] Pasting "+str(len(events_list))+" event(s).")
TimelineUndoRedo.add_do_method(add_events_at_index.bind(events_list, paste_position))
Expand Down