feat: implement networked match HUD with real-time scoreboard and killfeed systems

This commit is contained in:
DottsGit
2026-06-06 13:49:12 -04:00
parent aefed46daf
commit 168bd8f1ce
11 changed files with 501 additions and 13 deletions
+43 -12
View File
@@ -217,11 +217,25 @@ func _ready() -> void:
hl_left.add_child(hl_title)
var hl_cards = HBoxContainer.new()
hl_cards.add_theme_constant_override("separation", 30)
hl_cards.add_theme_constant_override("separation", 20)
hl_left.add_child(hl_cards)
_build_level_card(hl_cards, "Dust 2", "res://scenes/dust2_level/dust2_level.tscn", d2_gradient, true)
_build_level_card(hl_cards, "Test Level", "res://scenes/test_level/test_level.tscn", tl_gradient, true)
_build_level_card(hl_cards, "Dust 2", "res://scenes/dust2_level/dust2_level.tscn", d2_gradient, true, Vector2(200, 250))
_build_level_card(hl_cards, "Test Level", "res://scenes/test_level/test_level.tscn", tl_gradient, true, Vector2(200, 250))
var mode_label = Label.new()
mode_label.text = "Gamemode"
mode_label.add_theme_font_size_override("font_size", 32)
hl_left.add_child(mode_label)
var _gamemode_opt = OptionButton.new()
_gamemode_opt.add_theme_font_size_override("font_size", 24)
_gamemode_opt.add_item("Deathmatch", 0)
_gamemode_opt.item_selected.connect(func(index: int):
if get_node_or_null("/root/NetworkManager"):
get_node("/root/NetworkManager").current_gamemode = _gamemode_opt.get_item_text(index)
)
hl_left.add_child(_gamemode_opt)
var hl_spacer = Control.new()
hl_spacer.size_flags_vertical = Control.SIZE_EXPAND_FILL
@@ -251,21 +265,21 @@ func _ready() -> void:
_host_lobby_players_list.add_theme_font_size_override("font_size", 24)
hl_right.add_child(_host_lobby_players_list)
func _build_level_card(parent: Container, title: String, scene_path: String, gradient: Gradient, is_multiplayer: bool = false) -> void:
func _build_level_card(parent: Container, title: String, scene_path: String, gradient: Gradient, is_multiplayer: bool = false, card_size: Vector2 = Vector2(300, 400)) -> void:
var btn = TextureButton.new()
btn.custom_minimum_size = Vector2(300, 400)
btn.custom_minimum_size = card_size
var tex = GradientTexture2D.new()
tex.gradient = gradient
tex.width = 300
tex.height = 400
tex.width = int(card_size.x)
tex.height = int(card_size.y)
tex.fill_to = Vector2(1, 1)
btn.texture_normal = tex
var tex_hover = GradientTexture2D.new()
tex_hover.gradient = gradient
tex_hover.width = 300
tex_hover.height = 400
tex_hover.width = int(card_size.x)
tex_hover.height = int(card_size.y)
tex_hover.fill_to = Vector2(1, 1)
tex_hover.use_hdr = true # Slight bright effect on hover
btn.texture_hover = tex_hover
@@ -294,7 +308,12 @@ func _build_level_card(parent: Container, title: String, scene_path: String, gra
if is_multiplayer:
btn.pressed.connect(func(): get_node("/root/NetworkManager").rpc_load_level.rpc(scene_path))
else:
btn.pressed.connect(func(): get_tree().change_scene_to_file(scene_path))
btn.pressed.connect(func():
var nm = get_node_or_null("/root/NetworkManager")
if nm:
nm.start_singleplayer_match("Deathmatch")
get_tree().change_scene_to_file(scene_path)
)
parent.add_child(btn)
@@ -332,6 +351,8 @@ func _on_host_pressed() -> void:
if not nm.player_connected.is_connected(_on_network_player_connected):
nm.player_connected.connect(_on_network_player_connected)
nm.player_disconnected.connect(_on_network_player_disconnected)
if not nm.stats_updated.is_connected(_update_lobby_players):
nm.stats_updated.connect(_update_lobby_players)
func _on_direct_connect_pressed() -> void:
_multiplayer_panel.hide()
@@ -355,6 +376,8 @@ func _on_lobby_back_pressed() -> void:
if nm.player_connected.is_connected(_on_network_player_connected):
nm.player_connected.disconnect(_on_network_player_connected)
nm.player_disconnected.disconnect(_on_network_player_disconnected)
if nm.stats_updated.is_connected(_update_lobby_players):
nm.stats_updated.disconnect(_update_lobby_players)
func _on_network_player_connected(_id: int) -> void:
_update_lobby_players()
@@ -367,11 +390,19 @@ func _update_lobby_players() -> void:
_host_lobby_players_list.clear()
var nm = get_node("/root/NetworkManager")
var host_name = SettingsManager.username
var host_ping = 0
if nm.player_stats.has(1): host_ping = nm.player_stats[1].get("ping", 0)
for pid in nm.connected_players:
var p_ping = 0
if nm.player_stats.has(pid): p_ping = nm.player_stats[pid].get("ping", 0)
if pid == 1:
_host_lobby_players_list.add_item(host_name + " (Host)")
_host_lobby_players_list.add_item("%s (Host) - %sms" % [host_name, host_ping])
else:
_host_lobby_players_list.add_item("Player " + str(pid))
var p_name = "Player " + str(pid)
if nm.player_stats.has(pid): p_name = nm.player_stats[pid].get("username", p_name)
_host_lobby_players_list.add_item("%s - %sms" % [p_name, p_ping])
func _on_loadouts_pressed() -> void:
if has_node("/root/PauseMenu"):