extends Node var panel var label var entry var is_open = false func _ready(): pause_mode = PAUSE_MODE_PROCESS panel = Panel.new() panel.set_name("Panel") panel.margin_left = 100 panel.margin_right = 1820 panel.margin_top = 100 panel.margin_bottom = 980 panel.visible = false add_child(panel) label = RichTextLabel.new() label.set_name("Label") label.margin_left = 80 label.margin_right = 1640 label.margin_top = 80 label.margin_bottom = 720 label.scroll_following = true label.selection_enabled = true panel.add_child(label) var dynamic_font = DynamicFont.new() dynamic_font.font_data = load("res://fonts/Lingo.ttf") dynamic_font.size = 36 label.push_font(dynamic_font) var entry_style = StyleBoxFlat.new() entry_style.bg_color = Color(0.9, 0.9, 0.9, 1) entry = LineEdit.new() entry.set_name("Entry") entry.margin_left = 80 entry.margin_right = 1640 entry.margin_top = 760 entry.margin_bottom = 840 entry.add_font_override("font", dynamic_font) entry.add_color_override("font_color", Color(0, 0, 0, 1)) entry.add_color_override("cursor_color", Color(0, 0, 0, 1)) entry.add_stylebox_override("focus", entry_style) panel.add_child(entry) entry.connect("text_entered", self, "text_entered") func _input(event): if event is InputEventKey and event.pressed: if event.scancode == KEY_TAB and !Input.is_key_pressed(KEY_SHIFT): if !get_tree().paused: is_open = true get_tree().paused = true Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) panel.visible = true entry.grab_focus() get_tree().set_input_as_handled() else: dismiss() elif event.scancode == KEY_ESCAPE: if is_open: dismiss() get_tree().set_input_as_handled() func dismiss(): if is_open: get_tree().paused = false Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) panel.visible = false is_open = false func parse_printjson(text): if !label.text.empty(): label.append_bbcode("\n") label.append_bbcode(text) func text_entered(text): var apclient = global.get_node("Archipelago") var cmd = text.trim_suffix("\n") if cmd.begins_with("/say "): if apclient.enable_multiplayer: var msg = cmd.trim_prefix("/say ") parse_printjson( "[LOCAL] [color=#ee00ee]%s[/color]: %s" % [apclient.get_player_name(), msg] ) get_tree().get_root().get_node("Spatial/Multiplayer").say(msg) else: parse_printjson("Multiplayer must be enabled to use /say") else: apclient.say(cmd) entry.text = ""