diff options
Diffstat (limited to 'client/Archipelago')
| -rw-r--r-- | client/Archipelago/manager.gd | 42 | ||||
| -rw-r--r-- | client/Archipelago/pauseMenu.gd | 6 | ||||
| -rw-r--r-- | client/Archipelago/settings_screen.gd | 7 | ||||
| -rw-r--r-- | client/Archipelago/textclient.gd | 90 |
4 files changed, 145 insertions, 0 deletions
| diff --git a/client/Archipelago/manager.gd b/client/Archipelago/manager.gd index 6b34bdf..10c4096 100644 --- a/client/Archipelago/manager.gd +++ b/client/Archipelago/manager.gd | |||
| @@ -51,6 +51,7 @@ func _ready(): | |||
| 51 | client.SCRIPT_uuid = SCRIPT_uuid | 51 | client.SCRIPT_uuid = SCRIPT_uuid |
| 52 | 52 | ||
| 53 | client.connect("item_received", _process_item) | 53 | client.connect("item_received", _process_item) |
| 54 | client.connect("message_received", _process_message) | ||
| 54 | client.connect("could_not_connect", _client_could_not_connect) | 55 | client.connect("could_not_connect", _client_could_not_connect) |
| 55 | client.connect("connect_status", _client_connect_status) | 56 | client.connect("connect_status", _client_connect_status) |
| 56 | client.connect("client_connected", _client_connected) | 57 | client.connect("client_connected", _client_connected) |
| @@ -171,6 +172,8 @@ func _process_item(item, index, from, flags): | |||
| 171 | 172 | ||
| 172 | 173 | ||
| 173 | func _process_message(message): | 174 | func _process_message(message): |
| 175 | parse_printjson_for_textclient(message) | ||
| 176 | |||
| 174 | if ( | 177 | if ( |
| 175 | !message.has("receiving") | 178 | !message.has("receiving") |
| 176 | or !message.has("item") | 179 | or !message.has("item") |
| @@ -215,6 +218,45 @@ func _process_message(message): | |||
| 215 | global.get_node("Messages").showMessage(sentMsg) | 218 | global.get_node("Messages").showMessage(sentMsg) |
| 216 | 219 | ||
| 217 | 220 | ||
| 221 | func parse_printjson_for_textclient(message): | ||
| 222 | var parts = [] | ||
| 223 | for message_part in message["data"]: | ||
| 224 | if !message_part.has("type") and message_part.has("text"): | ||
| 225 | parts.append(message_part["text"]) | ||
| 226 | elif message_part["type"] == "player_id": | ||
| 227 | if int(message_part["text"]) == client._slot: | ||
| 228 | parts.append( | ||
| 229 | "[color=#ee00ee]%s[/color]" % client._player_name_by_slot[client._slot] | ||
| 230 | ) | ||
| 231 | else: | ||
| 232 | var from = float(message_part["text"]) | ||
| 233 | parts.append("[color=#fafad2]%s[/color]" % client._player_name_by_slot[from]) | ||
| 234 | elif message_part["type"] == "item_id": | ||
| 235 | var item_name = "Unknown" | ||
| 236 | var item_player_game = client._game_by_player[message_part["player"]] | ||
| 237 | if client._item_id_to_name[item_player_game].has(int(message_part["text"])): | ||
| 238 | item_name = client._item_id_to_name[item_player_game][int(message_part["text"])] | ||
| 239 | |||
| 240 | parts.append( | ||
| 241 | "[color=%s]%s[/color]" % [colorForItemType(message_part["flags"]), item_name] | ||
| 242 | ) | ||
| 243 | elif message_part["type"] == "location_id": | ||
| 244 | var location_name = "Unknown" | ||
| 245 | var location_player_game = client._game_by_player[message_part["player"]] | ||
| 246 | if client._location_id_to_name[location_player_game].has(int(message_part["text"])): | ||
| 247 | location_name = client._location_id_to_name[location_player_game][int( | ||
| 248 | message_part["text"] | ||
| 249 | )] | ||
| 250 | |||
| 251 | parts.append("[color=#00ff7f]%s[/color]" % location_name) | ||
| 252 | elif message_part.has("text"): | ||
| 253 | parts.append(message_part["text"]) | ||
| 254 | |||
| 255 | var textclient_node = global.get_node("Textclient") | ||
| 256 | if textclient_node != null: | ||
| 257 | textclient_node.parse_printjson("".join(parts)) | ||
| 258 | |||
| 259 | |||
| 218 | func _client_could_not_connect(): | 260 | func _client_could_not_connect(): |
| 219 | emit_signal("could_not_connect") | 261 | emit_signal("could_not_connect") |
| 220 | 262 | ||
| diff --git a/client/Archipelago/pauseMenu.gd b/client/Archipelago/pauseMenu.gd new file mode 100644 index 0000000..6c013a5 --- /dev/null +++ b/client/Archipelago/pauseMenu.gd | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | extends "res://scripts/ui/pauseMenu.gd" | ||
| 2 | |||
| 3 | |||
| 4 | func _pause_game(): | ||
| 5 | global.get_node("Textclient").dismiss() | ||
| 6 | super._pause_game() | ||
| diff --git a/client/Archipelago/settings_screen.gd b/client/Archipelago/settings_screen.gd index 0611bab..3697466 100644 --- a/client/Archipelago/settings_screen.gd +++ b/client/Archipelago/settings_screen.gd | |||
| @@ -39,6 +39,7 @@ func _ready(): | |||
| 39 | installScriptExtension(ResourceLoader.load("user://maps/Archipelago/animationListener.gd")) | 39 | installScriptExtension(ResourceLoader.load("user://maps/Archipelago/animationListener.gd")) |
| 40 | installScriptExtension(ResourceLoader.load("user://maps/Archipelago/door.gd")) | 40 | installScriptExtension(ResourceLoader.load("user://maps/Archipelago/door.gd")) |
| 41 | installScriptExtension(ResourceLoader.load("user://maps/Archipelago/painting.gd")) | 41 | installScriptExtension(ResourceLoader.load("user://maps/Archipelago/painting.gd")) |
| 42 | installScriptExtension(ResourceLoader.load("user://maps/Archipelago/pauseMenu.gd")) | ||
| 42 | installScriptExtension(ResourceLoader.load("user://maps/Archipelago/player.gd")) | 43 | installScriptExtension(ResourceLoader.load("user://maps/Archipelago/player.gd")) |
| 43 | installScriptExtension(ResourceLoader.load("user://maps/Archipelago/saver.gd")) | 44 | installScriptExtension(ResourceLoader.load("user://maps/Archipelago/saver.gd")) |
| 44 | installScriptExtension(ResourceLoader.load("user://maps/Archipelago/teleportListener.gd")) | 45 | installScriptExtension(ResourceLoader.load("user://maps/Archipelago/teleportListener.gd")) |
| @@ -58,6 +59,11 @@ func _ready(): | |||
| 58 | messages_instance.name = "Messages" | 59 | messages_instance.name = "Messages" |
| 59 | global.add_child(messages_instance) | 60 | global.add_child(messages_instance) |
| 60 | 61 | ||
| 62 | var textclient_script = load("user://maps/Archipelago/textclient.gd") | ||
| 63 | var textclient_instance = textclient_script.new() | ||
| 64 | textclient_instance.name = "Textclient" | ||
| 65 | global.add_child(textclient_instance) | ||
| 66 | |||
| 61 | var ap = global.get_node("Archipelago") | 67 | var ap = global.get_node("Archipelago") |
| 62 | ap.connect("ap_connected", connectionSuccessful) | 68 | ap.connect("ap_connected", connectionSuccessful) |
| 63 | ap.connect("could_not_connect", connectionUnsuccessful) | 69 | ap.connect("could_not_connect", connectionUnsuccessful) |
| @@ -149,6 +155,7 @@ func connectionSuccessful(): | |||
| 149 | clearResourceCache("res://objects/nodes/listeners/worldportListener.tscn") | 155 | clearResourceCache("res://objects/nodes/listeners/worldportListener.tscn") |
| 150 | clearResourceCache("res://objects/nodes/player.tscn") | 156 | clearResourceCache("res://objects/nodes/player.tscn") |
| 151 | clearResourceCache("res://objects/nodes/saver.tscn") | 157 | clearResourceCache("res://objects/nodes/saver.tscn") |
| 158 | clearResourceCache("res://objects/scenes/menus/pause_menu.tscn") | ||
| 152 | 159 | ||
| 153 | var paintings_dir = DirAccess.open("res://objects/meshes/paintings") | 160 | var paintings_dir = DirAccess.open("res://objects/meshes/paintings") |
| 154 | if paintings_dir: | 161 | if paintings_dir: |
| diff --git a/client/Archipelago/textclient.gd b/client/Archipelago/textclient.gd new file mode 100644 index 0000000..6a0aa95 --- /dev/null +++ b/client/Archipelago/textclient.gd | |||
| @@ -0,0 +1,90 @@ | |||
| 1 | extends CanvasLayer | ||
| 2 | |||
| 3 | var panel | ||
| 4 | var label | ||
| 5 | var entry | ||
| 6 | var is_open = false | ||
| 7 | |||
| 8 | |||
| 9 | func _ready(): | ||
| 10 | process_mode = ProcessMode.PROCESS_MODE_ALWAYS | ||
| 11 | |||
| 12 | panel = Panel.new() | ||
| 13 | panel.set_name("Panel") | ||
| 14 | panel.offset_left = 100 | ||
| 15 | panel.offset_right = 1820 | ||
| 16 | panel.offset_top = 100 | ||
| 17 | panel.offset_bottom = 980 | ||
| 18 | panel.visible = false | ||
| 19 | add_child(panel) | ||
| 20 | |||
| 21 | label = RichTextLabel.new() | ||
| 22 | label.set_name("Label") | ||
| 23 | label.offset_left = 80 | ||
| 24 | label.offset_right = 1640 | ||
| 25 | label.offset_top = 80 | ||
| 26 | label.offset_bottom = 720 | ||
| 27 | label.scroll_following = true | ||
| 28 | label.selection_enabled = true | ||
| 29 | panel.add_child(label) | ||
| 30 | |||
| 31 | label.push_font(load("res://assets/fonts/Lingo2.ttf")) | ||
| 32 | label.push_font_size(36) | ||
| 33 | |||
| 34 | var entry_style = StyleBoxFlat.new() | ||
| 35 | entry_style.bg_color = Color(0.9, 0.9, 0.9, 1) | ||
| 36 | |||
| 37 | entry = LineEdit.new() | ||
| 38 | entry.set_name("Entry") | ||
| 39 | entry.offset_left = 80 | ||
| 40 | entry.offset_right = 1640 | ||
| 41 | entry.offset_top = 760 | ||
| 42 | entry.offset_bottom = 840 | ||
| 43 | entry.add_theme_font_override("font", load("res://assets/fonts/Lingo2.ttf")) | ||
| 44 | entry.add_theme_font_size_override("font_size", 36) | ||
| 45 | entry.add_theme_color_override("font_color", Color(0, 0, 0, 1)) | ||
| 46 | entry.add_theme_color_override("cursor_color", Color(0, 0, 0, 1)) | ||
| 47 | entry.add_theme_stylebox_override("focus", entry_style) | ||
| 48 | panel.add_child(entry) | ||
| 49 | entry.connect("text_submitted", text_entered) | ||
| 50 | |||
| 51 | |||
| 52 | func _input(event): | ||
| 53 | if event is InputEventKey and event.pressed: | ||
| 54 | if event.keycode == KEY_TAB and !Input.is_key_pressed(KEY_SHIFT): | ||
| 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_viewport().set_input_as_handled() | ||
| 62 | else: | ||
| 63 | dismiss() | ||
| 64 | elif event.keycode == KEY_ESCAPE: | ||
| 65 | if is_open: | ||
| 66 | dismiss() | ||
| 67 | get_viewport().set_input_as_handled() | ||
| 68 | |||
| 69 | |||
| 70 | func 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 | |||
| 78 | func parse_printjson(text): | ||
| 79 | if !label.text.is_empty(): | ||
| 80 | #label.newline() | ||
| 81 | pass | ||
| 82 | |||
| 83 | label.append_text("[p]" + text + "[/p]") | ||
| 84 | |||
| 85 | |||
| 86 | func text_entered(text): | ||
| 87 | var ap = global.get_node("Archipelago") | ||
| 88 | var cmd = text.trim_suffix("\n") | ||
| 89 | ap.client.say(cmd) | ||
| 90 | entry.text = "" | ||
