diff options
author | tpart <tpart120@proton.me> | 2024-08-29 14:41:55 +0200 |
---|---|---|
committer | tpart <tpart120@proton.me> | 2024-08-29 14:41:55 +0200 |
commit | 6c74fe5c8a74031a4bfcbfc73a7fcd008af7554c (patch) | |
tree | ba11c0b46bd5aea17db5fda611ed1a13a2a9124f /client/menu/chat/chat_preview.gd | |
parent | 1561cd04a1cbba079a9f4cc4e6545b510d76e3ea (diff) | |
download | hurrycurry-6c74fe5c8a74031a4bfcbfc73a7fcd008af7554c.tar hurrycurry-6c74fe5c8a74031a4bfcbfc73a7fcd008af7554c.tar.bz2 hurrycurry-6c74fe5c8a74031a4bfcbfc73a7fcd008af7554c.tar.zst |
Add new chat system
Diffstat (limited to 'client/menu/chat/chat_preview.gd')
-rw-r--r-- | client/menu/chat/chat_preview.gd | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/client/menu/chat/chat_preview.gd b/client/menu/chat/chat_preview.gd new file mode 100644 index 00000000..189ca89b --- /dev/null +++ b/client/menu/chat/chat_preview.gd @@ -0,0 +1,33 @@ +# Hurry Curry! - a game about cooking +# Copyright 2024 tpart +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# +extends Control + +const CHAT_MESSAGE_SCENE = preload("res://menu/chat/chat_message.tscn") + +@onready var game: Game = $"../Game" +@onready var messages_container: VBoxContainer = $MarginContainer/ScrollContainer/PanelContainer/Messages + +func _ready(): + game.text_message.connect( + func message(player: int, text: String, timeout_initial: float, timeout_remaining: float): + add_message(player, text, timeout_remaining) + ) + +func add_message(player: int, message: String, time: float): + var username: String = game.players[player].username + var chat_message: ChatMessage = CHAT_MESSAGE_SCENE.instantiate() + messages_container.add_child(chat_message) + chat_message.set_message("<%s>" % username, message, true, time) |