aboutsummaryrefslogtreecommitdiff
path: root/client/game.gd
diff options
context:
space:
mode:
Diffstat (limited to 'client/game.gd')
-rw-r--r--client/game.gd19
1 files changed, 16 insertions, 3 deletions
diff --git a/client/game.gd b/client/game.gd
index ef7a4575..87613003 100644
--- a/client/game.gd
+++ b/client/game.gd
@@ -255,9 +255,15 @@ func _ready():
)
mp.server_message.connect(
- func(text):
- print("== ", text)
- popup_message.display_server_msg(text)
+ func(message: Dictionary, error: bool):
+ var message_str := get_message_str(message)
+
+ if error:
+ # TODO: Custom popup message style for errors
+ popup_message.display_server_msg(message_str)
+ push_error("Server error: %s" % message_str)
+ else:
+ popup_message.display_server_msg(message_str)
)
mp.score.connect(overlay.update)
@@ -289,6 +295,13 @@ func _process(delta):
if is_replay and mp != null:
mp.send_replay_tick(delta)
+func get_message_str(m: Dictionary) -> String:
+ if "text" in m: return m.text
+ if "translation" in m: return tr(m.translation.id) % m.translation.params.map(get_message_str)
+ if "tile" in m: return tile_names[m.tile]
+ if "item" in m: return item_names[m.item]
+ return "[unknown message type]"
+
func get_tile_collision(pos: Vector2i) -> bool:
var t = map.get_tile_name(pos)
if t == null: return true