]> Untitled Git - wolf-seeking-sheep.git/blob - addons/dialogic/Modules/Text/manual_advance.gd
Updated export config options
[wolf-seeking-sheep.git] / addons / dialogic / Modules / Text / manual_advance.gd
1 extends RefCounted
2 class_name DialogicManualAdvance
3 ## This class holds the settings for the Manual-Advance feature.
4 ## Changing the variables will alter the behaviour of manually advancing
5 ## the timeline, e.g. using the input action.
6
7 ## The key giving access to the state info of Manual-Advance.
8 const STATE_INFO_KEY := "manual_advance"
9 ## The key for the enabled state in the current state info.
10 const ENABLED_STATE_KEY := "enabled"
11 ## The key for the temporary event state in the current state info.
12 const DISABLED_UNTIL_NEXT_EVENT_STATE_KEY := "temp_disabled"
13
14
15 ## If `true`, Manual-Advance will be deactivated until the next event.
16 ##
17 ## Use this flag to create a temporary Manual-Advance block.
18 ##
19 ## Overrides [variable system_enabled] when true.
20 var disabled_until_next_event := false :
21         set(enabled):
22                 disabled_until_next_event = enabled
23                 DialogicUtil.autoload().current_state_info[STATE_INFO_KEY][DISABLED_UNTIL_NEXT_EVENT_STATE_KEY] = enabled
24
25
26 ## If `true`, Manual-Advance will stay enabled until this is set to `false`.
27 ##
28 ## Use this flag to activate or disable Manual-Advance mode.
29 ##
30 ## Can be temporarily overwritten by [variable disabled_until_next_event].
31 var system_enabled := true :
32         set(enabled):
33                 system_enabled = enabled
34                 DialogicUtil.autoload().current_state_info[STATE_INFO_KEY][ENABLED_STATE_KEY] = enabled
35
36
37 ## Checks if the current state info has the Manual-Advance settings.
38 ## If not, populates the current state info with the default settings.
39 func _init() -> void:
40         if DialogicUtil.autoload().current_state_info.has(STATE_INFO_KEY):
41                 var state_info := DialogicUtil.autoload().current_state_info
42                 var manual_advance: Dictionary = state_info[STATE_INFO_KEY]
43
44                 disabled_until_next_event = manual_advance.get(DISABLED_UNTIL_NEXT_EVENT_STATE_KEY, disabled_until_next_event)
45                 system_enabled = manual_advance.get(ENABLED_STATE_KEY, system_enabled)
46
47         else:
48                 DialogicUtil.autoload().current_state_info[STATE_INFO_KEY] = {
49                         ENABLED_STATE_KEY: system_enabled,
50                         DISABLED_UNTIL_NEXT_EVENT_STATE_KEY: disabled_until_next_event,
51                 }
52
53
54 #region MANUAL ADVANCE HELPERS
55
56 ## Whether the player can use Manual-Advance to advance the timeline.
57 func is_enabled() -> bool:
58         return system_enabled and not disabled_until_next_event
59
60 #endregion