mirror of
https://github.com/RPG-Research/bcirpg.git
synced 2024-04-16 14:23:01 +00:00
Merge branch 'Andrew'
This commit is contained in:
commit
c9b4e38def
@ -0,0 +1,18 @@
|
|||||||
|
#BUT_CHANGESCENE:
|
||||||
|
# Generic template script allowing GUI linking of scenes by button press.
|
||||||
|
|
||||||
|
tool
|
||||||
|
extends Button
|
||||||
|
|
||||||
|
#Creates param usable in the UI; and the params next to export make it string and file browser
|
||||||
|
export(String, FILE) var next_scene_path: = ""
|
||||||
|
|
||||||
|
var tempToggle = 0
|
||||||
|
|
||||||
|
func _on_But_NewGame_button_up():
|
||||||
|
get_tree().change_scene(next_scene_path)
|
||||||
|
|
||||||
|
|
||||||
|
func _get_configuration_warning() -> String:
|
||||||
|
return "next_scene_path must be set for this button to work" if next_scene_path == "" else ""
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
|
||||||
func instance_node(node: Object, parent: Object) -> Object:
|
func _instance_node(node: Object, parent: Object) -> Object:
|
||||||
var node_instance = node.instance()
|
var node_instance = node.instance()
|
||||||
parent.add_child(node_instance)
|
parent.add_child(node_instance)
|
||||||
return node_instance
|
return node_instance
|
||||||
|
@ -5,8 +5,12 @@ const MAX_CLIENTS = 6
|
|||||||
|
|
||||||
var server = null
|
var server = null
|
||||||
var client = null
|
var client = null
|
||||||
|
var player_counter = 1
|
||||||
|
var player = load("res://Player.tscn")
|
||||||
|
|
||||||
var ip_address = ""
|
var ip_address = ""
|
||||||
|
var room_name = ""
|
||||||
|
var room_password = ""
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
ip_address = IP.get_local_addresses()[3]
|
ip_address = IP.get_local_addresses()[3]
|
||||||
@ -33,3 +37,17 @@ func _connected_to_server() -> void:
|
|||||||
|
|
||||||
func _server_disconnected() -> void:
|
func _server_disconnected() -> void:
|
||||||
print("Disconnected from the server")
|
print("Disconnected from the server")
|
||||||
|
|
||||||
|
func _set_server_info(name, password) -> void:
|
||||||
|
room_name = name
|
||||||
|
room_password = password
|
||||||
|
|
||||||
|
func _instance_player(id, name) -> void:
|
||||||
|
var player_instance = Global._instance_node(player, Players)
|
||||||
|
player_instance.name = str(id)
|
||||||
|
player_instance._set_name(name)
|
||||||
|
#Using player_counter to determine the positioning of the player's name on the screen
|
||||||
|
#So that they aren't all overlapping
|
||||||
|
player_instance._set_name_position(player_counter)
|
||||||
|
player_instance.set_network_master(id)
|
||||||
|
player_counter += 1
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
[gd_scene load_steps=2 format=2]
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Network_Setup.gd" type="Script" id=1]
|
[ext_resource path="res://But_ChangeScene.gd" type="Script" id=2]
|
||||||
|
|
||||||
[node name="Network_Setup" type="Control"]
|
[node name="Network_Setup" type="Control"]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
script = ExtResource( 1 )
|
|
||||||
|
|
||||||
[node name="Multiplayer_Configure" type="Control" parent="."]
|
[node name="Multiplayer_Configure" type="Control" parent="."]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
@ -21,6 +20,8 @@ margin_top = 21.0
|
|||||||
margin_right = 125.0
|
margin_right = 125.0
|
||||||
margin_bottom = 121.0
|
margin_bottom = 121.0
|
||||||
text = "Create Server"
|
text = "Create Server"
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
next_scene_path = "res://Room_Creation.tscn"
|
||||||
|
|
||||||
[node name="Join_Server" type="Button" parent="Multiplayer_Configure"]
|
[node name="Join_Server" type="Button" parent="Multiplayer_Configure"]
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
@ -32,8 +33,11 @@ margin_top = -129.0
|
|||||||
margin_right = 125.0
|
margin_right = 125.0
|
||||||
margin_bottom = -29.0
|
margin_bottom = -29.0
|
||||||
text = "Join Server"
|
text = "Join Server"
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
next_scene_path = "res://Room_Join.tscn"
|
||||||
|
|
||||||
[node name="Server_IP_Address" type="LineEdit" parent="Multiplayer_Configure"]
|
[node name="Server_IP_Address" type="LineEdit" parent="Multiplayer_Configure"]
|
||||||
|
visible = false
|
||||||
margin_left = 389.0
|
margin_left = 389.0
|
||||||
margin_top = 82.0
|
margin_top = 82.0
|
||||||
margin_right = 639.0
|
margin_right = 639.0
|
||||||
@ -54,5 +58,5 @@ margin_bottom = -26.0
|
|||||||
align = 1
|
align = 1
|
||||||
valign = 1
|
valign = 1
|
||||||
|
|
||||||
[connection signal="pressed" from="Multiplayer_Configure/Create_Server" to="." method="_on_Create_Server_pressed"]
|
[connection signal="button_up" from="Multiplayer_Configure/Create_Server" to="Multiplayer_Configure/Create_Server" method="_on_But_NewGame_button_up"]
|
||||||
[connection signal="pressed" from="Multiplayer_Configure/Join_Server" to="." method="_on_Join_Server_pressed"]
|
[connection signal="button_up" from="Multiplayer_Configure/Join_Server" to="Multiplayer_Configure/Join_Server" method="_on_But_NewGame_button_up"]
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
extends Control
|
||||||
|
|
||||||
|
|
||||||
|
var playerCounter = 1
|
||||||
|
var player = load("res://Player.tscn")
|
||||||
|
|
||||||
|
onready var multiplayer_config_ui = $Multiplayer_Configure
|
||||||
|
#onready var server_ip_address = $Multiplayer_Configure/Server_IP_Address
|
||||||
|
onready var device_ip_address = $CanvasLayer/Device_IP_Address
|
||||||
|
onready var player_name = $Multiplayer_Configure/Player_Name
|
||||||
|
onready var room_name = $Multiplayer_Configure/Room_Name
|
||||||
|
onready var room_password = $Multiplayer_Configure/Room_Password
|
||||||
|
onready var room_ui = $Room_UI
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
get_tree().connect("network_peer_connected", self, "_player_connected")
|
||||||
|
get_tree().connect("network_peer_disconnected", self, "_player_disconnected")
|
||||||
|
get_tree().connect("connected_to_server", self, "_connected_to_server")
|
||||||
|
|
||||||
|
device_ip_address.text = Network.ip_address
|
||||||
|
|
||||||
|
func _player_connected(id) -> void:
|
||||||
|
print("Player " + str(id) + "connected")
|
||||||
|
Network._instance_player(id, "New Player")
|
||||||
|
|
||||||
|
func _player_disconnected(id) -> void:
|
||||||
|
print("Player " + str(id) + "disconnected")
|
||||||
|
|
||||||
|
if Players.has_node(str(id)):
|
||||||
|
Players.get_node(str(id)).queue_free()
|
||||||
|
|
||||||
|
func _on_Create_Server_pressed():
|
||||||
|
multiplayer_config_ui.hide()
|
||||||
|
Network._create_server()
|
||||||
|
Network._instance_player(get_tree().get_network_unique_id(), player_name.text)
|
||||||
|
Network._set_server_info(room_name.text, room_password.text)
|
||||||
|
$Room_UI/Room_Name.text = room_name.text
|
||||||
|
room_ui.show()
|
||||||
|
|
||||||
|
#func _on_Join_Server_pressed():
|
||||||
|
# if server_ip_address.text != "":
|
||||||
|
# multiplayer_config_ui.hide()
|
||||||
|
# Network.ip_address = server_ip_address.text
|
||||||
|
# Network._join_server()
|
||||||
|
|
||||||
|
func _connected_to_server() -> void:
|
||||||
|
yield(get_tree().create_timer(0.1), "timeout")
|
||||||
|
Network._instance_player(get_tree().get_network_unique_id(), player_name.text)
|
||||||
|
|
||||||
|
|
@ -0,0 +1,91 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Room_Creation.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://But_ChangeScene.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[node name="Room_Creation" type="Control"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Back" type="Button" parent="."]
|
||||||
|
margin_left = 312.0
|
||||||
|
margin_top = 419.0
|
||||||
|
margin_right = 474.0
|
||||||
|
margin_bottom = 493.0
|
||||||
|
text = "Back"
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
next_scene_path = "res://Network_Setup.tscn"
|
||||||
|
|
||||||
|
[node name="Multiplayer_Configure" type="Control" parent="."]
|
||||||
|
margin_right = 40.0
|
||||||
|
margin_bottom = 40.0
|
||||||
|
|
||||||
|
[node name="Create_Server" type="Button" parent="Multiplayer_Configure"]
|
||||||
|
margin_left = 592.0
|
||||||
|
margin_top = 419.0
|
||||||
|
margin_right = 754.0
|
||||||
|
margin_bottom = 493.0
|
||||||
|
text = "Create"
|
||||||
|
|
||||||
|
[node name="Room_Name" type="LineEdit" parent="Multiplayer_Configure"]
|
||||||
|
margin_left = 452.0
|
||||||
|
margin_top = 250.0
|
||||||
|
margin_right = 619.0
|
||||||
|
margin_bottom = 274.0
|
||||||
|
text = "Room Name"
|
||||||
|
align = 1
|
||||||
|
|
||||||
|
[node name="Room_Password" type="LineEdit" parent="Multiplayer_Configure"]
|
||||||
|
margin_left = 452.0
|
||||||
|
margin_top = 315.0
|
||||||
|
margin_right = 619.0
|
||||||
|
margin_bottom = 339.0
|
||||||
|
text = "Room Password"
|
||||||
|
align = 1
|
||||||
|
|
||||||
|
[node name="Player_Name" type="LineEdit" parent="Multiplayer_Configure"]
|
||||||
|
margin_left = 451.0
|
||||||
|
margin_top = 188.0
|
||||||
|
margin_right = 618.0
|
||||||
|
margin_bottom = 212.0
|
||||||
|
text = "Player Name"
|
||||||
|
align = 1
|
||||||
|
|
||||||
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
|
[node name="Device_IP_Address" type="Label" parent="CanvasLayer"]
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
margin_left = -1.0
|
||||||
|
margin_top = -76.0
|
||||||
|
margin_right = -1.0
|
||||||
|
margin_bottom = -26.0
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
|
||||||
|
[node name="Room_UI" type="Control" parent="."]
|
||||||
|
visible = false
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
|
||||||
|
[node name="Room_Name" type="Label" parent="Room_UI"]
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
margin_left = -80.5
|
||||||
|
margin_right = 80.5
|
||||||
|
margin_bottom = 14.0
|
||||||
|
align = 1
|
||||||
|
|
||||||
|
[node name="Players" type="Label" parent="Room_UI"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
margin_top = -225.0
|
||||||
|
margin_bottom = -225.0
|
||||||
|
text = "Players:"
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
|
||||||
|
[connection signal="button_up" from="Back" to="Back" method="_on_But_NewGame_button_up"]
|
||||||
|
[connection signal="pressed" from="Multiplayer_Configure/Create_Server" to="." method="_on_Create_Server_pressed"]
|
@ -0,0 +1,13 @@
|
|||||||
|
extends Control
|
||||||
|
|
||||||
|
onready var multiplayer_config_ui = $Multiplayer_Configure
|
||||||
|
onready var server_ip_address = $Multiplayer_Configure/Server_IP_Address
|
||||||
|
onready var room_password = $Multiplayer_Configure/Room_Password
|
||||||
|
onready var player_name = $Multiplayer_Configure/Player_Name
|
||||||
|
|
||||||
|
func _on_Join_Server_pressed():
|
||||||
|
if server_ip_address.text != "":
|
||||||
|
multiplayer_config_ui.hide()
|
||||||
|
Network.ip_address = server_ip_address.text
|
||||||
|
Network._join_server()
|
||||||
|
Network._instance_player(get_tree().get_network_unique_id(), player_name.text)
|
@ -0,0 +1,60 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Room_Join.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://But_ChangeScene.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[node name="Room_Join" type="Control"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Multiplayer_Configure" type="Control" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
|
||||||
|
[node name="Server_IP_Address" type="LineEdit" parent="Multiplayer_Configure"]
|
||||||
|
margin_left = 386.0
|
||||||
|
margin_top = 236.0
|
||||||
|
margin_right = 636.0
|
||||||
|
margin_bottom = 286.0
|
||||||
|
text = "Enter Room IP"
|
||||||
|
align = 1
|
||||||
|
|
||||||
|
[node name="Join_Server" type="Button" parent="Multiplayer_Configure"]
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
margin_left = 21.0
|
||||||
|
margin_top = 93.0
|
||||||
|
margin_right = 271.0
|
||||||
|
margin_bottom = 193.0
|
||||||
|
text = "Join Server"
|
||||||
|
|
||||||
|
[node name="Room_Password" type="LineEdit" parent="Multiplayer_Configure"]
|
||||||
|
margin_left = 388.0
|
||||||
|
margin_top = 311.0
|
||||||
|
margin_right = 638.0
|
||||||
|
margin_bottom = 361.0
|
||||||
|
text = "Room Password"
|
||||||
|
align = 1
|
||||||
|
|
||||||
|
[node name="Player_Name" type="LineEdit" parent="Multiplayer_Configure"]
|
||||||
|
margin_left = 387.0
|
||||||
|
margin_top = 164.0
|
||||||
|
margin_right = 637.0
|
||||||
|
margin_bottom = 214.0
|
||||||
|
text = "Player Name"
|
||||||
|
align = 1
|
||||||
|
|
||||||
|
[node name="Back" type="Button" parent="."]
|
||||||
|
margin_left = 235.0
|
||||||
|
margin_top = 394.0
|
||||||
|
margin_right = 485.0
|
||||||
|
margin_bottom = 494.0
|
||||||
|
text = "Back"
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
next_scene_path = "res://Network_Setup.tscn"
|
||||||
|
|
||||||
|
[connection signal="pressed" from="Multiplayer_Configure/Join_Server" to="." method="_on_Join_Server_pressed"]
|
||||||
|
[connection signal="button_up" from="Back" to="Back" method="_on_But_NewGame_button_up"]
|
Loading…
Reference in New Issue
Block a user