diff options
Diffstat (limited to 'apworld/client/textclient.gd')
-rw-r--r-- | apworld/client/textclient.gd | 123 |
1 files changed, 100 insertions, 23 deletions
diff --git a/apworld/client/textclient.gd b/apworld/client/textclient.gd index 9841063..1b36c29 100644 --- a/apworld/client/textclient.gd +++ b/apworld/client/textclient.gd | |||
@@ -1,35 +1,57 @@ | |||
1 | extends CanvasLayer | 1 | extends CanvasLayer |
2 | 2 | ||
3 | var tabs | ||
3 | var panel | 4 | var panel |
4 | var label | 5 | var label |
5 | var entry | 6 | var entry |
7 | var tracker_label | ||
6 | var is_open = false | 8 | var is_open = false |
7 | 9 | ||
10 | var locations_overlay | ||
11 | |||
8 | 12 | ||
9 | func _ready(): | 13 | func _ready(): |
10 | process_mode = ProcessMode.PROCESS_MODE_ALWAYS | 14 | process_mode = ProcessMode.PROCESS_MODE_ALWAYS |
11 | layer = 2 | 15 | layer = 2 |
12 | 16 | ||
13 | panel = Panel.new() | 17 | locations_overlay = RichTextLabel.new() |
14 | panel.set_name("Panel") | 18 | locations_overlay.name = "LocationsOverlay" |
15 | panel.offset_left = 100 | 19 | locations_overlay.offset_top = 220 |
16 | panel.offset_right = 1820 | 20 | locations_overlay.offset_bottom = 720 |
17 | panel.offset_top = 100 | 21 | locations_overlay.offset_left = 20 |
18 | panel.offset_bottom = 980 | 22 | locations_overlay.anchor_right = 1.0 |
19 | panel.visible = false | 23 | locations_overlay.offset_right = -20 |
20 | add_child(panel) | 24 | locations_overlay.scroll_active = false |
25 | locations_overlay.mouse_filter = Control.MOUSE_FILTER_IGNORE | ||
26 | add_child(locations_overlay) | ||
27 | update_locations_visibility() | ||
28 | |||
29 | tabs = TabContainer.new() | ||
30 | tabs.name = "Tabs" | ||
31 | tabs.offset_left = 100 | ||
32 | tabs.offset_right = 1820 | ||
33 | tabs.offset_top = 100 | ||
34 | tabs.offset_bottom = 980 | ||
35 | tabs.visible = false | ||
36 | tabs.theme = preload("res://assets/themes/baseUI.tres") | ||
37 | tabs.add_theme_font_size_override("font_size", 36) | ||
38 | add_child(tabs) | ||
39 | |||
40 | panel = MarginContainer.new() | ||
41 | panel.name = "Text Client" | ||
42 | panel.add_theme_constant_override("margin_top", 60) | ||
43 | panel.add_theme_constant_override("margin_left", 60) | ||
44 | panel.add_theme_constant_override("margin_right", 60) | ||
45 | panel.add_theme_constant_override("margin_bottom", 60) | ||
46 | tabs.add_child(panel) | ||
21 | 47 | ||
22 | label = RichTextLabel.new() | 48 | label = RichTextLabel.new() |
23 | label.set_name("Label") | 49 | label.set_name("Label") |
24 | label.offset_left = 80 | ||
25 | label.offset_right = 1640 | ||
26 | label.offset_top = 80 | ||
27 | label.offset_bottom = 720 | ||
28 | label.scroll_following = true | 50 | label.scroll_following = true |
29 | label.selection_enabled = true | 51 | label.selection_enabled = true |
30 | panel.add_child(label) | 52 | label.size_flags_horizontal = Control.SIZE_EXPAND_FILL |
31 | 53 | label.size_flags_vertical = Control.SIZE_EXPAND_FILL | |
32 | label.push_font(load("res://assets/fonts/Lingo2.ttf")) | 54 | label.push_font(preload("res://assets/fonts/Lingo2.ttf")) |
33 | label.push_font_size(36) | 55 | label.push_font_size(36) |
34 | 56 | ||
35 | var entry_style = StyleBoxFlat.new() | 57 | var entry_style = StyleBoxFlat.new() |
@@ -37,18 +59,30 @@ func _ready(): | |||
37 | 59 | ||
38 | entry = LineEdit.new() | 60 | entry = LineEdit.new() |
39 | entry.set_name("Entry") | 61 | entry.set_name("Entry") |
40 | entry.offset_left = 80 | 62 | entry.add_theme_font_override("font", preload("res://assets/fonts/Lingo2.ttf")) |
41 | entry.offset_right = 1640 | ||
42 | entry.offset_top = 760 | ||
43 | entry.offset_bottom = 840 | ||
44 | entry.add_theme_font_override("font", load("res://assets/fonts/Lingo2.ttf")) | ||
45 | entry.add_theme_font_size_override("font_size", 36) | 63 | entry.add_theme_font_size_override("font_size", 36) |
46 | entry.add_theme_color_override("font_color", Color(0, 0, 0, 1)) | 64 | entry.add_theme_color_override("font_color", Color(0, 0, 0, 1)) |
47 | entry.add_theme_color_override("cursor_color", Color(0, 0, 0, 1)) | 65 | entry.add_theme_color_override("cursor_color", Color(0, 0, 0, 1)) |
48 | entry.add_theme_stylebox_override("focus", entry_style) | 66 | entry.add_theme_stylebox_override("focus", entry_style) |
49 | panel.add_child(entry) | ||
50 | entry.text_submitted.connect(text_entered) | 67 | entry.text_submitted.connect(text_entered) |
51 | 68 | ||
69 | var tc_arranger = VBoxContainer.new() | ||
70 | tc_arranger.add_child(label) | ||
71 | tc_arranger.add_child(entry) | ||
72 | tc_arranger.add_theme_constant_override("separation", 40) | ||
73 | panel.add_child(tc_arranger) | ||
74 | |||
75 | var tracker_margins = MarginContainer.new() | ||
76 | tracker_margins.name = "Locations" | ||
77 | tracker_margins.add_theme_constant_override("margin_top", 60) | ||
78 | tracker_margins.add_theme_constant_override("margin_left", 60) | ||
79 | tracker_margins.add_theme_constant_override("margin_right", 60) | ||
80 | tracker_margins.add_theme_constant_override("margin_bottom", 60) | ||
81 | tabs.add_child(tracker_margins) | ||
82 | |||
83 | tracker_label = RichTextLabel.new() | ||
84 | tracker_margins.add_child(tracker_label) | ||
85 | |||
52 | 86 | ||
53 | func _input(event): | 87 | func _input(event): |
54 | if global.loaded and event is InputEventKey and event.pressed: | 88 | if global.loaded and event is InputEventKey and event.pressed: |
@@ -57,7 +91,7 @@ func _input(event): | |||
57 | is_open = true | 91 | is_open = true |
58 | get_tree().paused = true | 92 | get_tree().paused = true |
59 | Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) | 93 | Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) |
60 | panel.visible = true | 94 | tabs.visible = true |
61 | entry.grab_focus() | 95 | entry.grab_focus() |
62 | get_viewport().set_input_as_handled() | 96 | get_viewport().set_input_as_handled() |
63 | else: | 97 | else: |
@@ -72,7 +106,7 @@ func dismiss(): | |||
72 | if is_open: | 106 | if is_open: |
73 | get_tree().paused = false | 107 | get_tree().paused = false |
74 | Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) | 108 | Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) |
75 | panel.visible = false | 109 | tabs.visible = false |
76 | is_open = false | 110 | is_open = false |
77 | 111 | ||
78 | 112 | ||
@@ -93,3 +127,46 @@ func text_entered(text): | |||
93 | return | 127 | return |
94 | 128 | ||
95 | ap.client.say(cmd) | 129 | ap.client.say(cmd) |
130 | |||
131 | |||
132 | func update_locations(): | ||
133 | var ap = global.get_node("Archipelago") | ||
134 | var gamedata = global.get_node("Gamedata") | ||
135 | |||
136 | tracker_label.clear() | ||
137 | tracker_label.push_font(preload("res://assets/fonts/Lingo2.ttf")) | ||
138 | tracker_label.push_font_size(24) | ||
139 | |||
140 | locations_overlay.clear() | ||
141 | locations_overlay.push_font(preload("res://assets/fonts/Lingo2.ttf")) | ||
142 | locations_overlay.push_font_size(24) | ||
143 | locations_overlay.push_color(Color(0.9, 0.9, 0.9, 1)) | ||
144 | locations_overlay.push_outline_color(Color(0, 0, 0, 1)) | ||
145 | locations_overlay.push_outline_size(2) | ||
146 | |||
147 | var location_names = [] | ||
148 | for location_id in ap.client._accessible_locations: | ||
149 | if not ap.client._checked_locations.has(location_id): | ||
150 | var location_name = gamedata.location_name_by_id.get(location_id, "(Unknown)") | ||
151 | location_names.append(location_name) | ||
152 | |||
153 | location_names.sort() | ||
154 | |||
155 | var count = 0 | ||
156 | for location_name in location_names: | ||
157 | tracker_label.append_text("[p]%s[/p]" % location_name) | ||
158 | if count < 18: | ||
159 | locations_overlay.append_text("[p align=right]%s[/p]" % location_name) | ||
160 | count += 1 | ||
161 | |||
162 | if count > 18: | ||
163 | locations_overlay.append_text("[p align=right][lb]...[rb][/p]") | ||
164 | |||
165 | |||
166 | func update_locations_visibility(): | ||
167 | var ap = global.get_node("Archipelago") | ||
168 | locations_overlay.visible = ap.show_locations | ||
169 | |||
170 | |||
171 | func reset(): | ||
172 | locations_overlay.clear() | ||