diff --git a/overworld/entity/EntityMovement.gd b/overworld/entity/EntityMovement.gd index 37db895..3692d32 100644 --- a/overworld/entity/EntityMovement.gd +++ b/overworld/entity/EntityMovement.gd @@ -22,10 +22,12 @@ func _applyGravity() -> void: entity.velocity += GRAVITY * get_process_delta_time() func _applyPlayerMovement(_delta:float): + # Interactions, may move if Input.is_action_just_pressed("interact") && interactingArea && interactingArea.hasInteraction(): interactingArea.interact() return + # Directional input var inputDir:Vector2 = Input.get_vector("move_left", "move_right", "move_back", "move_forward").normalized() var cameraCurrent = get_viewport().get_camera_3d() if !cameraCurrent: diff --git a/ui/component/VNTextbox.gd b/ui/component/VNTextbox.gd index d053a92..f6f04f2 100644 --- a/ui/component/VNTextbox.gd +++ b/ui/component/VNTextbox.gd @@ -11,6 +11,8 @@ var newlineIndexes:Array[int] = []; var currentViewScrolled = true; var isSpeedupDown = false; +var hasLetGoOfInteract:bool = true; + var isClosed:bool = false: get(): return !self.visible; @@ -24,14 +26,22 @@ func _ready() -> void: isClosed = true func _process(delta: float) -> void: + if isClosed: + return; + if label.getFinalText() == "": isClosed = true; return; - + + if Input.is_action_just_released("interact") && !hasLetGoOfInteract: + hasLetGoOfInteract = true; + return + + # Have we finished displaying the current page? if label.visible_characters >= label.getCharactersDisplayedCount(): + # Not finished displaying current page if (label.maxLines + label.startLine) < label.getTotalLineCount(): - # Not on last page. - if Input.is_action_just_pressed("interact"): + if Input.is_action_just_pressed("interact") && hasLetGoOfInteract: label.startLine += label.maxLines; label.visible_characters = 0; currentViewScrolled = false; @@ -40,17 +50,19 @@ func _process(delta: float) -> void: currentViewScrolled = true; else: # On last page - if Input.is_action_just_released("interact"): + if Input.is_action_just_released("interact") && hasLetGoOfInteract: textboxClosing.emit(); isClosed = true; currentViewScrolled = true return; - if Input.is_action_just_pressed("interact"): + # 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"): + elif Input.is_action_just_released("interact") && hasLetGoOfInteract: isSpeedupDown = false; - elif !Input.is_action_pressed("interact"): + elif !Input.is_action_pressed("interact") && hasLetGoOfInteract: isSpeedupDown = false; revealTimer += delta; @@ -62,16 +74,22 @@ func _process(delta: float) -> void: label.visible_characters += 1; func setText(text:String) -> void: - isClosed = false; + # Prepare textbox for scrolling + + # Resets scroll revealTimer = 0; currentViewScrolled = false; - label.visible_characters = 0; label.startLine = 0; - label.text = "" - await get_tree().process_frame# Absolutely needed to make the text wrap + + # I had a frame wait here before. label.text = text; label.visible_characters = 0; + # Resets speedup and advancing + hasLetGoOfInteract = !Input.is_action_pressed("interact"); + isSpeedupDown = false + isClosed = false; + func setTextAndWait(text:String) -> void: - await setText(text); + self.setText(text); await self.textboxClosing diff --git a/ui/component/advancedrichtext/AdvancedRichText.gd b/ui/component/advancedrichtext/AdvancedRichText.gd index f4ec806..c3dcbf4 100644 --- a/ui/component/advancedrichtext/AdvancedRichText.gd +++ b/ui/component/advancedrichtext/AdvancedRichText.gd @@ -138,4 +138,4 @@ func _recalcText() -> void: _finalText = maxText self.richtextlabel_text = maxText - print("Updated text") + # print("Updated text")