Skip to content

Commit

Permalink
Small improvements (#2187)
Browse files Browse the repository at this point in the history
- should fix Timeline Dropdowns don't stop Inputs #2174
- should fix Text/Skip_Delay setting not being displayed correctly
- small code cleanup
  • Loading branch information
Jowan-Spooner committed Apr 18, 2024
1 parent 356f622 commit 46764c8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func _on_Search_text_changed(new_text:String, just_update:bool = false) -> void:
%Suggestions.size.x = max(%PanelContainer.size.x, line_length)


func suggestion_selected(index : int, position:=Vector2(), button_index:=MOUSE_BUTTON_LEFT) -> void:
func suggestion_selected(index: int, position := Vector2(), button_index := MOUSE_BUTTON_LEFT) -> void:
if button_index != MOUSE_BUTTON_LEFT:
return
if %Suggestions.is_item_disabled(index):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var _initialized := false
################## TIMELINE EVENT MANAGEMENT ###################################
################################################################################
var selected_items : Array = []
var drag_allowed := false


#region CREATE/SAVE/LOAD
Expand Down Expand Up @@ -299,7 +300,7 @@ func update_content_list() -> void:
#################################################################################

# SIGNAL handles input on the events mainly for selection and moving events
func _on_event_block_gui_input(event, item: Node) -> void:
func _on_event_block_gui_input(event: InputEvent, item: Node) -> void:
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
if event.is_pressed():
if len(selected_items) > 1 and item in selected_items and !Input.is_key_pressed(KEY_CTRL):
Expand All @@ -309,9 +310,11 @@ func _on_event_block_gui_input(event, item: Node) -> void:
elif len(selected_items) > 1 or Input.is_key_pressed(KEY_CTRL):
select_item(item)

drag_allowed = true

if len(selected_items) > 0 and event is InputEventMouseMotion:
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
if !%TimelineArea.dragging and !get_viewport().gui_is_dragging():
if !%TimelineArea.dragging and !get_viewport().gui_is_dragging() and drag_allowed:
sort_selection()
%TimelineArea.start_dragging(%TimelineArea.DragTypes.EXISTING_EVENTS, selected_items)

Expand Down Expand Up @@ -835,8 +838,8 @@ func offset_blocks_by_index(blocks:Array, offset:int):

func scroll_to_piece(piece_index:int) -> void:
await get_tree().process_frame
var height :float = %Timeline.get_child(min(piece_index, %Timeline.get_child_count()-1)).position.y
if height < %TimelineArea.scroll_vertical or height > %TimelineArea.scroll_vertical+%TimelineArea.size.y-(200*DialogicUtil.get_editor_scale()):
var height: float = %Timeline.get_child(min(piece_index, %Timeline.get_child_count()-1)).position.y
if height < %TimelineArea.scroll_vertical or height > %TimelineArea.scroll_vertical+%TimelineArea.size.y:
%TimelineArea.scroll_vertical = height


Expand Down Expand Up @@ -993,15 +996,20 @@ func duplicate_selected() -> void:


func _input(event:InputEvent) -> void:
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed == false:
drag_allowed = false

# we protect this with is_visible_in_tree to not
# invoke a shortcut by accident
if !((event is InputEventKey or !event is InputEventWithModifiers) and is_visible_in_tree()):
return


if "pressed" in event:
if !event.pressed:
return


## Some shortcuts should always work
match event.as_text():
"Ctrl+T": # Add text event
Expand Down
2 changes: 1 addition & 1 deletion addons/dialogic/Modules/Text/settings_text.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func _get_title() -> String:
func _refresh() -> void:
%DefaultSpeed.value = ProjectSettings.get_setting('dialogic/text/letter_speed', 0.01)
%Skippable.button_pressed = ProjectSettings.get_setting('dialogic/text/initial_text_reveal_skippable', true)
%SkippableDelay.value = ProjectSettings.get_setting('dialogic/text/skippable_delay', 0.1)
%SkippableDelay.value = ProjectSettings.get_setting('dialogic/text/text_reveal_skip_delay', 0.1)

%AutoAdvance.button_pressed = ProjectSettings.get_setting('dialogic/text/autoadvance_enabled', false)
%FixedDelay.value = ProjectSettings.get_setting('dialogic/text/autoadvance_fixed_delay', 1)
Expand Down

0 comments on commit 46764c8

Please sign in to comment.