push project up sabs assets
This commit is contained in:
100
scenes/screens/lobby_screen/lobby.gd
Normal file
100
scenes/screens/lobby_screen/lobby.gd
Normal file
@@ -0,0 +1,100 @@
|
||||
class_name Lobby extends LobbyBase
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Globals.lobby_data.lobby_ui = self
|
||||
|
||||
setup_signals()
|
||||
|
||||
func _exit_tree() -> void:
|
||||
if Globals.multiplayer_data.is_multiplayer_active: return
|
||||
|
||||
if client.peer:
|
||||
client.close_connection()
|
||||
|
||||
func setup_signals() -> void:
|
||||
rpc_signals.match_list_entries.connect(_match_list_entries)
|
||||
rpc_signals.match_list_entry_activated.connect(_on_match_list_entry_activated)
|
||||
rpc_signals.match_list_entry_added.connect(_on_match_list_entry_added)
|
||||
rpc_signals.match_list_entry_removed.connect(_on_match_list_entry_removed)
|
||||
rpc_signals.match_list_entry_load_match.connect(_on_match_list_entry_load_match)
|
||||
|
||||
func _server_host_started() -> void:
|
||||
host_connect_bttn.visible = false
|
||||
|
||||
# NOTE: 'matches_list' can be empty but so long as we get the call from the
|
||||
# server we know we are connected and thus hide respective UI elements.
|
||||
func _match_list_entries(matches_list: Array) -> void:
|
||||
push_warning("Client Joined Host: Full Match List Recieved...\n", matches_list)
|
||||
|
||||
match_create_vbox.visible = true
|
||||
search_vbox.visible = true
|
||||
host_disconnect_bttn.visible = true
|
||||
host_connect_bttn.visible = false
|
||||
|
||||
for match_entry in matches_list:
|
||||
_create_match_entry(match_entry)
|
||||
|
||||
func _on_match_list_entry_activated(match_id: String) -> void:
|
||||
for match_entry in match_list.get_children():
|
||||
match_entry.join_bttn.visible = false
|
||||
if not match_entry.match_id == match_id: continue
|
||||
|
||||
active_match = match_entry
|
||||
match_entry.join_bttn.text = "Delete"
|
||||
match_entry.join_bttn.visible = true
|
||||
match_create_vbox.visible = false
|
||||
|
||||
match_entry.join_bttn.pressed.disconnect(_join_match)
|
||||
match_entry.join_bttn.pressed.connect(
|
||||
_delete_match.bind(match_entry.match_id)
|
||||
)
|
||||
|
||||
func _on_match_list_entry_added(match_entry: Dictionary) -> void:
|
||||
push_warning("Client: Added Match List Entry...", match_entry)
|
||||
_create_match_entry(match_entry)
|
||||
|
||||
func _on_match_list_entry_removed(match_id: String) -> void:
|
||||
push_warning("Client: Removed Match List Entry...", match_id)
|
||||
|
||||
if active_match && (match_id == active_match.match_id):
|
||||
active_match = null
|
||||
match_create_vbox.visible = true
|
||||
|
||||
for match_entry in match_list.get_children():
|
||||
if not active_match:
|
||||
match_entry.join_bttn.visible = true
|
||||
|
||||
if not match_id == match_entry.match_id: continue
|
||||
match_entry.queue_free()
|
||||
|
||||
func _on_match_list_entry_load_match(match_entry: Dictionary, is_player_1: bool) -> void:
|
||||
push_warning(
|
||||
"Client: Loading Game Match...\nMatch Data: ", match_entry, "\nis_player_1: ", is_player_1
|
||||
)
|
||||
|
||||
Globals.multiplayer_data.set_multiplayer_active()
|
||||
Globals.game_data.set_game_mode(match_entry.type)
|
||||
Globals.game_data.set_player_id(is_player_1)
|
||||
Globals.game_state.set_game_scene("res://scenes/game.tscn")
|
||||
|
||||
func _create_match_entry(match_entry: Dictionary) -> void:
|
||||
var container = MATCH_ENTRY.instantiate()
|
||||
match_list.add_child(container)
|
||||
|
||||
container.name_lbl.text = match_entry.name
|
||||
container.type_lbl.text = match_entry.type
|
||||
container.match_id = match_entry.match_id
|
||||
|
||||
container.join_bttn.pressed.connect(
|
||||
_join_match.bind(match_entry.match_id)
|
||||
)
|
||||
|
||||
if active_match:
|
||||
container.join_bttn.visible = false
|
||||
|
||||
func _join_match(match_id: String) -> void:
|
||||
Globals.lobby_data.rpc_id(1, "match_list_join_entry", match_id)
|
||||
|
||||
func _delete_match(match_id: String) -> void:
|
||||
Globals.lobby_data.rpc_id(1, "match_list_remove_entry", match_id)
|
||||
1
scenes/screens/lobby_screen/lobby.gd.uid
Normal file
1
scenes/screens/lobby_screen/lobby.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dk7afnf7ol7dy
|
||||
28
scenes/screens/lobby_screen/lobby.tscn
Normal file
28
scenes/screens/lobby_screen/lobby.tscn
Normal file
@@ -0,0 +1,28 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://dkes5cdu45q6e"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dk7afnf7ol7dy" path="res://scenes/screens/lobby_screen/lobby.gd" id="1_hhiik"]
|
||||
[ext_resource type="PackedScene" uid="uid://dg7pgj6i5pk8p" path="res://scenes/ui_controls/lobby_screen/lobby_ui.tscn" id="2_lqt48"]
|
||||
[ext_resource type="Script" uid="uid://sihv0kwbcr33" path="res://scenes/screens/lobby_screen/lobby_rpc.gd" id="3_rurl6"]
|
||||
[ext_resource type="Script" uid="uid://ci57tiuqsx1jp" path="res://scripts/client_networking.gd" id="4_glu7g"]
|
||||
|
||||
[node name="lobby" type="Node"]
|
||||
script = ExtResource("1_hhiik")
|
||||
|
||||
[node name="ui" parent="." instance=ExtResource("2_lqt48")]
|
||||
|
||||
[node name="rpc_signals" type="Node" parent="."]
|
||||
script = ExtResource("3_rurl6")
|
||||
|
||||
[node name="client" type="Node" parent="."]
|
||||
script = ExtResource("4_glu7g")
|
||||
|
||||
[connection signal="pressed" from="ui/body/left_body/server_host_hbox/home_bttn" to="." method="_on_home_bttn_pressed"]
|
||||
[connection signal="pressed" from="ui/body/left_body/server_host_hbox/host_connect_bttn" to="." method="_on_host_connect_bttn_pressed"]
|
||||
[connection signal="pressed" from="ui/body/left_body/server_host_hbox/host_disconnect_bttn" to="." method="_on_host_disconnect_bttn_pressed"]
|
||||
[connection signal="pressed" from="ui/body/left_body/search_vbox/search_hbox/match_search_bttn" to="." method="_on_match_search_bttn_pressed"]
|
||||
[connection signal="pressed" from="ui/body/right_body/create_match_hbox/match_create_bttn" to="." method="_on_match_create_bttn_pressed"]
|
||||
[connection signal="pressed" from="ui/body/right_body/vbox/8ball" to="." method="_on_mode_bttn_pressed" flags=18]
|
||||
[connection signal="pressed" from="ui/body/right_body/vbox/9ball" to="." method="_on_mode_bttn_pressed" flags=18]
|
||||
[connection signal="pressed" from="ui/body/right_body/vbox/snooker" to="." method="_on_mode_bttn_pressed" flags=18]
|
||||
|
||||
[editable path="ui"]
|
||||
58
scenes/screens/lobby_screen/lobby_base.gd
Normal file
58
scenes/screens/lobby_screen/lobby_base.gd
Normal file
@@ -0,0 +1,58 @@
|
||||
class_name LobbyBase extends Node
|
||||
|
||||
|
||||
const MATCH_ENTRY = preload("res://scenes/screens/lobby_screen/match_entry.tscn")
|
||||
|
||||
@onready var host_address_input: LineEdit = $ui/body/left_body/server_host_hbox/host_address_input
|
||||
@onready var host_port_range: SpinBox = $ui/body/left_body/server_host_hbox/host_port_range
|
||||
@onready var host_connect_bttn: Button = $ui/body/left_body/server_host_hbox/host_connect_bttn
|
||||
@onready var host_disconnect_bttn: Button = $ui/body/left_body/server_host_hbox/host_disconnect_bttn
|
||||
|
||||
@onready var search_vbox: VBoxContainer = $ui/body/left_body/search_vbox
|
||||
@onready var match_search_input: LineEdit = $ui/body/left_body/search_vbox/search_hbox/match_search_input
|
||||
@onready var match_list: VBoxContainer = $ui/body/left_body/search_vbox/scroll_container/match_list
|
||||
|
||||
@onready var match_create_vbox: VBoxContainer = $ui/body/right_body
|
||||
@onready var new_match_name_input: LineEdit = $ui/body/right_body/create_match_hbox/new_match_name_input
|
||||
|
||||
@onready var rpc_signals: Node = $rpc_signals
|
||||
@onready var client: Node = $client
|
||||
|
||||
var active_mode: String = "snooker"
|
||||
var active_match: HBoxContainer = null
|
||||
|
||||
|
||||
func _on_home_bttn_pressed() -> void:
|
||||
Globals.game_state.set_game_scene(
|
||||
"res://scenes/screens/start_screen/start.tscn"
|
||||
)
|
||||
|
||||
func _on_host_connect_bttn_pressed() -> void:
|
||||
client.start_client(host_address_input.text, int(host_port_range.value))
|
||||
|
||||
func _on_host_disconnect_bttn_pressed() -> void:
|
||||
match_create_vbox.visible = false
|
||||
search_vbox.visible = false
|
||||
host_disconnect_bttn.visible = false
|
||||
host_connect_bttn.visible = true
|
||||
|
||||
for match_block in match_list.get_children():
|
||||
match_block.queue_free()
|
||||
|
||||
client.close_connection()
|
||||
|
||||
func _on_match_search_bttn_pressed() -> void:
|
||||
pass
|
||||
|
||||
func _on_match_create_bttn_pressed() -> void:
|
||||
if active_match: return
|
||||
|
||||
var match_entry: Dictionary = {
|
||||
"name": new_match_name_input.text,
|
||||
"type": active_mode
|
||||
}
|
||||
|
||||
Globals.lobby_data.rpc_id(1, "match_list_add_entry", match_entry)
|
||||
|
||||
func _on_mode_bttn_pressed(button: Button) -> void:
|
||||
active_mode = button.text.remove_chars("-").to_lower()
|
||||
1
scenes/screens/lobby_screen/lobby_base.gd.uid
Normal file
1
scenes/screens/lobby_screen/lobby_base.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://5tvhtoe6fdu1
|
||||
35
scenes/screens/lobby_screen/lobby_rpc.gd
Normal file
35
scenes/screens/lobby_screen/lobby_rpc.gd
Normal file
@@ -0,0 +1,35 @@
|
||||
extends Node
|
||||
|
||||
|
||||
signal match_list_entries(match_list: Array)
|
||||
signal match_list_entry_activated(match_id: String)
|
||||
signal match_list_entry_added(match_entry: Dictionary)
|
||||
signal match_list_entry_removed(match_id: String)
|
||||
signal match_list_entry_load_match(
|
||||
match_entry: Dictionary, is_player_1: bool
|
||||
)
|
||||
|
||||
|
||||
@rpc("authority", "call_local", "reliable")
|
||||
func match_list_add_entry(match_entry: Dictionary) -> void:
|
||||
push_warning("Client received new match entry...")
|
||||
match_list_entry_added.emit(match_entry)
|
||||
|
||||
@rpc("authority", "call_local", "reliable")
|
||||
func match_list_remove_entry(match_id: String) -> void:
|
||||
push_warning("Client received delete match entry...")
|
||||
match_list_entry_removed.emit(match_id)
|
||||
|
||||
@rpc("authority", "reliable")
|
||||
func receive_match_list(match_list: Array) -> void:
|
||||
push_warning("Client received match list...")
|
||||
match_list_entries.emit(match_list)
|
||||
|
||||
@rpc("authority", "reliable")
|
||||
func match_list_activate_entry(match_id: String) -> void:
|
||||
push_warning("Client set active match entry...")
|
||||
match_list_entry_activated.emit(match_id)
|
||||
|
||||
func load_game_scene(match_entry: Dictionary, is_player_1: bool) -> void:
|
||||
push_warning("Client load game scene...")
|
||||
match_list_entry_load_match.emit(match_entry, is_player_1)
|
||||
1
scenes/screens/lobby_screen/lobby_rpc.gd.uid
Normal file
1
scenes/screens/lobby_screen/lobby_rpc.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://sihv0kwbcr33
|
||||
8
scenes/screens/lobby_screen/match_entry.gd
Normal file
8
scenes/screens/lobby_screen/match_entry.gd
Normal file
@@ -0,0 +1,8 @@
|
||||
class_name MatchEntry extends HBoxContainer
|
||||
|
||||
|
||||
@onready var name_lbl: Label = $name_lbl
|
||||
@onready var type_lbl: Label = $type_lbl
|
||||
@onready var join_bttn: Button = $join_bttn
|
||||
|
||||
var match_id: String = ""
|
||||
1
scenes/screens/lobby_screen/match_entry.gd.uid
Normal file
1
scenes/screens/lobby_screen/match_entry.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ck663xy8rqumo
|
||||
23
scenes/screens/lobby_screen/match_entry.tscn
Normal file
23
scenes/screens/lobby_screen/match_entry.tscn
Normal file
@@ -0,0 +1,23 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://b5b18vkfe3caa"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ck663xy8rqumo" path="res://scenes/screens/lobby_screen/match_entry.gd" id="1_kw53p"]
|
||||
|
||||
[node name="match_entry" type="HBoxContainer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_kw53p")
|
||||
|
||||
[node name="name_lbl" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="type_lbl" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="join_bttn" type="Button" parent="."]
|
||||
layout_mode = 2
|
||||
text = "Join"
|
||||
15
scenes/screens/start_screen/start.gd
Normal file
15
scenes/screens/start_screen/start.gd
Normal file
@@ -0,0 +1,15 @@
|
||||
class_name StartMenu extends Node3D
|
||||
|
||||
|
||||
@onready var base_environment: Node3D = $base_environment
|
||||
@onready var animation_player: AnimationPlayer = $animation_player
|
||||
|
||||
|
||||
# NOTE: For future, look intio --> https://www.gotut.net/loading-screen-in-godot-4/
|
||||
# Sounds: https://www.pond5.com/
|
||||
func _ready() -> void:
|
||||
base_environment.game_music.stream = load("res://sounds/music/Blue Dot Sessions - 02 (Lemon and Melon).mp3")
|
||||
base_environment.game_music.stream.loop = true
|
||||
base_environment.game_music.play()
|
||||
|
||||
animation_player.play("rotation")
|
||||
1
scenes/screens/start_screen/start.gd.uid
Normal file
1
scenes/screens/start_screen/start.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cywa27h25s1j8
|
||||
66
scenes/screens/start_screen/start.tscn
Normal file
66
scenes/screens/start_screen/start.tscn
Normal file
@@ -0,0 +1,66 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://1uhmlnh88yq7"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cywa27h25s1j8" path="res://scenes/screens/start_screen/start.gd" id="1_mqdda"]
|
||||
[ext_resource type="PackedScene" uid="uid://djtq6hbp70kut" path="res://scenes/environments/base_environment.tscn" id="2_7nvb2"]
|
||||
[ext_resource type="PackedScene" uid="uid://2ib7f3y41pq4" path="res://assets/converted/full_pool_scene_original/scene.gltf" id="3_rfj27"]
|
||||
[ext_resource type="PackedScene" uid="uid://da0ok71rkjpx8" path="res://scenes/menus/start_menu/start_menu_controls.tscn" id="4_hk434"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_qell1"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("rotation_dolly:rotation")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 0, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_rxs04"]
|
||||
resource_name = "rotation"
|
||||
length = 60.0
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("rotation_dolly:rotation")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 60),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 0, 0), Vector3(0, 6.2831855, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_cn28k"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_qell1"),
|
||||
&"rotation": SubResource("Animation_rxs04")
|
||||
}
|
||||
|
||||
[node name="start_screen" type="Node3D"]
|
||||
script = ExtResource("1_mqdda")
|
||||
|
||||
[node name="base_environment" parent="." instance=ExtResource("2_7nvb2")]
|
||||
|
||||
[node name="meshes" type="Node3D" parent="."]
|
||||
|
||||
[node name="table" parent="meshes" instance=ExtResource("3_rfj27")]
|
||||
|
||||
[node name="rotation_dolly" type="Node3D" parent="."]
|
||||
|
||||
[node name="camera" type="Camera3D" parent="rotation_dolly"]
|
||||
transform = Transform3D(0.9995127, 0.012299462, -0.028690739, 0, 0.9191053, 0.39401212, 0.031215947, -0.39382014, 0.9186573, 0.020791333, 1.2903607, 1.9422052)
|
||||
current = true
|
||||
|
||||
[node name="start_menu_controls" parent="rotation_dolly/camera" instance=ExtResource("4_hk434")]
|
||||
|
||||
[node name="animation_player" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_cn28k")
|
||||
}
|
||||
Reference in New Issue
Block a user