aboutsummaryrefslogtreecommitdiff
path: root/client/menu/scroll_container_custom.gd
diff options
context:
space:
mode:
authortpart <tpart120@proton.me>2024-08-29 15:28:04 +0200
committertpart <tpart120@proton.me>2024-08-29 15:28:04 +0200
commitcd18aa57fa0c11bf455132d0c764d1340455eed1 (patch)
treecd0b4c12fc0097d06dfd0d27031c509e9e5621cb /client/menu/scroll_container_custom.gd
parent890e7eafa7cb8ce8ad5022013f7f71c74b51e3b4 (diff)
downloadhurrycurry-cd18aa57fa0c11bf455132d0c764d1340455eed1.tar
hurrycurry-cd18aa57fa0c11bf455132d0c764d1340455eed1.tar.bz2
hurrycurry-cd18aa57fa0c11bf455132d0c764d1340455eed1.tar.zst
Automatically scroll chat to bottom when opened
Diffstat (limited to 'client/menu/scroll_container_custom.gd')
-rw-r--r--client/menu/scroll_container_custom.gd9
1 files changed, 9 insertions, 0 deletions
diff --git a/client/menu/scroll_container_custom.gd b/client/menu/scroll_container_custom.gd
index cc578bb1..a456f644 100644
--- a/client/menu/scroll_container_custom.gd
+++ b/client/menu/scroll_container_custom.gd
@@ -21,9 +21,18 @@ class_name ScrollContainerCustom
const SCROLL_SPEED := 1000.
var velocity := 0.
+@export var auto_scroll_to_bottom := false
+
func _init():
follow_focus = true
+func _ready():
+ if auto_scroll_to_bottom:
+ call_deferred("scroll_to_bottom")
+
+func scroll_to_bottom():
+ set_deferred("scroll_vertical", get_v_scroll_bar().max_value)
+
func _process(delta):
velocity = G.interpolate(velocity, 0., delta * 5.)
velocity = 0. if abs(velocity) < .001 else velocity