From 46764c835a6b08c35bc8431134d4206f0de4609e Mon Sep 17 00:00:00 2001 From: Jowan-Spooner <42868150+Jowan-Spooner@users.noreply.github.com> Date: Thu, 18 Apr 2024 09:08:07 +0200 Subject: [PATCH] Small improvements (#2187) - should fix Timeline Dropdowns don't stop Inputs #2174 - should fix Text/Skip_Delay setting not being displayed correctly - small code cleanup --- .../Events/Fields/field_options_dynamic.gd | 2 +- .../VisualEditor/timeline_editor_visual.gd | 16 ++++++++++++---- addons/dialogic/Modules/Text/settings_text.gd | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/addons/dialogic/Editor/Events/Fields/field_options_dynamic.gd b/addons/dialogic/Editor/Events/Fields/field_options_dynamic.gd index eb25d3987..1bb799697 100644 --- a/addons/dialogic/Editor/Events/Fields/field_options_dynamic.gd +++ b/addons/dialogic/Editor/Events/Fields/field_options_dynamic.gd @@ -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): diff --git a/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd b/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd index 79d3637f9..acf136c29 100644 --- a/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd +++ b/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd @@ -28,6 +28,7 @@ var _initialized := false ################## TIMELINE EVENT MANAGEMENT ################################### ################################################################################ var selected_items : Array = [] +var drag_allowed := false #region CREATE/SAVE/LOAD @@ -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): @@ -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) @@ -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 @@ -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 diff --git a/addons/dialogic/Modules/Text/settings_text.gd b/addons/dialogic/Modules/Text/settings_text.gd index db75f28a6..f18576902 100644 --- a/addons/dialogic/Modules/Text/settings_text.gd +++ b/addons/dialogic/Modules/Text/settings_text.gd @@ -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)