about summary refs log tree commit diff stats
path: root/Archipelago/textclient.gd
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-09-07 14:20:13 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2024-09-07 14:20:13 -0400
commitf72463fda100ea858a154d6473111bc8edc1f697 (patch)
tree88691311f931422aa4297f0e174cc71000d807cb /Archipelago/textclient.gd
parent9ef676bab06b08f12e6fc8c8e2b56db70cea5ac3 (diff)
parent15fd151d4b7b4b86d65ae37386b96aae7cb6ba79 (diff)
downloadlingo-archipelago-panels.tar.gz
lingo-archipelago-panels.tar.bz2
lingo-archipelago-panels.zip
Merge branch 'main' into panels panels
Diffstat (limited to 'Archipelago/textclient.gd')
-rw-r--r--Archipelago/textclient.gd88
1 files changed, 88 insertions, 0 deletions
diff --git a/Archipelago/textclient.gd b/Archipelago/textclient.gd new file mode 100644 index 0000000..7bddf38 --- /dev/null +++ b/Archipelago/textclient.gd
@@ -0,0 +1,88 @@
1extends Node
2
3var panel
4var label
5var entry
6var is_open = false
7
8
9func _ready():
10 pause_mode = PAUSE_MODE_PROCESS
11
12 panel = Panel.new()
13 panel.set_name("Panel")
14 panel.margin_left = 100
15 panel.margin_right = 1820
16 panel.margin_top = 100
17 panel.margin_bottom = 980
18 panel.visible = false
19 add_child(panel)
20
21 label = RichTextLabel.new()
22 label.set_name("Label")
23 label.margin_left = 80
24 label.margin_right = 1640
25 label.margin_top = 80
26 label.margin_bottom = 720
27 label.scroll_following = true
28 panel.add_child(label)
29
30 var dynamic_font = DynamicFont.new()
31 dynamic_font.font_data = load("res://fonts/Lingo.ttf")
32 dynamic_font.size = 36
33 label.push_font(dynamic_font)
34
35 var entry_style = StyleBoxFlat.new()
36 entry_style.bg_color = Color(0.9, 0.9, 0.9, 1)
37
38 entry = LineEdit.new()
39 entry.set_name("Entry")
40 entry.margin_left = 80
41 entry.margin_right = 1640
42 entry.margin_top = 760
43 entry.margin_bottom = 840
44 entry.add_font_override("font", dynamic_font)
45 entry.add_color_override("font_color", Color(0, 0, 0, 1))
46 entry.add_color_override("cursor_color", Color(0, 0, 0, 1))
47 entry.add_stylebox_override("focus", entry_style)
48 panel.add_child(entry)
49 entry.connect("text_entered", self, "text_entered")
50
51
52func _input(event):
53 if event is InputEventKey and event.pressed:
54 if event.scancode == KEY_TAB:
55 if !get_tree().paused:
56 is_open = true
57 get_tree().paused = true
58 Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
59 panel.visible = true
60 entry.grab_focus()
61 get_tree().set_input_as_handled()
62 else:
63 dismiss()
64 elif event.scancode == KEY_ESCAPE:
65 if is_open:
66 dismiss()
67 get_tree().set_input_as_handled()
68
69
70func dismiss():
71 if is_open:
72 get_tree().paused = false
73 Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
74 panel.visible = false
75 is_open = false
76
77
78func parse_printjson(text):
79 if !label.text.empty():
80 label.append_bbcode("\n")
81
82 label.append_bbcode(text)
83
84
85func text_entered(text):
86 var apclient = global.get_node("Archipelago")
87 apclient.say(text.trim_suffix("\n"))
88 entry.text = ""