Refactor to fit game-shell structure; externalized lobby client code
This commit is contained in:
16
README.md
16
README.md
@@ -1,23 +1,7 @@
|
||||
# Running the Lobby Server
|
||||
|
||||
> **Note:** The lobby server looks for a local script named `game.sh`.
|
||||
|
||||
[Lobby Server](https://code.itdominator.com/itdominator/lobby-server)
|
||||
|
||||
## From the Editor
|
||||
|
||||
**Debug → Customize Run Instance**
|
||||
|
||||
```text
|
||||
--name_billiards server game_port_range 5000:5010
|
||||
```
|
||||
|
||||
## From the Command Line
|
||||
|
||||
```bash
|
||||
./lobby_server.sh --name_billiards server game_port_range 5000:5010
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Connecting Clients
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://04nv87epssf4"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dbca7qndk7coq" path="res://billiards.gd" id="1_bhs8v"]
|
||||
[ext_resource type="PackedScene" uid="uid://dy51wny4x53f4" path="res://scripts/data/data_bridge.tscn" id="1_xa5nf"]
|
||||
[ext_resource type="PackedScene" uid="uid://cbvv2msu13vr2" path="res://scripts/controllers/networking/game_client.tscn" id="3_hkpkv"]
|
||||
[ext_resource type="PackedScene" uid="uid://bss61m8hfvab3" path="res://scripts/controllers/networking/game_server.tscn" id="4_cni66"]
|
||||
|
||||
[node name="billiards" type="Node"]
|
||||
script = ExtResource("1_bhs8v")
|
||||
|
||||
[node name="data_bridge" parent="." instance=ExtResource("1_xa5nf")]
|
||||
|
||||
[node name="game_client" parent="." instance=ExtResource("3_hkpkv")]
|
||||
|
||||
[node name="game_server" parent="." instance=ExtResource("4_cni66")]
|
||||
|
||||
[node name="scene" type="Node" parent="."]
|
||||
@@ -1,15 +1,16 @@
|
||||
[preset.0]
|
||||
|
||||
name="Web"
|
||||
platform="Web"
|
||||
runnable=true
|
||||
advanced_options=false
|
||||
name="Game"
|
||||
platform="Linux"
|
||||
runnable=false
|
||||
advanced_options=true
|
||||
dedicated_server=false
|
||||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
export_filter="exclude"
|
||||
export_files=PackedStringArray("res://import_manager.gd", "res://sounds/music/Lobo Loco - 04 (Mountain Bells22).mp3", "res://sounds/music/Lobo Loco - 02 (Summer Rain).mp3", "res://sounds/music/Blue Dot Sessions - 02 (Lemon and Melon).mp3", "res://sounds/effects/ball-hits.wav", "res://sounds/effects/ball-hits-2.wav", "res://assets/converted/individuals/white_ball/white_ball.gltf", "res://assets/references/pool-vs-snooker-cue-ball-and-weight.png", "res://assets/converted/full_pool_scene_original/textures/billiard_ball_mat_baseColor.png", "res://assets/converted/full_pool_scene_original/textures/billiard_ball_mat_metallicRoughness.png", "res://assets/converted/full_pool_scene_original/textures/cue_mat_baseColor.png", "res://assets/converted/full_pool_scene_original/textures/cue_mat_metallicRoughness.png", "res://assets/converted/full_pool_scene_original/textures/cue_mat_normal.png", "res://assets/converted/full_pool_scene_original/textures/light_mat_baseColor.png", "res://assets/converted/full_pool_scene_original/textures/light_mat_emissive.png", "res://assets/converted/full_pool_scene_original/textures/light_mat_metallicRoughness.png", "res://assets/converted/full_pool_scene_original/textures/pool_table_mat_baseColor.png", "res://assets/converted/full_pool_scene_original/textures/pool_table_mat_metallicRoughness.png", "res://assets/converted/full_pool_scene_original/textures/pool_table_mat_normal.png", "res://assets/converted/full_pool_scene_original/textures/pool_table_mat_transmission.png", "res://assets/converted/full_pool_scene_original/scene.gltf", "res://assets/converted/individuals/balls/balls.gltf", "res://assets/converted/individuals/balls/balls_billiard_ball_mat_baseColor.png", "res://assets/converted/individuals/balls/balls_billiard_ball_mat_metallicRoughness.png", "res://assets/converted/individuals/balls/billiard_ball_mat_baseColor.png", "res://assets/converted/individuals/balls/billiard_ball_mat_metallicRoughness.png", "res://assets/converted/individuals/pool_cue_blue_tip/cue_mat_baseColor.png", "res://assets/converted/individuals/pool_cue_blue_tip/cue_mat_metallicRoughness.png", "res://assets/converted/individuals/pool_cue_blue_tip/cue_mat_normal.png", "res://assets/converted/individuals/pool_cue_blue_tip/pool_cue_blue_tip.gltf", "res://assets/converted/individuals/pool_cue_white_tip/cue_mat_baseColor.png", "res://assets/converted/individuals/pool_cue_white_tip/cue_mat_metallicRoughness.png", "res://assets/converted/individuals/pool_cue_white_tip/cue_mat_normal.png", "res://assets/converted/individuals/pool_cue_white_tip/pool_cue_white_tip.gltf", "res://assets/converted/individuals/pool_table/pooltable.gltf", "res://assets/converted/individuals/pool_table/pool_table_mat_baseColor.png", "res://assets/converted/individuals/pool_table/pool_table_mat_metallicRoughness.png", "res://assets/converted/individuals/pool_table/pool_table_mat_normal.png", "res://assets/converted/individuals/pool_table/pool_table_mat_transmission.png", "res://assets/converted/individuals/white_ball/billiard_ball_mat_baseColor.png", "res://assets/converted/individuals/white_ball/billiard_ball_mat_metallicRoughness.png")
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="../../builds/web/billiards/index.html"
|
||||
exclude_filter=".godot/*"
|
||||
export_path="../../builds/desktop/shell-test/modules/game.x86_64"
|
||||
patches=PackedStringArray()
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
@@ -22,40 +23,38 @@ script_export_mode=2
|
||||
|
||||
custom_template/debug=""
|
||||
custom_template/release=""
|
||||
variant/extensions_support=false
|
||||
variant/thread_support=false
|
||||
vram_texture_compression/for_desktop=true
|
||||
vram_texture_compression/for_mobile=true
|
||||
html/export_icon=true
|
||||
html/custom_html_shell=""
|
||||
html/head_include="Billiards"
|
||||
html/canvas_resize_policy=2
|
||||
html/focus_canvas_on_start=true
|
||||
html/experimental_virtual_keyboard=false
|
||||
progressive_web_app/enabled=false
|
||||
progressive_web_app/ensure_cross_origin_isolation_headers=true
|
||||
progressive_web_app/offline_page=""
|
||||
progressive_web_app/display=1
|
||||
progressive_web_app/orientation=0
|
||||
progressive_web_app/icon_144x144=""
|
||||
progressive_web_app/icon_180x180=""
|
||||
progressive_web_app/icon_512x512=""
|
||||
progressive_web_app/background_color=Color(0, 0, 0, 1)
|
||||
threads/emscripten_pool_size=8
|
||||
threads/godot_pool_size=4
|
||||
debug/export_console_wrapper=0
|
||||
binary_format/embed_pck=false
|
||||
texture_format/s3tc_bptc=true
|
||||
texture_format/etc2_astc=false
|
||||
shader_baker/enabled=false
|
||||
binary_format/architecture="x86_64"
|
||||
ssh_remote_deploy/enabled=false
|
||||
ssh_remote_deploy/host="user@host_ip"
|
||||
ssh_remote_deploy/port="22"
|
||||
ssh_remote_deploy/extra_args_ssh=""
|
||||
ssh_remote_deploy/extra_args_scp=""
|
||||
ssh_remote_deploy/run_script="#!/usr/bin/env bash
|
||||
export DISPLAY=:0
|
||||
unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
|
||||
\"{temp_dir}/{exe_name}\" {cmd_args}"
|
||||
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
|
||||
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
|
||||
rm -rf \"{temp_dir}\""
|
||||
|
||||
[preset.1]
|
||||
|
||||
name="Linux"
|
||||
name="Assets"
|
||||
platform="Linux"
|
||||
runnable=true
|
||||
runnable=false
|
||||
advanced_options=true
|
||||
dedicated_server=false
|
||||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
export_filter="resources"
|
||||
export_files=PackedStringArray("res://assets/converted/full_pool_scene_original/textures/billiard_ball_mat_baseColor.png", "res://assets/converted/full_pool_scene_original/textures/billiard_ball_mat_metallicRoughness.png", "res://assets/converted/full_pool_scene_original/textures/cue_mat_baseColor.png", "res://assets/converted/full_pool_scene_original/textures/cue_mat_metallicRoughness.png", "res://assets/converted/full_pool_scene_original/textures/cue_mat_normal.png", "res://assets/converted/full_pool_scene_original/textures/light_mat_baseColor.png", "res://assets/converted/full_pool_scene_original/textures/light_mat_emissive.png", "res://assets/converted/full_pool_scene_original/textures/light_mat_metallicRoughness.png", "res://assets/converted/full_pool_scene_original/textures/pool_table_mat_baseColor.png", "res://assets/converted/full_pool_scene_original/textures/pool_table_mat_metallicRoughness.png", "res://assets/converted/full_pool_scene_original/textures/pool_table_mat_normal.png", "res://assets/converted/full_pool_scene_original/textures/pool_table_mat_transmission.png", "res://assets/converted/full_pool_scene_original/scene.gltf", "res://assets/converted/individuals/balls/balls.gltf", "res://assets/converted/individuals/balls/balls_billiard_ball_mat_baseColor.png", "res://assets/converted/individuals/balls/balls_billiard_ball_mat_metallicRoughness.png", "res://assets/converted/individuals/balls/billiard_ball_mat_baseColor.png", "res://assets/converted/individuals/balls/billiard_ball_mat_metallicRoughness.png", "res://assets/converted/individuals/pool_cue_blue_tip/cue_mat_baseColor.png", "res://assets/converted/individuals/pool_cue_blue_tip/cue_mat_metallicRoughness.png", "res://assets/converted/individuals/pool_cue_blue_tip/cue_mat_normal.png", "res://assets/converted/individuals/pool_cue_blue_tip/pool_cue_blue_tip.gltf", "res://assets/converted/individuals/pool_cue_white_tip/cue_mat_baseColor.png", "res://assets/converted/individuals/pool_cue_white_tip/cue_mat_metallicRoughness.png", "res://assets/converted/individuals/pool_cue_white_tip/cue_mat_normal.png", "res://assets/converted/individuals/pool_cue_white_tip/pool_cue_white_tip.gltf", "res://assets/converted/individuals/pool_table/pooltable.gltf", "res://assets/converted/individuals/pool_table/pool_table_mat_baseColor.png", "res://assets/converted/individuals/pool_table/pool_table_mat_metallicRoughness.png", "res://assets/converted/individuals/pool_table/pool_table_mat_normal.png", "res://assets/converted/individuals/pool_table/pool_table_mat_transmission.png", "res://assets/converted/individuals/white_ball/billiard_ball_mat_baseColor.png", "res://assets/converted/individuals/white_ball/billiard_ball_mat_metallicRoughness.png", "res://assets/converted/individuals/white_ball/white_ball.gltf", "res://sounds/effects/ball-hits-2.wav", "res://sounds/effects/ball-hits.wav", "res://sounds/music/Blue Dot Sessions - 02 (Lemon and Melon).mp3", "res://sounds/music/Lobo Loco - 02 (Summer Rain).mp3", "res://sounds/music/Lobo Loco - 04 (Mountain Bells22).mp3")
|
||||
include_filter=""
|
||||
exclude_filter=".godot/*"
|
||||
export_path="../../builds/desktop/billiards/billiards.x86_64"
|
||||
exclude_filter=".godot/*,globals/*,splash.png"
|
||||
export_path="../../builds/desktop/shell-test/modules/assets.x86_64"
|
||||
patches=PackedStringArray()
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
@@ -86,71 +85,3 @@ unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
|
||||
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
|
||||
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
|
||||
rm -rf \"{temp_dir}\""
|
||||
|
||||
[preset.2]
|
||||
|
||||
name="Windows Desktop"
|
||||
platform="Windows Desktop"
|
||||
runnable=true
|
||||
advanced_options=false
|
||||
dedicated_server=false
|
||||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="../../builds/desktop/billiards/billiards-win.exe"
|
||||
patches=PackedStringArray()
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
seed=0
|
||||
encrypt_pck=false
|
||||
encrypt_directory=false
|
||||
script_export_mode=2
|
||||
|
||||
[preset.2.options]
|
||||
|
||||
custom_template/debug=""
|
||||
custom_template/release=""
|
||||
debug/export_console_wrapper=1
|
||||
binary_format/embed_pck=false
|
||||
texture_format/s3tc_bptc=true
|
||||
texture_format/etc2_astc=false
|
||||
shader_baker/enabled=false
|
||||
binary_format/architecture="x86_64"
|
||||
codesign/enable=false
|
||||
codesign/timestamp=true
|
||||
codesign/timestamp_server_url=""
|
||||
codesign/digest_algorithm=1
|
||||
codesign/description=""
|
||||
codesign/custom_options=PackedStringArray()
|
||||
application/modify_resources=true
|
||||
application/icon=""
|
||||
application/console_wrapper_icon=""
|
||||
application/icon_interpolation=4
|
||||
application/file_version=""
|
||||
application/product_version=""
|
||||
application/company_name=""
|
||||
application/product_name=""
|
||||
application/file_description=""
|
||||
application/copyright=""
|
||||
application/trademarks=""
|
||||
application/export_angle=0
|
||||
application/export_d3d12=0
|
||||
application/d3d12_agility_sdk_multiarch=true
|
||||
ssh_remote_deploy/enabled=false
|
||||
ssh_remote_deploy/host="user@host_ip"
|
||||
ssh_remote_deploy/port="22"
|
||||
ssh_remote_deploy/extra_args_ssh=""
|
||||
ssh_remote_deploy/extra_args_scp=""
|
||||
ssh_remote_deploy/run_script="Expand-Archive -LiteralPath '{temp_dir}\\{archive_name}' -DestinationPath '{temp_dir}'
|
||||
$action = New-ScheduledTaskAction -Execute '{temp_dir}\\{exe_name}' -Argument '{cmd_args}'
|
||||
$trigger = New-ScheduledTaskTrigger -Once -At 00:00
|
||||
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
|
||||
$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings
|
||||
Register-ScheduledTask godot_remote_debug -InputObject $task -Force:$true
|
||||
Start-ScheduledTask -TaskName godot_remote_debug
|
||||
while (Get-ScheduledTask -TaskName godot_remote_debug | ? State -eq running) { Start-Sleep -Milliseconds 100 }
|
||||
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue"
|
||||
ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue
|
||||
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue
|
||||
Remove-Item -Recurse -Force '{temp_dir}'"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class_name Billiards extends Node
|
||||
class_name GameCore extends Node
|
||||
|
||||
|
||||
@onready var game_server: GameServer = $game_server
|
||||
@@ -28,6 +28,11 @@ class_name Billiards extends Node
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_load_scene()
|
||||
_parse_args()
|
||||
|
||||
|
||||
func _load_scene() -> void:
|
||||
add_child(Globals.multiplayer_data.multiplayer_synchronizer)
|
||||
move_child(Globals.multiplayer_data.multiplayer_synchronizer, 0)
|
||||
|
||||
@@ -35,8 +40,6 @@ func _ready() -> void:
|
||||
"res://scenes/screens/start_screen/start.tscn"
|
||||
)
|
||||
|
||||
_parse_args()
|
||||
|
||||
func _parse_args() -> void:
|
||||
for arg in OS.get_cmdline_user_args():
|
||||
if "server_" in arg:
|
||||
17
game_core.tscn
Normal file
17
game_core.tscn
Normal file
@@ -0,0 +1,17 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://04nv87epssf4"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dbca7qndk7coq" path="res://game_core.gd" id="1_re4t7"]
|
||||
[ext_resource type="PackedScene" uid="uid://dy51wny4x53f4" path="res://scripts/data/data_bridge.tscn" id="2_7xtl2"]
|
||||
[ext_resource type="PackedScene" uid="uid://cbvv2msu13vr2" path="res://scripts/controllers/networking/game_client.tscn" id="3_8p78u"]
|
||||
[ext_resource type="PackedScene" uid="uid://bss61m8hfvab3" path="res://scripts/controllers/networking/game_server.tscn" id="4_2t0sw"]
|
||||
|
||||
[node name="game_core" type="Node"]
|
||||
script = ExtResource("1_re4t7")
|
||||
|
||||
[node name="data_bridge" parent="." instance=ExtResource("2_7xtl2")]
|
||||
|
||||
[node name="game_client" parent="." instance=ExtResource("3_8p78u")]
|
||||
|
||||
[node name="game_server" parent="." instance=ExtResource("4_2t0sw")]
|
||||
|
||||
[node name="scene" type="Node" parent="."]
|
||||
@@ -5,3 +5,13 @@ var game_data: GameData
|
||||
var game_state: GameState
|
||||
var lobby_data: LobbyData
|
||||
var multiplayer_data: MultiplayerData
|
||||
|
||||
|
||||
func cache_invalidate_load_resource(target: String) -> Resource:
|
||||
# NOTE: Deep replace version b/c we don't want to use an autoloads
|
||||
# that does this replasce before any nodes actually load.
|
||||
ResourceLoader.load(target, "", ResourceLoader.CACHE_MODE_REPLACE_DEEP)
|
||||
|
||||
# NOTE: Let prior call propigate naturally. (Unsure when...)
|
||||
# Enforce new script/node from pck called here.
|
||||
return ResourceLoader.load(target, "", ResourceLoader.CACHE_MODE_IGNORE_DEEP)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@tool class_name BilliardsImporter extends EditorScenePostImport
|
||||
@tool class_name ImportManager extends EditorScenePostImport
|
||||
|
||||
|
||||
func _post_import(scene: Node) -> Object:
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
class_name Lobby extends LobbyBase
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
setup_signals()
|
||||
|
||||
host_address_input.grab_focus()
|
||||
|
||||
func _exit_tree() -> void:
|
||||
# TODO: Maybe no longer needed...
|
||||
if Globals.multiplayer_data.is_multiplayer_active: return
|
||||
client._do_wait_close_connection()
|
||||
|
||||
|
||||
func setup_signals() -> void:
|
||||
MessageBus.subscribe("lobby_wait_for_connection", client._do_wait_for_connection)
|
||||
MessageBus.subscribe("lobby_close_connection", client._do_wait_close_connection)
|
||||
|
||||
MessageBus.subscribe("receive_match_list", _on_receive_match_list)
|
||||
MessageBus.subscribe("match_list_activate_entry", _on_match_list_entry_activated)
|
||||
MessageBus.subscribe("match_list_add_entry", _on_match_list_entry_added)
|
||||
MessageBus.subscribe("match_list_remove_entry", _on_match_list_entry_removed)
|
||||
MessageBus.subscribe("match_list_entry_load_match", _on_match_list_entry_load_match)
|
||||
|
||||
|
||||
func _server_host_started() -> void:
|
||||
host_connect_bttn.visible = false
|
||||
|
||||
# NOTE: 'matches_list' can be empty; so long as we get the call from the
|
||||
# server we know we are connected and thus hide respective UI elements.
|
||||
func _on_receive_match_list(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)
|
||||
|
||||
client.lobby_fully_connected = true
|
||||
new_match_name_input.grab_focus()
|
||||
|
||||
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_search_input.visible = false
|
||||
match_search_bttn.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
|
||||
match_search_input.visible = true
|
||||
match_search_bttn.visible = false
|
||||
new_match_name_input.grab_focus()
|
||||
|
||||
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:
|
||||
MessageBus.emit_request.rpc_id(1, "match_list_join_entry", match_id)
|
||||
|
||||
func _delete_match(match_id: String) -> void:
|
||||
MessageBus.emit_request.rpc_id(1, "match_list_remove_entry", match_id)
|
||||
@@ -1 +0,0 @@
|
||||
uid://dk7afnf7ol7dy
|
||||
@@ -1,42 +0,0 @@
|
||||
[gd_scene load_steps=4 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/lobby/lobby_ui.tscn" id="2_lqt48"]
|
||||
[ext_resource type="Script" uid="uid://dv7j35h2ngiq7" path="res://scenes/screens/lobby_screen/lobby_client.gd" id="4_glu7g"]
|
||||
|
||||
[node name="lobby" type="Node"]
|
||||
script = ExtResource("1_hhiik")
|
||||
|
||||
[node name="lobby_ui" parent="." instance=ExtResource("2_lqt48")]
|
||||
|
||||
[node name="host_address_input" parent="lobby_ui/body/left_body/server_host_hbox" index="1"]
|
||||
context_menu_enabled = false
|
||||
select_all_on_focus = true
|
||||
|
||||
[node name="host_port_range" parent="lobby_ui/body/left_body/server_host_hbox" index="2"]
|
||||
select_all_on_focus = true
|
||||
|
||||
[node name="match_search_input" parent="lobby_ui/body/left_body/search_vbox/search_hbox" index="0"]
|
||||
context_menu_enabled = false
|
||||
|
||||
[node name="right_body" parent="lobby_ui/body" index="1"]
|
||||
visible = false
|
||||
|
||||
[node name="new_match_name_input" parent="lobby_ui/body/right_body/create_match_hbox" index="0"]
|
||||
context_menu_enabled = false
|
||||
select_all_on_focus = true
|
||||
|
||||
[node name="client" type="Node" parent="."]
|
||||
script = ExtResource("4_glu7g")
|
||||
|
||||
[connection signal="pressed" from="lobby_ui/body/left_body/server_host_hbox/home_bttn" to="." method="_on_home_bttn_pressed"]
|
||||
[connection signal="pressed" from="lobby_ui/body/left_body/server_host_hbox/host_connect_bttn" to="." method="_on_host_connect_bttn_pressed"]
|
||||
[connection signal="pressed" from="lobby_ui/body/left_body/server_host_hbox/host_disconnect_bttn" to="." method="_on_host_disconnect_bttn_pressed"]
|
||||
[connection signal="pressed" from="lobby_ui/body/left_body/search_vbox/search_hbox/match_search_bttn" to="." method="_on_match_search_bttn_pressed"]
|
||||
[connection signal="pressed" from="lobby_ui/body/right_body/create_match_hbox/match_create_bttn" to="." method="_on_match_create_bttn_pressed"]
|
||||
[connection signal="pressed" from="lobby_ui/body/right_body/vbox/8ball" to="." method="_on_mode_bttn_pressed" flags=18]
|
||||
[connection signal="pressed" from="lobby_ui/body/right_body/vbox/9ball" to="." method="_on_mode_bttn_pressed" flags=18]
|
||||
[connection signal="pressed" from="lobby_ui/body/right_body/vbox/snooker" to="." method="_on_mode_bttn_pressed" flags=18]
|
||||
[connection signal="pressed" from="lobby_ui/body/right_body/vbox/freeball" to="." method="_on_mode_bttn_pressed" flags=18]
|
||||
|
||||
[editable path="lobby_ui"]
|
||||
@@ -1,62 +0,0 @@
|
||||
class_name LobbyBase extends Node
|
||||
|
||||
|
||||
const MATCH_ENTRY = preload("res://scenes/screens/lobby_screen/match_entry.tscn")
|
||||
|
||||
@onready var host_address_input: LineEdit = $lobby_ui/body/left_body/server_host_hbox/host_address_input
|
||||
@onready var host_port_range: SpinBox = $lobby_ui/body/left_body/server_host_hbox/host_port_range
|
||||
@onready var host_connect_bttn: Button = $lobby_ui/body/left_body/server_host_hbox/host_connect_bttn
|
||||
@onready var host_disconnect_bttn: Button = $lobby_ui/body/left_body/server_host_hbox/host_disconnect_bttn
|
||||
|
||||
@onready var search_vbox: VBoxContainer = $lobby_ui/body/left_body/search_vbox
|
||||
@onready var match_search_input: LineEdit = $lobby_ui/body/left_body/search_vbox/search_hbox/match_search_input
|
||||
@onready var match_search_bttn: Button = $lobby_ui/body/left_body/search_vbox/search_hbox/match_search_bttn
|
||||
@onready var match_list: VBoxContainer = $lobby_ui/body/left_body/search_vbox/scroll_container/match_list
|
||||
|
||||
@onready var match_create_vbox: VBoxContainer = $lobby_ui/body/right_body
|
||||
@onready var new_match_name_input: LineEdit = $lobby_ui/body/right_body/create_match_hbox/new_match_name_input
|
||||
|
||||
@onready var client: LobbyClient = $client
|
||||
|
||||
var active_mode: String = "freeball"
|
||||
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:
|
||||
Globals.game_data.game_address = host_address_input.text
|
||||
Globals.game_data.game_port = int(host_port_range.value)
|
||||
client.start_client(
|
||||
Globals.game_data.game_address, Globals.game_data.game_port
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
MessageBus.emit_request.rpc("match_list_add_entry", match_entry)
|
||||
|
||||
func _on_mode_bttn_pressed(button: Button) -> void:
|
||||
active_mode = button.name.to_lower()
|
||||
@@ -1 +0,0 @@
|
||||
uid://5tvhtoe6fdu1
|
||||
@@ -1,35 +0,0 @@
|
||||
class_name LobbyClient extends ClientNetworking
|
||||
|
||||
|
||||
var lobby_fully_connected: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
pass
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
pass
|
||||
|
||||
func _do_wait_for_connection() -> void:
|
||||
_wait_for_connection()
|
||||
|
||||
while not lobby_fully_connected:
|
||||
await get_tree().process_frame
|
||||
|
||||
func _do_wait_close_connection():
|
||||
_wait_close_connection()
|
||||
|
||||
lobby_fully_connected = false
|
||||
|
||||
|
||||
func client_connected_to_server() -> void:
|
||||
push_warning("Connected to server!")
|
||||
|
||||
|
||||
func client_disconnected_from_server() -> void:
|
||||
push_warning("Disconnected from, server...")
|
||||
|
||||
func client_connection_failed_to_server() -> void:
|
||||
push_warning("Connection failed!")
|
||||
|
||||
unset_client()
|
||||
@@ -1 +0,0 @@
|
||||
uid://dv7j35h2ngiq7
|
||||
@@ -1,8 +0,0 @@
|
||||
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 +0,0 @@
|
||||
uid://ck663xy8rqumo
|
||||
@@ -1,23 +0,0 @@
|
||||
[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"
|
||||
@@ -1,164 +0,0 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dg7pgj6i5pk8p"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_e03fk"]
|
||||
content_margin_left = 4.0
|
||||
content_margin_top = 4.0
|
||||
content_margin_right = 4.0
|
||||
content_margin_bottom = 4.0
|
||||
bg_color = Color(0.22352941, 0.47058824, 0.23137255, 1)
|
||||
corner_radius_top_left = 3
|
||||
corner_radius_top_right = 3
|
||||
corner_radius_bottom_right = 3
|
||||
corner_radius_bottom_left = 3
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_lqt48"]
|
||||
content_margin_left = 4.0
|
||||
content_margin_top = 4.0
|
||||
content_margin_right = 4.0
|
||||
content_margin_bottom = 4.0
|
||||
bg_color = Color(0.84705883, 0.21960784, 0.24705882, 1)
|
||||
corner_radius_top_left = 3
|
||||
corner_radius_top_right = 3
|
||||
corner_radius_bottom_right = 3
|
||||
corner_radius_bottom_left = 3
|
||||
|
||||
[node name="lobby_ui" type="MarginContainer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 16.0
|
||||
offset_top = 23.0
|
||||
offset_right = -19.0
|
||||
offset_bottom = -27.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="body" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="left_body" type="VBoxContainer" parent="body"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="server_host_hbox" type="HBoxContainer" parent="body/left_body"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="home_bttn" type="Button" parent="body/left_body/server_host_hbox"]
|
||||
layout_mode = 2
|
||||
text = "Home"
|
||||
|
||||
[node name="host_address_input" type="LineEdit" parent="body/left_body/server_host_hbox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "127.0.0.1"
|
||||
placeholder_text = "Server Address: (Eg. 0.0.0.0)"
|
||||
alignment = 1
|
||||
max_length = 15
|
||||
emoji_menu_enabled = false
|
||||
clear_button_enabled = true
|
||||
caret_blink = true
|
||||
|
||||
[node name="host_port_range" type="SpinBox" parent="body/left_body/server_host_hbox"]
|
||||
layout_mode = 2
|
||||
min_value = 1.0
|
||||
max_value = 65535.0
|
||||
page = 10.0
|
||||
value = 8080.0
|
||||
rounded = true
|
||||
alignment = 1
|
||||
|
||||
[node name="host_connect_bttn" type="Button" parent="body/left_body/server_host_hbox"]
|
||||
layout_mode = 2
|
||||
mouse_default_cursor_shape = 2
|
||||
theme_override_styles/normal = SubResource("StyleBoxFlat_e03fk")
|
||||
text = "Connect"
|
||||
|
||||
[node name="host_disconnect_bttn" type="Button" parent="body/left_body/server_host_hbox"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
mouse_default_cursor_shape = 2
|
||||
theme_override_styles/normal = SubResource("StyleBoxFlat_lqt48")
|
||||
text = "Disconnect"
|
||||
|
||||
[node name="search_vbox" type="VBoxContainer" parent="body/left_body"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="search_hbox" type="HBoxContainer" parent="body/left_body/search_vbox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="match_search_input" type="LineEdit" parent="body/left_body/search_vbox/search_hbox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
placeholder_text = "Search Match List... "
|
||||
max_length = 12
|
||||
emoji_menu_enabled = false
|
||||
clear_button_enabled = true
|
||||
caret_blink = true
|
||||
|
||||
[node name="match_search_bttn" type="Button" parent="body/left_body/search_vbox/search_hbox"]
|
||||
layout_mode = 2
|
||||
mouse_default_cursor_shape = 2
|
||||
text = "Search"
|
||||
|
||||
[node name="scroll_container" type="ScrollContainer" parent="body/left_body/search_vbox"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="match_list" type="VBoxContainer" parent="body/left_body/search_vbox/scroll_container"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="right_body" type="VBoxContainer" parent="body"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="create_match_hbox" type="HBoxContainer" parent="body/right_body"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="new_match_name_input" type="LineEdit" parent="body/right_body/create_match_hbox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
placeholder_text = "New Match Name..."
|
||||
max_length = 12
|
||||
emoji_menu_enabled = false
|
||||
clear_button_enabled = true
|
||||
|
||||
[node name="match_create_bttn" type="Button" parent="body/right_body/create_match_hbox"]
|
||||
layout_mode = 2
|
||||
mouse_default_cursor_shape = 2
|
||||
text = "Create"
|
||||
|
||||
[node name="vbox" type="VBoxContainer" parent="body/right_body"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
alignment = 1
|
||||
|
||||
[node name="8ball" type="Button" parent="body/right_body/vbox"]
|
||||
layout_mode = 2
|
||||
mouse_default_cursor_shape = 2
|
||||
disabled = true
|
||||
text = "8-Ball"
|
||||
|
||||
[node name="9ball" type="Button" parent="body/right_body/vbox"]
|
||||
layout_mode = 2
|
||||
mouse_default_cursor_shape = 2
|
||||
disabled = true
|
||||
text = "9-Ball"
|
||||
|
||||
[node name="snooker" type="Button" parent="body/right_body/vbox"]
|
||||
layout_mode = 2
|
||||
mouse_default_cursor_shape = 2
|
||||
disabled = true
|
||||
text = "Snooker"
|
||||
|
||||
[node name="freeball" type="Button" parent="body/right_body/vbox"]
|
||||
layout_mode = 2
|
||||
mouse_default_cursor_shape = 2
|
||||
text = "Free Ball"
|
||||
@@ -54,6 +54,10 @@ func close_connection() -> void:
|
||||
|
||||
func unset_client() -> void:
|
||||
if not peer: return
|
||||
if not multiplayer:
|
||||
peer.close()
|
||||
peer = null
|
||||
return
|
||||
|
||||
multiplayer.connected_to_server.disconnect(client_connected_to_server)
|
||||
multiplayer.connection_failed.disconnect(client_connection_failed_to_server)
|
||||
|
||||
@@ -18,13 +18,19 @@ func _init() -> void:
|
||||
|
||||
func load_game_scene(scene_str: String) -> void:
|
||||
var scene = load(scene_str).instantiate()
|
||||
var target = get_tree().root.get_node("billiards/scene")
|
||||
var target = get_tree().root.get_node_or_null("shell/scene")
|
||||
|
||||
if not target:
|
||||
target = get_tree().root.get_node("game_core/scene")
|
||||
|
||||
target.add_child(scene)
|
||||
|
||||
func set_game_scene(scene_str: String) -> void:
|
||||
var scene = load(scene_str).instantiate()
|
||||
var target = get_tree().root.get_node("billiards/scene")
|
||||
var target = get_tree().root.get_node_or_null("shell/scene")
|
||||
|
||||
if not target:
|
||||
target = get_tree().root.get_node("game_core/scene")
|
||||
|
||||
if "game" in scene_str:
|
||||
scene.name = "game"
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
class_name LobbyData extends Node
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
Globals.lobby_data = self
|
||||
|
||||
|
||||
@rpc("authority", "reliable")
|
||||
func connect_to_game() -> void:
|
||||
# NOTE: Leave the lobby
|
||||
MessageBus.emit_local("lobby_close_connection", null)
|
||||
|
||||
# NOTE: Join target game server
|
||||
MessageBus.emit_local(
|
||||
"game_start_client",
|
||||
[
|
||||
Globals.game_data.game_address,
|
||||
Globals.game_data.game_port
|
||||
],
|
||||
true
|
||||
)
|
||||
|
||||
@rpc("authority", "reliable")
|
||||
func go_back_to_match_screen() -> void:
|
||||
if multiplayer.is_server(): return
|
||||
|
||||
push_warning("Client peer disconnected...")
|
||||
|
||||
Globals.game_state.set_game_scene(
|
||||
"res://scenes/screens/lobby_screen/lobby.tscn"
|
||||
)
|
||||
@@ -1 +0,0 @@
|
||||
uid://6sfwe1hwgf0g
|
||||
@@ -11,7 +11,7 @@ func _init() -> void:
|
||||
Globals.multiplayer_data = self
|
||||
multiplayer_synchronizer.name = "multiplayer_synchronizer"
|
||||
multiplayer_synchronizer.replication_config = synchronizer_config
|
||||
multiplayer_synchronizer.root_path = "/root/billiards"
|
||||
multiplayer_synchronizer.root_path = "/root/shell"
|
||||
|
||||
@rpc("authority", "call_local", "reliable")
|
||||
func set_multiplayer_active() -> void:
|
||||
@@ -33,7 +33,7 @@ func reset() -> void:
|
||||
is_multiplayer_active = true
|
||||
multiplayer_synchronizer.name = "multiplayer_synchronizer"
|
||||
multiplayer_synchronizer.replication_config = synchronizer_config
|
||||
multiplayer_synchronizer.root_path = "/root/billiards"
|
||||
multiplayer_synchronizer.root_path = "/root/game_core"
|
||||
|
||||
func init_match() -> void:
|
||||
var match_entry = Dictionary()
|
||||
|
||||
Reference in New Issue
Block a user