feat: added global chat #9

Merged
EvgeniySugonyako merged 1 commits from develop into production 2024-05-15 11:45:31 +00:00
3 changed files with 211 additions and 1 deletions

View File

@ -0,0 +1,32 @@
extends Node
@export var GlobalChat : RichTextLabel
func _ready():
GlobalChat.clear()
GlobalChat.scroll_following = true
func send_message(_message):
self.rpc_id(1, "rpc_send_message", GATEWAY.clientId, _message)
#---------------------------------------------------------------------------------------------------
# RPC Client
@rpc("any_peer")
func rpc_add_message(_name, _message):
GlobalChat.append_text("# ")
GlobalChat.push_color(Color.DARK_ORANGE)
GlobalChat.append_text(_name)
GlobalChat.pop()
GlobalChat.append_text(" : ")
GlobalChat.append_text(_message)
GlobalChat.newline()
#---------------------------------------------------------------------------------------------------
# RPC Server
@rpc("any_peer", "call_local")
func rpc_send_message(_client_id, _message): pass

View File

@ -1,7 +1,44 @@
[gd_scene format=3 uid="uid://d4nhi3k0agm2q"]
[gd_scene load_steps=5 format=3 uid="uid://d4nhi3k0agm2q"]
[ext_resource type="FontFile" uid="uid://dhvfket83gjln" path="res://data/styles/fonts/Roboto-Regular.ttf" id="1_qbt18"]
[ext_resource type="Script" path="res://data/scenes/ChatSinhronizer.gd" id="2_cc8va"]
[sub_resource type="GDScript" id="GDScript_2o8xy"]
script/source = "extends LineEdit
@export var ChatSinhronizer : Node
func _process(_delta):
if self.has_focus() and Input.is_key_pressed(KEY_ENTER):
if !self.text.is_empty():
ChatSinhronizer.send_message(self.text)
self.text = \"\"
"
[sub_resource type="GDScript" id="GDScript_4mwjp"]
script/source = "extends Button
func _ready():
multiplayer.server_disconnected.connect(_server_disconnect)
func _on_button_up():
multiplayer.emit_signal(\"server_disconnected\")
func _server_disconnect():
get_tree().change_scene_to_packed(load(\"res://data/scenes/main_menu/main_menu.tscn\"))
"
[node name="Lobbies" type="Node"]
[node name="ChatSinhronizer" type="Node" parent="." node_paths=PackedStringArray("GlobalChat")]
script = ExtResource("2_cc8va")
GlobalChat = NodePath("../LobbieUI/MainMarginContainer/MainUIContainer/MainContainer/GlobalChatBackground/GlobalChatMarginContainer/GlobalChatContainer/Panel/GlobalChat")
[node name="LobbieUI" type="Control" parent="."]
layout_mode = 3
anchors_preset = 15
@ -18,3 +55,141 @@ anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.125911, 0.125911, 0.125911, 1)
[node name="MainMarginContainer" type="MarginContainer" parent="LobbieUI"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="MainUIContainer" type="VBoxContainer" parent="LobbieUI/MainMarginContainer"]
layout_mode = 2
[node name="MainContainer" type="HBoxContainer" parent="LobbieUI/MainMarginContainer/MainUIContainer"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/separation = 10
alignment = 1
[node name="GamesBackground" type="ColorRect" parent="LobbieUI/MainMarginContainer/MainUIContainer/MainContainer"]
layout_mode = 2
size_flags_horizontal = 3
color = Color(0.215902, 0.215902, 0.215902, 1)
[node name="GamesMarginContainer" type="MarginContainer" parent="LobbieUI/MainMarginContainer/MainUIContainer/MainContainer/GamesBackground"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 5
theme_override_constants/margin_top = 5
theme_override_constants/margin_right = 5
theme_override_constants/margin_bottom = 5
[node name="GamesContainer" type="VBoxContainer" parent="LobbieUI/MainMarginContainer/MainUIContainer/MainContainer/GamesBackground/GamesMarginContainer"]
layout_mode = 2
[node name="GamesTitle" type="Label" parent="LobbieUI/MainMarginContainer/MainUIContainer/MainContainer/GamesBackground/GamesMarginContainer/GamesContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0.707602, 0.575264, 0, 1)
theme_override_fonts/font = ExtResource("1_qbt18")
theme_override_font_sizes/font_size = 16
text = "$Games"
horizontal_alignment = 1
vertical_alignment = 1
[node name="GamesScroll" type="ScrollContainer" parent="LobbieUI/MainMarginContainer/MainUIContainer/MainContainer/GamesBackground/GamesMarginContainer/GamesContainer"]
layout_mode = 2
size_flags_vertical = 3
horizontal_scroll_mode = 0
vertical_scroll_mode = 2
[node name="Games" type="VBoxContainer" parent="LobbieUI/MainMarginContainer/MainUIContainer/MainContainer/GamesBackground/GamesMarginContainer/GamesContainer/GamesScroll"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 10
[node name="Label" type="Label" parent="LobbieUI/MainMarginContainer/MainUIContainer/MainContainer/GamesBackground/GamesMarginContainer/GamesContainer/GamesScroll/Games"]
layout_mode = 2
theme_override_fonts/font = ExtResource("1_qbt18")
theme_override_font_sizes/font_size = 15
text = "Game number 1"
[node name="GlobalChatBackground" type="ColorRect" parent="LobbieUI/MainMarginContainer/MainUIContainer/MainContainer"]
layout_mode = 2
size_flags_horizontal = 3
color = Color(0.215902, 0.215902, 0.215902, 1)
[node name="GlobalChatMarginContainer" type="MarginContainer" parent="LobbieUI/MainMarginContainer/MainUIContainer/MainContainer/GlobalChatBackground"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 5
theme_override_constants/margin_top = 5
theme_override_constants/margin_right = 5
theme_override_constants/margin_bottom = 5
[node name="GlobalChatContainer" type="VBoxContainer" parent="LobbieUI/MainMarginContainer/MainUIContainer/MainContainer/GlobalChatBackground/GlobalChatMarginContainer"]
layout_mode = 2
[node name="GlobalChatTitle" type="Label" parent="LobbieUI/MainMarginContainer/MainUIContainer/MainContainer/GlobalChatBackground/GlobalChatMarginContainer/GlobalChatContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0.707602, 0.575264, 0, 1)
theme_override_fonts/font = ExtResource("1_qbt18")
theme_override_font_sizes/font_size = 16
text = "$GlobalChat"
horizontal_alignment = 1
vertical_alignment = 1
[node name="Panel" type="Panel" parent="LobbieUI/MainMarginContainer/MainUIContainer/MainContainer/GlobalChatBackground/GlobalChatMarginContainer/GlobalChatContainer"]
layout_mode = 2
size_flags_vertical = 3
[node name="GlobalChat" type="RichTextLabel" parent="LobbieUI/MainMarginContainer/MainUIContainer/MainContainer/GlobalChatBackground/GlobalChatMarginContainer/GlobalChatContainer/Panel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
theme_override_fonts/normal_font = ExtResource("1_qbt18")
theme_override_font_sizes/normal_font_size = 15
bbcode_enabled = true
text = "# PlayerName : Text text text. Text text text. Text text text. Text text text. Text text text. Text text text."
scroll_following = true
shortcut_keys_enabled = false
deselect_on_focus_loss_enabled = false
drag_and_drop_selection_enabled = false
metadata/_edit_use_anchors_ = true
[node name="GlobalChatMessage" type="LineEdit" parent="LobbieUI/MainMarginContainer/MainUIContainer/MainContainer/GlobalChatBackground/GlobalChatMarginContainer/GlobalChatContainer" node_paths=PackedStringArray("ChatSinhronizer")]
layout_mode = 2
size_flags_vertical = 8
placeholder_text = "$your_message"
caret_blink = true
script = SubResource("GDScript_2o8xy")
ChatSinhronizer = NodePath("../../../../../../../../ChatSinhronizer")
[node name="Back" type="Button" parent="LobbieUI/MainMarginContainer/MainUIContainer"]
layout_mode = 2
size_flags_horizontal = 8
size_flags_vertical = 8
theme_override_fonts/font = ExtResource("1_qbt18")
theme_override_font_sizes/font_size = 15
text = "$Back"
script = SubResource("GDScript_4mwjp")
[connection signal="button_up" from="LobbieUI/MainMarginContainer/MainUIContainer/Back" to="LobbieUI/MainMarginContainer/MainUIContainer/Back" method="_on_button_up"]

View File

@ -19,3 +19,6 @@ $Saturday,Saturday,Субота,Суббота
$Sunday,Sunday,Неділя,Воскресение
$Enter_to_Cashflow_World,Enter to Cashflow World,Увійти у CashFlow всесвіт,Войти в мир CashFlow
$Registrate_on_Cashflow_World,Registrate on Cashflow World,Реєстрація у всесвіті CashFlow,Регистрация в мире CashFlow
$Games,Games,Ігри,Игры
$GlobalChat,Global chat,Глобальний чат,Общий чат
$your_message,Your message here (Enter),Ваше повідомлення (Enter),Ваше сообщение (Enter)

1 KEYS en uk ru
19 $Sunday Sunday Неділя Воскресение
20 $Enter_to_Cashflow_World Enter to Cashflow World Увійти у CashFlow всесвіт Войти в мир CashFlow
21 $Registrate_on_Cashflow_World Registrate on Cashflow World Реєстрація у всесвіті CashFlow Регистрация в мире CashFlow
22 $Games Games Ігри Игры
23 $GlobalChat Global chat Глобальний чат Общий чат
24 $your_message Your message here (Enter) Ваше повідомлення (Enter) Ваше сообщение (Enter)