Inital project
This commit is contained in:
58
3d_mp_base/scenes/ui/chat.gd
Normal file
58
3d_mp_base/scenes/ui/chat.gd
Normal file
@@ -0,0 +1,58 @@
|
||||
class_name Chat
|
||||
extends CanvasLayer
|
||||
|
||||
|
||||
@onready var chat_output: RichTextLabel = %ChatOutput
|
||||
@onready var chat_input: LineEdit = %ChatInput
|
||||
@onready var scroll_container: ScrollContainer = %ScrollContainer
|
||||
@onready var new_message_timer: Timer = %NewMessageTimer
|
||||
|
||||
var menu_open: bool = false
|
||||
|
||||
|
||||
func _ready():
|
||||
GameManager.chat_node = self
|
||||
new_message_timer.timeout.connect(_on_new_message_timer_timeout)
|
||||
|
||||
|
||||
func send_message(username: String, avatar_color: Color = Color.WEB_GRAY):
|
||||
if chat_input.text.is_empty(): return
|
||||
|
||||
if multiplayer.is_server():
|
||||
add_chat_message(username, chat_input.text, avatar_color)
|
||||
else:
|
||||
add_chat_message.rpc_id(1, username, chat_input.text, avatar_color)
|
||||
|
||||
chat_input.clear()
|
||||
|
||||
|
||||
@rpc("any_peer", "call_remote")
|
||||
func add_chat_message(username: String, text: String, avatar_color: Color = Color.WEB_GRAY):
|
||||
receive_chat_message.rpc(username, text, avatar_color)
|
||||
|
||||
|
||||
@rpc("authority", "call_local")
|
||||
func receive_chat_message(username: String, text: String, avatar_color: Color = Color.WEB_GRAY):
|
||||
var os_time = Time.get_time_dict_from_system()
|
||||
var formatted_os_time = str("%02d:%02d:%02d" % [os_time.hour, os_time.minute, os_time.second])
|
||||
var new_message = "[%s]: [color=%s]%s[/color]: %s\n" % [formatted_os_time, avatar_color.to_html(false), username, text]
|
||||
chat_output.append_text(new_message)
|
||||
new_message_timer.start()
|
||||
show()
|
||||
print("DEBUG: receive called on peer: ", multiplayer.get_unique_id(), " | frame: ", Engine.get_process_frames())
|
||||
|
||||
|
||||
func update_visiblity(set_chat_visible: bool, menu_open_init: bool):
|
||||
if set_chat_visible:
|
||||
show()
|
||||
chat_input.grab_focus()
|
||||
menu_open = menu_open_init
|
||||
elif !set_chat_visible:
|
||||
chat_input.release_focus()
|
||||
hide()
|
||||
menu_open = menu_open_init
|
||||
|
||||
|
||||
func _on_new_message_timer_timeout():
|
||||
if !menu_open:
|
||||
hide()
|
||||
1
3d_mp_base/scenes/ui/chat.gd.uid
Normal file
1
3d_mp_base/scenes/ui/chat.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://m4rcvxjd31mr
|
||||
67
3d_mp_base/scenes/ui/chat.tscn
Normal file
67
3d_mp_base/scenes/ui/chat.tscn
Normal file
@@ -0,0 +1,67 @@
|
||||
[gd_scene format=3 uid="uid://bg2q2emiroavd"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://m4rcvxjd31mr" path="res://scenes/ui/chat.gd" id="1_6bdm3"]
|
||||
|
||||
[node name="Chat" type="CanvasLayer" unique_id=1028379683]
|
||||
script = ExtResource("1_6bdm3")
|
||||
|
||||
[node name="Control" type="Control" parent="." unique_id=524383998]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 1
|
||||
|
||||
[node name="Panel" type="Panel" parent="Control" unique_id=284178139]
|
||||
custom_minimum_size = Vector2(300, 400)
|
||||
layout_mode = 1
|
||||
anchors_preset = 2
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -400.0
|
||||
offset_right = 300.0
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Control/Panel" unique_id=446822655]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
alignment = 2
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="Control/Panel/VBoxContainer" unique_id=1582116754]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="ChatOutput" type="RichTextLabel" parent="Control/Panel/VBoxContainer/ScrollContainer" unique_id=587198232]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/outline_size = 8
|
||||
theme_override_font_sizes/normal_font_size = 13
|
||||
theme_override_font_sizes/bold_font_size = 13
|
||||
theme_override_font_sizes/bold_italics_font_size = 13
|
||||
theme_override_font_sizes/italics_font_size = 13
|
||||
theme_override_font_sizes/mono_font_size = 13
|
||||
bbcode_enabled = true
|
||||
scroll_following = true
|
||||
|
||||
[node name="ChatInput" type="LineEdit" parent="Control/Panel/VBoxContainer" unique_id=1416488657]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 8
|
||||
placeholder_text = "Send message"
|
||||
max_length = 100
|
||||
keep_editing_on_text_submit = true
|
||||
caret_blink = true
|
||||
|
||||
[node name="NewMessageTimer" type="Timer" parent="." unique_id=1779987389]
|
||||
unique_name_in_owner = true
|
||||
wait_time = 5.0
|
||||
one_shot = true
|
||||
18
3d_mp_base/scenes/ui/loading_screen.gd
Normal file
18
3d_mp_base/scenes/ui/loading_screen.gd
Normal file
@@ -0,0 +1,18 @@
|
||||
class_name LoadingScreen
|
||||
extends CanvasLayer
|
||||
|
||||
@export var loading_icon: TextureRect
|
||||
@export var loading_label: Label
|
||||
@export var cancel_button: Button
|
||||
|
||||
signal cancel_pressed
|
||||
|
||||
func _ready() -> void:
|
||||
var offset := loading_icon.size / 2
|
||||
loading_icon.pivot_offset = offset
|
||||
|
||||
cancel_button.pressed.connect(func(): cancel_pressed.emit())
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
loading_icon.rotation_degrees += 2
|
||||
1
3d_mp_base/scenes/ui/loading_screen.gd.uid
Normal file
1
3d_mp_base/scenes/ui/loading_screen.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ddkeq7kl674rl
|
||||
54
3d_mp_base/scenes/ui/loading_screen.tscn
Normal file
54
3d_mp_base/scenes/ui/loading_screen.tscn
Normal file
@@ -0,0 +1,54 @@
|
||||
[gd_scene format=3 uid="uid://38t27mxycd35"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ddkeq7kl674rl" path="res://scenes/ui/loading_screen.gd" id="1_q4fso"]
|
||||
[ext_resource type="Texture2D" uid="uid://blpnie21uplx7" path="res://icon.svg" id="1_rqdcv"]
|
||||
|
||||
[node name="LoadingScreen" type="CanvasLayer" unique_id=1615444093 node_paths=PackedStringArray("loading_icon", "loading_label", "cancel_button")]
|
||||
script = ExtResource("1_q4fso")
|
||||
loading_icon = NodePath("Control/MarginContainer/LoadingIcon")
|
||||
loading_label = NodePath("Control/MarginContainer/LoadingLabel")
|
||||
cancel_button = NodePath("Control/MarginContainer/CancelButton")
|
||||
|
||||
[node name="Control" type="Control" parent="." unique_id=1464738685]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Control" unique_id=874650830]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 50
|
||||
theme_override_constants/margin_top = 50
|
||||
theme_override_constants/margin_right = 50
|
||||
theme_override_constants/margin_bottom = 50
|
||||
|
||||
[node name="LoadingIcon" type="TextureRect" parent="Control/MarginContainer" unique_id=6862137]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(50, 50)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
size_flags_vertical = 8
|
||||
texture = ExtResource("1_rqdcv")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="LoadingLabel" type="Label" parent="Control/MarginContainer" unique_id=1340572936]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 8
|
||||
text = "Joining..."
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="CancelButton" type="Button" parent="Control/MarginContainer" unique_id=1414424067]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
size_flags_vertical = 0
|
||||
text = "Cancel"
|
||||
151
3d_mp_base/scenes/ui/main_menu.gd
Normal file
151
3d_mp_base/scenes/ui/main_menu.gd
Normal file
@@ -0,0 +1,151 @@
|
||||
extends CanvasLayer
|
||||
|
||||
@onready var use_steam_check: CheckButton = %UseSteamCheck
|
||||
@onready var ip_edit: LineEdit = %IPEdit
|
||||
@onready var join_ip_button: Button = %JoinIPButton
|
||||
@onready var steam_host_button: Button = %SteamHostButton
|
||||
@onready var steam_lobby_id_edit: LineEdit = %SteamLobbyIDEdit
|
||||
@onready var join_steam_button: Button = %JoinSteamButton
|
||||
@onready var quit_button: Button = %QuitButton
|
||||
@onready var ip_host_button: Button = %IPHostButton
|
||||
@onready var steam_controls: VBoxContainer = %SteamControls
|
||||
@onready var e_net_controls: VBoxContainer = %ENetControls
|
||||
@onready var steam_avatar: TextureRect = %SteamAvatar
|
||||
@onready var steam_username_label: Label = %SteamUsernameLabel
|
||||
@onready var username_input: LineEdit = %UsernameInput
|
||||
@onready var ip_avatar_image: TextureButton = %IPAvatarImage
|
||||
|
||||
const TEST_LEVEL = preload("uid://tnw1q8a7ndio")
|
||||
const PLAYER = preload("uid://cq6ovfsdvnt40")
|
||||
|
||||
func _ready() -> void:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
|
||||
#if OS.has_feature("server"):
|
||||
#add_world()
|
||||
#NetworkManager.start_server()
|
||||
#hide()
|
||||
|
||||
use_steam_check.toggled.connect(_on_use_steam_toggled)
|
||||
|
||||
join_ip_button.pressed.connect(_on_ip_join_pressed)
|
||||
quit_button.pressed.connect(func(): get_tree().quit())
|
||||
ip_host_button.pressed.connect(_on_host_ip_pressed)
|
||||
username_input.text_changed.connect(_on_username_input_text_changed)
|
||||
ip_avatar_image.pressed.connect(_on_ip_avatar_clicked)
|
||||
|
||||
join_steam_button.pressed.connect(_on_join_steam_pressed)
|
||||
steam_host_button.pressed.connect(_on_host_steam_pressed)
|
||||
steam_lobby_id_edit.text_changed.connect(_on_lobby_text_changed)
|
||||
|
||||
Steam.join_requested.connect(_on_lobby_join_requested)
|
||||
|
||||
check_command_line()
|
||||
|
||||
func _on_use_steam_toggled(toggled_on: bool):
|
||||
if toggled_on:
|
||||
if !Steamworks.is_initalized:
|
||||
push_error("Steam not initalized, reverting to IP")
|
||||
steam_controls.hide()
|
||||
use_steam_check.button_pressed = false
|
||||
else:
|
||||
steam_controls.show()
|
||||
e_net_controls.hide()
|
||||
steam_username_label.text = Steamworks.steam_username
|
||||
steam_avatar.texture = Steamworks.steam_avatar
|
||||
else:
|
||||
e_net_controls.show()
|
||||
steam_controls.hide()
|
||||
|
||||
|
||||
func _on_ip_join_pressed():
|
||||
var avatar: ImageTexture = ImageTexture.create_from_image(ip_avatar_image.texture_normal.get_image())
|
||||
NetworkManager.join_server(ip_edit.text, username_input.text, avatar)
|
||||
add_world()
|
||||
hide()
|
||||
|
||||
|
||||
func _on_host_ip_pressed():
|
||||
var avatar: ImageTexture = ImageTexture.create_from_image(ip_avatar_image.texture_normal.get_image())
|
||||
NetworkManager.start_server(username_input.text, avatar)
|
||||
add_world()
|
||||
hide()
|
||||
|
||||
|
||||
func _on_host_steam_pressed():
|
||||
NetworkManager.start_steam_lobby()
|
||||
add_world()
|
||||
hide()
|
||||
|
||||
|
||||
func _on_join_steam_pressed():
|
||||
NetworkManager.join_steam_lobby(steam_lobby_id_edit.text.to_int())
|
||||
add_world()
|
||||
hide()
|
||||
|
||||
|
||||
func _on_lobby_join_requested(this_lobby_id: int, friend_id: int) -> void:
|
||||
NetworkManager.join_steam_lobby(this_lobby_id)
|
||||
add_world()
|
||||
hide()
|
||||
|
||||
|
||||
func add_world():
|
||||
var new_scene := TEST_LEVEL.instantiate()
|
||||
get_tree().current_scene.add_child.call_deferred(new_scene)
|
||||
|
||||
|
||||
func _on_lobby_text_changed(new_text: String):
|
||||
if new_text == "":
|
||||
join_steam_button.disabled = true
|
||||
else:
|
||||
join_steam_button.disabled = false
|
||||
|
||||
|
||||
func check_command_line() -> void:
|
||||
var these_arguments: Array = OS.get_cmdline_args()
|
||||
if these_arguments.size() > 0:
|
||||
if these_arguments[0] == "+connect_lobby":
|
||||
if int(these_arguments[1]) > 0:
|
||||
print("Command line lobby ID: %s" % these_arguments[1])
|
||||
NetworkManager.join_steam_lobby(these_arguments[1])
|
||||
add_world()
|
||||
hide()
|
||||
|
||||
|
||||
func _on_username_input_text_changed(new_text: String) -> void:
|
||||
if new_text == "":
|
||||
ip_host_button.hide()
|
||||
join_ip_button.hide()
|
||||
else:
|
||||
ip_host_button.show()
|
||||
join_ip_button.show()
|
||||
|
||||
|
||||
func _on_ip_avatar_clicked():
|
||||
var file_dialog := FileDialog.new()
|
||||
file_dialog.file_mode = FileDialog.FILE_MODE_OPEN_FILE
|
||||
file_dialog.access = FileDialog.ACCESS_FILESYSTEM
|
||||
file_dialog.filters = PackedStringArray([
|
||||
"*.png ; PNG Images",
|
||||
"*.jpg, *.jpeg ; JPEG Images",
|
||||
"*.bmp ; BMP Images"
|
||||
])
|
||||
|
||||
file_dialog.file_selected.connect(func(path: String):
|
||||
var img := Image.new()
|
||||
var err := img.load(path)
|
||||
|
||||
if err != OK:
|
||||
push_error("Failed to load image from file")
|
||||
return
|
||||
|
||||
img.resize(100, 100, Image.INTERPOLATE_LANCZOS)
|
||||
var texture := ImageTexture.create_from_image(img)
|
||||
ip_avatar_image.texture_normal = texture
|
||||
|
||||
file_dialog.queue_free()
|
||||
)
|
||||
|
||||
add_child(file_dialog)
|
||||
file_dialog.popup_centered()
|
||||
1
3d_mp_base/scenes/ui/main_menu.gd.uid
Normal file
1
3d_mp_base/scenes/ui/main_menu.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://crq0b0ygnfbjl
|
||||
165
3d_mp_base/scenes/ui/main_menu.tscn
Normal file
165
3d_mp_base/scenes/ui/main_menu.tscn
Normal file
@@ -0,0 +1,165 @@
|
||||
[gd_scene format=3 uid="uid://vrgbtswm2ko5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://crq0b0ygnfbjl" path="res://scenes/ui/main_menu.gd" id="1_sl1te"]
|
||||
[ext_resource type="Texture2D" uid="uid://blpnie21uplx7" path="res://icon.svg" id="2_fe2o3"]
|
||||
[ext_resource type="Texture2D" uid="uid://csljnn1ulbh7i" path="res://addons/kenney_prototype_textures/dark/texture_04.png" id="3_1g8jr"]
|
||||
|
||||
[node name="MainMenu" type="CanvasLayer" unique_id=1371882812]
|
||||
script = ExtResource("1_sl1te")
|
||||
|
||||
[node name="Control" type="Control" parent="." unique_id=1988941314]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Control" unique_id=1538311932]
|
||||
custom_minimum_size = Vector2(600, 300)
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -20.0
|
||||
offset_top = -20.0
|
||||
offset_right = 20.0
|
||||
offset_bottom = 20.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Control/PanelContainer" unique_id=1446206489]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 20
|
||||
theme_override_constants/margin_top = 20
|
||||
theme_override_constants/margin_right = 20
|
||||
theme_override_constants/margin_bottom = 20
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Control/PanelContainer/MarginContainer" unique_id=600731185]
|
||||
custom_minimum_size = Vector2(300, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="Control/PanelContainer/MarginContainer/VBoxContainer" unique_id=1127605886]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="Control/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer2" unique_id=1776570352]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 6
|
||||
text = "Multiplayer Template Game"
|
||||
|
||||
[node name="UseSteamCheck" type="CheckButton" parent="Control/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer2" unique_id=2050719522]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Use Steam"
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Control/PanelContainer/MarginContainer/VBoxContainer" unique_id=1028494634]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="SteamControls" type="VBoxContainer" parent="Control/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer" unique_id=614477215]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Control/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/SteamControls" unique_id=619438998]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="SteamAvatar" type="TextureRect" parent="Control/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/SteamControls/HBoxContainer" unique_id=1524328989]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(100, 100)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 6
|
||||
texture = ExtResource("2_fe2o3")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="SteamUsernameLabel" type="Label" parent="Control/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/SteamControls/HBoxContainer" unique_id=1636629417]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 6
|
||||
text = "Username"
|
||||
|
||||
[node name="SteamJoinHbox" type="HBoxContainer" parent="Control/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/SteamControls" unique_id=747576334]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="SteamLobbyIDEdit" type="LineEdit" parent="Control/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/SteamControls/SteamJoinHbox" unique_id=1021124488]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
placeholder_text = "Lobby ID"
|
||||
alignment = 1
|
||||
|
||||
[node name="JoinSteamButton" type="Button" parent="Control/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/SteamControls/SteamJoinHbox" unique_id=1137964974]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
disabled = true
|
||||
text = "Join"
|
||||
|
||||
[node name="SteamHostButton" type="Button" parent="Control/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/SteamControls" unique_id=574367772]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Host"
|
||||
|
||||
[node name="ENetControls" type="VBoxContainer" parent="Control/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer" unique_id=1909532057]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Control/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/ENetControls" unique_id=374121199]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 20
|
||||
|
||||
[node name="IPAvatarImage" type="TextureButton" parent="Control/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/ENetControls/HBoxContainer" unique_id=966792766]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(100, 100)
|
||||
layout_mode = 2
|
||||
texture_normal = ExtResource("3_1g8jr")
|
||||
ignore_texture_size = true
|
||||
stretch_mode = 0
|
||||
|
||||
[node name="UsernameInput" type="LineEdit" parent="Control/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/ENetControls/HBoxContainer" unique_id=53008613]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
text = "Username"
|
||||
placeholder_text = "Username"
|
||||
|
||||
[node name="IPHostButton" type="Button" parent="Control/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/ENetControls" unique_id=388231535]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Host"
|
||||
|
||||
[node name="IPJoinHBox" type="HBoxContainer" parent="Control/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/ENetControls" unique_id=1248428381]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="IPEdit" type="LineEdit" parent="Control/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/ENetControls/IPJoinHBox" unique_id=1604669433]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "127.0.0.1"
|
||||
placeholder_text = "IP Address"
|
||||
alignment = 1
|
||||
|
||||
[node name="JoinIPButton" type="Button" parent="Control/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/ENetControls/IPJoinHBox" unique_id=1995375905]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Join"
|
||||
|
||||
[node name="QuitButton" type="Button" parent="Control/PanelContainer/MarginContainer/VBoxContainer" unique_id=1924907920]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Quit"
|
||||
5
3d_mp_base/scenes/ui/player_list_item.gd
Normal file
5
3d_mp_base/scenes/ui/player_list_item.gd
Normal file
@@ -0,0 +1,5 @@
|
||||
class_name PlayerListItem
|
||||
extends HBoxContainer
|
||||
|
||||
@export var avatar: TextureRect
|
||||
@export var username: Label
|
||||
1
3d_mp_base/scenes/ui/player_list_item.gd.uid
Normal file
1
3d_mp_base/scenes/ui/player_list_item.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dh3xwj2voqo15
|
||||
22
3d_mp_base/scenes/ui/player_list_item.tscn
Normal file
22
3d_mp_base/scenes/ui/player_list_item.tscn
Normal file
@@ -0,0 +1,22 @@
|
||||
[gd_scene format=3 uid="uid://bv670qe133heb"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dh3xwj2voqo15" path="res://scenes/ui/player_list_item.gd" id="1_lm242"]
|
||||
[ext_resource type="Texture2D" uid="uid://blpnie21uplx7" path="res://icon.svg" id="1_scu6w"]
|
||||
|
||||
[node name="PlayerListItem" type="HBoxContainer" unique_id=775069241 node_paths=PackedStringArray("avatar", "username")]
|
||||
theme_override_constants/separation = 15
|
||||
script = ExtResource("1_lm242")
|
||||
avatar = NodePath("Avatar")
|
||||
username = NodePath("Username")
|
||||
|
||||
[node name="Avatar" type="TextureRect" parent="." unique_id=648912719]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(60, 60)
|
||||
layout_mode = 2
|
||||
texture = ExtResource("1_scu6w")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="Username" type="Label" parent="." unique_id=332583236]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Username"
|
||||
36
3d_mp_base/scenes/ui/player_menu.gd
Normal file
36
3d_mp_base/scenes/ui/player_menu.gd
Normal file
@@ -0,0 +1,36 @@
|
||||
extends CanvasLayer
|
||||
|
||||
const PLAYER_LIST_ITEM = preload("uid://bv670qe133heb")
|
||||
@onready var leave_button: Button = %LeaveButton
|
||||
@onready var player_list: VBoxContainer = %PlayerList
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
leave_button.pressed.connect(_on_leave_pressed)
|
||||
visibility_changed.connect(_on_visibility_changed)
|
||||
|
||||
|
||||
func _on_leave_pressed():
|
||||
NetworkManager.leave_server()
|
||||
|
||||
|
||||
func _on_visibility_changed():
|
||||
if visible:
|
||||
refresh_player_list()
|
||||
|
||||
|
||||
func refresh_player_list():
|
||||
for child in player_list.get_children():
|
||||
child.queue_free()
|
||||
|
||||
if NetworkManager.is_steam_lobby:
|
||||
for p in NetworkManager.player_list.values():
|
||||
var item: PlayerListItem = PLAYER_LIST_ITEM.instantiate()
|
||||
var player := p as Player
|
||||
|
||||
item.username.text = player.player_info.username
|
||||
|
||||
if player.player_info.avatar != null:
|
||||
item.avatar.texture = player.player_info.avatar
|
||||
|
||||
player_list.add_child(item)
|
||||
1
3d_mp_base/scenes/ui/player_menu.gd.uid
Normal file
1
3d_mp_base/scenes/ui/player_menu.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cnn532uwkyl2y
|
||||
50
3d_mp_base/scenes/ui/player_menu.tscn
Normal file
50
3d_mp_base/scenes/ui/player_menu.tscn
Normal file
@@ -0,0 +1,50 @@
|
||||
[gd_scene format=3 uid="uid://dg55eimlsqgp7"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cnn532uwkyl2y" path="res://scenes/ui/player_menu.gd" id="1_2rx5c"]
|
||||
|
||||
[node name="PlayerMenu" type="CanvasLayer" unique_id=1711189995]
|
||||
script = ExtResource("1_2rx5c")
|
||||
|
||||
[node name="Control" type="Control" parent="." unique_id=1118512792]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Control" unique_id=1851737141]
|
||||
layout_mode = 1
|
||||
anchors_preset = 9
|
||||
anchor_bottom = 1.0
|
||||
offset_right = 540.0
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Control/PanelContainer" unique_id=1940417879]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 20
|
||||
theme_override_constants/margin_top = 20
|
||||
theme_override_constants/margin_right = 20
|
||||
theme_override_constants/margin_bottom = 20
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Control/PanelContainer/MarginContainer" unique_id=1499285095]
|
||||
custom_minimum_size = Vector2(500, 0)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 50
|
||||
alignment = 1
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="Control/PanelContainer/MarginContainer/VBoxContainer" unique_id=670435526]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="PlayerList" type="VBoxContainer" parent="Control/PanelContainer/MarginContainer/VBoxContainer/ScrollContainer" unique_id=1713092068]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="LeaveButton" type="Button" parent="Control/PanelContainer/MarginContainer/VBoxContainer" unique_id=1877596038]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 8
|
||||
text = "Leave"
|
||||
Reference in New Issue
Block a user