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 User Input Auto-Advance #2024

Merged
merged 5 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions .github/workflows/resources/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ config/icon="res://icon.svg"

renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"

[autoload]

Dialogic="*res://addons/dialogic/Other/DialogicGameHandler.gd"
6 changes: 3 additions & 3 deletions addons/dialogic/Modules/Core/subsystem_input.gd
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ func resume() -> void:
####### MAIN METHODS ###########################################################
#region MAIN METHODS

func handle_input():
func handle_input() -> void:
if dialogic.paused or is_input_blocked():
return

if !action_was_consumed:
if not action_was_consumed:
# We want to stop auto-advancing that cancels on user inputs.
if (auto_advance.is_enabled()
and auto_advance.enabled_until_user_input):
auto_advance.enabled_until_next_event = false
auto_advance.enabled_until_user_input = false
action_was_consumed = true

# We want to stop auto-skipping if it's enabled, we are listening
Expand Down
1 change: 1 addition & 0 deletions addons/dialogic/Modules/Text/auto_advance.gd
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var enabled_until_user_input := false :
enabled_until_user_input = enabled
_try_emit_toggled()


func _init() -> void:
DialogicUtil.autoload().Input.add_child(autoadvance_timer)
autoadvance_timer.one_shot = true
Expand Down
19 changes: 19 additions & 0 deletions addons/dialogic/Tests/Unit/test_auto_advance.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
extends GdUnitTestSuite

## Ensure Auto-Advance is enabled properly using the user input flag.
func test_enable_auto_advance() -> void:
Dialogic.Input.auto_advance.enabled_until_user_input = true
var is_enabled: bool = Dialogic.Input.auto_advance.is_enabled()

assert(is_enabled == true, "Auto-Advance is not enabled.")


## This test was created to ensure a bug was fixed:
## When the user enabled the Auto-Advance until user input,
## the Auto-Advance would still run after the user input.
func test_disable_auto_advance() -> void:
Dialogic.Input.auto_advance.enabled_until_user_input = true
Dialogic.Input.handle_input()

var is_enabled: bool = Dialogic.Input.auto_advance.is_enabled()
assert(is_enabled == false, "Auto-Advance is still running after input")
1 change: 0 additions & 1 deletion addons/dialogic/Tests/Unit/test_example.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
class_name GdUnitExampleTest
extends GdUnitTestSuite

func test_example() -> void:
Expand Down
Loading