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.
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"
15 ## If `true`, Manual-Advance will be deactivated until the next event.
17 ## Use this flag to create a temporary Manual-Advance block.
19 ## Overrides [variable system_enabled] when true.
20 var disabled_until_next_event := false :
22 disabled_until_next_event = enabled
23 DialogicUtil.autoload().current_state_info[STATE_INFO_KEY][DISABLED_UNTIL_NEXT_EVENT_STATE_KEY] = enabled
26 ## If `true`, Manual-Advance will stay enabled until this is set to `false`.
28 ## Use this flag to activate or disable Manual-Advance mode.
30 ## Can be temporarily overwritten by [variable disabled_until_next_event].
31 var system_enabled := true :
33 system_enabled = enabled
34 DialogicUtil.autoload().current_state_info[STATE_INFO_KEY][ENABLED_STATE_KEY] = enabled
37 ## Checks if the current state info has the Manual-Advance settings.
38 ## If not, populates the current state info with the default settings.
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]
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)
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,
54 #region MANUAL ADVANCE HELPERS
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