1 class_name DialogicAutoSkip
3 ## This class holds the settings for the Auto-Skip feature.
4 ## Changing the variables will alter the behaviour of Auto-Skip.
6 ## Auto-Skip must be implemented per event.
8 ## Emitted whenever the Auto-Skip state changes, from `true` to `false` or
10 signal toggled(is_enabled: bool)
12 ## Whether Auto-Skip is enabled or not.
13 ## If Auto-Skip is referred to be [i]disabled[/i], it refers to setting this
14 ## this variable to `false`.
15 ## This variable will automatically emit [signal autoskip_changed] when changed.
16 var enabled := false : set = _set_enabled
18 ## If `true`, Auto-Skip will be disabled when the user presses a recognised
20 var disable_on_user_input := true
22 ## If `true`, Auto-Skip will be disabled when the timeline advances to a
23 ## unread Text event or an event requesting user input.
24 var disable_on_unread_text := false
26 ## If `true`, Auto-Skip will be enabled when the timeline advances to a
27 ## previously visited Text event.
28 ## Useful if the player always wants to skip already-visited Text events.
29 var enable_on_visited := false
31 ## If `true`, Auto-Skip will skip Voice events instead of playing them.
32 var skip_voice := true
34 ## The amount of seconds each event may take.
35 ## This is not enforced, each event must implement this behaviour.
36 var time_per_event: float = 0.1
39 ## Setting up Auto-Skip.
41 time_per_event = ProjectSettings.get_setting('dialogic/text/autoskip_time_per_event', time_per_event)
43 if DialogicUtil.autoload().has_subsystem("History") and not DialogicUtil.autoload().History.visited_event.is_connected(_handle_seen_event):
44 DialogicUtil.autoload().History.visited_event.connect(_handle_seen_event)
45 DialogicUtil.autoload().History.unvisited_event.connect(_handle_unseen_event)
48 ## Called when Auto-Skip is enabled or disabled.
49 ## Emits [signal autoskip_changed] if the state changed.
50 func _set_enabled(is_enabled: bool) -> void:
51 var previous_enabled := enabled
54 if enabled != previous_enabled:
58 func _handle_seen_event() -> void:
59 # If Auto-Skip is disabled but reacts to seen events, we
61 if not enabled and enable_on_visited:
65 func _handle_unseen_event() -> void:
69 if disable_on_unread_text: