Skip to content

Small fixes #2181

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

Merged
merged 3 commits into from
Apr 14, 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
7 changes: 4 additions & 3 deletions addons/dialogic/Core/DialogicGameHandler.gd
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ func start(timeline:Variant, label:Variant="") -> Node:
scene = self.Styles.load_style()
else:
scene = self.Styles.get_layout_node()
scene.show()

if not scene.is_node_ready():
scene.ready.connect(clear.bind(ClearFlags.KEEP_VARIABLES))
Expand Down Expand Up @@ -232,9 +233,9 @@ func preload_timeline(timeline_resource:Variant) -> Variant:
if timeline_resource == null:
printerr("[Dialogic] There was an error preloading this timeline. Check the filename, and the timeline for errors")
return null
else:
await (timeline_resource as DialogicTimeline).process()
return timeline_resource

await (timeline_resource as DialogicTimeline).process()

return timeline_resource


Expand Down
3 changes: 3 additions & 0 deletions addons/dialogic/Modules/Character/subsystem_portraits.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ func clear_game_state(clear_flag:=DialogicGameHandler.ClearFlags.FULL_CLEAR) ->


func load_game_state(load_flag:=LoadFlags.FULL_LOAD) -> void:
if not "portraits" in dialogic.current_state_info:
dialogic.current_state_info["portraits"] = {}

var portraits_info: Dictionary = dialogic.current_state_info.portraits.duplicate()
dialogic.current_state_info.portraits = {}
for character_path in portraits_info:
Expand Down
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 @@ -28,8 +28,8 @@ func clear_game_state(_clear_flag := DialogicGameHandler.ClearFlags.FULL_CLEAR)
if not is_node_ready():
await ready

manual_advance.enabled_until_next_event = false
manual_advance.enabled_forced = true
manual_advance.disabled_until_next_event = false
manual_advance.system_enabled = true


func pause() -> void:
Expand Down Expand Up @@ -180,7 +180,7 @@ func effect_input(text_node:Control, skipped:bool, argument:String) -> void:

func effect_noskip(text_node:Control, skipped:bool, argument:String) -> void:
dialogic.Text.set_text_reveal_skippable(false, true)
manual_advance.enabled_until_next_event = true
manual_advance.disabled_until_next_event = true
effect_autoadvance(text_node, skipped, argument)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ func _resize_bubble(content_size:Vector2, popup:=false) -> void:
name_label_holder.alignment = name_label_alignment
name_label_holder.size.x = text.size.x


func _on_choices_shown(info:Dictionary) -> void:
if !visible:
if !is_visible_in_tree():
return

await get_tree().process_frame
Expand All @@ -156,6 +157,7 @@ func get_base_content_size() -> Vector2:

func add_choice_container(node:Container, alignment:=FlowContainer.ALIGNMENT_BEGIN) -> void:
if choice_container:
choice_container.get_parent().remove_child(choice_container)
choice_container.queue_free()

node.name = "ChoiceContainer"
Expand Down
12 changes: 6 additions & 6 deletions addons/dialogic/Modules/Save/subsystem_save.gd
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ func load_file(slot_name: String, file_name: String, default: Variant) -> Varian
if slot_name.is_empty(): slot_name = get_default_slot()

var path := get_slot_path(slot_name).path_join(file_name)

if ResourceLoader.exists(path):
print("trying to load ", path)
if FileAccess.file_exists(path):
var encryption_password := get_encryption_password()
var file: FileAccess

Expand All @@ -198,7 +198,7 @@ func load_file(slot_name: String, file_name: String, default: Variant) -> Varian
return file.get_var()
else:
push_error(FileAccess.get_open_error())

print("Does not exist!")
return default


Expand Down Expand Up @@ -264,7 +264,7 @@ func get_encryption_password() -> String:
## Returns a list of all available slots. Useful for iterating over all slots,
## e.g., when building a UI with all save slots.
func get_slot_names() -> Array[String]:
var save_folders := []
var save_folders: Array[String] = []

if DirAccess.dir_exists_absolute(SAVE_SLOTS_DIR):
var directory := DirAccess.open(SAVE_SLOTS_DIR)
Expand Down Expand Up @@ -376,7 +376,7 @@ func _make_sure_slot_dir_exists() -> Error:

var global_info_path := SAVE_SLOTS_DIR.path_join('global_info.txt')

if not ResourceLoader.exists(global_info_path):
if not FileAccess.file_exists(global_info_path):
var config := ConfigFile.new()
var password := get_encryption_password()

Expand Down Expand Up @@ -442,7 +442,7 @@ func get_slot_thumbnail(slot_name: String) -> ImageTexture:

var path := get_slot_path(slot_name).path_join('thumbnail.png')

if ResourceLoader.exists(path):
if FileAccess.file_exists(path):
return ImageTexture.create_from_image(Image.load_from_file(path))

return null
Expand Down
30 changes: 15 additions & 15 deletions addons/dialogic/Modules/Text/manual_advance.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ const STATE_INFO_KEY := "manual_advance"
## The key for the enabled state in the current state info.
const ENABLED_STATE_KEY := "enabled"
## The key for the temporary event state in the current state info.
const ENABLED_UNTIL_NEXT_EVENT_STATE_KEY := "temp_enabled"
const DISABLED_UNTIL_NEXT_EVENT_STATE_KEY := "temp_disabled"


## If `true`, Manual-Advance will be active until the next event.
## If `true`, Manual-Advance will be deactivated until the next event.
##
## Use this flag to create a temporary Manual-Advance mode.
## Use this flag to create a temporary Manual-Advance block.
##
## Stacks with [variable enabled_forced].
var enabled_until_next_event := false :
## Overrides [variable system_enabled] when true.
var disabled_until_next_event := false :
set(enabled):
enabled_until_next_event = enabled
DialogicUtil.autoload().current_state_info[STATE_INFO_KEY][ENABLED_UNTIL_NEXT_EVENT_STATE_KEY] = enabled
disabled_until_next_event = enabled
DialogicUtil.autoload().current_state_info[STATE_INFO_KEY][DISABLED_UNTIL_NEXT_EVENT_STATE_KEY] = enabled


## If `true`, Manual-Advance will stay enabled until this is set to `false`.
##
## Use this flag to activate or disable Manual-Advance mode.
##
## Stacks with [variable enabled_until_next_event].
var enabled_forced := true :
## Can be temporarily overwritten by [variable disabled_until_next_event].
var system_enabled := true :
set(enabled):
enabled_forced = enabled
system_enabled = enabled
DialogicUtil.autoload().current_state_info[STATE_INFO_KEY][ENABLED_STATE_KEY] = enabled


Expand All @@ -41,20 +41,20 @@ func _init() -> void:
var state_info := DialogicUtil.autoload().current_state_info
var manual_advance: Dictionary = state_info[STATE_INFO_KEY]

enabled_until_next_event = manual_advance[ENABLED_UNTIL_NEXT_EVENT_STATE_KEY]
enabled_forced = manual_advance[ENABLED_STATE_KEY]
disabled_until_next_event = manual_advance[DISABLED_UNTIL_NEXT_EVENT_STATE_KEY]
system_enabled = manual_advance[ENABLED_STATE_KEY]

else:
DialogicUtil.autoload().current_state_info[STATE_INFO_KEY] = {
ENABLED_STATE_KEY: enabled_forced,
ENABLED_UNTIL_NEXT_EVENT_STATE_KEY: enabled_until_next_event,
ENABLED_STATE_KEY: system_enabled,
DISABLED_UNTIL_NEXT_EVENT_STATE_KEY: disabled_until_next_event,
}


#region MANUAL ADVANCE HELPERS

## Whether the player can use Manual-Advance to advance the timeline.
func is_enabled() -> bool:
return enabled_until_next_event or enabled_forced
return system_enabled and not disabled_until_next_event

#endregion
4 changes: 3 additions & 1 deletion addons/dialogic/Modules/Text/subsystem_text.gd
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func update_dialog_text(text: String, instant := false, additional := false) ->
# Reset Auto-Advance temporarily and the No-Skip setting:
dialogic.Inputs.auto_advance.enabled_until_next_event = false
dialogic.Inputs.auto_advance.override_delay_for_current_event = -1
dialogic.Inputs.manual_advance.enabled_until_next_event = false
dialogic.Inputs.manual_advance.disabled_until_next_event = false

set_text_reveal_skippable(true, true)

Expand Down Expand Up @@ -189,6 +189,8 @@ func update_typing_sound_mood(mood:Dictionary = {}) -> void:
func show_textbox(instant:=false) -> void:
var emitted := instant
for text_node in get_tree().get_nodes_in_group('dialogic_dialog_text'):
if not text_node.enabled:
continue
if !text_node.textbox_root.visible and !emitted:
animation_textbox_show.emit()
text_node.textbox_root.show()
Expand Down