Fixed VN Textbox
This commit is contained in:
@@ -22,10 +22,12 @@ func _applyGravity() -> void:
|
|||||||
entity.velocity += GRAVITY * get_process_delta_time()
|
entity.velocity += GRAVITY * get_process_delta_time()
|
||||||
|
|
||||||
func _applyPlayerMovement(_delta:float):
|
func _applyPlayerMovement(_delta:float):
|
||||||
|
# Interactions, may move
|
||||||
if Input.is_action_just_pressed("interact") && interactingArea && interactingArea.hasInteraction():
|
if Input.is_action_just_pressed("interact") && interactingArea && interactingArea.hasInteraction():
|
||||||
interactingArea.interact()
|
interactingArea.interact()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Directional input
|
||||||
var inputDir:Vector2 = Input.get_vector("move_left", "move_right", "move_back", "move_forward").normalized()
|
var inputDir:Vector2 = Input.get_vector("move_left", "move_right", "move_back", "move_forward").normalized()
|
||||||
var cameraCurrent = get_viewport().get_camera_3d()
|
var cameraCurrent = get_viewport().get_camera_3d()
|
||||||
if !cameraCurrent:
|
if !cameraCurrent:
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ var newlineIndexes:Array[int] = [];
|
|||||||
var currentViewScrolled = true;
|
var currentViewScrolled = true;
|
||||||
var isSpeedupDown = false;
|
var isSpeedupDown = false;
|
||||||
|
|
||||||
|
var hasLetGoOfInteract:bool = true;
|
||||||
|
|
||||||
var isClosed:bool = false:
|
var isClosed:bool = false:
|
||||||
get():
|
get():
|
||||||
return !self.visible;
|
return !self.visible;
|
||||||
@@ -24,14 +26,22 @@ func _ready() -> void:
|
|||||||
isClosed = true
|
isClosed = true
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
|
if isClosed:
|
||||||
|
return;
|
||||||
|
|
||||||
if label.getFinalText() == "":
|
if label.getFinalText() == "":
|
||||||
isClosed = true;
|
isClosed = true;
|
||||||
return;
|
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():
|
if label.visible_characters >= label.getCharactersDisplayedCount():
|
||||||
|
# Not finished displaying current page
|
||||||
if (label.maxLines + label.startLine) < label.getTotalLineCount():
|
if (label.maxLines + label.startLine) < label.getTotalLineCount():
|
||||||
# Not on last page.
|
if Input.is_action_just_pressed("interact") && hasLetGoOfInteract:
|
||||||
if Input.is_action_just_pressed("interact"):
|
|
||||||
label.startLine += label.maxLines;
|
label.startLine += label.maxLines;
|
||||||
label.visible_characters = 0;
|
label.visible_characters = 0;
|
||||||
currentViewScrolled = false;
|
currentViewScrolled = false;
|
||||||
@@ -40,17 +50,19 @@ func _process(delta: float) -> void:
|
|||||||
currentViewScrolled = true;
|
currentViewScrolled = true;
|
||||||
else:
|
else:
|
||||||
# On last page
|
# On last page
|
||||||
if Input.is_action_just_released("interact"):
|
if Input.is_action_just_released("interact") && hasLetGoOfInteract:
|
||||||
textboxClosing.emit();
|
textboxClosing.emit();
|
||||||
isClosed = true;
|
isClosed = true;
|
||||||
currentViewScrolled = true
|
currentViewScrolled = true
|
||||||
return;
|
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;
|
isSpeedupDown = true;
|
||||||
elif Input.is_action_just_released("interact"):
|
elif Input.is_action_just_released("interact") && hasLetGoOfInteract:
|
||||||
isSpeedupDown = false;
|
isSpeedupDown = false;
|
||||||
elif !Input.is_action_pressed("interact"):
|
elif !Input.is_action_pressed("interact") && hasLetGoOfInteract:
|
||||||
isSpeedupDown = false;
|
isSpeedupDown = false;
|
||||||
|
|
||||||
revealTimer += delta;
|
revealTimer += delta;
|
||||||
@@ -62,16 +74,22 @@ func _process(delta: float) -> void:
|
|||||||
label.visible_characters += 1;
|
label.visible_characters += 1;
|
||||||
|
|
||||||
func setText(text:String) -> void:
|
func setText(text:String) -> void:
|
||||||
isClosed = false;
|
# Prepare textbox for scrolling
|
||||||
|
|
||||||
|
# Resets scroll
|
||||||
revealTimer = 0;
|
revealTimer = 0;
|
||||||
currentViewScrolled = false;
|
currentViewScrolled = false;
|
||||||
label.visible_characters = 0;
|
|
||||||
label.startLine = 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.text = text;
|
||||||
label.visible_characters = 0;
|
label.visible_characters = 0;
|
||||||
|
|
||||||
|
# Resets speedup and advancing
|
||||||
|
hasLetGoOfInteract = !Input.is_action_pressed("interact");
|
||||||
|
isSpeedupDown = false
|
||||||
|
isClosed = false;
|
||||||
|
|
||||||
func setTextAndWait(text:String) -> void:
|
func setTextAndWait(text:String) -> void:
|
||||||
await setText(text);
|
self.setText(text);
|
||||||
await self.textboxClosing
|
await self.textboxClosing
|
||||||
|
|||||||
@@ -138,4 +138,4 @@ func _recalcText() -> void:
|
|||||||
|
|
||||||
_finalText = maxText
|
_finalText = maxText
|
||||||
self.richtextlabel_text = maxText
|
self.richtextlabel_text = maxText
|
||||||
print("Updated text")
|
# print("Updated text")
|
||||||
|
|||||||
Reference in New Issue
Block a user