summaryrefslogtreecommitdiff
path: root/client/menu/communicate/chat
diff options
context:
space:
mode:
Diffstat (limited to 'client/menu/communicate/chat')
-rw-r--r--client/menu/communicate/chat/chat_message.gd31
-rw-r--r--client/menu/communicate/chat/chat_message.tscn30
-rw-r--r--client/menu/communicate/chat/chat_open.gd46
-rw-r--r--client/menu/communicate/chat/chat_open.tscn54
-rw-r--r--client/menu/communicate/chat/chat_preview.gd33
-rw-r--r--client/menu/communicate/chat/chat_preview.tscn39
6 files changed, 233 insertions, 0 deletions
diff --git a/client/menu/communicate/chat/chat_message.gd b/client/menu/communicate/chat/chat_message.gd
new file mode 100644
index 00000000..1cc57102
--- /dev/null
+++ b/client/menu/communicate/chat/chat_message.gd
@@ -0,0 +1,31 @@
+# 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 HBoxContainer
+class_name ChatMessage
+
+@onready var fade_away_timer: Timer = $FadeAway
+@onready var sender_label: Label = $Sender
+@onready var message_label: Label = $Message
+
+func set_message(username: String, message: String, fade_away: bool = false, fade_time: float = 5.):
+ sender_label.text = username
+ message_label.text = message
+
+ if fade_away:
+ fade_away_timer.start(fade_time)
+
+func _on_fade_away_timeout() -> void:
+ queue_free()
diff --git a/client/menu/communicate/chat/chat_message.tscn b/client/menu/communicate/chat/chat_message.tscn
new file mode 100644
index 00000000..a095c42e
--- /dev/null
+++ b/client/menu/communicate/chat/chat_message.tscn
@@ -0,0 +1,30 @@
+[gd_scene load_steps=4 format=3 uid="uid://bpc2qgsvcafhe"]
+
+[ext_resource type="Script" path="res://menu/communicate/chat/chat_message.gd" id="1_ey0qp"]
+[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme.tres" id="1_rx6vg"]
+
+[sub_resource type="FontVariation" id="FontVariation_jfhbh"]
+variation_embolden = 1.3
+
+[node name="ChatMessage" type="HBoxContainer"]
+offset_right = 72.0
+offset_bottom = 165.0
+theme = ExtResource("1_rx6vg")
+script = ExtResource("1_ey0qp")
+
+[node name="Sender" type="Label" parent="."]
+layout_mode = 2
+theme_override_fonts/font = SubResource("FontVariation_jfhbh")
+text = "<Name>"
+
+[node name="Message" type="Label" parent="."]
+layout_mode = 2
+size_flags_horizontal = 3
+text = "Message"
+vertical_alignment = 1
+autowrap_mode = 3
+
+[node name="FadeAway" type="Timer" parent="."]
+one_shot = true
+
+[connection signal="timeout" from="FadeAway" to="." method="_on_fade_away_timeout"]
diff --git a/client/menu/communicate/chat/chat_open.gd b/client/menu/communicate/chat/chat_open.gd
new file mode 100644
index 00000000..c67a1b1c
--- /dev/null
+++ b/client/menu/communicate/chat/chat_open.gd
@@ -0,0 +1,46 @@
+# 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 Menu
+class_name ChatOpen
+
+const CHAT_MESSAGE_SCENE = preload("res://menu/communicate/chat/chat_message.tscn")
+
+@onready var messages_container: VBoxContainer = $PanelContainer/MarginContainer/VBoxContainer/ScrollContainerCustom/Messages
+@onready var line: LineEdit = $PanelContainer/MarginContainer/VBoxContainer/LineEdit
+@onready var game_menu: GameMenu = get_parent()
+@onready var game: Game = game_menu.game
+
+func _ready() -> void:
+ super()
+ for i in game.text_message_history:
+ add_message(i[0], i[1])
+
+ game.text_message.connect(
+ func message(username: String, text: String, _timeout_initial: float, _timeout_remaining: float):
+ add_message(username, text)
+ )
+
+func _input(event: InputEvent) -> void:
+ if Input.is_action_just_pressed("chat"):
+ if line.text != "":
+ game.mp.send_chat(game.player_id, line.text)
+ exit()
+ super(event)
+
+func add_message(username: String, message: String):
+ var chat_message: ChatMessage = CHAT_MESSAGE_SCENE.instantiate()
+ messages_container.add_child(chat_message)
+ chat_message.set_message("<%s>" % username, message)
diff --git a/client/menu/communicate/chat/chat_open.tscn b/client/menu/communicate/chat/chat_open.tscn
new file mode 100644
index 00000000..0247a1ca
--- /dev/null
+++ b/client/menu/communicate/chat/chat_open.tscn
@@ -0,0 +1,54 @@
+[gd_scene load_steps=7 format=3 uid="uid://dbd6k56l4p0ls"]
+
+[ext_resource type="Script" path="res://menu/communicate/chat/chat_open.gd" id="1_dsl4a"]
+[ext_resource type="Material" uid="uid://beea1pc5nt67r" path="res://menu/theme/dark_blur_material.tres" id="1_isqmk"]
+[ext_resource type="Script" path="res://menu/blur_setup.gd" id="2_urbd2"]
+[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme.tres" id="3_v7xmg"]
+[ext_resource type="StyleBox" uid="uid://bw4jamyna1top" path="res://menu/theme/style/panel_style_sidebar.tres" id="4_ew1yx"]
+[ext_resource type="Script" path="res://menu/scroll_container_custom.gd" id="5_3mths"]
+
+[node name="ChatOpen" type="Control"]
+layout_mode = 3
+anchors_preset = 9
+anchor_bottom = 1.0
+offset_right = 296.0
+grow_vertical = 2
+script = ExtResource("1_dsl4a")
+support_anim = false
+
+[node name="PanelContainer" type="PanelContainer" parent="."]
+material = ExtResource("1_isqmk")
+layout_mode = 1
+anchors_preset = 9
+anchor_bottom = 1.0
+offset_right = 296.0
+grow_vertical = 2
+theme = ExtResource("3_v7xmg")
+theme_override_styles/panel = ExtResource("4_ew1yx")
+script = ExtResource("2_urbd2")
+
+[node name="MarginContainer" type="MarginContainer" parent="PanelContainer"]
+layout_mode = 2
+
+[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer"]
+layout_mode = 2
+size_flags_horizontal = 3
+size_flags_vertical = 3
+theme_override_constants/separation = 0
+
+[node name="ScrollContainerCustom" type="ScrollContainer" parent="PanelContainer/MarginContainer/VBoxContainer"]
+material = ExtResource("1_isqmk")
+layout_mode = 2
+size_flags_horizontal = 3
+size_flags_vertical = 3
+script = ExtResource("5_3mths")
+auto_scroll_to_bottom = true
+
+[node name="Messages" type="VBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer/ScrollContainerCustom"]
+layout_mode = 2
+size_flags_horizontal = 3
+size_flags_vertical = 3
+
+[node name="LineEdit" type="LineEdit" parent="PanelContainer/MarginContainer/VBoxContainer"]
+layout_mode = 2
+placeholder_text = "c.chat.write_message"
diff --git a/client/menu/communicate/chat/chat_preview.gd b/client/menu/communicate/chat/chat_preview.gd
new file mode 100644
index 00000000..14713f7e
--- /dev/null
+++ b/client/menu/communicate/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
+class_name ChatPreview
+
+const CHAT_MESSAGE_SCENE = preload("res://menu/communicate/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(username: String, text: String, _timeout_initial: float, timeout_remaining: float):
+ add_message(username, text, timeout_remaining)
+ )
+
+func add_message(username: String, message: String, time: float):
+ var chat_message: ChatMessage = CHAT_MESSAGE_SCENE.instantiate()
+ messages_container.add_child(chat_message)
+ chat_message.set_message("<%s>" % username, message, true, time)
diff --git a/client/menu/communicate/chat/chat_preview.tscn b/client/menu/communicate/chat/chat_preview.tscn
new file mode 100644
index 00000000..4cc39e00
--- /dev/null
+++ b/client/menu/communicate/chat/chat_preview.tscn
@@ -0,0 +1,39 @@
+[gd_scene load_steps=5 format=3 uid="uid://xcxbmynn8mhi"]
+
+[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme.tres" id="1_x8ock"]
+[ext_resource type="Script" path="res://menu/communicate/chat/chat_preview.gd" id="2_72x70"]
+[ext_resource type="Material" uid="uid://beea1pc5nt67r" path="res://menu/theme/dark_blur_material.tres" id="4_jo1xn"]
+[ext_resource type="Script" path="res://menu/blur_setup.gd" id="5_1l77s"]
+
+[node name="ChatPreview" type="Control"]
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+mouse_filter = 2
+theme = ExtResource("1_x8ock")
+script = ExtResource("2_72x70")
+
+[node name="MarginContainer" type="MarginContainer" parent="."]
+layout_mode = 2
+anchor_bottom = 1.0
+offset_right = 296.0
+grow_vertical = 2
+
+[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer"]
+layout_mode = 2
+horizontal_scroll_mode = 0
+
+[node name="PanelContainer" type="PanelContainer" parent="MarginContainer/ScrollContainer"]
+material = ExtResource("4_jo1xn")
+layout_mode = 2
+size_flags_horizontal = 3
+size_flags_vertical = 0
+mouse_filter = 2
+script = ExtResource("5_1l77s")
+
+[node name="Messages" type="VBoxContainer" parent="MarginContainer/ScrollContainer/PanelContainer"]
+layout_mode = 2
+mouse_filter = 2