diff options
Diffstat (limited to 'apworld/client')
-rw-r--r-- | apworld/client/client.gd | 48 | ||||
-rw-r--r-- | apworld/client/gamedata.gd | 12 | ||||
-rw-r--r-- | apworld/client/keyboard.gd | 36 | ||||
-rw-r--r-- | apworld/client/manager.gd | 14 | ||||
-rw-r--r-- | apworld/client/pauseMenu.gd | 20 | ||||
-rw-r--r-- | apworld/client/player.gd | 1 | ||||
-rw-r--r-- | apworld/client/textclient.gd | 5 | ||||
-rw-r--r-- | apworld/client/worldport.gd | 10 |
8 files changed, 130 insertions, 16 deletions
diff --git a/apworld/client/client.gd b/apworld/client/client.gd index 286ad4b..a23e85a 100644 --- a/apworld/client/client.gd +++ b/apworld/client/client.gd | |||
@@ -18,10 +18,12 @@ var _seed = "" | |||
18 | var _team = 0 | 18 | var _team = 0 |
19 | var _slot = 0 | 19 | var _slot = 0 |
20 | var _checked_locations = [] | 20 | var _checked_locations = [] |
21 | var _checked_worldports = [] | ||
21 | var _received_indexes = [] | 22 | var _received_indexes = [] |
22 | var _received_items = {} | 23 | var _received_items = {} |
23 | var _slot_data = {} | 24 | var _slot_data = {} |
24 | var _accessible_locations = [] | 25 | var _accessible_locations = [] |
26 | var _accessible_worldports = [] | ||
25 | 27 | ||
26 | signal could_not_connect | 28 | signal could_not_connect |
27 | signal connect_status | 29 | signal connect_status |
@@ -33,6 +35,8 @@ signal item_sent_notification(message) | |||
33 | signal hint_received(message) | 35 | signal hint_received(message) |
34 | signal accessible_locations_updated | 36 | signal accessible_locations_updated |
35 | signal checked_locations_updated | 37 | signal checked_locations_updated |
38 | signal checked_worldports_updated | ||
39 | signal keyboard_update_received | ||
36 | 40 | ||
37 | 41 | ||
38 | func _init(): | 42 | func _init(): |
@@ -54,7 +58,9 @@ func _reset_state(): | |||
54 | _should_process = false | 58 | _should_process = false |
55 | _received_items = {} | 59 | _received_items = {} |
56 | _received_indexes = [] | 60 | _received_indexes = [] |
61 | _checked_worldports = [] | ||
57 | _accessible_locations = [] | 62 | _accessible_locations = [] |
63 | _accessible_worldports = [] | ||
58 | 64 | ||
59 | 65 | ||
60 | func disconnect_from_ap(): | 66 | func disconnect_from_ap(): |
@@ -116,6 +122,14 @@ func _on_web_socket_server_message_received(_peer_id: int, packet: String) -> vo | |||
116 | 122 | ||
117 | checked_locations_updated.emit() | 123 | checked_locations_updated.emit() |
118 | 124 | ||
125 | elif cmd == "UpdateWorldports": | ||
126 | for port_id in message["worldports"]: | ||
127 | var lint = int(port_id) | ||
128 | if not _checked_worldports.has(lint): | ||
129 | _checked_worldports.append(lint) | ||
130 | |||
131 | checked_worldports_updated.emit() | ||
132 | |||
119 | elif cmd == "ItemReceived": | 133 | elif cmd == "ItemReceived": |
120 | for item in message["items"]: | 134 | for item in message["items"]: |
121 | var index = int(item["index"]) | 135 | var index = int(item["index"]) |
@@ -151,12 +165,24 @@ func _on_web_socket_server_message_received(_peer_id: int, packet: String) -> vo | |||
151 | 165 | ||
152 | elif cmd == "AccessibleLocations": | 166 | elif cmd == "AccessibleLocations": |
153 | _accessible_locations.clear() | 167 | _accessible_locations.clear() |
168 | _accessible_worldports.clear() | ||
154 | 169 | ||
155 | for loc in message["locations"]: | 170 | for loc in message["locations"]: |
156 | _accessible_locations.append(int(loc)) | 171 | _accessible_locations.append(int(loc)) |
157 | 172 | ||
173 | if "worldports" in message: | ||
174 | for port_id in message["worldports"]: | ||
175 | _accessible_worldports.append(int(port_id)) | ||
176 | |||
158 | accessible_locations_updated.emit() | 177 | accessible_locations_updated.emit() |
159 | 178 | ||
179 | elif cmd == "UpdateKeyboard": | ||
180 | var updates = {} | ||
181 | for k in message["updates"]: | ||
182 | updates[k] = int(message["updates"][k]) | ||
183 | |||
184 | keyboard_update_received.emit(updates) | ||
185 | |||
160 | 186 | ||
161 | func connectToServer(server, un, pw): | 187 | func connectToServer(server, un, pw): |
162 | sendMessage([{"cmd": "Connect", "server": server, "player": un, "password": pw}]) | 188 | sendMessage([{"cmd": "Connect", "server": server, "player": un, "password": pw}]) |
@@ -202,19 +228,6 @@ func sendLocations(loc_ids): | |||
202 | sendMessage([{"cmd": "LocationChecks", "locations": loc_ids}]) | 228 | sendMessage([{"cmd": "LocationChecks", "locations": loc_ids}]) |
203 | 229 | ||
204 | 230 | ||
205 | func setValue(key, value, operation = "replace"): | ||
206 | sendMessage( | ||
207 | [ | ||
208 | { | ||
209 | "cmd": "Set", | ||
210 | "key": "Lingo2_%d_%s" % [_slot, key], | ||
211 | "want_reply": false, | ||
212 | "operations": [{"operation": operation, "value": value}] | ||
213 | } | ||
214 | ] | ||
215 | ) | ||
216 | |||
217 | |||
218 | func say(textdata): | 231 | func say(textdata): |
219 | sendMessage([{"cmd": "Say", "text": textdata}]) | 232 | sendMessage([{"cmd": "Say", "text": textdata}]) |
220 | 233 | ||
@@ -227,6 +240,15 @@ func scoutLocations(loc_ids): | |||
227 | sendMessage([{"cmd": "LocationScouts", "locations": loc_ids}]) | 240 | sendMessage([{"cmd": "LocationScouts", "locations": loc_ids}]) |
228 | 241 | ||
229 | 242 | ||
243 | func updateKeyboard(updates): | ||
244 | sendMessage([{"cmd": "UpdateKeyboard", "keyboard": updates}]) | ||
245 | |||
246 | |||
247 | func checkWorldport(port_id): | ||
248 | if not _checked_worldports.has(port_id): | ||
249 | sendMessage([{"cmd": "CheckWorldport", "port_id": port_id}]) | ||
250 | |||
251 | |||
230 | func sendQuit(): | 252 | func sendQuit(): |
231 | sendMessage([{"cmd": "Quit"}]) | 253 | sendMessage([{"cmd": "Quit"}]) |
232 | 254 | ||
diff --git a/apworld/client/gamedata.gd b/apworld/client/gamedata.gd index 39e0583..e44fa17 100644 --- a/apworld/client/gamedata.gd +++ b/apworld/client/gamedata.gd | |||
@@ -161,11 +161,23 @@ func get_door_ap_id(door_id): | |||
161 | return null | 161 | return null |
162 | 162 | ||
163 | 163 | ||
164 | func get_door_map_name(door_id): | ||
165 | var door = objects.get_doors()[door_id] | ||
166 | var room = objects.get_rooms()[door.get_room_id()] | ||
167 | var map = objects.get_maps()[room.get_map_id()] | ||
168 | return map.get_name() | ||
169 | |||
170 | |||
164 | func get_door_receivers(door_id): | 171 | func get_door_receivers(door_id): |
165 | var door = objects.get_doors()[door_id] | 172 | var door = objects.get_doors()[door_id] |
166 | return door.get_receivers() | 173 | return door.get_receivers() |
167 | 174 | ||
168 | 175 | ||
176 | func get_worldport_display_name(port_id): | ||
177 | var port = objects.get_ports()[port_id] | ||
178 | return "%s - %s (Worldport)" % [_get_room_object_map_name(port), port.get_name()] | ||
179 | |||
180 | |||
169 | func _get_map_object_map_name(obj): | 181 | func _get_map_object_map_name(obj): |
170 | return objects.get_maps()[obj.get_map_id()].get_display_name() | 182 | return objects.get_maps()[obj.get_map_id()].get_display_name() |
171 | 183 | ||
diff --git a/apworld/client/keyboard.gd b/apworld/client/keyboard.gd index 450566d..a59c4d0 100644 --- a/apworld/client/keyboard.gd +++ b/apworld/client/keyboard.gd | |||
@@ -48,6 +48,9 @@ func load_seed(): | |||
48 | if localdata.size() > 2: | 48 | if localdata.size() > 2: |
49 | keyholder_state = localdata[2] | 49 | keyholder_state = localdata[2] |
50 | 50 | ||
51 | if not letters_saved.is_empty(): | ||
52 | ap.client.updateKeyboard(letters_saved) | ||
53 | |||
51 | for k in kALL_LETTERS: | 54 | for k in kALL_LETTERS: |
52 | var level = 0 | 55 | var level = 0 |
53 | 56 | ||
@@ -105,10 +108,20 @@ func update_unlocks(): | |||
105 | 108 | ||
106 | 109 | ||
107 | func collect_local_letter(key, level): | 110 | func collect_local_letter(key, level): |
108 | if level < 0 or level > 2 or level < letters_saved.get(key, 0): | 111 | var ap = global.get_node("Archipelago") |
112 | var true_level = 0 | ||
113 | |||
114 | if ap.get_letter_behavior(key, false) == ap.kLETTER_BEHAVIOR_VANILLA: | ||
115 | true_level += 1 | ||
116 | if level == 2 and ap.get_letter_behavior(key, true) == ap.kLETTER_BEHAVIOR_VANILLA: | ||
117 | true_level += 1 | ||
118 | |||
119 | if true_level < letters_saved.get(key, 0): | ||
109 | return | 120 | return |
110 | 121 | ||
111 | letters_saved[key] = level | 122 | letters_saved[key] = true_level |
123 | |||
124 | ap.client.updateKeyboard({key: true_level}) | ||
112 | 125 | ||
113 | if letters_blocked.has(key): | 126 | if letters_blocked.has(key): |
114 | letters_blocked.erase(key) | 127 | letters_blocked.erase(key) |
@@ -197,3 +210,22 @@ func reset_keyholders(): | |||
197 | save() | 210 | save() |
198 | 211 | ||
199 | return cleared_anything | 212 | return cleared_anything |
213 | |||
214 | |||
215 | func remote_keyboard_updated(updates): | ||
216 | var reverse = {} | ||
217 | var should_update = false | ||
218 | |||
219 | for k in updates: | ||
220 | if not letters_saved.has(k) or updates[k] > letters_saved[k]: | ||
221 | letters_saved[k] = updates[k] | ||
222 | should_update = true | ||
223 | elif updates[k] < letters_saved[k]: | ||
224 | reverse[k] = letters_saved[k] | ||
225 | |||
226 | if should_update: | ||
227 | update_unlocks() | ||
228 | |||
229 | if not reverse.is_empty(): | ||
230 | var ap = global.get_node("Archipelago") | ||
231 | ap.client.updateKeyboard(reverse) | ||
diff --git a/apworld/client/manager.gd b/apworld/client/manager.gd index 2c25269..3facfba 100644 --- a/apworld/client/manager.gd +++ b/apworld/client/manager.gd | |||
@@ -15,6 +15,7 @@ var ap_pass = "" | |||
15 | var connection_history = [] | 15 | var connection_history = [] |
16 | var show_compass = false | 16 | var show_compass = false |
17 | var show_locations = false | 17 | var show_locations = false |
18 | var show_minimap = false | ||
18 | 19 | ||
19 | var client | 20 | var client |
20 | var keyboard | 21 | var keyboard |
@@ -93,6 +94,9 @@ func _init(): | |||
93 | if data.size() > 5: | 94 | if data.size() > 5: |
94 | show_locations = data[5] | 95 | show_locations = data[5] |
95 | 96 | ||
97 | if data.size() > 6: | ||
98 | show_minimap = data[6] | ||
99 | |||
96 | 100 | ||
97 | func _ready(): | 101 | func _ready(): |
98 | client = SCRIPT_client.new() | 102 | client = SCRIPT_client.new() |
@@ -105,6 +109,7 @@ func _ready(): | |||
105 | client.hint_received.connect(_process_hint_received) | 109 | client.hint_received.connect(_process_hint_received) |
106 | client.accessible_locations_updated.connect(_on_accessible_locations_updated) | 110 | client.accessible_locations_updated.connect(_on_accessible_locations_updated) |
107 | client.checked_locations_updated.connect(_on_checked_locations_updated) | 111 | client.checked_locations_updated.connect(_on_checked_locations_updated) |
112 | client.checked_worldports_updated.connect(_on_checked_worldports_updated) | ||
108 | 113 | ||
109 | client.could_not_connect.connect(_client_could_not_connect) | 114 | client.could_not_connect.connect(_client_could_not_connect) |
110 | client.connect_status.connect(_client_connect_status) | 115 | client.connect_status.connect(_client_connect_status) |
@@ -114,6 +119,7 @@ func _ready(): | |||
114 | 119 | ||
115 | keyboard = SCRIPT_keyboard.new() | 120 | keyboard = SCRIPT_keyboard.new() |
116 | add_child(keyboard) | 121 | add_child(keyboard) |
122 | client.keyboard_update_received.connect(keyboard.remote_keyboard_updated) | ||
117 | 123 | ||
118 | 124 | ||
119 | func saveSettings(): | 125 | func saveSettings(): |
@@ -128,6 +134,7 @@ func saveSettings(): | |||
128 | connection_history, | 134 | connection_history, |
129 | show_compass, | 135 | show_compass, |
130 | show_locations, | 136 | show_locations, |
137 | show_minimap, | ||
131 | ] | 138 | ] |
132 | file.store_var(data, true) | 139 | file.store_var(data, true) |
133 | file.close() | 140 | file.close() |
@@ -189,6 +196,7 @@ func _process_item(item, amount): | |||
189 | if gamedata.get_door_map_name(lock[0]) != global.map: | 196 | if gamedata.get_door_map_name(lock[0]) != global.map: |
190 | continue | 197 | continue |
191 | 198 | ||
199 | # TODO: fix doors opening from door groups | ||
192 | var receivers = gamedata.get_door_receivers(lock[0]) | 200 | var receivers = gamedata.get_door_receivers(lock[0]) |
193 | var scene = get_tree().get_root().get_node_or_null("scene") | 201 | var scene = get_tree().get_root().get_node_or_null("scene") |
194 | if scene != null: | 202 | if scene != null: |
@@ -321,6 +329,12 @@ func _on_checked_locations_updated(): | |||
321 | textclient_node.update_locations() | 329 | textclient_node.update_locations() |
322 | 330 | ||
323 | 331 | ||
332 | func _on_checked_worldports_updated(): | ||
333 | var textclient_node = global.get_node("Textclient") | ||
334 | if textclient_node != null: | ||
335 | textclient_node.update_locations() | ||
336 | |||
337 | |||
324 | func _client_could_not_connect(message): | 338 | func _client_could_not_connect(message): |
325 | could_not_connect.emit(message) | 339 | could_not_connect.emit(message) |
326 | 340 | ||
diff --git a/apworld/client/pauseMenu.gd b/apworld/client/pauseMenu.gd index d1b4bb3..72b45e8 100644 --- a/apworld/client/pauseMenu.gd +++ b/apworld/client/pauseMenu.gd | |||
@@ -2,6 +2,7 @@ extends "res://scripts/ui/pauseMenu.gd" | |||
2 | 2 | ||
3 | var compass_button | 3 | var compass_button |
4 | var locations_button | 4 | var locations_button |
5 | var minimap_button | ||
5 | 6 | ||
6 | 7 | ||
7 | func _ready(): | 8 | func _ready(): |
@@ -29,6 +30,15 @@ func _ready(): | |||
29 | locations_button.pressed.connect(_toggle_locations) | 30 | locations_button.pressed.connect(_toggle_locations) |
30 | ap_panel.add_child(locations_button) | 31 | ap_panel.add_child(locations_button) |
31 | 32 | ||
33 | minimap_button = CheckBox.new() | ||
34 | minimap_button.text = "show minimap" | ||
35 | minimap_button.button_pressed = ap.show_minimap | ||
36 | minimap_button.position = Vector2(65, 300) | ||
37 | minimap_button.theme = preload("res://assets/themes/baseUI.tres") | ||
38 | minimap_button.add_theme_font_size_override("font_size", 60) | ||
39 | minimap_button.pressed.connect(_toggle_minimap) | ||
40 | ap_panel.add_child(minimap_button) | ||
41 | |||
32 | super._ready() | 42 | super._ready() |
33 | 43 | ||
34 | 44 | ||
@@ -69,3 +79,13 @@ func _toggle_locations(): | |||
69 | 79 | ||
70 | var textclient = global.get_node("Textclient") | 80 | var textclient = global.get_node("Textclient") |
71 | textclient.update_locations_visibility() | 81 | textclient.update_locations_visibility() |
82 | |||
83 | |||
84 | func _toggle_minimap(): | ||
85 | var ap = global.get_node("Archipelago") | ||
86 | ap.show_minimap = minimap_button.button_pressed | ||
87 | ap.saveSettings() | ||
88 | |||
89 | var minimap = get_tree().get_root().get_node("scene/Minimap") | ||
90 | if minimap != null: | ||
91 | minimap.visible = ap.show_minimap | ||
diff --git a/apworld/client/player.gd b/apworld/client/player.gd index fb88880..366c3b0 100644 --- a/apworld/client/player.gd +++ b/apworld/client/player.gd | |||
@@ -330,6 +330,7 @@ func _ready(): | |||
330 | 330 | ||
331 | var minimap = ap.SCRIPT_minimap.new() | 331 | var minimap = ap.SCRIPT_minimap.new() |
332 | minimap.name = "Minimap" | 332 | minimap.name = "Minimap" |
333 | minimap.visible = ap.show_minimap | ||
333 | get_parent().add_child.call_deferred(minimap) | 334 | get_parent().add_child.call_deferred(minimap) |
334 | 335 | ||
335 | super._ready() | 336 | super._ready() |
diff --git a/apworld/client/textclient.gd b/apworld/client/textclient.gd index 1b36c29..af155fb 100644 --- a/apworld/client/textclient.gd +++ b/apworld/client/textclient.gd | |||
@@ -150,6 +150,11 @@ func update_locations(): | |||
150 | var location_name = gamedata.location_name_by_id.get(location_id, "(Unknown)") | 150 | var location_name = gamedata.location_name_by_id.get(location_id, "(Unknown)") |
151 | location_names.append(location_name) | 151 | location_names.append(location_name) |
152 | 152 | ||
153 | for port_id in ap.client._accessible_worldports: | ||
154 | if not ap.client._checked_worldports.has(port_id): | ||
155 | var port_name = gamedata.get_worldport_display_name(port_id) | ||
156 | location_names.append(port_name) | ||
157 | |||
153 | location_names.sort() | 158 | location_names.sort() |
154 | 159 | ||
155 | var count = 0 | 160 | var count = 0 |
diff --git a/apworld/client/worldport.gd b/apworld/client/worldport.gd index cdca248..ed9891e 100644 --- a/apworld/client/worldport.gd +++ b/apworld/client/worldport.gd | |||
@@ -3,6 +3,8 @@ extends "res://scripts/nodes/worldport.gd" | |||
3 | var absolute_rotation = false | 3 | var absolute_rotation = false |
4 | var target_rotation = 0 | 4 | var target_rotation = 0 |
5 | 5 | ||
6 | var port_id = null | ||
7 | |||
6 | 8 | ||
7 | func _ready(): | 9 | func _ready(): |
8 | var node_path = String( | 10 | var node_path = String( |
@@ -13,7 +15,7 @@ func _ready(): | |||
13 | 15 | ||
14 | if ap.shuffle_worldports: | 16 | if ap.shuffle_worldports: |
15 | var gamedata = global.get_node("Gamedata") | 17 | var gamedata = global.get_node("Gamedata") |
16 | var port_id = gamedata.get_port_for_map_node_path(global.map, node_path) | 18 | port_id = gamedata.get_port_for_map_node_path(global.map, node_path) |
17 | if port_id != null: | 19 | if port_id != null: |
18 | if port_id in ap.port_pairings: | 20 | if port_id in ap.port_pairings: |
19 | var target_port = gamedata.objects.get_ports()[ap.port_pairings[port_id]] | 21 | var target_port = gamedata.objects.get_ports()[ap.port_pairings[port_id]] |
@@ -29,6 +31,8 @@ func _ready(): | |||
29 | sets_entry_point = true | 31 | sets_entry_point = true |
30 | invisible = false | 32 | invisible = false |
31 | fades = true | 33 | fades = true |
34 | else: | ||
35 | port_id = null | ||
32 | 36 | ||
33 | if global.map == "icarus" and exit == "daedalus": | 37 | if global.map == "icarus" and exit == "daedalus": |
34 | if not ap.daedalus_roof_access: | 38 | if not ap.daedalus_roof_access: |
@@ -39,6 +43,10 @@ func _ready(): | |||
39 | 43 | ||
40 | func bodyEntered(body): | 44 | func bodyEntered(body): |
41 | if body.is_in_group("player"): | 45 | if body.is_in_group("player"): |
46 | if port_id != null: | ||
47 | var ap = global.get_node("Archipelago") | ||
48 | ap.client.checkWorldport(port_id) | ||
49 | |||
42 | if absolute_rotation: | 50 | if absolute_rotation: |
43 | entry_rotate.y = target_rotation - body.rotation_degrees.y | 51 | entry_rotate.y = target_rotation - body.rotation_degrees.y |
44 | 52 | ||