diff options
Diffstat (limited to 'client/Archipelago/manager.gd')
| -rw-r--r-- | client/Archipelago/manager.gd | 42 |
1 files changed, 42 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 | ||
