1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
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
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:
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 = ""
|