From 04842187606a24f66c3b5ac0f0599dbf41774377 Mon Sep 17 00:00:00 2001 From: Brazly Date: Sun, 18 Jan 2026 14:33:31 +0000 Subject: [PATCH] added scrolling but scrolls infinitely --- Assets/Scripts/Player Controls/interact.gd | 6 ++++++ .../Scripts/UI/terminal/terminal_controls.gd | 19 +++++++++++++++++-- Scenes/Levels/office.tscn | 3 ++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Player Controls/interact.gd b/Assets/Scripts/Player Controls/interact.gd index c46393e..da8a67f 100644 --- a/Assets/Scripts/Player Controls/interact.gd +++ b/Assets/Scripts/Player Controls/interact.gd @@ -27,6 +27,12 @@ func Get_Camera_Collision(): func _input(event: InputEvent) -> void: if event is InputEventKey and event.pressed and crosshair.is_highlighted: + if event.keycode == KEY_PAGEUP: + terminal.ScrollUp() + + if event.keycode == KEY_PAGEDOWN: + terminal.ScrollDown() + if event.keycode == KEY_BACKSPACE: terminal.InputDelChar() diff --git a/Assets/Scripts/UI/terminal/terminal_controls.gd b/Assets/Scripts/UI/terminal/terminal_controls.gd index ce5b70e..e5926b4 100644 --- a/Assets/Scripts/UI/terminal/terminal_controls.gd +++ b/Assets/Scripts/UI/terminal/terminal_controls.gd @@ -193,15 +193,31 @@ cat (or view) [file] : Read the contents of a file clear (or cls) : Clear the terminal screen help : Show this menu -------------------------") - + +func ScrollUp(): + var scroll: ScrollContainer = $MarginContainer/ScrollContainer + await get_tree().create_timer(.0001).timeout + scroll.set_deferred("scroll_vertical", scroll.get_v_scroll_bar().value - 10 ) + call("ScrollUp") + + +func ScrollDown(): + var scroll: ScrollContainer = $MarginContainer/ScrollContainer + await get_tree().create_timer(.0001).timeout + scroll.set_deferred("scroll_vertical", scroll.get_v_scroll_bar().value + 10 ) + call("ScrollDown") + + + func GetBottomScroll(): var scroll: ScrollContainer = $MarginContainer/ScrollContainer var scrollMax: float = scroll.get_v_scroll_bar().max_value await get_tree().create_timer(.01).timeout scroll.set_deferred("scroll_vertical", scrollMax) + #scroll.vertical_scroll_mode = ScrollContainer.SCROLL_MODE_SHOW_NEVER call_deferred("GetBottomScroll") func UpdateCaretPos(): @@ -209,4 +225,3 @@ func UpdateCaretPos(): var char_rect = terminalLine.get_character_bounds(max(0, last_char_index)) caret.position.x = char_rect.end.x + 1 caret.position.y = char_rect.position.y - print(char_rect.end.x) diff --git a/Scenes/Levels/office.tscn b/Scenes/Levels/office.tscn index 01beaae..61543a6 100644 --- a/Scenes/Levels/office.tscn +++ b/Scenes/Levels/office.tscn @@ -236,7 +236,8 @@ grow_vertical = 2 [node name="ScrollContainer" type="ScrollContainer" parent="Interactables/PC/Sprite3D/SubViewport/MarginContainer"] layout_mode = 2 -vertical_scroll_mode = 3 +scroll_horizontal_custom_step = 0.001 +scroll_vertical_custom_step = 0.001 [node name="VBoxContainer" type="VBoxContainer" parent="Interactables/PC/Sprite3D/SubViewport/MarginContainer/ScrollContainer"] layout_mode = 2