diff --git a/Assets/Scripts/UI/terminal/terminal_controls.gd b/Assets/Scripts/UI/terminal/terminal_controls.gd index c6fc20e..b1073c9 100644 --- a/Assets/Scripts/UI/terminal/terminal_controls.gd +++ b/Assets/Scripts/UI/terminal/terminal_controls.gd @@ -4,7 +4,7 @@ class_name TerminalControls @onready var historyContainer = $MarginContainer/ScrollContainer/VBoxContainer @onready var caret = $MarginContainer/ScrollContainer/VBoxContainer/Label/Caret @onready var blink_timer = $MarginContainer/ScrollContainer/VBoxContainer/Label/CaretTimer -@export var terminalLine: Label +@export var terminalLine: RichTextLabel var command: String var directory: String = "~/" @@ -24,9 +24,9 @@ var fileSystem: Dictionary = { func _ready() -> void: terminalLine.text = "user@work "+ directory + " " - UpdateCaretPos() blink_timer.start() Help() + UpdateCaretPos() # --- Caret Blinking Logic --- func _on_caret_timer_timeout() -> void: @@ -110,19 +110,36 @@ func EnterCommand() -> void: # --- History and FileSystem Helpers --- func CreateHistoryEntry(content: String) -> void: - var label = Label.new() - label.text = content - label.label_settings = LabelSettings.new() - label.label_settings.font_size = 42 - label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART - label.custom_minimum_size = Vector2(1400, 0) +# var label = Label.new() +# label.text = content +# label.label_settings = LabelSettings.new() +# label.label_settings.font_size = 42 +# label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART +# label.custom_minimum_size = Vector2(1400, 0) # #if terminalLine.text.length() > 200: #for child in historyContainer.get_children(): #if child != terminalLine: #child.queue_free() - historyContainer.add_child(label) - historyContainer.move_child(label, historyContainer.get_child_count() - 2) +# historyContainer.add_child(label) +# historyContainer.move_child(label, historyContainer.get_child_count() - 2) + + + + var rtl = RichTextLabel.new() + rtl.bbcode_enabled = true + rtl.fit_content = true # Important for VBoxContainer + rtl.text = content + rtl.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART + rtl.custom_minimum_size = Vector2(1400, 0) + rtl.add_theme_font_size_override("normal_font_size", 42) + + # Optional: Set a theme or font override here + # rtl.add_theme_font_size_override("normal_font_size", 42) + + historyContainer.add_child(rtl) + # Moves the entry above the input line + historyContainer.move_child(rtl, historyContainer.get_child_count() - 2) func ResolvePath(current: String, target: String) -> String: if target.begins_with("~/"): @@ -194,11 +211,20 @@ help : Show this menu -------------------------") func ScrollUp(): - var scroll: ScrollContainer = $MarginContainer/ScrollContainer + #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_deferred("ScrollUp") + #await get_tree().create_timer(.0001).timeout + #scroll.set_deferred("scroll_vertical", scroll.get_v_scroll_bar().value - 10 ) + #call_deferred("ScrollUp") + + var scrolli: RichTextLabel = $MarginContainer/ScrollContainer/VBoxContainer/Label + + var scroll = scrolli.get_v_scroll_bar() + + var tween: = create_tween() + tween.tween_property(scroll, "value", scroll.value - (scroll.page - scroll.page * 0.1), 0.1) + get_tree().get_root().set_input_as_handled() + func ScrollDown(): @@ -220,7 +246,16 @@ func GetBottomScroll(): call_deferred("GetBottomScroll") func UpdateCaretPos(): - var last_char_index = terminalLine.text.length() - 1 - var char_rect = terminalLine.get_character_bounds(max(0, last_char_index)) + + await get_tree().create_timer(.01).timeout + var visible_text = terminalLine.get_parsed_text() + var ruler: Label = $"caret-ruler" + + ruler.autowrap_mode =TextServer.AUTOWRAP_WORD_SMART + ruler.text = visible_text + + var last_char_index = ruler.text.length() - 1 + var char_rect = ruler.get_character_bounds(max(0, last_char_index)) caret.position.x = char_rect.end.x + 1 - caret.position.y = char_rect.position.y + caret.position.y = terminalLine.get_content_height() - 50 + diff --git a/Scenes/Levels/office.tscn b/Scenes/Levels/office.tscn index 61543a6..0174427 100644 --- a/Scenes/Levels/office.tscn +++ b/Scenes/Levels/office.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=22 format=3 uid="uid://cqtabc6coc58l"] +[gd_scene load_steps=23 format=3 uid="uid://cqtabc6coc58l"] [ext_resource type="Script" uid="uid://dmtpstry0o0a3" path="res://Assets/Scripts/Player Controls/player_movement.gd" id="1_48dl1"] [ext_resource type="PackedScene" uid="uid://cbpsnsta7u3wl" path="res://Scenes/Special_Effects/PSX_style.tscn" id="2_gba58"] @@ -86,6 +86,10 @@ viewport_path = NodePath("Interactables/PC/Sprite3D/SubViewport") [sub_resource type="LabelSettings" id="LabelSettings_nmbs0"] font_size = 42 +font_color = Color(0, 0, 0, 1) + +[sub_resource type="Theme" id="Theme_nmbs0"] +default_font_size = 42 [node name="Node3D" type="Node3D"] @@ -227,6 +231,15 @@ size = Vector2i(1830, 1400) script = ExtResource("10_gba58") terminalLine = NodePath("MarginContainer/ScrollContainer/VBoxContainer/Label") +[node name="caret-ruler" type="Label" parent="Interactables/PC/Sprite3D/SubViewport"] +clip_contents = true +custom_minimum_size = Vector2(1800, 0) +offset_right = 1800.0 +offset_bottom = 58.0 +text = "a0ifjaojkfna" +label_settings = SubResource("LabelSettings_nmbs0") +autowrap_mode = 3 + [node name="MarginContainer" type="MarginContainer" parent="Interactables/PC/Sprite3D/SubViewport"] anchors_preset = 15 anchor_right = 1.0 @@ -240,20 +253,23 @@ 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 - -[node name="Label" type="Label" parent="Interactables/PC/Sprite3D/SubViewport/MarginContainer/ScrollContainer/VBoxContainer"] -clip_contents = true custom_minimum_size = Vector2(1800, 0) layout_mode = 2 -text = "a0ifjaojkfna" -label_settings = SubResource("LabelSettings_nmbs0") -autowrap_mode = 3 + +[node name="Label" type="RichTextLabel" parent="Interactables/PC/Sprite3D/SubViewport/MarginContainer/ScrollContainer/VBoxContainer"] +clip_contents = false +layout_mode = 2 +size_flags_vertical = 0 +theme = SubResource("Theme_nmbs0") +bbcode_enabled = true +text = "afafafafafafa" +fit_content = true [node name="Caret" type="ColorRect" parent="Interactables/PC/Sprite3D/SubViewport/MarginContainer/ScrollContainer/VBoxContainer/Label"] layout_mode = 0 +offset_top = -62.0 offset_right = 24.0 -offset_bottom = 42.0 +offset_bottom = -20.0 [node name="CaretTimer" type="Timer" parent="Interactables/PC/Sprite3D/SubViewport/MarginContainer/ScrollContainer/VBoxContainer/Label"] wait_time = 0.5 diff --git a/addons/godot-git-plugin/windows/~libgit_plugin.windows.editor.x86_64.dll b/addons/godot-git-plugin/windows/~libgit_plugin.windows.editor.x86_64.dll new file mode 100644 index 0000000..1102afc Binary files /dev/null and b/addons/godot-git-plugin/windows/~libgit_plugin.windows.editor.x86_64.dll differ