TD-18: Setup Matchmaking
All checks were successful
Quality Check / Linting (push) Successful in 7s
All checks were successful
Quality Check / Linting (push) Successful in 7s
This commit is contained in:
parent
8cafd27ff4
commit
b1c2dd4eb5
19 changed files with 479 additions and 1836 deletions
|
@ -114,7 +114,7 @@ custom_features=""
|
||||||
export_filter="all_resources"
|
export_filter="all_resources"
|
||||||
include_filter=""
|
include_filter=""
|
||||||
exclude_filter=""
|
exclude_filter=""
|
||||||
export_path=""
|
export_path="../../../../../Downloads/TowerDefence.dmg"
|
||||||
encryption_include_filters=""
|
encryption_include_filters=""
|
||||||
encryption_exclude_filters=""
|
encryption_exclude_filters=""
|
||||||
encrypt_pck=false
|
encrypt_pck=false
|
||||||
|
|
2
gdlintrc
2
gdlintrc
|
@ -37,7 +37,7 @@ loop-variable-name: _?[a-z][a-z0-9]*(_[a-z0-9]+)*
|
||||||
max-file-lines: 1000
|
max-file-lines: 1000
|
||||||
max-line-length: 80
|
max-line-length: 80
|
||||||
max-public-methods: 20
|
max-public-methods: 20
|
||||||
max-returns: 6
|
max-returns: 20
|
||||||
mixed-tabs-and-spaces: null
|
mixed-tabs-and-spaces: null
|
||||||
no-elif-return: null
|
no-elif-return: null
|
||||||
no-else-return: null
|
no-else-return: null
|
||||||
|
|
|
@ -18,6 +18,14 @@ config/icon="res://textures/icon.svg"
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
ConnectionChannel="*res://scripts/channel/connection/connection_channel.gd"
|
ConnectionChannel="*res://scripts/channel/connection/connection_channel.gd"
|
||||||
|
MatchmakingChannel="*res://scripts/channel/matchmaking/matchmaking_channel.gd"
|
||||||
|
|
||||||
|
[display]
|
||||||
|
|
||||||
|
window/size/viewport_width=1920
|
||||||
|
window/size/viewport_height=1080
|
||||||
|
window/stretch/mode="viewport"
|
||||||
|
window/stretch/aspect="expand"
|
||||||
|
|
||||||
[editor_plugins]
|
[editor_plugins]
|
||||||
|
|
||||||
|
|
|
@ -1,120 +0,0 @@
|
||||||
[gd_scene load_steps=6 format=3 uid="uid://dtaaw31x3n22f"]
|
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/ui/login.gd" id="1_12w35"]
|
|
||||||
[ext_resource type="Script" path="res://scripts/ui/show_banner_on_error.gd" id="1_41hxt"]
|
|
||||||
[ext_resource type="Resource" uid="uid://cdixdbu3sqgjn" path="res://config/api_config.tres" id="2_60hb8"]
|
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_d0bbp"]
|
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_bdovr"]
|
|
||||||
bg_color = Color(0.74463, 0.147328, 0, 1)
|
|
||||||
|
|
||||||
[node name="Login" type="Control"]
|
|
||||||
layout_mode = 3
|
|
||||||
anchors_preset = 15
|
|
||||||
anchor_right = 1.0
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
|
|
||||||
[node name="Panel" type="Panel" parent="."]
|
|
||||||
layout_mode = 1
|
|
||||||
anchors_preset = 15
|
|
||||||
anchor_right = 1.0
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
theme_override_styles/panel = SubResource("StyleBoxFlat_d0bbp")
|
|
||||||
|
|
||||||
[node name="Container" type="VBoxContainer" parent="Panel"]
|
|
||||||
layout_mode = 1
|
|
||||||
anchors_preset = 15
|
|
||||||
anchor_right = 1.0
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
|
|
||||||
[node name="Banner" type="PanelContainer" parent="Panel/Container" node_paths=PackedStringArray("login", "text")]
|
|
||||||
layout_mode = 2
|
|
||||||
script = ExtResource("1_41hxt")
|
|
||||||
login = NodePath("../CenterContainer/VBoxContainer/Button")
|
|
||||||
text = NodePath("CenterContainer/MarginContainer/RichTextLabel")
|
|
||||||
|
|
||||||
[node name="Panel" type="Panel" parent="Panel/Container/Banner"]
|
|
||||||
layout_mode = 2
|
|
||||||
theme_override_styles/panel = SubResource("StyleBoxFlat_bdovr")
|
|
||||||
|
|
||||||
[node name="CenterContainer" type="CenterContainer" parent="Panel/Container/Banner"]
|
|
||||||
layout_mode = 2
|
|
||||||
|
|
||||||
[node name="MarginContainer" type="MarginContainer" parent="Panel/Container/Banner/CenterContainer"]
|
|
||||||
layout_mode = 2
|
|
||||||
theme_override_constants/margin_top = 8
|
|
||||||
theme_override_constants/margin_bottom = 8
|
|
||||||
|
|
||||||
[node name="RichTextLabel" type="RichTextLabel" parent="Panel/Container/Banner/CenterContainer/MarginContainer"]
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Keine Verbindung"
|
|
||||||
fit_content = true
|
|
||||||
autowrap_mode = 0
|
|
||||||
|
|
||||||
[node name="CenterContainer" type="CenterContainer" parent="Panel/Container"]
|
|
||||||
layout_mode = 2
|
|
||||||
size_flags_vertical = 3
|
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/Container/CenterContainer"]
|
|
||||||
custom_minimum_size = Vector2(500, 0)
|
|
||||||
layout_mode = 2
|
|
||||||
theme_override_constants/separation = 16
|
|
||||||
|
|
||||||
[node name="Header" type="RichTextLabel" parent="Panel/Container/CenterContainer/VBoxContainer"]
|
|
||||||
layout_mode = 2
|
|
||||||
theme_override_font_sizes/normal_font_size = 30
|
|
||||||
text = "Login"
|
|
||||||
fit_content = true
|
|
||||||
scroll_active = false
|
|
||||||
autowrap_mode = 0
|
|
||||||
|
|
||||||
[node name="InputContainer" type="VBoxContainer" parent="Panel/Container/CenterContainer/VBoxContainer"]
|
|
||||||
layout_mode = 2
|
|
||||||
theme_override_constants/separation = 8
|
|
||||||
|
|
||||||
[node name="UsernameContainer" type="VBoxContainer" parent="Panel/Container/CenterContainer/VBoxContainer/InputContainer"]
|
|
||||||
layout_mode = 2
|
|
||||||
|
|
||||||
[node name="UsernameLabel" type="RichTextLabel" parent="Panel/Container/CenterContainer/VBoxContainer/InputContainer/UsernameContainer"]
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Username:
|
|
||||||
"
|
|
||||||
fit_content = true
|
|
||||||
scroll_active = false
|
|
||||||
autowrap_mode = 0
|
|
||||||
|
|
||||||
[node name="UsernameInput" type="LineEdit" parent="Panel/Container/CenterContainer/VBoxContainer/InputContainer/UsernameContainer"]
|
|
||||||
layout_mode = 2
|
|
||||||
placeholder_text = "username"
|
|
||||||
|
|
||||||
[node name="PasswordContainer" type="VBoxContainer" parent="Panel/Container/CenterContainer/VBoxContainer/InputContainer"]
|
|
||||||
layout_mode = 2
|
|
||||||
|
|
||||||
[node name="PaswordLabel" type="RichTextLabel" parent="Panel/Container/CenterContainer/VBoxContainer/InputContainer/PasswordContainer"]
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Password:"
|
|
||||||
fit_content = true
|
|
||||||
scroll_active = false
|
|
||||||
autowrap_mode = 0
|
|
||||||
|
|
||||||
[node name="PasswordInput" type="LineEdit" parent="Panel/Container/CenterContainer/VBoxContainer/InputContainer/PasswordContainer"]
|
|
||||||
layout_mode = 2
|
|
||||||
placeholder_text = "password"
|
|
||||||
secret = true
|
|
||||||
|
|
||||||
[node name="Button" type="Button" parent="Panel/Container/CenterContainer/VBoxContainer" node_paths=PackedStringArray("username_field", "password_field")]
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Login"
|
|
||||||
script = ExtResource("1_12w35")
|
|
||||||
username_field = NodePath("../InputContainer/UsernameContainer/UsernameInput")
|
|
||||||
password_field = NodePath("../InputContainer/PasswordContainer/PasswordInput")
|
|
||||||
api_config = ExtResource("2_60hb8")
|
|
||||||
|
|
||||||
[node name="HTTPRequest" type="HTTPRequest" parent="Panel/Container/CenterContainer/VBoxContainer/Button"]
|
|
|
@ -1,7 +1,24 @@
|
||||||
[gd_scene load_steps=3 format=3 uid="uid://bqfijb7bk2g7j"]
|
[gd_scene load_steps=12 format=3 uid="uid://bqfijb7bk2g7j"]
|
||||||
|
|
||||||
[ext_resource type="Theme" uid="uid://bt4hxdwromnxs" path="res://ui/theme.tres" id="1_6qgep"]
|
[ext_resource type="Theme" uid="uid://bt4hxdwromnxs" path="res://ui/theme.tres" id="1_6qgep"]
|
||||||
[ext_resource type="Script" path="res://scripts/ui/switch_to_scene.gd" id="2_c477a"]
|
[ext_resource type="Script" path="res://scripts/ui/show_banner_on_error.gd" id="2_1tbi1"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/ui/swap_menu.gd" id="2_c477a"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/ui/login.gd" id="3_33cgr"]
|
||||||
|
[ext_resource type="Resource" uid="uid://cdixdbu3sqgjn" path="res://config/api_config.tres" id="4_5vuod"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/ui/quit.gd" id="6_cixwl"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/ui/search_match.gd" id="7_dmfpl"]
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_q2pxx"]
|
||||||
|
bg_color = Color(0.52, 0.52, 0.52, 1)
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_socr1"]
|
||||||
|
bg_color = Color(0.74463, 0.147328, 0, 1)
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_fh0xh"]
|
||||||
|
bg_color = Color(0.135012, 0.135012, 0.135012, 1)
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_x4jly"]
|
||||||
|
bg_color = Color(7.89344e-06, 0.65411, 0.87403, 1)
|
||||||
|
|
||||||
[node name="Root" type="Panel"]
|
[node name="Root" type="Panel"]
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
|
@ -12,22 +29,26 @@ offset_right = -1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
theme = ExtResource("1_6qgep")
|
theme = ExtResource("1_6qgep")
|
||||||
|
theme_override_styles/panel = SubResource("StyleBoxFlat_q2pxx")
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
[node name="Screens" type="TabContainer" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 8
|
anchors_preset = 15
|
||||||
anchor_left = 0.5
|
anchor_right = 1.0
|
||||||
anchor_top = 0.5
|
anchor_bottom = 1.0
|
||||||
anchor_right = 0.5
|
|
||||||
anchor_bottom = 0.5
|
|
||||||
offset_left = -180.5
|
|
||||||
offset_top = -44.0
|
|
||||||
offset_right = 180.5
|
|
||||||
offset_bottom = 44.0
|
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
current_tab = 0
|
||||||
|
tabs_visible = false
|
||||||
|
|
||||||
[node name="Text" type="RichTextLabel" parent="VBoxContainer"]
|
[node name="Start" type="CenterContainer" parent="Screens"]
|
||||||
|
layout_mode = 2
|
||||||
|
metadata/_tab_index = 0
|
||||||
|
|
||||||
|
[node name="V" type="VBoxContainer" parent="Screens/Start"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Title" type="RichTextLabel" parent="Screens/Start/V"]
|
||||||
clip_contents = false
|
clip_contents = false
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_stretch_ratio = 7.45
|
size_flags_stretch_ratio = 7.45
|
||||||
|
@ -37,14 +58,141 @@ fit_content = true
|
||||||
scroll_active = false
|
scroll_active = false
|
||||||
autowrap_mode = 0
|
autowrap_mode = 0
|
||||||
|
|
||||||
[node name="Button" type="Button" parent="VBoxContainer"]
|
[node name="Login" type="Button" parent="Screens/Start/V" node_paths=PackedStringArray("menu")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Login"
|
text = "Login"
|
||||||
script = ExtResource("2_c477a")
|
script = ExtResource("2_c477a")
|
||||||
scene_name = "login"
|
menu = NodePath("../../../Login")
|
||||||
|
|
||||||
[node name="Button2" type="Button" parent="VBoxContainer"]
|
[node name="Settings" type="Button" parent="Screens/Start/V"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Testszene"
|
text = "Settings"
|
||||||
script = ExtResource("2_c477a")
|
script = ExtResource("2_c477a")
|
||||||
scene_name = "theme_test"
|
|
||||||
|
[node name="Quit" type="Button" parent="Screens/Start/V"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Quit"
|
||||||
|
script = ExtResource("6_cixwl")
|
||||||
|
|
||||||
|
[node name="Login" type="VBoxContainer" parent="Screens"]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
metadata/_tab_index = 1
|
||||||
|
|
||||||
|
[node name="Banner" type="PanelContainer" parent="Screens/Login" node_paths=PackedStringArray("login", "text")]
|
||||||
|
layout_mode = 2
|
||||||
|
script = ExtResource("2_1tbi1")
|
||||||
|
login = NodePath("../CenterContainer/VBoxContainer/Actions/Login")
|
||||||
|
text = NodePath("CenterContainer/MarginContainer/RichTextLabel")
|
||||||
|
|
||||||
|
[node name="Panel" type="Panel" parent="Screens/Login/Banner"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_styles/panel = SubResource("StyleBoxFlat_socr1")
|
||||||
|
|
||||||
|
[node name="CenterContainer" type="CenterContainer" parent="Screens/Login/Banner"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="MarginContainer" type="MarginContainer" parent="Screens/Login/Banner/CenterContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/margin_top = 8
|
||||||
|
theme_override_constants/margin_bottom = 8
|
||||||
|
|
||||||
|
[node name="RichTextLabel" type="RichTextLabel" parent="Screens/Login/Banner/CenterContainer/MarginContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Keine Verbindung"
|
||||||
|
fit_content = true
|
||||||
|
autowrap_mode = 0
|
||||||
|
|
||||||
|
[node name="CenterContainer" type="CenterContainer" parent="Screens/Login"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="Screens/Login/CenterContainer"]
|
||||||
|
custom_minimum_size = Vector2(500, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/separation = 16
|
||||||
|
|
||||||
|
[node name="UsernameInput" type="LineEdit" parent="Screens/Login/CenterContainer/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
placeholder_text = "username"
|
||||||
|
|
||||||
|
[node name="PasswordInput" type="LineEdit" parent="Screens/Login/CenterContainer/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
placeholder_text = "password"
|
||||||
|
secret = true
|
||||||
|
|
||||||
|
[node name="Actions" type="HBoxContainer" parent="Screens/Login/CenterContainer/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Back" type="Button" parent="Screens/Login/CenterContainer/VBoxContainer/Actions" node_paths=PackedStringArray("menu")]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Back"
|
||||||
|
script = ExtResource("2_c477a")
|
||||||
|
menu = NodePath("../../../../../Start")
|
||||||
|
|
||||||
|
[node name="Login" type="Button" parent="Screens/Login/CenterContainer/VBoxContainer/Actions" node_paths=PackedStringArray("username_field", "password_field", "next_view")]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Login"
|
||||||
|
script = ExtResource("3_33cgr")
|
||||||
|
username_field = NodePath("../../UsernameInput")
|
||||||
|
password_field = NodePath("../../PasswordInput")
|
||||||
|
api_config = ExtResource("4_5vuod")
|
||||||
|
next_view = NodePath("../../../../../Lobby")
|
||||||
|
|
||||||
|
[node name="HTTPRequest" type="HTTPRequest" parent="Screens/Login/CenterContainer/VBoxContainer/Actions/Login"]
|
||||||
|
|
||||||
|
[node name="Lobby" type="CenterContainer" parent="Screens" node_paths=PackedStringArray("popup", "search_button", "abort_button", "accept_button", "decline_button", "time_bar", "login")]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
script = ExtResource("7_dmfpl")
|
||||||
|
popup = NodePath("Popup")
|
||||||
|
search_button = NodePath("Search")
|
||||||
|
abort_button = NodePath("Abort")
|
||||||
|
accept_button = NodePath("Popup/MarginContainer/HBoxContainer/Accept")
|
||||||
|
decline_button = NodePath("Popup/MarginContainer/HBoxContainer/Decline")
|
||||||
|
time_bar = NodePath("Popup/Time Bar")
|
||||||
|
login = NodePath("../Login/CenterContainer/VBoxContainer/Actions/Login")
|
||||||
|
metadata/_tab_index = 2
|
||||||
|
|
||||||
|
[node name="Search" type="Button" parent="Screens/Lobby"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Search"
|
||||||
|
|
||||||
|
[node name="Abort" type="Button" parent="Screens/Lobby"]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Abort"
|
||||||
|
|
||||||
|
[node name="Popup" type="PanelContainer" parent="Screens/Lobby"]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_styles/panel = SubResource("StyleBoxFlat_fh0xh")
|
||||||
|
|
||||||
|
[node name="MarginContainer" type="MarginContainer" parent="Screens/Lobby/Popup"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/margin_left = 16
|
||||||
|
theme_override_constants/margin_top = 16
|
||||||
|
theme_override_constants/margin_right = 16
|
||||||
|
theme_override_constants/margin_bottom = 16
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="Screens/Lobby/Popup/MarginContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/separation = 16
|
||||||
|
|
||||||
|
[node name="Accept" type="Button" parent="Screens/Lobby/Popup/MarginContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Accept
|
||||||
|
"
|
||||||
|
|
||||||
|
[node name="Decline" type="Button" parent="Screens/Lobby/Popup/MarginContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Decline"
|
||||||
|
|
||||||
|
[node name="Time Bar" type="ProgressBar" parent="Screens/Lobby/Popup"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 8
|
||||||
|
theme_override_styles/fill = SubResource("StyleBoxFlat_x4jly")
|
||||||
|
value = 100.0
|
||||||
|
show_percentage = false
|
||||||
|
|
File diff suppressed because it is too large
Load diff
11
scripts/channel/matchmaking/match_aborted_message.gd
Normal file
11
scripts/channel/matchmaking/match_aborted_message.gd
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
class_name MatchAbortedMessage
|
||||||
|
extends Message
|
||||||
|
|
||||||
|
const MESSAGE_ID := "MatchAborted"
|
||||||
|
|
||||||
|
# gdlint:ignore = class-variable-name
|
||||||
|
@export var matchId: String
|
||||||
|
|
||||||
|
|
||||||
|
func get_message_id() -> String:
|
||||||
|
return MESSAGE_ID
|
10
scripts/channel/matchmaking/match_accepted_message.gd
Normal file
10
scripts/channel/matchmaking/match_accepted_message.gd
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
class_name MatchAcceptedMessage
|
||||||
|
extends Message
|
||||||
|
|
||||||
|
# gdlint:ignore = class-variable-name
|
||||||
|
@export var matchId: String
|
||||||
|
@export var accepted: bool
|
||||||
|
|
||||||
|
|
||||||
|
func get_message_id() -> String:
|
||||||
|
return "MatchAccepted"
|
14
scripts/channel/matchmaking/match_established_message.gd
Normal file
14
scripts/channel/matchmaking/match_established_message.gd
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
class_name MatchEstablishedMessage
|
||||||
|
extends Message
|
||||||
|
|
||||||
|
const MESSAGE_ID := "MatchEstablished"
|
||||||
|
|
||||||
|
# gdlint:ignore = class-variable-name
|
||||||
|
@export var matchId: String
|
||||||
|
# gdlint:ignore = class-variable-name
|
||||||
|
@export var opponentName: String
|
||||||
|
@export var token: String
|
||||||
|
|
||||||
|
|
||||||
|
func get_message_id() -> String:
|
||||||
|
return MESSAGE_ID
|
13
scripts/channel/matchmaking/match_found_message.gd
Normal file
13
scripts/channel/matchmaking/match_found_message.gd
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
class_name MatchFoundMessage
|
||||||
|
extends Message
|
||||||
|
|
||||||
|
const MESSAGE_ID := "MatchFound"
|
||||||
|
|
||||||
|
# gdlint:ignore = class-variable-name
|
||||||
|
@export var matchId: String
|
||||||
|
@export var created: int
|
||||||
|
@export var ttl: int
|
||||||
|
|
||||||
|
|
||||||
|
func get_message_id() -> String:
|
||||||
|
return MESSAGE_ID
|
|
@ -0,0 +1,10 @@
|
||||||
|
class_name MatchSetSearchStateMessage
|
||||||
|
extends Message
|
||||||
|
|
||||||
|
const MESSAGE_ID := "MatchSetSearchState"
|
||||||
|
|
||||||
|
@export var searching: bool
|
||||||
|
|
||||||
|
|
||||||
|
func get_message_id() -> String:
|
||||||
|
return MESSAGE_ID
|
57
scripts/channel/matchmaking/matchmaking_channel.gd
Normal file
57
scripts/channel/matchmaking/matchmaking_channel.gd
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
extends Channel
|
||||||
|
|
||||||
|
signal on_match_set_search_state(msg: MatchSetSearchStateMessage)
|
||||||
|
signal on_match_found(msg: MatchFoundMessage)
|
||||||
|
signal on_match_aborted
|
||||||
|
signal on_match_established(msg: MatchEstablishedMessage)
|
||||||
|
|
||||||
|
|
||||||
|
func get_channel_location() -> String:
|
||||||
|
return "matchmaking"
|
||||||
|
|
||||||
|
|
||||||
|
func _process(_delta: float) -> void:
|
||||||
|
self.socket.poll()
|
||||||
|
if self.socket.get_ready_state() != WebSocketPeer.STATE_OPEN:
|
||||||
|
return
|
||||||
|
while self.socket.get_available_packet_count():
|
||||||
|
var msg := (
|
||||||
|
Message
|
||||||
|
. deserialize(
|
||||||
|
self.socket.get_packet().get_string_from_utf8(),
|
||||||
|
[
|
||||||
|
MatchSetSearchStateMessage,
|
||||||
|
MatchFoundMessage,
|
||||||
|
MatchAbortedMessage,
|
||||||
|
MatchEstablishedMessage,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
match msg.get_message_id():
|
||||||
|
MatchSetSearchStateMessage.MESSAGE_ID:
|
||||||
|
on_match_set_search_state.emit(msg)
|
||||||
|
MatchFoundMessage.MESSAGE_ID:
|
||||||
|
on_match_found.emit(msg)
|
||||||
|
MatchAbortedMessage.MESSAGE_ID:
|
||||||
|
on_match_found.emit(msg)
|
||||||
|
MatchEstablishedMessage.MESSAGE_ID:
|
||||||
|
on_match_established.emit(msg)
|
||||||
|
_:
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
func send_search_state(searching: bool) -> void:
|
||||||
|
if self.socket.get_ready_state() != WebSocketPeer.STATE_OPEN:
|
||||||
|
return
|
||||||
|
var msg := MatchSetSearchStateMessage.new()
|
||||||
|
msg.searching = searching
|
||||||
|
self.socket.send_text(Message.serialize(msg))
|
||||||
|
|
||||||
|
|
||||||
|
func send_match_accepted(accepted: bool, match_id: String) -> void:
|
||||||
|
if self.socket.get_ready_state() != WebSocketPeer.STATE_OPEN:
|
||||||
|
return
|
||||||
|
var msg := MatchAcceptedMessage.new()
|
||||||
|
msg.accepted = accepted
|
||||||
|
msg.matchId = match_id
|
||||||
|
self.socket.send_text(Message.serialize(msg))
|
|
@ -1,6 +1,6 @@
|
||||||
class_name Message
|
class_name Message
|
||||||
|
|
||||||
enum Channels { CONNECTION, TIME }
|
enum Channels { CONNECTION, MATCHMAKING }
|
||||||
|
|
||||||
|
|
||||||
func get_message_id() -> String:
|
func get_message_id() -> String:
|
||||||
|
|
|
@ -7,6 +7,7 @@ signal login_error(error: ApiError)
|
||||||
@export var username_field: LineEdit
|
@export var username_field: LineEdit
|
||||||
@export var password_field: LineEdit
|
@export var password_field: LineEdit
|
||||||
@export var api_config: ApiConfig
|
@export var api_config: ApiConfig
|
||||||
|
@export var next_view: Control
|
||||||
var api: ServerApi
|
var api: ServerApi
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +21,9 @@ func _ready() -> void:
|
||||||
if not api_config:
|
if not api_config:
|
||||||
push_error("No API Configuration provided")
|
push_error("No API Configuration provided")
|
||||||
return
|
return
|
||||||
|
if not next_view:
|
||||||
|
push_error("No next view configured")
|
||||||
|
return
|
||||||
api = ServerApi.new(api_config)
|
api = ServerApi.new(api_config)
|
||||||
connect("pressed", login)
|
connect("pressed", login)
|
||||||
username_field.connect("text_submitted", login_wrapper)
|
username_field.connect("text_submitted", login_wrapper)
|
||||||
|
@ -38,6 +42,8 @@ func login() -> void:
|
||||||
|
|
||||||
|
|
||||||
func on_success(response: ApiResponse) -> void:
|
func on_success(response: ApiResponse) -> void:
|
||||||
|
ConnectionChannel.connect_to_channel(response.data.token)
|
||||||
|
next_view.visible = true
|
||||||
login_successful.emit(response.data)
|
login_successful.emit(response.data)
|
||||||
|
|
||||||
|
|
||||||
|
|
9
scripts/ui/quit.gd
Normal file
9
scripts/ui/quit.gd
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
extends Button
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
connect("pressed", on_pressed)
|
||||||
|
|
||||||
|
|
||||||
|
func on_pressed() -> void:
|
||||||
|
get_tree().quit()
|
157
scripts/ui/search_match.gd
Normal file
157
scripts/ui/search_match.gd
Normal file
|
@ -0,0 +1,157 @@
|
||||||
|
extends Control
|
||||||
|
|
||||||
|
@export var popup: PanelContainer
|
||||||
|
@export var search_button: Button
|
||||||
|
@export var abort_button: Button
|
||||||
|
@export var accept_button: Button
|
||||||
|
@export var decline_button: Button
|
||||||
|
@export var time_bar: ProgressBar
|
||||||
|
@export var login: Login
|
||||||
|
|
||||||
|
var searching: bool = false
|
||||||
|
var sent_accept_message: bool = false
|
||||||
|
var match_id: String = ""
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
if !export_valid():
|
||||||
|
return
|
||||||
|
login.connect("login_successful", on_login)
|
||||||
|
|
||||||
|
# Websockets
|
||||||
|
(
|
||||||
|
ConnectionChannel
|
||||||
|
. connect(
|
||||||
|
"on_channel_token_received",
|
||||||
|
on_channel_token_received,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(
|
||||||
|
MatchmakingChannel
|
||||||
|
. connect(
|
||||||
|
"on_match_set_search_state",
|
||||||
|
on_match_set_search_state,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
MatchmakingChannel.connect("on_match_found", on_match_found)
|
||||||
|
MatchmakingChannel.connect("on_match_aborted", on_match_aborted)
|
||||||
|
MatchmakingChannel.connect("on_match_established", on_match_established)
|
||||||
|
|
||||||
|
# UI
|
||||||
|
search_button.connect("pressed", on_search_pressed)
|
||||||
|
abort_button.connect("pressed", on_abort_pressed)
|
||||||
|
accept_button.connect("pressed", on_accept_pressed)
|
||||||
|
decline_button.connect("pressed", on_decline_pressed)
|
||||||
|
popup.visible = false
|
||||||
|
|
||||||
|
|
||||||
|
# gdlint:ignore = max-public-methods
|
||||||
|
func export_valid() -> bool:
|
||||||
|
if not popup:
|
||||||
|
push_error("Popup not Set")
|
||||||
|
return false
|
||||||
|
if not search_button:
|
||||||
|
push_error("Search Button not Set")
|
||||||
|
return false
|
||||||
|
if not abort_button:
|
||||||
|
push_error("Abort Button not Set")
|
||||||
|
return false
|
||||||
|
if not accept_button:
|
||||||
|
push_error("Accept Button not Set")
|
||||||
|
return false
|
||||||
|
if not decline_button:
|
||||||
|
push_error("Decline Button not Set")
|
||||||
|
return false
|
||||||
|
if not time_bar:
|
||||||
|
push_error("Time Bar not Set")
|
||||||
|
return false
|
||||||
|
if not login:
|
||||||
|
push_error("No login configured")
|
||||||
|
return false
|
||||||
|
return true
|
||||||
|
|
||||||
|
|
||||||
|
func on_login(_session: PlayerLoginSession) -> void:
|
||||||
|
ConnectionChannel.request_channel_token(Message.Channels.MATCHMAKING)
|
||||||
|
|
||||||
|
|
||||||
|
##############################
|
||||||
|
# Websocket Interactions #
|
||||||
|
##############################
|
||||||
|
|
||||||
|
|
||||||
|
func on_channel_token_received(msg: ProvidedConnectionTokenMessage) -> void:
|
||||||
|
if msg.channel != Message.Channels.MATCHMAKING:
|
||||||
|
return
|
||||||
|
MatchmakingChannel.connect_socket(msg.token)
|
||||||
|
|
||||||
|
|
||||||
|
func on_match_set_search_state(msg: MatchSetSearchStateMessage) -> void:
|
||||||
|
set_searching_ui(msg.searching)
|
||||||
|
|
||||||
|
|
||||||
|
func on_match_found(msg: MatchFoundMessage) -> void:
|
||||||
|
set_match_accptance_ui(true)
|
||||||
|
set_accaptence_buttons_enabled(true)
|
||||||
|
match_id = msg.matchId
|
||||||
|
# TODO: Show and Reset Timer bar
|
||||||
|
|
||||||
|
|
||||||
|
func on_match_aborted() -> void:
|
||||||
|
set_match_accptance_ui(false)
|
||||||
|
set_searching_ui(false)
|
||||||
|
match_id = ""
|
||||||
|
|
||||||
|
|
||||||
|
func on_match_established(msg: MatchEstablishedMessage) -> void:
|
||||||
|
print(msg.opponentName)
|
||||||
|
#TODO: Implement
|
||||||
|
|
||||||
|
|
||||||
|
#############################
|
||||||
|
# UI Interactions #
|
||||||
|
#############################
|
||||||
|
|
||||||
|
|
||||||
|
func on_search_pressed() -> void:
|
||||||
|
if searching:
|
||||||
|
return
|
||||||
|
set_searching_ui(true)
|
||||||
|
MatchmakingChannel.send_search_state(true)
|
||||||
|
|
||||||
|
|
||||||
|
func on_abort_pressed() -> void:
|
||||||
|
if not searching:
|
||||||
|
return
|
||||||
|
set_searching_ui(false)
|
||||||
|
MatchmakingChannel.send_search_state(false)
|
||||||
|
|
||||||
|
|
||||||
|
func on_accept_pressed() -> void:
|
||||||
|
set_accaptence_buttons_enabled(false)
|
||||||
|
MatchmakingChannel.send_match_accepted(true, match_id)
|
||||||
|
|
||||||
|
|
||||||
|
func on_decline_pressed() -> void:
|
||||||
|
set_accaptence_buttons_enabled(false)
|
||||||
|
MatchmakingChannel.send_match_accepted(false, match_id)
|
||||||
|
|
||||||
|
|
||||||
|
#############################
|
||||||
|
# UI Management #
|
||||||
|
#############################
|
||||||
|
|
||||||
|
|
||||||
|
func set_searching_ui(new_searching: bool) -> void:
|
||||||
|
searching = new_searching
|
||||||
|
search_button.visible = !new_searching
|
||||||
|
abort_button.visible = new_searching
|
||||||
|
|
||||||
|
|
||||||
|
func set_accaptence_buttons_enabled(enabled: bool) -> void:
|
||||||
|
accept_button.disabled = !enabled
|
||||||
|
decline_button.disabled = !enabled
|
||||||
|
|
||||||
|
|
||||||
|
func set_match_accptance_ui(vissible: bool) -> void:
|
||||||
|
popup.visible = vissible
|
14
scripts/ui/swap_menu.gd
Normal file
14
scripts/ui/swap_menu.gd
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
extends Button
|
||||||
|
|
||||||
|
@export var menu: Control
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
connect("pressed", _on_Button_pressed)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Button_pressed() -> void:
|
||||||
|
if not menu:
|
||||||
|
push_error("Menu to swap to not configgured")
|
||||||
|
return
|
||||||
|
menu.visible = true
|
|
@ -1,14 +0,0 @@
|
||||||
extends Button
|
|
||||||
|
|
||||||
@export var scene_name: String
|
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
connect("pressed", _on_Button_pressed)
|
|
||||||
|
|
||||||
|
|
||||||
func _on_Button_pressed() -> void:
|
|
||||||
if not scene_name:
|
|
||||||
push_error("Scene to switch to is not configured")
|
|
||||||
return
|
|
||||||
get_tree().change_scene_to_file("res://scenes/" + scene_name + ".tscn")
|
|
|
@ -42,7 +42,7 @@ func _process(_delta: float) -> void:
|
||||||
if state != WebSocketPeer.STATE_OPEN:
|
if state != WebSocketPeer.STATE_OPEN:
|
||||||
return
|
return
|
||||||
while time_channel.get_available_packet_count():
|
while time_channel.get_available_packet_count():
|
||||||
var msg: CurrentUnixTimeMessage = Message.deserialize(
|
var msg: CurrentUnixTimeMessage = Messize(
|
||||||
time_channel.get_packet().get_string_from_utf8(), [CurrentUnixTimeMessage]
|
time_channel.get_packet().get_string_from_utf8(), [CurrentUnixTimeMessage]
|
||||||
)
|
)
|
||||||
if msg == null:
|
if msg == null:
|
||||||
|
|
Loading…
Add table
Reference in a new issue