push project up
This commit is contained in:
42
scenes/screens/lobby_screen/lobby.gd
Normal file
42
scenes/screens/lobby_screen/lobby.gd
Normal file
@@ -0,0 +1,42 @@
|
||||
class_name Lobby extends LobbyBase
|
||||
|
||||
|
||||
@onready var rpc_signals: Node = $rpc_signals
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Globals.lobby_data.lobby_ui = self
|
||||
setup_signals()
|
||||
|
||||
func _exit_tree() -> void:
|
||||
if server.peer:
|
||||
server.close_connection()
|
||||
|
||||
func setup_signals() -> void:
|
||||
rpc_signals.server_host_started.connect(_server_host_started)
|
||||
rpc_signals.match_list_entry_added.connect(_on_match_list_entry_added)
|
||||
rpc_signals.match_list_entry_removed.connect(_on_match_list_entry_removed)
|
||||
|
||||
func _server_host_started() -> void:
|
||||
host_start_bttn.visible = false
|
||||
host_stop_bttn.visible = true
|
||||
|
||||
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)
|
||||
|
||||
for match_entry in match_list.get_children():
|
||||
if not match_id == match_entry.match_id: continue
|
||||
match_entry.queue_free()
|
||||
|
||||
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
|
||||
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
|
||||
34
scenes/screens/lobby_screen/lobby.tscn
Normal file
34
scenes/screens/lobby_screen/lobby.tscn
Normal file
@@ -0,0 +1,34 @@
|
||||
[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://rb6av5eg4u0" path="res://scenes/ui_controls/lobby_screen/lobby_ui.tscn" id="2_lqt48"]
|
||||
[ext_resource type="Script" uid="uid://6sfwe1hwgf0g" path="res://scenes/screens/lobby_screen/lobby_rpc.gd" id="3_rurl6"]
|
||||
[ext_resource type="Script" uid="uid://bvqtgf3vbsoj4" path="res://scripts/server_networking.gd" id="4_glu7g"]
|
||||
|
||||
[node name="lobby_screen" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_hhiik")
|
||||
|
||||
[node name="ui" parent="." instance=ExtResource("2_lqt48")]
|
||||
layout_mode = 1
|
||||
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="rpc_signals" type="Node" parent="."]
|
||||
script = ExtResource("3_rurl6")
|
||||
|
||||
[node name="server" type="Node" parent="."]
|
||||
script = ExtResource("4_glu7g")
|
||||
|
||||
[connection signal="pressed" from="ui/body/left_body/server_host_hbox/host_start_bttn" to="." method="_on_host_start_bttn_pressed"]
|
||||
[connection signal="pressed" from="ui/body/left_body/server_host_hbox/host_stop_bttn" to="." method="_on_host_stop_bttn_pressed"]
|
||||
[connection signal="button_up" from="ui/body/left_body/search_vbox/search_hbox/match_search_bttn" to="." method="_on_match_search_bttn_button_up"]
|
||||
|
||||
[editable path="ui"]
|
||||
39
scenes/screens/lobby_screen/lobby_base.gd
Normal file
39
scenes/screens/lobby_screen/lobby_base.gd
Normal file
@@ -0,0 +1,39 @@
|
||||
class_name LobbyBase extends Control
|
||||
|
||||
|
||||
const MATCH_ENTRY = preload("res://scenes/screens/lobby_screen/match_entry.tscn")
|
||||
|
||||
@onready var host_start_bttn: Button = $ui/body/left_body/server_host_hbox/host_start_bttn
|
||||
@onready var host_stop_bttn: Button = $ui/body/left_body/server_host_hbox/host_stop_bttn
|
||||
@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 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 server: Node = $server
|
||||
|
||||
|
||||
|
||||
func _on_home_bttn_pressed() -> void:
|
||||
Globals.game_state.set_game_scene(
|
||||
"res://scenes/screens/start_screen/start.tscn"
|
||||
)
|
||||
|
||||
func _on_host_start_bttn_pressed() -> void:
|
||||
server.start_server(host_address_input.text, int(host_port_range.value))
|
||||
|
||||
func _on_host_stop_bttn_pressed() -> void:
|
||||
if not server.peer: return
|
||||
|
||||
server.close_connection()
|
||||
|
||||
host_start_bttn.visible = true
|
||||
host_stop_bttn.visible = false
|
||||
|
||||
func _on_search_bttn_pressed() -> void:
|
||||
pass
|
||||
|
||||
func _on_match_search_bttn_button_up() -> void:
|
||||
pass
|
||||
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
|
||||
29
scenes/screens/lobby_screen/lobby_rpc.gd
Normal file
29
scenes/screens/lobby_screen/lobby_rpc.gd
Normal file
@@ -0,0 +1,29 @@
|
||||
extends Node
|
||||
|
||||
|
||||
@warning_ignore_start("unused_signal")
|
||||
signal server_host_started()
|
||||
signal match_list_entry_added(match_entry: Dictionary)
|
||||
signal match_list_entry_removed(match_id: String)
|
||||
@warning_ignore_restore("unused_signal")
|
||||
|
||||
|
||||
@rpc("authority", "call_local", "reliable")
|
||||
func match_list_add_entry(match_entry: Dictionary) -> void:
|
||||
push_warning("Received new match entry...")
|
||||
|
||||
emit_signal("match_list_entry_added", match_entry)
|
||||
|
||||
@rpc("authority", "call_local", "reliable")
|
||||
func match_list_remove_entry(match_id: String) -> void:
|
||||
push_warning("Received delete match entry...")
|
||||
|
||||
emit_signal("match_list_entry_removed", match_id)
|
||||
|
||||
@rpc("authority", "reliable")
|
||||
func receive_match_list(_match_list: Array) -> void:
|
||||
pass
|
||||
|
||||
@rpc("authority", "reliable")
|
||||
func match_list_activate_entry(_match_id: String) -> void:
|
||||
pass
|
||||
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://6sfwe1hwgf0g
|
||||
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 view_bttn: Button = $view_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="view_bttn" type="Button" parent="."]
|
||||
layout_mode = 2
|
||||
text = "Join"
|
||||
Reference in New Issue
Block a user