Fix some bugs with chat

This commit is contained in:
2026-06-12 09:16:19 -05:00
parent b364fae1c7
commit 5668250ea9
5 changed files with 74 additions and 53 deletions
+55 -44
View File
@@ -68,75 +68,86 @@ func _updateWorldPosition() -> void:
func _process(delta: float) -> void:
if isClosed:
return;
return
_updateWorldPosition()
# _recalcText always resets fit_content to false; re-apply so the
# PanelContainer can grow to its content height in world-space mode.
# _recalcText always resets fit_content; keep it on in world-space mode so
# the PanelContainer auto-sizes to the full speech-bubble content.
if worldTarget != null and !label.fit_content:
label.fit_content = true
if label.getFinalText() == "":
isClosed = true;
return;
if Input.is_action_just_released("interact") && !hasLetGoOfInteract:
hasLetGoOfInteract = true;
isClosed = true
return
# Have we finished displaying the current page?
if label.visible_characters >= label.getCharactersDisplayedCount():
# Not finished displaying current page
if Input.is_action_just_released("interact") and !hasLetGoOfInteract:
hasLetGoOfInteract = true
return
# World-space (speech-bubble) mode: all text is shown immediately with no
# typing reveal. One press advances to the next page; release closes the last.
if worldTarget != null:
if (label.maxLines + label.startLine) < label.getTotalLineCount():
if Input.is_action_just_pressed("interact") && hasLetGoOfInteract:
label.startLine += label.maxLines;
label.visible_characters = 0;
currentViewScrolled = false;
return
currentViewScrolled = true;
if Input.is_action_just_pressed("interact") and hasLetGoOfInteract:
label.startLine += label.maxLines
label.fit_content = true
else:
# On last page
if Input.is_action_just_released("interact") && hasLetGoOfInteract:
chatboxClosing.emit();
isClosed = true;
if Input.is_action_just_released("interact") and hasLetGoOfInteract:
chatboxClosing.emit()
isClosed = true
return
# Bottom-bar mode: typing reveal with paging.
if label.visible_characters >= label.getCharactersDisplayedCount():
if (label.maxLines + label.startLine) < label.getTotalLineCount():
if Input.is_action_just_pressed("interact") and hasLetGoOfInteract:
label.startLine += label.maxLines
label.visible_characters = 0
currentViewScrolled = false
return
currentViewScrolled = true
return;
else:
if Input.is_action_just_released("interact") and hasLetGoOfInteract:
chatboxClosing.emit()
isClosed = true
currentViewScrolled = true
return
# This prevents the game trying to advance if the player is still holding
# down interact.
if Input.is_action_just_pressed("interact") && hasLetGoOfInteract:
isSpeedupDown = true;
elif Input.is_action_just_released("interact") && hasLetGoOfInteract:
isSpeedupDown = false;
elif !Input.is_action_pressed("interact") && hasLetGoOfInteract:
isSpeedupDown = false;
if Input.is_action_just_pressed("interact") and hasLetGoOfInteract:
isSpeedupDown = true
elif Input.is_action_just_released("interact") and hasLetGoOfInteract:
isSpeedupDown = false
elif !Input.is_action_pressed("interact") and hasLetGoOfInteract:
isSpeedupDown = false
revealTimer += delta;
revealTimer += delta
if isSpeedupDown:
revealTimer += delta;
revealTimer += delta
if revealTimer > VN_REVEAL_TIME:
revealTimer = 0;
label.visible_characters += 1;
revealTimer = 0
label.visible_characters += 1
func setText(text:String, target:Node3D = null) -> void:
worldTarget = target
_setWorldLayout(worldTarget != null)
# Resets scroll
revealTimer = 0;
currentViewScrolled = false;
label.startLine = 0;
revealTimer = 0
currentViewScrolled = false
label.startLine = 0
label.text = text
label.text = text;
label.visible_characters = 0;
if worldTarget != null:
# Speech-bubble mode: show all text immediately and auto-size the container.
# _recalcText already sets visible_characters = -1; just enable fit_content.
label.fit_content = true
else:
label.visible_characters = 0
# Resets speedup and advancing
hasLetGoOfInteract = !Input.is_action_pressed("interact");
hasLetGoOfInteract = !Input.is_action_pressed("interact")
isSpeedupDown = false
isClosed = false;
isClosed = false
func setTextAndWait(text:String, target:Node3D = null) -> void:
self.setText(text, target);
+3
View File
@@ -22,6 +22,9 @@ func showTimed(text:String, duration:float) -> void:
_label.text = text
visible = true
func resetTimer(duration:float) -> void:
_timer = duration
func showAdvanceable(text:String) -> void:
mode = Mode.ADVANCEABLE
_label.text = text