Dialog bug fix/tweaks
All checks were successful
Deploy Promiscuity Auth API / deploy (push) Successful in 47s
Deploy Promiscuity Character API / deploy (push) Successful in 43s
Deploy Promiscuity Locations API / deploy (push) Successful in 44s
k8s smoke test / test (push) Successful in 7s

This commit is contained in:
Zeeshaun 2026-02-13 11:55:19 -06:00
parent ba6edd455a
commit 6dc4d53ba0
3 changed files with 44 additions and 4 deletions

View File

@ -5,6 +5,7 @@ extends Area3D
@export_multiline var dialog_text := ""
@export var auto_popup := false
@export_enum("Every Entry", "Once") var auto_popup_mode := 0
@export var auto_popup_close_on_exit := false
var _has_triggered := false
@ -24,9 +25,15 @@ func _on_body_entered(body: Node) -> void:
if not (target_group == StringName() or body.is_in_group(target_group)):
return
if auto_popup:
if DialogSystem and DialogSystem.has_method("is_dialog_open") and DialogSystem.is_dialog_open():
if not (DialogSystem.has_method("is_dialog_open_from") and DialogSystem.is_dialog_open_from(self)):
return
if auto_popup_mode == 1 and _has_triggered:
return
_has_triggered = true
if DialogSystem and auto_popup_close_on_exit and DialogSystem.has_method("show_text_from"):
DialogSystem.show_text_from(self, dialog_text)
return
if DialogSystem and DialogSystem.has_method("show_text"):
DialogSystem.show_text(dialog_text)
return
@ -35,7 +42,15 @@ func _on_body_entered(body: Node) -> void:
func _on_body_exited(body: Node) -> void:
if not (target_group == StringName() or body.is_in_group(target_group)):
return
if auto_popup:
if auto_popup_close_on_exit and DialogSystem:
if DialogSystem.has_method("close_if_source"):
DialogSystem.close_if_source(self)
elif DialogSystem.has_method("close_if_text"):
DialogSystem.close_if_text(dialog_text)
return
return
if target_group == StringName() or body.is_in_group(target_group):
DialogSystem.unregister_interactable(self)

View File

@ -236,6 +236,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4, 0, -6.5)
script = ExtResource("6_dialog")
dialog_text = "Auto dialog trigger"
auto_popup = true
auto_popup_close_on_exit = true
[node name="CollisionShape3D" type="CollisionShape3D" parent="AutoDialogZone"]
shape = SubResource("SphereShape3D_dialog_zone")

View File

@ -3,6 +3,7 @@ extends CanvasLayer
var _interactables: Array[Node] = []
var _active_interactable: Node = null
var _dialog_visible := false
var _dialog_source: Node = null
var _prompt_label: Label
var _dialog_panel: PanelContainer
@ -38,8 +39,6 @@ func unregister_interactable(interactable: Node) -> void:
if interactable == null:
return
_interactables.erase(interactable)
if _active_interactable == interactable and _dialog_visible:
_set_dialog_visible(false)
_refresh_active_interactable()
@ -47,20 +46,27 @@ func _refresh_active_interactable() -> void:
while _interactables.size() > 0 and not is_instance_valid(_interactables[_interactables.size() - 1]):
_interactables.pop_back()
_active_interactable = _interactables[_interactables.size() - 1] if _interactables.size() > 0 else null
if _dialog_visible and _active_interactable != null:
_dialog_label.text = _get_dialog_text(_active_interactable)
_update_prompt_visibility()
func _open_dialog_for(interactable: Node) -> void:
if _dialog_label:
_dialog_label.text = _get_dialog_text(interactable)
_dialog_source = interactable
_set_dialog_visible(true)
func show_text(text: String) -> void:
if _dialog_label:
_dialog_label.text = text
_dialog_source = null
_set_dialog_visible(true)
func show_text_from(source: Node, text: String) -> void:
if _dialog_label:
_dialog_label.text = text
_dialog_source = source
_set_dialog_visible(true)
@ -74,8 +80,26 @@ func close_if_text(expected_text: String) -> void:
_set_dialog_visible(false)
func is_dialog_open() -> bool:
return _dialog_visible
func is_dialog_open_from(source: Node) -> bool:
return _dialog_visible and _dialog_source == source
func close_if_source(source: Node) -> void:
if not _dialog_visible:
return
if _dialog_source != source:
return
_set_dialog_visible(false)
func _set_dialog_visible(dialog_open: bool) -> void:
_dialog_visible = dialog_open
if not _dialog_visible:
_dialog_source = null
if _dialog_panel:
_dialog_panel.visible = _dialog_visible
_update_prompt_visibility()