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-02 11:49:12 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2024-09-02 11:49:12 -0400
commit400ad1ed74166d3f01adf6d97f07a16ec391f2a9 (patch)
tree74daf09a579867f1e8715d70a2797bd18025062e /Archipelago/textclient.gd
parent6b5b85f96fc855810ac21e96e1aeb9cbde0fe88e (diff)
downloadlingo-archipelago-400ad1ed74166d3f01adf6d97f07a16ec391f2a9.tar.gz
lingo-archipelago-400ad1ed74166d3f01adf6d97f07a16ec391f2a9.tar.bz2
lingo-archipelago-400ad1ed74166d3f01adf6d97f07a16ec391f2a9.zip
Added text client
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 = ""